This patch adds some debug functions, cleans up whitespace (per indent), and adds const in a few places.

include/device/path.h
	Make path_eq take const path*.
	
include/device/device.h
	Use const with dev_path, dev_id_string, bus_path, find_dev_path,
	andalloc_find.

device/device.c
	Add functions for tree printing of devs and resources.
	Change %p to more useful info.

device/device_util.c
	Use const changes from device.h.

lib/stage2.c
	Use updated printing functions.

Signed-off-by: Myles Watson <mylesgw@gmail.com>
Acked-by: Ronald G. Minnich <rminnich@gmail.com>


git-svn-id: svn://coreboot.org/repository/coreboot-v3@1024 f3766cd6-281f-0410-b1cd-43a5c92072e9
This commit is contained in:
Myles Watson 2008-11-14 16:15:33 +00:00
parent f222dfc6f5
commit 981c3652a1
5 changed files with 282 additions and 212 deletions

View file

@ -71,7 +71,6 @@ static struct device devs[MAX_DEVICES];
*/ */
static int devcnt; static int devcnt;
/** /**
* The device creator. * The device creator.
* *
@ -101,7 +100,8 @@ static struct device *new_device(void)
* @param dev Pointer to the newly created device structure. * @param dev Pointer to the newly created device structure.
* @param ops Pointer to device_operations * @param ops Pointer to device_operations
*/ */
void default_device_constructor(struct device *dev, const struct device_operations *ops) void default_device_constructor(struct device *dev,
const struct device_operations *ops)
{ {
printk(BIOS_DEBUG, "default device constructor called\n"); printk(BIOS_DEBUG, "default device constructor called\n");
dev->ops = ops; dev->ops = ops;
@ -121,11 +121,11 @@ struct device_operations *find_device_operations(struct device_id *id)
int i; int i;
for (i = 0; all_device_operations[i]; i++) { for (i = 0; all_device_operations[i]; i++) {
printk(BIOS_SPEW, "%s: check all_device_operations[i] %p\n", printk(BIOS_SPEW, "%s: check all_device_operations[%d]\n",
__func__, all_device_operations[i]); __func__, i);
c = all_device_operations[i]; c = all_device_operations[i];
printk(BIOS_SPEW, "%s: cons %p, cons id %s\n", printk(BIOS_SPEW, "%s: cons id %s\n",
__func__, c, dev_id_string(&c->id)); __func__, dev_id_string(&c->id));
if (id_eq(&c->id, id)) { if (id_eq(&c->id, id)) {
printk(BIOS_SPEW, "%s: match\n", __func__); printk(BIOS_SPEW, "%s: match\n", __func__);
return c; return c;
@ -184,16 +184,17 @@ void constructor(struct device *dev)
if (!c) if (!c)
c = find_device_operations(&dev->id); c = find_device_operations(&dev->id);
printk(BIOS_SPEW, "%s: constructor is %p\n", __func__, c);
if (c) { if (c) {
printk(BIOS_SPEW, "%s: constructor has ID %s\n", __func__,
dev_id_string(&c->id));
if (c->constructor) if (c->constructor)
c->constructor(dev, c); c->constructor(dev, c);
else else
default_device_constructor(dev, c); default_device_constructor(dev, c);
} } else
else printk(BIOS_INFO,
printk(BIOS_INFO, "No ops found and no constructor called for %s.\n", "No ops found and no constructor called for %s.\n",
dev_id_string(&dev->id)); dev_id_string(&dev->id));
} }
@ -311,7 +312,7 @@ void read_resources(struct bus *bus)
/* Read in subtractive resources behind the current device. */ /* Read in subtractive resources behind the current device. */
links = 0; links = 0;
for (i = 0; i < curdev->resources; i++) { for (i = 0; i < curdev->resources && (curdev->links > 0); i++) {
struct resource *resource; struct resource *resource;
unsigned int link; unsigned int link;
resource = &curdev->resource[i]; resource = &curdev->resource[i];
@ -380,8 +381,8 @@ static struct device *largest_resource(struct bus *bus, struct resource
struct pick_largest_state state; struct pick_largest_state state;
state.last = *result_res; state.last = *result_res;
state.result_dev = 0; state.result_dev = NULL;
state.result = 0; state.result = NULL;
state.seen_last = 0; state.seen_last = 0;
search_bus_resources(bus, type_mask, type, pick_largest_resource, search_bus_resources(bus, type_mask, type, pick_largest_resource,
@ -434,10 +435,12 @@ void compute_allocate_resource(struct bus *bus, struct resource *bridge,
base = bridge->base; base = bridge->base;
printk(BIOS_SPEW, printk(BIOS_SPEW,
"%s compute_allocate_%s: base: %08llx size: %08llx align: %d gran: %d\n", "%s compute_allocate_%s: base: %08llx size: %08llx align: %d gran: %d limit: %08llx\n",
dev_path(bus->dev), dev_path(bus->dev),
(bridge->flags & IORESOURCE_IO) ? "io" : (bridge->flags & IORESOURCE_PREFETCH) ? "prefmem" : "mem", (bridge->flags & IORESOURCE_IO) ? "io" : (bridge->flags &
base, bridge->size, bridge->align, bridge->gran); IORESOURCE_PREFETCH) ?
"prefmem" : "mem", base, bridge->size, bridge->align,
bridge->gran, bridge->limit);
/* We want different minimum alignments for different kinds of /* We want different minimum alignments for different kinds of
* resources. These minimums are not device type specific but * resources. These minimums are not device type specific but
@ -454,7 +457,7 @@ void compute_allocate_resource(struct bus *bus, struct resource *bridge,
read_resources(bus); read_resources(bus);
/* Remember we haven't found anything yet. */ /* Remember we haven't found anything yet. */
resource = 0; resource = NULL;
/* Walk through all the devices on the current bus and /* Walk through all the devices on the current bus and
* compute the addresses. * compute the addresses.
@ -542,8 +545,10 @@ void compute_allocate_resource(struct bus *bus, struct resource *bridge,
printk(BIOS_SPEW, printk(BIOS_SPEW,
"%s compute_allocate_%s: base: %08llx size: %08llx align: %d gran: %d done\n", "%s compute_allocate_%s: base: %08llx size: %08llx align: %d gran: %d done\n",
dev_path(bus->dev), dev_path(bus->dev),
(bridge->flags & IORESOURCE_IO) ? "io" : (bridge->flags & IORESOURCE_PREFETCH) ? "prefmem" : "mem", (bridge->flags & IORESOURCE_IO) ? "io" : (bridge->flags &
base, bridge->size, bridge->align, bridge->gran); IORESOURCE_PREFETCH) ?
"prefmem" : "mem", base, bridge->size, bridge->align,
bridge->gran);
} }
#ifdef CONFIG_PCI_OPTION_ROM_RUN #ifdef CONFIG_PCI_OPTION_ROM_RUN
@ -754,12 +759,12 @@ void dev_phase2(void)
printk(BIOS_DEBUG, "Phase 2: Early setup...\n"); printk(BIOS_DEBUG, "Phase 2: Early setup...\n");
for (dev = all_devices; dev; dev = dev->next) { for (dev = all_devices; dev; dev = dev->next) {
printk(BIOS_SPEW, printk(BIOS_SPEW,
"%s: dev %s: ops %p ops->phase2_fixup %p\n", "%s: dev %s: ops %sNULL ops->phase2_fixup %s\n",
__FUNCTION__, dev->dtsname, dev->ops, __FUNCTION__, dev->dtsname, dev->ops ? "NOT " : "",
dev->ops? dev->ops->phase2_fixup : NULL); dev->ops ? (dev->ops->phase2_fixup ? "NOT NULL" : "NULL")
: "N/A");
if (dev->ops && dev->ops->phase2_fixup) { if (dev->ops && dev->ops->phase2_fixup) {
printk(BIOS_SPEW, printk(BIOS_SPEW, "Calling phase2 phase2_fixup...\n");
"Calling phase2 phase2_fixup...\n");
dev->ops->phase2_fixup(dev); dev->ops->phase2_fixup(dev);
printk(BIOS_SPEW, "phase2_fixup done\n"); printk(BIOS_SPEW, "phase2_fixup done\n");
} }
@ -788,10 +793,11 @@ unsigned int dev_phase3_scan(struct device *busdevice, unsigned int max)
post_code(POST_STAGE2_PHASE3_SCAN_ENTER); post_code(POST_STAGE2_PHASE3_SCAN_ENTER);
if (!busdevice || !busdevice->enabled || if (!busdevice || !busdevice->enabled ||
!busdevice->ops || !busdevice->ops->phase3_scan) { !busdevice->ops || !busdevice->ops->phase3_scan) {
printk(BIOS_INFO, "%s: %s: busdevice %p enabled %d ops %p\n", printk(BIOS_INFO, "%s: busdevice %s: enabled %d ops %s\n",
__FUNCTION__, busdevice->dtsname, busdevice, __FUNCTION__, busdevice ? busdevice->dtsname : "NULL",
busdevice ? busdevice->enabled : 0, busdevice ? busdevice->enabled : 0,
busdevice ? busdevice->ops : NULL); busdevice ? (busdevice->ops?
"NOT NULL" : "NULL") : "N/A");
printk(BIOS_INFO, "%s: can not scan from here, returning %d\n", printk(BIOS_INFO, "%s: can not scan from here, returning %d\n",
__FUNCTION__, max); __FUNCTION__, max);
return max; return max;
@ -824,16 +830,14 @@ unsigned int dev_phase3_scan(struct device *busdevice, unsigned int max)
/** /**
* Determine the existence of devices and extend the device tree. * Determine the existence of devices and extend the device tree.
* *
* Most of the devices in the system are listed in the mainboard Config.lb * Most of the devices in the system are listed in the mainboard dts
* file. The device structures for these devices are generated at compile * file. The device structures for these devices are generated at compile
* time by the config tool and are organized into the device tree. This * time by the config tool and are organized into the device tree, statictree.c.
* function determines if the devices created at compile time actually exist * This function determines if the devices created at compile time actually
* in the physical system. * exist in the physical system.
* TODO: Fix comment, v3 doesn't have Config.lb files.
* *
* For devices in the physical system but not listed in the Config.lb file, * For devices in the physical system but not listed in the dts, the device
* the device structures have to be created at run time and attached to the * structures have to be created at run time and attached to the device tree.
* device tree.
* *
* This function starts from the root device 'dev_root', scan the buses in * This function starts from the root device 'dev_root', scan the buses in
* the system recursively, modify the device tree according to the result of * the system recursively, modify the device tree according to the result of
@ -870,6 +874,51 @@ void dev_root_phase3(void)
printk(BIOS_INFO, "Phase 3: Done.\n"); printk(BIOS_INFO, "Phase 3: Done.\n");
} }
void resource_tree(const struct device *const root, int debug_level, int depth)
{
int i = 0, link = 0;
const struct device const *child;
char indent[30]; /* If your tree has more levels, it's wrong. */
for (i = 0; i < depth + 1 && i < 29; i++)
indent[i] = ' ';
indent[i] = '\0';
printk(BIOS_DEBUG, "%s%s links %x child on link 0 %s\n",
indent, dev_path(root), root->links,
root->link[0].children ? root->link[0].children->
dtsname : "NULL");
for (i = 0; i < root->resources; i++) {
printk(BIOS_DEBUG,
"%s%s resource base %llx size %llx align %x gran %x limit %llx flags %lx index %lx\n",
indent, dev_path(root), root->resource[i].base,
root->resource[i].size, root->resource[i].align,
root->resource[i].gran, root->resource[i].limit,
root->resource[i].flags, root->resource[i].index);
}
for (link = 0; link < root->links; link++) {
for (child = root->link[link].children; child;
child = child->sibling)
resource_tree(child, debug_level, depth + 1);
}
}
void print_resource_tree(const struct device *const root, int debug_level,
const char *msg)
{
/* Bail if root is null. */
if (!root) {
printk(debug_level, "%s passed NULL for root!\n", __func__);
return;
}
/* Bail if not printing to screen. */
if (!printk(debug_level, "Show all resources in tree form...%s\n", msg))
return;
resource_tree(root, debug_level, 0);
}
/** /**
* Configure devices on the device tree. * Configure devices on the device tree.
* *
@ -948,6 +997,8 @@ void dev_phase4(void)
compute_allocate_resource(&root->link[0], mem, compute_allocate_resource(&root->link[0], mem,
IORESOURCE_MEM, IORESOURCE_MEM); IORESOURCE_MEM, IORESOURCE_MEM);
print_resource_tree(root, BIOS_DEBUG, "After first compute_allocate.");
/* Now we need to adjust the resources. The issue is that mem grows /* Now we need to adjust the resources. The issue is that mem grows
* downward. * downward.
*/ */
@ -975,9 +1026,12 @@ void dev_phase4(void)
compute_allocate_resource(&root->link[0], mem, compute_allocate_resource(&root->link[0], mem,
IORESOURCE_MEM, IORESOURCE_MEM); IORESOURCE_MEM, IORESOURCE_MEM);
print_resource_tree(root, BIOS_DEBUG, "After second compute_allocate.");
/* Store the computed resource allocations into device registers. */ /* Store the computed resource allocations into device registers. */
printk(BIOS_INFO, "Phase 4: Setting resources...\n"); printk(BIOS_INFO, "Phase 4: Setting resources...\n");
root->ops->phase4_set_resources(root); root->ops->phase4_set_resources(root);
print_resource_tree(root, BIOS_DEBUG, "After setting resources.");
printk(BIOS_INFO, "Phase 4: Done setting resources.\n"); printk(BIOS_INFO, "Phase 4: Done setting resources.\n");
#if 0 #if 0
mem->flags |= IORESOURCE_STORED; mem->flags |= IORESOURCE_STORED;
@ -1028,13 +1082,52 @@ void dev_phase6(void)
printk(BIOS_INFO, "Phase 6: Devices initialized.\n"); printk(BIOS_INFO, "Phase 6: Devices initialized.\n");
} }
void show_all_devs(void) void show_devs_tree(struct device *dev, int debug_level, int depth, int linknum)
{
char depth_str[20] = "";
int i;
struct device *sibling;
for (i = 0; i < depth; i++)
depth_str[i] = ' ';
depth_str[i] = '\0';
printk(debug_level, "%s%s(%s): enabled %d have_resources %d devfn %x\n",
depth_str, dev->dtsname, dev_path(dev), dev->enabled,
dev->have_resources,
dev->path.type == DEVICE_PATH_PCI ? dev->path.pci.devfn : 0xff);
for (i = 0; i < dev->links; i++) {
for (sibling = dev->link[i].children; sibling;
sibling = sibling->sibling)
show_devs_tree(sibling, debug_level, depth + 1, i);
}
}
void show_all_devs_tree(int debug_level, const char *msg)
{
/* Bail if not printing to screen. */
if (!printk(debug_level, "Show all devs in tree form...%s\n", msg))
return;
show_devs_tree(all_devices, debug_level, 0, -1);
}
void show_devs_subtree(struct device *root, int debug_level, const char *msg)
{
/* Bail if not printing to screen. */
if (!printk(debug_level, "Show all devs in subtree %s...%s\n",
root->dtsname, msg))
return;
printk(debug_level, "%s\n", msg);
show_devs_tree(root, debug_level, 0, -1);
}
void show_all_devs(int debug_level, const char *msg)
{ {
struct device *dev; struct device *dev;
printk(BIOS_INFO, "Show all devs...\n"); /* Bail if not printing to screen. */
if (!printk(debug_level, "Show all devs...%s\n", msg))
return;
for (dev = all_devices; dev; dev = dev->next) { for (dev = all_devices; dev; dev = dev->next) {
printk(BIOS_SPEW, printk(debug_level,
"%s(%s): enabled %d have_resources %d\n", "%s(%s): enabled %d have_resources %d\n",
dev->dtsname, dev_path(dev), dev->enabled, dev->dtsname, dev_path(dev), dev->enabled,
dev->have_resources); dev->have_resources);

View file

@ -37,7 +37,8 @@
* @return Pointer to a device structure for the device on bus at path * @return Pointer to a device structure for the device on bus at path
* or 0/NULL if no device is found. * or 0/NULL if no device is found.
*/ */
struct device *find_dev_path(struct bus *parent, struct device_path *path) struct device *find_dev_path(const struct bus *parent,
const struct device_path *path)
{ {
struct device *child; struct device *child;
for (child = parent->children; child; child = child->sibling) { for (child = parent->children; child; child = child->sibling) {
@ -182,7 +183,7 @@ struct device *dev_find_class(unsigned int class, struct device *from)
} }
/* WARNING: NOT SMP-safe! */ /* WARNING: NOT SMP-safe! */
const char *dev_path(struct device *dev) const char *dev_path(const struct device *dev)
{ {
static char buffer[DEVICE_PATH_MAX]; static char buffer[DEVICE_PATH_MAX];
buffer[0] = '\0'; buffer[0] = '\0';
@ -223,8 +224,7 @@ const char *dev_path(struct device *dev)
dev->path.pci_domain.domain); dev->path.pci_domain.domain);
break; break;
case DEVICE_PATH_PCI_BUS: case DEVICE_PATH_PCI_BUS:
sprintf(buffer, "PCI_BUS: %04x", sprintf(buffer, "PCI_BUS: %04x", dev->path.pci_bus.bus);
dev->path.pci_bus.bus);
break; break;
case DEVICE_PATH_APIC_CLUSTER: case DEVICE_PATH_APIC_CLUSTER:
sprintf(buffer, "APIC_CLUSTER: %01x", sprintf(buffer, "APIC_CLUSTER: %01x",
@ -234,8 +234,7 @@ const char *dev_path(struct device *dev)
sprintf(buffer, "CPU: %02x", dev->path.cpu.id); sprintf(buffer, "CPU: %02x", dev->path.cpu.id);
break; break;
case DEVICE_PATH_CPU_BUS: case DEVICE_PATH_CPU_BUS:
sprintf(buffer, "CPU_BUS: %02x", sprintf(buffer, "CPU_BUS: %02x", dev->path.cpu_bus.id);
dev->path.cpu_bus.id);
break; break;
case DEVICE_PATH_IOPORT: case DEVICE_PATH_IOPORT:
sprintf(buffer, "IOPORT: %02x", sprintf(buffer, "IOPORT: %02x",
@ -251,7 +250,7 @@ const char *dev_path(struct device *dev)
} }
/* WARNING: NOT SMP-safe! */ /* WARNING: NOT SMP-safe! */
const char *dev_id_string(struct device_id *id) const char *dev_id_string(const struct device_id *id)
{ {
static char buffer[DEVICE_ID_MAX]; static char buffer[DEVICE_ID_MAX];
buffer[0] = '\0'; buffer[0] = '\0';
@ -278,8 +277,7 @@ const char *dev_id_string(struct device_id *id)
break; break;
case DEVICE_ID_PCI_DOMAIN: case DEVICE_ID_PCI_DOMAIN:
sprintf(buffer, "PCI_DOMAIN: %04x:%04x", sprintf(buffer, "PCI_DOMAIN: %04x:%04x",
id->pci_domain.vendor, id->pci_domain.vendor, id->pci_domain.device);
id->pci_domain.device);
break; break;
case DEVICE_ID_APIC_CLUSTER: case DEVICE_ID_APIC_CLUSTER:
sprintf(buffer, "APIC_CLUSTER: %02x:%02x", sprintf(buffer, "APIC_CLUSTER: %02x:%02x",
@ -304,14 +302,14 @@ const char *dev_id_string(struct device_id *id)
return buffer; return buffer;
} }
const char *bus_path(struct bus *bus) const char *bus_path(const struct bus *bus)
{ {
static char buffer[BUS_PATH_MAX]; static char buffer[BUS_PATH_MAX];
sprintf(buffer, "%s,%d", dev_path(bus->dev), bus->link); sprintf(buffer, "%s,%d", dev_path(bus->dev), bus->link);
return buffer; return buffer;
} }
int path_eq(struct device_path *path1, struct device_path *path2) int path_eq(const struct device_path *path1, const struct device_path *path2)
{ {
int equal = 0; int equal = 0;
if (path1->type == path2->type) { if (path1->type == path2->type) {
@ -332,8 +330,7 @@ int path_eq(struct device_path *path1, struct device_path *path2)
equal = (path1->i2c.device == path2->i2c.device); equal = (path1->i2c.device == path2->i2c.device);
break; break;
case DEVICE_PATH_APIC: case DEVICE_PATH_APIC:
equal = equal = (path1->apic.apic_id == path2->apic.apic_id);
(path1->apic.apic_id == path2->apic.apic_id);
break; break;
case DEVICE_PATH_PCI_DOMAIN: case DEVICE_PATH_PCI_DOMAIN:
equal = equal =
@ -402,10 +399,8 @@ int id_eq(struct device_id *path1, struct device_id *path2)
equal = (path1->cpu.cpuid == path2->cpu.cpuid); equal = (path1->cpu.cpuid == path2->cpu.cpuid);
break; break;
case DEVICE_ID_CPU_BUS: case DEVICE_ID_CPU_BUS:
equal = equal = (path1->cpu_bus.vendor == path2->cpu_bus.vendor)
(path1->cpu_bus.vendor == path2->cpu_bus.vendor) && (path1->cpu_bus.device == path2->cpu_bus.device);
&& (path1->cpu_bus.device ==
path2->cpu_bus.device);
break; break;
default: default:
printk(BIOS_ERR, "Unknown device type: %d\n", printk(BIOS_ERR, "Unknown device type: %d\n",
@ -430,7 +425,8 @@ void compact_resources(struct device *dev)
for (i = 0; i < dev->resources;) { for (i = 0; i < dev->resources;) {
resource = &dev->resource[i]; resource = &dev->resource[i];
if (!resource->flags) { if (!resource->flags) {
memmove(resource, resource + 1, (dev->resources-i)* sizeof(*resource)); memmove(resource, resource + 1,
(dev->resources - i) * sizeof(*resource));
dev->resources -= 1; dev->resources -= 1;
memset(&dev->resource[dev->resources], 0, memset(&dev->resource[dev->resources], 0,
sizeof(*resource)); sizeof(*resource));
@ -452,7 +448,7 @@ struct resource *probe_resource(struct device *dev, unsigned int index)
struct resource *resource; struct resource *resource;
int i; int i;
/* See if there is a resource with the appropriate index. */ /* See if there is a resource with the appropriate index. */
resource = 0; resource = NULL;
for (i = 0; i < dev->resources; i++) { for (i = 0; i < dev->resources; i++) {
if (dev->resource[i].index == index) { if (dev->resource[i].index == index) {
resource = &dev->resource[i]; resource = &dev->resource[i];
@ -675,7 +671,8 @@ void search_global_resources(unsigned long type_mask, unsigned long type,
resource_search_t search, void *gp) resource_search_t search, void *gp)
{ {
struct device *curdev; struct device *curdev;
printk(BIOS_SPEW, "%s: mask %lx type %lx \n", __func__, type_mask, type); printk(BIOS_SPEW, "%s: mask %lx type %lx \n", __func__, type_mask,
type);
for (curdev = all_devices; curdev; curdev = curdev->next) { for (curdev = all_devices; curdev; curdev = curdev->next) {
int i; int i;
printk(BIOS_SPEW, printk(BIOS_SPEW,

View file

@ -56,44 +56,35 @@ struct pci_bus_operations;
struct smbus_bus_operations; struct smbus_bus_operations;
struct bus; struct bus;
struct pci_domain_id {
struct pci_domain_id
{
u16 vendor, device; u16 vendor, device;
}; };
struct pci_id struct pci_id {
{
u16 vendor, device; u16 vendor, device;
}; };
struct pnp_id struct pnp_id {
{
u32 device; u32 device;
}; };
struct i2c_id struct i2c_id {
{
u32 id; u32 id;
}; };
struct apic_id struct apic_id {
{
u16 vendor, device; u16 vendor, device;
}; };
struct apic_cluster_id struct apic_cluster_id {
{
u16 vendor, device; u16 vendor, device;
}; };
struct cpu_id struct cpu_id {
{
u8 cpuid[24]; u8 cpuid[24];
}; };
struct cpu_bus_id struct cpu_bus_id {
{
u16 vendor, device; u16 vendor, device;
}; };
@ -111,7 +102,6 @@ struct device_id {
}; };
}; };
struct device_operations { struct device_operations {
/* the device id for this set of device operations. /* the device id for this set of device operations.
* In almost all cases, this is non-zero. For the * In almost all cases, this is non-zero. For the
@ -147,7 +137,7 @@ struct device_operations {
/* phase 3 is for scanning the bus, if needed. */ /* phase 3 is for scanning the bus, if needed. */
void (*phase3_chip_setup_dev) (struct device * dev); void (*phase3_chip_setup_dev) (struct device * dev);
/* some devices need to be enabled to scan. */ /* some devices need to be enabled to scan. */
/* this function enables/disables according the value of 'enabled' in the device*/ /* this function enables/disables based on 'enabled' in the device. */
void (*phase3_enable) (struct device * dev); void (*phase3_enable) (struct device * dev);
unsigned int (*phase3_scan) (struct device * bus, unsigned int max); unsigned int (*phase3_scan) (struct device * bus, unsigned int max);
@ -167,7 +157,6 @@ struct device_operations {
const struct pci_bus_operations *ops_pci_bus; const struct pci_bus_operations *ops_pci_bus;
}; };
struct bus { struct bus {
struct device *dev; /* This bridge device */ struct device *dev; /* This bridge device */
struct device *children; /* devices behind this bridge */ struct device *children; /* devices behind this bridge */
@ -237,10 +226,10 @@ struct device {
extern struct device dev_root; /* root bus */ extern struct device dev_root; /* root bus */
extern struct device *all_devices; /* list of all devices */ extern struct device *all_devices; /* list of all devices */
/* Generic device interface functions */ /* Generic device interface functions */
struct device_operations *find_device_operations(struct device_id *id); struct device_operations *find_device_operations(struct device_id *id);
struct device * alloc_dev(struct bus *parent, struct device_path *path, struct device_id *id); struct device *alloc_dev(struct bus *parent, struct device_path *path,
struct device_id *id);
void dev_enumerate(void); void dev_enumerate(void);
void dev_configure(void); void dev_configure(void);
void dev_enable(void); void dev_enable(void);
@ -256,15 +245,17 @@ void assign_resources(struct bus *bus);
void enable_resources(struct device *dev); void enable_resources(struct device *dev);
void enumerate_static_device(void); void enumerate_static_device(void);
void enumerate_static_devices(void); void enumerate_static_devices(void);
const char *dev_path(struct device * dev); const char *dev_path(const struct device *dev);
const char *dev_id_string(struct device_id *id); const char *dev_id_string(const struct device_id *id);
const char *bus_path(struct bus *bus); const char *bus_path(const struct bus *bus);
void dev_set_enabled(struct device *dev, int enable); void dev_set_enabled(struct device *dev, int enable);
void disable_children(struct bus *bus); void disable_children(struct bus *bus);
/* Helper functions */ /* Helper functions */
struct device * find_dev_path(struct bus *parent, struct device_path *path); struct device *find_dev_path(const struct bus *parent,
struct device * alloc_find_dev(struct bus *parent, struct device_path *path, struct device_id *id); const struct device_path *path);
struct device *alloc_find_dev(struct bus *parent, struct device_path *path,
struct device_id *id);
struct device *dev_find_device(struct device_id *devid, struct device *from); struct device *dev_find_device(struct device_id *devid, struct device *from);
struct device *dev_find_pci_device(u16 vendor, u16 device, struct device *from); struct device *dev_find_pci_device(u16 vendor, u16 device, struct device *from);
EXPORT_SYMBOL(dev_find_pci_device); EXPORT_SYMBOL(dev_find_pci_device);
@ -272,11 +263,13 @@ struct device * dev_find_class (unsigned int class, struct device * from);
struct device *dev_find_slot(unsigned int bus, unsigned int devfn); struct device *dev_find_slot(unsigned int bus, unsigned int devfn);
EXPORT_SYMBOL(dev_find_slot); EXPORT_SYMBOL(dev_find_slot);
struct device *dev_find_slot_on_smbus(unsigned int bus, unsigned int addr); struct device *dev_find_slot_on_smbus(unsigned int bus, unsigned int addr);
void default_device_constructor(struct device *dev, const struct device_operations *constructor); void default_device_constructor(struct device *dev,
const struct device_operations *constructor);
void show_all_devs(int debug_level, const char *msg);
void show_all_devs_tree(int debug_level, const char *msg);
/* Rounding for boundaries. /* Rounding for boundaries.
* Due to some chip bugs, go ahead and roung IO to 16 * Due to some chip bugs, go ahead and round IO to 16
*/ */
#define DEVICE_IO_ALIGN 16 #define DEVICE_IO_ALIGN 16
#define DEVICE_MEM_ALIGN 4096 #define DEVICE_MEM_ALIGN 4096

View file

@ -33,60 +33,49 @@ enum device_path_type {
DEVICE_PATH_IOPORT, DEVICE_PATH_IOPORT,
}; };
struct pci_domain_path struct pci_domain_path {
{
unsigned domain; unsigned domain;
}; };
struct pci_bus_path struct pci_bus_path {
{
unsigned bus; unsigned bus;
}; };
struct pci_path struct pci_path {
{
unsigned devfn; unsigned devfn;
}; };
struct pnp_path struct pnp_path {
{
unsigned port; unsigned port;
unsigned device; unsigned device;
}; };
struct i2c_path struct i2c_path {
{
unsigned device; unsigned device;
}; };
struct apic_path struct apic_path {
{
unsigned apic_id; unsigned apic_id;
unsigned node_id; unsigned node_id;
unsigned core_id; unsigned core_id;
}; };
struct apic_cluster_path struct apic_cluster_path {
{
unsigned cluster; unsigned cluster;
}; };
struct cpu_path struct cpu_path {
{
unsigned id; unsigned id;
}; };
struct cpu_bus_path struct cpu_bus_path {
{
unsigned id; unsigned id;
}; };
struct ioport_path struct ioport_path {
{
unsigned iobase; unsigned iobase;
}; };
struct device_path { struct device_path {
enum device_path_type type; enum device_path_type type;
union { union {
@ -103,10 +92,10 @@ struct device_path {
}; };
}; };
#define DEVICE_PATH_MAX 30 #define DEVICE_PATH_MAX 30
#define BUS_PATH_MAX (DEVICE_PATH_MAX+10) #define BUS_PATH_MAX (DEVICE_PATH_MAX+10)
extern int path_eq(struct device_path *path1, struct device_path *path2); extern int path_eq(const struct device_path *path1,
const struct device_path *path2);
#endif /* DEVICE_PATH_H */ #endif /* DEVICE_PATH_H */

View file

@ -45,9 +45,6 @@ void *stage2(void)
{ {
void *mbi; void *mbi;
/* TODO: Add comment. */
void show_all_devs(void);
post_code(POST_STAGE2_BEGIN); post_code(POST_STAGE2_BEGIN);
dev_init(); dev_init();
@ -56,7 +53,7 @@ void *stage2(void)
*/ */
post_code(POST_STAGE2_PHASE1_START); post_code(POST_STAGE2_PHASE1_START);
dev_phase1(); dev_phase1();
show_all_devs(); show_all_devs(BIOS_DEBUG, "After phase 1.");
/* Here is where weird stuff like init_timer handling should be /* Here is where weird stuff like init_timer handling should be
* done. This is for ANYTHING that might have to happen before * done. This is for ANYTHING that might have to happen before
@ -64,35 +61,36 @@ void *stage2(void)
*/ */
post_code(POST_STAGE2_PHASE2_START); post_code(POST_STAGE2_PHASE2_START);
dev_phase2(); dev_phase2();
show_all_devs(); show_all_devs(BIOS_DEBUG, "After phase 2.");
/* Walk physical devices and add any dynamic devices to the /* Walk physical devices and add any dynamic devices to the
* device tree. * device tree.
*/ */
post_code(POST_STAGE2_PHASE3_START); post_code(POST_STAGE2_PHASE3_START);
dev_root_phase3(); dev_root_phase3();
show_all_devs(); show_all_devs_tree(BIOS_DEBUG, "After phase 3.");
/* Compute and assign the bus resources. */ /* Compute and assign the bus resources. */
post_code(POST_STAGE2_PHASE4_START); post_code(POST_STAGE2_PHASE4_START);
dev_phase4(); dev_phase4();
show_all_devs(); show_all_devs(BIOS_DEBUG, "After phase 4.");
/* Now actually enable devices on the bus. */ /* Now actually enable devices on the bus. */
post_code(POST_STAGE2_PHASE5_START); post_code(POST_STAGE2_PHASE5_START);
dev_root_phase5(); dev_root_phase5();
show_all_devs(); show_all_devs(BIOS_DEBUG, "After phase 5.");
/* Initialize devices on the bus. */ /* Initialize devices on the bus. */
post_code(POST_STAGE2_PHASE6_START); post_code(POST_STAGE2_PHASE6_START);
dev_phase6(); dev_phase6();
show_all_devs(); show_all_devs(BIOS_DEBUG, "After phase 6.");
/* TODO: Add comment. */ /* Write tables to pass information to the payloads. */
post_code(POST_STAGE2_WRITE_TABLES); post_code(POST_STAGE2_WRITE_TABLES);
mbi = write_tables(); mbi = write_tables();
show_all_devs(); show_all_devs(BIOS_DEBUG, "After writing tables.");
return mbi; return mbi;
} }
EXPORT_SYMBOL(stage2); EXPORT_SYMBOL(stage2);