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 is the same as ENTRY_ARG except the "calll"
49
// instruction is avoided to work around known issues in the
50
// emulation of some versions of x86emu.
51
.macro ENTRY_ARG_VGA cfunc
55
movw %ss, %ax // Move %ss to %ds
57
movl %esp, %ebx // Backup %esp, then zero high bits
59
movl %esp, %eax // First arg is pointer to struct bregs
60
pushw %ax ; callw \cfunc
61
movl %ebx, %esp // Restore %esp (including high bits)
67
ENTRY_ARG_VGA vbe_104f05
70
DECLFUNC _optionrom_entry
72
ENTRY_ARG_VGA vga_post
77
ENTRY_ARG_VGA handle_10
80
// Entry point using extra stack
81
DECLFUNC entry_10_extrastack
85
pushw %ds // Set %ds:%eax to space on ExtraStack
87
movw %cs:ExtraStackSeg, %ds
88
movl $(CONFIG_VGA_EXTRA_STACK_SIZE-BREGS_size-8), %eax
89
popl BREGS_eax(%eax) // Backup registers
91
movl %edi, BREGS_edi(%eax)
92
movl %esi, BREGS_esi(%eax)
93
movl %ebp, BREGS_ebp(%eax)
94
movl %ebx, BREGS_ebx(%eax)
95
movl %edx, BREGS_edx(%eax)
96
movl %ecx, BREGS_ecx(%eax)
97
movw %es, BREGS_es(%eax)
98
movl %esp, BREGS_size+0(%eax)
99
movw %ss, BREGS_size+4(%eax)
100
popl BREGS_code(%eax)
101
popw BREGS_flags(%eax)
103
movw %ds, %dx // Setup %ss/%esp and call function
106
pushw %ax ; callw handle_10
108
movl %esp, %eax // Restore registers and return
109
movw BREGS_size+4(%eax), %ss
110
movl BREGS_size+0(%eax), %esp
113
pushw BREGS_flags(%eax)
114
pushl BREGS_code(%eax)
115
movl BREGS_edi(%eax), %edi
116
movl BREGS_esi(%eax), %esi
117
movl BREGS_ebp(%eax), %ebp
118
movl BREGS_ebx(%eax), %ebx
119
movl BREGS_edx(%eax), %edx
120
movl BREGS_ecx(%eax), %ecx
121
movw BREGS_es(%eax), %es
123
pushl BREGS_eax(%eax)