Deleted Added
full compact
ofw_bus_subr.c (276726) ofw_bus_subr.c (277098)
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 276726 2015-01-05 21:39:35Z nwhitehorn $");
31__FBSDID("$FreeBSD: head/sys/dev/ofw/ofw_bus_subr.c 277098 2015-01-13 00:00:09Z zbb $");
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

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

365 }
366 mptr += tsz;
367 i -= tsz;
368 }
369 return (0);
370}
371
372int
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

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

365 }
366 mptr += tsz;
367 i -= tsz;
368 }
369 return (0);
370}
371
372int
373ofw_bus_reg_to_rl(device_t dev, phandle_t node, pcell_t acells, pcell_t scells,
374 struct resource_list *rl)
375{
376 uint64_t phys, size;
377 ssize_t i, j, rid, nreg, ret;
378 uint32_t *reg;
379 char *name;
380
381 /*
382 * This may be just redundant when having ofw_bus_devinfo
383 * but makes this routine independent of it.
384 */
385 ret = OF_getencprop_alloc(node, "name", sizeof(*name), (void **)&name);
386 if (ret == -1)
387 name = NULL;
388
389 ret = OF_getencprop_alloc(node, "reg", sizeof(*reg), (void **)&reg);
390 nreg = (ret == -1) ? 0 : ret;
391
392 if (nreg % (acells + scells) != 0) {
393 if (bootverbose)
394 device_printf(dev, "Malformed reg property on <%s>\n",
395 (name == NULL) ? "unknown" : name);
396 nreg = 0;
397 }
398
399 for (i = 0, rid = 0; i < nreg; i += acells + scells, rid++) {
400 phys = size = 0;
401 for (j = 0; j < acells; j++) {
402 phys <<= 32;
403 phys |= reg[i + j];
404 }
405 for (j = 0; j < scells; j++) {
406 size <<= 32;
407 size |= reg[i + acells + j];
408 }
409 /* Skip the dummy reg property of glue devices like ssm(4). */
410 if (size != 0)
411 resource_list_add(rl, SYS_RES_MEMORY, rid,
412 phys, phys + size - 1, size);
413 }
414 free(name, M_OFWPROP);
415 free(reg, M_OFWPROP);
416
417 return (0);
418}
419
420int
373ofw_bus_intr_to_rl(device_t dev, phandle_t node, struct resource_list *rl)
374{
375 phandle_t iparent;
376 uint32_t icells, *intr;
377 int err, i, irqnum, nintr, rid;
378 boolean_t extended;
379
380 nintr = OF_getencprop_alloc(node, "interrupts", sizeof(*intr),

--- 61 unchanged lines hidden ---
421ofw_bus_intr_to_rl(device_t dev, phandle_t node, struct resource_list *rl)
422{
423 phandle_t iparent;
424 uint32_t icells, *intr;
425 int err, i, irqnum, nintr, rid;
426 boolean_t extended;
427
428 nintr = OF_getencprop_alloc(node, "interrupts", sizeof(*intr),

--- 61 unchanged lines hidden ---