From 587f263c4d8db119551ac4d9518abee9498ebd04 Mon Sep 17 00:00:00 2001 From: tmm Date: Sun, 24 Mar 2002 01:51:29 +0000 Subject: Map the device memory belonging to resources of type SYS_RES_MEMORY into KVA upon activation so that rman_get_virtual() works as expected. --- sys/sparc64/pci/psycho.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'sys/sparc64/pci') diff --git a/sys/sparc64/pci/psycho.c b/sys/sparc64/pci/psycho.c index ff1ba03..54edab5 100644 --- a/sys/sparc64/pci/psycho.c +++ b/sys/sparc64/pci/psycho.c @@ -1169,9 +1169,22 @@ static int psycho_activate_resource(device_t bus, device_t child, int type, int rid, struct resource *r) { + void *p; + int error; if (type == SYS_RES_IRQ) return (bus_activate_resource(bus, type, rid, r)); + if (type == SYS_RES_MEMORY) { + /* + * Need to memory-map the device space, as some drivers depend + * on the virtual address being set and useable. + */ + error = sparc64_bus_mem_map(rman_get_bustag(r), + rman_get_bushandle(r), rman_get_size(r), 0, NULL, &p); + if (error != 0) + return (error); + rman_set_virtual(r, p); + } return (rman_activate_resource(r)); } @@ -1182,6 +1195,10 @@ psycho_deactivate_resource(device_t bus, device_t child, int type, int rid, if (type == SYS_RES_IRQ) return (bus_deactivate_resource(bus, type, rid, r)); + if (type == SYS_RES_MEMORY) { + sparc64_bus_mem_unmap(rman_get_virtual(r), rman_get_size(r)); + rman_set_virtual(r, NULL); + } return (rman_deactivate_resource(r)); } -- cgit v1.1