1 2#if defined(CONFIG_RAM32MB) 3#define MEM_END 0x02000000 /* Memory size 32Mb */ 4#elif defined(CONFIG_RAM16MB) 5#define MEM_END 0x01000000 /* Memory size 16Mb */ 6#else 7#define MEM_END 0x00800000 /* Memory size 8Mb */ 8#endif 9 10#undef CRT_DEBUG 11 12.macro PUTC CHAR 13#ifdef CRT_DEBUG 14 moveq #\CHAR, %d7 15 jsr putc 16#endif 17.endm 18 19 .global _start 20 .global _rambase 21 .global _ramvec 22 .global _ramstart 23 .global _ramend 24 25 .data 26 27/* 28 * Set up the usable of RAM stuff 29 */ 30_rambase: 31 .long 0 32_ramvec: 33 .long 0 34_ramstart: 35 .long 0 36_ramend: 37 .long 0 38 39 .text 40 41_start: 42 43/* 44 * Setup initial stack 45 */ 46 /* disable all interrupts */ 47 movew #0x2700, %sr 48 movel #-1, 0xfffff304 49 movel #MEM_END-4, %sp 50 51 PUTC '\r' 52 PUTC '\n' 53 PUTC 'A' 54 PUTC 'B' 55 56/* 57 * Determine end of RAM 58 */ 59 60 movel #MEM_END, %a0 61 movel %a0, _ramend 62 63 PUTC 'C' 64 65/* 66 * Move ROM filesystem above bss :-) 67 */ 68 69 moveal #_sbss, %a0 /* romfs at the start of bss */ 70 moveal #_ebss, %a1 /* Set up destination */ 71 movel %a0, %a2 /* Copy of bss start */ 72 73 movel 8(%a0), %d1 /* Get size of ROMFS */ 74 addql #8, %d1 /* Allow for rounding */ 75 andl #0xfffffffc, %d1 /* Whole words */ 76 77 addl %d1, %a0 /* Copy from end */ 78 addl %d1, %a1 /* Copy from end */ 79 movel %a1, _ramstart /* Set start of ram */ 80 811: 82 movel -(%a0), %d0 /* Copy dword */ 83 movel %d0, -(%a1) 84 cmpl %a0, %a2 /* Check if at end */ 85 bne 1b 86 87 PUTC 'D' 88 89/* 90 * Initialize BSS segment to 0 91 */ 92 93 lea _sbss, %a0 94 lea _ebss, %a1 95 96 /* Copy 0 to %a0 until %a0 == %a1 */ 972: cmpal %a0, %a1 98 beq 1f 99 clrl (%a0)+ 100 bra 2b 1011: 102 103 PUTC 'E' 104 105/* 106 * Load the current task pointer and stack 107 */ 108 109 lea init_thread_union, %a0 110 lea 0x2000(%a0), %sp 111 112 PUTC 'F' 113 PUTC '\r' 114 PUTC '\n' 115 116/* 117 * Go 118 */ 119 120 jmp start_kernel 121 122/* 123 * Local functions 124 */ 125 126#ifdef CRT_DEBUG 127putc: 128 moveb %d7, 0xfffff907 1291: 130 movew 0xfffff906, %d7 131 andw #0x2000, %d7 132 beq 1b 133 rts 134#endif 135