]>
Commit | Line | Data |
---|---|---|
dd4b2659 AG |
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 | |
0d09e41a | 23 | #include "../../include/hw/nvram/fw_cfg.h" |
dd4b2659 AG |
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 | ||
590bf491 | 53 | #define read_fw_blob_pre(var) \ |
dd4b2659 AG |
54 | read_fw var ## _ADDR; \ |
55 | mov %eax, %edi; \ | |
56 | read_fw var ## _SIZE; \ | |
57 | mov %eax, %ecx; \ | |
58 | mov $var ## _DATA, %ax; \ | |
59 | mov $BIOS_CFG_IOPORT_CFG, %edx; \ | |
60 | outw %ax, (%dx); \ | |
61 | mov $BIOS_CFG_IOPORT_DATA, %dx; \ | |
590bf491 AG |
62 | cld |
63 | ||
64 | /* | |
65 | * Read a blob from the fw_cfg device. | |
66 | * Requires _ADDR, _SIZE and _DATA values for the parameter. | |
67 | * | |
68 | * Clobbers: %eax, %edx, %es, %ecx, %edi | |
69 | */ | |
70 | #define read_fw_blob(var) \ | |
71 | read_fw_blob_pre(var); \ | |
dd4239d6 JL |
72 | /* old as(1) doesn't like this insn so emit the bytes instead: \ |
73 | rep insb (%dx), %es:(%edi); \ | |
74 | */ \ | |
590bf491 AG |
75 | .dc.b 0xf3,0x6c |
76 | ||
77 | /* | |
78 | * Read a blob from the fw_cfg device in forced addr32 mode. | |
79 | * Requires _ADDR, _SIZE and _DATA values for the parameter. | |
80 | * | |
81 | * Clobbers: %eax, %edx, %es, %ecx, %edi | |
82 | */ | |
83 | #define read_fw_blob_addr32(var) \ | |
84 | read_fw_blob_pre(var); \ | |
85 | /* old as(1) doesn't like this insn so emit the bytes instead: \ | |
86 | addr32 rep insb (%dx), %es:(%edi); \ | |
87 | */ \ | |
dd4239d6 | 88 | .dc.b 0x67,0xf3,0x6c |
dd4b2659 AG |
89 | |
90 | #define OPTION_ROM_START \ | |
91 | .code16; \ | |
92 | .text; \ | |
93 | .global _start; \ | |
94 | _start:; \ | |
95 | .short 0xaa55; \ | |
96 | .byte (_end - _start) / 512; | |
97 | ||
98 | #define BOOT_ROM_START \ | |
99 | OPTION_ROM_START \ | |
dd4b2659 | 100 | lret; \ |
75b9f690 GN |
101 | .org 0x18; \ |
102 | .short 0; \ | |
103 | .short _pnph; \ | |
104 | _pnph: \ | |
105 | .ascii "$PnP"; \ | |
106 | .byte 0x01; \ | |
107 | .byte ( _pnph_len / 16 ); \ | |
108 | .short 0x0000; \ | |
109 | .byte 0x00; \ | |
110 | .byte 0x00; \ | |
111 | .long 0x00000000; \ | |
112 | .short _manufacturer; \ | |
113 | .short _product; \ | |
114 | .long 0x00000000; \ | |
115 | .short 0x0000; \ | |
116 | .short 0x0000; \ | |
117 | .short _bev; \ | |
118 | .short 0x0000; \ | |
119 | .short 0x0000; \ | |
120 | .equ _pnph_len, . - _pnph; \ | |
121 | _bev:; \ | |
dd4b2659 AG |
122 | /* DS = CS */ \ |
123 | movw %cs, %ax; \ | |
124 | movw %ax, %ds; | |
125 | ||
126 | #define OPTION_ROM_END \ | |
209ca750 JK |
127 | .byte 0; \ |
128 | .align 512, 0; \ | |
dd4b2659 AG |
129 | _end: |
130 | ||
131 | #define BOOT_ROM_END \ | |
75b9f690 GN |
132 | _manufacturer:; \ |
133 | .asciz "QEMU"; \ | |
134 | _product:; \ | |
135 | .asciz BOOT_ROM_PRODUCT; \ | |
dd4b2659 AG |
136 | OPTION_ROM_END |
137 |