summaryrefslogtreecommitdiffstats
path: root/sys
diff options
context:
space:
mode:
authorimp <imp@FreeBSD.org>2000-04-20 08:37:46 +0000
committerimp <imp@FreeBSD.org>2000-04-20 08:37:46 +0000
commit13a243d8b505e941ea630f4b61891daf50fefeea (patch)
tree69957a17c1a42efacc3ed378c74214581f9debb1 /sys
parentfd604ada090518363ca1e7006a95289d56558f90 (diff)
downloadFreeBSD-src-13a243d8b505e941ea630f4b61891daf50fefeea.zip
FreeBSD-src-13a243d8b505e941ea630f4b61891daf50fefeea.tar.gz
o Preliminary support for mapping the CIS by the driver.
o Modify xe driver to use this. There's still some issues with this code, so xe can't map the cis just yet. I'm thinking about how to resolve the issue. pccard_nbk's pccard_alloc_resource is getting in the way.
Diffstat (limited to 'sys')
-rw-r--r--sys/dev/xe/if_xe.c10
-rw-r--r--sys/pccard/pccard_nbk.c35
-rw-r--r--sys/pccard/pcic.c51
3 files changed, 83 insertions, 13 deletions
diff --git a/sys/dev/xe/if_xe.c b/sys/dev/xe/if_xe.c
index 00d75c6..8ed6196 100644
--- a/sys/dev/xe/if_xe.c
+++ b/sys/dev/xe/if_xe.c
@@ -35,9 +35,6 @@
*
* xe_memwrite -- maybe better handled pccard layer?
* xe_cem56fix -- need to figure out how to map the extra stuff.
- * xe_activate -- need to write it, and add some stuff to it. Look at if_sn
- * for guidance. resources/interrupts.
- * xe_deactivate -- turn off resources/interrupts.
*/
/*
@@ -142,6 +139,9 @@
#include <net/if_mib.h>
#include <net/bpf.h>
+#include <dev/pccard/pccardvar.h>
+#include "card_if.h"
+
#include <dev/xe/if_xereg.h>
#include <dev/xe/if_xevar.h>
@@ -331,7 +331,6 @@ xe_probe(device_t dev)
#endif
/* Map in the CIS */
- /* XXX This CANNOT work as it needs RF_PCCARD_ATTR support */
r = bus_alloc_resource(dev, SYS_RES_MEMORY, &rid, 0, ~0, 4 << 10, RF_ACTIVE);
if (!r) {
#ifdef XE_DEBUG
@@ -341,6 +340,9 @@ xe_probe(device_t dev)
}
buf = (u_char *) rman_get_start(r);
+ CARD_SET_RES_FLAGS(device_get_parent(dev), dev, SYS_RES_MEMORY, rid,
+ PCCARD_A_MEM_ATTR);
+
/* Grep through CIS looking for relevant tuples */
offs = 0;
do {
diff --git a/sys/pccard/pccard_nbk.c b/sys/pccard/pccard_nbk.c
index 34be8b7..bcc2652 100644
--- a/sys/pccard/pccard_nbk.c
+++ b/sys/pccard/pccard_nbk.c
@@ -72,6 +72,8 @@
#include <dev/pccard/pccardvar.h>
#include <net/ethernet.h>
+#include "card_if.h"
+
devclass_t pccard_devclass;
#define PCCARD_NPORT 2
@@ -213,6 +215,8 @@ pccard_alloc_resource(device_t bus, device_t child, int type, int *rid,
struct resource_list_entry *rle;
struct resource *res;
+ /* XXX Do I need to add a special case here for the cis memory? XXX */
+
if (!passthrough && !isdefault) {
rle = resource_list_find(rl, type, *rid);
if (!rle) {
@@ -269,6 +273,32 @@ pccard_read_ivar(device_t bus, device_t child, int which, u_char *result)
return ENOENT;
}
+/* Pass card requests up to pcic. This may mean a bad design XXX */
+
+static int
+pccard_set_res_flags(device_t bus, device_t child, int restype, int rid,
+ u_long value)
+{
+ return CARD_SET_RES_FLAGS(device_get_parent(bus), child, restype,
+ rid, value);
+}
+
+static int
+pccard_get_res_flags(device_t bus, device_t child, int restype, int rid,
+ u_long *value)
+{
+ return CARD_GET_RES_FLAGS(device_get_parent(bus), child, restype,
+ rid, value);
+}
+
+static int
+pccard_set_memory_offset(device_t bus, device_t child, int rid,
+ u_int32_t offset)
+{
+ return CARD_SET_MEMORY_OFFSET(device_get_parent(bus), child, rid,
+ offset);
+}
+
static device_method_t pccard_methods[] = {
/* Device interface */
DEVMETHOD(device_probe, pccard_probe),
@@ -291,6 +321,11 @@ static device_method_t pccard_methods[] = {
DEVMETHOD(bus_delete_resource, pccard_delete_resource),
DEVMETHOD(bus_read_ivar, pccard_read_ivar),
+ /* Card interface */
+ DEVMETHOD(card_set_res_flags, pccard_set_res_flags),
+ DEVMETHOD(card_get_res_flags, pccard_get_res_flags),
+ DEVMETHOD(card_set_memory_offset, pccard_set_memory_offset),
+
{ 0, 0 }
};
diff --git a/sys/pccard/pcic.c b/sys/pccard/pcic.c
index dbb55ea..6e76a4d 100644
--- a/sys/pccard/pcic.c
+++ b/sys/pccard/pcic.c
@@ -48,6 +48,8 @@
#include <isa/isavar.h>
#include <dev/pcic/i82365reg.h>
+#include "card_if.h"
+
/*
* Prototypes for interrupt handler.
*/
@@ -806,8 +808,7 @@ pcic_activate_resource(device_t dev, device_t child, int type, int rid,
int err;
switch (type) {
- case SYS_RES_IOPORT:
- {
+ case SYS_RES_IOPORT: {
struct io_desc *ip;
ip = &devi->slt->io[rid];
if (ip->flags == 0) {
@@ -831,8 +832,7 @@ pcic_activate_resource(device_t dev, device_t child, int type, int rid,
* interrupt messages.
*/
break;
- case SYS_RES_MEMORY:
- {
+ case SYS_RES_MEMORY: {
struct mem_desc *mp;
if (rid >= NUM_MEM_WINDOWS)
return EINVAL;
@@ -860,8 +860,7 @@ pcic_deactivate_resource(device_t dev, device_t child, int type, int rid,
int err;
switch (type) {
- case SYS_RES_IOPORT:
- {
+ case SYS_RES_IOPORT: {
struct io_desc *ip = &devi->slt->io[rid];
ip->flags &= ~IODF_ACTIVE;
err = pcic_io(devi->slt, rid);
@@ -872,8 +871,7 @@ pcic_deactivate_resource(device_t dev, device_t child, int type, int rid,
}
case SYS_RES_IRQ:
break;
- case SYS_RES_MEMORY:
- {
+ case SYS_RES_MEMORY: {
struct mem_desc *mp = &devi->slt->mem[rid];
mp->flags &= ~(MDF_ACTIVE | MDF_ATTR);
err = pcic_memory(devi->slt, rid);
@@ -916,6 +914,41 @@ pcic_teardown_intr(device_t dev, device_t child, struct resource *irq,
return (bus_generic_teardown_intr(dev, child, irq, cookie));
}
+static int
+pcic_set_res_flags(device_t bus, device_t child, int restype, int rid,
+ u_long value)
+{
+ struct pccard_devinfo *devi = device_get_ivars(child);
+ int err = 0;
+
+ switch (restype) {
+ case SYS_RES_MEMORY: {
+ struct mem_desc *mp = &devi->slt->mem[rid];
+ if (value)
+ mp->flags |= MDF_ATTR;
+ else
+ mp->flags &= ~MDF_ATTR;
+ err = pcic_memory(devi->slt, rid);
+ break;
+ }
+ default:
+ err = EOPNOTSUPP;
+ }
+ return (err);
+}
+
+static struct resource *
+pcic_alloc_resource(device_t bus, device_t child, int type, int *rid,
+ u_long start, u_long end, u_long count, u_int flags)
+{
+ if (start == 0 && end == ~0 && type == SYS_RES_MEMORY && count != 1) {
+ start = 0xd0000;
+ end = 0xdffff;
+ }
+ return bus_generic_alloc_resource(bus, child, type, rid, start, end,
+ count, flags);
+}
+
static device_method_t pcic_methods[] = {
/* Device interface */
DEVMETHOD(device_probe, pcic_probe),
@@ -927,7 +960,7 @@ static device_method_t pcic_methods[] = {
/* Bus interface */
DEVMETHOD(bus_print_child, bus_generic_print_child),
- DEVMETHOD(bus_alloc_resource, bus_generic_alloc_resource),
+ DEVMETHOD(bus_alloc_resource, pcic_alloc_resource),
DEVMETHOD(bus_release_resource, bus_generic_release_resource),
DEVMETHOD(bus_activate_resource, pcic_activate_resource),
DEVMETHOD(bus_deactivate_resource, pcic_deactivate_resource),
OpenPOWER on IntegriCloud