PERFORCE change 103451 for review
Oleksandr Tymoshenko
gonzo at FreeBSD.org
Tue Aug 8 15:55:42 UTC 2006
http://perforce.freebsd.org/chv.cgi?CH=103451
Change 103451 by gonzo at gonzo_hq on 2006/08/08 15:55:01
o Add proper resource handling for nexus device.
Affected files ...
.. //depot/projects/mips2/src/sys/mips/mips/nexus.c#2 edit
Differences ...
==== //depot/projects/mips2/src/sys/mips/mips/nexus.c#2 (text+ko) ====
@@ -48,16 +48,17 @@
#include <sys/kernel.h>
#include <sys/malloc.h>
#include <sys/module.h>
-#include <machine/bus.h>
#include <sys/rman.h>
#include <sys/interrupt.h>
-#include <machine/vmparam.h>
#include <vm/vm.h>
#include <vm/pmap.h>
+
+#include <machine/bus.h>
+#include <machine/intr_machdep.h>
#include <machine/pmap.h>
-
#include <machine/resource.h>
+#include <machine/vmparam.h>
static MALLOC_DEFINE(M_NEXUSDEV, "nexusdev", "Nexus device");
@@ -67,7 +68,7 @@
#define DEVTONX(dev) ((struct nexus_device *)device_get_ivars(dev))
-static struct rman mem_rman;
+static struct rman irq_rman;
static int nexus_probe(device_t);
static int nexus_attach(device_t);
@@ -109,23 +110,30 @@
{
device_quiet(dev); /* suppress attach message for neatness */
- mem_rman.rm_start = 0;
- mem_rman.rm_end = ~0u;
- mem_rman.rm_type = RMAN_ARRAY;
- mem_rman.rm_descr = "I/O memory addresses";
- if (rman_init(&mem_rman)
- || rman_manage_region(&mem_rman, 0, ~0u))
- panic("nexus_probe mem_rman");
+ irq_rman.rm_start = 0;
+ irq_rman.rm_end = 5;
+ irq_rman.rm_type = RMAN_ARRAY;
+ irq_rman.rm_descr = "Hardware IRQs";
+ if (rman_init(&irq_rman)
+ || rman_manage_region(&irq_rman, 0, 5))
+ panic("nexus_probe irq_rman");
+
return (0);
- return bus_generic_probe(dev);
}
static int
nexus_setup_intr(device_t dev, device_t child, struct resource *res, int flags,
driver_intr_t *intr, void *arg, void **cookiep)
{
- printf("Unimplemented %s at %s:%d\n", __func__, __FILE__, __LINE__);
+ int irq;
+
+ intr_disable();
+ irq = rman_get_start(res);
+ if(irq > 5)
+ return(0);
+ cpu_establish_hardintr(irq, intr, arg);
+ intr_enable();
return (0);
}
@@ -166,6 +174,7 @@
{
device_t child;
struct nexus_device *ndev;
+
ndev = malloc(sizeof(struct nexus_device), M_NEXUSDEV, M_NOWAIT|M_ZERO);
if (!ndev)
@@ -195,8 +204,8 @@
int needactivate = flags & RF_ACTIVE;
switch (type) {
- case SYS_RES_MEMORY:
- rm = &mem_rman;
+ case SYS_RES_IRQ:
+ rm = &irq_rman;
break;
default:
@@ -208,8 +217,6 @@
return 0;
rman_set_rid(rv, *rid);
- rman_set_bustag(rv, MIPS_BUS_SPACE_MEM);
- rman_set_bushandle(rv, rman_get_start(rv));
if (needactivate) {
if (bus_activate_resource(child, type, *rid, rv)) {
@@ -226,22 +233,6 @@
nexus_activate_resource(device_t bus, device_t child, int type, int rid,
struct resource *r)
{
- /*
- * If this is a memory resource, map it into the kernel.
- */
- if (rman_get_bustag(r) == MIPS_BUS_SPACE_MEM) {
- caddr_t vaddr = 0;
- u_int32_t paddr;
- u_int32_t psize;
- u_int32_t poffs;
-
- paddr = rman_get_start(r);
- psize = rman_get_size(r);
- poffs = paddr - trunc_page(paddr);
- vaddr = (caddr_t) pmap_mapdev(paddr-poffs, psize+poffs) + poffs;
- rman_set_virtual(r, vaddr);
- rman_set_bushandle(r, (bus_space_handle_t) vaddr);
- }
return (rman_activate_resource(r));
}
More information about the p4-projects
mailing list