blob: 5983a4a7b1c615e64acba65d30674078a8fedb0e [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'Connor3dba4c22011-01-29 11:26:54 -050014#include "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
Kevin O'Connor3dba4c22011-01-29 11:26:54 -050020#include "asm-offsets.h" // BREGS_*
Kevin O'Connorf8e176c2009-05-06 23:33:32 -040021#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/****************************************************************
Kevin O'Connor87b533b2011-07-10 22:35:07 -0400233 * Misc. entry points.
Kevin O'Connor79dde652009-04-13 19:26:43 -0400234 ****************************************************************/
235
Kevin O'Connor87b533b2011-07-10 22:35:07 -0400236// Resume (and reboot) entry point - called from entry_post
237 DECLFUNC entry_resume
238entry_resume:
Kevin O'Connor79dde652009-04-13 19:26:43 -0400239 // Disable interrupts
240 cli
241 cld
Kevin O'Connor79dde652009-04-13 19:26:43 -0400242 // Use a stack in EBDA
243 movw $SEG_BDA, %ax
244 movw %ax, %ds
245 movw BDA_ebda_seg, %ax
Kevin O'Connor87b533b2011-07-10 22:35:07 -0400246 movw %ax, %ds
Kevin O'Connor79dde652009-04-13 19:26:43 -0400247 movw %ax, %ss
248 movl $EBDA_OFFSET_TOP_STACK, %esp
Kevin O'Connor79dde652009-04-13 19:26:43 -0400249 // Call handler.
Kevin O'Connor79dde652009-04-13 19:26:43 -0400250 jmp handle_resume
251
Kevin O'Connore54ee382009-07-26 19:33:13 -0400252// PMM entry point
253 DECLFUNC entry_pmm
254entry_pmm:
255 pushl %esp // Backup %esp, then clear high bits
256 movzwl %sp, %esp
257 pushfl // Save registers clobbered by C code
258 cli
259 cld
260 pushl %eax
261 pushl %ecx
262 pushl %edx
263 pushw %es
264 pushw %ds
265 movw %ss, %cx // Move %ss to %ds
266 movw %cx, %ds
Kevin O'Connor533b6282011-07-16 13:13:12 -0400267 movl $_cfunc32flat_handle_pmm, %eax // Setup: call32(handle_pmm, args, -1)
268 leal 28(%esp), %edx // %edx points to start of args
269 movl $-1, %ecx
270 calll call32
Kevin O'Connore54ee382009-07-26 19:33:13 -0400271 movw %ax, 12(%esp) // Modify %ax:%dx to return %eax
272 shrl $16, %eax
273 movw %ax, 4(%esp)
274 popw %ds // Restore saved registers
275 popw %es
276 popl %edx
277 popl %ecx
278 popl %eax
279 popfl
280 popl %esp
281 lretw
282
Kevin O'Connor79dde652009-04-13 19:26:43 -0400283// PnP entry points
Kevin O'Connord67a7032009-01-17 19:37:26 -0500284 DECLFUNC entry_pnp_real
285 .global entry_pnp_prot
Kevin O'Connor0c3068d2008-12-21 17:51:36 -0500286entry_pnp_prot:
287 pushl %esp
288 jmp 1f
289entry_pnp_real:
290 pushl %esp // Backup %esp, then clear high bits
291 movzwl %sp, %esp
2921:
293 pushfl // Save registers clobbered by C code
Kevin O'Connore54ee382009-07-26 19:33:13 -0400294 cli
295 cld
Kevin O'Connor0c3068d2008-12-21 17:51:36 -0500296 pushl %eax
297 pushl %ecx
298 pushl %edx
299 pushw %es
300 pushw %ds
301 movw %ss, %cx // Move %ss to %ds
302 movw %cx, %ds
Kevin O'Connor752151b2009-12-10 21:16:07 -0500303 leal 28(%esp), %eax // %eax points to start of u16 args
Kevin O'Connor0c3068d2008-12-21 17:51:36 -0500304 calll handle_pnp
305 movw %ax, 12(%esp) // Modify %eax to return %ax
306 popw %ds
307 popw %es
308 popl %edx
309 popl %ecx
310 popl %eax
311 popfl
312 popl %esp
313 lretw
314
Kevin O'Connor79dde652009-04-13 19:26:43 -0400315// APM entry points
Kevin O'Connor47c8e312011-07-10 22:57:32 -0400316 DECLFUNC entry_apm16
317entry_apm16:
Kevin O'Connor1d019512008-03-11 21:21:47 -0400318 pushfw // save flags
319 pushl %eax // dummy
Kevin O'Connorc0031482010-01-01 13:03:17 -0500320 ENTRY_ARG handle_apm16
Kevin O'Connorb3c28be2008-06-08 13:34:43 -0400321 addw $4, %sp // pop dummy
Kevin O'Connor1d019512008-03-11 21:21:47 -0400322 popfw // restore flags
323 lretw
324
325 .code32
Kevin O'Connor47c8e312011-07-10 22:57:32 -0400326 DECLFUNC entry_apm32
327entry_apm32:
Kevin O'Connorc0031482010-01-01 13:03:17 -0500328 pushfl
329 pushl %gs
330 pushl %cs // Move second descriptor after %cs to %gs
331 addl $16, (%esp)
332 popl %gs
Kevin O'Connorf3fe3aa2010-12-05 12:38:33 -0500333 ENTRY_ARG_ESP _cfunc32seg_handle_apm32
Kevin O'Connorc0031482010-01-01 13:03:17 -0500334 popl %gs
335 popfl
Kevin O'Connor1d019512008-03-11 21:21:47 -0400336 lretl
Kevin O'Connoree4f9ff2008-07-05 21:19:10 -0400337
Kevin O'Connor871e0a02009-12-30 12:14:53 -0500338// PCI-BIOS 32bit entry point
Kevin O'Connor47c8e312011-07-10 22:57:32 -0400339 DECLFUNC entry_pcibios32
340entry_pcibios32:
Kevin O'Connor871e0a02009-12-30 12:14:53 -0500341 pushfl
Kevin O'Connorc0031482010-01-01 13:03:17 -0500342 pushl %gs // Backup %gs and set %gs=%ds
343 pushl %ds
344 popl %gs
Kevin O'Connorf3fe3aa2010-12-05 12:38:33 -0500345 ENTRY_ARG_ESP _cfunc32seg_handle_pcibios32
Kevin O'Connor871e0a02009-12-30 12:14:53 -0500346 popl %gs
347 popfl
348 lretl
349
350// BIOS32 support
Kevin O'Connor47c8e312011-07-10 22:57:32 -0400351 EXPORTFUNC entry_bios32
352entry_bios32:
Kevin O'Connor871e0a02009-12-30 12:14:53 -0500353 pushfl
354#if CONFIG_PCIBIOS
355 // Check for PCI-BIOS request
356 cmpl $0x49435024, %eax // $PCI
357 jne 1f
358 movl $BUILD_BIOS_ADDR, %ebx
359 movl $BUILD_BIOS_SIZE, %ecx
Kevin O'Connor47c8e312011-07-10 22:57:32 -0400360 movl $entry_pcibios32, %edx
Kevin O'Connor871e0a02009-12-30 12:14:53 -0500361 xorb %al, %al
362 jmp 2f
363#endif
364 // Unknown request
3651: movb $0x80, %al
366 // Return to caller
3672: popfl
368 lretl
369
Kevin O'Connoree4f9ff2008-07-05 21:19:10 -0400370// 32bit elf entry point
Kevin O'Connor47c8e312011-07-10 22:57:32 -0400371 EXPORTFUNC entry_elf
372entry_elf:
Kevin O'Connoree4f9ff2008-07-05 21:19:10 -0400373 cli
374 cld
375 lidtl (BUILD_BIOS_ADDR + pmode_IDT_info)
376 lgdtl (BUILD_BIOS_ADDR + rombios32_gdt_48)
Kevin O'Connore0504b02009-04-13 19:32:51 -0400377 movl $SEG32_MODE32_DS, %eax
378 movw %ax, %ds
379 movw %ax, %es
380 movw %ax, %fs
381 movw %ax, %gs
382 movw %ax, %ss
Kevin O'Connoree4f9ff2008-07-05 21:19:10 -0400383 movl $BUILD_STACK_ADDR, %esp
Kevin O'Connor87b533b2011-07-10 22:35:07 -0400384 ljmpl $SEG32_MODE32_CS, $_cfunc32flat_handle_post
Kevin O'Connoree4f9ff2008-07-05 21:19:10 -0400385
Kevin O'Connor1d019512008-03-11 21:21:47 -0400386 .code16gcc
Kevin O'Connor1d019512008-03-11 21:21:47 -0400387
Kevin O'Connor38fcbfe2008-02-25 22:30:47 -0500388
389/****************************************************************
Kevin O'Connorc5b50362008-12-18 21:56:41 -0500390 * Interrupt entry points
391 ****************************************************************/
392
Kevin O'Connor9f193b92009-05-16 23:31:27 -0400393 // Main entry point for interrupts without args
394 DECLFUNC irqentry
395irqentry:
396 ENTRY_ST
397 iretw
398
399 // Main entry point for interrupts with args
Kevin O'Connoreaec3c22009-05-30 03:40:22 -0400400 DECLFUNC irqentryarg
Kevin O'Connor9f193b92009-05-16 23:31:27 -0400401irqentryarg:
402 ENTRY_ARG_ST
403 iretw
404
Kevin O'Connor812478e2011-01-22 10:53:48 -0500405 // Define an entry point for an interrupt (no args passed).
406 .macro IRQ_ENTRY num
407 .global entry_\num
408 entry_\num :
409 pushl $ handle_\num
410 jmp irqentry
411 .endm
412
413 .macro DECL_IRQ_ENTRY num
414 DECLFUNC entry_\num
415 IRQ_ENTRY \num
416 .endm
417
418 // Define an entry point for an interrupt (can read/modify args).
419 .macro IRQ_ENTRY_ARG num
420 .global entry_\num
421 entry_\num :
422 pushl $ handle_\num
423 jmp irqentryarg
424 .endm
425
426 .macro DECL_IRQ_ENTRY_ARG num
427 DECLFUNC entry_\num
428 IRQ_ENTRY_ARG \num
429 .endm
430
431 // Various entry points (that don't require a fixed location).
Kevin O'Connord67a7032009-01-17 19:37:26 -0500432 DECL_IRQ_ENTRY_ARG 13
Kevin O'Connord67a7032009-01-17 19:37:26 -0500433 DECL_IRQ_ENTRY 76
Kevin O'Connord67a7032009-01-17 19:37:26 -0500434 DECL_IRQ_ENTRY 70
435 DECL_IRQ_ENTRY 74
436 DECL_IRQ_ENTRY 75
437 DECL_IRQ_ENTRY hwpic1
438 DECL_IRQ_ENTRY hwpic2
439
Kevin O'Connor4ebc0b72009-03-01 12:31:57 -0500440 // int 18/19 are special - they reset stack and call into 32bit mode.
Kevin O'Connord67a7032009-01-17 19:37:26 -0500441 DECLFUNC entry_19
442entry_19:
Kevin O'Connorf3fe3aa2010-12-05 12:38:33 -0500443 ENTRY_INTO32 _cfunc32flat_handle_19
Kevin O'Connord67a7032009-01-17 19:37:26 -0500444
445 DECLFUNC entry_18
446entry_18:
Kevin O'Connorf3fe3aa2010-12-05 12:38:33 -0500447 ENTRY_INTO32 _cfunc32flat_handle_18
Kevin O'Connord67a7032009-01-17 19:37:26 -0500448
449
450/****************************************************************
451 * Fixed position entry points
452 ****************************************************************/
453
454 // Specify a location in the fixed part of bios area.
455 .macro ORG addr
456 .section .fixedaddr.\addr
457 .endm
458
459 ORG 0xe05b
Kevin O'Connor87b533b2011-07-10 22:35:07 -0400460entry_post:
461 cmpl $0, %cs:HaveRunPost // Check for resume/reboot
462 jnz entry_resume
463 ENTRY_INTO32 _cfunc32flat_handle_post // Normal entry point
Kevin O'Connord67a7032009-01-17 19:37:26 -0500464
Kevin O'Connorc5b50362008-12-18 21:56:41 -0500465 ORG 0xe2c3
Kevin O'Connor75f49b32009-03-07 00:07:24 -0500466 IRQ_ENTRY 02
Kevin O'Connorc5b50362008-12-18 21:56:41 -0500467
Kevin O'Connor74534532008-05-12 18:28:58 -0400468 ORG 0xe3fe
Kevin O'Connorb4f0e892008-12-13 18:33:05 -0500469 .global entry_13_official
470entry_13_official:
Kevin O'Connorf076a3e2008-02-25 22:25:15 -0500471 jmp entry_13
472
Kevin O'Connor30853762009-01-17 18:49:20 -0500473 // 0xe401 - OldFDPT in disk.c
Kevin O'Connorf076a3e2008-02-25 22:25:15 -0500474
Kevin O'Connor74534532008-05-12 18:28:58 -0400475 ORG 0xe6f2
Kevin O'Connorb4f0e892008-12-13 18:33:05 -0500476 .global entry_19_official
477entry_19_official:
Kevin O'Connorf076a3e2008-02-25 22:25:15 -0500478 jmp entry_19
479
Kevin O'Connor30853762009-01-17 18:49:20 -0500480 // 0xe6f5 - BIOS_CONFIG_TABLE in misc.c
Kevin O'Connorf076a3e2008-02-25 22:25:15 -0500481
Kevin O'Connor30853762009-01-17 18:49:20 -0500482 // 0xe729 - BaudTable in serial.c
Kevin O'Connorf076a3e2008-02-25 22:25:15 -0500483
Kevin O'Connor74534532008-05-12 18:28:58 -0400484 ORG 0xe739
Kevin O'Connored128492008-03-11 11:14:59 -0400485 IRQ_ENTRY_ARG 14
486
Kevin O'Connorb4f0e892008-12-13 18:33:05 -0500487 ORG 0xe82e
488 IRQ_ENTRY_ARG 16
489
490 ORG 0xe987
491 IRQ_ENTRY 09
492
493 ORG 0xec59
494 IRQ_ENTRY_ARG 40
495
496 ORG 0xef57
497 IRQ_ENTRY 0e
498
Kevin O'Connor30853762009-01-17 18:49:20 -0500499 // 0xefc7 - diskette_param_table in floppy.c
Kevin O'Connorb4f0e892008-12-13 18:33:05 -0500500
501 ORG 0xefd2
502 IRQ_ENTRY_ARG 17
503
504 ORG 0xf045
Kevin O'Connord67a7032009-01-17 19:37:26 -0500505entry_10_0x0f:
Kevin O'Connorb4f0e892008-12-13 18:33:05 -0500506 // XXX - INT 10 Functions 0-Fh Entry Point
507 iretw
508
509 ORG 0xf065
510 IRQ_ENTRY_ARG 10
511
Kevin O'Connor30853762009-01-17 18:49:20 -0500512 // 0xf0a4 - VideoParams in misc.c
Kevin O'Connorb4f0e892008-12-13 18:33:05 -0500513
Kevin O'Connorb4f0e892008-12-13 18:33:05 -0500514 ORG 0xf841
Kevin O'Connor9f193b92009-05-16 23:31:27 -0400515 IRQ_ENTRY_ARG 12
Kevin O'Connorb4f0e892008-12-13 18:33:05 -0500516
517 ORG 0xf84d
Kevin O'Connor9f193b92009-05-16 23:31:27 -0400518 IRQ_ENTRY_ARG 11
Kevin O'Connorb4f0e892008-12-13 18:33:05 -0500519
520 ORG 0xf859
521 IRQ_ENTRY_ARG 15
522
Kevin O'Connor30853762009-01-17 18:49:20 -0500523 // 0xfa6e - vgafont8 in font.c
Kevin O'Connorf076a3e2008-02-25 22:25:15 -0500524
Kevin O'Connor74534532008-05-12 18:28:58 -0400525 ORG 0xfe6e
Kevin O'Connored128492008-03-11 11:14:59 -0400526 IRQ_ENTRY_ARG 1a
Kevin O'Connorf076a3e2008-02-25 22:25:15 -0500527
Kevin O'Connor74534532008-05-12 18:28:58 -0400528 ORG 0xfea5
Kevin O'Connorf076a3e2008-02-25 22:25:15 -0500529 IRQ_ENTRY 08
530
Kevin O'Connor30853762009-01-17 18:49:20 -0500531 // 0xfef3 - InitVectors in misc.c
Kevin O'Connorf076a3e2008-02-25 22:25:15 -0500532
Kevin O'Connor30853762009-01-17 18:49:20 -0500533 // 0xff00 - BiosCopyright in misc.c
Kevin O'Connorf076a3e2008-02-25 22:25:15 -0500534
Kevin O'Connor74534532008-05-12 18:28:58 -0400535 ORG 0xff53
Kevin O'Connord67a7032009-01-17 19:37:26 -0500536 .global entry_iret_official
537entry_iret_official:
Kevin O'Connorf076a3e2008-02-25 22:25:15 -0500538 iretw
539
Kevin O'Connor74534532008-05-12 18:28:58 -0400540 ORG 0xff54
Kevin O'Connored128492008-03-11 11:14:59 -0400541 IRQ_ENTRY_ARG 05
Kevin O'Connorf076a3e2008-02-25 22:25:15 -0500542
Kevin O'Connor74534532008-05-12 18:28:58 -0400543 ORG 0xfff0 // Power-up Entry Point
Kevin O'Connor3f168b62008-11-29 13:22:29 -0500544 .global reset_vector
545reset_vector:
Kevin O'Connor87b533b2011-07-10 22:35:07 -0400546 ljmpw $SEG_BIOS, $entry_post
Kevin O'Connorf076a3e2008-02-25 22:25:15 -0500547
Kevin O'Connor30853762009-01-17 18:49:20 -0500548 // 0xfff5 - BiosDate in misc.c
Kevin O'Connorf076a3e2008-02-25 22:25:15 -0500549
Kevin O'Connor30853762009-01-17 18:49:20 -0500550 // 0xfffe - BiosModelId in misc.c
Kevin O'Connore3677b12008-07-04 15:29:23 -0400551
Kevin O'Connor30853762009-01-17 18:49:20 -0500552 // 0xffff - BiosChecksum in misc.c
Kevin O'Connorf076a3e2008-02-25 22:25:15 -0500553
554 .end