execkern.S revision 1.1 1 |
2 | execute NetBSD kernel
3 |
4 | written by Yasha (ITOH Yasufumi)
5 | public domain
6 |
7 | $NetBSD: execkern.S,v 1.1 1998/09/01 19:51:56 itohy Exp $
8
9 /* XXX this value is from <machine/exec_aout.h> */
10 #define __LDPGSZ 8192
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 kernel image top address (a.out header is excluded)
23 | a3+4 load address
24 | a3+8 text size
25 | a3+12 data size
26 | a3+16 bss size
27 | a3+20 symbol size
28 | a3+24 (reserved) (d5)
29 | a3+28 bootdev (d6)
30 | a3+32 boothowto (d7)
31 | a3+36 entry address (absolute address)
32
33 #ifndef XK_NO_C_INTERFACE
34 .text
35 .even
36 .globl _exec_kernel
37 _exec_kernel:
38 addql #4,sp
39 moveal sp@+,a3 | struct execkern_arg *
40 #endif
41
42 moveal a3@+,a0 | image address
43 moveal a3@+,a1 | load address
44 movel a1,d3
45
46 |
47 | copy image
48 |
49
50 | copy text segment
51 movel a3@+,d0 | text size
52 movel d0,d1
53 jbsr copy
54
55 | clear gap between text and data
56 negl d1
57 andil #__LDPGSZ-1,d1
58 movel d1,d0 | gap size between text and data
59 jbsr clear
60
61 | copy data segment
62 movel a3@+,d0 | data size
63 jbsr copy
64
65 | clear bss
66 movel a3@+,d0 | bss size
67 jbsr clear
68
69 | copy symbol table
70 movel a3@+,d0 | symbol table size
71 movel d0,a1@+
72 beqs Lnotable
73 jbsr copy
74
75 | copy string table size
76 movel a0@+,d0
77 movel d0,a1@+
78 beqs Lnotable
79
80 | copy string table
81 subql #4,d0 | table size is already copied
82 jbsr copy
83
84 Lnotable:
85
86 | stop MFP interrupts (for compatibility)
87 clrb MFP_IERA
88 clrb MFP_IERB
89 clrb MFP_RSR
90
91 |
92 | execute kernel
93 | start(load_addr, mem_max, kernel_end)
94 |
95 movel a1,d0
96 addql #3,d0
97 andib #0xFC,d0
98 subl d3,d0
99 movel d0,sp@- | arg #3 (kernel size)
100 movel SRAM_MEMSZ,sp@- | arg #2 (RAM size from SRAM)
101 movel d3,sp@- | arg #1 (load address)
102
103 #if 0
104 movel a3@+,d5 | (reserved)
105 movel a3@+,d6 | boot device
106 movel a3@+,d7 | boot howto
107
108 movel a3@+,a0 | entry address
109 #else /* optimized */
110 moveml a3@+,d5-d7/a0
111 #endif
112
113 | clear unused registers
114 moveq #0,d0
115 moveq #0,d1
116 moveq #0,d2
117 moveq #0,d3
118 moveq #0,d4
119 moveal d0,a1
120 moveal d0,a2
121 moveal d0,a3
122 moveal d0,a4
123 moveal d0,a5
124 moveal d0,a6
125
126 jsr a0@ | execute NetBSD kernel
127 | NOTREACHED
128
129 | ??? returned from kernel -- issue software reset
130 subal a1,a1
131 moveml 0x00ff0000,#0x0101 | get RESET vectors (d0: ssp, a0: pc)
132 moveml #0x0101,a1@ | put them at 0x00000000 (for Xellent)
133 .long 0x4E7B9801 | movec a1,vbr
134 jmp a0@ | go to reset address
135
136
137 |
138 | utility routines
139 |
140
141 | copy d0 bytes from higher (a0) to lower (a1) address
142 1: moveb a0@+,a1@+
143 copy: subql #1,d0
144 bpls 1b
145 rts
146
147 | clear d0 bytes at a1
148 | do nothing if d0 is zero
149 1: clrb a1@+
150 clear: subql #1,d0
151 bpls 1b
152 rts
153