projects
/
seabios.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
vgabios: Unify code to generate the vbe mode list.
[seabios.git]
/
src
/
mptable.c
diff --git
a/src/mptable.c
b/src/mptable.c
index 5357c032309b570091f06154cfa7bc7e6e108317..103f46243d8cd3b89afa3fc44f97901f8e265908 100644
(file)
--- a/
src/mptable.c
+++ b/
src/mptable.c
@@
-1,6
+1,6
@@
// MPTable generation (on emulators)
//
// MPTable generation (on emulators)
//
-// Copyright (C) 2008
,2009
Kevin O'Connor <kevin@koconnor.net>
+// Copyright (C) 2008
-2010
Kevin O'Connor <kevin@koconnor.net>
// Copyright (C) 2006 Fabrice Bellard
//
// This file may be distributed under the terms of the GNU LGPLv3 license.
// Copyright (C) 2006 Fabrice Bellard
//
// This file may be distributed under the terms of the GNU LGPLv3 license.
@@
-21,9
+21,9
@@
mptable_init(void)
dprintf(3, "init MPTable\n");
// Config structure in temp area.
dprintf(3, "init MPTable\n");
// Config structure in temp area.
- struct mptable_config_s *config = malloc_tmp
high
(32*1024);
+ struct mptable_config_s *config = malloc_tmp(32*1024);
if (!config) {
if (!config) {
-
dprintf(1, "No space for temp mptable\n"
);
+
warn_noalloc(
);
return;
}
memset(config, 0, sizeof(*config));
return;
}
memset(config, 0, sizeof(*config));
@@
-36,7
+36,11
@@
mptable_init(void)
// Detect cpu info
u32 cpuid_signature, ebx, ecx, cpuid_features;
cpuid(1, &cpuid_signature, &ebx, &ecx, &cpuid_features);
// Detect cpu info
u32 cpuid_signature, ebx, ecx, cpuid_features;
cpuid(1, &cpuid_signature, &ebx, &ecx, &cpuid_features);
- u8 apic_version = readl((u8*)BUILD_APIC_ADDR + 0x30) & 0xff;
+ if (! cpuid_signature) {
+ // Use default values.
+ cpuid_signature = 0x600;
+ cpuid_features = 0x201;
+ }
int pkgcpus = 1;
if (cpuid_features & (1 << 28)) {
/* Only populate the MPS tables with the first logical CPU in
int pkgcpus = 1;
if (cpuid_features & (1 << 28)) {
/* Only populate the MPS tables with the first logical CPU in
@@
-44,6
+48,7
@@
mptable_init(void)
pkgcpus = (ebx >> 16) & 0xff;
pkgcpus = 1 << (__fls(pkgcpus - 1) + 1); /* round up to power of 2 */
}
pkgcpus = (ebx >> 16) & 0xff;
pkgcpus = 1 << (__fls(pkgcpus - 1) + 1); /* round up to power of 2 */
}
+ u8 apic_version = readl((u8*)BUILD_APIC_ADDR + 0x30) & 0xff;
// CPU definitions.
struct mpt_cpu *cpus = (void*)&config[1], *cpu = cpus;
// CPU definitions.
struct mpt_cpu *cpus = (void*)&config[1], *cpu = cpus;
@@
-54,23
+59,19
@@
mptable_init(void)
cpu->apicid = i;
cpu->apicver = apic_version;
/* cpu flags: enabled, bootstrap cpu */
cpu->apicid = i;
cpu->apicver = apic_version;
/* cpu flags: enabled, bootstrap cpu */
- cpu->cpuflag = (i < CountCPUs) | ((i == 0) << 1);
- if (cpuid_signature) {
- cpu->cpusignature = cpuid_signature;
- cpu->featureflag = cpuid_features;
- } else {
- cpu->cpusignature = 0x600;
- cpu->featureflag = 0x201;
- }
+ cpu->cpuflag = ((i<CountCPUs) ? 0x01 : 0x00) | ((i==0) ? 0x02 : 0x00);
+ cpu->cpusignature = cpuid_signature;
+ cpu->featureflag = cpuid_features;
cpu++;
}
int entrycount = cpu - cpus;
// PCI buses
cpu++;
}
int entrycount = cpu - cpus;
// PCI buses
- struct mpt_bus *bus = (void*)cpu;
- int bdf, max, lastbus = -1;
- foreachpci(bdf, max) {
- int curbus = pci_bdf_to_bus(bdf);
+ struct mpt_bus *buses = (void*)cpu, *bus = buses;
+ int lastbus = -1;
+ struct pci_device *pci;
+ foreachpci(pci) {
+ int curbus = pci_bdf_to_bus(pci->bdf);
if (curbus == lastbus)
continue;
lastbus = curbus;
if (curbus == lastbus)
continue;
lastbus = curbus;
@@
-79,7
+80,6
@@
mptable_init(void)
bus->busid = curbus;
memcpy(bus->bustype, "PCI ", sizeof(bus->bustype));
bus++;
bus->busid = curbus;
memcpy(bus->bustype, "PCI ", sizeof(bus->bustype));
bus++;
- entrycount++;
}
/* isa bus */
}
/* isa bus */
@@
-88,11
+88,12
@@
mptable_init(void)
bus->type = MPT_TYPE_BUS;
isabusid = bus->busid = lastbus + 1;
memcpy(bus->bustype, "ISA ", sizeof(bus->bustype));
bus->type = MPT_TYPE_BUS;
isabusid = bus->busid = lastbus + 1;
memcpy(bus->bustype, "ISA ", sizeof(bus->bustype));
- entrycount++;
+ bus++;
+ entrycount += bus - buses;
/* ioapic */
u8 ioapic_id = CountCPUs;
/* ioapic */
u8 ioapic_id = CountCPUs;
- struct mpt_ioapic *ioapic = (void*)
&bus[1]
;
+ struct mpt_ioapic *ioapic = (void*)
bus
;
memset(ioapic, 0, sizeof(*ioapic));
ioapic->type = MPT_TYPE_IOAPIC;
ioapic->apicid = ioapic_id;
memset(ioapic, 0, sizeof(*ioapic));
ioapic->type = MPT_TYPE_IOAPIC;
ioapic->apicid = ioapic_id;
@@
-106,7
+107,8
@@
mptable_init(void)
int dev = -1;
unsigned short mask = 0, pinmask = 0;
int dev = -1;
unsigned short mask = 0, pinmask = 0;
- foreachpci(bdf, max) {
+ foreachpci(pci) {
+ u16 bdf = pci->bdf;
int pin = pci_config_readb(bdf, PCI_INTERRUPT_PIN);
int irq = pci_config_readb(bdf, PCI_INTERRUPT_LINE);
if (pin == 0)
int pin = pci_config_readb(bdf, PCI_INTERRUPT_PIN);
int irq = pci_config_readb(bdf, PCI_INTERRUPT_LINE);
if (pin == 0)
@@
-151,7
+153,6
@@
mptable_init(void)
}
intsrc++;
}
}
intsrc++;
}
- entrycount += intsrc - intsrcs;
/* Local interrupt assignment */
intsrc->type = MPT_TYPE_LOCAL_INT;
/* Local interrupt assignment */
intsrc->type = MPT_TYPE_LOCAL_INT;
@@
-162,17
+163,16
@@
mptable_init(void)
intsrc->dstapic = 0; /* BSP == APIC #0 */
intsrc->dstirq = 0; /* LINTIN0 */
intsrc++;
intsrc->dstapic = 0; /* BSP == APIC #0 */
intsrc->dstirq = 0; /* LINTIN0 */
intsrc++;
- entrycount++;
intsrc->type = MPT_TYPE_LOCAL_INT;
intsrc->irqtype = 1; /* NMI */
intsrc->irqflag = 0; /* PO, EL default */
intsrc->srcbus = isabusid; /* ISA */
intsrc->srcbusirq = 0;
intsrc->type = MPT_TYPE_LOCAL_INT;
intsrc->irqtype = 1; /* NMI */
intsrc->irqflag = 0; /* PO, EL default */
intsrc->srcbus = isabusid; /* ISA */
intsrc->srcbusirq = 0;
- intsrc->dstapic = 0
; /* BSP == APIC #0
*/
+ intsrc->dstapic = 0
xff; /* to all local APICs
*/
intsrc->dstirq = 1; /* LINTIN1 */
intsrc++;
intsrc->dstirq = 1; /* LINTIN1 */
intsrc++;
- entrycount
++
;
+ entrycount
+= intsrc - intsrcs
;
// Finalize config structure.
int length = (void*)intsrc - (void*)config;
// Finalize config structure.
int length = (void*)intsrc - (void*)config;
@@
-186,7
+186,7
@@
mptable_init(void)
struct mptable_config_s *finalconfig = malloc_fseg(length);
struct mptable_floating_s *floating = malloc_fseg(sizeof(*floating));
if (!finalconfig || !floating) {
struct mptable_config_s *finalconfig = malloc_fseg(length);
struct mptable_floating_s *floating = malloc_fseg(sizeof(*floating));
if (!finalconfig || !floating) {
-
dprintf(1, "No room for MPTABLE!\n"
);
+
warn_noalloc(
);
free(config);
free(finalconfig);
free(floating);
free(config);
free(finalconfig);
free(floating);