blob: e9ea067052f50c5d99c3b8e47cd02217e6a6ca50 [file] [log] [blame]
Kevin O'Connorf076a3e2008-02-25 22:25:15 -05001// Rom layout and bios assembler to C interface.
2//
3// Copyright (C) 2008 Kevin O'Connor <kevin@koconnor.net>
4// Copyright (C) 2002 MandrakeSoft S.A.
5//
6// This file may be distributed under the terms of the GNU GPLv3 license.
7
8#include "config.h"
9
Kevin O'Connor38fcbfe2008-02-25 22:30:47 -050010
11/****************************************************************
12 * Include of 16bit C code
13 ****************************************************************/
14
Kevin O'Connor74534532008-05-12 18:28:58 -040015 .code16gcc
16.include "out/blob.16.s"
Kevin O'Connorf076a3e2008-02-25 22:25:15 -050017
18
Kevin O'Connor38fcbfe2008-02-25 22:30:47 -050019/****************************************************************
Kevin O'Connor1d019512008-03-11 21:21:47 -040020 * Entry macros
Kevin O'Connor38fcbfe2008-02-25 22:30:47 -050021 ****************************************************************/
22
Kevin O'Connor1d019512008-03-11 21:21:47 -040023 // Call a C function - this does the minimal work necessary to
24 // call into C. It sets up %ds, backs up %es, and backs up
25 // those registers that are call clobbered by the C compiler.
26 .macro ENTRY cfunc
27 cld
Kevin O'Connor18f368e2008-03-31 21:56:04 -040028 pushl %eax // Save registers clobbered by C code
Kevin O'Connor1d019512008-03-11 21:21:47 -040029 pushl %ecx
30 pushl %edx
31 pushw %es
32 pushw %ds
Kevin O'Connor18f368e2008-03-31 21:56:04 -040033 movw %ss, %ax // Move %ss to %ds
Kevin O'Connor1d019512008-03-11 21:21:47 -040034 movw %ax, %ds
Kevin O'Connorb3c28be2008-06-08 13:34:43 -040035 pushl %esp // Backup %esp, then clear high bits
36 movzwl %sp, %esp
Kevin O'Connor1d019512008-03-11 21:21:47 -040037 calll \cfunc
Kevin O'Connorb3c28be2008-06-08 13:34:43 -040038 popl %esp // Restore %esp (including high bits)
Kevin O'Connor18f368e2008-03-31 21:56:04 -040039 popw %ds // Restore registers saved above
Kevin O'Connor1d019512008-03-11 21:21:47 -040040 popw %es
41 popl %edx
42 popl %ecx
43 popl %eax
44 .endm
45
46 // Call a C function with current register list as an
47 // argument. This backs up the registers and sets %eax
48 // to point to the backup. On return, the registers are
49 // restored from the structure.
50 .macro ENTRY_ARG cfunc
51 cld
Kevin O'Connor18f368e2008-03-31 21:56:04 -040052 pushl %eax // Save registers (matches struct bregs)
Kevin O'Connor1d019512008-03-11 21:21:47 -040053 pushl %ecx
54 pushl %edx
55 pushl %ebx
56 pushl %esi
57 pushl %edi
58 pushw %es
59 pushw %ds
Kevin O'Connor18f368e2008-03-31 21:56:04 -040060 movw %ss, %ax // Move %ss to %ds
Kevin O'Connor1d019512008-03-11 21:21:47 -040061 movw %ax, %ds
Kevin O'Connorb3c28be2008-06-08 13:34:43 -040062 movl %esp, %ebx // Backup %esp, then zero high bits
63 movzwl %sp, %esp
64 movl %esp, %eax // First arg is pointer to struct bregs
65 calll \cfunc
66 movl %ebx, %esp // Restore %esp (including high bits)
67 popw %ds // Restore registers (from struct bregs)
68 popw %es
69 popl %edi
70 popl %esi
71 popl %ebx
72 popl %edx
73 popl %ecx
74 popl %eax
75 .endm
76
77 // As above, but don't mangle %esp
78 .macro ENTRY_ARG_ESP cfunc
79 cld
80 pushl %eax // Save registers (matches struct bregs)
81 pushl %ecx
82 pushl %edx
83 pushl %ebx
84 pushl %esi
85 pushl %edi
86 pushw %es
87 pushw %ds
88 movw %ss, %ax // Move %ss to %ds
89 movw %ax, %ds
Kevin O'Connor18f368e2008-03-31 21:56:04 -040090 movl %esp, %eax // First arg is pointer to struct bregs
Kevin O'Connor1d019512008-03-11 21:21:47 -040091 calll \cfunc
Kevin O'Connor18f368e2008-03-31 21:56:04 -040092 popw %ds // Restore registers (from struct bregs)
Kevin O'Connor1d019512008-03-11 21:21:47 -040093 popw %es
94 popl %edi
95 popl %esi
96 popl %ebx
97 popl %edx
98 popl %ecx
99 popl %eax
100 .endm
101
Kevin O'Connorbdce35f2008-02-26 21:33:14 -0500102 // Macro to reset the 16bit stack
103 // Clobbers %ax
104 .macro RESET_STACK
Kevin O'Connor38fcbfe2008-02-25 22:30:47 -0500105 xorw %ax, %ax
106 movw %ax, %ss
Kevin O'Connor276d4a92008-06-11 22:47:01 -0400107 movl $ BUILD_STACK_ADDR , %esp
Kevin O'Connor44eeaf12008-07-06 10:14:49 -0400108 cld
Kevin O'Connorbdce35f2008-02-26 21:33:14 -0500109 .endm
110
Kevin O'Connor74534532008-05-12 18:28:58 -0400111 // Specify a location in the fixed part of bios area.
112 .macro ORG addr
113 .section .text.fixed.addr
Kevin O'Connor276d4a92008-06-11 22:47:01 -0400114 .org \addr - BUILD_START_FIXED
Kevin O'Connor74534532008-05-12 18:28:58 -0400115 .endm
116
Kevin O'Connor1d019512008-03-11 21:21:47 -0400117
118/****************************************************************
119 * POST handler
120 ****************************************************************/
121
Kevin O'Connor74534532008-05-12 18:28:58 -0400122 ORG 0xe05b
Kevin O'Connorbdce35f2008-02-26 21:33:14 -0500123post16:
Kevin O'Connor50cf4f12008-10-25 23:06:23 -0400124 // enable cache
125 movl %cr0, %eax
126 andl $0x9fffffff, %eax
127 movl %eax, %cr0
128
Kevin O'Connorbdce35f2008-02-26 21:33:14 -0500129 // init the stack pointer
130 RESET_STACK
Kevin O'Connorf076a3e2008-02-25 22:25:15 -0500131
Kevin O'Connor2fda7cb2008-07-05 20:41:53 -0400132 pushl $_code32__start
Kevin O'Connorf076a3e2008-02-25 22:25:15 -0500133
Kevin O'Connor38fcbfe2008-02-25 22:30:47 -0500134 // Fall through to transition32 function below
Kevin O'Connorf076a3e2008-02-25 22:25:15 -0500135
Kevin O'Connor38fcbfe2008-02-25 22:30:47 -0500136
137/****************************************************************
138 * Call trampolines
139 ****************************************************************/
140
141// Place CPU into 32bit mode from 16bit mode.
142// Clobbers: %eax, flags, stack registers, cr0, idt/gdt
Kevin O'Connorf076a3e2008-02-25 22:25:15 -0500143transition32:
144 // Disable irqs
145 cli
146
147 // enable a20
148 inb $0x92, %al
149 orb $0x02, %al
150 outb %al, $0x92
151
152 // Set segment descriptors
153 lidt %cs:pmode_IDT_info
154 lgdt %cs:rombios32_gdt_48
155
156 // set PE bit in CR0
157 movl %cr0, %eax
158 orb $0x01, %al
159 movl %eax, %cr0
160
161 // start protected mode code
Kevin O'Connor14927082008-11-08 19:07:49 -0500162 ljmpl $SEG32_MODE32_CS, $(BUILD_BIOS_ADDR + 1f)
Kevin O'Connorf076a3e2008-02-25 22:25:15 -0500163
164 .code32
1651:
166 // init data segments
Kevin O'Connor14927082008-11-08 19:07:49 -0500167 movl $SEG32_MODE32_DS, %eax
Kevin O'Connorf076a3e2008-02-25 22:25:15 -0500168 movw %ax, %ds
169 movw %ax, %es
170 movw %ax, %ss
171 xorl %eax, %eax
172 movw %ax, %fs
173 movw %ax, %gs
174
Kevin O'Connor38fcbfe2008-02-25 22:30:47 -0500175 retl
176
177// Call a 16bit function from 32bit mode.
Kevin O'Connorcb6735f2008-03-01 13:39:52 -0500178// %eax = address of struct bregs
Kevin O'Connor38fcbfe2008-02-25 22:30:47 -0500179// Clobbers: all gp registers, flags, stack registers, cr0, idt/gdt
Kevin O'Connor2fda7cb2008-07-05 20:41:53 -0400180 .global __call16_from32
Kevin O'Connor38fcbfe2008-02-25 22:30:47 -0500181__call16_from32:
182 pushl %eax
183
184 // Jump to 16bit mode
Kevin O'Connor14927082008-11-08 19:07:49 -0500185 ljmpw $SEG32_MODE16_CS, $1f
Kevin O'Connorf076a3e2008-02-25 22:25:15 -0500186
187 .code16gcc
Kevin O'Connor38fcbfe2008-02-25 22:30:47 -05001881:
Kevin O'Connorf076a3e2008-02-25 22:25:15 -0500189 // restore data segment limits to 0xffff
Kevin O'Connor14927082008-11-08 19:07:49 -0500190 movw $SEG32_MODE16_DS, %ax
Kevin O'Connorf076a3e2008-02-25 22:25:15 -0500191 movw %ax, %ds
192 movw %ax, %es
193 movw %ax, %ss
194 movw %ax, %fs
195 movw %ax, %gs
196
197 // reset PE bit in CR0
198 movl %cr0, %eax
199 andb $0xfe, %al
200 movl %eax, %cr0
201
202 // far jump to flush CPU queue after transition to real mode
Kevin O'Connore3677b12008-07-04 15:29:23 -0400203 ljmpw $SEG_BIOS, $2f
Kevin O'Connor21e930b2008-03-01 09:49:37 -0500204
Kevin O'Connor38fcbfe2008-02-25 22:30:47 -05002052:
Kevin O'Connorf076a3e2008-02-25 22:25:15 -0500206 // restore IDT to normal real-mode defaults
207 lidt %cs:rmode_IDT_info
208
Kevin O'Connor38fcbfe2008-02-25 22:30:47 -0500209 // Clear segment registers
Kevin O'Connorf076a3e2008-02-25 22:25:15 -0500210 xorw %ax, %ax
Kevin O'Connorf076a3e2008-02-25 22:25:15 -0500211 movw %ax, %fs
212 movw %ax, %gs
Kevin O'Connorf076a3e2008-02-25 22:25:15 -0500213 movw %ax, %es
Kevin O'Connor38fcbfe2008-02-25 22:30:47 -0500214 movw %ax, %ds
215 movw %ax, %ss // Assume stack is in segment 0
Kevin O'Connorf076a3e2008-02-25 22:25:15 -0500216
Kevin O'Connorf076a3e2008-02-25 22:25:15 -0500217 popl %eax
Kevin O'Connor18f368e2008-03-31 21:56:04 -0400218
219 // Set __call16 return address to be transition32
Kevin O'Connor38fcbfe2008-02-25 22:30:47 -0500220 pushl $transition32
Kevin O'Connorf076a3e2008-02-25 22:25:15 -0500221
Kevin O'Connor38fcbfe2008-02-25 22:30:47 -0500222 // Fall through to __call16
Kevin O'Connorf076a3e2008-02-25 22:25:15 -0500223
Kevin O'Connorf076a3e2008-02-25 22:25:15 -0500224
Kevin O'Connor21e930b2008-03-01 09:49:37 -0500225// Call a 16bit function from 16bit mode with a specified cpu register state
Kevin O'Connor38fcbfe2008-02-25 22:30:47 -0500226// %eax = address of struct bregs
227// Clobbers: all gp registers, es
Kevin O'Connor2fda7cb2008-07-05 20:41:53 -0400228 .global __call16
Kevin O'Connor38fcbfe2008-02-25 22:30:47 -0500229__call16:
230 // Save eax
231 pushl %eax
232
233 // Setup for iretw call
Kevin O'Connore3677b12008-07-04 15:29:23 -0400234 pushw $SEG_BIOS
Kevin O'Connor38fcbfe2008-02-25 22:30:47 -0500235 pushw $1f // return point
Kevin O'Connor1d019512008-03-11 21:21:47 -0400236 pushw 0x20(%eax) // flags
237 pushl 0x1c(%eax) // CS:IP
Kevin O'Connor38fcbfe2008-02-25 22:30:47 -0500238
239 // Load calling registers.
240 movl 0x04(%eax), %edi
241 movl 0x08(%eax), %esi
Kevin O'Connor1d019512008-03-11 21:21:47 -0400242 movl 0x0c(%eax), %ebx
243 movl 0x10(%eax), %edx
244 movl 0x14(%eax), %ecx
Kevin O'Connor38fcbfe2008-02-25 22:30:47 -0500245 movw 0x02(%eax), %es // XXX - should load %ds too
Kevin O'Connor1d019512008-03-11 21:21:47 -0400246 movl 0x18(%eax), %eax
Kevin O'Connor38fcbfe2008-02-25 22:30:47 -0500247
248 // Invoke call
249 iretw // XXX - just do a lcalll
2501:
251 // Store flags, eax, ecx
252 pushfw
253 pushl %eax
254 movl 0x06(%esp), %eax
Kevin O'Connor1d019512008-03-11 21:21:47 -0400255 movl %ecx, %ss:0x14(%eax) // Save %ecx
Kevin O'Connorcbbb6672008-03-08 13:04:10 -0500256 movw %ss, %cx
257 movw %cx, %ds // Restore %ds == %ss
Kevin O'Connor38fcbfe2008-02-25 22:30:47 -0500258 popl %ecx
Kevin O'Connor1d019512008-03-11 21:21:47 -0400259 movl %ecx, 0x18(%eax) // Save %eax
Kevin O'Connor38fcbfe2008-02-25 22:30:47 -0500260 popw %cx
Kevin O'Connor1d019512008-03-11 21:21:47 -0400261 movw %cx, 0x20(%eax) // Save flags
Kevin O'Connor38fcbfe2008-02-25 22:30:47 -0500262
263 // Store remaining registers
264 movw %es, 0x02(%eax)
265 movl %edi, 0x04(%eax)
266 movl %esi, 0x08(%eax)
Kevin O'Connor1d019512008-03-11 21:21:47 -0400267 movl %ebx, 0x0c(%eax)
268 movl %edx, 0x10(%eax)
Kevin O'Connor38fcbfe2008-02-25 22:30:47 -0500269
270 // Remove %eax
271 popl %eax
272
Kevin O'Connored128492008-03-11 11:14:59 -0400273 cld
274
Kevin O'Connor38fcbfe2008-02-25 22:30:47 -0500275 retl
276
Kevin O'Connor18f368e2008-03-31 21:56:04 -0400277
278// APM trampolines
Kevin O'Connor2fda7cb2008-07-05 20:41:53 -0400279 .global apm16protected_entry
Kevin O'Connor1d019512008-03-11 21:21:47 -0400280apm16protected_entry:
281 pushfw // save flags
282 pushl %eax // dummy
283 ENTRY_ARG handle_1553
Kevin O'Connorb3c28be2008-06-08 13:34:43 -0400284 addw $4, %sp // pop dummy
Kevin O'Connor1d019512008-03-11 21:21:47 -0400285 popfw // restore flags
286 lretw
287
288 .code32
Kevin O'Connor2fda7cb2008-07-05 20:41:53 -0400289 .global apm32protected_entry
Kevin O'Connor1d019512008-03-11 21:21:47 -0400290apm32protected_entry:
Kevin O'Connor68296e82008-03-13 21:33:26 -0400291 pushfw
292 pushw %cs // Setup for long jump to 16bit mode
293 pushw $1f
Kevin O'Connor0fae9e12008-06-07 14:51:14 -0400294 addw $8, 2(%esp)
Kevin O'Connor68296e82008-03-13 21:33:26 -0400295 ljmpw *(%esp)
296 .code16gcc
2971:
Kevin O'Connorb3c28be2008-06-08 13:34:43 -0400298 ENTRY_ARG_ESP handle_1553
Kevin O'Connor68296e82008-03-13 21:33:26 -0400299
300 movw $2f,(%esp) // Setup for long jump back to 32bit mode
Kevin O'Connor0fae9e12008-06-07 14:51:14 -0400301 subw $8, 2(%esp)
Kevin O'Connor68296e82008-03-13 21:33:26 -0400302 ljmpw *(%esp)
303 .code32
3042:
Kevin O'Connor1d019512008-03-11 21:21:47 -0400305 addl $4, %esp // pop call address
306 popfw
307 lretl
Kevin O'Connoree4f9ff2008-07-05 21:19:10 -0400308
309// 32bit elf entry point
310 .global post32
311post32:
312 cli
313 cld
314 lidtl (BUILD_BIOS_ADDR + pmode_IDT_info)
315 lgdtl (BUILD_BIOS_ADDR + rombios32_gdt_48)
316 movl $BUILD_STACK_ADDR, %esp
Kevin O'Connor14927082008-11-08 19:07:49 -0500317 ljmpl $SEG32_MODE32_CS, $_code32__start
Kevin O'Connoree4f9ff2008-07-05 21:19:10 -0400318
Kevin O'Connor1d019512008-03-11 21:21:47 -0400319 .code16gcc
Kevin O'Connor1d019512008-03-11 21:21:47 -0400320
Kevin O'Connor484270d2008-08-17 10:50:57 -0400321// Shutdown a CPU. We want this in the 0xf000 section to ensure that
322// the code wont be overwritten with something else. (Should
323// something spurious wake up the CPU, we want to be sure that the hlt
324// insn will still be present and will shutdown the CPU.)
325 .global permanent_halt
326permanent_halt:
327 cli
3281: hlt
329 jmp 1b
330
Kevin O'Connor38fcbfe2008-02-25 22:30:47 -0500331
332/****************************************************************
333 * GDT and IDT tables
334 ****************************************************************/
Kevin O'Connorf076a3e2008-02-25 22:25:15 -0500335
336// Protected mode IDT descriptor
337//
338// I just make the limit 0, so the machine will shutdown
339// if an exception occurs during protected mode memory
340// transfers.
341//
342// Set base to f0000 to correspond to beginning of BIOS,
343// in case I actually define an IDT later
344// Set limit to 0
345pmode_IDT_info:
346 .word 0x0000 // limit 15:00
Kevin O'Connorddd4bfd2008-02-28 20:00:20 -0500347 .long 0xf0000 // base 16:47
Kevin O'Connorf076a3e2008-02-25 22:25:15 -0500348
349// Real mode IDT descriptor
350//
351// Set to typical real-mode values.
352// base = 000000
353// limit = 03ff
354rmode_IDT_info:
355 .word 0x03ff // limit 15:00
Kevin O'Connorddd4bfd2008-02-28 20:00:20 -0500356 .long 0 // base 16:47
Kevin O'Connorf076a3e2008-02-25 22:25:15 -0500357
358rombios32_gdt_48:
359 .word 0x30
360 .word rombios32_gdt
361 .word 0x000f
362
Kevin O'Connor44c631d2008-03-02 11:24:36 -0500363 .balign 8
Kevin O'Connorf076a3e2008-02-25 22:25:15 -0500364rombios32_gdt:
365 .word 0, 0, 0, 0
366 .word 0, 0, 0, 0
Kevin O'Connor14927082008-11-08 19:07:49 -0500367 // 32 bit flat code segment (SEG32_MODE32_CS)
Kevin O'Connorcb6735f2008-03-01 13:39:52 -0500368 .word 0xffff, 0, 0x9b00, 0x00cf
Kevin O'Connor14927082008-11-08 19:07:49 -0500369 // 32 bit flat data segment (SEG32_MODE32_DS)
Kevin O'Connorcb6735f2008-03-01 13:39:52 -0500370 .word 0xffff, 0, 0x9300, 0x00cf
Kevin O'Connor14927082008-11-08 19:07:49 -0500371 // 16 bit code segment base=0xf0000 limit=0xffff (SEG32_MODE16_CS)
Kevin O'Connorcb6735f2008-03-01 13:39:52 -0500372 .word 0xffff, 0, 0x9b0f, 0x0000
Kevin O'Connor14927082008-11-08 19:07:49 -0500373 // 16 bit data segment base=0x0 limit=0xffff (SEG32_MODE16_DS)
Kevin O'Connorcb6735f2008-03-01 13:39:52 -0500374 .word 0xffff, 0, 0x9300, 0x0000
Kevin O'Connorf076a3e2008-02-25 22:25:15 -0500375
Kevin O'Connorccaf1c52008-07-06 09:30:47 -0400376// We need a copy of this string in the 0xf000 segment, but we are not
377// actually a PnP BIOS, so make sure it is *not* aligned, so OSes will
378// not see it if they scan.
379 .global pnp_string
380 .balign 2
381 .byte 0
382pnp_string:
383 .ascii "$PnP"
384
Kevin O'Connor38fcbfe2008-02-25 22:30:47 -0500385
386/****************************************************************
387 * Interrupt entry points
388 ****************************************************************/
Kevin O'Connorf076a3e2008-02-25 22:25:15 -0500389
Kevin O'Connored128492008-03-11 11:14:59 -0400390 // Define an entry point for an interrupt (no args passed).
Kevin O'Connorf076a3e2008-02-25 22:25:15 -0500391 .macro IRQ_ENTRY num
Kevin O'Connor2fda7cb2008-07-05 20:41:53 -0400392 .global entry_\num
Kevin O'Connorf076a3e2008-02-25 22:25:15 -0500393 entry_\num :
Kevin O'Connor44d65302008-03-08 11:34:46 -0500394 cli // In case something far-calls instead of using "int"
Kevin O'Connorf076a3e2008-02-25 22:25:15 -0500395 ENTRY handle_\num
396 iretw
397 .endm
398
Kevin O'Connored128492008-03-11 11:14:59 -0400399 // Define an entry point for an interrupt (can read/modify args).
400 .macro IRQ_ENTRY_ARG num
Kevin O'Connor2fda7cb2008-07-05 20:41:53 -0400401 .global entry_\num
Kevin O'Connored128492008-03-11 11:14:59 -0400402 entry_\num :
403 cli // In case something far-calls instead of using "int"
404 ENTRY_ARG handle_\num
405 iretw
406 .endm
407
Kevin O'Connor74534532008-05-12 18:28:58 -0400408 ORG 0xe2c3
Kevin O'Connorf076a3e2008-02-25 22:25:15 -0500409 IRQ_ENTRY nmi
410
Kevin O'Connored128492008-03-11 11:14:59 -0400411 IRQ_ENTRY_ARG 13
412 IRQ_ENTRY_ARG 12
413 IRQ_ENTRY_ARG 11
Kevin O'Connorf076a3e2008-02-25 22:25:15 -0500414 IRQ_ENTRY 76
Kevin O'Connorf076a3e2008-02-25 22:25:15 -0500415 IRQ_ENTRY 1c
416 IRQ_ENTRY 70
Kevin O'Connorf076a3e2008-02-25 22:25:15 -0500417
Kevin O'Connor74534532008-05-12 18:28:58 -0400418 ORG 0xe3fe
Kevin O'Connorf076a3e2008-02-25 22:25:15 -0500419 jmp entry_13
420
Kevin O'Connor74534532008-05-12 18:28:58 -0400421 ORG 0xe401
Kevin O'Connorf076a3e2008-02-25 22:25:15 -0500422 // XXX - Fixed Disk Parameter Table
423
Kevin O'Connor74534532008-05-12 18:28:58 -0400424 ORG 0xe6f2
Kevin O'Connorf076a3e2008-02-25 22:25:15 -0500425 jmp entry_19
426
Kevin O'Connor74534532008-05-12 18:28:58 -0400427 ORG 0xe6f5
Kevin O'Connorf076a3e2008-02-25 22:25:15 -0500428.include "out/cbt.proc.16.s"
429 .text
430
Kevin O'Connor74534532008-05-12 18:28:58 -0400431 ORG 0xe729
Kevin O'Connorf076a3e2008-02-25 22:25:15 -0500432 // XXX - Baud Rate Generator Table
433
Kevin O'Connor74534532008-05-12 18:28:58 -0400434 ORG 0xe739
Kevin O'Connored128492008-03-11 11:14:59 -0400435 IRQ_ENTRY_ARG 14
436
Kevin O'Connor18f368e2008-03-31 21:56:04 -0400437 IRQ_ENTRY 74
Kevin O'Connor1d019512008-03-11 21:21:47 -0400438 IRQ_ENTRY 75
439
Kevin O'Connored128492008-03-11 11:14:59 -0400440 // int 18/19 are special - they reset the stack and do not return.
Kevin O'Connor2fda7cb2008-07-05 20:41:53 -0400441 .global entry_19
Kevin O'Connored128492008-03-11 11:14:59 -0400442entry_19:
443 RESET_STACK
Kevin O'Connor44eeaf12008-07-06 10:14:49 -0400444 pushl $_code32_handle_19
445 jmp transition32
Kevin O'Connored128492008-03-11 11:14:59 -0400446
Kevin O'Connor2fda7cb2008-07-05 20:41:53 -0400447 .global entry_18
Kevin O'Connored128492008-03-11 11:14:59 -0400448entry_18:
449 RESET_STACK
Kevin O'Connor44eeaf12008-07-06 10:14:49 -0400450 pushl $_code32_handle_18
451 jmp transition32
Kevin O'Connored128492008-03-11 11:14:59 -0400452
453 // IRQ trampolines
454 .macro IRQ_TRAMPOLINE num
Kevin O'Connor2fda7cb2008-07-05 20:41:53 -0400455 .global irq_trampoline_0x\num
Kevin O'Connored128492008-03-11 11:14:59 -0400456 irq_trampoline_0x\num :
457 int $0x\num
458 lretw
459 .endm
460
461 IRQ_TRAMPOLINE 02
462 IRQ_TRAMPOLINE 10
463 IRQ_TRAMPOLINE 13
464 IRQ_TRAMPOLINE 15
Kevin O'Connore0113c92008-04-05 15:51:12 -0400465 IRQ_TRAMPOLINE 16
Kevin O'Connored128492008-03-11 11:14:59 -0400466 IRQ_TRAMPOLINE 18
467 IRQ_TRAMPOLINE 19
468 IRQ_TRAMPOLINE 1c
469 IRQ_TRAMPOLINE 4a
Kevin O'Connorf076a3e2008-02-25 22:25:15 -0500470
Kevin O'Connor74534532008-05-12 18:28:58 -0400471 ORG 0xe82e
Kevin O'Connored128492008-03-11 11:14:59 -0400472 IRQ_ENTRY_ARG 16
Kevin O'Connorf076a3e2008-02-25 22:25:15 -0500473
Kevin O'Connorc541e1b2008-06-21 12:24:14 -0400474entry_hwirq:
475 ENTRY handle_hwirq
476
Kevin O'Connor74534532008-05-12 18:28:58 -0400477 ORG 0xe987
Kevin O'Connorf076a3e2008-02-25 22:25:15 -0500478 IRQ_ENTRY 09
479
Kevin O'Connor74534532008-05-12 18:28:58 -0400480 ORG 0xec59
Kevin O'Connored128492008-03-11 11:14:59 -0400481 IRQ_ENTRY_ARG 40
Kevin O'Connorf076a3e2008-02-25 22:25:15 -0500482
Kevin O'Connor74534532008-05-12 18:28:58 -0400483 ORG 0xef57
Kevin O'Connorf076a3e2008-02-25 22:25:15 -0500484 IRQ_ENTRY 0e
485
Kevin O'Connor74534532008-05-12 18:28:58 -0400486 ORG 0xefc7
Kevin O'Connor44c631d2008-03-02 11:24:36 -0500487.include "out/floppy_dbt.proc.16.s"
488 .text
Kevin O'Connorf076a3e2008-02-25 22:25:15 -0500489
Kevin O'Connor74534532008-05-12 18:28:58 -0400490 ORG 0xefd2
Kevin O'Connored128492008-03-11 11:14:59 -0400491 IRQ_ENTRY_ARG 17
Kevin O'Connorf076a3e2008-02-25 22:25:15 -0500492
Kevin O'Connor74534532008-05-12 18:28:58 -0400493 ORG 0xf045
Kevin O'Connorf076a3e2008-02-25 22:25:15 -0500494 // XXX int 10
495 iretw
496
Kevin O'Connor74534532008-05-12 18:28:58 -0400497 ORG 0xf065
Kevin O'Connored128492008-03-11 11:14:59 -0400498 IRQ_ENTRY_ARG 10
Kevin O'Connorf076a3e2008-02-25 22:25:15 -0500499
Kevin O'Connor74534532008-05-12 18:28:58 -0400500 ORG 0xf0a4
Kevin O'Connorf076a3e2008-02-25 22:25:15 -0500501 // XXX int 1D
502 iretw
503
Kevin O'Connor2fda7cb2008-07-05 20:41:53 -0400504 .global freespace2_start, freespace2_end
Kevin O'Connor38fcbfe2008-02-25 22:30:47 -0500505freespace2_start:
506
Kevin O'Connor74534532008-05-12 18:28:58 -0400507 ORG 0xf841
Kevin O'Connor38fcbfe2008-02-25 22:30:47 -0500508freespace2_end:
Kevin O'Connorf076a3e2008-02-25 22:25:15 -0500509 jmp entry_12
510
Kevin O'Connor74534532008-05-12 18:28:58 -0400511 ORG 0xf84d
Kevin O'Connorf076a3e2008-02-25 22:25:15 -0500512 jmp entry_11
513
Kevin O'Connor74534532008-05-12 18:28:58 -0400514 ORG 0xf859
Kevin O'Connored128492008-03-11 11:14:59 -0400515 IRQ_ENTRY_ARG 15
Kevin O'Connorf076a3e2008-02-25 22:25:15 -0500516
Kevin O'Connor74534532008-05-12 18:28:58 -0400517 ORG 0xfa6e
Kevin O'Connorf076a3e2008-02-25 22:25:15 -0500518.include "out/font.proc.16.s"
519 .text
520
Kevin O'Connor74534532008-05-12 18:28:58 -0400521 ORG 0xfe6e
Kevin O'Connored128492008-03-11 11:14:59 -0400522 IRQ_ENTRY_ARG 1a
Kevin O'Connorf076a3e2008-02-25 22:25:15 -0500523
Kevin O'Connor74534532008-05-12 18:28:58 -0400524 ORG 0xfea5
Kevin O'Connorf076a3e2008-02-25 22:25:15 -0500525 IRQ_ENTRY 08
526
Kevin O'Connor74534532008-05-12 18:28:58 -0400527 ORG 0xfef3
Kevin O'Connorf076a3e2008-02-25 22:25:15 -0500528 // XXX - Initial Interrupt Vector Offsets Loaded by POST
529
Kevin O'Connor74534532008-05-12 18:28:58 -0400530 ORG 0xff00
Kevin O'Connorf076a3e2008-02-25 22:25:15 -0500531 // XXX - BIOS_COPYRIGHT_STRING
532 .ascii "(c) 2002 MandrakeSoft S.A. Written by Kevin Lawton & the Bochs team."
533
Kevin O'Connor74534532008-05-12 18:28:58 -0400534 ORG 0xff53
Kevin O'Connor2fda7cb2008-07-05 20:41:53 -0400535 .global dummy_iret_handler
Kevin O'Connorf076a3e2008-02-25 22:25:15 -0500536dummy_iret_handler:
537 iretw
538
Kevin O'Connor74534532008-05-12 18:28:58 -0400539 ORG 0xff54
Kevin O'Connored128492008-03-11 11:14:59 -0400540 IRQ_ENTRY_ARG 05
Kevin O'Connorf076a3e2008-02-25 22:25:15 -0500541
Kevin O'Connor74534532008-05-12 18:28:58 -0400542 ORG 0xfff0 // Power-up Entry Point
Kevin O'Connore3677b12008-07-04 15:29:23 -0400543 ljmpw $SEG_BIOS, $post16
Kevin O'Connorf076a3e2008-02-25 22:25:15 -0500544
Kevin O'Connor74534532008-05-12 18:28:58 -0400545 ORG 0xfff5
Kevin O'Connorf076a3e2008-02-25 22:25:15 -0500546 // BIOS build date
547 .ascii "06/23/99"
548
Kevin O'Connor74534532008-05-12 18:28:58 -0400549 ORG 0xfffe
Kevin O'Connor44c631d2008-03-02 11:24:36 -0500550 .byte CONFIG_MODEL_ID
Kevin O'Connore3677b12008-07-04 15:29:23 -0400551
Kevin O'Connor2fda7cb2008-07-05 20:41:53 -0400552 .global bios_checksum
Kevin O'Connore3677b12008-07-04 15:29:23 -0400553bios_checksum:
Kevin O'Connorf076a3e2008-02-25 22:25:15 -0500554 .byte 0x00
555
556 .end