blob: c4b2ef11db44be1ab3803004274e7025c9fea9af [file] [log] [blame]
Kevin O'Connorf076a3e2008-02-25 22:25:15 -05001// Rom layout and bios assembler to C interface.
2//
Kevin O'Connor36feea92012-02-11 10:49:45 -05003// Copyright (C) 2008-2012 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'Connorf8e176c2009-05-06 23:33:32 -04008#include "config.h" // CONFIG_*
9#include "ioport.h" // PORT_A20
10#include "bregs.h" // CR0_*
11#include "cmos.h" // CMOS_RESET_CODE
Kevin O'Connor3dba4c22011-01-29 11:26:54 -050012#include "asm-offsets.h" // BREGS_*
Kevin O'Connorf8e176c2009-05-06 23:33:32 -040013#include "entryfuncs.S" // ENTRY_*
Kevin O'Connor74534532008-05-12 18:28:58 -040014
Kevin O'Connor1d019512008-03-11 21:21:47 -040015
16/****************************************************************
Kevin O'Connor38fcbfe2008-02-25 22:30:47 -050017 * Call trampolines
18 ****************************************************************/
19
20// Place CPU into 32bit mode from 16bit mode.
Kevin O'Connor4057f982010-11-25 08:52:50 -050021// %edx = return location (in 32bit mode)
Kevin O'Connorad901592009-12-13 11:25:25 -050022// Clobbers: ecx, flags, segment registers, cr0, idt/gdt
Kevin O'Connord67a7032009-01-17 19:37:26 -050023 DECLFUNC transition32
Kevin O'Connor36feea92012-02-11 10:49:45 -050024 .code16gcc
Kevin O'Connorf076a3e2008-02-25 22:25:15 -050025transition32:
Kevin O'Connorad901592009-12-13 11:25:25 -050026 movl %eax, %ecx
Kevin O'Connor9caf7862009-02-27 20:14:05 -050027
Kevin O'Connorf094ba82009-04-13 19:30:27 -040028 // Disable irqs (and clear direction flag)
29 cli
30 cld
31
32 // Disable nmi
33 movl $CMOS_RESET_CODE|NMI_DISABLE_BIT, %eax
34 outb %al, $PORT_CMOS_INDEX
35 inb $PORT_CMOS_DATA, %al
36
Kevin O'Connorf076a3e2008-02-25 22:25:15 -050037 // enable a20
Kevin O'Connord9a8b2d2008-11-16 09:17:02 -050038 inb $PORT_A20, %al
39 orb $A20_ENABLE_BIT, %al
40 outb %al, $PORT_A20
Kevin O'Connorf076a3e2008-02-25 22:25:15 -050041
42 // Set segment descriptors
Kevin O'Connor6e5b4a42008-12-06 13:03:52 -050043 lidtw %cs:pmode_IDT_info
44 lgdtw %cs:rombios32_gdt_48
Kevin O'Connorf076a3e2008-02-25 22:25:15 -050045
Kevin O'Connor3eac0092008-11-16 09:59:32 -050046 // Enable protected mode
47 movl %cr0, %eax
48 orl $CR0_PE, %eax
49 movl %eax, %cr0
Kevin O'Connorf076a3e2008-02-25 22:25:15 -050050
Kevin O'Connor6e5b4a42008-12-06 13:03:52 -050051 // start 32bit protected mode code
Kevin O'Connor14927082008-11-08 19:07:49 -050052 ljmpl $SEG32_MODE32_CS, $(BUILD_BIOS_ADDR + 1f)
Kevin O'Connorf076a3e2008-02-25 22:25:15 -050053
54 .code32
551:
56 // init data segments
Kevin O'Connor14927082008-11-08 19:07:49 -050057 movl $SEG32_MODE32_DS, %eax
Kevin O'Connorf076a3e2008-02-25 22:25:15 -050058 movw %ax, %ds
59 movw %ax, %es
60 movw %ax, %ss
Kevin O'Connorf076a3e2008-02-25 22:25:15 -050061 movw %ax, %fs
62 movw %ax, %gs
63
Kevin O'Connorad901592009-12-13 11:25:25 -050064 movl %ecx, %eax
Kevin O'Connor4057f982010-11-25 08:52:50 -050065 jmpl *%edx
Kevin O'Connor38fcbfe2008-02-25 22:30:47 -050066
Kevin O'Connor752151b2009-12-10 21:16:07 -050067// Place CPU into 16bit mode from 32bit mode.
Kevin O'Connor4057f982010-11-25 08:52:50 -050068// %edx = return location (in 16bit mode)
Kevin O'Connorad901592009-12-13 11:25:25 -050069// Clobbers: ecx, flags, segment registers, cr0, idt/gdt
Kevin O'Connor752151b2009-12-10 21:16:07 -050070 DECLFUNC transition16
71 .global transition16big
72transition16:
Kevin O'Connorad901592009-12-13 11:25:25 -050073 movl %eax, %ecx
Kevin O'Connor38fcbfe2008-02-25 22:30:47 -050074
Kevin O'Connorf076a3e2008-02-25 22:25:15 -050075 // restore data segment limits to 0xffff
Kevin O'Connor6e5b4a42008-12-06 13:03:52 -050076 movl $SEG32_MODE16_DS, %eax
Kevin O'Connorf076a3e2008-02-25 22:25:15 -050077 movw %ax, %ds
78 movw %ax, %es
79 movw %ax, %ss
80 movw %ax, %fs
81 movw %ax, %gs
82
Kevin O'Connorffb81a42009-04-13 19:44:55 -040083#if CONFIG_DISABLE_A20
Kevin O'Connor1a72e2e2008-11-11 22:03:55 -050084 // disable a20
Kevin O'Connord9a8b2d2008-11-16 09:17:02 -050085 inb $PORT_A20, %al
86 andb $~A20_ENABLE_BIT, %al
87 outb %al, $PORT_A20
Kevin O'Connorffb81a42009-04-13 19:44:55 -040088#endif
Kevin O'Connor1a72e2e2008-11-11 22:03:55 -050089
90 // Jump to 16bit mode
91 ljmpw $SEG32_MODE16_CS, $1f
92
Kevin O'Connor752151b2009-12-10 21:16:07 -050093transition16big:
Kevin O'Connorad901592009-12-13 11:25:25 -050094 movl %eax, %ecx
Kevin O'Connor6e5b4a42008-12-06 13:03:52 -050095
96 movl $SEG32_MODE16BIG_DS, %eax
97 movw %ax, %ds
98 movw %ax, %es
99 movw %ax, %ss
100 movw %ax, %fs
101 movw %ax, %gs
102
Kevin O'Connor0f788892010-07-25 14:04:01 -0400103 ljmpw $SEG32_MODE16BIG_CS, $1f
Kevin O'Connor6e5b4a42008-12-06 13:03:52 -0500104
Kevin O'Connor1a72e2e2008-11-11 22:03:55 -0500105 .code16gcc
1061:
Kevin O'Connor3eac0092008-11-16 09:59:32 -0500107 // Disable protected mode
Kevin O'Connorf076a3e2008-02-25 22:25:15 -0500108 movl %cr0, %eax
Kevin O'Connor3eac0092008-11-16 09:59:32 -0500109 andl $~CR0_PE, %eax
Kevin O'Connorf076a3e2008-02-25 22:25:15 -0500110 movl %eax, %cr0
111
112 // far jump to flush CPU queue after transition to real mode
Kevin O'Connore3677b12008-07-04 15:29:23 -0400113 ljmpw $SEG_BIOS, $2f
Kevin O'Connor21e930b2008-03-01 09:49:37 -0500114
Kevin O'Connor38fcbfe2008-02-25 22:30:47 -05001152:
Kevin O'Connorf076a3e2008-02-25 22:25:15 -0500116 // restore IDT to normal real-mode defaults
Kevin O'Connor6e5b4a42008-12-06 13:03:52 -0500117 lidtw %cs:rmode_IDT_info
Kevin O'Connorf076a3e2008-02-25 22:25:15 -0500118
Kevin O'Connor38fcbfe2008-02-25 22:30:47 -0500119 // Clear segment registers
Kevin O'Connorf076a3e2008-02-25 22:25:15 -0500120 xorw %ax, %ax
Kevin O'Connorf076a3e2008-02-25 22:25:15 -0500121 movw %ax, %fs
122 movw %ax, %gs
Kevin O'Connorf076a3e2008-02-25 22:25:15 -0500123 movw %ax, %es
Kevin O'Connor38fcbfe2008-02-25 22:30:47 -0500124 movw %ax, %ds
125 movw %ax, %ss // Assume stack is in segment 0
Kevin O'Connorf076a3e2008-02-25 22:25:15 -0500126
Kevin O'Connorad901592009-12-13 11:25:25 -0500127 movl %ecx, %eax
Kevin O'Connor4057f982010-11-25 08:52:50 -0500128 jmpl *%edx
Kevin O'Connorf076a3e2008-02-25 22:25:15 -0500129
Kevin O'Connor21e930b2008-03-01 09:49:37 -0500130// Call a 16bit function from 16bit mode with a specified cpu register state
Kevin O'Connor38fcbfe2008-02-25 22:30:47 -0500131// %eax = address of struct bregs
Kevin O'Connor9caf7862009-02-27 20:14:05 -0500132// Clobbers: %e[bcd]x, %e[ds]i, flags
Kevin O'Connord67a7032009-01-17 19:37:26 -0500133 DECLFUNC __call16
Kevin O'Connor38fcbfe2008-02-25 22:30:47 -0500134__call16:
Kevin O'Connor9caf7862009-02-27 20:14:05 -0500135 // Save %eax, %ebp
136 pushl %ebp
Kevin O'Connor38fcbfe2008-02-25 22:30:47 -0500137 pushl %eax
138
139 // Setup for iretw call
Kevin O'Connor273e8ae2009-01-19 19:56:07 -0500140 pushw %cs
Kevin O'Connor38fcbfe2008-02-25 22:30:47 -0500141 pushw $1f // return point
Kevin O'Connor952974e2008-11-16 18:14:33 -0500142 pushw BREGS_flags(%eax) // flags
Kevin O'Connor9f985422009-09-09 11:34:39 -0400143 pushl BREGS_code(%eax) // CS:IP
Kevin O'Connor38fcbfe2008-02-25 22:30:47 -0500144
145 // Load calling registers.
Kevin O'Connor952974e2008-11-16 18:14:33 -0500146 movl BREGS_edi(%eax), %edi
147 movl BREGS_esi(%eax), %esi
Kevin O'Connor7da210c2009-05-16 23:57:08 -0400148 movl BREGS_ebp(%eax), %ebp
Kevin O'Connor952974e2008-11-16 18:14:33 -0500149 movl BREGS_ebx(%eax), %ebx
150 movl BREGS_edx(%eax), %edx
151 movl BREGS_ecx(%eax), %ecx
152 movw BREGS_es(%eax), %es
153 movw BREGS_ds(%eax), %ds
154 movl %ss:BREGS_eax(%eax), %eax
Kevin O'Connor38fcbfe2008-02-25 22:30:47 -0500155
156 // Invoke call
157 iretw // XXX - just do a lcalll
1581:
159 // Store flags, eax, ecx
160 pushfw
161 pushl %eax
162 movl 0x06(%esp), %eax
Kevin O'Connor952974e2008-11-16 18:14:33 -0500163 movl %ecx, %ss:BREGS_ecx(%eax)
164 movw %ds, %ss:BREGS_ds(%eax)
Kevin O'Connorcbbb6672008-03-08 13:04:10 -0500165 movw %ss, %cx
Kevin O'Connor952974e2008-11-16 18:14:33 -0500166 movw %cx, %ds // Restore %ds == %ss
Kevin O'Connor38fcbfe2008-02-25 22:30:47 -0500167 popl %ecx
Kevin O'Connor952974e2008-11-16 18:14:33 -0500168 movl %ecx, BREGS_eax(%eax)
Kevin O'Connor38fcbfe2008-02-25 22:30:47 -0500169 popw %cx
Kevin O'Connor952974e2008-11-16 18:14:33 -0500170 movw %cx, BREGS_flags(%eax)
Kevin O'Connor38fcbfe2008-02-25 22:30:47 -0500171
172 // Store remaining registers
Kevin O'Connor952974e2008-11-16 18:14:33 -0500173 movw %es, BREGS_es(%eax)
174 movl %edi, BREGS_edi(%eax)
175 movl %esi, BREGS_esi(%eax)
Kevin O'Connor7da210c2009-05-16 23:57:08 -0400176 movl %ebp, BREGS_ebp(%eax)
Kevin O'Connor952974e2008-11-16 18:14:33 -0500177 movl %ebx, BREGS_ebx(%eax)
178 movl %edx, BREGS_edx(%eax)
Kevin O'Connor38fcbfe2008-02-25 22:30:47 -0500179
Kevin O'Connor9caf7862009-02-27 20:14:05 -0500180 // Remove %eax, restore %ebp
Kevin O'Connor38fcbfe2008-02-25 22:30:47 -0500181 popl %eax
Kevin O'Connor9caf7862009-02-27 20:14:05 -0500182 popl %ebp
Kevin O'Connor38fcbfe2008-02-25 22:30:47 -0500183
184 retl
185
Kevin O'Connor752151b2009-12-10 21:16:07 -0500186// Call a 16bit function from 32bit mode.
187// %eax = address of struct bregs
188// Clobbers: %e[bcd]x, %e[ds]i, flags, segment registers, idt/gdt
189 DECLFUNC __call16_from32
190 .global __call16big_from32
191 .code32
192__call16_from32:
Kevin O'Connor4057f982010-11-25 08:52:50 -0500193 movl $1f, %edx
Kevin O'Connor752151b2009-12-10 21:16:07 -0500194 jmp transition16
195__call16big_from32:
Kevin O'Connor4057f982010-11-25 08:52:50 -0500196 movl $1f, %edx
Kevin O'Connor752151b2009-12-10 21:16:07 -0500197 jmp transition16big
198
199 // Make call.
200 .code16gcc
2011: calll __call16
202 // Return via transition32
Kevin O'Connor4057f982010-11-25 08:52:50 -0500203 movl $(2f + BUILD_BIOS_ADDR), %edx
Kevin O'Connor752151b2009-12-10 21:16:07 -0500204 jmp transition32
Kevin O'Connor4057f982010-11-25 08:52:50 -0500205 .code32
2062: retl
Kevin O'Connor752151b2009-12-10 21:16:07 -0500207
Kevin O'Connor4057f982010-11-25 08:52:50 -0500208 .code16gcc
Kevin O'Connor79dde652009-04-13 19:26:43 -0400209// IRQ trampolines
210 .macro IRQ_TRAMPOLINE num
211 DECLFUNC irq_trampoline_0x\num
212 irq_trampoline_0x\num :
213 int $0x\num
214 lretw
215 .endm
216
217 IRQ_TRAMPOLINE 10
218 IRQ_TRAMPOLINE 13
219 IRQ_TRAMPOLINE 15
220 IRQ_TRAMPOLINE 16
221 IRQ_TRAMPOLINE 18
222 IRQ_TRAMPOLINE 19
223
224
225/****************************************************************
Kevin O'Connor87b533b2011-07-10 22:35:07 -0400226 * Misc. entry points.
Kevin O'Connor79dde652009-04-13 19:26:43 -0400227 ****************************************************************/
228
Kevin O'Connor87b533b2011-07-10 22:35:07 -0400229// Resume (and reboot) entry point - called from entry_post
230 DECLFUNC entry_resume
231entry_resume:
Kevin O'Connor79dde652009-04-13 19:26:43 -0400232 // Disable interrupts
233 cli
234 cld
Kevin O'Connor79dde652009-04-13 19:26:43 -0400235 // Use a stack in EBDA
236 movw $SEG_BDA, %ax
237 movw %ax, %ds
238 movw BDA_ebda_seg, %ax
Kevin O'Connor87b533b2011-07-10 22:35:07 -0400239 movw %ax, %ds
Kevin O'Connor79dde652009-04-13 19:26:43 -0400240 movw %ax, %ss
241 movl $EBDA_OFFSET_TOP_STACK, %esp
Kevin O'Connor79dde652009-04-13 19:26:43 -0400242 // Call handler.
Kevin O'Connor79dde652009-04-13 19:26:43 -0400243 jmp handle_resume
244
Kevin O'Connore54ee382009-07-26 19:33:13 -0400245// PMM entry point
246 DECLFUNC entry_pmm
247entry_pmm:
248 pushl %esp // Backup %esp, then clear high bits
249 movzwl %sp, %esp
250 pushfl // Save registers clobbered by C code
251 cli
252 cld
253 pushl %eax
254 pushl %ecx
255 pushl %edx
256 pushw %es
257 pushw %ds
258 movw %ss, %cx // Move %ss to %ds
259 movw %cx, %ds
Kevin O'Connor533b6282011-07-16 13:13:12 -0400260 movl $_cfunc32flat_handle_pmm, %eax // Setup: call32(handle_pmm, args, -1)
261 leal 28(%esp), %edx // %edx points to start of args
262 movl $-1, %ecx
263 calll call32
Kevin O'Connore54ee382009-07-26 19:33:13 -0400264 movw %ax, 12(%esp) // Modify %ax:%dx to return %eax
265 shrl $16, %eax
266 movw %ax, 4(%esp)
267 popw %ds // Restore saved registers
268 popw %es
269 popl %edx
270 popl %ecx
271 popl %eax
272 popfl
273 popl %esp
274 lretw
275
Kevin O'Connor79dde652009-04-13 19:26:43 -0400276// PnP entry points
Kevin O'Connord67a7032009-01-17 19:37:26 -0500277 DECLFUNC entry_pnp_real
278 .global entry_pnp_prot
Kevin O'Connor0c3068d2008-12-21 17:51:36 -0500279entry_pnp_prot:
280 pushl %esp
281 jmp 1f
282entry_pnp_real:
283 pushl %esp // Backup %esp, then clear high bits
284 movzwl %sp, %esp
2851:
286 pushfl // Save registers clobbered by C code
Kevin O'Connore54ee382009-07-26 19:33:13 -0400287 cli
288 cld
Kevin O'Connor0c3068d2008-12-21 17:51:36 -0500289 pushl %eax
290 pushl %ecx
291 pushl %edx
292 pushw %es
293 pushw %ds
294 movw %ss, %cx // Move %ss to %ds
295 movw %cx, %ds
Kevin O'Connor752151b2009-12-10 21:16:07 -0500296 leal 28(%esp), %eax // %eax points to start of u16 args
Kevin O'Connor0c3068d2008-12-21 17:51:36 -0500297 calll handle_pnp
298 movw %ax, 12(%esp) // Modify %eax to return %ax
299 popw %ds
300 popw %es
301 popl %edx
302 popl %ecx
303 popl %eax
304 popfl
305 popl %esp
306 lretw
307
Kevin O'Connor79dde652009-04-13 19:26:43 -0400308// APM entry points
Kevin O'Connor47c8e312011-07-10 22:57:32 -0400309 DECLFUNC entry_apm16
310entry_apm16:
Kevin O'Connor1d019512008-03-11 21:21:47 -0400311 pushfw // save flags
312 pushl %eax // dummy
Kevin O'Connorc0031482010-01-01 13:03:17 -0500313 ENTRY_ARG handle_apm16
Kevin O'Connorb3c28be2008-06-08 13:34:43 -0400314 addw $4, %sp // pop dummy
Kevin O'Connor1d019512008-03-11 21:21:47 -0400315 popfw // restore flags
316 lretw
317
318 .code32
Kevin O'Connor47c8e312011-07-10 22:57:32 -0400319 DECLFUNC entry_apm32
320entry_apm32:
Kevin O'Connorc0031482010-01-01 13:03:17 -0500321 pushfl
322 pushl %gs
323 pushl %cs // Move second descriptor after %cs to %gs
324 addl $16, (%esp)
325 popl %gs
Kevin O'Connorf3fe3aa2010-12-05 12:38:33 -0500326 ENTRY_ARG_ESP _cfunc32seg_handle_apm32
Kevin O'Connorc0031482010-01-01 13:03:17 -0500327 popl %gs
328 popfl
Kevin O'Connor1d019512008-03-11 21:21:47 -0400329 lretl
Kevin O'Connoree4f9ff2008-07-05 21:19:10 -0400330
Kevin O'Connor871e0a02009-12-30 12:14:53 -0500331// PCI-BIOS 32bit entry point
Kevin O'Connor47c8e312011-07-10 22:57:32 -0400332 DECLFUNC entry_pcibios32
333entry_pcibios32:
Kevin O'Connor871e0a02009-12-30 12:14:53 -0500334 pushfl
Kevin O'Connorc0031482010-01-01 13:03:17 -0500335 pushl %gs // Backup %gs and set %gs=%ds
336 pushl %ds
337 popl %gs
Kevin O'Connorf3fe3aa2010-12-05 12:38:33 -0500338 ENTRY_ARG_ESP _cfunc32seg_handle_pcibios32
Kevin O'Connor871e0a02009-12-30 12:14:53 -0500339 popl %gs
340 popfl
341 lretl
342
343// BIOS32 support
Kevin O'Connor47c8e312011-07-10 22:57:32 -0400344 EXPORTFUNC entry_bios32
345entry_bios32:
Kevin O'Connor871e0a02009-12-30 12:14:53 -0500346 pushfl
347#if CONFIG_PCIBIOS
348 // Check for PCI-BIOS request
349 cmpl $0x49435024, %eax // $PCI
350 jne 1f
351 movl $BUILD_BIOS_ADDR, %ebx
352 movl $BUILD_BIOS_SIZE, %ecx
Kevin O'Connor47c8e312011-07-10 22:57:32 -0400353 movl $entry_pcibios32, %edx
Kevin O'Connor871e0a02009-12-30 12:14:53 -0500354 xorb %al, %al
355 jmp 2f
356#endif
357 // Unknown request
3581: movb $0x80, %al
359 // Return to caller
3602: popfl
361 lretl
362
Kevin O'Connoree4f9ff2008-07-05 21:19:10 -0400363// 32bit elf entry point
Kevin O'Connor47c8e312011-07-10 22:57:32 -0400364 EXPORTFUNC entry_elf
365entry_elf:
Kevin O'Connoree4f9ff2008-07-05 21:19:10 -0400366 cli
367 cld
368 lidtl (BUILD_BIOS_ADDR + pmode_IDT_info)
369 lgdtl (BUILD_BIOS_ADDR + rombios32_gdt_48)
Kevin O'Connore0504b02009-04-13 19:32:51 -0400370 movl $SEG32_MODE32_DS, %eax
371 movw %ax, %ds
372 movw %ax, %es
373 movw %ax, %fs
374 movw %ax, %gs
375 movw %ax, %ss
Kevin O'Connoree4f9ff2008-07-05 21:19:10 -0400376 movl $BUILD_STACK_ADDR, %esp
Kevin O'Connor87b533b2011-07-10 22:35:07 -0400377 ljmpl $SEG32_MODE32_CS, $_cfunc32flat_handle_post
Kevin O'Connoree4f9ff2008-07-05 21:19:10 -0400378
Kevin O'Connor1d019512008-03-11 21:21:47 -0400379 .code16gcc
Kevin O'Connor1d019512008-03-11 21:21:47 -0400380
Kevin O'Connor38fcbfe2008-02-25 22:30:47 -0500381
382/****************************************************************
Kevin O'Connorc5b50362008-12-18 21:56:41 -0500383 * Interrupt entry points
384 ****************************************************************/
385
Kevin O'Connor9f193b92009-05-16 23:31:27 -0400386 // Main entry point for interrupts without args
387 DECLFUNC irqentry
388irqentry:
389 ENTRY_ST
390 iretw
391
392 // Main entry point for interrupts with args
Kevin O'Connoreaec3c22009-05-30 03:40:22 -0400393 DECLFUNC irqentryarg
Kevin O'Connor9f193b92009-05-16 23:31:27 -0400394irqentryarg:
395 ENTRY_ARG_ST
396 iretw
397
Kevin O'Connor812478e2011-01-22 10:53:48 -0500398 // Define an entry point for an interrupt (no args passed).
399 .macro IRQ_ENTRY num
400 .global entry_\num
401 entry_\num :
402 pushl $ handle_\num
403 jmp irqentry
404 .endm
405
406 .macro DECL_IRQ_ENTRY num
407 DECLFUNC entry_\num
408 IRQ_ENTRY \num
409 .endm
410
411 // Define an entry point for an interrupt (can read/modify args).
412 .macro IRQ_ENTRY_ARG num
413 .global entry_\num
414 entry_\num :
415 pushl $ handle_\num
416 jmp irqentryarg
417 .endm
418
419 .macro DECL_IRQ_ENTRY_ARG num
420 DECLFUNC entry_\num
421 IRQ_ENTRY_ARG \num
422 .endm
423
424 // Various entry points (that don't require a fixed location).
Kevin O'Connord67a7032009-01-17 19:37:26 -0500425 DECL_IRQ_ENTRY_ARG 13
Kevin O'Connord67a7032009-01-17 19:37:26 -0500426 DECL_IRQ_ENTRY 76
Kevin O'Connord67a7032009-01-17 19:37:26 -0500427 DECL_IRQ_ENTRY 70
428 DECL_IRQ_ENTRY 74
429 DECL_IRQ_ENTRY 75
430 DECL_IRQ_ENTRY hwpic1
431 DECL_IRQ_ENTRY hwpic2
432
Kevin O'Connor4ebc0b72009-03-01 12:31:57 -0500433 // int 18/19 are special - they reset stack and call into 32bit mode.
Kevin O'Connord67a7032009-01-17 19:37:26 -0500434 DECLFUNC entry_19
435entry_19:
Kevin O'Connorf3fe3aa2010-12-05 12:38:33 -0500436 ENTRY_INTO32 _cfunc32flat_handle_19
Kevin O'Connord67a7032009-01-17 19:37:26 -0500437
438 DECLFUNC entry_18
439entry_18:
Kevin O'Connorf3fe3aa2010-12-05 12:38:33 -0500440 ENTRY_INTO32 _cfunc32flat_handle_18
Kevin O'Connord67a7032009-01-17 19:37:26 -0500441
442
443/****************************************************************
444 * Fixed position entry points
445 ****************************************************************/
446
447 // Specify a location in the fixed part of bios area.
448 .macro ORG addr
449 .section .fixedaddr.\addr
450 .endm
451
452 ORG 0xe05b
Kevin O'Connor87b533b2011-07-10 22:35:07 -0400453entry_post:
454 cmpl $0, %cs:HaveRunPost // Check for resume/reboot
455 jnz entry_resume
456 ENTRY_INTO32 _cfunc32flat_handle_post // Normal entry point
Kevin O'Connord67a7032009-01-17 19:37:26 -0500457
Kevin O'Connorc5b50362008-12-18 21:56:41 -0500458 ORG 0xe2c3
Kevin O'Connor75f49b32009-03-07 00:07:24 -0500459 IRQ_ENTRY 02
Kevin O'Connorc5b50362008-12-18 21:56:41 -0500460
Kevin O'Connor74534532008-05-12 18:28:58 -0400461 ORG 0xe3fe
Kevin O'Connorb4f0e892008-12-13 18:33:05 -0500462 .global entry_13_official
463entry_13_official:
Kevin O'Connorf076a3e2008-02-25 22:25:15 -0500464 jmp entry_13
465
Kevin O'Connor30853762009-01-17 18:49:20 -0500466 // 0xe401 - OldFDPT in disk.c
Kevin O'Connorf076a3e2008-02-25 22:25:15 -0500467
Kevin O'Connor74534532008-05-12 18:28:58 -0400468 ORG 0xe6f2
Kevin O'Connorb4f0e892008-12-13 18:33:05 -0500469 .global entry_19_official
470entry_19_official:
Kevin O'Connorf076a3e2008-02-25 22:25:15 -0500471 jmp entry_19
472
Kevin O'Connor30853762009-01-17 18:49:20 -0500473 // 0xe6f5 - BIOS_CONFIG_TABLE in misc.c
Kevin O'Connorf076a3e2008-02-25 22:25:15 -0500474
Kevin O'Connor30853762009-01-17 18:49:20 -0500475 // 0xe729 - BaudTable in serial.c
Kevin O'Connorf076a3e2008-02-25 22:25:15 -0500476
Kevin O'Connor74534532008-05-12 18:28:58 -0400477 ORG 0xe739
Kevin O'Connored128492008-03-11 11:14:59 -0400478 IRQ_ENTRY_ARG 14
479
Kevin O'Connorb4f0e892008-12-13 18:33:05 -0500480 ORG 0xe82e
481 IRQ_ENTRY_ARG 16
482
483 ORG 0xe987
484 IRQ_ENTRY 09
485
486 ORG 0xec59
487 IRQ_ENTRY_ARG 40
488
489 ORG 0xef57
490 IRQ_ENTRY 0e
491
Kevin O'Connor30853762009-01-17 18:49:20 -0500492 // 0xefc7 - diskette_param_table in floppy.c
Kevin O'Connorb4f0e892008-12-13 18:33:05 -0500493
494 ORG 0xefd2
495 IRQ_ENTRY_ARG 17
496
497 ORG 0xf045
Kevin O'Connord67a7032009-01-17 19:37:26 -0500498entry_10_0x0f:
Kevin O'Connorb4f0e892008-12-13 18:33:05 -0500499 // XXX - INT 10 Functions 0-Fh Entry Point
500 iretw
501
502 ORG 0xf065
503 IRQ_ENTRY_ARG 10
504
Kevin O'Connor30853762009-01-17 18:49:20 -0500505 // 0xf0a4 - VideoParams in misc.c
Kevin O'Connorb4f0e892008-12-13 18:33:05 -0500506
Kevin O'Connorb4f0e892008-12-13 18:33:05 -0500507 ORG 0xf841
Kevin O'Connor9f193b92009-05-16 23:31:27 -0400508 IRQ_ENTRY_ARG 12
Kevin O'Connorb4f0e892008-12-13 18:33:05 -0500509
510 ORG 0xf84d
Kevin O'Connor9f193b92009-05-16 23:31:27 -0400511 IRQ_ENTRY_ARG 11
Kevin O'Connorb4f0e892008-12-13 18:33:05 -0500512
513 ORG 0xf859
514 IRQ_ENTRY_ARG 15
515
Kevin O'Connor30853762009-01-17 18:49:20 -0500516 // 0xfa6e - vgafont8 in font.c
Kevin O'Connorf076a3e2008-02-25 22:25:15 -0500517
Kevin O'Connor74534532008-05-12 18:28:58 -0400518 ORG 0xfe6e
Kevin O'Connored128492008-03-11 11:14:59 -0400519 IRQ_ENTRY_ARG 1a
Kevin O'Connorf076a3e2008-02-25 22:25:15 -0500520
Kevin O'Connor74534532008-05-12 18:28:58 -0400521 ORG 0xfea5
Kevin O'Connorf076a3e2008-02-25 22:25:15 -0500522 IRQ_ENTRY 08
523
Kevin O'Connor30853762009-01-17 18:49:20 -0500524 // 0xfef3 - InitVectors in misc.c
Kevin O'Connorf076a3e2008-02-25 22:25:15 -0500525
Kevin O'Connor30853762009-01-17 18:49:20 -0500526 // 0xff00 - BiosCopyright in misc.c
Kevin O'Connorf076a3e2008-02-25 22:25:15 -0500527
Kevin O'Connor74534532008-05-12 18:28:58 -0400528 ORG 0xff53
Kevin O'Connord67a7032009-01-17 19:37:26 -0500529 .global entry_iret_official
530entry_iret_official:
Kevin O'Connorf076a3e2008-02-25 22:25:15 -0500531 iretw
532
Kevin O'Connor74534532008-05-12 18:28:58 -0400533 ORG 0xff54
Kevin O'Connored128492008-03-11 11:14:59 -0400534 IRQ_ENTRY_ARG 05
Kevin O'Connorf076a3e2008-02-25 22:25:15 -0500535
Kevin O'Connor74534532008-05-12 18:28:58 -0400536 ORG 0xfff0 // Power-up Entry Point
Kevin O'Connor3f168b62008-11-29 13:22:29 -0500537 .global reset_vector
538reset_vector:
Kevin O'Connor87b533b2011-07-10 22:35:07 -0400539 ljmpw $SEG_BIOS, $entry_post
Kevin O'Connorf076a3e2008-02-25 22:25:15 -0500540
Kevin O'Connor30853762009-01-17 18:49:20 -0500541 // 0xfff5 - BiosDate in misc.c
Kevin O'Connorf076a3e2008-02-25 22:25:15 -0500542
Kevin O'Connor30853762009-01-17 18:49:20 -0500543 // 0xfffe - BiosModelId in misc.c
Kevin O'Connore3677b12008-07-04 15:29:23 -0400544
Kevin O'Connor30853762009-01-17 18:49:20 -0500545 // 0xffff - BiosChecksum in misc.c
Kevin O'Connorf076a3e2008-02-25 22:25:15 -0500546
547 .end