Add function to encode device path into integer
This function will encode the device path into 3 bytes of a dword which can be saved for debug. It will be used by subsequent commit to store the current device into CMOS for debugging BIOS hangs. BUG=chrome-os-partner:19980 BRANCH=none TEST=New code only, nothing uses it yet. Change-Id: I3a5155ea53c8d280806e610a0f8998dbabe15f3c Signed-off-by: Duncan Laurie <dlaurie@chromium.org> Reviewed-on: https://gerrit.chromium.org/gerrit/58103 Reviewed-by: Aaron Durbin <adurbin@chromium.org>
This commit is contained in:
parent
7d55ce2c25
commit
cede29786b
2 changed files with 56 additions and 0 deletions
|
|
@ -158,6 +158,61 @@ struct device *dev_find_class(unsigned int class, struct device *from)
|
|||
return from;
|
||||
}
|
||||
|
||||
/**
|
||||
* Encode the device path into 3 bytes for logging to CMOS.
|
||||
*
|
||||
* @param dev The device path to encode.
|
||||
* @return Device path encoded into lower 3 bytes of dword.
|
||||
*/
|
||||
u32 dev_path_encode(device_t dev)
|
||||
{
|
||||
u32 ret;
|
||||
|
||||
if (!dev)
|
||||
return 0;
|
||||
|
||||
/* Store the device type in 3rd byte. */
|
||||
ret = dev->path.type << 16;
|
||||
|
||||
/* Encode the device specific path in the low word. */
|
||||
switch (dev->path.type) {
|
||||
case DEVICE_PATH_ROOT:
|
||||
break;
|
||||
case DEVICE_PATH_PCI:
|
||||
ret |= dev->bus->secondary << 8 | dev->path.pci.devfn;
|
||||
break;
|
||||
case DEVICE_PATH_PNP:
|
||||
ret |= dev->path.pnp.port << 8 | dev->path.pnp.device;
|
||||
break;
|
||||
case DEVICE_PATH_I2C:
|
||||
ret |= dev->bus->secondary << 8 | dev->path.pnp.device;
|
||||
break;
|
||||
case DEVICE_PATH_APIC:
|
||||
ret |= dev->path.apic.apic_id;
|
||||
break;
|
||||
case DEVICE_PATH_DOMAIN:
|
||||
ret |= dev->path.domain.domain;
|
||||
break;
|
||||
case DEVICE_PATH_CPU_CLUSTER:
|
||||
ret |= dev->path.cpu_cluster.cluster;
|
||||
break;
|
||||
case DEVICE_PATH_CPU:
|
||||
ret |= dev->path.cpu.id;
|
||||
break;
|
||||
case DEVICE_PATH_CPU_BUS:
|
||||
ret |= dev->path.cpu_bus.id;
|
||||
break;
|
||||
case DEVICE_PATH_IOAPIC:
|
||||
ret |= dev->path.ioapic.ioapic_id;
|
||||
break;
|
||||
case DEVICE_PATH_NONE:
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
/*
|
||||
* Warning: This function uses a static buffer. Don't call it more than once
|
||||
* from the same print statement!
|
||||
|
|
|
|||
|
|
@ -143,6 +143,7 @@ void enumerate_static_device(void);
|
|||
void enumerate_static_devices(void);
|
||||
const char *dev_name(device_t dev);
|
||||
const char *dev_path(device_t dev);
|
||||
u32 dev_path_encode(device_t dev);
|
||||
const char *bus_path(struct bus *bus);
|
||||
void dev_set_enabled(device_t dev, int enable);
|
||||
void disable_children(struct bus *bus);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue