Changeset View
Changeset View
Standalone View
Standalone View
sys/dev/pccard/pccard.c
Show First 20 Lines • Show All 42 Lines • ▼ Show 20 Lines | |||||
static void pccard_function_disable(struct pccard_function *pf); | static void pccard_function_disable(struct pccard_function *pf); | ||||
static int pccard_probe(device_t dev); | static int pccard_probe(device_t dev); | ||||
static int pccard_attach(device_t dev); | static int pccard_attach(device_t dev); | ||||
static int pccard_detach(device_t dev); | static int pccard_detach(device_t dev); | ||||
static void pccard_print_resources(struct resource_list *rl, | static void pccard_print_resources(struct resource_list *rl, | ||||
const char *name, int type, int count, const char *format); | const char *name, int type, int count, const char *format); | ||||
static int pccard_print_child(device_t dev, device_t child); | static int pccard_print_child(device_t dev, device_t child); | ||||
static int pccard_set_resource(device_t dev, device_t child, int type, | static int pccard_set_resource(device_t dev, device_t child, int type, | ||||
int rid, u_long start, u_long count); | int rid, rman_res_t start, rman_res_t count); | ||||
static int pccard_get_resource(device_t dev, device_t child, int type, | static int pccard_get_resource(device_t dev, device_t child, int type, | ||||
int rid, u_long *startp, u_long *countp); | int rid, rman_res_t *startp, rman_res_t *countp); | ||||
static void pccard_delete_resource(device_t dev, device_t child, int type, | static void pccard_delete_resource(device_t dev, device_t child, int type, | ||||
int rid); | int rid); | ||||
static int pccard_set_res_flags(device_t dev, device_t child, int type, | static int pccard_set_res_flags(device_t dev, device_t child, int type, | ||||
int rid, u_long flags); | int rid, u_long flags); | ||||
static int pccard_set_memory_offset(device_t dev, device_t child, int rid, | static int pccard_set_memory_offset(device_t dev, device_t child, int rid, | ||||
uint32_t offset, uint32_t *deltap); | uint32_t offset, uint32_t *deltap); | ||||
static int pccard_probe_and_attach_child(device_t dev, device_t child, | static int pccard_probe_and_attach_child(device_t dev, device_t child, | ||||
struct pccard_function *pf); | struct pccard_function *pf); | ||||
static void pccard_probe_nomatch(device_t cbdev, device_t child); | static void pccard_probe_nomatch(device_t cbdev, device_t child); | ||||
static int pccard_read_ivar(device_t bus, device_t child, int which, | static int pccard_read_ivar(device_t bus, device_t child, int which, | ||||
uintptr_t *result); | uintptr_t *result); | ||||
static void pccard_driver_added(device_t dev, driver_t *driver); | static void pccard_driver_added(device_t dev, driver_t *driver); | ||||
static struct resource *pccard_alloc_resource(device_t dev, | static struct resource *pccard_alloc_resource(device_t dev, | ||||
device_t child, int type, int *rid, u_long start, | device_t child, int type, int *rid, rman_res_t start, | ||||
u_long end, u_long count, u_int flags); | rman_res_t end, rman_res_t count, u_int flags); | ||||
static int pccard_release_resource(device_t dev, device_t child, int type, | static int pccard_release_resource(device_t dev, device_t child, int type, | ||||
int rid, struct resource *r); | int rid, struct resource *r); | ||||
static void pccard_child_detached(device_t parent, device_t dev); | static void pccard_child_detached(device_t parent, device_t dev); | ||||
static int pccard_filter(void *arg); | static int pccard_filter(void *arg); | ||||
static void pccard_intr(void *arg); | static void pccard_intr(void *arg); | ||||
static int pccard_setup_intr(device_t dev, device_t child, | static int pccard_setup_intr(device_t dev, device_t child, | ||||
struct resource *irq, int flags, driver_filter_t *filt, | struct resource *irq, int flags, driver_filter_t *filt, | ||||
driver_intr_t *intr, void *arg, void **cookiep); | driver_intr_t *intr, void *arg, void **cookiep); | ||||
▲ Show 20 Lines • Show All 84 Lines • ▼ Show 20 Lines | |||||
struct pccard_config_entry *cfe; | struct pccard_config_entry *cfe; | ||||
struct pccard_ivar *devi = PCCARD_IVAR(pf->dev); | struct pccard_ivar *devi = PCCARD_IVAR(pf->dev); | ||||
struct resource_list *rl = &devi->resources; | struct resource_list *rl = &devi->resources; | ||||
struct resource_list_entry *rle; | struct resource_list_entry *rle; | ||||
struct resource *r = 0; | struct resource *r = 0; | ||||
struct pccard_ce_iospace *ios; | struct pccard_ce_iospace *ios; | ||||
struct pccard_ce_memspace *mems; | struct pccard_ce_memspace *mems; | ||||
device_t bus; | device_t bus; | ||||
u_long start, end, len; | rman_res_t start, end, len; | ||||
int i, rid, spaces; | int i, rid, spaces; | ||||
if (pf->pf_flags & PFF_ENABLED) { | if (pf->pf_flags & PFF_ENABLED) { | ||||
printf("pccard_function_init: function is enabled"); | printf("pccard_function_init: function is enabled"); | ||||
return; | return; | ||||
} | } | ||||
/* | /* | ||||
Show All 15 Lines | |||||
continue; | continue; | ||||
spaces = 0; | spaces = 0; | ||||
for (i = 0; i < cfe->num_iospace; i++) { | for (i = 0; i < cfe->num_iospace; i++) { | ||||
ios = cfe->iospace + i; | ios = cfe->iospace + i; | ||||
start = ios->start; | start = ios->start; | ||||
if (start) | if (start) | ||||
end = start + ios->length - 1; | end = start + ios->length - 1; | ||||
else | else | ||||
end = ~0UL; | end = ~0; | ||||
DEVPRINTF((bus, "I/O rid %d start %#lx end %#lx\n", | DEVPRINTF((bus, "I/O rid %d start %#jx end %#jx\n", | ||||
i, start, end)); | i, start, end)); | ||||
rid = i; | rid = i; | ||||
len = ios->length; | len = ios->length; | ||||
r = bus_alloc_resource(bus, SYS_RES_IOPORT, &rid, | r = bus_alloc_resource(bus, SYS_RES_IOPORT, &rid, | ||||
start, end, len, rman_make_alignment_flags(len)); | start, end, len, rman_make_alignment_flags(len)); | ||||
if (r == NULL) { | if (r == NULL) { | ||||
DEVPRINTF((bus, "I/O rid %d failed\n", i)); | DEVPRINTF((bus, "I/O rid %d failed\n", i)); | ||||
goto not_this_one; | goto not_this_one; | ||||
} | } | ||||
rle = resource_list_add(rl, SYS_RES_IOPORT, | rle = resource_list_add(rl, SYS_RES_IOPORT, | ||||
rid, rman_get_start(r), rman_get_end(r), len); | rid, rman_get_start(r), rman_get_end(r), len); | ||||
if (rle == NULL) | if (rle == NULL) | ||||
panic("Cannot add resource rid %d IOPORT", rid); | panic("Cannot add resource rid %d IOPORT", rid); | ||||
rle->res = r; | rle->res = r; | ||||
spaces++; | spaces++; | ||||
} | } | ||||
for (i = 0; i < cfe->num_memspace; i++) { | for (i = 0; i < cfe->num_memspace; i++) { | ||||
mems = cfe->memspace + i; | mems = cfe->memspace + i; | ||||
start = mems->cardaddr + mems->hostaddr; | start = mems->cardaddr + mems->hostaddr; | ||||
if (start) | if (start) | ||||
end = start + mems->length - 1; | end = start + mems->length - 1; | ||||
else | else | ||||
end = ~0UL; | end = ~0; | ||||
DEVPRINTF((bus, "Memory rid %d start %#lx end %#lx\ncardaddr %#lx hostaddr %#lx length %#lx\n", | DEVPRINTF((bus, "Memory rid %d start %#jx end %#jx\ncardaddr %#jx hostaddr %#jx length %#jx\n", | ||||
i, start, end, mems->cardaddr, mems->hostaddr, | i, start, end, mems->cardaddr, mems->hostaddr, | ||||
jhb: Since you've changed the 'cardaddr', 'length', and 'hostaddr' fields in these structures… | |||||
mems->length)); | mems->length)); | ||||
rid = i; | rid = i; | ||||
len = mems->length; | len = mems->length; | ||||
r = bus_alloc_resource(bus, SYS_RES_MEMORY, &rid, | r = bus_alloc_resource(bus, SYS_RES_MEMORY, &rid, | ||||
start, end, len, rman_make_alignment_flags(len)); | start, end, len, rman_make_alignment_flags(len)); | ||||
if (r == NULL) { | if (r == NULL) { | ||||
DEVPRINTF((bus, "Memory rid %d failed\n", i)); | DEVPRINTF((bus, "Memory rid %d failed\n", i)); | ||||
// goto not_this_one; | // goto not_this_one; | ||||
▲ Show 20 Lines • Show All 53 Lines • ▼ Show 20 Lines | |||||
} | } | ||||
STAILQ_FOREACH(rle, &devi->resources, link) { | STAILQ_FOREACH(rle, &devi->resources, link) { | ||||
if (rle->res) { | if (rle->res) { | ||||
if (rman_get_device(rle->res) != pf->sc->dev) | if (rman_get_device(rle->res) != pf->sc->dev) | ||||
device_printf(pf->sc->dev, | device_printf(pf->sc->dev, | ||||
"function_free: Resource still owned by " | "function_free: Resource still owned by " | ||||
"child, oops. " | "child, oops. " | ||||
"(type=%d, rid=%d, addr=%#lx)\n", | "(type=%d, rid=%d, addr=%#jx)\n", | ||||
rle->type, rle->rid, | rle->type, rle->rid, | ||||
rman_get_start(rle->res)); | rman_get_start(rle->res)); | ||||
BUS_RELEASE_RESOURCE(device_get_parent(pf->sc->dev), | BUS_RELEASE_RESOURCE(device_get_parent(pf->sc->dev), | ||||
pf->sc->dev, rle->type, rle->rid, rle->res); | pf->sc->dev, rle->type, rle->rid, rle->res); | ||||
rle->res = NULL; | rle->res = NULL; | ||||
} | } | ||||
} | } | ||||
resource_list_free(&devi->resources); | resource_list_free(&devi->resources); | ||||
} | } | ||||
static void | static void | ||||
pccard_mfc_adjust_iobase(struct pccard_function *pf, bus_addr_t addr, | pccard_mfc_adjust_iobase(struct pccard_function *pf, rman_res_t addr, | ||||
bus_addr_t offset, bus_size_t size) | rman_res_t offset, rman_res_t size) | ||||
{ | { | ||||
bus_size_t iosize, tmp; | bus_size_t iosize, tmp; | ||||
if (addr != 0) { | if (addr != 0) { | ||||
if (pf->pf_mfc_iomax == 0) { | if (pf->pf_mfc_iomax == 0) { | ||||
pf->pf_mfc_iobase = addr + offset; | pf->pf_mfc_iobase = addr + offset; | ||||
pf->pf_mfc_iomax = pf->pf_mfc_iobase + size; | pf->pf_mfc_iomax = pf->pf_mfc_iobase + size; | ||||
} else { | } else { | ||||
▲ Show 20 Lines • Show All 65 Lines • ▼ Show 20 Lines | |||||
} | } | ||||
} | } | ||||
if (tmp == NULL) { | if (tmp == NULL) { | ||||
pf->ccr_rid = 0; | pf->ccr_rid = 0; | ||||
pf->ccr_res = bus_alloc_resource(dev, SYS_RES_MEMORY, | pf->ccr_res = bus_alloc_resource(dev, SYS_RES_MEMORY, | ||||
&pf->ccr_rid, 0, ~0, PCCARD_MEM_PAGE_SIZE, RF_ACTIVE); | &pf->ccr_rid, 0, ~0, PCCARD_MEM_PAGE_SIZE, RF_ACTIVE); | ||||
if (!pf->ccr_res) | if (!pf->ccr_res) | ||||
goto bad; | goto bad; | ||||
DEVPRINTF((dev, "ccr_res == %#lx-%#lx, base=%#x\n", | DEVPRINTF((dev, "ccr_res == %#jx-%#jx, base=%#x\n", | ||||
rman_get_start(pf->ccr_res), rman_get_end(pf->ccr_res), | rman_get_start(pf->ccr_res), rman_get_end(pf->ccr_res), | ||||
pf->ccr_base)); | pf->ccr_base)); | ||||
CARD_SET_RES_FLAGS(device_get_parent(dev), dev, SYS_RES_MEMORY, | CARD_SET_RES_FLAGS(device_get_parent(dev), dev, SYS_RES_MEMORY, | ||||
pf->ccr_rid, PCCARD_A_MEM_ATTR); | pf->ccr_rid, PCCARD_A_MEM_ATTR); | ||||
CARD_SET_MEMORY_OFFSET(device_get_parent(dev), dev, | CARD_SET_MEMORY_OFFSET(device_get_parent(dev), dev, | ||||
pf->ccr_rid, pf->ccr_base, &pf->pf_ccr_offset); | pf->ccr_rid, pf->ccr_base, &pf->pf_ccr_offset); | ||||
pf->pf_ccrt = rman_get_bustag(pf->ccr_res); | pf->pf_ccrt = rman_get_bustag(pf->ccr_res); | ||||
pf->pf_ccrh = rman_get_bushandle(pf->ccr_res); | pf->pf_ccrh = rman_get_bushandle(pf->ccr_res); | ||||
▲ Show 20 Lines • Show All 84 Lines • ▼ Show 20 Lines | |||||
retval += bus_print_child_footer(dev, child); | retval += bus_print_child_footer(dev, child); | ||||
return (retval); | return (retval); | ||||
} | } | ||||
static int | static int | ||||
pccard_set_resource(device_t dev, device_t child, int type, int rid, | pccard_set_resource(device_t dev, device_t child, int type, int rid, | ||||
u_long start, u_long count) | rman_res_t start, rman_res_t count) | ||||
{ | { | ||||
struct pccard_ivar *devi = PCCARD_IVAR(child); | struct pccard_ivar *devi = PCCARD_IVAR(child); | ||||
struct resource_list *rl = &devi->resources; | struct resource_list *rl = &devi->resources; | ||||
if (type != SYS_RES_IOPORT && type != SYS_RES_MEMORY | if (type != SYS_RES_IOPORT && type != SYS_RES_MEMORY | ||||
&& type != SYS_RES_IRQ && type != SYS_RES_DRQ) | && type != SYS_RES_IRQ && type != SYS_RES_DRQ) | ||||
return (EINVAL); | return (EINVAL); | ||||
if (rid < 0) | if (rid < 0) | ||||
Show All 12 Lines | |||||
type, &rid, start, start + count - 1, count, 0)) | type, &rid, start, start + count - 1, count, 0)) | ||||
return 0; | return 0; | ||||
else | else | ||||
return ENOMEM; | return ENOMEM; | ||||
} | } | ||||
static int | static int | ||||
pccard_get_resource(device_t dev, device_t child, int type, int rid, | pccard_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 pccard_ivar *devi = PCCARD_IVAR(child); | struct pccard_ivar *devi = PCCARD_IVAR(child); | ||||
struct resource_list *rl = &devi->resources; | struct resource_list *rl = &devi->resources; | ||||
struct resource_list_entry *rle; | struct resource_list_entry *rle; | ||||
rle = resource_list_find(rl, type, rid); | rle = resource_list_find(rl, type, rid); | ||||
if (rle == NULL) | if (rle == NULL) | ||||
return (ENOENT); | return (ENOENT); | ||||
▲ Show 20 Lines • Show All 84 Lines • ▼ Show 20 Lines | |||||
continue; | continue; | ||||
pccard_probe_and_attach_child(dev, child, pf); | pccard_probe_and_attach_child(dev, child, pf); | ||||
} | } | ||||
return; | return; | ||||
} | } | ||||
static struct resource * | static struct resource * | ||||
pccard_alloc_resource(device_t dev, device_t child, int type, int *rid, | pccard_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 pccard_ivar *dinfo; | struct pccard_ivar *dinfo; | ||||
struct resource_list_entry *rle = 0; | struct resource_list_entry *rle = 0; | ||||
int passthrough = (device_get_parent(child) != dev); | int passthrough = (device_get_parent(child) != dev); | ||||
int isdefault = (start == 0 && end == ~0UL && count == 1); | int isdefault = (start == 0 && end == ~0 && count == 1); | ||||
struct resource *r = NULL; | struct resource *r = NULL; | ||||
/* XXX I'm no longer sure this is right */ | /* XXX I'm no longer sure this is right */ | ||||
if (passthrough) { | if (passthrough) { | ||||
return (BUS_ALLOC_RESOURCE(device_get_parent(dev), child, | return (BUS_ALLOC_RESOURCE(device_get_parent(dev), child, | ||||
type, rid, start, end, count, flags)); | type, rid, start, end, count, flags)); | ||||
} | } | ||||
▲ Show 20 Lines • Show All 43 Lines • ▼ Show 20 Lines | |||||
type, rid, r); | type, rid, r); | ||||
dinfo = device_get_ivars(child); | dinfo = device_get_ivars(child); | ||||
rle = resource_list_find(&dinfo->resources, type, rid); | rle = resource_list_find(&dinfo->resources, type, rid); | ||||
if (!rle) { | if (!rle) { | ||||
device_printf(dev, "Allocated resource not found, " | device_printf(dev, "Allocated resource not found, " | ||||
"%d %#x %#lx %#lx\n", | "%d %#x %#jx %#jx\n", | ||||
type, rid, rman_get_start(r), rman_get_size(r)); | type, rid, rman_get_start(r), rman_get_size(r)); | ||||
return ENOENT; | return ENOENT; | ||||
} | } | ||||
if (!rle->res) { | if (!rle->res) { | ||||
device_printf(dev, "Allocated resource not recorded\n"); | device_printf(dev, "Allocated resource not recorded\n"); | ||||
return ENOENT; | return ENOENT; | ||||
} | } | ||||
/* | /* | ||||
▲ Show 20 Lines • Show All 42 Lines • Show Last 20 Lines |
Since you've changed the 'cardaddr', 'length', and 'hostaddr' fields in these structures (pccard_ce_iospace and pccard_ce_memspace) to rman_res_t, these casts seem redundant? Perhaps these were from an earlier version before the structures were changed?