1 // Rom layout and bios assembler to C interface.
3 // Copyright (C) 2009-2013 Kevin O'Connor <kevin@koconnor.net>
5 // This file may be distributed under the terms of the GNU LGPLv3 license.
8 #include "asm-offsets.h" // BREGS_*
9 #include "config.h" // CONFIG_*
10 #include "entryfuncs.S" // ENTRY_*
13 /****************************************************************
15 ****************************************************************/
19 .global _rom_header, _rom_header_size, _rom_header_checksum
31 #if CONFIG_VGA_PCI == 1
40 _rom_header_signature:
44 /****************************************************************
46 ****************************************************************/
48 // This macro implements a call while avoiding instructions
49 // that old versions of x86emu have problems with.
50 .macro VGA_CALLL cfunc
51 #if CONFIG_VGA_FIXUP_ASM
59 // This macro is the same as ENTRY_ARG except VGA_CALLL is used.
60 .macro ENTRY_ARG_VGA cfunc
64 movw %ss, %ax // Move %ss to %ds
66 movl %esp, %ebx // Backup %esp, then zero high bits
68 movl %esp, %eax // First arg is pointer to struct bregs
70 movl %ebx, %esp // Restore %esp (including high bits)
76 ENTRY_ARG_VGA vbe_104f05
79 DECLFUNC _optionrom_entry
81 ENTRY_ARG_VGA vga_post
86 ENTRY_ARG_VGA handle_10
89 #define VGA_CUSTOM_BDA_FLAGS 0xb9
90 #define BF_EXTRA_STACK 0x40
92 // Entry point using extra stack
93 DECLFUNC entry_10_extrastack
100 movw $SEG_BDA, %ax // Check if extra stack is enabled
102 testb $BF_EXTRA_STACK, VGA_CUSTOM_BDA_FLAGS
105 movw %cs:ExtraStackSeg, %ds // Set %ds:%eax to space on ExtraStack
106 movl $(CONFIG_VGA_EXTRA_STACK_SIZE-PUSHBREGS_size-16), %eax
107 SAVEBREGS_POP_DSEAX // Save registers on extra stack
108 movl %esp, PUSHBREGS_size+8(%eax)
109 movw %ss, PUSHBREGS_size+12(%eax)
110 popl BREGS_code(%eax)
111 popw BREGS_flags(%eax)
113 movw %ds, %dx // Setup %ss/%esp and call function
118 movl %esp, %eax // Restore registers and return
119 movw PUSHBREGS_size+12(%eax), %ss
120 movl PUSHBREGS_size+8(%eax), %esp
123 pushw BREGS_flags(%eax)
124 pushl BREGS_code(%eax)
128 1: // Use regular entry point if the extra stack is disabled
133 // Timer irq handling
134 DECLFUNC entry_timer_hook
136 ENTRY handle_timer_hook
137 ljmpw *%cs:Timer_Hook_Resume
139 // Timer irq handling on extra stack
140 DECLFUNC entry_timer_hook_extrastack
141 entry_timer_hook_extrastack:
144 pushw %ds // Set %ds:%eax to space on ExtraStack
146 movw %cs:ExtraStackSeg, %ds
147 movl $(CONFIG_VGA_EXTRA_STACK_SIZE-PUSHBREGS_size-8), %eax
149 movl %esp, PUSHBREGS_size(%eax)
150 movw %ss, PUSHBREGS_size+4(%eax)
152 movw %ds, %dx // Setup %ss/%esp and call function
155 calll handle_timer_hook
157 movl %esp, %eax // Restore registers and return
158 movw PUSHBREGS_size+4(%eax), %ss
159 movl PUSHBREGS_size(%eax), %esp
161 ljmpw *%cs:Timer_Hook_Resume