Add qemu 2.4.0
[kvmfornfv.git] / qemu / roms / seabios / vgasrc / vgaentry.S
1 // Rom layout and bios assembler to C interface.
2 //
3 // Copyright (C) 2009-2013  Kevin O'Connor <kevin@koconnor.net>
4 //
5 // This file may be distributed under the terms of the GNU LGPLv3 license.
6
7
8 #include "asm-offsets.h" // BREGS_*
9 #include "config.h" // CONFIG_*
10 #include "entryfuncs.S" // ENTRY_*
11
12
13 /****************************************************************
14  * Rom Header
15  ****************************************************************/
16
17         .section .rom.header
18         .code16
19         .global _rom_header, _rom_header_size, _rom_header_checksum
20 _rom_header:
21         .word 0xaa55
22 _rom_header_size:
23         .byte 0
24 _rom_header_entry:
25         jmp _optionrom_entry
26 _rom_header_checksum:
27         .byte 0
28 _rom_header_other:
29         .space 17
30 _rom_header_pcidata:
31 #if CONFIG_VGA_PCI == 1
32         .word rom_pci_data
33 #else
34         .word 0
35 #endif
36 _rom_header_pnpdata:
37         .word 0
38 _rom_header_other2:
39         .word 0
40 _rom_header_signature:
41         .asciz "IBM"
42
43
44 /****************************************************************
45  * Entry points
46  ****************************************************************/
47
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
52         pushw %ax
53         callw \cfunc
54 #else
55         calll \cfunc
56 #endif
57         .endm
58
59         // This macro is the same as ENTRY_ARG except VGA_CALLL is used.
60         .macro ENTRY_ARG_VGA cfunc
61         cli
62         cld
63         PUSHBREGS
64         movw %ss, %ax           // Move %ss to %ds
65         movw %ax, %ds
66         movl %esp, %ebx         // Backup %esp, then zero high bits
67         movzwl %sp, %esp
68         movl %esp, %eax         // First arg is pointer to struct bregs
69         VGA_CALLL \cfunc
70         movl %ebx, %esp         // Restore %esp (including high bits)
71         POPBREGS
72         .endm
73
74         DECLFUNC entry_104f05
75 entry_104f05:
76         ENTRY_ARG_VGA vbe_104f05
77         lretw
78
79         DECLFUNC _optionrom_entry
80 _optionrom_entry:
81         ENTRY_ARG_VGA vga_post
82         lretw
83
84         DECLFUNC entry_10
85 entry_10:
86         ENTRY_ARG_VGA handle_10
87         iretw
88
89         // Entry point using extra stack
90         DECLFUNC entry_10_extrastack
91 entry_10_extrastack:
92         cli
93         cld
94         pushw %ds               // Set %ds:%eax to space on ExtraStack
95         pushl %eax
96         movw %cs:ExtraStackSeg, %ds
97         movl $(CONFIG_VGA_EXTRA_STACK_SIZE-PUSHBREGS_size-16), %eax
98         SAVEBREGS_POP_DSEAX     // Save registers on extra stack
99         movl %esp, PUSHBREGS_size+8(%eax)
100         movw %ss, PUSHBREGS_size+12(%eax)
101         popl BREGS_code(%eax)
102         popw BREGS_flags(%eax)
103
104         movw %ds, %dx           // Setup %ss/%esp and call function
105         movw %dx, %ss
106         movl %eax, %esp
107         VGA_CALLL handle_10
108
109         movl %esp, %eax         // Restore registers and return
110         movw PUSHBREGS_size+12(%eax), %ss
111         movl PUSHBREGS_size+8(%eax), %esp
112         popl %edx
113         popw %dx
114         pushw BREGS_flags(%eax)
115         pushl BREGS_code(%eax)
116         RESTOREBREGS_DSEAX
117         iretw
118
119         // Timer irq handling
120         DECLFUNC entry_timer_hook
121 entry_timer_hook:
122         ENTRY handle_timer_hook
123         ljmpw *%cs:Timer_Hook_Resume
124
125         // Timer irq handling on extra stack
126         DECLFUNC entry_timer_hook_extrastack
127 entry_timer_hook_extrastack:
128         cli
129         cld
130         pushw %ds               // Set %ds:%eax to space on ExtraStack
131         pushl %eax
132         movw %cs:ExtraStackSeg, %ds
133         movl $(CONFIG_VGA_EXTRA_STACK_SIZE-PUSHBREGS_size-8), %eax
134         SAVEBREGS_POP_DSEAX
135         movl %esp, PUSHBREGS_size(%eax)
136         movw %ss, PUSHBREGS_size+4(%eax)
137
138         movw %ds, %dx           // Setup %ss/%esp and call function
139         movw %dx, %ss
140         movl %eax, %esp
141         calll handle_timer_hook
142
143         movl %esp, %eax         // Restore registers and return
144         movw PUSHBREGS_size+4(%eax), %ss
145         movl PUSHBREGS_size(%eax), %esp
146         RESTOREBREGS_DSEAX
147         ljmpw *%cs:Timer_Hook_Resume