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