1 1.1 itohy | 2 1.1 itohy | execute NetBSD kernel 3 1.1 itohy | 4 1.4 itohy | written by ITOH Yasufumi 5 1.1 itohy | public domain 6 1.1 itohy | 7 1.4 itohy | $NetBSD: execkern.S,v 1.4 2011/02/21 02:31:58 itohy Exp $ 8 1.1 itohy 9 1.3 isaki #include <machine/asm.h> 10 1.3 isaki #include "execkern.h" 11 1.1 itohy 12 1.1 itohy #define MFP 0x00E88000 /* MFP */ 13 1.1 itohy #define MFP_IERA (MFP+0x07) /* (B) interrupt enable reg A */ 14 1.1 itohy #define MFP_IERB (MFP+0x09) /* (B) interrupt enable reg B */ 15 1.1 itohy #define MFP_RSR (MFP+0x2B) /* (B) USART receiver status reg */ 16 1.1 itohy 17 1.1 itohy #ifndef SRAM_MEMSZ 18 1.1 itohy #define SRAM 0x00ED0000 /* SRAM start addr */ 19 1.1 itohy #define SRAM_MEMSZ (SRAM + 8) /* (L) size of main memory */ 20 1.1 itohy #endif 21 1.1 itohy 22 1.3 isaki | a3+0 load address 23 1.3 isaki | 24 1.3 isaki | a3+4 section #1 image top address 25 1.3 isaki | a3+8 section #1 size 26 1.3 isaki | a3+12 section #1 gap size 27 1.3 isaki | : : 28 1.3 isaki | a3+n-12 section #XK_NSEC image top address 29 1.3 isaki | a3+n-8 section #XK_NSEC size 30 1.3 isaki | a3+n-4 section #XK_NSEC gap size 31 1.3 isaki | 32 1.3 isaki | a3+n (reserved) (d5) 33 1.3 isaki | a3+n+4 bootdev (d6) 34 1.3 isaki | a3+n+8 boothowto (d7) 35 1.3 isaki | a3+n+12 entry address (absolute address) 36 1.1 itohy 37 1.1 itohy #ifndef XK_NO_C_INTERFACE 38 1.1 itohy .text 39 1.1 itohy .even 40 1.2 minoura ENTRY_NOPROFILE(exec_kernel) 41 1.2 minoura addql #4,%sp 42 1.2 minoura moveal %sp@+,%a3 | struct execkern_arg * 43 1.1 itohy #endif 44 1.1 itohy 45 1.2 minoura moveal %a3@+,%a1 | load address 46 1.2 minoura movel %a1,%d3 47 1.1 itohy 48 1.1 itohy | 49 1.1 itohy | copy image 50 1.1 itohy | 51 1.1 itohy 52 1.3 isaki movel #XK_NSEC-1,%d2 53 1.3 isaki Lloop: 54 1.3 isaki moveal %a3@+,%a0 | section image address 55 1.3 isaki movel %a3@+,%d0 | section size 56 1.2 minoura movel %d0,%d1 57 1.1 itohy jbsr copy 58 1.3 isaki movel %a3@+,%d0 | section gap 59 1.1 itohy jbsr clear 60 1.1 itohy 61 1.3 isaki dbra %d2,Lloop 62 1.1 itohy 63 1.1 itohy | stop MFP interrupts (for compatibility) 64 1.1 itohy clrb MFP_IERA 65 1.1 itohy clrb MFP_IERB 66 1.1 itohy clrb MFP_RSR 67 1.1 itohy 68 1.1 itohy | 69 1.1 itohy | execute kernel 70 1.1 itohy | start(load_addr, mem_max, kernel_end) 71 1.1 itohy | 72 1.2 minoura movel %a1,%d0 73 1.2 minoura addql #3,%d0 74 1.2 minoura andib #0xFC,%d0 75 1.2 minoura subl %d3,%d0 76 1.3 isaki movel %d0,%sp@- | arg #3 (end of kernel) 77 1.2 minoura movel SRAM_MEMSZ,%sp@- | arg #2 (RAM size from SRAM) 78 1.2 minoura movel %d3,%sp@- | arg #1 (load address) 79 1.1 itohy 80 1.1 itohy #if 0 81 1.2 minoura movel %a3@+,%d5 | (reserved) 82 1.2 minoura movel %a3@+,%d6 | boot device 83 1.2 minoura movel %a3@+,%d7 | boot howto 84 1.1 itohy 85 1.2 minoura movel %a3@+,%a0 | entry address 86 1.1 itohy #else /* optimized */ 87 1.2 minoura moveml %a3@+,%d5-%d7/%a0 88 1.1 itohy #endif 89 1.1 itohy 90 1.1 itohy | clear unused registers 91 1.2 minoura moveq #0,%d0 92 1.2 minoura moveq #0,%d1 93 1.2 minoura moveq #0,%d2 94 1.2 minoura moveq #0,%d3 95 1.2 minoura moveq #0,%d4 96 1.2 minoura moveal %d0,%a1 97 1.2 minoura moveal %d0,%a2 98 1.2 minoura moveal %d0,%a3 99 1.2 minoura moveal %d0,%a4 100 1.2 minoura moveal %d0,%a5 101 1.2 minoura moveal %d0,%a6 102 1.1 itohy 103 1.2 minoura jsr %a0@ | execute NetBSD kernel 104 1.1 itohy | NOTREACHED 105 1.1 itohy 106 1.1 itohy | ??? returned from kernel -- issue software reset 107 1.2 minoura subal %a1,%a1 108 1.2 minoura moveml 0x00ff0000,#0x0101 | get RESET vectors (%d0: ssp, %a0: pc) 109 1.2 minoura moveml #0x0101,%a1@ | put them at 0x00000000 (for Xellent) 110 1.2 minoura .long 0x4E7B9801 | movec %a1,%vbr 111 1.2 minoura jmp %a0@ | go to reset address 112 1.1 itohy 113 1.1 itohy 114 1.1 itohy | 115 1.1 itohy | utility routines 116 1.1 itohy | 117 1.1 itohy 118 1.2 minoura | copy %d0 bytes from higher (%a0) to lower (%a1) address 119 1.2 minoura 1: moveb %a0@+,%a1@+ 120 1.2 minoura copy: subql #1,%d0 121 1.1 itohy bpls 1b 122 1.1 itohy rts 123 1.1 itohy 124 1.2 minoura | clear %d0 bytes at %a1 125 1.2 minoura | do nothing if %d0 is zero 126 1.2 minoura 1: clrb %a1@+ 127 1.2 minoura clear: subql #1,%d0 128 1.1 itohy bpls 1b 129 1.1 itohy rts 130