Revision c34ebfdc

b/.gitmodules
1
[submodule "roms/vgabios"]
2
	path = roms/vgabios
3
	url = ../vgabios.git
4
[submodule "roms/seabios"]
5
	path = roms/seabios
6
	url = ../seabios.git
7
[submodule "roms/pcbios"]
8
	path = roms/pcbios
9
	url = ../pcbios.git
b/configure
2405 2405
# build tree in object directory if source path is different from current one
2406 2406
if test "$source_path_used" = "yes" ; then
2407 2407
    DIRS="tests tests/cris slirp audio block pc-bios/optionrom"
2408
    DIRS="$DIRS roms/pcbios roms/seabios roms/vgabios"
2408 2409
    FILES="Makefile tests/Makefile"
2409 2410
    FILES="$FILES tests/cris/Makefile tests/cris/.gdbinit"
2410 2411
    FILES="$FILES tests/test-mmap.c"
2411 2412
    FILES="$FILES pc-bios/optionrom/Makefile pc-bios/keymaps pc-bios/video.x"
2413
    FILES="$FILES roms/pcbios/Makefile roms/seabios/Makefile roms/vgabios/Makefile"
2412 2414
    for bios_file in $source_path/pc-bios/*.bin $source_path/pc-bios/*.dtb $source_path/pc-bios/openbios-*; do
2413 2415
        FILES="$FILES pc-bios/`basename $bios_file`"
2414 2416
    done
......
2422 2424
    done
2423 2425
fi
2424 2426

  
2427
# temporary config to build submodules
2428
for rom in seabios vgabios pcbios; do
2429
    config_mak=roms/$rom/config.mak
2430
    echo "# Automatically generated by configure - do not modify" >> $config_mak
2431
    echo "SRC_PATH=$source_path/roms/$rom" >> $config_mak
2432
    echo "CC=$cc" >> $config_mak
2433
    echo "BCC=bcc" >> $config_mak
2434
    echo "CPP=${cross_prefix}cpp" >> $config_mak
2435
    echo "OBJCOPY=objcopy" >> $config_mak
2436
    echo "IASL=iasl" >> $config_mak
2437
    echo "HOST_CC=$host_cc" >> $config_mak
2438
    echo "LD=$ld" >> $config_mak
2439
done
2440

  
2425 2441
for hwlib in 32 64; do
2426 2442
  d=libhw$hwlib
2427 2443
  mkdir -p $d
b/pc-bios/README
1 1
- The PC BIOS comes from the Bochs project (http://bochs.sourceforge.net/).
2
  The patches in bios-pq have been applied. The binary is based on the revision
3
  in bios-pq/HEAD with the patches in bios-pq/series applied.  The git repo
4
  that HEAD refers to is located at
5
  git://git.kernel.org/pub/scm/virt/bochs/bochs.git
6

  
7
  To build these use the following instructions:
8
  using guilt:
9
  $ export QEMUSRC=/path/to/qemu/svn
10
  $ git clone git://git.kernel.org/pub/scm/virt/bochs/bochs.git
11
  $ cd bochs
12
  $ git checkout -b qemu-bios $(cat $QEMUSRC/pc-bios/bios-pq/HEAD)
13

  
14
  $ mkdir -p .git/patches
15
  $ ln -s $QEMUSRC/pc-bios/bios-pq .git/patches/qemu-bios
16
  $ touch .git/patches/qemu-bios/status
17
  $ guilt push -a
18
  $ ./configure
19
  $ cd bios
20
  $ make
21
  $ cp BIOS-bochs-latest $QEMUSRC/pc-bios/bios.bin
22

  
23
  or alternatively (after the git checkout):
24
  $ for p in $(cat $QEMUSRC/pc-bios/bios-pq/series); do git am $p; done
25
  $ ./configure
26
  $ make bios
27 2

  
28 3
- The VGA BIOS and the Cirrus VGA BIOS come from the LGPL VGA bios
29
  project (http://www.nongnu.org/vgabios/).  The binary is based on the revision
30
  in vgabios-pq/HEAD with the patches in vgabios-pq/series applied.  The git
31
  repo that HEAD refers to is located at
32
  git://git.kernel.org/pub/scm/virt/vgabios/vgabios.git
4
  project (http://www.nongnu.org/vgabios/).
33 5

  
34 6
- The PowerPC Open Hack'Ware Open Firmware Compatible BIOS is
35 7
  available at http://perso.magic.fr/l_indien/OpenHackWare/index.htm.
/dev/null
1
--- bochs-2.3.7.orig/bios/rombios.h
2
+++ bochs-2.3.7/bios/rombios.h
3
@@ -19,7 +19,7 @@
4
 //  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301 USA
5
 
6
 /* define it to include QEMU specific code */
7
-//#define BX_QEMU
8
+#define BX_QEMU
9
 
10
 #ifndef LEGACY
11
 #  define BX_ROMBIOS32     1
/dev/null
1
update SMBIOS table to report memory above 4G (Alex Williamson)
2

  
3
Signed-off-by: Alex Williamson <alex.williamson@hp.com>
4
Signed-off-by: Avi Kivity <avi@redhat.com>
5
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
6

  
7
Index: bochs/bios/rombios32.c
8
===================================================================
9
diff --git a/bios/rombios32.c b/bios/rombios32.c
10
index 3269be5..9587288 100644
11
--- a/bios/rombios32.c
12
+++ b/bios/rombios32.c
13
@@ -429,6 +429,7 @@ uint32_t cpuid_signature;
14
 uint32_t cpuid_features;
15
 uint32_t cpuid_ext_features;
16
 unsigned long ram_size;
17
+uint64_t ram_end;
18
 uint8_t bios_uuid[16];
19
 #ifdef BX_USE_EBDA_TABLES
20
 unsigned long ebda_cur_addr;
21
@@ -571,6 +572,13 @@ void ram_probe(void)
22
     ram_size = (cmos_readb(0x30) | (cmos_readb(0x31) << 8)) * 1024 +
23
         1 * 1024 * 1024;
24
   BX_INFO("ram_size=0x%08lx\n", ram_size);
25
+  if (cmos_readb(0x5b) | cmos_readb(0x5c) | cmos_readb(0x5d))
26
+    ram_end = (((uint64_t)cmos_readb(0x5b) << 16) |
27
+               ((uint64_t)cmos_readb(0x5c) << 24) |
28
+               ((uint64_t)cmos_readb(0x5d) << 32)) + (1ull << 32);
29
+  else
30
+    ram_end = ram_size;
31
+  BX_INFO("end of ram=%ldMB\n", ram_end >> 20);
32
 #ifdef BX_USE_EBDA_TABLES
33
   ebda_cur_addr = ((*(uint16_t *)(0x40e)) << 4) + 0x380;
34
   BX_INFO("ebda_cur_addr: 0x%08lx\n", ebda_cur_addr);
35
@@ -2174,7 +2182,8 @@ void smbios_init(void)
36
 {
37
     unsigned cpu_num, nr_structs = 0, max_struct_size = 0;
38
     char *start, *p, *q;
39
-    int memsize = ram_size / (1024 * 1024);
40
+    int memsize = (ram_end == ram_size) ? ram_size / (1024 * 1024) :
41
+                  (ram_end - (1ull << 32) + ram_size) / (1024 * 1024);
42
 
43
 #ifdef BX_USE_EBDA_TABLES
44
     ebda_cur_addr = align(ebda_cur_addr, 16);
45
@@ -2201,8 +2210,8 @@ void smbios_init(void)
46
         add_struct(smbios_type_4_init(p, cpu_num));
47
     add_struct(smbios_type_16_init(p, memsize));
48
     add_struct(smbios_type_17_init(p, memsize));
49
-    add_struct(smbios_type_19_init(p, memsize));
50
-    add_struct(smbios_type_20_init(p, memsize));
51
+    add_struct(smbios_type_19_init(p, ram_end / (1024 * 1024)));
52
+    add_struct(smbios_type_20_init(p, ram_end / (1024 * 1024)));
53
     add_struct(smbios_type_32_init(p));
54
     add_struct(smbios_type_127_init(p));
55
 
/dev/null
1
generate mptable unconditionally (Avi Kivity)
2

  
3
VMware ESX requires an mptable even for uniprocessor guests.
4

  
5
Signed-off-by: Avi Kivity <avi@qumranet.com>
6
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
7

  
8
Index: bochs/bios/rombios32.c
9
===================================================================
10
--- bochs.orig/bios/rombios32.c
11
+++ bochs/bios/rombios32.c
12
@@ -970,11 +970,6 @@ static void mptable_init(void)
13
     int ioapic_id, i, len;
14
     int mp_config_table_size;
15

  
16
-#ifdef BX_QEMU
17
-    if (smp_cpus <= 1)
18
-        return;
19
-#endif
20
-
21
 #ifdef BX_USE_EBDA_TABLES
22
     mp_config_table = (uint8_t *)(ram_size - ACPI_DATA_SIZE - MPTABLE_MAX_SIZE);
23
 #else
24

  
25

  
/dev/null
1
resolve memory device roll over reporting  issues with >32G guests (Bill Rieske)
2

  
3
The field within the Memory Device type 17 is only a word with the MSB being
4
used to report MB/KB.  Thereby, a guest with 32G and greater would report
5
incorrect memory device information rolling over to 0.
6

  
7
This presents more than one memory device and associated memory structures
8
if the memory is larger than 16G
9

  
10
Signed-off-by: Bill Rieske <brieske@novell.com>
11
Signed-off-by: Avi Kivity <avi@redhat.com>
12
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
13

  
14
Index: bochs/bios/rombios32.c
15
===================================================================
16
--- bochs.orig/bios/rombios32.c
17
+++ bochs/bios/rombios32.c
18
@@ -381,6 +381,17 @@ int vsnprintf(char *buf, int buflen, con
19
     return buf - buf0;
20
 }
21

  
22
+int snprintf(char * buf, size_t size, const char *fmt, ...)
23
+{
24
+	va_list args;
25
+	int i;
26
+
27
+	va_start(args, fmt);
28
+	i=vsnprintf(buf,size,fmt,args);
29
+	va_end(args);
30
+	return i;
31
+}
32
+
33
 void bios_printf(int flags, const char *fmt, ...)
34
 {
35
     va_list ap;
36
@@ -2039,7 +2050,7 @@ smbios_type_4_init(void *start, unsigned
37

  
38
 /* Type 16 -- Physical Memory Array */
39
 static void *
40
-smbios_type_16_init(void *start, uint32_t memsize)
41
+smbios_type_16_init(void *start, uint32_t memsize, int nr_mem_devs)
42
 {
43
     struct smbios_type_16 *p = (struct smbios_type_16*)start;
44

  
45
@@ -2052,7 +2063,7 @@ smbios_type_16_init(void *start, uint32_
46
     p->error_correction = 0x01; /* other */
47
     p->maximum_capacity = memsize * 1024;
48
     p->memory_error_information_handle = 0xfffe; /* none provided */
49
-    p->number_of_memory_devices = 1;
50
+    p->number_of_memory_devices = nr_mem_devs;
51

  
52
     start += sizeof(struct smbios_type_16);
53
     *((uint16_t *)start) = 0;
54
@@ -2062,20 +2073,19 @@ smbios_type_16_init(void *start, uint32_
55

  
56
 /* Type 17 -- Memory Device */
57
 static void *
58
-smbios_type_17_init(void *start, uint32_t memory_size_mb)
59
+smbios_type_17_init(void *start, uint32_t memory_size_mb, int instance)
60
 {
61
     struct smbios_type_17 *p = (struct smbios_type_17 *)start;
62

  
63
     p->header.type = 17;
64
     p->header.length = sizeof(struct smbios_type_17);
65
-    p->header.handle = 0x1100;
66
+    p->header.handle = 0x1100 + instance;
67

  
68
     p->physical_memory_array_handle = 0x1000;
69
     p->total_width = 64;
70
     p->data_width = 64;
71
-    /* truncate memory_size_mb to 16 bits and clear most significant
72
-       bit [indicates size in MB] */
73
-    p->size = (uint16_t) memory_size_mb & 0x7fff;
74
+/* TODO: should assert in case something is wrong   ASSERT((memory_size_mb & ~0x7fff) == 0); */
75
+    p->size = memory_size_mb;
76
     p->form_factor = 0x09; /* DIMM */
77
     p->device_set = 0;
78
     p->device_locator_str = 1;
79
@@ -2084,8 +2094,8 @@ smbios_type_17_init(void *start, uint32_
80
     p->type_detail = 0;
81

  
82
     start += sizeof(struct smbios_type_17);
83
-    memcpy((char *)start, "DIMM 1", 7);
84
-    start += 7;
85
+    snprintf(start, 8, "DIMM %d", instance);
86
+    start += strlen(start) + 1;
87
     *((uint8_t *)start) = 0;
88

  
89
     return start+1;
90
@@ -2093,16 +2103,16 @@ smbios_type_17_init(void *start, uint32_
91

  
92
 /* Type 19 -- Memory Array Mapped Address */
93
 static void *
94
-smbios_type_19_init(void *start, uint32_t memory_size_mb)
95
+smbios_type_19_init(void *start, uint32_t memory_size_mb, int instance)
96
 {
97
     struct smbios_type_19 *p = (struct smbios_type_19 *)start;
98

  
99
     p->header.type = 19;
100
     p->header.length = sizeof(struct smbios_type_19);
101
-    p->header.handle = 0x1300;
102
+    p->header.handle = 0x1300 + instance;
103

  
104
-    p->starting_address = 0;
105
-    p->ending_address = (memory_size_mb * 1024) - 1;
106
+    p->starting_address = instance << 24;
107
+    p->ending_address = p->starting_address + (memory_size_mb << 10) - 1;
108
     p->memory_array_handle = 0x1000;
109
     p->partition_width = 1;
110

  
111
@@ -2114,18 +2124,18 @@ smbios_type_19_init(void *start, uint32_
112

  
113
 /* Type 20 -- Memory Device Mapped Address */
114
 static void *
115
-smbios_type_20_init(void *start, uint32_t memory_size_mb)
116
+smbios_type_20_init(void *start, uint32_t memory_size_mb, int instance)
117
 {
118
     struct smbios_type_20 *p = (struct smbios_type_20 *)start;
119

  
120
     p->header.type = 20;
121
     p->header.length = sizeof(struct smbios_type_20);
122
-    p->header.handle = 0x1400;
123
+    p->header.handle = 0x1400 + instance;
124

  
125
-    p->starting_address = 0;
126
-    p->ending_address = (memory_size_mb * 1024) - 1;
127
-    p->memory_device_handle = 0x1100;
128
-    p->memory_array_mapped_address_handle = 0x1300;
129
+    p->starting_address = instance << 24;
130
+    p->ending_address = p->starting_address + (memory_size_mb << 10) - 1;
131
+    p->memory_device_handle = 0x1100 + instance;
132
+    p->memory_array_mapped_address_handle = 0x1300 + instance;
133
     p->partition_row_position = 1;
134
     p->interleave_position = 0;
135
     p->interleaved_data_depth = 0;
136
@@ -2176,6 +2186,7 @@ void smbios_init(void)
137
     char *start, *p, *q;
138
     int memsize = (ram_end == ram_size) ? ram_size / (1024 * 1024) :
139
                   (ram_end - (1ull << 32) + ram_size) / (1024 * 1024);
140
+    int i, nr_mem_devs;
141

  
142
 #ifdef BX_USE_EBDA_TABLES
143
     ebda_cur_addr = align(ebda_cur_addr, 16);
144
@@ -2187,23 +2198,32 @@ void smbios_init(void)
145

  
146
 	p = (char *)start + sizeof(struct smbios_entry_point);
147

  
148
-#define add_struct(fn) { \
149
+#define add_struct(fn) do{ \
150
     q = (fn); \
151
     nr_structs++; \
152
     if ((q - p) > max_struct_size) \
153
         max_struct_size = q - p; \
154
     p = q; \
155
-}
156
+}while (0)
157

  
158
     add_struct(smbios_type_0_init(p));
159
     add_struct(smbios_type_1_init(p));
160
     add_struct(smbios_type_3_init(p));
161
     for (cpu_num = 1; cpu_num <= smp_cpus; cpu_num++)
162
         add_struct(smbios_type_4_init(p, cpu_num));
163
-    add_struct(smbios_type_16_init(p, memsize));
164
-    add_struct(smbios_type_17_init(p, memsize));
165
-    add_struct(smbios_type_19_init(p, ram_end / (1024 * 1024)));
166
-    add_struct(smbios_type_20_init(p, ram_end / (1024 * 1024)));
167
+
168
+    /* Each 'memory device' covers up to 16GB of address space. */
169
+    nr_mem_devs = (memsize + 0x3fff) >> 14;
170
+    add_struct(smbios_type_16_init(p, memsize, nr_mem_devs));
171
+    for ( i = 0; i < nr_mem_devs; i++ )
172
+    {
173
+        uint32_t dev_memsize = ((i == (nr_mem_devs - 1))
174
+                                ? (memsize & 0x3fff) : 0x4000);
175
+        add_struct(smbios_type_17_init(p, dev_memsize, i));
176
+        add_struct(smbios_type_19_init(p, dev_memsize, i));
177
+        add_struct(smbios_type_20_init(p, dev_memsize, i));
178
+    }
179
+
180
     add_struct(smbios_type_32_init(p));
181
     add_struct(smbios_type_127_init(p));
182

  
183

  
184

  
/dev/null
1
fix smbios memory device length boundary  condition (Bill Rieske)
2

  
3
dev_memsize ends up 0 when it shouldn't be on 16G boundary conditions.
4
    
5
Signed-off-by: Bill Rieske <brieske@novell.com>
6
Signed-off-by: Avi Kivity <avi@redhat.com>
7
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
8

  
9
Index: bochs/bios/rombios32.c
10
===================================================================
11
--- bochs.orig/bios/rombios32.c
12
+++ bochs/bios/rombios32.c
13
@@ -2218,7 +2218,7 @@ void smbios_init(void)
14
     for ( i = 0; i < nr_mem_devs; i++ )
15
     {
16
         uint32_t dev_memsize = ((i == (nr_mem_devs - 1))
17
-                                ? (memsize & 0x3fff) : 0x4000);
18
+                                ? (((memsize-1) & 0x3fff)+1) : 0x4000);
19
         add_struct(smbios_type_17_init(p, dev_memsize, i));
20
         add_struct(smbios_type_19_init(p, dev_memsize, i));
21
         add_struct(smbios_type_20_init(p, dev_memsize, i));
22

  
23

  
/dev/null
1
qemu: bios: use preprocessor for pci link routing (Avi Kivity)
2

  
3
Signed-off-by: Avi Kivity <avi@qumranet.com>
4
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
5

  
6
Index: bochs/bios/acpi-dsdt.dsl
7
===================================================================
8
--- bochs.orig/bios/acpi-dsdt.dsl
9
+++ bochs/bios/acpi-dsdt.dsl
10
@@ -47,42 +47,22 @@ DefinitionBlock (
11
                    section 6.2.8.1 */
12
                 /* Note: we provide the same info as the PCI routing
13
                    table of the Bochs BIOS */
14
-
15
-                // PCI Slot 0
16
-                Package() {0x0000ffff, 0, LNKD, 0},
17
-                Package() {0x0000ffff, 1, LNKA, 0},
18
-                Package() {0x0000ffff, 2, LNKB, 0},
19
-                Package() {0x0000ffff, 3, LNKC, 0},
20
-
21
-                // PCI Slot 1
22
-                Package() {0x0001ffff, 0, LNKA, 0},
23
-                Package() {0x0001ffff, 1, LNKB, 0},
24
-                Package() {0x0001ffff, 2, LNKC, 0},
25
-                Package() {0x0001ffff, 3, LNKD, 0},
26
-
27
-                // PCI Slot 2
28
-                Package() {0x0002ffff, 0, LNKB, 0},
29
-                Package() {0x0002ffff, 1, LNKC, 0},
30
-                Package() {0x0002ffff, 2, LNKD, 0},
31
-                Package() {0x0002ffff, 3, LNKA, 0},
32
-
33
-                // PCI Slot 3
34
-                Package() {0x0003ffff, 0, LNKC, 0},
35
-                Package() {0x0003ffff, 1, LNKD, 0},
36
-                Package() {0x0003ffff, 2, LNKA, 0},
37
-                Package() {0x0003ffff, 3, LNKB, 0},
38
-
39
-                // PCI Slot 4
40
-                Package() {0x0004ffff, 0, LNKD, 0},
41
-                Package() {0x0004ffff, 1, LNKA, 0},
42
-                Package() {0x0004ffff, 2, LNKB, 0},
43
-                Package() {0x0004ffff, 3, LNKC, 0},
44
-
45
-                // PCI Slot 5
46
-                Package() {0x0005ffff, 0, LNKA, 0},
47
-                Package() {0x0005ffff, 1, LNKB, 0},
48
-                Package() {0x0005ffff, 2, LNKC, 0},
49
-                Package() {0x0005ffff, 3, LNKD, 0},
50
+#define prt_slot(nr, lnk0, lnk1, lnk2, lnk3) \
51
+       Package() { nr##ffff, 0, lnk0, 0 }, \
52
+       Package() { nr##ffff, 1, lnk1, 0 }, \
53
+       Package() { nr##ffff, 2, lnk2, 0 }, \
54
+       Package() { nr##ffff, 3, lnk3, 0 }
55
+
56
+#define prt_slot0(nr) prt_slot(nr, LNKD, LNKA, LNKB, LNKC)
57
+#define prt_slot1(nr) prt_slot(nr, LNKA, LNKB, LNKC, LNKD)
58
+#define prt_slot2(nr) prt_slot(nr, LNKB, LNKC, LNKD, LNKA)
59
+#define prt_slot3(nr) prt_slot(nr, LNKC, LNKD, LNKA, LNKB)
60
+               prt_slot0(0x0000),
61
+               prt_slot1(0x0001),
62
+               prt_slot2(0x0002),
63
+               prt_slot3(0x0003),
64
+               prt_slot0(0x0004),
65
+               prt_slot1(0x0005),
66
             })
67
 
68
             Name (_CRS, ResourceTemplate ()
69

  
70
-- 
71

  
72

  
73

  
/dev/null
1
bios: add 26 pci slots, bringing the total to 32 (Avi Kivity)
2

  
3
lack of pci slots causes Windows to complain when installing too many devices.
4

  
5
Signed-off-by: Avi Kivity <avi@qumranet.com>
6
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
7

  
8
Index: bochs/bios/acpi-dsdt.dsl
9
===================================================================
10
--- bochs.orig/bios/acpi-dsdt.dsl
11
+++ bochs/bios/acpi-dsdt.dsl
12
@@ -63,6 +63,32 @@ DefinitionBlock (
13
                prt_slot3(0x0003),
14
                prt_slot0(0x0004),
15
                prt_slot1(0x0005),
16
+               prt_slot2(0x0006),
17
+               prt_slot3(0x0007),
18
+               prt_slot0(0x0008),
19
+               prt_slot1(0x0009),
20
+               prt_slot2(0x000a),
21
+               prt_slot3(0x000b),
22
+               prt_slot0(0x000c),
23
+               prt_slot1(0x000d),
24
+               prt_slot2(0x000e),
25
+               prt_slot3(0x000f),
26
+               prt_slot0(0x0010),
27
+               prt_slot1(0x0011),
28
+               prt_slot2(0x0012),
29
+               prt_slot3(0x0013),
30
+               prt_slot0(0x0014),
31
+               prt_slot1(0x0015),
32
+               prt_slot2(0x0016),
33
+               prt_slot3(0x0017),
34
+               prt_slot0(0x0018),
35
+               prt_slot1(0x0019),
36
+               prt_slot2(0x001a),
37
+               prt_slot3(0x001b),
38
+               prt_slot0(0x001c),
39
+               prt_slot1(0x001d),
40
+               prt_slot2(0x001e),
41
+               prt_slot3(0x001f),
42
             })
43
 
44
             Name (_CRS, ResourceTemplate ()
45

  
46
-- 
47

  
48

  
49

  
/dev/null
1
qemu: bios: provide gpe _L0x methods (Glauber Costa)
2

  
3
provide methods for gpe blk 0, even though they do nothing atm
4
    
5
Signed-off-by: Glauber Costa <gcosta@redhat.com>
6
Signed-off-by: Avi Kivity <avi@qumranet.com>
7
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
8

  
9
Index: bochs/bios/acpi-dsdt.dsl
10
===================================================================
11
--- bochs.orig/bios/acpi-dsdt.dsl
12
+++ bochs/bios/acpi-dsdt.dsl
13
@@ -597,4 +597,59 @@ DefinitionBlock (
14
         Zero,  /* reserved */
15
         Zero   /* reserved */
16
     })
17
+
18
+    Scope (\_GPE)
19
+    {
20
+        Name(_HID, "ACPI0006")
21
+
22
+        Method(_L00) {
23
+            Return(0x01)
24
+        }
25
+        Method(_L01) {
26
+            Return(0x01)
27
+        }
28
+        Method(_L02) {
29
+            Return(0x01)
30
+        }
31
+        Method(_L03) {
32
+            Return(0x01)
33
+        }
34
+        Method(_L04) {
35
+            Return(0x01)
36
+        }
37
+        Method(_L05) {
38
+            Return(0x01)
39
+        }
40
+        Method(_L06) {
41
+            Return(0x01)
42
+        }
43
+        Method(_L07) {
44
+            Return(0x01)
45
+        }
46
+        Method(_L08) {
47
+            Return(0x01)
48
+        }
49
+        Method(_L09) {
50
+            Return(0x01)
51
+        }
52
+        Method(_L0A) {
53
+            Return(0x01)
54
+        }
55
+        Method(_L0B) {
56
+            Return(0x01)
57
+        }
58
+        Method(_L0C) {
59
+            Return(0x01)
60
+        }
61
+        Method(_L0D) {
62
+            Return(0x01)
63
+        }
64
+        Method(_L0E) {
65
+            Return(0x01)
66
+        }
67
+        Method(_L0F) {
68
+            Return(0x01)
69
+        }
70
+    }
71
+
72
 }
73
Index: bochs/bios/rombios32.c
74
===================================================================
75
--- bochs.orig/bios/rombios32.c
76
+++ bochs/bios/rombios32.c
77
@@ -1647,6 +1647,8 @@ void acpi_bios_init(void)
78
     fadt->pm_tmr_len = 4;
79
     fadt->plvl2_lat = cpu_to_le16(0xfff); // C2 state not supported
80
     fadt->plvl3_lat = cpu_to_le16(0xfff); // C3 state not supported
81
+    fadt->gpe0_blk = cpu_to_le32(0xafe0);
82
+    fadt->gpe0_blk_len = 4;
83
     /* WBINVD + PROC_C1 + PWR_BUTTON + SLP_BUTTON + FIX_RTC */
84
     fadt->flags = cpu_to_le32((1 << 0) | (1 << 2) | (1 << 4) | (1 << 5) | (1 << 6));
85
     acpi_build_table_header((struct acpi_table_header *)fadt, "FACP",
86

  
87
-- 
88

  
89

  
90

  
91

  
92

  
/dev/null
1
qemu: bios: pci hotplug support (Marcelo Tosatti)
2

  
3
Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>
4
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
5

  
6
Index: bochs/bios/acpi-dsdt.dsl
7
===================================================================
8
--- bochs.orig/bios/acpi-dsdt.dsl
9
+++ bochs/bios/acpi-dsdt.dsl
10
@@ -91,6 +91,61 @@ DefinitionBlock (
11
                prt_slot3(0x001f),
12
             })
13
 
14
+            OperationRegion(PCST, SystemIO, 0xae00, 0x08)
15
+            Field (PCST, DWordAcc, NoLock, WriteAsZeros)
16
+            {
17
+                PCIU, 32,
18
+                PCID, 32,
19
+            }
20
+
21
+            OperationRegion(SEJ, SystemIO, 0xae08, 0x04)
22
+            Field (SEJ, DWordAcc, NoLock, WriteAsZeros)
23
+            {
24
+                B0EJ, 32,
25
+            }
26
+
27
+#define hotplug_slot(name, nr) \
28
+            Device (S##name) {                    \
29
+               Name (_ADR, nr##0000)              \
30
+               Method (_EJ0,1) {                  \
31
+                    Store(ShiftLeft(1, nr), B0EJ) \
32
+                    Return (0x0)                  \
33
+               }                                  \
34
+               Name (_SUN, name)                  \
35
+            }
36
+
37
+	    hotplug_slot(1, 0x0001)
38
+	    hotplug_slot(2, 0x0002)
39
+	    hotplug_slot(3, 0x0003)
40
+	    hotplug_slot(4, 0x0004)
41
+	    hotplug_slot(5, 0x0005)
42
+	    hotplug_slot(6, 0x0006)
43
+	    hotplug_slot(7, 0x0007)
44
+	    hotplug_slot(8, 0x0008)
45
+	    hotplug_slot(9, 0x0009)
46
+	    hotplug_slot(10, 0x000a)
47
+	    hotplug_slot(11, 0x000b)
48
+	    hotplug_slot(12, 0x000c)
49
+	    hotplug_slot(13, 0x000d)
50
+	    hotplug_slot(14, 0x000e)
51
+	    hotplug_slot(15, 0x000f)
52
+	    hotplug_slot(16, 0x0010)
53
+	    hotplug_slot(17, 0x0011)
54
+	    hotplug_slot(18, 0x0012)
55
+	    hotplug_slot(19, 0x0013)
56
+	    hotplug_slot(20, 0x0014)
57
+	    hotplug_slot(21, 0x0015)
58
+	    hotplug_slot(22, 0x0016)
59
+	    hotplug_slot(23, 0x0017)
60
+	    hotplug_slot(24, 0x0018)
61
+	    hotplug_slot(25, 0x0019)
62
+	    hotplug_slot(26, 0x001a)
63
+	    hotplug_slot(27, 0x001b)
64
+	    hotplug_slot(28, 0x001c)
65
+	    hotplug_slot(29, 0x001d)
66
+	    hotplug_slot(30, 0x001e)
67
+	    hotplug_slot(31, 0x001f)
68
+
69
             Name (_CRS, ResourceTemplate ()
70
             {
71
                 WordBusNumber (ResourceProducer, MinFixed, MaxFixed, PosDecode,
72
@@ -605,8 +660,50 @@ DefinitionBlock (
73
         Method(_L00) {
74
             Return(0x01)
75
         }
76
+
77
+#define gen_pci_hotplug(nr)                                       \
78
+            If (And(\_SB.PCI0.PCIU, ShiftLeft(1, nr))) {          \
79
+                Notify(\_SB.PCI0.S##nr, 1)                        \
80
+            }                                                     \
81
+            If (And(\_SB.PCI0.PCID, ShiftLeft(1, nr))) {          \
82
+                Notify(\_SB.PCI0.S##nr, 3)                        \
83
+            }
84
+
85
         Method(_L01) {
86
-            Return(0x01)
87
+            gen_pci_hotplug(1)
88
+            gen_pci_hotplug(2)
89
+            gen_pci_hotplug(3)
90
+            gen_pci_hotplug(4)
91
+            gen_pci_hotplug(5)
92
+            gen_pci_hotplug(6)
93
+            gen_pci_hotplug(7)
94
+            gen_pci_hotplug(8)
95
+            gen_pci_hotplug(9)
96
+            gen_pci_hotplug(10)
97
+            gen_pci_hotplug(11)
98
+            gen_pci_hotplug(12)
99
+            gen_pci_hotplug(13)
100
+            gen_pci_hotplug(14)
101
+            gen_pci_hotplug(15)
102
+            gen_pci_hotplug(16)
103
+            gen_pci_hotplug(17)
104
+            gen_pci_hotplug(18)
105
+            gen_pci_hotplug(19)
106
+            gen_pci_hotplug(20)
107
+            gen_pci_hotplug(21)
108
+            gen_pci_hotplug(22)
109
+            gen_pci_hotplug(23)
110
+            gen_pci_hotplug(24)
111
+            gen_pci_hotplug(25)
112
+            gen_pci_hotplug(26)
113
+            gen_pci_hotplug(27)
114
+            gen_pci_hotplug(28)
115
+            gen_pci_hotplug(29)
116
+            gen_pci_hotplug(30)
117
+            gen_pci_hotplug(31)
118
+
119
+            Return (0x01)
120
+
121
         }
122
         Method(_L02) {
123
             Return(0x01)
124

  
125
-- 
126

  
127

  
128

  
/dev/null
1
bios: mark the acpi sci interrupt as connected to irq 9 (Avi Kivity)
2

  
3
Due to a chipset bug, the sci interrupt is hardwired to irq 9.  Set the
4
pci interrupt line register accordingly.
5
    
6
Signed-off-by: Avi Kivity <avi@qumranet.com>
7
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
8

  
9
Index: bochs/bios/rombios32.c
10
===================================================================
11
--- bochs.orig/bios/rombios32.c
12
+++ bochs/bios/rombios32.c
13
@@ -981,6 +981,8 @@ static void pci_bios_init_device(PCIDevi
14
         /* PIIX4 Power Management device (for ACPI) */
15
         pm_io_base = PM_IO_BASE;
16
         smb_io_base = SMB_IO_BASE;
17
+        // acpi sci is hardwired to 9
18
+        pci_config_writeb(d, PCI_INTERRUPT_LINE, 9);
19
         pm_sci_int = pci_config_readb(d, PCI_INTERRUPT_LINE);
20
         piix4_pm_enable(d);
21
         acpi_enabled = 1;
22

  
23
-- 
24

  
25

  
26

  
/dev/null
1
Read additional ACPI tables from a VM (Gleb Natapov)
2

  
3
Signed-off-by: Gleb Natapov <gleb@redhat.com>
4
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
5

  
6
diff --git a/bios/rombios32.c b/bios/rombios32.c
7
index 27c5952..7be4216 100644
8
--- a/bios/rombios32.c
9
+++ b/bios/rombios32.c
10
@@ -469,6 +469,8 @@ void wrmsr_smp(uint32_t index, uint64_t val)
11
 #define QEMU_CFG_SIGNATURE  0x00
12
 #define QEMU_CFG_ID         0x01
13
 #define QEMU_CFG_UUID       0x02
14
+#define QEMU_CFG_ARCH_LOCAL     0x8000
15
+#define QEMU_CFG_ACPI_TABLES  (QEMU_CFG_ARCH_LOCAL + 0)
16
 
17
 int qemu_cfg_port;
18
 
19
@@ -496,6 +498,27 @@ void qemu_cfg_read(uint8_t *buf, int len)
20
     while (len--)
21
         *(buf++) = inb(QEMU_CFG_DATA_PORT);
22
 }
23
+
24
+static uint16_t acpi_additional_tables(void)
25
+{
26
+    uint16_t cnt;
27
+
28
+    qemu_cfg_select(QEMU_CFG_ACPI_TABLES);
29
+    qemu_cfg_read((uint8_t*)&cnt, sizeof(cnt));
30
+
31
+    return cnt;
32
+}
33
+
34
+static int acpi_load_table(int i, uint32_t addr, uint16_t *len)
35
+{
36
+    qemu_cfg_read((uint8_t*)len, sizeof(*len));
37
+
38
+    if (!*len)
39
+        return -1;
40
+
41
+    qemu_cfg_read((uint8_t*)addr, *len);
42
+    return 0;
43
+}
44
 #endif
45
 
46
 void uuid_probe(void)
47
@@ -1550,8 +1573,8 @@ void acpi_bios_init(void)
48
     uint32_t hpet_addr;
49
 #endif
50
     uint32_t base_addr, rsdt_addr, fadt_addr, addr, facs_addr, dsdt_addr, ssdt_addr;
51
-    uint32_t acpi_tables_size, madt_addr, madt_size;
52
-    int i;
53
+    uint32_t acpi_tables_size, madt_addr, madt_size, rsdt_size;
54
+    uint16_t i, external_tables;
55
 
56
     /* reserve memory space for tables */
57
 #ifdef BX_USE_EBDA_TABLES
58
@@ -1564,10 +1587,17 @@ void acpi_bios_init(void)
59
     bios_table_cur_addr += sizeof(*rsdp);
60
 #endif
61
 
62
+#ifdef BX_QEMU
63
+    external_tables = acpi_additional_tables();
64
+#else
65
+    external_tables = 0;
66
+#endif
67
+
68
     addr = base_addr = ram_size - ACPI_DATA_SIZE;
69
     rsdt_addr = addr;
70
     rsdt = (void *)(addr);
71
-    addr += sizeof(*rsdt);
72
+    rsdt_size = sizeof(*rsdt) + external_tables * 4;
73
+    addr += rsdt_size;
74
 
75
     fadt_addr = addr;
76
     fadt = (void *)(addr);
77
@@ -1606,12 +1636,6 @@ void acpi_bios_init(void)
78
     addr += sizeof(*hpet);
79
 #endif
80
 
81
-    acpi_tables_size = addr - base_addr;
82
-
83
-    BX_INFO("ACPI tables: RSDP addr=0x%08lx ACPI DATA addr=0x%08lx size=0x%x\n",
84
-            (unsigned long)rsdp,
85
-            (unsigned long)rsdt, acpi_tables_size);
86
-
87
     /* RSDP */
88
     memset(rsdp, 0, sizeof(*rsdp));
89
     memcpy(rsdp->signature, "RSD PTR ", 8);
90
@@ -1623,17 +1647,6 @@ void acpi_bios_init(void)
91
     rsdp->rsdt_physical_address = cpu_to_le32(rsdt_addr);
92
     rsdp->checksum = acpi_checksum((void *)rsdp, 20);
93
 
94
-    /* RSDT */
95
-    memset(rsdt, 0, sizeof(*rsdt));
96
-    rsdt->table_offset_entry[0] = cpu_to_le32(fadt_addr);
97
-    rsdt->table_offset_entry[1] = cpu_to_le32(madt_addr);
98
-    rsdt->table_offset_entry[2] = cpu_to_le32(ssdt_addr);
99
-#ifdef BX_QEMU
100
-    rsdt->table_offset_entry[3] = cpu_to_le32(hpet_addr);
101
-#endif
102
-    acpi_build_table_header((struct acpi_table_header *)rsdt,
103
-                            "RSDT", sizeof(*rsdt), 1);
104
-
105
     /* FADT */
106
     memset(fadt, 0, sizeof(*fadt));
107
     fadt->firmware_ctrl = cpu_to_le32(facs_addr);
108
@@ -1710,6 +1723,7 @@ void acpi_bios_init(void)
109
                                 "APIC", madt_size, 1);
110
     }
111
 
112
+    memset(rsdt, 0, rsdt_size);
113
 #ifdef BX_QEMU
114
     /* HPET */
115
     memset(hpet, 0, sizeof(*hpet));
116
@@ -1720,7 +1734,34 @@ void acpi_bios_init(void)
117
     hpet->addr.address = cpu_to_le32(ACPI_HPET_ADDRESS);
118
     acpi_build_table_header((struct  acpi_table_header *)hpet,
119
                              "HPET", sizeof(*hpet), 1);
120
+
121
+    acpi_additional_tables(); /* resets cfg to required entry */
122
+    for(i = 0; i < external_tables; i++) {
123
+        uint16_t len;
124
+        if(acpi_load_table(i, addr, &len) < 0)
125
+            BX_PANIC("Failed to load ACPI table from QEMU\n");
126
+        rsdt->table_offset_entry[i+4] = cpu_to_le32(addr);
127
+        addr += len;
128
+        if(addr >= ram_size)
129
+            BX_PANIC("ACPI table overflow\n");
130
+    }
131
+#endif
132
+
133
+    /* RSDT */
134
+    rsdt->table_offset_entry[0] = cpu_to_le32(fadt_addr);
135
+    rsdt->table_offset_entry[1] = cpu_to_le32(madt_addr);
136
+    rsdt->table_offset_entry[2] = cpu_to_le32(ssdt_addr);
137
+#ifdef BX_QEMU
138
+    rsdt->table_offset_entry[3] = cpu_to_le32(hpet_addr);
139
 #endif
140
+    acpi_build_table_header((struct acpi_table_header *)rsdt,
141
+                            "RSDT", rsdt_size, 1);
142
+
143
+    acpi_tables_size = addr - base_addr;
144
+
145
+    BX_INFO("ACPI tables: RSDP addr=0x%08lx ACPI DATA addr=0x%08lx size=0x%x\n",
146
+            (unsigned long)rsdp,
147
+            (unsigned long)rsdt, acpi_tables_size);
148
 
149
 }
150
 
/dev/null
1
qemu:bios: Load SMBIOS entries and files from qemu (Alex Williamson)
2

  
3
Allow SMBIOS fields to be overridden and entries replaced by those
4
read from qemu.
5

  
6
Signed-off-by: Alex Williamson <alex.williamson@hp.com>
7
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
8

  
9
diff --git a/bios/rombios32.c b/bios/rombios32.c
10
index 7be4216..1a1ed64 100644
11
--- a/bios/rombios32.c
12
+++ b/bios/rombios32.c
13
@@ -441,7 +441,6 @@ uint32_t cpuid_features;
14
 uint32_t cpuid_ext_features;
15
 unsigned long ram_size;
16
 uint64_t ram_end;
17
-uint8_t bios_uuid[16];
18
 #ifdef BX_USE_EBDA_TABLES
19
 unsigned long ebda_cur_addr;
20
 #endif
21
@@ -471,6 +470,7 @@ void wrmsr_smp(uint32_t index, uint64_t val)
22
 #define QEMU_CFG_UUID       0x02
23
 #define QEMU_CFG_ARCH_LOCAL     0x8000
24
 #define QEMU_CFG_ACPI_TABLES  (QEMU_CFG_ARCH_LOCAL + 0)
25
+#define QEMU_CFG_SMBIOS_ENTRIES  (QEMU_CFG_ARCH_LOCAL + 1)
26
 
27
 int qemu_cfg_port;
28
 
29
@@ -519,19 +519,17 @@ static int acpi_load_table(int i, uint32_t addr, uint16_t *len)
30
     qemu_cfg_read((uint8_t*)addr, *len);
31
     return 0;
32
 }
33
-#endif
34
 
35
-void uuid_probe(void)
36
+static uint16_t smbios_entries(void)
37
 {
38
-#ifdef BX_QEMU
39
-    if(qemu_cfg_port) {
40
-        qemu_cfg_select(QEMU_CFG_UUID);
41
-        qemu_cfg_read(bios_uuid, 16);
42
-        return;
43
-    }
44
-#endif
45
-    memset(bios_uuid, 0, 16);
46
+    uint16_t cnt;
47
+
48
+    qemu_cfg_select(QEMU_CFG_SMBIOS_ENTRIES);
49
+    qemu_cfg_read((uint8_t*)&cnt, sizeof(cnt));
50
+
51
+    return cnt;
52
 }
53
+#endif
54
 
55
 void cpu_probe(void)
56
 {
57
@@ -1963,21 +1961,105 @@ smbios_entry_point_init(void *start,
58
     ep->intermediate_checksum = -sum;
59
     }
60
 
61
+struct smbios_header {
62
+    uint16_t length;
63
+    uint8_t type;
64
+} __attribute__((__packed__));
65
+
66
+struct smbios_field {
67
+    struct smbios_header header;
68
+    uint8_t type;
69
+    uint16_t offset;
70
+    uint8_t data[];
71
+} __attribute__((__packed__));
72
+
73
+struct smbios_table {
74
+    struct smbios_header header;
75
+    uint8_t data[];
76
+} __attribute__((__packed__));
77
+
78
+#define SMBIOS_FIELD_ENTRY 0
79
+#define SMBIOS_TABLE_ENTRY 1
80
+
81
+static size_t
82
+smbios_load_field(int type, size_t offset, void *addr)
83
+{
84
+#ifdef BX_QEMU
85
+    int i;
86
+
87
+    for (i = smbios_entries(); i > 0; i--) {
88
+        struct smbios_field field;
89
+
90
+        qemu_cfg_read((uint8_t *)&field, sizeof(struct smbios_header));
91
+        field.header.length -= sizeof(struct smbios_header);
92
+
93
+        if (field.header.type != SMBIOS_FIELD_ENTRY) {
94
+            while (field.header.length--)
95
+                inb(QEMU_CFG_DATA_PORT);
96
+            continue;
97
+        }
98
+
99
+        qemu_cfg_read((uint8_t *)&field.type,
100
+                      sizeof(field) - sizeof(struct smbios_header));
101
+        field.header.length -= sizeof(field) - sizeof(struct smbios_header);
102
+
103
+        if (field.type != type || field.offset != offset) {
104
+            while (field.header.length--)
105
+                inb(QEMU_CFG_DATA_PORT);
106
+            continue;
107
+        }
108
+
109
+        qemu_cfg_read(addr, field.header.length);
110
+        return (size_t)field.header.length;
111
+    }
112
+#endif
113
+    return 0;
114
+}
115
+ 
116
+#define load_str_field_with_default(type, field, def) do {             \
117
+    size = smbios_load_field(type, offsetof(struct smbios_type_##type, \
118
+                                            field), end);              \
119
+    if (size > 0) {                                                    \
120
+        end += size;                                                   \
121
+    } else {                                                           \
122
+        memcpy(end, def, sizeof(def));                                 \
123
+        end += sizeof(def);                                            \
124
+    }                                                                  \
125
+    p->field = ++str_index;                                            \
126
+} while (0)
127
+
128
+#define load_str_field_or_skip(type, field) do {                       \
129
+    size = smbios_load_field(type, offsetof(struct smbios_type_##type, \
130
+                                            field), end);              \
131
+    if (size > 0) {                                                    \
132
+        end += size;                                                   \
133
+        p->field = ++str_index;                                        \
134
+    } else {                                                           \
135
+        p->field = 0;                                                  \
136
+    }                                                                  \
137
+} while (0)
138
+
139
 /* Type 0 -- BIOS Information */
140
 #define RELEASE_DATE_STR "01/01/2007"
141
 static void *
142
-smbios_type_0_init(void *start)
143
+smbios_init_type_0(void *start)
144
 {
145
     struct smbios_type_0 *p = (struct smbios_type_0 *)start;
146
+    char *end = (char *)start + sizeof(struct smbios_type_0);
147
+    size_t size;
148
+    int str_index = 0;
149
 
150
     p->header.type = 0;
151
     p->header.length = sizeof(struct smbios_type_0);
152
     p->header.handle = 0;
153
 
154
-    p->vendor_str = 1;
155
-    p->bios_version_str = 1;
156
+    load_str_field_with_default(0, vendor_str, BX_APPNAME);
157
+    load_str_field_with_default(0, bios_version_str, BX_APPNAME);
158
+
159
     p->bios_starting_address_segment = 0xe800;
160
-    p->bios_release_date_str = 2;
161
+
162
+    load_str_field_with_default(0, bios_release_date_str, RELEASE_DATE_STR);
163
+
164
     p->bios_rom_size = 0; /* FIXME */
165
 
166
     memset(p->bios_characteristics, 0, 8);
167
@@ -1985,50 +2067,66 @@ smbios_type_0_init(void *start)
168
     p->bios_characteristics_extension_bytes[0] = 0;
169
     p->bios_characteristics_extension_bytes[1] = 0;
170
 
171
-    p->system_bios_major_release = 1;
172
-    p->system_bios_minor_release = 0;
173
+    if (!smbios_load_field(0, offsetof(struct smbios_type_0,
174
+                                       system_bios_major_release),
175
+                           &p->system_bios_major_release))
176
+        p->system_bios_major_release = 1;
177
+
178
+    if (!smbios_load_field(0, offsetof(struct smbios_type_0,
179
+                                       system_bios_minor_release),
180
+                           &p->system_bios_minor_release))
181
+        p->system_bios_minor_release = 0;
182
+
183
     p->embedded_controller_major_release = 0xff;
184
     p->embedded_controller_minor_release = 0xff;
185
 
186
-    start += sizeof(struct smbios_type_0);
187
-    memcpy((char *)start, BX_APPNAME, sizeof(BX_APPNAME));
188
-    start += sizeof(BX_APPNAME);
189
-    memcpy((char *)start, RELEASE_DATE_STR, sizeof(RELEASE_DATE_STR));
190
-    start += sizeof(RELEASE_DATE_STR);
191
-    *((uint8_t *)start) = 0;
192
+    *end = 0;
193
+    end++;
194
 
195
-    return start+1;
196
+    return end;
197
 }
198
 
199
 /* Type 1 -- System Information */
200
 static void *
201
-smbios_type_1_init(void *start)
202
+smbios_init_type_1(void *start)
203
 {
204
     struct smbios_type_1 *p = (struct smbios_type_1 *)start;
205
+    char *end = (char *)start + sizeof(struct smbios_type_1);
206
+    size_t size;
207
+    int str_index = 0;
208
+
209
     p->header.type = 1;
210
     p->header.length = sizeof(struct smbios_type_1);
211
     p->header.handle = 0x100;
212
 
213
-    p->manufacturer_str = 0;
214
-    p->product_name_str = 0;
215
-    p->version_str = 0;
216
-    p->serial_number_str = 0;
217
+    load_str_field_or_skip(1, manufacturer_str);
218
+    load_str_field_or_skip(1, product_name_str);
219
+    load_str_field_or_skip(1, version_str);
220
+    load_str_field_or_skip(1, serial_number_str);
221
 
222
-    memcpy(p->uuid, bios_uuid, 16);
223
+    size = smbios_load_field(1, offsetof(struct smbios_type_1,
224
+                                         uuid), &p->uuid);
225
+    if (size == 0)
226
+        memset(p->uuid, 0, 16);
227
 
228
     p->wake_up_type = 0x06; /* power switch */
229
-    p->sku_number_str = 0;
230
-    p->family_str = 0;
231
 
232
-    start += sizeof(struct smbios_type_1);
233
-    *((uint16_t *)start) = 0;
234
+    load_str_field_or_skip(1, sku_number_str);
235
+    load_str_field_or_skip(1, family_str);
236
 
237
-    return start+2;
238
+    *end = 0;
239
+    end++;
240
+    if (!str_index) {
241
+        *end = 0;
242
+        end++;
243
+    }
244
+
245
+    return end;
246
 }
247
 
248
 /* Type 3 -- System Enclosure */
249
 static void *
250
-smbios_type_3_init(void *start)
251
+smbios_init_type_3(void *start)
252
 {
253
     struct smbios_type_3 *p = (struct smbios_type_3 *)start;
254
 
255
@@ -2058,7 +2156,7 @@ smbios_type_3_init(void *start)
256
 
257
 /* Type 4 -- Processor Information */
258
 static void *
259
-smbios_type_4_init(void *start, unsigned int cpu_number)
260
+smbios_init_type_4(void *start, unsigned int cpu_number)
261
 {
262
     struct smbios_type_4 *p = (struct smbios_type_4 *)start;
263
 
264
@@ -2098,7 +2196,7 @@ smbios_type_4_init(void *start, unsigned int cpu_number)
265
 
266
 /* Type 16 -- Physical Memory Array */
267
 static void *
268
-smbios_type_16_init(void *start, uint32_t memsize, int nr_mem_devs)
269
+smbios_init_type_16(void *start, uint32_t memsize, int nr_mem_devs)
270
 {
271
     struct smbios_type_16 *p = (struct smbios_type_16*)start;
272
 
273
@@ -2121,7 +2219,7 @@ smbios_type_16_init(void *start, uint32_t memsize, int nr_mem_devs)
274
 
275
 /* Type 17 -- Memory Device */
276
 static void *
277
-smbios_type_17_init(void *start, uint32_t memory_size_mb, int instance)
278
+smbios_init_type_17(void *start, uint32_t memory_size_mb, int instance)
279
 {
280
     struct smbios_type_17 *p = (struct smbios_type_17 *)start;
281
 
282
@@ -2151,7 +2249,7 @@ smbios_type_17_init(void *start, uint32_t memory_size_mb, int instance)
283
 
284
 /* Type 19 -- Memory Array Mapped Address */
285
 static void *
286
-smbios_type_19_init(void *start, uint32_t memory_size_mb, int instance)
287
+smbios_init_type_19(void *start, uint32_t memory_size_mb, int instance)
288
 {
289
     struct smbios_type_19 *p = (struct smbios_type_19 *)start;
290
 
291
@@ -2172,7 +2270,7 @@ smbios_type_19_init(void *start, uint32_t memory_size_mb, int instance)
292
 
293
 /* Type 20 -- Memory Device Mapped Address */
294
 static void *
295
-smbios_type_20_init(void *start, uint32_t memory_size_mb, int instance)
296
+smbios_init_type_20(void *start, uint32_t memory_size_mb, int instance)
297
 {
298
     struct smbios_type_20 *p = (struct smbios_type_20 *)start;
299
 
300
@@ -2196,7 +2294,7 @@ smbios_type_20_init(void *start, uint32_t memory_size_mb, int instance)
301
 
302
 /* Type 32 -- System Boot Information */
303
 static void *
304
-smbios_type_32_init(void *start)
305
+smbios_init_type_32(void *start)
306
 {
307
     struct smbios_type_32 *p = (struct smbios_type_32 *)start;
308
 
309
@@ -2214,7 +2312,7 @@ smbios_type_32_init(void *start)
310
 
311
 /* Type 127 -- End of Table */
312
 static void *
313
-smbios_type_127_init(void *start)
314
+smbios_init_type_127(void *start)
315
 {
316
     struct smbios_type_127 *p = (struct smbios_type_127 *)start;
317
 
318
@@ -2228,6 +2326,78 @@ smbios_type_127_init(void *start)
319
     return start + 2;
320
 }
321
 
322
+static int
323
+smbios_load_external(int type, char **p, unsigned *nr_structs,
324
+                     unsigned *max_struct_size)
325
+{
326
+#ifdef BX_QEMU
327
+    static uint64_t used_bitmap[4] = { 0 };
328
+    char *start = *p;
329
+    int i;
330
+
331
+    /* Check if we've already reported these tables */
332
+    if (used_bitmap[(type >> 6) & 0x3] & (1ULL << (type & 0x3f)))
333
+        return 1;
334
+
335
+    /* Don't introduce spurious end markers */
336
+    if (type == 127)
337
+        return 0;
338
+
339
+    for (i = smbios_entries(); i > 0; i--) {
340
+        struct smbios_table table;
341
+        struct smbios_structure_header *header = (void *)*p;
342
+        int string;
343
+
344
+        qemu_cfg_read((uint8_t *)&table, sizeof(struct smbios_header));
345
+        table.header.length -= sizeof(struct smbios_header);
346
+
347
+        if (table.header.type != SMBIOS_TABLE_ENTRY) {
348
+            while (table.header.length--)
349
+                inb(QEMU_CFG_DATA_PORT);
350
+            continue;
351
+        }
352
+
353
+        qemu_cfg_read((uint8_t *)*p, sizeof(struct smbios_structure_header));
354
+        table.header.length -= sizeof(struct smbios_structure_header);
355
+
356
+        if (header->type != type) {
357
+            while (table.header.length--)
358
+                inb(QEMU_CFG_DATA_PORT);
359
+            continue;
360
+        }
361
+
362
+        *p += sizeof(struct smbios_structure_header);
363
+
364
+        /* Entries end with a double NULL char, if there's a string at
365
+         * the end (length is greater than formatted length), the string
366
+         * terminator provides the first NULL. */
367
+        string = header->length < table.header.length +
368
+                 sizeof(struct smbios_structure_header);
369
+
370
+        /* Read the rest and terminate the entry */
371
+        qemu_cfg_read((uint8_t *)*p, table.header.length);
372
+        *p += table.header.length;
373
+        *((uint8_t*)*p) = 0;
374
+        (*p)++;
375
+        if (!string) {
376
+            *((uint8_t*)*p) = 0;
377
+            (*p)++;
378
+        }
379
+
380
+        (*nr_structs)++;
381
+        if (*p - (char *)header > *max_struct_size)
382
+            *max_struct_size = *p - (char *)header;
383
+    }
384
+
385
+    /* Mark that we've reported on this type */
386
+    used_bitmap[(type >> 6) & 0x3] |= (1ULL << (type & 0x3f));
387
+
388
+    return (start != *p);
389
+#else /* !BX_QEMU */
390
+    return 0;
391
+#endif
392
+}
393
+
394
 void smbios_init(void)
395
 {
396
     unsigned cpu_num, nr_structs = 0, max_struct_size = 0;
397
@@ -2246,34 +2416,39 @@ void smbios_init(void)
398
 
399
 	p = (char *)start + sizeof(struct smbios_entry_point);
400
 
401
-#define add_struct(fn) do{ \
402
-    q = (fn); \
403
-    nr_structs++; \
404
-    if ((q - p) > max_struct_size) \
405
-        max_struct_size = q - p; \
406
-    p = q; \
407
-}while (0)
408
-
409
-    add_struct(smbios_type_0_init(p));
410
-    add_struct(smbios_type_1_init(p));
411
-    add_struct(smbios_type_3_init(p));
412
+#define add_struct(type, args...) do {                                    \
413
+    if (!smbios_load_external(type, &p, &nr_structs, &max_struct_size)) { \
414
+        q = smbios_init_type_##type(args);                                \
415
+        nr_structs++;                                                     \
416
+        if ((q - p) > max_struct_size)                                    \
417
+            max_struct_size = q - p;                                      \
418
+        p = q;                                                            \
419
+    }                                                                     \
420
+} while (0)
421
+
422
+    add_struct(0, p);
423
+    add_struct(1, p);
424
+    add_struct(3, p);
425
     for (cpu_num = 1; cpu_num <= smp_cpus; cpu_num++)
426
-        add_struct(smbios_type_4_init(p, cpu_num));
427
+        add_struct(4, p, cpu_num);
428
 
429
     /* Each 'memory device' covers up to 16GB of address space. */
430
     nr_mem_devs = (memsize + 0x3fff) >> 14;
431
-    add_struct(smbios_type_16_init(p, memsize, nr_mem_devs));
432
+    add_struct(16, p, memsize, nr_mem_devs);
433
     for ( i = 0; i < nr_mem_devs; i++ )
434
     {
435
         uint32_t dev_memsize = ((i == (nr_mem_devs - 1))
436
                                 ? (((memsize-1) & 0x3fff)+1) : 0x4000);
437
-        add_struct(smbios_type_17_init(p, dev_memsize, i));
438
-        add_struct(smbios_type_19_init(p, dev_memsize, i));
439
-        add_struct(smbios_type_20_init(p, dev_memsize, i));
440
+        add_struct(17, p, dev_memsize, i);
441
+        add_struct(19, p, dev_memsize, i);
442
+        add_struct(20, p, dev_memsize, i);
443
     }
444
 
445
-    add_struct(smbios_type_32_init(p));
446
-    add_struct(smbios_type_127_init(p));
447
+    add_struct(32, p);
448
+    /* Add any remaining provided entries before the end marker */
449
+    for (i = 0; i < 256; i++)
450
+        smbios_load_external(i, &p, &nr_structs, &max_struct_size);
451
+    add_struct(127, p);
452
 
453
 #undef add_struct
454
 
455
@@ -2380,8 +2555,6 @@ void rombios32_init(uint32_t *s3_resume_vector, uint8_t *shutdown_flag)
456
 
457
         mptable_init();
458
 
459
-        uuid_probe();
460
-
461
         smbios_init();
462
 
463
         if (acpi_enabled)
464

  
465

  
466
--
467
To unsubscribe from this list: send the line "unsubscribe kvm" in
468
the body of a message to majordomo@vger.kernel.org
469
More majordomo info at  http://vger.kernel.org/majordomo-info.html
470

  
/dev/null
1
From c09142004a409bf27070939f470c5e0b37595a5a Mon Sep 17 00:00:00 2001
2
From: Beth Kon <eak@us.ibm.com>
3
Date: Fri, 19 Jun 2009 14:22:00 -0400
4
Subject: [PATCH] Fix non-ACPI Timer Interrupt Routing - v3
5

  
6
Replicate ACPI irq0->inti2 override in mp table for non-acpi case.
7

  
8
v1 -> v2 adds comment suggested by Ryan.
9
v2 -> v3 clarifies comment and corrects entry count
10

  
11
Signed-off-by: Beth Kon <eak@us.ibm.com>
12
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
13
---
14
 bios/rombios32.c |   14 ++++++++++++++
15
 1 files changed, 14 insertions(+), 0 deletions(-)
16

  
17
diff --git a/bios/rombios32.c b/bios/rombios32.c
18
index 1a1ed64..d789e20 100644
19
--- a/bios/rombios32.c
20
+++ b/bios/rombios32.c
21
@@ -1124,7 +1124,11 @@ static void mptable_init(void)
22
     putstr(&q, "0.1         "); /* vendor id */
23
     putle32(&q, 0); /* OEM table ptr */
24
     putle16(&q, 0); /* OEM table size */
25
+#ifdef BX_QEMU
26
+    putle16(&q, smp_cpus + 17); /* entry count */
27
+#else
28
     putle16(&q, smp_cpus + 18); /* entry count */
29
+#endif
30
     putle32(&q, 0xfee00000); /* local APIC addr */
31
     putle16(&q, 0); /* ext table length */
32
     putb(&q, 0); /* ext table checksum */
33
@@ -1166,6 +1170,12 @@ static void mptable_init(void)
34
 
... This diff was truncated because it exceeds the maximum size that can be displayed.

Also available in: Unified diff