root / pc-bios / optionrom / optionrom.h @ dd4b2659
History | View | Annotate | Download (2.4 kB)
1 |
/*
|
---|---|
2 |
* Common Option ROM Functions
|
3 |
*
|
4 |
* This program is free software; you can redistribute it and/or modify
|
5 |
* it under the terms of the GNU General Public License as published by
|
6 |
* the Free Software Foundation; either version 2 of the License, or
|
7 |
* (at your option) any later version.
|
8 |
*
|
9 |
* This program is distributed in the hope that it will be useful,
|
10 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
11 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
12 |
* GNU General Public License for more details.
|
13 |
*
|
14 |
* You should have received a copy of the GNU General Public License
|
15 |
* along with this program; if not, see <http://www.gnu.org/licenses/>.
|
16 |
*
|
17 |
* Copyright Novell Inc, 2009
|
18 |
* Authors: Alexander Graf <agraf@suse.de>
|
19 |
*/
|
20 |
|
21 |
|
22 |
#define NO_QEMU_PROTOS
|
23 |
#include "../../hw/fw_cfg.h" |
24 |
|
25 |
#define BIOS_CFG_IOPORT_CFG 0x510 |
26 |
#define BIOS_CFG_IOPORT_DATA 0x511 |
27 |
|
28 |
/* Break the translation block flow so -d cpu shows us values */
|
29 |
#define DEBUG_HERE \
|
30 |
jmp 1f; \
|
31 |
1:
|
32 |
|
33 |
/*
|
34 |
* Read a variable from the fw_cfg device.
|
35 |
* Clobbers: %edx
|
36 |
* Out: %eax
|
37 |
*/
|
38 |
.macro read_fw VAR |
39 |
mov $\VAR, %ax
|
40 |
mov $BIOS_CFG_IOPORT_CFG, %dx |
41 |
outw %ax, (%dx) |
42 |
mov $BIOS_CFG_IOPORT_DATA, %dx |
43 |
inb (%dx), %al |
44 |
shl $8, %eax
|
45 |
inb (%dx), %al |
46 |
shl $8, %eax
|
47 |
inb (%dx), %al |
48 |
shl $8, %eax
|
49 |
inb (%dx), %al |
50 |
bswap %eax |
51 |
.endm |
52 |
|
53 |
/*
|
54 |
* Read a blob from the fw_cfg device.
|
55 |
* Requires _ADDR, _SIZE and _DATA values for the parameter.
|
56 |
*
|
57 |
* Clobbers: %eax, %edx, %es, %ecx, %edi
|
58 |
*/
|
59 |
#define read_fw_blob(var) \
|
60 |
read_fw var ## _ADDR; \ |
61 |
mov %eax, %edi; \ |
62 |
read_fw var ## _SIZE; \ |
63 |
mov %eax, %ecx; \ |
64 |
mov $var ## _DATA, %ax; \ |
65 |
mov $BIOS_CFG_IOPORT_CFG, %edx; \ |
66 |
outw %ax, (%dx); \ |
67 |
mov $BIOS_CFG_IOPORT_DATA, %dx; \ |
68 |
cld; \ |
69 |
rep insb (%dx), %es:(%edi); |
70 |
|
71 |
#define OPTION_ROM_START \
|
72 |
.code16; \ |
73 |
.text; \ |
74 |
.global _start; \ |
75 |
_start:; \ |
76 |
.short 0xaa55; \ |
77 |
.byte (_end - _start) / 512;
|
78 |
|
79 |
#define BOOT_ROM_START \
|
80 |
OPTION_ROM_START \ |
81 |
push %eax; \ |
82 |
push %ds; \ |
83 |
\ |
84 |
/* setup ds so we can access the IVT */ \
|
85 |
xor %ax, %ax; \ |
86 |
mov %ax, %ds; \ |
87 |
\ |
88 |
/* install our int 19 handler */ \
|
89 |
movw $int19_handler, (0x19*4); \ |
90 |
mov %cs, (0x19*4+2); \ |
91 |
\ |
92 |
pop %ds; \ |
93 |
pop %eax; \ |
94 |
lret; \ |
95 |
\ |
96 |
int19_handler:; \ |
97 |
/* DS = CS */ \
|
98 |
movw %cs, %ax; \ |
99 |
movw %ax, %ds; |
100 |
|
101 |
#define OPTION_ROM_END \
|
102 |
.align 512, 0; \ |
103 |
_end: |
104 |
|
105 |
#define BOOT_ROM_END \
|
106 |
OPTION_ROM_END |
107 |
|