Re: git: 7b5d62bb73e3 - main - ofw: add BUS_GET_DEVICE_PATH interface to openfirm/fdt, somewhat incomplete.
Date: Tue, 18 Oct 2022 14:35:18 UTC
On 18 Oct 2022, at 09:01, Takanori Watanabe <takawata@FreeBSD.org> wrote: > > The branch main has been updated by takawata: > > URL: https://cgit.FreeBSD.org/src/commit/?id=7b5d62bb73e32d50bb07024ac483532fbcaafe81 > > commit 7b5d62bb73e32d50bb07024ac483532fbcaafe81 > Author: Takanori Watanabe <takawata@FreeBSD.org> > AuthorDate: 2022-10-18 06:08:53 +0000 > Commit: Takanori Watanabe <takawata@FreeBSD.org> > CommitDate: 2022-10-18 07:55:47 +0000 > > ofw: add BUS_GET_DEVICE_PATH interface to openfirm/fdt, somewhat incomplete. > > This add BUS_GET_DEVICE_PATH interface, > which shows device tree of openfirm/fdt. > > In qemu-system-arm64 with "virt" machine with device-tree firmware, > % devctl getpath OFW cpu0 > > Reviewed by: andrew > Differential Revision: https://reviews.freebsd.org/D37031 > --- > sys/arm/arm/gic_fdt.c | 1 + > sys/arm64/arm64/gic_v3_fdt.c | 1 + > sys/dev/fdt/simplebus.c | 1 + > sys/dev/ofw/ofw_bus_subr.c | 16 ++++++++++++++++ > sys/dev/ofw/ofw_bus_subr.h | 1 + > sys/dev/ofw/ofw_cpu.c | 1 + > sys/sys/bus.h | 1 + > 7 files changed, 22 insertions(+) > > diff --git a/sys/arm/arm/gic_fdt.c b/sys/arm/arm/gic_fdt.c > index 5b1b77024df6..9e5e51429534 100644 > --- a/sys/arm/arm/gic_fdt.c > +++ b/sys/arm/arm/gic_fdt.c > @@ -90,6 +90,7 @@ static device_method_t gic_fdt_methods[] = { > > /* Bus interface */ > DEVMETHOD(bus_get_resource_list,gic_fdt_get_resource_list), > + DEVMETHOD(bus_get_device_path, ofw_bus_gen_get_device_path), > > /* ofw_bus interface */ > DEVMETHOD(ofw_bus_get_devinfo, gic_ofw_get_devinfo), > diff --git a/sys/arm64/arm64/gic_v3_fdt.c b/sys/arm64/arm64/gic_v3_fdt.c > index 16007c5c4147..3ccf2e543b8a 100644 > --- a/sys/arm64/arm64/gic_v3_fdt.c > +++ b/sys/arm64/arm64/gic_v3_fdt.c > @@ -64,6 +64,7 @@ static device_method_t gic_v3_fdt_methods[] = { > > /* Bus interface */ > DEVMETHOD(bus_get_resource_list, gic_v3_fdt_get_resource_list), > + DEVMETHOD(bus_get_device_path, ofw_bus_gen_get_device_path), > > /* ofw_bus interface */ > DEVMETHOD(ofw_bus_get_devinfo, gic_v3_ofw_get_devinfo), > diff --git a/sys/dev/fdt/simplebus.c b/sys/dev/fdt/simplebus.c > index 0b1277983da0..a69bdf93e7d6 100644 > --- a/sys/dev/fdt/simplebus.c > +++ b/sys/dev/fdt/simplebus.c > @@ -94,6 +94,7 @@ static device_method_t simplebus_methods[] = { > DEVMETHOD(bus_child_pnpinfo, ofw_bus_gen_child_pnpinfo), > DEVMETHOD(bus_get_resource_list, simplebus_get_resource_list), > DEVMETHOD(bus_get_property, simplebus_get_property), > + DEVMETHOD(bus_get_device_path, ofw_bus_gen_get_device_path), > > /* ofw_bus interface */ > DEVMETHOD(ofw_bus_get_devinfo, simplebus_get_devinfo), > diff --git a/sys/dev/ofw/ofw_bus_subr.c b/sys/dev/ofw/ofw_bus_subr.c > index 404bed3c73fa..169bea1f5997 100644 > --- a/sys/dev/ofw/ofw_bus_subr.c > +++ b/sys/dev/ofw/ofw_bus_subr.c > @@ -104,6 +104,22 @@ ofw_bus_gen_child_pnpinfo(device_t cbdev, device_t child, struct sbuf *sb) > return (0); > }; > > +int > +ofw_bus_gen_get_device_path(device_t cbdev, device_t child, const char *locator, > + struct sbuf *sb) > +{ > + int rv; > + > + if ( strcmp(locator, BUS_LOCATOR_OFW) == 0){ The space after ( shouldn’t be there and ){ should have one. Jess > + rv = bus_generic_get_device_path(cbdev, child, locator, sb); > + if (rv == 0){ > + sbuf_printf(sb, "/%s", ofw_bus_get_name(child)); > + } > + return (rv); > + } > + return (bus_generic_get_device_path(cbdev, child, locator, sb)); > +}; > + > const char * > ofw_bus_gen_get_compat(device_t bus, device_t dev) > { > diff --git a/sys/dev/ofw/ofw_bus_subr.h b/sys/dev/ofw/ofw_bus_subr.h > index 89f291f92373..8dcf517fd58b 100644 > --- a/sys/dev/ofw/ofw_bus_subr.h > +++ b/sys/dev/ofw/ofw_bus_subr.h > @@ -84,6 +84,7 @@ ofw_bus_get_type_t ofw_bus_gen_get_type; > > /* Helper method to report interesting OF properties in pnpinfo */ > bus_child_pnpinfo_t ofw_bus_gen_child_pnpinfo; > +bus_get_device_path_t ofw_bus_gen_get_device_path; > > /* Routines for processing firmware interrupt maps */ > void ofw_bus_setup_iinfo(phandle_t, struct ofw_bus_iinfo *, int); > diff --git a/sys/dev/ofw/ofw_cpu.c b/sys/dev/ofw/ofw_cpu.c > index f7bfc10b7b73..8b48e645f1b4 100644 > --- a/sys/dev/ofw/ofw_cpu.c > +++ b/sys/dev/ofw/ofw_cpu.c > @@ -68,6 +68,7 @@ static device_method_t ofw_cpulist_methods[] = { > /* Bus interface */ > DEVMETHOD(bus_add_child, bus_generic_add_child), > DEVMETHOD(bus_child_pnpinfo, ofw_bus_gen_child_pnpinfo), > + DEVMETHOD(bus_get_device_path, ofw_bus_gen_get_device_path), > > /* ofw_bus interface */ > DEVMETHOD(ofw_bus_get_devinfo, ofw_cpulist_get_devinfo), > diff --git a/sys/sys/bus.h b/sys/sys/bus.h > index 5dead4dd382e..2f9a5a6de588 100644 > --- a/sys/sys/bus.h > +++ b/sys/sys/bus.h > @@ -761,6 +761,7 @@ void bus_data_generation_update(void); > #define BUS_LOCATOR_ACPI "ACPI" > #define BUS_LOCATOR_FREEBSD "FreeBSD" > #define BUS_LOCATOR_UEFI "UEFI" > +#define BUS_LOCATOR_OFW "OFW" > > extern int bus_current_pass; >