2 * Common Option ROM Functions
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.
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.
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/>.
17 * Copyright Novell Inc, 2009
18 * Authors: Alexander Graf <agraf@suse.de>
22 #define FW_CFG_KERNEL_ADDR 0x07
23 #define FW_CFG_KERNEL_SIZE 0x08
24 #define FW_CFG_KERNEL_CMDLINE 0x09
25 #define FW_CFG_INITRD_ADDR 0x0a
26 #define FW_CFG_INITRD_SIZE 0x0b
27 #define FW_CFG_KERNEL_ENTRY 0x10
28 #define FW_CFG_KERNEL_DATA 0x11
29 #define FW_CFG_INITRD_DATA 0x12
30 #define FW_CFG_CMDLINE_ADDR 0x13
31 #define FW_CFG_CMDLINE_SIZE 0x14
32 #define FW_CFG_CMDLINE_DATA 0x15
33 #define FW_CFG_SETUP_ADDR 0x16
34 #define FW_CFG_SETUP_SIZE 0x17
35 #define FW_CFG_SETUP_DATA 0x18
37 #define BIOS_CFG_IOPORT_CFG 0x510
38 #define BIOS_CFG_IOPORT_DATA 0x511
40 #define FW_CFG_DMA_CTL_ERROR 0x01
41 #define FW_CFG_DMA_CTL_READ 0x02
42 #define FW_CFG_DMA_CTL_SKIP 0x04
43 #define FW_CFG_DMA_CTL_SELECT 0x08
44 #define FW_CFG_DMA_CTL_WRITE 0x10
46 #define FW_CFG_DMA_SIGNATURE 0x51454d5520434647ULL /* "QEMU CFG" */
48 #define BIOS_CFG_DMA_ADDR_HIGH 0x514
49 #define BIOS_CFG_DMA_ADDR_LOW 0x518
51 /* Break the translation block flow so -d cpu shows us values */
57 * Read a variable from the fw_cfg device.
63 mov $BIOS_CFG_IOPORT_CFG
, %dx
65 mov $BIOS_CFG_IOPORT_DATA
, %dx
78 * Read data from the fw_cfg device using DMA.
79 * Clobbers: %edx, %eax, ADDR, SIZE, memory[%esp-16] to memory[%esp]
81 .macro read_fw_dma VAR
, SIZE
, ADDR
86 /* We only support 32 bit target addresses */
89 mov $BIOS_CFG_DMA_ADDR_HIGH
, %dx
97 movl $
(\VAR
<< 16) | (FW_CFG_DMA_CTL_READ
| FW_CFG_DMA_CTL_SELECT
), %eax
101 movl
%esp
, %eax
/* Address of the struct we generated */
103 mov $BIOS_CFG_DMA_ADDR_LOW
, %dx
104 outl
%eax
, (%dx
) /* Initiate DMA */
106 1: mov (%esp
), %eax
/* Wait for completion */
108 testl $
~FW_CFG_DMA_CTL_ERROR
, %eax
115 * Read a blob from the fw_cfg device using DMA
116 * Requires _ADDR, _SIZE and _DATA values for the parameter.
118 * Clobbers: %eax, %edx, %es, %ecx, %edi and adresses %esp-20 to %esp
120 #ifdef USE_FW_CFG_DMA
121 #define read_fw_blob_dma(var) \
122 read_fw var ## _SIZE; \
124 read_fw var ## _ADDR; \
126 read_fw_dma var ## _DATA, %ecx, %edi
128 #define read_fw_blob_dma(var) read_fw_blob(var)
131 #define read_fw_blob_pre(var) \
132 read_fw var ## _SIZE; \
134 mov $var ## _DATA, %ax; \
135 mov $BIOS_CFG_IOPORT_CFG, %edx; \
137 mov $BIOS_CFG_IOPORT_DATA, %dx; \
141 * Read a blob from the fw_cfg device.
142 * Requires _ADDR, _SIZE and _DATA values for the parameter.
144 * Clobbers: %eax, %edx, %es, %ecx, %edi
146 #define read_fw_blob(var) \
147 read_fw var ## _ADDR; \
149 read_fw_blob_pre(var); \
150 /* old as(1) doesn't like this insn so emit the bytes instead: \
151 rep insb (%dx), %es:(%edi); \
156 * Read a blob from the fw_cfg device in forced addr32 mode.
157 * Requires _ADDR, _SIZE and _DATA values for the parameter.
159 * Clobbers: %eax, %edx, %es, %ecx, %edi
161 #define read_fw_blob_addr32(var) \
162 read_fw var ## _ADDR; \
164 read_fw_blob_pre(var); \
165 /* old as(1) doesn't like this insn so emit the bytes instead: \
166 addr32 rep insb (%dx), %es:(%edi); \
171 * Read a blob from the fw_cfg device in forced addr32 mode, address is in %edi.
172 * Requires _SIZE and _DATA values for the parameter.
174 * Clobbers: %eax, %edx, %edi, %es, %ecx
176 #define read_fw_blob_addr32_edi(var) \
177 read_fw_blob_pre(var); \
178 /* old as(1) doesn't like this insn so emit the bytes instead: \
179 addr32 rep insb (%dx), %es:(%edi); \
183 #define OPTION_ROM_START \
189 .byte (_end - _start) / 512;
191 #define BOOT_ROM_START \
200 .byte ( _pnph_len / 16 ); \
205 .short _manufacturer; \
213 .equ _pnph_len, . - _pnph; \
219 #define OPTION_ROM_END \
224 #define BOOT_ROM_END \
228 .asciz BOOT_ROM_PRODUCT; \