nexus.c (257702) | nexus.c (261513) |
---|---|
1/*- 2 * Copyright 1998 Massachusetts Institute of Technology 3 * 4 * Permission to use, copy, modify, and distribute this software and 5 * its documentation for any purpose and without fee is hereby 6 * granted, provided that both the above copyright notice and this 7 * permission notice appear in all copies, that both the above 8 * copyright notice and this permission notice appear in all --- 24 unchanged lines hidden (view full) --- 33 * machines. The function of the root nexus is to serve as an 34 * attachment point for both processors and buses, and to manage 35 * resources which are common to all of them. In particular, 36 * this code implements the core resource managers for interrupt 37 * requests and memory address space. 38 */ 39 40#include <sys/cdefs.h> | 1/*- 2 * Copyright 1998 Massachusetts Institute of Technology 3 * 4 * Permission to use, copy, modify, and distribute this software and 5 * its documentation for any purpose and without fee is hereby 6 * granted, provided that both the above copyright notice and this 7 * permission notice appear in all copies, that both the above 8 * copyright notice and this permission notice appear in all --- 24 unchanged lines hidden (view full) --- 33 * machines. The function of the root nexus is to serve as an 34 * attachment point for both processors and buses, and to manage 35 * resources which are common to all of them. In particular, 36 * this code implements the core resource managers for interrupt 37 * requests and memory address space. 38 */ 39 40#include <sys/cdefs.h> |
41__FBSDID("$FreeBSD: head/sys/mips/mips/nexus.c 257702 2013-11-05 13:48:34Z nwhitehorn $"); | 41__FBSDID("$FreeBSD: head/sys/mips/mips/nexus.c 261513 2014-02-05 14:44:22Z nwhitehorn $"); |
42 43#include <sys/param.h> 44#include <sys/systm.h> 45#include <sys/bus.h> 46#include <sys/kernel.h> 47#include <sys/malloc.h> 48#include <sys/module.h> 49#include <sys/rman.h> --- 5 unchanged lines hidden (view full) --- 55#include <machine/bus.h> 56#include <machine/intr_machdep.h> 57#include <machine/pmap.h> 58#include <machine/resource.h> 59#include <machine/vmparam.h> 60 61#include "opt_platform.h" 62 | 42 43#include <sys/param.h> 44#include <sys/systm.h> 45#include <sys/bus.h> 46#include <sys/kernel.h> 47#include <sys/malloc.h> 48#include <sys/module.h> 49#include <sys/rman.h> --- 5 unchanged lines hidden (view full) --- 55#include <machine/bus.h> 56#include <machine/intr_machdep.h> 57#include <machine/pmap.h> 58#include <machine/resource.h> 59#include <machine/vmparam.h> 60 61#include "opt_platform.h" 62 |
63#ifdef FDT 64#include <dev/ofw/ofw_nexus.h> 65#endif 66 | |
67#undef NEXUS_DEBUG 68#ifdef NEXUS_DEBUG 69#define dprintf printf 70#else 71#define dprintf(x, arg...) 72#endif /* NEXUS_DEBUG */ 73 74#define NUM_MIPS_IRQS 6 75 | 63#undef NEXUS_DEBUG 64#ifdef NEXUS_DEBUG 65#define dprintf printf 66#else 67#define dprintf(x, arg...) 68#endif /* NEXUS_DEBUG */ 69 70#define NUM_MIPS_IRQS 6 71 |
76#ifndef FDT | |
77static MALLOC_DEFINE(M_NEXUSDEV, "nexusdev", "Nexus device"); 78 79struct nexus_device { 80 struct resource_list nx_resources; 81}; 82 83#define DEVTONX(dev) ((struct nexus_device *)device_get_ivars(dev)) 84 --- 12 unchanged lines hidden (view full) --- 97 u_long *); 98static int nexus_print_child(device_t, device_t); 99static int nexus_print_all_resources(device_t dev); 100static int nexus_probe(device_t); 101static int nexus_release_resource(device_t, device_t, int, int, 102 struct resource *); 103static int nexus_set_resource(device_t, device_t, int, int, u_long, 104 u_long); | 72static MALLOC_DEFINE(M_NEXUSDEV, "nexusdev", "Nexus device"); 73 74struct nexus_device { 75 struct resource_list nx_resources; 76}; 77 78#define DEVTONX(dev) ((struct nexus_device *)device_get_ivars(dev)) 79 --- 12 unchanged lines hidden (view full) --- 92 u_long *); 93static int nexus_print_child(device_t, device_t); 94static int nexus_print_all_resources(device_t dev); 95static int nexus_probe(device_t); 96static int nexus_release_resource(device_t, device_t, int, int, 97 struct resource *); 98static int nexus_set_resource(device_t, device_t, int, int, u_long, 99 u_long); |
105#endif | |
106static int nexus_activate_resource(device_t, device_t, int, int, 107 struct resource *); 108static int nexus_deactivate_resource(device_t, device_t, int, int, 109 struct resource *); 110static void nexus_hinted_child(device_t, const char *, int); 111static int nexus_setup_intr(device_t dev, device_t child, 112 struct resource *res, int flags, driver_filter_t *filt, 113 driver_intr_t *intr, void *arg, void **cookiep); 114static int nexus_teardown_intr(device_t, device_t, struct resource *, 115 void *); 116 117static device_method_t nexus_methods[] = { | 100static int nexus_activate_resource(device_t, device_t, int, int, 101 struct resource *); 102static int nexus_deactivate_resource(device_t, device_t, int, int, 103 struct resource *); 104static void nexus_hinted_child(device_t, const char *, int); 105static int nexus_setup_intr(device_t dev, device_t child, 106 struct resource *res, int flags, driver_filter_t *filt, 107 driver_intr_t *intr, void *arg, void **cookiep); 108static int nexus_teardown_intr(device_t, device_t, struct resource *, 109 void *); 110 111static device_method_t nexus_methods[] = { |
118#ifndef FDT | |
119 /* Device interface */ 120 DEVMETHOD(device_probe, nexus_probe), 121 DEVMETHOD(device_attach, nexus_attach), 122 123 /* Bus interface */ 124 DEVMETHOD(bus_add_child, nexus_add_child), 125 DEVMETHOD(bus_alloc_resource, nexus_alloc_resource), 126 DEVMETHOD(bus_delete_resource, nexus_delete_resource), 127 DEVMETHOD(bus_get_resource, nexus_get_resource), 128 DEVMETHOD(bus_get_resource_list, nexus_get_reslist), 129 DEVMETHOD(bus_print_child, nexus_print_child), 130 DEVMETHOD(bus_release_resource, nexus_release_resource), 131 DEVMETHOD(bus_set_resource, nexus_set_resource), | 112 /* Device interface */ 113 DEVMETHOD(device_probe, nexus_probe), 114 DEVMETHOD(device_attach, nexus_attach), 115 116 /* Bus interface */ 117 DEVMETHOD(bus_add_child, nexus_add_child), 118 DEVMETHOD(bus_alloc_resource, nexus_alloc_resource), 119 DEVMETHOD(bus_delete_resource, nexus_delete_resource), 120 DEVMETHOD(bus_get_resource, nexus_get_resource), 121 DEVMETHOD(bus_get_resource_list, nexus_get_reslist), 122 DEVMETHOD(bus_print_child, nexus_print_child), 123 DEVMETHOD(bus_release_resource, nexus_release_resource), 124 DEVMETHOD(bus_set_resource, nexus_set_resource), |
132#endif | |
133 DEVMETHOD(bus_setup_intr, nexus_setup_intr), 134 DEVMETHOD(bus_teardown_intr, nexus_teardown_intr), 135 DEVMETHOD(bus_activate_resource,nexus_activate_resource), 136 DEVMETHOD(bus_deactivate_resource, nexus_deactivate_resource), 137 DEVMETHOD(bus_hinted_child, nexus_hinted_child), 138 139 { 0, 0 } 140}; 141 | 125 DEVMETHOD(bus_setup_intr, nexus_setup_intr), 126 DEVMETHOD(bus_teardown_intr, nexus_teardown_intr), 127 DEVMETHOD(bus_activate_resource,nexus_activate_resource), 128 DEVMETHOD(bus_deactivate_resource, nexus_deactivate_resource), 129 DEVMETHOD(bus_hinted_child, nexus_hinted_child), 130 131 { 0, 0 } 132}; 133 |
142#ifndef FDT | |
143static driver_t nexus_driver = { 144 "nexus", 145 nexus_methods, 146 1 /* no softc */ 147}; | 134static driver_t nexus_driver = { 135 "nexus", 136 nexus_methods, 137 1 /* no softc */ 138}; |
148#else 149DEFINE_CLASS_1(nexus, nexus_driver, nexus_methods, 150 sizeof(struct ofw_nexus_softc), ofw_nexus_driver); 151#endif | |
152static devclass_t nexus_devclass; 153 | 139static devclass_t nexus_devclass; 140 |
154#ifndef FDT | |
155static int 156nexus_probe(device_t dev) 157{ 158 159 device_set_desc(dev, "MIPS32 root nexus"); 160 161 irq_rman.rm_start = 0; 162 irq_rman.rm_end = NUM_MIPS_IRQS - 1; --- 219 unchanged lines hidden (view full) --- 382 if (rman_get_flags(r) & RF_ACTIVE) { 383 int error = bus_deactivate_resource(child, type, rid, r); 384 if (error) 385 return error; 386 } 387 388 return (rman_release_resource(r)); 389} | 141static int 142nexus_probe(device_t dev) 143{ 144 145 device_set_desc(dev, "MIPS32 root nexus"); 146 147 irq_rman.rm_start = 0; 148 irq_rman.rm_end = NUM_MIPS_IRQS - 1; --- 219 unchanged lines hidden (view full) --- 368 if (rman_get_flags(r) & RF_ACTIVE) { 369 int error = bus_deactivate_resource(child, type, rid, r); 370 if (error) 371 return error; 372 } 373 374 return (rman_release_resource(r)); 375} |
390#endif | |
391 392static int 393nexus_activate_resource(device_t bus, device_t child, int type, int rid, 394 struct resource *r) 395{ 396 void *vaddr; 397 vm_paddr_t paddr; 398 vm_size_t psize; --- 113 unchanged lines hidden --- | 376 377static int 378nexus_activate_resource(device_t bus, device_t child, int type, int rid, 379 struct resource *r) 380{ 381 void *vaddr; 382 vm_paddr_t paddr; 383 vm_size_t psize; --- 113 unchanged lines hidden --- |