device: Add device path display support

Add an optional routine to translate the device path types into a string
for display.

TEST=Build and run on Galileo

Change-Id: Iea5d0a2430d9a8546105324e2beda0955210dca9
Signed-off-by: Lee Leahy <leroy.p.leahy@intel.com>
Reviewed-on: https://review.coreboot.org/13715
Tested-by: build bot (Jenkins)
Reviewed-by: Martin Roth <martinroth@google.com>
This commit is contained in:
Lee Leahy 2016-02-13 06:10:04 -08:00 committed by Martin Roth
parent 800e964eef
commit a95baf9f7f
2 changed files with 32 additions and 0 deletions

View File

@ -921,3 +921,15 @@ int dev_count_cpu(void)
return count; return count;
} }
/* Get device path name */
const char *dev_path_name(enum device_path_type type)
{
static const char *const type_names[] = DEVICE_PATH_NAMES;
const char *type_name = "Unknown";
/* Translate the type value into a string */
if (type < ARRAY_SIZE(type_names))
type_name = type_names[type];
return type_name;
}

View File

@ -13,8 +13,27 @@ enum device_path_type {
DEVICE_PATH_CPU, DEVICE_PATH_CPU,
DEVICE_PATH_CPU_BUS, DEVICE_PATH_CPU_BUS,
DEVICE_PATH_IOAPIC, DEVICE_PATH_IOAPIC,
/*
* When adding path types to this table, please also update the
* DEVICE_PATH_NAMES macro below.
*/
}; };
#define DEVICE_PATH_NAMES { \
"DEVICE_PATH_NONE", \
"DEVICE_PATH_ROOT", \
"DEVICE_PATH_PCI", \
"DEVICE_PATH_PNP", \
"DEVICE_PATH_I2C", \
"DEVICE_PATH_APIC", \
"DEVICE_PATH_DOMAIN", \
"DEVICE_PATH_CPU_CLUSTER", \
"DEVICE_PATH_CPU", \
"DEVICE_PATH_CPU_BUS", \
"DEVICE_PATH_IOAPIC" \
}
struct domain_path struct domain_path
{ {
unsigned domain; unsigned domain;
@ -86,5 +105,6 @@ struct device_path {
#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(struct device_path *path1, struct device_path *path2);
extern const char *dev_path_name(enum device_path_type type);
#endif /* DEVICE_PATH_H */ #endif /* DEVICE_PATH_H */