1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22#include "../../include/hw/nvram/fw_cfg_keys.h"
23
24#define BIOS_CFG_IOPORT_CFG 0x510
25#define BIOS_CFG_IOPORT_DATA 0x511
26
27
28#define DEBUG_HERE \
29 jmp 1f; \
30 1:
31
32
33
34
35
36
37.macro read_fw VAR
38 mov $\VAR, %ax
39 mov $BIOS_CFG_IOPORT_CFG, %dx
40 outw %ax, (%dx)
41 mov $BIOS_CFG_IOPORT_DATA, %dx
42 inb (%dx), %al
43 shl $8, %eax
44 inb (%dx), %al
45 shl $8, %eax
46 inb (%dx), %al
47 shl $8, %eax
48 inb (%dx), %al
49 bswap %eax
50.endm
51
52#define read_fw_blob_pre(var) \
53 read_fw var ## _SIZE; \
54 mov %eax, %ecx; \
55 mov $var ## _DATA, %ax; \
56 mov $BIOS_CFG_IOPORT_CFG, %edx; \
57 outw %ax, (%dx); \
58 mov $BIOS_CFG_IOPORT_DATA, %dx; \
59 cld
60
61
62
63
64
65
66
67#define read_fw_blob(var) \
68 read_fw var ## _ADDR; \
69 mov %eax, %edi; \
70 read_fw_blob_pre(var); \
71
72
73 \
74 .dc.b 0xf3,0x6c
75
76
77
78
79
80
81
82#define read_fw_blob_addr32(var) \
83 read_fw var ## _ADDR; \
84 mov %eax, %edi; \
85 read_fw_blob_pre(var); \
86
87
88 \
89 .dc.b 0x67,0xf3,0x6c
90
91
92
93
94
95
96
97#define read_fw_blob_addr32_edi(var) \
98 read_fw_blob_pre(var); \
99
100
101 \
102 .dc.b 0x67,0xf3,0x6c
103
104#define OPTION_ROM_START \
105 .code16; \
106 .text; \
107 .global _start; \
108 _start:; \
109 .short 0xaa55; \
110 .byte (_end - _start) / 512;
111
112#define BOOT_ROM_START \
113 OPTION_ROM_START \
114 lret; \
115 .org 0x18; \
116 .short 0; \
117 .short _pnph; \
118 _pnph: \
119 .ascii "$PnP"; \
120 .byte 0x01; \
121 .byte ( _pnph_len / 16 ); \
122 .short 0x0000; \
123 .byte 0x00; \
124 .byte 0x00; \
125 .long 0x00000000; \
126 .short _manufacturer; \
127 .short _product; \
128 .long 0x00000000; \
129 .short 0x0000; \
130 .short 0x0000; \
131 .short _bev; \
132 .short 0x0000; \
133 .short 0x0000; \
134 .equ _pnph_len, . - _pnph; \
135 _bev:; \
136 \
137 movw %cs, %ax; \
138 movw %ax, %ds;
139
140#define OPTION_ROM_END \
141 .byte 0; \
142 .align 512, 0; \
143 _end:
144
145#define BOOT_ROM_END \
146 _manufacturer:; \
147 .asciz "QEMU"; \
148 _product:; \
149 .asciz BOOT_ROM_PRODUCT; \
150 OPTION_ROM_END
151
152