Revision dd4b2659
b/pc-bios/optionrom/multiboot.S | ||
---|---|---|
18 | 18 |
* Authors: Alexander Graf <agraf@suse.de> |
19 | 19 |
*/ |
20 | 20 |
|
21 |
#define NO_QEMU_PROTOS |
|
22 |
#include "../../hw/fw_cfg.h" |
|
23 |
|
|
24 |
#define BIOS_CFG_IOPORT_CFG 0x510 |
|
25 |
#define BIOS_CFG_IOPORT_DATA 0x511 |
|
21 |
#include "optionrom.h" |
|
26 | 22 |
|
27 | 23 |
#define MULTIBOOT_MAGIC 0x2badb002 |
28 | 24 |
|
29 | 25 |
#define GS_PROT_JUMP 0 |
30 | 26 |
#define GS_GDT_DESC 6 |
31 | 27 |
|
32 |
/* Break the translation block flow so -d cpu shows us values */ |
|
33 |
#define DEBUG_HERE \ |
|
34 |
jmp 1f; \ |
|
35 |
1: |
|
36 |
|
|
37 |
/* Read a variable from the fw_cfg device. |
|
38 |
Clobbers: %edx |
|
39 |
Out: %eax */ |
|
40 |
.macro read_fw VAR |
|
41 |
mov $\VAR, %ax |
|
42 |
mov $BIOS_CFG_IOPORT_CFG, %dx |
|
43 |
outw %ax, (%dx) |
|
44 |
mov $BIOS_CFG_IOPORT_DATA, %dx |
|
45 |
inb (%dx), %al |
|
46 |
shl $8, %eax |
|
47 |
inb (%dx), %al |
|
48 |
shl $8, %eax |
|
49 |
inb (%dx), %al |
|
50 |
shl $8, %eax |
|
51 |
inb (%dx), %al |
|
52 |
bswap %eax |
|
53 |
.endm |
|
54 | 28 |
|
55 |
/* |
|
56 |
* Read a blob from the fw_cfg device. |
|
57 |
* Requires _ADDR, _SIZE and _DATA values for the parameter. |
|
58 |
* |
|
59 |
* Clobbers: %eax, %edx, %es, %ecx, %edi |
|
60 |
*/ |
|
61 |
#define read_fw_blob(var) \ |
|
62 |
read_fw var ## _ADDR; \ |
|
63 |
mov %eax, %edi; \ |
|
64 |
read_fw var ## _SIZE; \ |
|
65 |
mov %eax, %ecx; \ |
|
66 |
mov $var ## _DATA, %ax; \ |
|
67 |
mov $BIOS_CFG_IOPORT_CFG, %edx; \ |
|
68 |
outw %ax, (%dx); \ |
|
69 |
mov $BIOS_CFG_IOPORT_DATA, %dx; \ |
|
70 |
cld; \ |
|
71 |
DEBUG_HERE \ |
|
72 |
rep insb (%dx), %es:(%edi); |
|
73 |
|
|
74 |
.code16 |
|
75 |
.text |
|
76 |
.global _start |
|
77 |
_start: |
|
78 |
.short 0xaa55 |
|
79 |
.byte (_end - _start) / 512 |
|
80 |
push %eax |
|
81 |
push %ds |
|
82 |
|
|
83 |
/* setup ds so we can access the IVT */ |
|
84 |
xor %ax, %ax |
|
85 |
mov %ax, %ds |
|
86 |
|
|
87 |
/* install our int 19 handler */ |
|
88 |
movw $int19_handler, (0x19*4) |
|
89 |
mov %cs, (0x19*4+2) |
|
90 |
|
|
91 |
pop %ds |
|
92 |
pop %eax |
|
93 |
lret |
|
94 |
|
|
95 |
int19_handler: |
|
96 |
/* DS = CS */ |
|
97 |
movw %cs, %ax |
|
98 |
movw %ax, %ds |
|
99 |
|
|
100 |
/* fall through */ |
|
29 |
BOOT_ROM_START |
|
101 | 30 |
|
102 | 31 |
run_multiboot: |
103 | 32 |
|
... | ... | |
249 | 178 |
.short (5 * 8) - 1 |
250 | 179 |
.long gdt |
251 | 180 |
|
252 |
.align 512, 0 |
|
253 |
_end: |
|
254 |
|
|
181 |
BOOT_ROM_END |
b/pc-bios/optionrom/optionrom.h | ||
---|---|---|
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 |
|
Also available in: Unified diff