Hi,
bad bug/regression report, i know, just want to archive a fix somewhere
before moving on. maybe it's not a bug either, just unused feature,
given dumpsys() has /* XXX TBD */ atleast in octeon too, idk..
small side-effect in the diff below, it leaves armv7/bootconfig.h
laying around totally unused.
-Artturi
diff --git a/sys/arch/arm/arm/stubs.c b/sys/arch/arm/arm/stubs.c
index 7a99ef06bba..682ee0fdc7f 100644
--- a/sys/arch/arm/arm/stubs.c
+++ b/sys/arch/arm/arm/stubs.c
@@ -51,7 +51,6 @@
#include <sys/core.h>
#include <sys/kcore.h>
#include <uvm/uvm_extern.h>
-#include <machine/bootconfig.h>
#include <machine/cpu.h>
#include <machine/intr.h>
#include <machine/pcb.h>
@@ -82,7 +81,7 @@ void dumpconf(void);
void
dumpconf(void)
{
- int nblks, block;
+ int nblks;
if (dumpdev == NODEV ||
(nblks = (bdevsw[major(dumpdev)].d_psize)(dumpdev)) == 0)
@@ -101,13 +100,6 @@ dumpconf(void)
dumpsize = dtoc(nblks - dumplo) - 1;
if (dumplo < nblks - ctod(dumpsize) - 1)
dumplo = nblks - ctod(dumpsize) - 1;
-
- for (block = 0; block < bootconfig.dramblocks; block++) {
- cpu_kcore_hdr.ram_segs[block].start =
- bootconfig.dram[block].address;
- cpu_kcore_hdr.ram_segs[block].size =
- ptoa(bootconfig.dram[block].pages);
- }
}
/* This should be moved to machdep.c */
@@ -121,16 +113,14 @@ extern char *memhook; /* XXX */
*/
void
-dumpsys()
+dumpsys(void)
{
const struct bdevsw *bdev;
daddr_t blkno;
int psize;
int error;
- int addr;
- int block;
int len;
- vaddr_t dumpspace;
+ int seg;
kcore_seg_t *kseg_p;
cpu_kcore_hdr_t *chdr_p;
char dump_hdr[dbtob(1)]; /* assumes header fits in one block */
@@ -157,7 +147,6 @@ dumpsys()
minor(dumpdev), dumplo);
blkno = dumplo;
- dumpspace = (vaddr_t) memhook;
bdev = bdevsw_lookup(dumpdev);
if (bdev == NULL || bdev->d_psize == NULL)
@@ -176,7 +165,7 @@ dumpsys()
CORE_SETMAGIC(*kseg_p, KCORE_MAGIC, MID_MACHINE, CORE_CPU);
kseg_p->c_size = sizeof(dump_hdr) - ALIGN(sizeof(*kseg_p));
- *chdr_p = cpu_kcore_hdr;
+ bcopy(&cpu_kcore_hdr, chdr_p, sizeof(*chdr_p));
error = (*bdev->d_dump)(dumpdev, blkno++, (caddr_t)dump_hdr,
sizeof(dump_hdr));
@@ -184,23 +173,23 @@ dumpsys()
goto abort;
len = 0;
- for (block = 0; block < bootconfig.dramblocks && error == 0; ++block) {
- addr = bootconfig.dram[block].address;
- for (;addr < (bootconfig.dram[block].address
- + (bootconfig.dram[block].pages * PAGE_SIZE));
- addr += PAGE_SIZE) {
+ for (seg = 0; seg < cpu_kcore_hdr.ram_nsegs && error == 0; seg++) {
+ paddr_t _addr = cpu_kcore_hdr.ram_segs[seg].start;
+ paddr_t seg_end = _addr + cpu_kcore_hdr.ram_segs[seg].size;
+
+ for (; _addr < seg_end; _addr += NBPG, blkno += btodb(NBPG)) {
if ((len % (1024*1024)) == 0)
printf("%d ", len / (1024*1024));
- pmap_kenter_pa(dumpspace, addr, PROT_READ);
+ len += NBPG;
+
+ pmap_kenter_pa((vaddr_t)memhook, _addr, PROT_READ);
pmap_update(pmap_kernel());
- error = (*bdev->d_dump)(dumpdev,
- blkno, (caddr_t) dumpspace, PAGE_SIZE);
- pmap_kremove(dumpspace, PAGE_SIZE);
+ error = (*bdev->d_dump)(dumpdev, blkno, memhook, NBPG);
+ pmap_kremove((vaddr_t)memhook, PAGE_SIZE);
pmap_update(pmap_kernel());
- if (error) break;
- blkno += btodb(PAGE_SIZE);
- len += PAGE_SIZE;
+ if (error)
+ break;
}
}
diff --git a/sys/arch/arm/include/kcore.h b/sys/arch/arm/include/kcore.h
index 02050490bbc..3a0def6f522 100644
--- a/sys/arch/arm/include/kcore.h
+++ b/sys/arch/arm/include/kcore.h
@@ -1,8 +1,8 @@
/* $OpenBSD: kcore.h,v 1.1 2007/05/19 15:49:05 miod Exp $ */
/* public domain */
-/* Make sure this is larger than DRAM_BLOCKS on all arm-based platforms */
-#define NPHYS_RAM_SEGS 8
+#include <machine/vmparam.h>
+#define NPHYS_RAM_SEGS VM_PHYSSEG_MAX
typedef struct cpu_kcore_hdr {
u_int32_t kernelbase; /* value of KERNEL_BASE */
@@ -11,5 +11,6 @@ typedef struct cpu_kcore_hdr {
u_int32_t pmap_kernel_l1; /* pmap_kernel()->pm_l1 */
u_int32_t pmap_kernel_l2; /* pmap_kernel()->pm_l2 */
u_int32_t reserved[11];
+ int ram_nsegs;
phys_ram_seg_t ram_segs[NPHYS_RAM_SEGS];
} cpu_kcore_hdr_t;
diff --git a/sys/arch/armv7/armv7/armv7_machdep.c
b/sys/arch/armv7/armv7/armv7_machdep.c
index aa1c549b29b..7be916c19dd 100644
--- a/sys/arch/armv7/armv7/armv7_machdep.c
+++ b/sys/arch/armv7/armv7/armv7_machdep.c
@@ -107,18 +107,19 @@
#include <sys/param.h>
#include <sys/systm.h>
+#include <sys/kcore.h>
#include <sys/proc.h>
#include <sys/reboot.h>
#include <sys/termios.h>
#include <sys/socket.h>
#include <machine/db_machdep.h>
-#include <machine/bootconfig.h>
#include <machine/machine_reg.h>
#include <machine/bus.h>
#include <arm/undefined.h>
#include <arm/machdep.h>
+#include <arm/kcore.h>
#include <arm/armv7/armv7var.h>
#include <armv7/armv7/armv7_machdep.h>
@@ -146,7 +147,6 @@
#define ABT_STACK_SIZE 1
#define UND_STACK_SIZE 1
-BootConfig bootconfig; /* Boot config storage */
char *boot_args = NULL;
char *boot_file = "";
u_int cpu_reset_address = 0;
@@ -162,6 +162,7 @@ int physmem = 0;
#ifndef PMAP_STATIC_L1S
int max_processes = 64; /* Default number */
#endif /* !PMAP_STATIC_L1S */
+#define MAX_BOOT_STRING 255
/* Physical and virtual addresses for some global pages */
pv_addr_t systempage;
@@ -356,6 +357,22 @@ copy_io_area_map(pd_entry_t *new_pd)
}
}
+static inline void
+bootstrap_pmem_load(paddr_t _pms, paddr_t _pme, u_int _pmas, u_int _pmae)
+{
+ extern cpu_kcore_hdr_t cpu_kcore_hdr;
+ cpu_kcore_hdr_t *hdr = &cpu_kcore_hdr;
+
+ hdr->ram_segs[vm_nphysseg].start = round_page(_pms);
+ hdr->ram_segs[vm_nphysseg].size = trunc_page(_pme - _pms);
+ uvm_page_physload(
+ atop(_pms),
+ atop(_pme),
+ atop(_pmas ? _pmas : _pms),
+ atop(_pmae ? _pmae : _pme), 0);
+ hdr->ram_nsegs = vm_nphysseg;
+}
+
/*
* u_int initarm(...)
*
@@ -371,7 +388,7 @@ copy_io_area_map(pd_entry_t *new_pd)
u_int
initarm(void *arg0, void *arg1, void *arg2, paddr_t loadaddr)
{
- int loop, loop1, i, physsegs = VM_PHYSSEG_MAX;
+ int loop, loop1, i;
u_int l1pagetable;
pv_addr_t kernel_l1pt;
pv_addr_t fdt;
@@ -740,17 +757,23 @@ initarm(void *arg0, void *arg1, void *arg2, paddr_t
loadaddr)
printf("page ");
#endif
uvm_setpagesize(); /* initialize PAGE_SIZE-dependent variables */
- uvm_page_physload(atop(physical_freestart), atop(physical_freeend),
- atop(physical_freestart), atop(physical_freeend), 0);
- if (physical_start < loadaddr) {
- uvm_page_physload(atop(physical_start), atop(loadaddr),
- atop(physical_start), atop(loadaddr), 0);
- physsegs--;
- }
+ /*
+ * Stingily optimistic fractioning of the first segment to save a few
+ * bytes for all the new compatibles i'd like to get in, instead of
+ * the other obvious solution of relocating once more even after
+ * bootarm.efi.. XXX i wish;)
+ */
+ if (trunc_page(loadaddr - physical_start) >= PAGE_SIZE)
+ bootstrap_pmem_load(physical_start, loadaddr, 0, 0);
+ bootstrap_pmem_load(loadaddr, physical_end, physical_freestart, 0);
+ /*
+ * And the rest, if any, as there is/was supposedly DTs in the wild,
+ * using >1 prop(array?)s for desribing the contiguous ram they have.
+ */
node = fdt_find_node("/memory");
- for (i = 1; i < physsegs; i++) {
+ for (i = 1; vm_nphysseg < VM_PHYSSEG_MAX; i++) {
if (fdt_get_reg(node, i, ®))
break;
if (reg.size == 0)
@@ -759,8 +782,7 @@ initarm(void *arg0, void *arg1, void *arg2, paddr_t
loadaddr)
memstart = reg.addr;
memend = MIN(reg.addr + reg.size, (paddr_t)-PAGE_SIZE);
physmem += (memend - memstart) / PAGE_SIZE;
- uvm_page_physload(atop(memstart), atop(memend),
- atop(memstart), atop(memend), 0);
+ bootstrap_pmem_load(memstart, memend, 0, 0);
}
/* Boot strap pmap telling it where the kernel page table is */
diff --git a/sys/arch/armv7/armv7/autoconf.c b/sys/arch/armv7/armv7/autoconf.c
index 5865e40d4f8..c6695625072 100644
--- a/sys/arch/armv7/armv7/autoconf.c
+++ b/sys/arch/armv7/armv7/autoconf.c
@@ -49,7 +49,6 @@
#include <sys/conf.h>
#include <sys/kernel.h>
-#include <machine/bootconfig.h>
#include <machine/intr.h>
#include <machine/bus.h>
@@ -101,6 +100,7 @@ cpu_configure(void)
void
diskconf(void)
{
+ extern char *boot_file;
dev_t tmpdev;
#if 0
diff --git a/sys/arch/armv7/omap/omap_machdep.c
b/sys/arch/armv7/omap/omap_machdep.c
index 12302c08e96..c35d70e7d5b 100644
--- a/sys/arch/armv7/omap/omap_machdep.c
+++ b/sys/arch/armv7/omap/omap_machdep.c
@@ -22,7 +22,6 @@
#include <sys/termios.h>
#include <machine/bus.h>
-#include <machine/bootconfig.h>
#include <dev/ic/comreg.h>
#include <dev/ic/comvar.h>