used in the fdt attach args and the device tree.
ok kettenis@
-/* $OpenBSD: armv7_machdep.c,v 1.32 2016/07/26 18:09:07 kettenis Exp $ */
+/* $OpenBSD: armv7_machdep.c,v 1.33 2016/07/26 22:10:10 patrick Exp $ */
/* $NetBSD: lubbock_machdep.c,v 1.2 2003/07/15 00:25:06 lukem Exp $ */
/*
}
if (fdt_init(config) && fdt_get_size(config) != 0) {
- struct fdt_memory mem;
+ struct fdt_reg reg;
void *node;
node = fdt_find_node("/memory");
- if (node == NULL || fdt_get_memory_address(node, 0, &mem))
+ if (node == NULL || fdt_get_reg(node, 0, ®))
panic("initarm: no memory specificed");
- memstart = mem.addr;
- memsize = mem.size;
- physical_start = mem.addr;
- physical_end = MIN(mem.addr + mem.size, (paddr_t)-PAGE_SIZE);
+ memstart = reg.addr;
+ memsize = reg.size;
+ physical_start = reg.addr;
+ physical_end = MIN(reg.addr + reg.size, (paddr_t)-PAGE_SIZE);
node = fdt_find_node("/chosen");
if (node != NULL) {
-/* $OpenBSD: exclock.c,v 1.3 2016/04/24 00:57:23 patrick Exp $ */
+/* $OpenBSD: exclock.c,v 1.4 2016/07/26 22:10:10 patrick Exp $ */
/*
* Copyright (c) 2012-2013 Patrick Wildt <patrick@blueri.se>
*
sc->sc_iot = aa->aa_iot;
#if NFDT > 0
if (aa->aa_node) {
- struct fdt_memory fdtmem;
- if (fdt_get_memory_address(aa->aa_node, 0, &fdtmem))
+ struct fdt_reg reg;
+ if (fdt_get_reg(aa->aa_node, 0, ®))
panic("%s: could not extract memory data from FDT",
__func__);
- mem.addr = fdtmem.addr;
- mem.size = fdtmem.size;
+ mem.addr = reg.addr;
+ mem.size = reg.size;
} else
#endif
{
-/* $OpenBSD: exdisplay.c,v 1.3 2016/04/24 00:57:23 patrick Exp $ */
+/* $OpenBSD: exdisplay.c,v 1.4 2016/07/26 22:10:10 patrick Exp $ */
/*
* Copyright (c) 2013 Patrick Wildt <patrick@blueri.se>
*
sc->sc_iot = aa->aa_iot;
#if NFDT > 0
if (aa->aa_node) {
- struct fdt_memory fdtmem;
- if (fdt_get_memory_address(aa->aa_node, 0, &fdtmem))
+ struct fdt_reg reg;
+ if (fdt_get_reg(aa->aa_node, 0, ®))
panic("%s: could not extract memory data from FDT",
__func__);
- mem.addr = fdtmem.addr;
- mem.size = fdtmem.size;
+ mem.addr = reg.addr;
+ mem.size = reg.size;
} else
#endif
{
-/* $OpenBSD: exdog.c,v 1.3 2016/04/24 00:57:23 patrick Exp $ */
+/* $OpenBSD: exdog.c,v 1.4 2016/07/26 22:10:10 patrick Exp $ */
/*
* Copyright (c) 2012-2013 Patrick Wildt <patrick@blueri.se>
*
sc->sc_iot = aa->aa_iot;
#if NFDT > 0
if (aa->aa_node) {
- struct fdt_memory fdtmem;
- if (fdt_get_memory_address(aa->aa_node, 0, &fdtmem))
+ struct fdt_reg reg;
+ if (fdt_get_reg(aa->aa_node, 0, ®))
panic("%s: could not extract memory data from FDT",
__func__);
- mem.addr = fdtmem.addr;
- mem.size = fdtmem.size;
+ mem.addr = reg.addr;
+ mem.size = reg.size;
} else
#endif
{
-/* $OpenBSD: exehci.c,v 1.3 2016/04/24 00:57:23 patrick Exp $ */
+/* $OpenBSD: exehci.c,v 1.4 2016/07/26 22:10:10 patrick Exp $ */
/*
* Copyright (c) 2012-2013 Patrick Wildt <patrick@blueri.se>
*
#if NFDT > 0
if (aa->aa_node) {
- struct fdt_memory fhmem, fpmem;
+ struct fdt_reg hreg, preg;
uint32_t ints[3];
- if (fdt_get_memory_address(aa->aa_node, 0, &fhmem))
+ if (fdt_get_reg(aa->aa_node, 0, &hreg))
panic("%s: could not extract memory data from FDT",
__func__);
/* XXX: In a different way, please. */
void *node = fdt_find_compatible("samsung,exynos5250-usb2-phy");
- if (node == NULL || fdt_get_memory_address(node, 0, &fpmem))
+ if (node == NULL || fdt_get_reg(node, 0, &preg))
panic("%s: could not extract phy data from FDT",
__func__);
panic("%s: could not extract interrupt data from FDT",
__func__);
- hmem.addr = fhmem.addr;
- hmem.size = fhmem.size;
- pmem.addr = fpmem.addr;
- pmem.size = fpmem.size;
+ hmem.addr = hreg.addr;
+ hmem.size = hreg.size;
+ pmem.addr = preg.addr;
+ pmem.size = preg.size;
irq = ints[1];
} else
-/* $OpenBSD: exesdhc.c,v 1.7 2016/05/05 11:01:08 kettenis Exp $ */
+/* $OpenBSD: exesdhc.c,v 1.8 2016/07/26 22:10:10 patrick Exp $ */
/*
* Copyright (c) 2009 Dale Rahn <drahn@openbsd.org>
* Copyright (c) 2006 Uwe Stuehler <uwe@openbsd.org>
sc->sc_iot = aa->aa_iot;
#if NFDT > 0
if (aa->aa_node) {
- struct fdt_memory fdtmem;
+ struct fdt_reg reg;
static int unit = 0;
uint32_t ints[3];
sc->unit = unit++;
- if (fdt_get_memory_address(aa->aa_node, 0, &fdtmem))
+ if (fdt_get_reg(aa->aa_node, 0, ®))
panic("%s: could not extract memory data from FDT",
__func__);
panic("%s: could not extract interrupt data from FDT",
__func__);
- mem.addr = fdtmem.addr;
- mem.size = fdtmem.size;
+ mem.addr = reg.addr;
+ mem.size = reg.size;
irq = ints[1];
} else
-/* $OpenBSD: exgpio.c,v 1.3 2016/04/24 00:57:23 patrick Exp $ */
+/* $OpenBSD: exgpio.c,v 1.4 2016/07/26 22:10:10 patrick Exp $ */
/*
* Copyright (c) 2007,2009 Dale Rahn <drahn@openbsd.org>
* Copyright (c) 2012-2013 Patrick Wildt <patrick@blueri.se>
sc->sc_iot = aa->aa_iot;
#if NFDT > 0
if (aa->aa_node) {
- struct fdt_memory fdtmem;
- if (fdt_get_memory_address(aa->aa_node, 0, &fdtmem))
+ struct fdt_reg reg;
+ if (fdt_get_reg(aa->aa_node, 0, ®))
panic("%s: could not extract memory data from FDT",
__func__);
- mem.addr = fdtmem.addr;
- mem.size = fdtmem.size;
+ mem.addr = reg.addr;
+ mem.size = reg.size;
} else
#endif
{
sc->sc_iot = aa->aa_iot;
#if NFDT > 0
if (aa->aa_node) {
- struct fdt_memory fdtmem;
+ struct fdt_reg reg;
static int unit = 0;
sc->unit = unit++;
- if (fdt_get_memory_address(aa->aa_node, 0, &fdtmem))
+ if (fdt_get_reg(aa->aa_node, 0, ®))
panic("%s: could not extract memory data from FDT",
__func__);
- mem.addr = fdtmem.addr;
- mem.size = fdtmem.size;
+ mem.addr = reg.addr;
+ mem.size = reg.size;
} else
#endif
{
-/* $OpenBSD: exmct.c,v 1.3 2016/04/24 00:57:23 patrick Exp $ */
+/* $OpenBSD: exmct.c,v 1.4 2016/07/26 22:10:10 patrick Exp $ */
/*
* Copyright (c) 2012-2013 Patrick Wildt <patrick@blueri.se>
*
sc->sc_iot = aa->aa_iot;
#if NFDT > 0
if (aa->aa_node) {
- struct fdt_memory fdtmem;
- if (fdt_get_memory_address(aa->aa_node, 0, &fdtmem))
+ struct fdt_reg reg;
+ if (fdt_get_reg(aa->aa_node, 0, ®))
panic("%s: could not extract memory data from FDT",
__func__);
- mem.addr = fdtmem.addr;
- mem.size = fdtmem.size;
+ mem.addr = reg.addr;
+ mem.size = reg.size;
} else
#endif
{
-/* $OpenBSD: expower.c,v 1.3 2016/04/24 00:57:23 patrick Exp $ */
+/* $OpenBSD: expower.c,v 1.4 2016/07/26 22:10:10 patrick Exp $ */
/*
* Copyright (c) 2012-2013 Patrick Wildt <patrick@blueri.se>
*
sc->sc_iot = aa->aa_iot;
#if NFDT > 0
if (aa->aa_node) {
- struct fdt_memory fdtmem;
- if (fdt_get_memory_address(aa->aa_node, 0, &fdtmem))
+ struct fdt_reg reg;
+ if (fdt_get_reg(aa->aa_node, 0, ®))
panic("%s: could not extract memory data from FDT",
__func__);
- mem.addr = fdtmem.addr;
- mem.size = fdtmem.size;
+ mem.addr = reg.addr;
+ mem.size = reg.size;
} else
#endif
{
-/* $OpenBSD: exsysreg.c,v 1.3 2016/04/24 00:57:23 patrick Exp $ */
+/* $OpenBSD: exsysreg.c,v 1.4 2016/07/26 22:10:10 patrick Exp $ */
/*
* Copyright (c) 2012-2013 Patrick Wildt <patrick@blueri.se>
*
sc->sc_iot = aa->aa_iot;
#if NFDT > 0
if (aa->aa_node) {
- struct fdt_memory fdtmem;
- if (fdt_get_memory_address(aa->aa_node, 0, &fdtmem))
+ struct fdt_reg reg;
+ if (fdt_get_reg(aa->aa_node, 0, ®))
panic("%s: could not extract memory data from FDT",
__func__);
- mem.addr = fdtmem.addr;
- mem.size = fdtmem.size;
+ mem.addr = reg.addr;
+ mem.size = reg.size;
} else
#endif
{
-/* $OpenBSD: exuart.c,v 1.5 2016/06/11 08:08:16 jsg Exp $ */
+/* $OpenBSD: exuart.c,v 1.6 2016/07/26 22:10:10 patrick Exp $ */
/*
* Copyright (c) 2005 Dale Rahn <drahn@motorola.com>
*
void
exuart_init_cons(void)
{
- struct fdt_memory mem;
+ struct fdt_reg reg;
void *node;
if ((node = fdt_find_cons("samsung,exynos4210-uart")) == NULL)
return;
- if (fdt_get_memory_address(node, 0, &mem))
+ if (fdt_get_reg(node, 0, ®))
return;
/* dtb uses serial2, qemu uses serial0 */
if (board_id == BOARD_ID_EXYNOS4_SMDKC210)
- mem.addr = 0x13800000;
+ reg.addr = 0x13800000;
- exuartcnattach(&armv7_bs_tag, mem.addr, comcnspeed, comcnmode);
+ exuartcnattach(&armv7_bs_tag, reg.addr, comcnspeed, comcnmode);
}
int
sc->sc_iot = aa->aa_iot;
#if NFDT > 0
if (aa->aa_node) {
- struct fdt_memory fdtmem;
+ struct fdt_reg reg;
uint32_t ints[3];
- if (fdt_get_memory_address(aa->aa_node, 0, &fdtmem))
+ if (fdt_get_reg(aa->aa_node, 0, ®))
panic("%s: could not extract memory data from FDT",
__func__);
panic("%s: could not extract interrupt data from FDT",
__func__);
- mem.addr = fdtmem.addr;
- mem.size = fdtmem.size;
+ mem.addr = reg.addr;
+ mem.size = reg.size;
irq = ints[1];
} else
-/* $OpenBSD: imxuart.c,v 1.8 2016/07/23 15:02:08 patrick Exp $ */
+/* $OpenBSD: imxuart.c,v 1.9 2016/07/26 22:10:10 patrick Exp $ */
/*
* Copyright (c) 2005 Dale Rahn <drahn@motorola.com>
*
void
imxuart_init_cons(void)
{
- struct fdt_memory mem;
+ struct fdt_reg reg;
void *node;
if ((node = fdt_find_cons("fsl,imx21-uart")) == NULL)
return;
- if (fdt_get_memory_address(node, 0, &mem))
+ if (fdt_get_reg(node, 0, ®))
return;
- imxuartcnattach(&armv7_bs_tag, mem.addr, comcnspeed, comcnmode);
+ imxuartcnattach(&armv7_bs_tag, reg.addr, comcnspeed, comcnmode);
}
int
-/* $OpenBSD: omap_com.c,v 1.6 2016/07/17 02:45:05 jsg Exp $ */
+/* $OpenBSD: omap_com.c,v 1.7 2016/07/26 22:10:10 patrick Exp $ */
/*
* Copyright 2003 Wasabi Systems, Inc.
* All rights reserved.
void
omapuart_init_cons(void)
{
- struct fdt_memory mem;
+ struct fdt_reg reg;
void *node;
if ((node = fdt_find_cons("ti,omap3-uart")) == NULL)
if ((node = fdt_find_cons("ti,omap4-uart")) == NULL)
return;
- if (fdt_get_memory_address(node, 0, &mem))
+ if (fdt_get_reg(node, 0, ®))
return;
- comcnattach(&armv7_a4x_bs_tag, mem.addr, comcnspeed, 48000000,
+ comcnattach(&armv7_a4x_bs_tag, reg.addr, comcnspeed, 48000000,
comcnmode);
comdefaultrate = comcnspeed;
}
-/* $OpenBSD: sxiuart.c,v 1.7 2016/06/12 06:58:39 jsg Exp $ */
+/* $OpenBSD: sxiuart.c,v 1.8 2016/07/26 22:10:10 patrick Exp $ */
/*
* Copyright (c) 2005 Dale Rahn <drahn@motorola.com>
* Copyright (c) 2013 Artturi Alm
void
sxiuart_init_cons(void)
{
- struct fdt_memory mem;
+ struct fdt_reg reg;
void *node;
if ((node = fdt_find_cons("snps,dw-apb-uart")) == NULL)
return;
- if (fdt_get_memory_address(node, 0, &mem))
+ if (fdt_get_reg(node, 0, ®))
return;
- sxiuartcnattach(&armv7_a4x_bs_tag, mem.addr, comcnspeed, 24000000,
+ sxiuartcnattach(&armv7_a4x_bs_tag, reg.addr, comcnspeed, 24000000,
comcnmode);
}
-/* $OpenBSD: pl011.c,v 1.3 2016/06/08 15:27:05 jsg Exp $ */
+/* $OpenBSD: pl011.c,v 1.4 2016/07/26 22:10:10 patrick Exp $ */
/*
* Copyright (c) 2014 Patrick Wildt <patrick@blueri.se>
void
pl011_init_cons(void)
{
- struct fdt_memory mem;
+ struct fdt_reg reg;
void *node;
if ((node = fdt_find_cons("arm,pl011")) == NULL)
return;
- if (fdt_get_memory_address(node, 0, &mem))
+ if (fdt_get_reg(node, 0, ®))
return;
- pl011cnattach(&armv7_bs_tag, mem.addr, comcnspeed, comcnmode);
+ pl011cnattach(&armv7_bs_tag, reg.addr, comcnspeed, comcnmode);
}
int
#if NFDT > 0
if (aa->aa_node) {
- struct fdt_memory fdtmem;
+ struct fdt_reg reg;
- if (fdt_get_memory_address(aa->aa_node, 0, &fdtmem))
+ if (fdt_get_reg(aa->aa_node, 0, ®))
panic("%s: could not extract memory data from FDT",
__func__);
- mem.addr = fdtmem.addr;
- mem.size = fdtmem.size;
+ mem.addr = reg.addr;
+ mem.size = reg.size;
if (fdt_node_property_ints(aa->aa_node, "interrupts",
ints, 3) != 3)
-/* $OpenBSD: virtio_mmio.c,v 1.3 2016/07/14 12:42:00 sf Exp $ */
+/* $OpenBSD: virtio_mmio.c,v 1.4 2016/07/26 22:10:10 patrick Exp $ */
/* $NetBSD: virtio.c,v 1.3 2011/11/02 23:05:52 njoly Exp $ */
/*
#if NFDT > 0
if (aa->aa_node) {
- struct fdt_memory fdtmem;
+ struct fdt_reg reg;
uint32_t ints[3];
- if (fdt_get_memory_address(aa->aa_node, 0, &fdtmem))
+ if (fdt_get_reg(aa->aa_node, 0, ®))
panic("%s: could not extract memory data from FDT", __func__);
if (fdt_node_property_ints(aa->aa_node, "interrupts",
panic("%s: could not extract interrupt data from FDT",
__func__);
- mem.addr = fdtmem.addr;
- mem.size = fdtmem.size;
+ mem.addr = reg.addr;
+ mem.size = reg.size;
irq = ints[1];
} else
-/* $OpenBSD: fdt.c,v 1.17 2016/07/09 12:31:05 kettenis Exp $ */
+/* $OpenBSD: fdt.c,v 1.18 2016/07/26 22:10:10 patrick Exp $ */
/*
* Copyright (c) 2009 Dariusz Swiderski <sfires@sfires.net>
void *fdt_find_phandle_recurse(void *, uint32_t);
int fdt_node_property_int(void *, char *, int *);
int fdt_node_property_ints(void *, char *, int *, int);
-int fdt_translate_memory_address(void *, struct fdt_memory *);
+int fdt_translate_reg(void *, struct fdt_reg *);
#ifdef DEBUG
void fdt_print_node_recurse(void *, int);
#endif
* has a ranges attribute and ask the same questions again.
*/
int
-fdt_translate_memory_address(void *node, struct fdt_memory *mem)
+fdt_translate_reg(void *node, struct fdt_reg *reg)
{
void *parent;
int pac, psc, ac, sc, ret, rlen, rone, *range;
/* Empty ranges means 1:1 mapping. Continue translation on parent. */
if (rlen <= 0)
- return fdt_translate_memory_address(parent, mem);
+ return fdt_translate_reg(parent, reg);
/* We only support 32-bit (1), and 64-bit (2) wide addresses here. */
ret = fdt_node_property_int(parent, "#address-cells", &pac);
size = (size << 32) + betoh32(range[ac + pac + 1]);
/* Try next, if we're not in the range. */
- if (mem->addr < from || (mem->addr + mem->size) > (from + size))
+ if (reg->addr < from || (reg->addr + reg->size) > (from + size))
continue;
/* All good, extract to address and translate. */
if (pac == 2)
to = (to << 32) + betoh32(range[ac + 1]);
- mem->addr -= from;
- mem->addr += to;
- return fdt_translate_memory_address(parent, mem);
+ reg->addr -= from;
+ reg->addr += to;
+ return fdt_translate_reg(parent, reg);
}
/* To be successful, we must have returned in the for-loop. */
* Parse the memory address and size of a node.
*/
int
-fdt_get_memory_address(void *node, int idx, struct fdt_memory *mem)
+fdt_get_reg(void *node, int idx, struct fdt_reg *reg)
{
void *parent;
int ac, sc, off, ret, *in, inlen;
- if (node == NULL || mem == NULL)
+ if (node == NULL || reg == NULL)
return EINVAL;
parent = fdt_parent_node(node);
off = idx * (ac + sc);
- mem->addr = betoh32(in[off]);
+ reg->addr = betoh32(in[off]);
if (ac == 2)
- mem->addr = (mem->addr << 32) + betoh32(in[off + 1]);
+ reg->addr = (reg->addr << 32) + betoh32(in[off + 1]);
- mem->size = betoh32(in[off + ac]);
+ reg->size = betoh32(in[off + ac]);
if (sc == 2)
- mem->size = (mem->size << 32) + betoh32(in[off + ac + 1]);
+ reg->size = (reg->size << 32) + betoh32(in[off + ac + 1]);
- return fdt_translate_memory_address(parent, mem);
+ return fdt_translate_reg(parent, reg);
}
int
-/* $OpenBSD: fdt.h,v 1.4 2016/07/09 12:31:05 kettenis Exp $ */
+/* $OpenBSD: fdt.h,v 1.5 2016/07/26 22:10:10 patrick Exp $ */
/*
* Copyright (c) 2009 Dariusz Swiderski <sfires@sfires.net>
int strings_size;
};
-struct fdt_memory {
+struct fdt_reg {
uint64_t addr;
uint64_t size;
};
int fdt_node_property(void *, char *, char **);
void *fdt_parent_node(void *);
void *fdt_find_phandle(uint32_t);
-int fdt_get_memory_address(void *, int, struct fdt_memory *);
+int fdt_get_reg(void *, int, struct fdt_reg *);
int fdt_is_compatible(void *, const char *);
#ifdef DEBUG
void *fdt_print_property(void *, int);