blob: 7a14a7f639b4c8d14492257bab2847691bf923e5 [file] [log] [blame]
Kevin O'Connorf076a3e2008-02-25 22:25:15 -05001// Rom layout and bios assembler to C interface.
2//
Kevin O'Connorf8e176c2009-05-06 23:33:32 -04003// Copyright (C) 2008,2009 Kevin O'Connor <kevin@koconnor.net>
Kevin O'Connorf076a3e2008-02-25 22:25:15 -05004// Copyright (C) 2002 MandrakeSoft S.A.
5//
Kevin O'Connorb1b7c2a2009-01-15 20:52:58 -05006// This file may be distributed under the terms of the GNU LGPLv3 license.
Kevin O'Connorf076a3e2008-02-25 22:25:15 -05007
Kevin O'Connor38fcbfe2008-02-25 22:30:47 -05008
9/****************************************************************
10 * Include of 16bit C code
11 ****************************************************************/
12
Kevin O'Connor74534532008-05-12 18:28:58 -040013 .code16gcc
Kevin O'Connor9e821222008-12-06 18:56:19 -050014.include "out/ccode.16.s"
Kevin O'Connorf076a3e2008-02-25 22:25:15 -050015
Kevin O'Connorf8e176c2009-05-06 23:33:32 -040016#include "config.h" // CONFIG_*
17#include "ioport.h" // PORT_A20
18#include "bregs.h" // CR0_*
19#include "cmos.h" // CMOS_RESET_CODE
20#include "../out/asm-offsets.h" // BREGS_*
21#include "entryfuncs.S" // ENTRY_*
Kevin O'Connor74534532008-05-12 18:28:58 -040022
Kevin O'Connor1d019512008-03-11 21:21:47 -040023
24/****************************************************************
Kevin O'Connor38fcbfe2008-02-25 22:30:47 -050025 * Call trampolines
26 ****************************************************************/
27
28// Place CPU into 32bit mode from 16bit mode.
Kevin O'Connor4057f982010-11-25 08:52:50 -050029// %edx = return location (in 32bit mode)
Kevin O'Connorad901592009-12-13 11:25:25 -050030// Clobbers: ecx, flags, segment registers, cr0, idt/gdt
Kevin O'Connord67a7032009-01-17 19:37:26 -050031 DECLFUNC transition32
Kevin O'Connorf076a3e2008-02-25 22:25:15 -050032transition32:
Kevin O'Connorad901592009-12-13 11:25:25 -050033 movl %eax, %ecx
Kevin O'Connor9caf7862009-02-27 20:14:05 -050034
Kevin O'Connorf094ba82009-04-13 19:30:27 -040035 // Disable irqs (and clear direction flag)
36 cli
37 cld
38
39 // Disable nmi
40 movl $CMOS_RESET_CODE|NMI_DISABLE_BIT, %eax
41 outb %al, $PORT_CMOS_INDEX
42 inb $PORT_CMOS_DATA, %al
43
Kevin O'Connorf076a3e2008-02-25 22:25:15 -050044 // enable a20
Kevin O'Connord9a8b2d2008-11-16 09:17:02 -050045 inb $PORT_A20, %al
46 orb $A20_ENABLE_BIT, %al
47 outb %al, $PORT_A20
Kevin O'Connorf076a3e2008-02-25 22:25:15 -050048
49 // Set segment descriptors
Kevin O'Connor6e5b4a42008-12-06 13:03:52 -050050 lidtw %cs:pmode_IDT_info
51 lgdtw %cs:rombios32_gdt_48
Kevin O'Connorf076a3e2008-02-25 22:25:15 -050052
Kevin O'Connor3eac0092008-11-16 09:59:32 -050053 // Enable protected mode
54 movl %cr0, %eax
55 orl $CR0_PE, %eax
56 movl %eax, %cr0
Kevin O'Connorf076a3e2008-02-25 22:25:15 -050057
Kevin O'Connor6e5b4a42008-12-06 13:03:52 -050058 // start 32bit protected mode code
Kevin O'Connor14927082008-11-08 19:07:49 -050059 ljmpl $SEG32_MODE32_CS, $(BUILD_BIOS_ADDR + 1f)
Kevin O'Connorf076a3e2008-02-25 22:25:15 -050060
61 .code32
621:
63 // init data segments
Kevin O'Connor14927082008-11-08 19:07:49 -050064 movl $SEG32_MODE32_DS, %eax
Kevin O'Connorf076a3e2008-02-25 22:25:15 -050065 movw %ax, %ds
66 movw %ax, %es
67 movw %ax, %ss
Kevin O'Connorf076a3e2008-02-25 22:25:15 -050068 movw %ax, %fs
69 movw %ax, %gs
70
Kevin O'Connorad901592009-12-13 11:25:25 -050071 movl %ecx, %eax
Kevin O'Connor4057f982010-11-25 08:52:50 -050072 jmpl *%edx
Kevin O'Connor38fcbfe2008-02-25 22:30:47 -050073
Kevin O'Connor752151b2009-12-10 21:16:07 -050074// Place CPU into 16bit mode from 32bit mode.
Kevin O'Connor4057f982010-11-25 08:52:50 -050075// %edx = return location (in 16bit mode)
Kevin O'Connorad901592009-12-13 11:25:25 -050076// Clobbers: ecx, flags, segment registers, cr0, idt/gdt
Kevin O'Connor752151b2009-12-10 21:16:07 -050077 DECLFUNC transition16
78 .global transition16big
79transition16:
Kevin O'Connorad901592009-12-13 11:25:25 -050080 movl %eax, %ecx
Kevin O'Connor38fcbfe2008-02-25 22:30:47 -050081
Kevin O'Connorf076a3e2008-02-25 22:25:15 -050082 // restore data segment limits to 0xffff
Kevin O'Connor6e5b4a42008-12-06 13:03:52 -050083 movl $SEG32_MODE16_DS, %eax
Kevin O'Connorf076a3e2008-02-25 22:25:15 -050084 movw %ax, %ds
85 movw %ax, %es
86 movw %ax, %ss
87 movw %ax, %fs
88 movw %ax, %gs
89
Kevin O'Connorffb81a42009-04-13 19:44:55 -040090#if CONFIG_DISABLE_A20
Kevin O'Connor1a72e2e2008-11-11 22:03:55 -050091 // disable a20
Kevin O'Connord9a8b2d2008-11-16 09:17:02 -050092 inb $PORT_A20, %al
93 andb $~A20_ENABLE_BIT, %al
94 outb %al, $PORT_A20
Kevin O'Connorffb81a42009-04-13 19:44:55 -040095#endif
Kevin O'Connor1a72e2e2008-11-11 22:03:55 -050096
97 // Jump to 16bit mode
98 ljmpw $SEG32_MODE16_CS, $1f
99
Kevin O'Connor752151b2009-12-10 21:16:07 -0500100transition16big:
Kevin O'Connorad901592009-12-13 11:25:25 -0500101 movl %eax, %ecx
Kevin O'Connor6e5b4a42008-12-06 13:03:52 -0500102
103 movl $SEG32_MODE16BIG_DS, %eax
104 movw %ax, %ds
105 movw %ax, %es
106 movw %ax, %ss
107 movw %ax, %fs
108 movw %ax, %gs
109
Kevin O'Connor0f788892010-07-25 14:04:01 -0400110 ljmpw $SEG32_MODE16BIG_CS, $1f
Kevin O'Connor6e5b4a42008-12-06 13:03:52 -0500111
Kevin O'Connor1a72e2e2008-11-11 22:03:55 -0500112 .code16gcc
1131:
Kevin O'Connor3eac0092008-11-16 09:59:32 -0500114 // Disable protected mode
Kevin O'Connorf076a3e2008-02-25 22:25:15 -0500115 movl %cr0, %eax
Kevin O'Connor3eac0092008-11-16 09:59:32 -0500116 andl $~CR0_PE, %eax
Kevin O'Connorf076a3e2008-02-25 22:25:15 -0500117 movl %eax, %cr0
118
119 // far jump to flush CPU queue after transition to real mode
Kevin O'Connore3677b12008-07-04 15:29:23 -0400120 ljmpw $SEG_BIOS, $2f
Kevin O'Connor21e930b2008-03-01 09:49:37 -0500121
Kevin O'Connor38fcbfe2008-02-25 22:30:47 -05001222:
Kevin O'Connorf076a3e2008-02-25 22:25:15 -0500123 // restore IDT to normal real-mode defaults
Kevin O'Connor6e5b4a42008-12-06 13:03:52 -0500124 lidtw %cs:rmode_IDT_info
Kevin O'Connorf076a3e2008-02-25 22:25:15 -0500125
Kevin O'Connor38fcbfe2008-02-25 22:30:47 -0500126 // Clear segment registers
Kevin O'Connorf076a3e2008-02-25 22:25:15 -0500127 xorw %ax, %ax
Kevin O'Connorf076a3e2008-02-25 22:25:15 -0500128 movw %ax, %fs
129 movw %ax, %gs
Kevin O'Connorf076a3e2008-02-25 22:25:15 -0500130 movw %ax, %es
Kevin O'Connor38fcbfe2008-02-25 22:30:47 -0500131 movw %ax, %ds
132 movw %ax, %ss // Assume stack is in segment 0
Kevin O'Connorf076a3e2008-02-25 22:25:15 -0500133
Kevin O'Connorad901592009-12-13 11:25:25 -0500134 movl %ecx, %eax
Kevin O'Connor4057f982010-11-25 08:52:50 -0500135 jmpl *%edx
Kevin O'Connorf076a3e2008-02-25 22:25:15 -0500136
Kevin O'Connor21e930b2008-03-01 09:49:37 -0500137// Call a 16bit function from 16bit mode with a specified cpu register state
Kevin O'Connor38fcbfe2008-02-25 22:30:47 -0500138// %eax = address of struct bregs
Kevin O'Connor9caf7862009-02-27 20:14:05 -0500139// Clobbers: %e[bcd]x, %e[ds]i, flags
Kevin O'Connord67a7032009-01-17 19:37:26 -0500140 DECLFUNC __call16
Kevin O'Connor38fcbfe2008-02-25 22:30:47 -0500141__call16:
Kevin O'Connor9caf7862009-02-27 20:14:05 -0500142 // Save %eax, %ebp
143 pushl %ebp
Kevin O'Connor38fcbfe2008-02-25 22:30:47 -0500144 pushl %eax
145
146 // Setup for iretw call
Kevin O'Connor273e8ae2009-01-19 19:56:07 -0500147 pushw %cs
Kevin O'Connor38fcbfe2008-02-25 22:30:47 -0500148 pushw $1f // return point
Kevin O'Connor952974e2008-11-16 18:14:33 -0500149 pushw BREGS_flags(%eax) // flags
Kevin O'Connor9f985422009-09-09 11:34:39 -0400150 pushl BREGS_code(%eax) // CS:IP
Kevin O'Connor38fcbfe2008-02-25 22:30:47 -0500151
152 // Load calling registers.
Kevin O'Connor952974e2008-11-16 18:14:33 -0500153 movl BREGS_edi(%eax), %edi
154 movl BREGS_esi(%eax), %esi
Kevin O'Connor7da210c2009-05-16 23:57:08 -0400155 movl BREGS_ebp(%eax), %ebp
Kevin O'Connor952974e2008-11-16 18:14:33 -0500156 movl BREGS_ebx(%eax), %ebx
157 movl BREGS_edx(%eax), %edx
158 movl BREGS_ecx(%eax), %ecx
159 movw BREGS_es(%eax), %es
160 movw BREGS_ds(%eax), %ds
161 movl %ss:BREGS_eax(%eax), %eax
Kevin O'Connor38fcbfe2008-02-25 22:30:47 -0500162
163 // Invoke call
164 iretw // XXX - just do a lcalll
1651:
166 // Store flags, eax, ecx
167 pushfw
168 pushl %eax
169 movl 0x06(%esp), %eax
Kevin O'Connor952974e2008-11-16 18:14:33 -0500170 movl %ecx, %ss:BREGS_ecx(%eax)
171 movw %ds, %ss:BREGS_ds(%eax)
Kevin O'Connorcbbb6672008-03-08 13:04:10 -0500172 movw %ss, %cx
Kevin O'Connor952974e2008-11-16 18:14:33 -0500173 movw %cx, %ds // Restore %ds == %ss
Kevin O'Connor38fcbfe2008-02-25 22:30:47 -0500174 popl %ecx
Kevin O'Connor952974e2008-11-16 18:14:33 -0500175 movl %ecx, BREGS_eax(%eax)
Kevin O'Connor38fcbfe2008-02-25 22:30:47 -0500176 popw %cx
Kevin O'Connor952974e2008-11-16 18:14:33 -0500177 movw %cx, BREGS_flags(%eax)
Kevin O'Connor38fcbfe2008-02-25 22:30:47 -0500178
179 // Store remaining registers
Kevin O'Connor952974e2008-11-16 18:14:33 -0500180 movw %es, BREGS_es(%eax)
181 movl %edi, BREGS_edi(%eax)
182 movl %esi, BREGS_esi(%eax)
Kevin O'Connor7da210c2009-05-16 23:57:08 -0400183 movl %ebp, BREGS_ebp(%eax)
Kevin O'Connor952974e2008-11-16 18:14:33 -0500184 movl %ebx, BREGS_ebx(%eax)
185 movl %edx, BREGS_edx(%eax)
Kevin O'Connor38fcbfe2008-02-25 22:30:47 -0500186
Kevin O'Connor9caf7862009-02-27 20:14:05 -0500187 // Remove %eax, restore %ebp
Kevin O'Connor38fcbfe2008-02-25 22:30:47 -0500188 popl %eax
Kevin O'Connor9caf7862009-02-27 20:14:05 -0500189 popl %ebp
Kevin O'Connor38fcbfe2008-02-25 22:30:47 -0500190
191 retl
192
Kevin O'Connor752151b2009-12-10 21:16:07 -0500193// Call a 16bit function from 32bit mode.
194// %eax = address of struct bregs
195// Clobbers: %e[bcd]x, %e[ds]i, flags, segment registers, idt/gdt
196 DECLFUNC __call16_from32
197 .global __call16big_from32
198 .code32
199__call16_from32:
Kevin O'Connor4057f982010-11-25 08:52:50 -0500200 movl $1f, %edx
Kevin O'Connor752151b2009-12-10 21:16:07 -0500201 jmp transition16
202__call16big_from32:
Kevin O'Connor4057f982010-11-25 08:52:50 -0500203 movl $1f, %edx
Kevin O'Connor752151b2009-12-10 21:16:07 -0500204 jmp transition16big
205
206 // Make call.
207 .code16gcc
2081: calll __call16
209 // Return via transition32
Kevin O'Connor4057f982010-11-25 08:52:50 -0500210 movl $(2f + BUILD_BIOS_ADDR), %edx
Kevin O'Connor752151b2009-12-10 21:16:07 -0500211 jmp transition32
Kevin O'Connor4057f982010-11-25 08:52:50 -0500212 .code32
2132: retl
Kevin O'Connor752151b2009-12-10 21:16:07 -0500214
Kevin O'Connor4057f982010-11-25 08:52:50 -0500215 .code16gcc
Kevin O'Connor79dde652009-04-13 19:26:43 -0400216// IRQ trampolines
217 .macro IRQ_TRAMPOLINE num
218 DECLFUNC irq_trampoline_0x\num
219 irq_trampoline_0x\num :
220 int $0x\num
221 lretw
222 .endm
223
224 IRQ_TRAMPOLINE 10
225 IRQ_TRAMPOLINE 13
226 IRQ_TRAMPOLINE 15
227 IRQ_TRAMPOLINE 16
228 IRQ_TRAMPOLINE 18
229 IRQ_TRAMPOLINE 19
230
231
232/****************************************************************
233 * POST entry point
234 ****************************************************************/
235
236 DECLFUNC entry_post
237entry_post:
238 // Enable cache
239 movl %cr0, %eax
240 andl $~(CR0_CD|CR0_NW), %eax
241 movl %eax, %cr0
242
243 // Disable interrupts
244 cli
245 cld
246
247 // Check for restart indicator.
248 movl $CMOS_RESET_CODE|NMI_DISABLE_BIT, %eax
249 outb %al, $PORT_CMOS_INDEX
250 inb $PORT_CMOS_DATA, %al
251 cmpb $0x0, %al
252 jnz 1f
253
254 // Normal entry point
Kevin O'Connorf3fe3aa2010-12-05 12:38:33 -0500255 ENTRY_INTO32 _cfunc32flat__start
Kevin O'Connor79dde652009-04-13 19:26:43 -0400256
257 // Entry point when a post call looks like a resume.
2581:
259 // Save old shutdown status.
260 movl %eax, %ebx
261
262 // Clear shutdown status register.
263 movl $CMOS_RESET_CODE|NMI_DISABLE_BIT, %eax
264 outb %al, $PORT_CMOS_INDEX
265 xorl %eax, %eax
266 outb %al, $PORT_CMOS_DATA
267
268 // Use a stack in EBDA
269 movw $SEG_BDA, %ax
270 movw %ax, %ds
271 movw BDA_ebda_seg, %ax
Kevin O'Connor49553a42009-05-17 10:31:34 -0400272
273 cmpw $EBDA_SEGMENT_START, %ax
274 jle 2f
275 // EBDA segment doesn't look valid - use startup value.
276 movw $EBDA_SEGMENT_START, %ax
277
2782: movw %ax, %ds
Kevin O'Connor79dde652009-04-13 19:26:43 -0400279 movw %ax, %ss
280 movl $EBDA_OFFSET_TOP_STACK, %esp
281
282 // Call handler.
283 movl %ebx, %eax
284 jmp handle_resume
285
286
287/****************************************************************
288 * Misc. entry points.
289 ****************************************************************/
290
Kevin O'Connore54ee382009-07-26 19:33:13 -0400291// PMM entry point
292 DECLFUNC entry_pmm
293entry_pmm:
294 pushl %esp // Backup %esp, then clear high bits
295 movzwl %sp, %esp
296 pushfl // Save registers clobbered by C code
297 cli
298 cld
299 pushl %eax
300 pushl %ecx
301 pushl %edx
302 pushw %es
303 pushw %ds
304 movw %ss, %cx // Move %ss to %ds
305 movw %cx, %ds
Kevin O'Connor752151b2009-12-10 21:16:07 -0500306 leal 28(%esp), %eax // %eax points to start of args
Kevin O'Connore54ee382009-07-26 19:33:13 -0400307 calll handle_pmm
308 movw %ax, 12(%esp) // Modify %ax:%dx to return %eax
309 shrl $16, %eax
310 movw %ax, 4(%esp)
311 popw %ds // Restore saved registers
312 popw %es
313 popl %edx
314 popl %ecx
315 popl %eax
316 popfl
317 popl %esp
318 lretw
319
Kevin O'Connor79dde652009-04-13 19:26:43 -0400320// PnP entry points
Kevin O'Connord67a7032009-01-17 19:37:26 -0500321 DECLFUNC entry_pnp_real
322 .global entry_pnp_prot
Kevin O'Connor0c3068d2008-12-21 17:51:36 -0500323entry_pnp_prot:
324 pushl %esp
325 jmp 1f
326entry_pnp_real:
327 pushl %esp // Backup %esp, then clear high bits
328 movzwl %sp, %esp
3291:
330 pushfl // Save registers clobbered by C code
Kevin O'Connore54ee382009-07-26 19:33:13 -0400331 cli
332 cld
Kevin O'Connor0c3068d2008-12-21 17:51:36 -0500333 pushl %eax
334 pushl %ecx
335 pushl %edx
336 pushw %es
337 pushw %ds
338 movw %ss, %cx // Move %ss to %ds
339 movw %cx, %ds
Kevin O'Connor752151b2009-12-10 21:16:07 -0500340 leal 28(%esp), %eax // %eax points to start of u16 args
Kevin O'Connor0c3068d2008-12-21 17:51:36 -0500341 calll handle_pnp
342 movw %ax, 12(%esp) // Modify %eax to return %ax
343 popw %ds
344 popw %es
345 popl %edx
346 popl %ecx
347 popl %eax
348 popfl
349 popl %esp
350 lretw
351
Kevin O'Connor79dde652009-04-13 19:26:43 -0400352// APM entry points
Kevin O'Connord67a7032009-01-17 19:37:26 -0500353 DECLFUNC apm16protected_entry
Kevin O'Connor1d019512008-03-11 21:21:47 -0400354apm16protected_entry:
355 pushfw // save flags
356 pushl %eax // dummy
Kevin O'Connorc0031482010-01-01 13:03:17 -0500357 ENTRY_ARG handle_apm16
Kevin O'Connorb3c28be2008-06-08 13:34:43 -0400358 addw $4, %sp // pop dummy
Kevin O'Connor1d019512008-03-11 21:21:47 -0400359 popfw // restore flags
360 lretw
361
362 .code32
Kevin O'Connord67a7032009-01-17 19:37:26 -0500363 DECLFUNC apm32protected_entry
Kevin O'Connor1d019512008-03-11 21:21:47 -0400364apm32protected_entry:
Kevin O'Connorc0031482010-01-01 13:03:17 -0500365 pushfl
366 pushl %gs
367 pushl %cs // Move second descriptor after %cs to %gs
368 addl $16, (%esp)
369 popl %gs
Kevin O'Connorf3fe3aa2010-12-05 12:38:33 -0500370 ENTRY_ARG_ESP _cfunc32seg_handle_apm32
Kevin O'Connorc0031482010-01-01 13:03:17 -0500371 popl %gs
372 popfl
Kevin O'Connor1d019512008-03-11 21:21:47 -0400373 lretl
Kevin O'Connoree4f9ff2008-07-05 21:19:10 -0400374
Kevin O'Connor871e0a02009-12-30 12:14:53 -0500375// PCI-BIOS 32bit entry point
376 DECLFUNC pcibios32_entry
377pcibios32_entry:
378 pushfl
Kevin O'Connorc0031482010-01-01 13:03:17 -0500379 pushl %gs // Backup %gs and set %gs=%ds
380 pushl %ds
381 popl %gs
Kevin O'Connorf3fe3aa2010-12-05 12:38:33 -0500382 ENTRY_ARG_ESP _cfunc32seg_handle_pcibios32
Kevin O'Connor871e0a02009-12-30 12:14:53 -0500383 popl %gs
384 popfl
385 lretl
386
387// BIOS32 support
388 EXPORTFUNC bios32_entry
389bios32_entry:
390 pushfl
391#if CONFIG_PCIBIOS
392 // Check for PCI-BIOS request
393 cmpl $0x49435024, %eax // $PCI
394 jne 1f
395 movl $BUILD_BIOS_ADDR, %ebx
396 movl $BUILD_BIOS_SIZE, %ecx
397 movl $pcibios32_entry, %edx
398 xorb %al, %al
399 jmp 2f
400#endif
401 // Unknown request
4021: movb $0x80, %al
403 // Return to caller
4042: popfl
405 lretl
406
Kevin O'Connoree4f9ff2008-07-05 21:19:10 -0400407// 32bit elf entry point
Kevin O'Connorc0693942009-06-10 21:56:01 -0400408 EXPORTFUNC post32
Kevin O'Connoree4f9ff2008-07-05 21:19:10 -0400409post32:
410 cli
411 cld
412 lidtl (BUILD_BIOS_ADDR + pmode_IDT_info)
413 lgdtl (BUILD_BIOS_ADDR + rombios32_gdt_48)
Kevin O'Connore0504b02009-04-13 19:32:51 -0400414 movl $SEG32_MODE32_DS, %eax
415 movw %ax, %ds
416 movw %ax, %es
417 movw %ax, %fs
418 movw %ax, %gs
419 movw %ax, %ss
Kevin O'Connoree4f9ff2008-07-05 21:19:10 -0400420 movl $BUILD_STACK_ADDR, %esp
Kevin O'Connorf3fe3aa2010-12-05 12:38:33 -0500421 ljmpl $SEG32_MODE32_CS, $_cfunc32flat__start
Kevin O'Connoree4f9ff2008-07-05 21:19:10 -0400422
Kevin O'Connor1d019512008-03-11 21:21:47 -0400423 .code16gcc
Kevin O'Connor1d019512008-03-11 21:21:47 -0400424
Kevin O'Connor38fcbfe2008-02-25 22:30:47 -0500425
426/****************************************************************
Kevin O'Connorc5b50362008-12-18 21:56:41 -0500427 * Interrupt entry points
428 ****************************************************************/
429
Kevin O'Connor9f193b92009-05-16 23:31:27 -0400430 // Define an entry point for an interrupt (no args passed).
431 .macro IRQ_ENTRY num
432 .global entry_\num
433 entry_\num :
434 pushl $ handle_\num
435 jmp irqentry
436 .endm
437
438 // Define an entry point for an interrupt (can read/modify args).
439 .macro IRQ_ENTRY_ARG num
440 .global entry_\num
441 entry_\num :
442 pushl $ handle_\num
443 jmp irqentryarg
444 .endm
445
446 // Macros that put each handler into its own section
447 .macro DECL_IRQ_ENTRY num
448 DECLFUNC entry_\num
449 IRQ_ENTRY \num
450 .endm
451 .macro DECL_IRQ_ENTRY_ARG num
452 DECLFUNC entry_\num
453 IRQ_ENTRY_ARG \num
454 .endm
455
456 // Main entry point for interrupts without args
457 DECLFUNC irqentry
458irqentry:
459 ENTRY_ST
460 iretw
461
462 // Main entry point for interrupts with args
Kevin O'Connoreaec3c22009-05-30 03:40:22 -0400463 DECLFUNC irqentryarg
Kevin O'Connor9f193b92009-05-16 23:31:27 -0400464irqentryarg:
465 ENTRY_ARG_ST
466 iretw
467
Kevin O'Connord67a7032009-01-17 19:37:26 -0500468 DECL_IRQ_ENTRY_ARG 13
Kevin O'Connord67a7032009-01-17 19:37:26 -0500469 DECL_IRQ_ENTRY 76
Kevin O'Connord67a7032009-01-17 19:37:26 -0500470 DECL_IRQ_ENTRY 70
471 DECL_IRQ_ENTRY 74
472 DECL_IRQ_ENTRY 75
473 DECL_IRQ_ENTRY hwpic1
474 DECL_IRQ_ENTRY hwpic2
475
Kevin O'Connor4ebc0b72009-03-01 12:31:57 -0500476 // int 18/19 are special - they reset stack and call into 32bit mode.
Kevin O'Connord67a7032009-01-17 19:37:26 -0500477 DECLFUNC entry_19
478entry_19:
Kevin O'Connorf3fe3aa2010-12-05 12:38:33 -0500479 ENTRY_INTO32 _cfunc32flat_handle_19
Kevin O'Connord67a7032009-01-17 19:37:26 -0500480
481 DECLFUNC entry_18
482entry_18:
Kevin O'Connorf3fe3aa2010-12-05 12:38:33 -0500483 ENTRY_INTO32 _cfunc32flat_handle_18
Kevin O'Connord67a7032009-01-17 19:37:26 -0500484
485
486/****************************************************************
487 * Fixed position entry points
488 ****************************************************************/
489
490 // Specify a location in the fixed part of bios area.
491 .macro ORG addr
492 .section .fixedaddr.\addr
493 .endm
494
495 ORG 0xe05b
496entry_post_official:
497 jmp entry_post
498
Kevin O'Connorc5b50362008-12-18 21:56:41 -0500499 ORG 0xe2c3
Kevin O'Connor75f49b32009-03-07 00:07:24 -0500500 IRQ_ENTRY 02
Kevin O'Connorc5b50362008-12-18 21:56:41 -0500501
Kevin O'Connor74534532008-05-12 18:28:58 -0400502 ORG 0xe3fe
Kevin O'Connorb4f0e892008-12-13 18:33:05 -0500503 .global entry_13_official
504entry_13_official:
Kevin O'Connorf076a3e2008-02-25 22:25:15 -0500505 jmp entry_13
506
Kevin O'Connor30853762009-01-17 18:49:20 -0500507 // 0xe401 - OldFDPT in disk.c
Kevin O'Connorf076a3e2008-02-25 22:25:15 -0500508
Kevin O'Connor74534532008-05-12 18:28:58 -0400509 ORG 0xe6f2
Kevin O'Connorb4f0e892008-12-13 18:33:05 -0500510 .global entry_19_official
511entry_19_official:
Kevin O'Connorf076a3e2008-02-25 22:25:15 -0500512 jmp entry_19
513
Kevin O'Connor30853762009-01-17 18:49:20 -0500514 // 0xe6f5 - BIOS_CONFIG_TABLE in misc.c
Kevin O'Connorf076a3e2008-02-25 22:25:15 -0500515
Kevin O'Connor30853762009-01-17 18:49:20 -0500516 // 0xe729 - BaudTable in serial.c
Kevin O'Connorf076a3e2008-02-25 22:25:15 -0500517
Kevin O'Connor74534532008-05-12 18:28:58 -0400518 ORG 0xe739
Kevin O'Connored128492008-03-11 11:14:59 -0400519 IRQ_ENTRY_ARG 14
520
Kevin O'Connorb4f0e892008-12-13 18:33:05 -0500521 ORG 0xe82e
522 IRQ_ENTRY_ARG 16
523
524 ORG 0xe987
525 IRQ_ENTRY 09
526
527 ORG 0xec59
528 IRQ_ENTRY_ARG 40
529
530 ORG 0xef57
531 IRQ_ENTRY 0e
532
Kevin O'Connor30853762009-01-17 18:49:20 -0500533 // 0xefc7 - diskette_param_table in floppy.c
Kevin O'Connorb4f0e892008-12-13 18:33:05 -0500534
535 ORG 0xefd2
536 IRQ_ENTRY_ARG 17
537
538 ORG 0xf045
Kevin O'Connord67a7032009-01-17 19:37:26 -0500539entry_10_0x0f:
Kevin O'Connorb4f0e892008-12-13 18:33:05 -0500540 // XXX - INT 10 Functions 0-Fh Entry Point
541 iretw
542
543 ORG 0xf065
544 IRQ_ENTRY_ARG 10
545
Kevin O'Connor30853762009-01-17 18:49:20 -0500546 // 0xf0a4 - VideoParams in misc.c
Kevin O'Connorb4f0e892008-12-13 18:33:05 -0500547
Kevin O'Connorb4f0e892008-12-13 18:33:05 -0500548 ORG 0xf841
Kevin O'Connor9f193b92009-05-16 23:31:27 -0400549 IRQ_ENTRY_ARG 12
Kevin O'Connorb4f0e892008-12-13 18:33:05 -0500550
551 ORG 0xf84d
Kevin O'Connor9f193b92009-05-16 23:31:27 -0400552 IRQ_ENTRY_ARG 11
Kevin O'Connorb4f0e892008-12-13 18:33:05 -0500553
554 ORG 0xf859
555 IRQ_ENTRY_ARG 15
556
Kevin O'Connor30853762009-01-17 18:49:20 -0500557 // 0xfa6e - vgafont8 in font.c
Kevin O'Connorf076a3e2008-02-25 22:25:15 -0500558
Kevin O'Connor74534532008-05-12 18:28:58 -0400559 ORG 0xfe6e
Kevin O'Connored128492008-03-11 11:14:59 -0400560 IRQ_ENTRY_ARG 1a
Kevin O'Connorf076a3e2008-02-25 22:25:15 -0500561
Kevin O'Connor74534532008-05-12 18:28:58 -0400562 ORG 0xfea5
Kevin O'Connorf076a3e2008-02-25 22:25:15 -0500563 IRQ_ENTRY 08
564
Kevin O'Connor30853762009-01-17 18:49:20 -0500565 // 0xfef3 - InitVectors in misc.c
Kevin O'Connorf076a3e2008-02-25 22:25:15 -0500566
Kevin O'Connor30853762009-01-17 18:49:20 -0500567 // 0xff00 - BiosCopyright in misc.c
Kevin O'Connorf076a3e2008-02-25 22:25:15 -0500568
Kevin O'Connor74534532008-05-12 18:28:58 -0400569 ORG 0xff53
Kevin O'Connord67a7032009-01-17 19:37:26 -0500570 .global entry_iret_official
571entry_iret_official:
Kevin O'Connorf076a3e2008-02-25 22:25:15 -0500572 iretw
573
Kevin O'Connor74534532008-05-12 18:28:58 -0400574 ORG 0xff54
Kevin O'Connored128492008-03-11 11:14:59 -0400575 IRQ_ENTRY_ARG 05
Kevin O'Connorf076a3e2008-02-25 22:25:15 -0500576
Kevin O'Connor74534532008-05-12 18:28:58 -0400577 ORG 0xfff0 // Power-up Entry Point
Kevin O'Connor3f168b62008-11-29 13:22:29 -0500578 .global reset_vector
579reset_vector:
Kevin O'Connord67a7032009-01-17 19:37:26 -0500580 ljmpw $SEG_BIOS, $entry_post_official
Kevin O'Connorf076a3e2008-02-25 22:25:15 -0500581
Kevin O'Connor30853762009-01-17 18:49:20 -0500582 // 0xfff5 - BiosDate in misc.c
Kevin O'Connorf076a3e2008-02-25 22:25:15 -0500583
Kevin O'Connor30853762009-01-17 18:49:20 -0500584 // 0xfffe - BiosModelId in misc.c
Kevin O'Connore3677b12008-07-04 15:29:23 -0400585
Kevin O'Connor30853762009-01-17 18:49:20 -0500586 // 0xffff - BiosChecksum in misc.c
Kevin O'Connorf076a3e2008-02-25 22:25:15 -0500587
588 .end