MAINTAINERS: Make section QOM cover hw/core/*bus.c as well
[qemu/armbru.git] / pc-bios / optionrom / optionrom.h
bloba2b612f1a7e3b0dc557146e83e6c7d66b09f9624
1 /*
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 /* Break the translation block flow so -d cpu shows us values */
41 #define DEBUG_HERE \
42 jmp 1f; \
46 * Read a variable from the fw_cfg device.
47 * Clobbers: %edx
48 * Out: %eax
50 .macro read_fw VAR
51 mov $\VAR, %ax
52 mov $BIOS_CFG_IOPORT_CFG, %dx
53 outw %ax, (%dx)
54 mov $BIOS_CFG_IOPORT_DATA, %dx
55 inb (%dx), %al
56 shl $8, %eax
57 inb (%dx), %al
58 shl $8, %eax
59 inb (%dx), %al
60 shl $8, %eax
61 inb (%dx), %al
62 bswap %eax
63 .endm
65 #define read_fw_blob_pre(var) \
66 read_fw var ## _SIZE; \
67 mov %eax, %ecx; \
68 mov $var ## _DATA, %ax; \
69 mov $BIOS_CFG_IOPORT_CFG, %edx; \
70 outw %ax, (%dx); \
71 mov $BIOS_CFG_IOPORT_DATA, %dx; \
72 cld
75 * Read a blob from the fw_cfg device.
76 * Requires _ADDR, _SIZE and _DATA values for the parameter.
78 * Clobbers: %eax, %edx, %es, %ecx, %edi
80 #define read_fw_blob(var) \
81 read_fw var ## _ADDR; \
82 mov %eax, %edi; \
83 read_fw_blob_pre(var); \
84 /* old as(1) doesn't like this insn so emit the bytes instead: \
85 rep insb (%dx), %es:(%edi); \
86 */ \
87 .dc.b 0xf3,0x6c
90 * Read a blob from the fw_cfg device in forced addr32 mode.
91 * Requires _ADDR, _SIZE and _DATA values for the parameter.
93 * Clobbers: %eax, %edx, %es, %ecx, %edi
95 #define read_fw_blob_addr32(var) \
96 read_fw var ## _ADDR; \
97 mov %eax, %edi; \
98 read_fw_blob_pre(var); \
99 /* old as(1) doesn't like this insn so emit the bytes instead: \
100 addr32 rep insb (%dx), %es:(%edi); \
101 */ \
102 .dc.b 0x67,0xf3,0x6c
105 * Read a blob from the fw_cfg device in forced addr32 mode, address is in %edi.
106 * Requires _SIZE and _DATA values for the parameter.
108 * Clobbers: %eax, %edx, %edi, %es, %ecx
110 #define read_fw_blob_addr32_edi(var) \
111 read_fw_blob_pre(var); \
112 /* old as(1) doesn't like this insn so emit the bytes instead: \
113 addr32 rep insb (%dx), %es:(%edi); \
114 */ \
115 .dc.b 0x67,0xf3,0x6c
117 #define OPTION_ROM_START \
118 .code16; \
119 .text; \
120 .global _start; \
121 _start:; \
122 .short 0xaa55; \
123 .byte (_end - _start) / 512;
125 #define BOOT_ROM_START \
126 OPTION_ROM_START \
127 lret; \
128 .org 0x18; \
129 .short 0; \
130 .short _pnph; \
131 _pnph: \
132 .ascii "$PnP"; \
133 .byte 0x01; \
134 .byte ( _pnph_len / 16 ); \
135 .short 0x0000; \
136 .byte 0x00; \
137 .byte 0x00; \
138 .long 0x00000000; \
139 .short _manufacturer; \
140 .short _product; \
141 .long 0x00000000; \
142 .short 0x0000; \
143 .short 0x0000; \
144 .short _bev; \
145 .short 0x0000; \
146 .short 0x0000; \
147 .equ _pnph_len, . - _pnph; \
148 _bev:; \
149 /* DS = CS */ \
150 movw %cs, %ax; \
151 movw %ax, %ds;
153 #define OPTION_ROM_END \
154 .byte 0; \
155 .align 512, 0; \
156 _end:
158 #define BOOT_ROM_END \
159 _manufacturer:; \
160 .asciz "QEMU"; \
161 _product:; \
162 .asciz BOOT_ROM_PRODUCT; \
163 OPTION_ROM_END