Skip to content

Commit

Permalink
Allow callers of OF_decode_addr to get the size of the found mapping.…
Browse files Browse the repository at this point in the history
… This

will allow for code that uses the old fdt_get_range and fdt_regsize
functions to find a range, map it, access, then unmap to replace this, up
to and including the map, with a call to OF_decode_addr.

As this function should only be used in the early boot code the unmap is
mostly do document we no longer need the mapping as it's a no-op, at least
on arm.

Reviewed by:	jhibbits
Sponsored by:	ABT Systems Ltd
Differential Revision:	https://reviews.freebsd.org/D5258
  • Loading branch information
zxombie committed Feb 16, 2016
1 parent 284f6cd commit 05274f8
Show file tree
Hide file tree
Showing 10 changed files with 26 additions and 10 deletions.
6 changes: 5 additions & 1 deletion sys/arm/arm/ofw_machdep.c
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ __FBSDID("$FreeBSD$");

int
OF_decode_addr(phandle_t dev, int regno, bus_space_tag_t *tag,
bus_space_handle_t *handle)
bus_space_handle_t *handle, bus_size_t *sz)
{
bus_addr_t addr;
bus_size_t size;
Expand Down Expand Up @@ -66,6 +66,10 @@ OF_decode_addr(phandle_t dev, int regno, bus_space_tag_t *tag,
*tag = fdtbus_bs_tag;
flags = 0;
#endif

if (sz != NULL)
*sz = size;

return (bus_space_map(*tag, addr, size, flags, handle));
}

6 changes: 5 additions & 1 deletion sys/arm64/arm64/ofw_machdep.c
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ extern struct bus_space memmap_bus;

int
OF_decode_addr(phandle_t dev, int regno, bus_space_tag_t *tag,
bus_space_handle_t *handle)
bus_space_handle_t *handle, bus_size_t *sz)
{
bus_addr_t addr;
bus_size_t size;
Expand All @@ -50,5 +50,9 @@ OF_decode_addr(phandle_t dev, int regno, bus_space_tag_t *tag,
return (err);

*tag = &memmap_bus;

if (sz != NULL)
*sz = size;

return (bus_space_map(*tag, addr, size, 0, handle));
}
2 changes: 1 addition & 1 deletion sys/dev/ofw/openfirm.h
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ int OF_interpret(const char *cmd, int nreturns, ...);
*/
#ifndef __sparc64__
int OF_decode_addr(phandle_t dev, int regno, bus_space_tag_t *ptag,
bus_space_handle_t *phandle);
bus_space_handle_t *phandle, bus_size_t *sz);
#endif

#endif /* _KERNEL */
Expand Down
2 changes: 1 addition & 1 deletion sys/dev/tsec/if_tsec_fdt.c
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ tsec_fdt_attach(device_t dev)
}

phy = OF_node_from_xref(phy);
OF_decode_addr(OF_parent(phy), 0, &sc->phy_bst, &sc->phy_bsh);
OF_decode_addr(OF_parent(phy), 0, &sc->phy_bst, &sc->phy_bsh, NULL);
OF_getencprop(phy, "reg", &sc->phyaddr, sizeof(sc->phyaddr));

/* Init timer */
Expand Down
2 changes: 1 addition & 1 deletion sys/dev/uart/uart_cpu_fdt.c
Original file line number Diff line number Diff line change
Expand Up @@ -212,5 +212,5 @@ uart_cpu_getdev(int devtype, struct uart_devinfo *di)
di->stopbits = 1;
di->parity = UART_PARITY_NONE;

return (OF_decode_addr(node, 0, &di->bas.bst, &di->bas.bsh));
return (OF_decode_addr(node, 0, &di->bas.bst, &di->bas.bsh, NULL));
}
2 changes: 1 addition & 1 deletion sys/dev/uart/uart_cpu_powerpc.c
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ uart_cpu_getdev(int devtype, struct uart_devinfo *di)
if (class == NULL)
return (ENXIO);

error = OF_decode_addr(input, 0, &di->bas.bst, &di->bas.bsh);
error = OF_decode_addr(input, 0, &di->bas.bst, &di->bas.bsh, NULL);
if (error)
return (error);

Expand Down
3 changes: 2 additions & 1 deletion sys/dev/vt/hw/ofwfb/ofwfb.c
Original file line number Diff line number Diff line change
Expand Up @@ -480,7 +480,8 @@ ofwfb_init(struct vt_device *vd)
return (CN_DEAD);

#if defined(__powerpc__)
OF_decode_addr(node, fb_phys, &sc->sc_memt, &sc->fb.fb_vbase);
OF_decode_addr(node, fb_phys, &sc->sc_memt, &sc->fb.fb_vbase,
NULL);
sc->fb.fb_pbase = sc->fb.fb_vbase; /* 1:1 mapped */
#ifdef __powerpc64__
/* Real mode under a hypervisor probably doesn't cover FB */
Expand Down
6 changes: 5 additions & 1 deletion sys/mips/mips/ofw_machdep.c
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ __FBSDID("$FreeBSD$");

int
OF_decode_addr(phandle_t dev, int regno, bus_space_tag_t *tag,
bus_space_handle_t *handle)
bus_space_handle_t *handle, bus_size_t *sz)
{
bus_addr_t addr;
bus_size_t size;
Expand Down Expand Up @@ -66,5 +66,9 @@ OF_decode_addr(phandle_t dev, int regno, bus_space_tag_t *tag,
*tag = fdtbus_bs_tag;
flags = 0;
#endif

if (sz != NULL)
*sz = size;

return (bus_space_map(*tag, addr, size, flags, handle));
}
5 changes: 4 additions & 1 deletion sys/powerpc/ofw/ofw_machdep.c
Original file line number Diff line number Diff line change
Expand Up @@ -565,7 +565,7 @@ OF_getetheraddr(device_t dev, u_char *addr)
*/
int
OF_decode_addr(phandle_t dev, int regno, bus_space_tag_t *tag,
bus_space_handle_t *handle)
bus_space_handle_t *handle, bus_size_t *sz)
{
bus_addr_t addr;
bus_size_t size;
Expand All @@ -585,6 +585,9 @@ OF_decode_addr(phandle_t dev, int regno, bus_space_tag_t *tag,
BUS_SPACE_MAP_PREFETCHABLE: 0;
}

if (sz != NULL)
*sz = size;

return (bus_space_map(*tag, addr, size, flags, handle));
}

2 changes: 1 addition & 1 deletion sys/powerpc/ofw/ofw_syscons.c
Original file line number Diff line number Diff line change
Expand Up @@ -342,7 +342,7 @@ ofwfb_configure(int flags)
if (fb_phys == sc->sc_num_pciaddrs)
return (0);

OF_decode_addr(node, fb_phys, &sc->sc_tag, &sc->sc_addr);
OF_decode_addr(node, fb_phys, &sc->sc_tag, &sc->sc_addr, NULL);
}

ofwfb_init(0, &sc->sc_va, 0);
Expand Down

0 comments on commit 05274f8

Please sign in to comment.