Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. =================================================================== RCS file: /ftp/cvs/cvsroot/src/sys/arch/evbarm/fdt/fdt_machdep.c,v rcsdiff: /ftp/cvs/cvsroot/src/sys/arch/evbarm/fdt/fdt_machdep.c,v: warning: Unknown phrases like `commitid ...;' are present. retrieving revision 1.24.2.2 retrieving revision 1.58 diff -u -p -r1.24.2.2 -r1.58 --- src/sys/arch/evbarm/fdt/fdt_machdep.c 2020/04/08 14:07:35 1.24.2.2 +++ src/sys/arch/evbarm/fdt/fdt_machdep.c 2019/01/31 13:26:21 1.58 @@ -1,4 +1,4 @@ -/* $NetBSD: fdt_machdep.c,v 1.24.2.2 2020/04/08 14:07:35 martin Exp $ */ +/* $NetBSD: fdt_machdep.c,v 1.58 2019/01/31 13:26:21 skrll Exp $ */ /*- * Copyright (c) 2015-2017 Jared McNeill @@ -27,7 +27,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: fdt_machdep.c,v 1.24.2.2 2020/04/08 14:07:35 martin Exp $"); +__KERNEL_RCSID(0, "$NetBSD: fdt_machdep.c,v 1.58 2019/01/31 13:26:21 skrll Exp $"); #include "opt_machdep.h" #include "opt_bootconfig.h" @@ -64,7 +64,6 @@ __KERNEL_RCSID(0, "$NetBSD: fdt_machdep. #include #include #include -#include #include #include @@ -89,7 +88,6 @@ __KERNEL_RCSID(0, "$NetBSD: fdt_machdep. #include #include -#include #ifdef EFI_RUNTIME #include @@ -119,7 +117,6 @@ u_long uboot_args[4] __attribute__((__se const uint8_t *fdt_addr_r __attribute__((__section__(".data"))); static uint64_t initrd_start, initrd_end; -static uint64_t rndseed_start, rndseed_end; #include #include @@ -161,7 +158,8 @@ static struct consdev earlycons = { #endif /* - * Get all of physical memory, including holes. + * ARM: Get the first physically contiguous region of memory. + * ARM64: Get all of physical memory, including holes. */ static void fdt_get_memory(uint64_t *pstart, uint64_t *pend) @@ -186,8 +184,14 @@ fdt_get_memory(uint64_t *pstart, uint64_ VPRINTF("FDT /memory [%d] @ 0x%" PRIx64 " size 0x%" PRIx64 "\n", index, cur_addr, cur_size); +#ifdef __aarch64__ if (cur_addr + cur_size > *pend) *pend = cur_addr + cur_size; +#else + /* If subsequent entries follow the previous, append them. */ + if (*pend == cur_addr) + *pend = cur_addr + cur_size; +#endif } } @@ -254,24 +258,21 @@ static struct boot_physmem fdt_physmem[M static void fdt_add_boot_physmem(const struct fdt_memory *m, void *arg) { - const paddr_t saddr = round_page(m->start); - const paddr_t eaddr = trunc_page(m->end); - - VPRINTF(" %" PRIx64 " - %" PRIx64, m->start, m->end - 1); - if (saddr >= eaddr) { - VPRINTF(" skipped\n"); - return; - } - VPRINTF("\n"); - struct boot_physmem *bp = &fdt_physmem[nfdt_physmem++]; + VPRINTF(" %" PRIx64 " - %" PRIx64 "\n", m->start, m->end - 1); + KASSERT(nfdt_physmem <= MAX_PHYSMEM); - bp->bp_start = atop(saddr); - bp->bp_pages = atop(eaddr) - bp->bp_start; + bp->bp_start = atop(round_page(m->start)); + bp->bp_pages = atop(trunc_page(m->end)) - bp->bp_start; bp->bp_freelist = VM_FREELIST_DEFAULT; +#ifdef _LP64 + if (m->end > 0x100000000) + bp->bp_freelist = VM_FREELIST_HIGHMEM; +#endif + #ifdef PMAP_NEED_ALLOC_POOLPAGE const uint64_t memory_size = *(uint64_t *)arg; if (atop(memory_size) > bp->bp_pages) { @@ -309,10 +310,6 @@ fdt_build_bootconfig(uint64_t mem_start, if (initrd_size > 0) fdt_memory_remove_range(initrd_start, initrd_size); - const uint64_t rndseed_size = rndseed_end - rndseed_start; - if (rndseed_size > 0) - fdt_memory_remove_range(rndseed_start, rndseed_size); - const int framebuffer = OF_finddevice("/chosen/framebuffer"); if (framebuffer >= 0) { for (index = 0; @@ -392,65 +389,6 @@ fdt_setup_initrd(void) #endif } -static void -fdt_probe_rndseed(uint64_t *pstart, uint64_t *pend) -{ - int chosen, len; - const void *start_data, *end_data; - - *pstart = *pend = 0; - chosen = OF_finddevice("/chosen"); - if (chosen < 0) - return; - - start_data = fdtbus_get_prop(chosen, "netbsd,rndseed-start", &len); - end_data = fdtbus_get_prop(chosen, "netbsd,rndseed-end", NULL); - if (start_data == NULL || end_data == NULL) - return; - - switch (len) { - case 4: - *pstart = be32dec(start_data); - *pend = be32dec(end_data); - break; - case 8: - *pstart = be64dec(start_data); - *pend = be64dec(end_data); - break; - default: - printf("Unsupported len %d for /chosen/rndseed-start\n", len); - return; - } -} - -static void -fdt_setup_rndseed(void) -{ - const uint64_t rndseed_size = rndseed_end - rndseed_start; - const paddr_t startpa = trunc_page(rndseed_start); - const paddr_t endpa = round_page(rndseed_end); - paddr_t pa; - vaddr_t va; - void *rndseed; - - if (rndseed_size == 0) - return; - - va = uvm_km_alloc(kernel_map, endpa - startpa, 0, - UVM_KMF_VAONLY | UVM_KMF_NOWAIT); - if (va == 0) { - printf("Failed to allocate VA for rndseed\n"); - return; - } - rndseed = (void *)va; - - for (pa = startpa; pa < endpa; pa += PAGE_SIZE, va += PAGE_SIZE) - pmap_kenter_pa(va, pa, VM_PROT_READ|VM_PROT_WRITE, 0); - pmap_update(pmap_kernel()); - - rnd_seed(rndseed, rndseed_size); -} - #ifdef EFI_RUNTIME static void fdt_map_efi_runtime(const char *prop, enum arm_efirt_mem_type type) @@ -497,7 +435,7 @@ initarm(void *arg) error = fdt_open_into(fdt_addr_r, fdt_data, sizeof(fdt_data)); if (error != 0) panic("fdt_move failed: %s", fdt_strerror(error)); - fdtbus_init(fdt_data); + fdtbus_set_data(fdt_data); } else { panic("fdt_check_header failed: %s", fdt_strerror(error)); } @@ -581,9 +519,6 @@ initarm(void *arg) /* Parse ramdisk info */ fdt_probe_initrd(&initrd_start, &initrd_end); - /* Parse rndseed */ - fdt_probe_rndseed(&rndseed_start, &rndseed_end); - /* * Populate bootconfig structure for the benefit of * dodumpsys @@ -610,9 +545,6 @@ initarm(void *arg) u_int sp = initarm_common(KERNEL_VM_BASE, KERNEL_VM_SIZE, fdt_physmem, nfdt_physmem); - /* - * initarm_common flushes cache if required before AP start - */ error = 0; if ((boothowto & RB_MD1) == 0) { VPRINTF("mpstart\n"); @@ -693,15 +625,6 @@ consinit(void) } void -cpu_startup_hook(void) -{ - - fdtbus_intr_init(); - - fdt_setup_rndseed(); -} - -void delay(u_int us) { const struct arm_platform *plat = arm_fdt_platform();