From owner-freebsd-mobile Sun Aug 27 8:36:44 2000 Delivered-To: freebsd-mobile@freebsd.org Received: from lavender.sanpei.org (ppp152.dialup.st.keio.ac.jp [131.113.27.152]) by hub.freebsd.org (Postfix) with ESMTP id 4E27A37B423 for ; Sun, 27 Aug 2000 08:36:28 -0700 (PDT) Received: (from sanpei@localhost) by lavender.sanpei.org (8.11.0/3.7W) id e7RFaa207582; Mon, 28 Aug 2000 00:36:36 +0900 (JST) Message-Id: <200008271536.e7RFaa207582@lavender.sanpei.org> To: mobile@FreeBSD.org Subject: Re: [PCCARD,PATCH] IOC_GET_RESOURCE_RANGE patch In-Reply-To: Your message of "Sun, 20 Aug 2000 17:48:28 +0900" References: <20000820174828I.iwasaki@jp.FreeBSD.org> X-Mailer: Mew version 1.70 on Emacs 19.34.1 / Mule 2.3 Mime-Version: 1.0 Content-Type: Text/Plain; charset=us-ascii Content-Transfer-Encoding: 7bit Date: Mon, 28 Aug 2000 00:36:36 +0900 From: MIHIRA Sanpei Yoshiro Sender: owner-freebsd-mobile@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.org Thanks Warner-san and IWASAKI-san. Sorry, last patch was too experimental to commit into 5-current. I re-write PIOCSRESOURCE ioctl with below point. - use pcic_devclass, not use ``ed3'' (I tried pccarddev, but it does not have softc, so we never allocate resources with pccarddev....) - RF_ACTIVE --> 0 in bus_alloc_resource - do not use MALLOC By the way, I statically set rid=1 for dummy resources. Is that right? ---------- I already created usr.sbin/pccard/pccardd patch for PIOCSRESOURCE from PAO3 code. http://home.jp.FreeBSD.org/~sanpei/5-current/usr.sbin-pccard-pccardd-kernel-resource-2000820.diff But I think it needs to re-write. Because this pccardd patch does not consider other dynamic allocated devices (for example, OSS/FreeBSD sound driver). --- MIHIRA, Sanpei Yoshiro Yokohama, Japan. --- pccard.c.orig Mon Aug 21 01:16:56 2000 +++ pccard.c Sun Aug 27 23:40:49 2000 @@ -460,7 +460,12 @@ struct slot *slt = pccard_slots[minor(dev)]; struct mem_desc *mp; struct io_desc *ip; + struct pccard_resource *pr; + struct resource *r; + device_t pcicdev; int s, err; + int rid = 1; + int i; int pwval; if (slt == 0 && cmd != PIOCRWMEM) @@ -611,6 +616,45 @@ case PIOCSBEEP: if (pccard_beep_select(*(int *)data)) { return EINVAL; + } + break; + case PIOCSRESOURCE: + pr = (struct pccard_resource *)data; + pr->resource_addr = ~0ul; + /* pccard_devclass does not have softc + * so we use pcic_devclass + */ + pcicdev = devclass_get_device(pcic_devclass, 0); + switch(pr->type) { + default: + return EINVAL; + case SYS_RES_IOPORT: + case SYS_RES_MEMORY: + for (i = pr->min; i + pr->size <= pr->max; i++) { + err = bus_set_resource(pcicdev, pr->type, rid, i, pr->size); + if (!err) { + r = bus_alloc_resource(pcicdev, pr->type, &rid, 0ul, ~0ul, pr->size, 0); + if (r) { + pr->resource_addr = (u_long)rman_get_start(r); + bus_release_resource(pcicdev, pr->type, rid, r); + break; + } + } + } + break; + case SYS_RES_IRQ: + for (i = pr->min; i <= pr->max; i++) { + err = bus_set_resource(pcicdev, SYS_RES_IRQ, rid, i, 1); + if (!err) { + r = bus_alloc_resource(pcicdev, SYS_RES_IRQ, &rid, 0ul, ~0ul, 1, 0); + if (r) { + pr->resource_addr = (u_long)rman_get_start(r); + bus_release_resource(pcicdev, SYS_RES_IRQ, rid, r); + break; + } + } + } + break; } break; } --- cardinfo.h.orig Mon Aug 21 01:16:56 2000 +++ cardinfo.h Sun Aug 27 18:41:35 2000 @@ -49,6 +49,7 @@ #define PIOCSPOW _IOW('P', 9, struct power) /* Set power structure */ #define PIOCSVIR _IOW('P', 10, int) /* Virtual insert/remove */ #define PIOCSBEEP _IOW('P', 11, int) /* Select Beep */ +#define PIOCSRESOURCE _IOWR('P', 12, struct pccard_resource) /* get resource info */ /* * Debug codes. */ @@ -135,6 +136,18 @@ int vcc; int vpp; }; + +/* + * Th PC-Card resource IOC_GET_RESOURCE_RANGE + */ +struct pccard_resource { + int type; + u_long size; + u_long min; + u_long max; + u_long resource_addr; +}; + /* * Other system limits --- pcic.h.org Sun Aug 27 23:41:48 2000 +++ pcic.h Sun Aug 27 23:31:28 2000 @@ -41,3 +41,4 @@ #define PCIC_RF_MDF_WS1 (0x08 << 16) #define PCIC_RF_MDF_ATTR (0x10 << 16) #define PCIC_RF_MDF_WP (0x20 << 16) +extern devclass_t pcic_devclass; To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-mobile" in the body of the message