- HDAMA boots!

- Set the bootstrap processor flag in the mptable.
- Implement 64bit support in our print statements
- Fix the reporting of how many cpus we are waiting to stop.
  It is the 1 less than the actual number of cpus running.
- Actually enable cpu_initialization.
- Fix firstsiblingdevice in config.g
- Add IORESOURCE_FIXED to all of the resources set by config.g
- Fix the apic_cluster rule to add an apic_cluster path not an apic path.
- Add a div64.h to assist in the 64bit printf.


git-svn-id: svn://svn.coreboot.org/coreboot/trunk@1682 2b7e53f0-3cfb-0310-b3e9-8179ed1497e1
This commit is contained in:
Eric Biederman 2004-10-16 08:38:58 +00:00
parent 7003ba4a88
commit f3ed1cfad7
6 changed files with 88 additions and 32 deletions

View File

@ -0,0 +1,48 @@
#ifndef __I386_DIV64
#define __I386_DIV64
/*
* do_div() is NOT a C function. It wants to return
* two values (the quotient and the remainder), but
* since that doesn't work very well in C, what it
* does is:
*
* - modifies the 64-bit dividend _in_place_
* - returns the 32-bit remainder
*
* This ends up being the most efficient "calling
* convention" on x86.
*/
#define do_div(n,base) ({ \
unsigned long __upper, __low, __high, __mod, __base; \
__base = (base); \
asm("":"=a" (__low), "=d" (__high):"A" (n)); \
__upper = __high; \
if (__high) { \
__upper = __high % (__base); \
__high = __high / (__base); \
} \
asm("divl %2":"=a" (__low), "=d" (__mod):"rm" (__base), "0" (__low), "1" (__upper)); \
asm("":"=A" (n):"a" (__low),"d" (__high)); \
__mod; \
})
/*
* (long)X = ((long long)divs) / (long)div
* (long)rem = ((long long)divs) % (long)div
*
* Warning, this will do an exception if X overflows.
*/
#define div_long_long_rem(a,b,c) div_ll_X_l_rem(a,b,c)
extern inline long
div_ll_X_l_rem(long long divs, long div, long *rem)
{
long dum2;
__asm__("divl %2":"=a"(dum2), "=d"(*rem)
: "rm"(div), "A"(divs));
return dum2;
}
#endif

View File

@ -121,7 +121,7 @@ void smp_write_processors(struct mp_config_table *mc)
} }
cpu_flag = MPC_CPU_ENABLED; cpu_flag = MPC_CPU_ENABLED;
if (boot_apic_id == cpu->path.u.apic.apic_id) { if (boot_apic_id == cpu->path.u.apic.apic_id) {
cpu_flag = MPC_CPU_ENABLED; cpu_flag = MPC_CPU_ENABLED | MPC_CPU_BOOTPROCESSOR;
} }
smp_write_processor(mc, smp_write_processor(mc,
cpu->path.u.apic.apic_id, apic_version, cpu->path.u.apic.apic_id, apic_version,

View File

@ -6,6 +6,7 @@
#include <stdarg.h> #include <stdarg.h>
#include <string.h> #include <string.h>
#include <div64.h>
/* haha, don't need ctype.c */ /* haha, don't need ctype.c */
#define isdigit(c) ((c) >= '0' && (c) <= '9') #define isdigit(c) ((c) >= '0' && (c) <= '9')
@ -62,14 +63,8 @@ static int skip_atoi(const char **s)
#define SPECIAL 32 /* 0x */ #define SPECIAL 32 /* 0x */
#define LARGE 64 /* use 'ABCDEF' instead of 'abcdef' */ #define LARGE 64 /* use 'ABCDEF' instead of 'abcdef' */
#define do_div(n,base) ({ \ static int number(void (*tx_byte)(unsigned char byte),
int __res; \ unsigned long long num, int base, int size, int precision, int type)
__res = ((unsigned long) n) % (unsigned) base; \
n = ((unsigned long) n) / (unsigned) base; \
__res; })
static int number(void (*tx_byte)(unsigned char byte), long num, int base, int size, int precision
,int type)
{ {
char c,sign,tmp[66]; char c,sign,tmp[66];
const char *digits="0123456789abcdefghijklmnopqrstuvwxyz"; const char *digits="0123456789abcdefghijklmnopqrstuvwxyz";
@ -85,7 +80,7 @@ static int number(void (*tx_byte)(unsigned char byte), long num, int base, int s
c = (type & ZEROPAD) ? '0' : ' '; c = (type & ZEROPAD) ? '0' : ' ';
sign = 0; sign = 0;
if (type & SIGN) { if (type & SIGN) {
if (num < 0) { if ((signed long long)num < 0) {
sign = '-'; sign = '-';
num = -num; num = -num;
size--; size--;
@ -140,7 +135,7 @@ static int number(void (*tx_byte)(unsigned char byte), long num, int base, int s
int vtxprintf(void (*tx_byte)(unsigned char byte), const char *fmt, va_list args) int vtxprintf(void (*tx_byte)(unsigned char byte), const char *fmt, va_list args)
{ {
int len; int len;
unsigned long num; unsigned long long num;
int i, base; int i, base;
const char *s; const char *s;
@ -205,6 +200,10 @@ int vtxprintf(void (*tx_byte)(unsigned char byte), const char *fmt, va_list args
if (*fmt == 'h' || *fmt == 'l' || *fmt == 'L') { if (*fmt == 'h' || *fmt == 'l' || *fmt == 'L') {
qualifier = *fmt; qualifier = *fmt;
++fmt; ++fmt;
if (*fmt == 'l') {
qualifier = 'L';
++fmt;
}
} }
/* default base */ /* default base */
@ -248,7 +247,10 @@ int vtxprintf(void (*tx_byte)(unsigned char byte), const char *fmt, va_list args
case 'n': case 'n':
if (qualifier == 'l') { if (qualifier == 'L') {
long long *ip = va_arg(args, long long *);
*ip = count;
} else if (qualifier == 'l') {
long * ip = va_arg(args, long *); long * ip = va_arg(args, long *);
*ip = count; *ip = count;
} else { } else {
@ -286,16 +288,19 @@ int vtxprintf(void (*tx_byte)(unsigned char byte), const char *fmt, va_list args
--fmt; --fmt;
continue; continue;
} }
if (qualifier == 'l') if (qualifier == 'L') {
num = va_arg(args, unsigned long long);
} else if (qualifier == 'l') {
num = va_arg(args, unsigned long); num = va_arg(args, unsigned long);
else if (qualifier == 'h') { } else if (qualifier == 'h') {
num = (unsigned short) va_arg(args, int); num = (unsigned short) va_arg(args, int);
if (flags & SIGN) if (flags & SIGN)
num = (short) num; num = (short) num;
} else if (flags & SIGN) } else if (flags & SIGN) {
num = va_arg(args, int); num = va_arg(args, int);
else } else {
num = va_arg(args, unsigned int); num = va_arg(args, unsigned int);
}
count += number(tx_byte, num, base, field_width, precision, flags); count += number(tx_byte, num, base, field_width, precision, flags);
} }
return count; return count;

View File

@ -261,7 +261,7 @@ static void initialize_other_cpus(struct bus *cpu_bus)
active_count = atomic_read(&active_cpus); active_count = atomic_read(&active_cpus);
while(active_count > 1) { while(active_count > 1) {
if (active_count != old_active_count) { if (active_count != old_active_count) {
printk_info("Waiting for %d CPUS to stop\n", active_count); printk_info("Waiting for %d CPUS to stop\n", active_count - 1);
old_active_count = active_count; old_active_count = active_count;
} }
udelay(10); udelay(10);

View File

@ -598,7 +598,7 @@ static void pci_domain_set_resources(device_t dev)
mem1->base = resource_max(mem1); mem1->base = resource_max(mem1);
} }
#if 1 #if 0
printk_debug("base1: 0x%08Lx limit1: 0x%08lx size: 0x%08Lx\n", printk_debug("base1: 0x%08Lx limit1: 0x%08lx size: 0x%08Lx\n",
mem1->base, mem1->limit, mem1->size); mem1->base, mem1->limit, mem1->size);
printk_debug("base2: 0x%08Lx limit2: 0x%08Lx size: 0x%08Lx\n", printk_debug("base2: 0x%08Lx limit2: 0x%08Lx size: 0x%08Lx\n",
@ -702,7 +702,7 @@ static struct device_operations pci_domain_ops = {
.scan_bus = pci_domain_scan_bus, .scan_bus = pci_domain_scan_bus,
}; };
static unsigned int scan_cpu_bus(device_t dev, unsigned int max) static unsigned int cpu_bus_scan(device_t dev, unsigned int max)
{ {
struct bus *cpu_bus; struct bus *cpu_bus;
unsigned reg; unsigned reg;
@ -750,18 +750,19 @@ static unsigned int scan_cpu_bus(device_t dev, unsigned int max)
static void cpu_bus_init(device_t dev) static void cpu_bus_init(device_t dev)
{ {
printk_debug("cpu_bus_init\n");
#if 0
initialize_cpus(&dev->link[0]); initialize_cpus(&dev->link[0]);
#endif }
static void cpu_bus_noop(device_t dev)
{
} }
static struct device_operations cpu_bus_ops = { static struct device_operations cpu_bus_ops = {
.read_resources = 0, .read_resources = cpu_bus_noop,
.set_resources = 0, .set_resources = cpu_bus_noop,
.enable_resources = 0, .enable_resources = cpu_bus_noop,
.init = cpu_bus_init, .init = cpu_bus_init,
.scan_bus = scan_cpu_bus, .scan_bus = cpu_bus_scan,
}; };
static void enable_dev(struct device *dev) static void enable_dev(struct device *dev)

View File

@ -724,6 +724,8 @@ class partobj:
def firstsiblingdevice(self): def firstsiblingdevice(self):
"""Find the first device in the sibling link.""" """Find the first device in the sibling link."""
sibling = self.siblings sibling = self.siblings
if ((not sibling) and (self.parent.chip_or_device == 'chip')):
sibling = self.parent.siblings
while(sibling): while(sibling):
if (sibling.chip_or_device == 'device'): if (sibling.chip_or_device == 'device'):
return sibling return sibling
@ -921,7 +923,7 @@ class partobj:
fatal("Invalid pci_domain: 0x%x is out of the range 0 to 0xffff" % pci_domain) fatal("Invalid pci_domain: 0x%x is out of the range 0 to 0xffff" % pci_domain)
self.path = ".type=DEVICE_PATH_PCI_DOMAIN,.u={.pci_domain={ .domain = 0x%x }}" % (pci_domain) self.path = ".type=DEVICE_PATH_PCI_DOMAIN,.u={.pci_domain={ .domain = 0x%x }}" % (pci_domain)
def addapic_cluster(self, cluster): def addapic_clusterpath(self, cluster):
""" Add a pci_domain number to a chip """ """ Add a pci_domain number to a chip """
if ((cluster < 0) or (cluster > 15)): if ((cluster < 0) or (cluster > 15)):
fatal("Invalid apic cluster: %d is out of the range 0 to ff" % cluster) fatal("Invalid apic cluster: %d is out of the range 0 to ff" % cluster)
@ -1689,10 +1691,10 @@ parser Config:
) {{ if(C): partstack.tos().set_enabled(val) }} ) {{ if(C): partstack.tos().set_enabled(val) }}
rule resource<<C>>: {{ type = "" }} rule resource<<C>>: {{ type = "" }}
( IO {{ type = "IORESOURCE_IO" }} ( IO {{ type = "IORESOURCE_FIXED | IORESOURCE_IO" }}
| MEM {{ type = "IORESOURCE_MEM" }} | MEM {{ type = "IORESOURCE_FIXED | IORESOURCE_MEM" }}
| IRQ {{ type = "IORESOURCE_IRQ" }} | IRQ {{ type = "IORESOURCE_FIXED | IORESOURCE_IRQ" }}
| DRQ {{ type = "IORESOURCE_DRQ" }} | DRQ {{ type = "IORESOURCE_FIXED | IORESOURCE_DRQ" }}
) )
term '=' {{ index = term }} term '=' {{ index = term }}
term {{ value = term }} term {{ value = term }}
@ -1729,7 +1731,7 @@ parser Config:
rule apic_cluster<<C>>: APIC_CLUSTER {{ if (C): devicepart('apic_cluster') }} rule apic_cluster<<C>>: APIC_CLUSTER {{ if (C): devicepart('apic_cluster') }}
HEX_NUM {{ cluster = int(HEX_NUM, 16) }} HEX_NUM {{ cluster = int(HEX_NUM, 16) }}
{{ if (C): partstack.tos().addapicpath(cluster) }} {{ if (C): partstack.tos().addapic_clusterpath(cluster) }}
rule dev_path<<C>>: rule dev_path<<C>>:
pci<<C>> {{ return pci }} pci<<C>> {{ return pci }}