Changeset View
Changeset View
Standalone View
Standalone View
sys/dev/puc/puc.c
Show First 20 Lines • Show All 42 Lines • ▼ Show 20 Lines | |||||
SYSCTL_NODE(_hw, OID_AUTO, puc, CTLFLAG_RD, 0, "puc(9) driver configuration"); | SYSCTL_NODE(_hw, OID_AUTO, puc, CTLFLAG_RD, 0, "puc(9) driver configuration"); | ||||
struct puc_bar * | struct puc_bar * | ||||
puc_get_bar(struct puc_softc *sc, int rid) | puc_get_bar(struct puc_softc *sc, int rid) | ||||
{ | { | ||||
struct puc_bar *bar; | struct puc_bar *bar; | ||||
struct rman *rm; | struct rman *rm; | ||||
u_long end, start; | rman_res_t end, start; | ||||
int error, i; | int error, i; | ||||
/* Find the BAR entry with the given RID. */ | /* Find the BAR entry with the given RID. */ | ||||
i = 0; | i = 0; | ||||
while (i < PUC_PCI_BARS && sc->sc_bar[i].b_rid != rid) | while (i < PUC_PCI_BARS && sc->sc_bar[i].b_rid != rid) | ||||
i++; | i++; | ||||
if (i < PUC_PCI_BARS) | if (i < PUC_PCI_BARS) | ||||
return (&sc->sc_bar[i]); | return (&sc->sc_bar[i]); | ||||
▲ Show 20 Lines • Show All 84 Lines • ▼ Show 20 Lines | |||||
return (error); | return (error); | ||||
if (res != 0) | if (res != 0) | ||||
device_set_desc(dev, (const char *)res); | device_set_desc(dev, (const char *)res); | ||||
return (BUS_PROBE_DEFAULT); | return (BUS_PROBE_DEFAULT); | ||||
} | } | ||||
struct resource * | struct resource * | ||||
puc_bus_alloc_resource(device_t dev, device_t child, int type, int *rid, | puc_bus_alloc_resource(device_t dev, device_t child, int type, int *rid, | ||||
u_long start, u_long end, u_long count, u_int flags) | rman_res_t start, rman_res_t end, rman_res_t count, u_int flags) | ||||
{ | { | ||||
struct puc_port *port; | struct puc_port *port; | ||||
struct resource *res; | struct resource *res; | ||||
device_t assigned, originator; | device_t assigned, originator; | ||||
int error; | int error; | ||||
/* Get our immediate child. */ | /* Get our immediate child. */ | ||||
originator = child; | originator = child; | ||||
while (child != NULL && device_get_parent(child) != dev) | while (child != NULL && device_get_parent(child) != dev) | ||||
child = device_get_parent(child); | child = device_get_parent(child); | ||||
if (child == NULL) | if (child == NULL) | ||||
return (NULL); | return (NULL); | ||||
port = device_get_ivars(child); | port = device_get_ivars(child); | ||||
KASSERT(port != NULL, ("%s %d", __func__, __LINE__)); | KASSERT(port != NULL, ("%s %d", __func__, __LINE__)); | ||||
if (rid == NULL || *rid != 0) | if (rid == NULL || *rid != 0) | ||||
return (NULL); | return (NULL); | ||||
/* We only support default allocations. */ | /* We only support default allocations. */ | ||||
if (start != 0UL || end != ~0UL) | if (start != 0 || end != ~0) | ||||
return (NULL); | return (NULL); | ||||
if (type == port->p_bar->b_type) | if (type == port->p_bar->b_type) | ||||
res = port->p_rres; | res = port->p_rres; | ||||
else if (type == SYS_RES_IRQ) | else if (type == SYS_RES_IRQ) | ||||
res = port->p_ires; | res = port->p_ires; | ||||
else | else | ||||
return (NULL); | return (NULL); | ||||
▲ Show 20 Lines • Show All 55 Lines • ▼ Show 20 Lines | |||||
if (rman_get_flags(res) & RF_ACTIVE) | if (rman_get_flags(res) & RF_ACTIVE) | ||||
rman_deactivate_resource(res); | rman_deactivate_resource(res); | ||||
rman_set_device(res, NULL); | rman_set_device(res, NULL); | ||||
return (0); | return (0); | ||||
} | } | ||||
int | int | ||||
puc_bus_get_resource(device_t dev, device_t child, int type, int rid, | puc_bus_get_resource(device_t dev, device_t child, int type, int rid, | ||||
u_long *startp, u_long *countp) | rman_res_t *startp, rman_res_t *countp) | ||||
{ | { | ||||
struct puc_port *port; | struct puc_port *port; | ||||
struct resource *res; | struct resource *res; | ||||
u_long start; | rman_res_t start; | ||||
/* Get our immediate child. */ | /* Get our immediate child. */ | ||||
while (child != NULL && device_get_parent(child) != dev) | while (child != NULL && device_get_parent(child) != dev) | ||||
child = device_get_parent(child); | child = device_get_parent(child); | ||||
if (child == NULL) | if (child == NULL) | ||||
return (EINVAL); | return (EINVAL); | ||||
port = device_get_ivars(child); | port = device_get_ivars(child); | ||||
▲ Show 20 Lines • Show All 42 Lines • Show Last 20 Lines |