Deleted Added
full compact
ncr53c500_pccard.c (71467) ncr53c500_pccard.c (73087)
1/* $FreeBSD: head/sys/dev/ncv/ncr53c500_pccard.c 71467 2001-01-23 22:06:10Z jhb $ */
1/* $FreeBSD: head/sys/dev/ncv/ncr53c500_pccard.c 73087 2001-02-26 12:26:29Z non $ */
2/* $NecBSD: ncr53c500_pisa.c,v 1.28 1998/11/26 01:59:11 honda Exp $ */
3/* $NetBSD$ */
4
5/*
6 * [Ported for FreeBSD]
7 * Copyright (c) 2000
8 * Noriaki Mitsunaga, Mitsuru Iwasaki and Takanori Watanabe.
9 * All rights reserved.

--- 107 unchanged lines hidden (view full) ---

117 bus_teardown_intr(dev, sc->irq_res, sc->ncv_intrhand);
118 }
119
120 if (sc->port_res) {
121 bus_release_resource(dev, SYS_RES_IOPORT,
122 sc->port_rid, sc->port_res);
123 }
124
2/* $NecBSD: ncr53c500_pisa.c,v 1.28 1998/11/26 01:59:11 honda Exp $ */
3/* $NetBSD$ */
4
5/*
6 * [Ported for FreeBSD]
7 * Copyright (c) 2000
8 * Noriaki Mitsunaga, Mitsuru Iwasaki and Takanori Watanabe.
9 * All rights reserved.

--- 107 unchanged lines hidden (view full) ---

117 bus_teardown_intr(dev, sc->irq_res, sc->ncv_intrhand);
118 }
119
120 if (sc->port_res) {
121 bus_release_resource(dev, SYS_RES_IOPORT,
122 sc->port_rid, sc->port_res);
123 }
124
125 if (sc->port_res_dmy) {
126 bus_release_resource(dev, SYS_RES_IOPORT,
127 sc->port_rid_dmy, sc->port_res_dmy);
128 }
129
125 if (sc->irq_res) {
126 bus_release_resource(dev, SYS_RES_IRQ,
127 sc->irq_rid, sc->irq_res);
128 }
129
130 if (sc->mem_res) {
131 bus_release_resource(dev, SYS_RES_MEMORY,
132 sc->mem_rid, sc->mem_res);
133 }
134}
135
136static int
137ncv_alloc_resource(DEVPORT_PDEVICE dev)
138{
139 struct ncv_softc *sc = device_get_softc(dev);
140 u_int32_t flags = DEVPORT_PDEVFLAGS(dev);
130 if (sc->irq_res) {
131 bus_release_resource(dev, SYS_RES_IRQ,
132 sc->irq_rid, sc->irq_res);
133 }
134
135 if (sc->mem_res) {
136 bus_release_resource(dev, SYS_RES_MEMORY,
137 sc->mem_rid, sc->mem_res);
138 }
139}
140
141static int
142ncv_alloc_resource(DEVPORT_PDEVICE dev)
143{
144 struct ncv_softc *sc = device_get_softc(dev);
145 u_int32_t flags = DEVPORT_PDEVFLAGS(dev);
141 u_int iobase = DEVPORT_PDEVIOBASE(dev);
142 u_long maddr, msize;
146 u_long ioaddr, iosize, maddr, msize;
143 int error;
144 bus_addr_t offset = 0;
145
146 if(flags & KME_KXLC004_01)
147 offset = OFFSET_KME_KXLC004_01;
148
147 int error;
148 bus_addr_t offset = 0;
149
150 if(flags & KME_KXLC004_01)
151 offset = OFFSET_KME_KXLC004_01;
152
153 error = bus_get_resource(dev, SYS_RES_IOPORT, 0, &ioaddr, &iosize);
154 if (error || (iosize < (offset + NCVIOSZ))) {
155 return(ENOMEM);
156 }
157
149 sc->port_rid = 0;
150 sc->port_res = bus_alloc_resource(dev, SYS_RES_IOPORT, &sc->port_rid,
158 sc->port_rid = 0;
159 sc->port_res = bus_alloc_resource(dev, SYS_RES_IOPORT, &sc->port_rid,
151 iobase+offset, ~0, NCVIOSZ, RF_ACTIVE);
160 ioaddr+offset, ioaddr+iosize-offset,
161 iosize-offset, RF_ACTIVE);
152 if (sc->port_res == NULL) {
153 ncv_release_resource(dev);
154 return(ENOMEM);
155 }
156
162 if (sc->port_res == NULL) {
163 ncv_release_resource(dev);
164 return(ENOMEM);
165 }
166
167 if (offset != 0) {
168 sc->port_rid_dmy = 0;
169 sc->port_res_dmy = bus_alloc_resource(dev, SYS_RES_IOPORT,
170 &sc->port_rid_dmy,
171 ioaddr, ioaddr+offset, offset,
172 RF_ACTIVE);
173 if (sc->port_res_dmy == NULL) {
174 printf("Warning: cannot allocate IOPORT partially.\n");
175 }
176 } else {
177 sc->port_rid_dmy = 0;
178 sc->port_res_dmy = NULL;
179 }
180
157 sc->irq_rid = 0;
158 sc->irq_res = bus_alloc_resource(dev, SYS_RES_IRQ, &sc->irq_rid,
159 0, ~0, 1, RF_ACTIVE);
160 if (sc->irq_res == NULL) {
161 ncv_release_resource(dev);
162 return(ENOMEM);
163 }
164

--- 247 unchanged lines hidden ---
181 sc->irq_rid = 0;
182 sc->irq_res = bus_alloc_resource(dev, SYS_RES_IRQ, &sc->irq_rid,
183 0, ~0, 1, RF_ACTIVE);
184 if (sc->irq_res == NULL) {
185 ncv_release_resource(dev);
186 return(ENOMEM);
187 }
188

--- 247 unchanged lines hidden ---