Deleted Added
full compact
ofw_bus_subr.c (208614) ofw_bus_subr.c (209298)
1/*-
2 * Copyright (c) 2001 - 2003 by Thomas Moestl <tmm@FreeBSD.org>.
3 * Copyright (c) 2005 Marius Strobl <marius@FreeBSD.org>
4 * All rights reserved.
5 *
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
8 * are met:

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

23 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
24 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
25 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
26 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
27 * SUCH DAMAGE.
28 */
29
30#include <sys/cdefs.h>
1/*-
2 * Copyright (c) 2001 - 2003 by Thomas Moestl <tmm@FreeBSD.org>.
3 * Copyright (c) 2005 Marius Strobl <marius@FreeBSD.org>
4 * All rights reserved.
5 *
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
8 * are met:

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

23 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
24 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
25 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
26 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
27 * SUCH DAMAGE.
28 */
29
30#include <sys/cdefs.h>
31__FBSDID("$FreeBSD: head/sys/dev/ofw/ofw_bus_subr.c 208614 2010-05-28 10:43:56Z raj $");
31__FBSDID("$FreeBSD: head/sys/dev/ofw/ofw_bus_subr.c 209298 2010-06-18 14:06:27Z nwhitehorn $");
32
33#include "opt_platform.h"
34#include <sys/param.h>
35#include <sys/systm.h>
36#include <sys/bus.h>
37#include <sys/errno.h>
38#include <sys/libkern.h>
39

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

217 panic("ofw_bus_setup_iinfo: bad interrupt-map-mask "
218 "property!");
219 }
220}
221
222int
223ofw_bus_lookup_imap(phandle_t node, struct ofw_bus_iinfo *ii, void *reg,
224 int regsz, void *pintr, int pintrsz, void *mintr, int mintrsz,
32
33#include "opt_platform.h"
34#include <sys/param.h>
35#include <sys/systm.h>
36#include <sys/bus.h>
37#include <sys/errno.h>
38#include <sys/libkern.h>
39

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

217 panic("ofw_bus_setup_iinfo: bad interrupt-map-mask "
218 "property!");
219 }
220}
221
222int
223ofw_bus_lookup_imap(phandle_t node, struct ofw_bus_iinfo *ii, void *reg,
224 int regsz, void *pintr, int pintrsz, void *mintr, int mintrsz,
225 void *maskbuf)
225 phandle_t *iparent, void *maskbuf)
226{
227 int rv;
228
229 if (ii->opi_imapsz <= 0)
230 return (0);
231 KASSERT(regsz >= ii->opi_addrc,
232 ("ofw_bus_lookup_imap: register size too small: %d < %d",
233 regsz, ii->opi_addrc));
234 rv = OF_getprop(node, "reg", reg, regsz);
235 if (rv < regsz)
236 panic("ofw_bus_lookup_imap: could not get reg property");
237 return (ofw_bus_search_intrmap(pintr, pintrsz, reg, ii->opi_addrc,
238 ii->opi_imap, ii->opi_imapsz, ii->opi_imapmsk, maskbuf, mintr,
226{
227 int rv;
228
229 if (ii->opi_imapsz <= 0)
230 return (0);
231 KASSERT(regsz >= ii->opi_addrc,
232 ("ofw_bus_lookup_imap: register size too small: %d < %d",
233 regsz, ii->opi_addrc));
234 rv = OF_getprop(node, "reg", reg, regsz);
235 if (rv < regsz)
236 panic("ofw_bus_lookup_imap: could not get reg property");
237 return (ofw_bus_search_intrmap(pintr, pintrsz, reg, ii->opi_addrc,
238 ii->opi_imap, ii->opi_imapsz, ii->opi_imapmsk, maskbuf, mintr,
239 mintrsz));
239 mintrsz, iparent));
240}
241
242/*
243 * Map an interrupt using the firmware reg, interrupt-map and
244 * interrupt-map-mask properties.
245 * The interrupt property to be mapped must be of size intrsz, and pointed to
246 * by intr. The regs property of the node for which the mapping is done must
247 * be passed as regs. This property is an array of register specifications;

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

254 * maskbuf must point to a buffer of length physsz + intrsz.
255 * The interrupt is returned in result, which must point to a buffer of length
256 * rintrsz (which gives the expected size of the mapped interrupt).
257 * Returns 1 if a mapping was found, 0 otherwise.
258 */
259int
260ofw_bus_search_intrmap(void *intr, int intrsz, void *regs, int physsz,
261 void *imap, int imapsz, void *imapmsk, void *maskbuf, void *result,
240}
241
242/*
243 * Map an interrupt using the firmware reg, interrupt-map and
244 * interrupt-map-mask properties.
245 * The interrupt property to be mapped must be of size intrsz, and pointed to
246 * by intr. The regs property of the node for which the mapping is done must
247 * be passed as regs. This property is an array of register specifications;

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

254 * maskbuf must point to a buffer of length physsz + intrsz.
255 * The interrupt is returned in result, which must point to a buffer of length
256 * rintrsz (which gives the expected size of the mapped interrupt).
257 * Returns 1 if a mapping was found, 0 otherwise.
258 */
259int
260ofw_bus_search_intrmap(void *intr, int intrsz, void *regs, int physsz,
261 void *imap, int imapsz, void *imapmsk, void *maskbuf, void *result,
262 int rintrsz)
262 int rintrsz, phandle_t *iparent)
263{
264 phandle_t parent;
265 uint8_t *ref = maskbuf;
266 uint8_t *uiintr = intr;
267 uint8_t *uiregs = regs;
268 uint8_t *uiimapmsk = imapmsk;
269 uint8_t *mptr;
270 pcell_t pintrsz;

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

298 * XXX: Apple hardware uses a second cell to set information
299 * on the interrupt trigger type. This information should
300 * be used somewhere to program the PIC.
301 */
302
303 if (bcmp(ref, mptr, physsz + intrsz) == 0) {
304 bcopy(mptr + physsz + intrsz + sizeof(parent),
305 result, rintrsz);
263{
264 phandle_t parent;
265 uint8_t *ref = maskbuf;
266 uint8_t *uiintr = intr;
267 uint8_t *uiregs = regs;
268 uint8_t *uiimapmsk = imapmsk;
269 uint8_t *mptr;
270 pcell_t pintrsz;

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

298 * XXX: Apple hardware uses a second cell to set information
299 * on the interrupt trigger type. This information should
300 * be used somewhere to program the PIC.
301 */
302
303 if (bcmp(ref, mptr, physsz + intrsz) == 0) {
304 bcopy(mptr + physsz + intrsz + sizeof(parent),
305 result, rintrsz);
306
307 if (iparent != NULL)
308 *iparent = parent;
306 return (1);
307 }
308 mptr += tsz;
309 i -= tsz;
310 }
311 return (0);
312}
313#endif /* !FDT */
309 return (1);
310 }
311 mptr += tsz;
312 i -= tsz;
313 }
314 return (0);
315}
316#endif /* !FDT */