Index: sys/kern/bus_if.m =================================================================== --- sys/kern/bus_if.m +++ sys/kern/bus_if.m @@ -955,3 +955,22 @@ void *_propvalue; size_t _size; } DEFAULT null_get_property; + +/** + * @brief Gets a child's full path to the device + * + * The get_device_path method retrieves a device's + * full path to the device using one of several + * locators present in the system. + * + * @param _bus the bus device + * @param _child the child device + * @param _locator locator name + * @param _sb buffer loaction string + */ +METHOD int get_device_path { + device_t _bus; + device_t _child; + const char *_locator; + struct sbuf *_sb; +} DEFAULT bus_generic_get_device_path; Index: sys/kern/subr_bus.c =================================================================== --- sys/kern/subr_bus.c +++ sys/kern/subr_bus.c @@ -4585,6 +4585,41 @@ return (ENOENT); } +/** + * @brief Helper function to implement normal BUS_GET_DEVICE_PATH() + * + * This function knows how to (a) pass the request up the tree if there's + * a parent and (b) Knows how to supply a FreeBSD locator. + * + * @param bus bus in the walk up the tree + * @param child leaf node to print information about + * @param locator BUS_LOCATOR_xxx string for locator + * @param sb Buffer to print information into + */ +int +bus_generic_get_device_path(device_t bus, device_t child, const char *locator, + struct sbuf *sb) +{ + int rv = 0; + device_t parent; + + parent = device_get_parent(bus); + if (parent != NULL) + rv = BUS_GET_DEVICE_PATH(parent, bus, locator, sb); + if (strcmp(locator, BUS_LOCATOR_FREEBSD) == 0) { + if (rv == 0) { + sbuf_printf(sb, "/%s", device_get_nameunit(child)); + } + return (rv); + } + /* + * Don't know what to do. So assume we do nothing. Not sure that's + * the right thing, but keeps us from having a big list here. + */ + return (0); +} + + /** * @brief Helper function for implementing BUS_RESCAN(). * Index: sys/sys/bus.h =================================================================== --- sys/sys/bus.h +++ sys/sys/bus.h @@ -492,6 +492,8 @@ struct resource_map *map); int bus_generic_write_ivar(device_t dev, device_t child, int which, uintptr_t value); +int bus_generic_get_device_path(device_t bus, device_t child, const char *locator, + struct sbuf *sb); int bus_helper_reset_post(device_t dev, int flags); int bus_helper_reset_prepare(device_t dev, int flags); int bus_null_rescan(device_t dev); @@ -733,6 +735,9 @@ #define BUS_PASS_ORDER_LATE 7 #define BUS_PASS_ORDER_LAST 9 +#define BUS_LOCATOR_UEFI "UEFI" +#define BUS_LOCATOR_FREEBSD "FreeBSD" + extern int bus_current_pass; void bus_set_pass(int pass);