Statistics
| Branch: | Revision:

root / pc-bios / bios-pq / 0021-qemu-madt-maxcpus.patch @ baef8a66

History | View | Annotate | Download (4.2 kB)

1
Use max_cpus when building bios tables.
2

    
3
Signed-off-by: Jes Sorensen <jes@sgi.com>
4

    
5
diff --git a/bios/rombios32.c b/bios/rombios32.c
6
index e6bb164..3d15283 100644
7
--- a/bios/rombios32.c
8
+++ b/bios/rombios32.c
9
@@ -1145,23 +1145,25 @@ static void mptable_init(void)
10
     putle32(&q, 0); /* OEM table ptr */
11
     putle16(&q, 0); /* OEM table size */
12
 #ifdef BX_QEMU
13
-    putle16(&q, smp_cpus + 17); /* entry count */
14
+    putle16(&q, max_cpus + 17); /* entry count */
15
 #else
16
-    putle16(&q, smp_cpus + 18); /* entry count */
17
+    putle16(&q, max_cpus + 18); /* entry count */
18
 #endif
19
     putle32(&q, 0xfee00000); /* local APIC addr */
20
     putle16(&q, 0); /* ext table length */
21
     putb(&q, 0); /* ext table checksum */
22
     putb(&q, 0); /* reserved */
23
 
24
-    for(i = 0; i < smp_cpus; i++) {
25
+    for(i = 0; i < max_cpus; i++) {
26
         putb(&q, 0); /* entry type = processor */
27
         putb(&q, i); /* APIC id */
28
         putb(&q, 0x11); /* local APIC version number */
29
         if (i == 0)
30
             putb(&q, 3); /* cpu flags: enabled, bootstrap cpu */
31
-        else
32
+        else if (i < smp_cpus)
33
             putb(&q, 1); /* cpu flags: enabled */
34
+        else
35
+            putb(&q, 0); /* cpu flags: disabled */
36
         putb(&q, 0); /* cpu signature */
37
         putb(&q, 6);
38
         putb(&q, 0);
39
@@ -1181,7 +1183,7 @@ static void mptable_init(void)
40
     putstr(&q, "ISA   ");
41
 
42
     /* ioapic */
43
-    ioapic_id = smp_cpus;
44
+    ioapic_id = max_cpus;
45
     putb(&q, 2); /* entry type = I/O APIC */
46
     putb(&q, ioapic_id); /* apic ID */
47
     putb(&q, 0x11); /* I/O APIC version number */
48
@@ -1581,7 +1583,7 @@ int acpi_build_processor_ssdt(uint8_t *ssdt)
49
 {
50
     uint8_t *ssdt_ptr = ssdt;
51
     int i, length;
52
-    int acpi_cpus = smp_cpus > 0xff ? 0xff : smp_cpus;
53
+    int acpi_cpus = max_cpus > 0xff ? 0xff : max_cpus;
54
 
55
     ssdt_ptr[9] = 0; // checksum;
56
     ssdt_ptr += sizeof(struct acpi_table_header);
57
@@ -1713,7 +1715,7 @@ void acpi_bios_init(void)
58
         addr = (addr + 7) & ~7;
59
         srat_addr = addr;
60
         srat_size = sizeof(*srat) +
61
-            sizeof(struct srat_processor_affinity) * smp_cpus +
62
+            sizeof(struct srat_processor_affinity) * max_cpus +
63
             sizeof(struct srat_memory_affinity) * (nb_numa_nodes + 2);
64
         srat = (void *)(addr);
65
         addr += srat_size;
66
@@ -1726,7 +1728,7 @@ void acpi_bios_init(void)
67
     addr = (addr + 7) & ~7;
68
     madt_addr = addr;
69
     madt_size = sizeof(*madt) +
70
-        sizeof(struct madt_processor_apic) * smp_cpus +
71
+        sizeof(struct madt_processor_apic) * max_cpus +
72
 #ifdef BX_QEMU
73
         sizeof(struct madt_io_apic) + sizeof(struct madt_int_override);
74
 #else
75
@@ -1799,18 +1801,21 @@ void acpi_bios_init(void)
76
         madt->local_apic_address = cpu_to_le32(0xfee00000);
77
         madt->flags = cpu_to_le32(1);
78
         apic = (void *)(madt + 1);
79
-        for(i=0;i<smp_cpus;i++) {
80
+        for(i = 0;i < max_cpus; i++) {
81
             apic->type = APIC_PROCESSOR;
82
             apic->length = sizeof(*apic);
83
             apic->processor_id = i;
84
             apic->local_apic_id = i;
85
-            apic->flags = cpu_to_le32(1);
86
+            if (i < smp_cpus)
87
+                apic->flags = cpu_to_le32(1);
88
+            else
89
+                apic->flags = 0;
90
             apic++;
91
         }
92
         io_apic = (void *)apic;
93
         io_apic->type = APIC_IO;
94
         io_apic->length = sizeof(*io_apic);
95
-        io_apic->io_apic_id = smp_cpus;
96
+        io_apic->io_apic_id = max_cpus;
97
         io_apic->address = cpu_to_le32(0xfec00000);
98
         io_apic->interrupt = cpu_to_le32(0);
99
 #ifdef BX_QEMU
100
@@ -1844,7 +1849,7 @@ void acpi_bios_init(void)
101
         srat->reserved1=1;
102
  
103
         core = (void*)(srat + 1);
104
-        for (i = 0; i < smp_cpus; ++i) {
105
+        for (i = 0; i < max_cpus; ++i) {
106
              core->type = SRAT_PROCESSOR;
107
              core->length = sizeof(*core);
108
              core->local_apic_id = i;
109
@@ -2603,7 +2608,7 @@ void smbios_init(void)
110
     add_struct(0, p);
111
     add_struct(1, p);
112
     add_struct(3, p);
113
-    for (cpu_num = 1; cpu_num <= smp_cpus; cpu_num++)
114
+    for (cpu_num = 1; cpu_num <= max_cpus; cpu_num++)
115
         add_struct(4, p, cpu_num);
116
 
117
     /* Each 'memory device' covers up to 16GB of address space. */