1 | /* |
---|
2 | * This file is the main boot and configuration file for the i386ex. It is |
---|
3 | * solely responsible for initializing the internal register set to reflect |
---|
4 | * the proper board configuration. This version is the "generic" i386ex |
---|
5 | * startup: |
---|
6 | * |
---|
7 | * 1) 512K flask ROM @3f80000 |
---|
8 | * 2) 1 Mb RAM @ 0x0 |
---|
9 | * 3) Timer0 used as RTEMS clock ticker, 1 msec tick rate. |
---|
10 | * 4) READY# is generated by CPU |
---|
11 | * |
---|
12 | * The file is a multi-section file, with sections as follows: |
---|
13 | * 1) interrupt gates, in section "ints" |
---|
14 | * 2) interrupt descriptor table, in section "idt" |
---|
15 | * 3) global descriptor table, in section "gdt" |
---|
16 | * 4) reset in section "reset" |
---|
17 | * 5) and initial boot code in section " initial" |
---|
18 | * |
---|
19 | * Submitted by: |
---|
20 | * |
---|
21 | * Erik Ivanenko |
---|
22 | * University of Toronto |
---|
23 | * erik.ivanenko@utoronto.ca |
---|
24 | * |
---|
25 | * The license and distribution terms for this file may be |
---|
26 | * found in the file LICENSE in this distribution or at |
---|
27 | * http://www.OARcorp.com/rtems/license.html. |
---|
28 | * |
---|
29 | * $Id$ |
---|
30 | */ |
---|
31 | |
---|
32 | #include "asm.h" |
---|
33 | #include "macros.inc" |
---|
34 | #include "80386ex.inc" |
---|
35 | |
---|
36 | /* |
---|
37 | * Needed for binutils 2.9.1.0.7 and higher |
---|
38 | * #define NEXT_GAS |
---|
39 | */ |
---|
40 | |
---|
41 | EXTERN (main) /* exits to bspstart */ |
---|
42 | EXTERN (stack_start) /* defined in startup/linkcmds */ |
---|
43 | |
---|
44 | .section .idt |
---|
45 | |
---|
46 | BEGIN_DATA |
---|
47 | PUBLIC (Interrupt_descriptor_table) |
---|
48 | PUBLIC(SYM(IDTR) ) |
---|
49 | SYM(IDTR): DESC3( SYM(IDT), 0x188 ); |
---|
50 | SYM (Interrupt_descriptor_table): |
---|
51 | SYM(IDT): |
---|
52 | SYM(GATE_DIVIDE_ERROR): INTERRUPT_GATE( DIVIDE_ERROR ); |
---|
53 | SYM(GATE_DEBUG_EXCEPTION): INTERRUPT_GATE( DEBUG_EXCEPTION ); |
---|
54 | SYM(GATE_NMI_INTERRUPT): INTERRUPT_GATE( NMI_INTERRUPT ); |
---|
55 | SYM(GATE_BREAKPOINT): INTERRUPT_GATE( BREAKPOINT ); |
---|
56 | SYM(GATE_INTO_OVERFLOW ): INTERRUPT_GATE( INTO_OVERFLOW ); |
---|
57 | SYM(GATE_BOUND_EXCEEDED ): INTERRUPT_GATE( BOUND_EXCEEDED ); |
---|
58 | SYM(GATE_INVALID_OPCODE ): INTERRUPT_GATE( INVALID_OPCODE ); |
---|
59 | SYM(GATE_COPRO_NA ): INTERRUPT_GATE( COPRO_NA ); |
---|
60 | SYM(GATE_DOUBLE_FAULT ): INTERRUPT_GATE( DOUBLE_FAULT ); |
---|
61 | SYM(GATE_COPRO_SEG_OVERRUN ): INTERRUPT_GATE( COPRO_SEG_OVERRUN ); |
---|
62 | SYM(GATE_INVALID_TSS ): INTERRUPT_GATE( INVALID_TSS ); |
---|
63 | SYM(GATE_SEGMENT_NOT_PRESENT ): INTERRUPT_GATE( SEGMENT_NOT_PRESENT ); |
---|
64 | SYM(GATE_STACK_FAULT ): INTERRUPT_GATE( STACK_FAULT ); |
---|
65 | SYM(GATE_GPF ): INTERRUPT_GATE( GPF ); |
---|
66 | SYM(GATE_PAGE_FAULT ): INTERRUPT_GATE( PAGE_FAULT ); |
---|
67 | SYM(GATE_RESERVED_1 ): INTERRUPT_GATE( RESERVED ); |
---|
68 | SYM(GATE_COPRO_ERROR ): INTERRUPT_GATE( COPRO_ERROR ); |
---|
69 | SYM(GATE_RESERVED_17): INTERRUPT_GATE( RESERVED_17 ); |
---|
70 | SYM(GATE_RESERVED_18): INTERRUPT_GATE( RESERVED_18 ); |
---|
71 | SYM(GATE_RESERVED_19): INTERRUPT_GATE( RESERVED_19 ); |
---|
72 | SYM(GATE_RESERVED_20): INTERRUPT_GATE( RESERVED_20 ); |
---|
73 | SYM(GATE_RESERVED_21): INTERRUPT_GATE( RESERVED_21 ); |
---|
74 | SYM(GATE_RESERVED_22): INTERRUPT_GATE( RESERVED_22 ); |
---|
75 | SYM(GATE_RESERVED_23): INTERRUPT_GATE( RESERVED_23 ); |
---|
76 | SYM(GATE_RESERVED_24): INTERRUPT_GATE( RESERVED_24 ); |
---|
77 | SYM(GATE_RESERVED_25): INTERRUPT_GATE( RESERVED_25 ); |
---|
78 | SYM(GATE_RESERVED_26): INTERRUPT_GATE( RESERVED_26 ); |
---|
79 | SYM(GATE_RESERVED_27): INTERRUPT_GATE( RESERVED_27 ); |
---|
80 | SYM(GATE_RESERVED_28): INTERRUPT_GATE( RESERVED_28 ); |
---|
81 | SYM(GATE_RESERVED_29): INTERRUPT_GATE( RESERVED_29 ); |
---|
82 | SYM(GATE_RESERVED_30): INTERRUPT_GATE( RESERVED_30 ); |
---|
83 | SYM(GATE_RESERVED_31): INTERRUPT_GATE( RESERVED_31 ); |
---|
84 | |
---|
85 | SYM ( GATE_TIMINT0): INTERRUPT_GATE( TIMINT0 ); |
---|
86 | SYM ( GATE_MASTER_IR2 ): INTERRUPT_GATE( MASTER_IR2 ); |
---|
87 | SYM ( GATE_SIOINT1 ): INTERRUPT_GATE( SIOINT1 ); |
---|
88 | SYM ( GATE_SIOINT2 ): INTERRUPT_GATE( SIOINT2 ); |
---|
89 | SYM ( GATE_DMAINT ): INTERRUPT_GATE( DMAINT ); |
---|
90 | SYM ( GATE_UNUSED_IR5 ): INTERRUPT_GATE( UNUSED_IR5); |
---|
91 | SYM ( GATE_UNUSED_IR6 ): INTERRUPT_GATE( UNUSED_IR6); |
---|
92 | SYM ( GATE_UNUSED_IR7 ): INTERRUPT_GATE( UNUSED_IR7); |
---|
93 | SYM ( GATE_SLAVE_IR0 ): INTERRUPT_GATE( SLAVE_IR0 ); |
---|
94 | SYM ( GATE_SLAVE_IR1 ): INTERRUPT_GATE( SLAVE_IR1 ); |
---|
95 | SYM ( GATE_SLAVE_IR2 ): INTERRUPT_GATE( SLAVE_IR2 ); |
---|
96 | SYM ( GATE_SLAVE_IR3 ): INTERRUPT_GATE( SLAVE_IR3 ); |
---|
97 | SYM ( GATE_SLAVE_IR4 ): INTERRUPT_GATE( SLAVE_IR4 ); |
---|
98 | SYM ( GATE_SLAVE_IR5 ): INTERRUPT_GATE( SLAVE_IR5 ); |
---|
99 | SYM ( GATE_SLAVE_IR6 ): INTERRUPT_GATE( SLAVE_IR6 ); |
---|
100 | SYM ( GATE_SLAVE_IR7 ): INTERRUPT_GATE( SLAVE_IR7 ); |
---|
101 | END_DATA |
---|
102 | |
---|
103 | .section .gdt |
---|
104 | BEGIN_DATA |
---|
105 | PUBLIC (_Global_descriptor_table) |
---|
106 | |
---|
107 | SYM(GDTR): DESC3( GDT_TABLE, 0x1f ); # one less than the size |
---|
108 | SYM (_Global_descriptor_table): |
---|
109 | SYM(GDT): |
---|
110 | SYM(GDT_TABLE): DESC2(0,0,0,0,0,0); |
---|
111 | SYM(GDT_ALIAS): DESC2(32,0x1000,0x0,0x93,0,0x0); |
---|
112 | SYM(GDT_CODE): DESC2(0xffff,0,0x0,0x9B,0xDF,0x00); |
---|
113 | SYM(GDT_DATA): DESC2(0xffff,0,0x0,0x92,0xDF,0x00); # was CF |
---|
114 | SYM(GDT_END): |
---|
115 | |
---|
116 | END_DATA |
---|
117 | |
---|
118 | |
---|
119 | /* This section is the section that is used by the interrupt |
---|
120 | descriptor table. It is used to provide the IDT with the |
---|
121 | correct vector offsets. It is for symbol definition only. |
---|
122 | */ |
---|
123 | |
---|
124 | .section .ints |
---|
125 | |
---|
126 | SYM(INTERRUPT_HANDLERS): |
---|
127 | SYM(DIVIDE_ERROR): jmp SYM(DIVIDE_ERROR) |
---|
128 | SYM(DEBUG_EXCEPTION): jmp SYM(DEBUG_EXCEPTION) |
---|
129 | SYM(NMI_INTERRUPT): jmp SYM(NMI_INTERRUPT) |
---|
130 | SYM(BREAKPOINT): jmp SYM(BREAKPOINT) |
---|
131 | SYM(INTO_OVERFLOW): jmp SYM(INTO_OVERFLOW) |
---|
132 | SYM(BOUND_EXCEEDED): jmp SYM(BOUND_EXCEEDED) |
---|
133 | SYM(INVALID_OPCODE): jmp SYM(INVALID_OPCODE) |
---|
134 | SYM(COPRO_NA): jmp SYM(COPRO_NA) |
---|
135 | SYM(DOUBLE_FAULT): jmp SYM(DOUBLE_FAULT) |
---|
136 | SYM(COPRO_SEG_OVERRUN): jmp SYM(COPRO_SEG_OVERRUN) |
---|
137 | SYM(INVALID_TSS): jmp SYM(INVALID_TSS) |
---|
138 | SYM(RESERVED): JMP SYM(RESERVED) |
---|
139 | SYM(COPRO_ERROR): JMP SYM(COPRO_ERROR) |
---|
140 | SYM(PAGE_FAULT): JMP SYM(PAGE_FAULT) |
---|
141 | SYM(GPF): JMP SYM(GPF) |
---|
142 | SYM(STACK_FAULT): JMP SYM(STACK_FAULT) |
---|
143 | SYM(SEGMENT_NOT_PRESENT): jmp SYM(SEGMENT_NOT_PRESENT) |
---|
144 | SYM(RESERVED_17): jmp SYM(RESERVED_17) |
---|
145 | SYM(RESERVED_18): jmp SYM(RESERVED_18) |
---|
146 | SYM(RESERVED_19): jmp SYM(RESERVED_19) |
---|
147 | SYM(RESERVED_20): jmp SYM(RESERVED_20) |
---|
148 | SYM(RESERVED_21): jmp SYM(RESERVED_21) |
---|
149 | SYM(RESERVED_22): jmp SYM(RESERVED_22) |
---|
150 | SYM(RESERVED_23): jmp SYM(RESERVED_23) |
---|
151 | SYM(RESERVED_24): jmp SYM(RESERVED_24) |
---|
152 | SYM(RESERVED_25): jmp SYM(RESERVED_25) |
---|
153 | SYM(RESERVED_26): jmp SYM(RESERVED_26) |
---|
154 | SYM(RESERVED_27): jmp SYM(RESERVED_27) |
---|
155 | SYM(RESERVED_28): jmp SYM(RESERVED_28) |
---|
156 | SYM(RESERVED_29): jmp SYM(RESERVED_29) |
---|
157 | SYM(RESERVED_30): jmp SYM(RESERVED_30) |
---|
158 | SYM(RESERVED_31): jmp SYM(RESERVED_31) |
---|
159 | SYM(TIMINT0): nop; iret |
---|
160 | SYM(MASTER_IR2): jmp SYM(MASTER_IR2) |
---|
161 | SYM(SIOINT1): jmp SYM(SIOINT1) |
---|
162 | SYM(SIOINT2): jmp SYM(SIOINT2) |
---|
163 | SYM(DMAINT): jmp SYM(DMAINT) |
---|
164 | SYM(UNUSED_IR5): jmp SYM(UNUSED_IR5) |
---|
165 | SYM(UNUSED_IR6): JMP SYM(UNUSED_IR6) |
---|
166 | SYM(UNUSED_IR7): JMP SYM(UNUSED_IR7) |
---|
167 | SYM(SLAVE_IR0): JMP SYM(SLAVE_IR0) |
---|
168 | SYM(SLAVE_IR1): JMP SYM(SLAVE_IR1) |
---|
169 | SYM(SLAVE_IR2): nop; iret |
---|
170 | SYM(SLAVE_IR3): JMP SYM(SLAVE_IR3) |
---|
171 | SYM(SLAVE_IR4): JMP SYM(SLAVE_IR4) |
---|
172 | SYM(SLAVE_IR5): JMP SYM(SLAVE_IR5) |
---|
173 | SYM(SLAVE_IR6): JMP SYM(SLAVE_IR6) |
---|
174 | SYM(SLAVE_IR7): JMP SYM(SLAVE_IR7) |
---|
175 | |
---|
176 | PUBLIC( SYM(_initInternalRegisters) ) |
---|
177 | |
---|
178 | |
---|
179 | .section .reset |
---|
180 | |
---|
181 | PUBLIC ( SYM(reset) ) |
---|
182 | SYM(reset): |
---|
183 | .code16 |
---|
184 | nop |
---|
185 | cli |
---|
186 | #ifdef NEXT_GAS |
---|
187 | addr32 |
---|
188 | #endif |
---|
189 | jmp SYM(_initInternalRegisters) /* different section in this file */ |
---|
190 | .code32 /* in case this section moves */ |
---|
191 | nop /* required by CHIP LAB to pad out size */ |
---|
192 | nop |
---|
193 | nop |
---|
194 | nop |
---|
195 | nop |
---|
196 | |
---|
197 | .section .initial |
---|
198 | |
---|
199 | /* |
---|
200 | * Enable access to peripheral register at expanded I/O addresses |
---|
201 | */ |
---|
202 | SYM(_initInternalRegisters): |
---|
203 | .code16 |
---|
204 | movw $0x8000 , ax |
---|
205 | outb al , $REMAPCFGH |
---|
206 | xchg al , ah |
---|
207 | outb al,$REMAPCFGL |
---|
208 | outw ax, $REMAPCFG ; |
---|
209 | |
---|
210 | |
---|
211 | /* |
---|
212 | * Configure operation of the A20 Address Line |
---|
213 | */ |
---|
214 | SYM(A20): |
---|
215 | movw $PORT92 , dx |
---|
216 | |
---|
217 | inb dx , al # clear A20 port reset |
---|
218 | andb $0xfe , al # b0 Fast Reset(0)=disabled,(1)=reset triggered |
---|
219 | orb $0x02 , al # Bit 1 Fast A20 = 0 (always 0) else enabled. |
---|
220 | outb al , dx |
---|
221 | |
---|
222 | SYM(Watchdog): |
---|
223 | SetExRegByte( WDTSTATUS, 0x01 ) # disable watchdog timer |
---|
224 | |
---|
225 | /* |
---|
226 | * Initialize Refresh Control Unit for: |
---|
227 | * Refresh Address = 0x0000 |
---|
228 | |
---|
229 | * Refresh gate between rows is 15.6 uSec |
---|
230 | * Using a CLK2 frequency of 50Mhz ( 25Mhz CPU ) |
---|
231 | * The refresh unit is enabled |
---|
232 | * The refresh pin is not used. |
---|
233 | */ |
---|
234 | |
---|
235 | SYM(InitRCU): |
---|
236 | SetExRegWord( RFSCIR , 390) # refresh interval was 390, tried 312 |
---|
237 | SetExRegWord( RFSBAD , 0x0) # base address |
---|
238 | SetExRegWord( RFSADD , 0x0) # address register |
---|
239 | SetExRegWord( RFSCON , 0x8000) # enable bit |
---|
240 | |
---|
241 | /* |
---|
242 | * Initialize clock and power mgmt unit for: |
---|
243 | * Clock Frequency = 50 Mhz |
---|
244 | * Prescaled clock output = 1.19318 Mhz |
---|
245 | * ( matches standard PC ) |
---|
246 | * Normal halt instructions |
---|
247 | */ |
---|
248 | |
---|
249 | SYM(InitClk): |
---|
250 | SetExRegByte( PWRCON, 0x0 ) |
---|
251 | SetExRegWord( CLKPRS, 0x13) |
---|
252 | |
---|
253 | /************************************************************** |
---|
254 | * Initialize the Pin Configurations |
---|
255 | *************************************************************/ |
---|
256 | |
---|
257 | /* |
---|
258 | * Initialize I/O port 1 for: |
---|
259 | * PIN 0 = 1, DCD0# to package pin |
---|
260 | * PIN 1 = 1, RTS0# to package pin |
---|
261 | * PIN 2 = 1, DTR0# to package pin |
---|
262 | * PIN 3 = 1, DSR0# to package pin |
---|
263 | * PIN 4 = 1, RI0# to package pin |
---|
264 | * PIN 5 = 0, Outport (FLASH Vpp Enable, 0=Enable 1=Disable) |
---|
265 | * PIN 6 = 0, Outport (P16_HOLD to 386ex option header JP7 pin 5) |
---|
266 | * PIN 7 = 0, Outport (P17_HOLD to 386ex option header JP7 pin 3) |
---|
267 | */ |
---|
268 | |
---|
269 | SYM(InitPort1): |
---|
270 | SetExRegByte( P1LTC , 0xff ) |
---|
271 | SetExRegByte( P1DIR , 0x0 ) |
---|
272 | SetExRegByte( P1CFG , 0x1f) |
---|
273 | |
---|
274 | /* |
---|
275 | * Initialize I/O port 2 for: |
---|
276 | * PIN 0 = 0, Outport (P20_CS0# to 386ex option header JP7 pin 11) |
---|
277 | * PIN 1 = 0, Outport (P21_CS1# to 386ex option header JP7 pin 9) |
---|
278 | * PIN 2 = 1, CS2# (SMRAM) If not using CS2 can be configured as.? |
---|
279 | * PIN 3 = 0, Outport ( no connect ) |
---|
280 | * PIN 4 = 1, CS#4 (DRAM) |
---|
281 | * PIN 5 = 1, RXD0 input. See not for I/0 port 1 pins 1-4 |
---|
282 | * PIN 6 = 1, TXD0 output. |
---|
283 | * PIN 7 = 1, CTS0# input. |
---|
284 | */ |
---|
285 | |
---|
286 | SYM(InitPort2): |
---|
287 | SetExRegByte( P2LTC , 0xff ) |
---|
288 | SetExRegByte( P2DIR , 0x0 ) |
---|
289 | SetExRegByte( P2CFG , 0xfe) |
---|
290 | |
---|
291 | /* |
---|
292 | * Initialize I/O port 3 P3CFG |
---|
293 | * PIN 0 = 1, TMROUT0 to package pin |
---|
294 | * PIN 1 = 0, (TMROUT1 to 386ex option header JP7 pin 23) |
---|
295 | * PIN 2 = 0, INT0 (IR1) disabled, (P3.2 out to JP7 pin 21) |
---|
296 | * PIN 3 = 0, INT1 (IR5) disbled (P3.3 to option header JP7 pin 19) |
---|
297 | * PIN 4 = 0, INT2 (IR6) disbled (P3.4 to option header JP7 pin 17) |
---|
298 | * PIN 5 = 0, INT2 (IR7) disabled (P3.5 to 386ex header JP7 pin 15) |
---|
299 | * PIN 6 = 0, Inport (Debugger Break P3.6/PWRD to package pin ) |
---|
300 | * P3.6 selected |
---|
301 | * PIN 7 = 0, COMCLK output disabled, 1.8432 Mhz OSC1 oscillator. |
---|
302 | * ( Debbugger uses COMCLK as the clocking source ) |
---|
303 | * P3.7 connected to package pin. |
---|
304 | */ |
---|
305 | |
---|
306 | SYM(InitPort3): |
---|
307 | SetExRegByte( P3LTC , 0xff ) |
---|
308 | SetExRegByte( P3DIR , 0x41 ) |
---|
309 | SetExRegByte( P3CFG , 0x09 ) # can check TMROUT0 |
---|
310 | /* |
---|
311 | * Initialize Peripheral Pin Configurations: |
---|
312 | * PIN 0 = 1, RTS1# to package pin |
---|
313 | * PIN 1 = 1, DTR1# to package pin |
---|
314 | * PIN 2 = 1, TXD1 out to package pin |
---|
315 | * PIN 3 = 0, EOP#/TC |
---|
316 | * PIN 4 = 0, DACK0# |
---|
317 | * PIN 5 = 1, Timer2 |
---|
318 | * PIN 6 = 0, 0 => CS6# connected to package pin |
---|
319 | * PIN 7 = 0, Don't care |
---|
320 | */ |
---|
321 | |
---|
322 | SYM(InitPeriph): |
---|
323 | SetExRegByte( PINCFG , 0x24) |
---|
324 | |
---|
325 | /* |
---|
326 | * Initialize the Asynchronous Serial Ports: |
---|
327 | * BIT 7 = 1, Internal SIO1 modem signals |
---|
328 | * BIT 6 = 1, Internal SIO0 modem signals |
---|
329 | * BIT 2 = 0, PSCLK for SSIO clock |
---|
330 | * BIT 1 = 1, SERCLK for SIO1 clock |
---|
331 | * BIT 0 = 1, SERCLK for SIO0 clock |
---|
332 | */ |
---|
333 | |
---|
334 | SYM(InitSIO): |
---|
335 | SetExRegByte( SIOCFG, 0xC3 ) # SIOn clocked internally |
---|
336 | |
---|
337 | SetExRegByte( LCR0, 0x80 ) # latch DLL0, DLH0 |
---|
338 | SetExRegByte( DLL0, 0x51 ) # 0x51 sets to 9600 baud 0x7 -> 115,200 |
---|
339 | SetExRegByte( DLH0, 0x00 ) # 0x145 is 2400 baud |
---|
340 | SetExRegByte( LCR0, 0x03 ) # enable r/w buffers, IER0 accessible |
---|
341 | # mode 8-n-1 |
---|
342 | SetExRegByte( IER0, 0x00 ) # was 0x0f All interrupts detected |
---|
343 | |
---|
344 | SetExRegByte( LCR1, 0x80 ) # latch DLL0, DLH0 |
---|
345 | SetExRegByte( DLL1, 0x51 ) # 0x51 set to 9600 baud, 0x7 = 115200 |
---|
346 | SetExRegByte( DLH1, 0x00 ) # 0x145 is 2400 baud |
---|
347 | SetExRegByte( LCR1, 0x03 ) # enable r/w buffers, IER1 accessible |
---|
348 | # reg 8-n-1 |
---|
349 | SetExRegByte( IER1, 0x00 ) # was 0x0f - All interrupts detected |
---|
350 | |
---|
351 | SYM(InitMCR): |
---|
352 | /* |
---|
353 | * Initialize Timer for: |
---|
354 | * BIT 7 = 1, Timer clocks disabled |
---|
355 | * BIT 6 = 0, Reserved |
---|
356 | * BIT 5 = 1, TMRCLK2 instead of Vcc to Gate2 |
---|
357 | * BIT 4 = 0, PSCLK to CLK2 |
---|
358 | * BIT 3 = 1, TMRCLK1 instead of Vcc to Gate1 |
---|
359 | * BIT 2 = 0, PSCLK to Gate1 |
---|
360 | * BIT 1 = 0, Vcc to Gate0 |
---|
361 | * BIT 0 = 0, PSCLK to Gate0 |
---|
362 | */ |
---|
363 | |
---|
364 | SYM(InitTimer): |
---|
365 | SetExRegByte(TMRCFG , 0x80 ) # All counters disabled, Gates 0,1 |
---|
366 | # and 2 are set to Vcc |
---|
367 | |
---|
368 | SetExRegByte(TMRCON , 0x34 ) # prepare to write counter 0 LSB,MSB |
---|
369 | SetExRegByte(TMR0 , 0xA8 ) # LSB = 0B count, followed by MSB |
---|
370 | SetExRegByte(TMR0 , 0x04 ) # for INT every 50 msec. MSB = 0xE900 |
---|
371 | # for INT every 5 msec. 0x174c |
---|
372 | # for INT every 1 msec. 0x04A8 |
---|
373 | # was 0xe900 |
---|
374 | |
---|
375 | SetExRegByte(TMRCON , 0x70 ) # mode 0 disables on Gate= Vcc |
---|
376 | SetExRegByte(TMR1 , 0x00 ) # sfa |
---|
377 | SetExRegByte(TMR1 , 0x00 ) # sfa |
---|
378 | |
---|
379 | SetExRegByte(TMRCON , 0xB0 ) # mode 0 disables on gate =Vcc |
---|
380 | SetExRegByte(TMR2 , 0x00 ) # |
---|
381 | SetExRegByte(TMR2 , 0x00 ) # |
---|
382 | SetExRegByte(TMRCFG , 0x80 ) # Enable timers = 0x00 |
---|
383 | |
---|
384 | |
---|
385 | /* |
---|
386 | * Initialize the DMACFG register for: |
---|
387 | * BIT 7 = 1 , Disable DACK#1 |
---|
388 | * BITs 6:4 = 100, TMROUT2 connected to DRQ1 |
---|
389 | * BIT 3 = 1 , Disable DACK0# |
---|
390 | * BIT 2:0 = 000, Pin is connected to DRQ0 |
---|
391 | */ |
---|
392 | |
---|
393 | SetExRegByte(DMACFG , 0xC0 ) |
---|
394 | SetExRegByte(DMACMD1, 0x00 ) # disable both DMA channels |
---|
395 | SetExRegByte(DMAMOD1, 0x40 ) |
---|
396 | /* |
---|
397 | * Initialize the INTCFG register for: |
---|
398 | * BIT 7 = 0, 8259 cascade disabled |
---|
399 | * BIT 3 = 0, SLAVE IR6 connected to Vss |
---|
400 | * BIT 2 = 0, SLAVE IR5 connected to Vss |
---|
401 | * BIT 1 = 0, SLAVE IR1 connected to SSIOINT |
---|
402 | * BIT 0 = 0, SLAVE IR0 connected to Vss |
---|
403 | */ |
---|
404 | |
---|
405 | SYM(InitInt): |
---|
406 | |
---|
407 | cli # ! |
---|
408 | |
---|
409 | SetExRegByte(ICW1S , 0x11 ) # EDGE TRIGGERED |
---|
410 | SetExRegByte(ICW2S , 0x28 ) # Slave base vector after Master |
---|
411 | SetExRegByte(ICW3S , 0x04 ) # ( was 0x02! )slave cascaded to IR2 on master |
---|
412 | SetExRegByte(ICW4S , 0x01 ) # must be 0x01 |
---|
413 | |
---|
414 | SetExRegByte(ICW1M , 0x11 ) # edge triggered |
---|
415 | SetExRegByte(ICW2M , 0x20 ) # base vector starts at byte 32 |
---|
416 | SetExRegByte(ICW3M , 0x02 ) # IR2 is cascaded internally |
---|
417 | SetExRegByte(ICW4M , 0x01 ) # idem |
---|
418 | |
---|
419 | SetExRegByte(OCW1M , 0xde ) # IR0 only = 0xfe. for IR5 and IR0 active use 0xde |
---|
420 | SetExRegByte(INTCFG , 0x00 ) |
---|
421 | |
---|
422 | SYM(SetCS4): |
---|
423 | SetExRegWord(CS4ADL , 0x702) #Configure chip select 4 |
---|
424 | SetExRegWord(CS4ADH , 0x00) |
---|
425 | SetExRegWord(CS4MSKH, 0x03F) |
---|
426 | SetExRegWord(CS4MSKL, 0xFC01) |
---|
427 | |
---|
428 | SYM(SetUCS1): |
---|
429 | SetExRegWord(UCSADL , 0x0304) # 512K block starting at 0x80000 until 0x3f80000 |
---|
430 | SetExRegWord(UCSADH , 0x03F8) |
---|
431 | SetExRegWord(UCSMSKH, 0x03F7) |
---|
432 | SetExRegWord(UCSMSKL, 0xFC01) # configure upper chip select |
---|
433 | |
---|
434 | SYM(xfer_idt): |
---|
435 | movw $ _ram_idt_offset , di |
---|
436 | movw $ _ram_idt_segment , cx |
---|
437 | mov cx, es |
---|
438 | |
---|
439 | movw $ _rom_idt_offset , si |
---|
440 | movw $ _rom_idt_segment , ax |
---|
441 | mov ax , ds |
---|
442 | |
---|
443 | movw $ _idt_size , cx |
---|
444 | |
---|
445 | repne |
---|
446 | movsb |
---|
447 | |
---|
448 | SYM(xfer_ints): |
---|
449 | |
---|
450 | movw $ _ram_ints_offset , di |
---|
451 | movw $ _ram_ints_segment , ax |
---|
452 | mov ax , es |
---|
453 | |
---|
454 | movw $ _rom_ints_offset , si |
---|
455 | movw $ _rom_ints_segment, ax |
---|
456 | mov ax , ds |
---|
457 | |
---|
458 | movw $ _ints_size , cx |
---|
459 | |
---|
460 | repne |
---|
461 | movsb |
---|
462 | |
---|
463 | SYM(lidt): |
---|
464 | movw $ _ram_idt_offset , di |
---|
465 | movw $ 0x0 , si |
---|
466 | |
---|
467 | movw $ _ram_idt_segment , ax |
---|
468 | |
---|
469 | mov ax , ds |
---|
470 | lidt _ram_idt_offset |
---|
471 | SYM(xfer_gdt): |
---|
472 | movw $ _ram_gdt_offset , di |
---|
473 | movw $ _ram_gdt_segment , cx |
---|
474 | mov cx , es |
---|
475 | |
---|
476 | movw $ _gdt_size , cx |
---|
477 | movw $ _rom_gdt_segment , ax |
---|
478 | movw $ _rom_gdt_offset , si |
---|
479 | mov ax , ds |
---|
480 | |
---|
481 | repne |
---|
482 | movsb |
---|
483 | |
---|
484 | /***************************** |
---|
485 | * Load the Global Descriptor |
---|
486 | * Table Register |
---|
487 | ****************************/ |
---|
488 | |
---|
489 | movw $ _ram_gdt_segment, ax |
---|
490 | mov ax , ds |
---|
491 | #ifdef NEXT_GAS |
---|
492 | data32 |
---|
493 | addr32 |
---|
494 | #endif |
---|
495 | lgdt _ram_gdt_offset # location of GDT |
---|
496 | |
---|
497 | |
---|
498 | SYM(SetUCS): |
---|
499 | SetExRegWord(UCSADL, 0x0704) # now 512K starting at 0x3f80000. |
---|
500 | SetExRegWord(UCSADH, 0x03f8) |
---|
501 | SetExRegWord(UCSMSKH, 0x0007) |
---|
502 | SetExRegWord(UCSMSKL, 0xFC01) # configure upper chip select |
---|
503 | |
---|
504 | /*************************** |
---|
505 | * Switch to Protected Mode |
---|
506 | ***************************/ |
---|
507 | mov cr0, eax |
---|
508 | orw $0x1, ax |
---|
509 | mov eax, cr0 |
---|
510 | |
---|
511 | /************************** |
---|
512 | * Flush prefetch queue, |
---|
513 | * and load CS selector |
---|
514 | *********************/ |
---|
515 | |
---|
516 | ljmpl $ GDT_CODE_PTR , $ SYM(_copy_data) # sets the code selector |
---|
517 | /* |
---|
518 | * Copy the data section down to RAM |
---|
519 | */ |
---|
520 | SYM(_copy_data): |
---|
521 | .code32 |
---|
522 | pLOAD_SEGMENT( GDT_DATA_PTR, fs) |
---|
523 | pLOAD_SEGMENT( GDT_DATA_PTR, gs) |
---|
524 | pLOAD_SEGMENT( GDT_DATA_PTR, ss) |
---|
525 | pLOAD_SEGMENT( GDT_DATA_PTR, ds) |
---|
526 | pLOAD_SEGMENT( GDT_DATA_PTR, es) |
---|
527 | |
---|
528 | movl $ SYM(_data_start) , edi # ram destination |
---|
529 | movl $ SYM(_rom_data_start) , esi # rom data source |
---|
530 | movl $ SYM(_edata) , ecx # end of data section |
---|
531 | subl $ SYM(_data_start) , ecx # length of data section |
---|
532 | # es, ds preloaded |
---|
533 | repne # while ecx != 0 |
---|
534 | movsb # move a byte |
---|
535 | |
---|
536 | /* |
---|
537 | * Set up the stack |
---|
538 | */ |
---|
539 | |
---|
540 | SYM (_establish_stack): |
---|
541 | movl $end, eax # stack starts right after bss |
---|
542 | /* movl eax, stack_start # save for brk() routine */ |
---|
543 | movl $stack_origin, esp # this is the high starting address |
---|
544 | movl $stack_origin, ebp |
---|
545 | /* |
---|
546 | * Zero out the BSS segment |
---|
547 | */ |
---|
548 | SYM (zero_bss): |
---|
549 | cld # make direction flag count up |
---|
550 | movl $ SYM (end),ecx # find end of .bss |
---|
551 | movl $ SYM (_bss_start),edi # edi = beginning of .bss |
---|
552 | subl edi,ecx # ecx = size of .bss in bytes |
---|
553 | shrl ecx # size of .bss in longs |
---|
554 | shrl ecx |
---|
555 | xorl eax,eax # value to clear out memory |
---|
556 | repne # while ecx != 0 |
---|
557 | stosl # clear a long in the bss |
---|
558 | |
---|
559 | /* |
---|
560 | * Transfer control to User's Board Support Package |
---|
561 | */ |
---|
562 | pushl $0 # environp |
---|
563 | pushl $0 # argv |
---|
564 | pushl $0 # argc |
---|
565 | call SYM (main) # does not return |
---|
566 | addl $12,esp |
---|
567 | |
---|
568 | BEGIN_DATA_DCL |
---|
569 | |
---|
570 | /* .align 2 |
---|
571 | PUBLIC (start_frame) |
---|
572 | SYM (start_frame): |
---|
573 | .long 0 |
---|
574 | */ |
---|
575 | /* PUBLIC (stack_start) |
---|
576 | SYM (stack_start): |
---|
577 | .long 0 |
---|
578 | */ |
---|
579 | |
---|
580 | END_DATA_DCL |
---|
581 | |
---|
582 | END |
---|