Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/arch/arm32/riscpc Updated the bootloader for RiscPC/A700...



details:   https://anonhg.NetBSD.org/src/rev/bdea74047d3e
branches:  trunk
changeset: 503915:bdea74047d3e
user:      reinoud <reinoud%NetBSD.org@localhost>
date:      Sun Feb 18 00:59:33 2001 +0000

description:
Updated the bootloader for RiscPC/A7000/NCs etc. remains compatible with the old bootloader by an COMPAT_OLD_BOOTLOADER option

diffstat:

 sys/arch/arm32/riscpc/rpc_machdep.c |  1116 +++++++++++++++++++++++++++-------
 1 files changed, 880 insertions(+), 236 deletions(-)

diffs (truncated from 1209 to 300 lines):

diff -r 93850df5a2a0 -r bdea74047d3e sys/arch/arm32/riscpc/rpc_machdep.c
--- a/sys/arch/arm32/riscpc/rpc_machdep.c       Sun Feb 18 00:56:42 2001 +0000
+++ b/sys/arch/arm32/riscpc/rpc_machdep.c       Sun Feb 18 00:59:33 2001 +0000
@@ -1,6 +1,7 @@
-/*     $NetBSD: rpc_machdep.c,v 1.34 2000/06/26 14:20:38 mrg Exp $     */
+/*     $NetBSD: rpc_machdep.c,v 1.35 2001/02/18 00:59:33 reinoud Exp $ */
 
 /*
+ * Copyright (c) 2000-2001 Reinoud Zandijk.
  * Copyright (c) 1994-1998 Mark Brinicombe.
  * Copyright (c) 1994 Brini.
  * All rights reserved.
@@ -40,14 +41,16 @@
  *
  * Machine dependant functions for kernel setup
  *
- * This file needs a lot of work. 
+ * This file still needs a lot of work
  *
  * Created      : 17/09/94
+ * Updated for new bootloader 22/10/00
  */
 
 #include "opt_cputypes.h"
 #include "opt_ddb.h"
 #include "opt_pmap_debug.h"
+#include "opt_compat_old_bootloader.h"
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -90,7 +93,11 @@
  * on where the ROM appears when you turn the MMU off.
  */
 
-u_int cpu_reset_address = 0;
+#define VERBOSE_INIT_ARM
+
+u_int cpu_reset_address = 0x3800000; /* XXX for rev0 RiscPC600 */
+
+#define MAX_BOOT_STRING 0xff
 
 /* Define various stack sizes in pages */
 #define IRQ_STACK_SIZE 1
@@ -103,13 +110,21 @@
 
 BootConfig bootconfig;         /* Boot config storage */
 videomemory_t videomemory;     /* Video memory descriptor */
+/*     static char bootargs[MAX_BOOT_STRING + 1]; */
+char *boot_args = NULL;
+char *boot_file = NULL;
 
 vm_offset_t physical_start;
 vm_offset_t physical_freestart;
 vm_offset_t physical_freeend;
 vm_offset_t physical_end;
+vm_offset_t dma_range_begin;
+vm_offset_t dma_range_end;
+
 u_int free_pages;
+vm_offset_t pagetables_start;
 int physmem = 0;
+vm_offset_t memoryblock_end;
 
 #ifndef PMAP_STATIC_L1S
 int max_processes = 64;                        /* Default number */
@@ -128,9 +143,6 @@
 pv_addr_t hydrascratch;
 #endif /* NHYDRABUS */
 
-char *boot_args = NULL;
-char *boot_file = NULL;
-
 vm_offset_t msgbufphys;
 
 extern u_int data_abort_handler_address;
@@ -195,6 +207,7 @@
 extern void dumpsys    __P((void));
 extern void hydrastop  __P((void));
 
+
 /*
  * void cpu_reboot(int howto, char *bootstr)
  *
@@ -330,6 +343,7 @@
        /*NOTREACHED*/
 }
 
+
 /*
  * u_int initarm(BootConfig *bootconf)
  *
@@ -344,6 +358,860 @@
  *   Relocating the kernel to the bottom of physical memory
  */
 
+/*
+ * this part is completely rewritten for the new bootloader ... It features
+ * a flat memory map with a mapping comparable to the EBSA arm32 machine
+ * to boost the portability and likeness of the code
+ */
+
+/*
+ * Mapping table for core kernel memory. This memory is mapped at init
+ * time with section mappings.
+ * 
+ * XXX One big assumption in the current architecture seems that the kernel is
+ * XXX supposed to be mapped into bootconfig.dram[0], so the bootloader will
+ * XXX put other area's at the end when deciding to move the kernel to a
+ * XXX different dram block.
+ */
+
+#define ONE_MB 0x100000
+
+struct l1_sec_map {
+       vm_offset_t     va;
+       vm_offset_t     pa;
+       vm_size_t       size;
+       int             flags;
+} l1_sec_table[] = {
+       /* Map 1Mb section for VIDC20 */
+       { VIDC_BASE,            VIDC_HW_BASE,
+           ONE_MB,             0 },
+       /* Map 1Mb section from IOMD */
+       { IOMD_BASE,            IOMD_HW_BASE,
+           ONE_MB,             0 },
+       /* Map 1Mb of COMBO (and module space) */
+       { IO_BASE,              IO_HW_BASE,
+           ONE_MB,             0 },
+       { 0, 0, 0, 0 }
+};
+
+
+/*
+ * temporary compat stuff
+ * XXX delete me as soon as posible
+ */
+
+#ifdef COMPAT_OLD_BOOTLOADER
+
+u_int initarm_new_bootloader __P((BootConfig *bootconf));
+u_int initarm_old_bootloader __P((BootConfig *bootconf));
+
+u_int
+initarm(bootconf)
+       BootConfig *bootconf;
+{
+       if (bootconf->magic == BOOTCONFIG_MAGIC)
+               return initarm_new_bootloader(bootconf);
+       else
+               return initarm_old_bootloader(bootconf);
+}
+
+#else
+#      define initarm(a) initarm_new_bootloader(a)
+#endif
+
+/*
+ * The new bootloader initarm ... should be renamed to initarm when the old
+ * bootloader compatibility is removed
+ */
+u_int
+initarm_new_bootloader(bootconf)
+       BootConfig *bootconf;
+{
+       int loop;
+       int loop1;
+       u_int logical;
+       u_int kerneldatasize;
+       u_int l1pagetable;
+       u_int l2pagetable;
+       extern char page0[], page0_end[];
+       struct exec *kernexec = (struct exec *)KERNEL_TEXT_BASE;
+       int id;
+       pv_addr_t kernel_l1pt;
+       pv_addr_t kernel_ptpt;
+
+       /*
+        * Heads up ... Setup the CPU / MMU / TLB functions
+        */
+       set_cpufuncs();
+
+       /* Copy the boot configuration structure */
+       bootconfig = *bootconf;
+
+       /*
+        * Initialise the video memory descriptor
+        *
+        * Note: all references to the video memory virtual/physical address
+        * should go via this structure.
+        */
+
+       /* Hardwire it on the place the bootloader tells us */
+       videomemory.vidm_vbase = bootconfig.display_start;
+       videomemory.vidm_pbase = bootconfig.display_phys;
+       videomemory.vidm_size = bootconfig.display_size;
+       if (bootconfig.vram[0].pages) 
+               videomemory.vidm_type = VIDEOMEM_TYPE_VRAM;
+       else 
+               videomemory.vidm_type = VIDEOMEM_TYPE_DRAM
+       ;
+
+       /*
+        * Initialise the physical console
+        * This is done in main() but for the moment we do it here so that
+        * we can use printf in initarm() before main() has been called.
+        */
+       consinit();
+
+       /*
+        * Initialise the diagnostic serial console
+        * This allows a means of generating output during initarm().
+        * Once all the memory map changes are complete we can call consinit()
+        * and not have to worry about things moving.
+        */
+/*      fcomcnattach(DC21285_ARMCSR_BASE, comcnspeed, comcnmode);*/
+       /* XXX snif .... i am still not able to this */
+
+
+       /* Talk to the user */
+       printf("NetBSD/arm32 booting ... \n");
+
+       /* Tell the user if his boot loader is too old */
+       if (bootconfig.magic > BOOTCONFIG_MAGIC) {
+               printf("\nDETECTED AN OLD BOOTLOADER. PLEASE UPGRADE IT\n\n");
+               delay(5000000);
+       }
+
+       printf("Kernel loaded from file %s\n", bootconfig.kernelname);
+       printf("Kernel arg string (@%p) %s\n", (void *) bootconfig.argvirtualbase, (char *)bootconfig.argvirtualbase);
+       printf("\nBoot configuration structure reports the following memory\n");
+
+       /*
+        * We have the following memory map (derived from EBSA)
+        *
+        * virtual address == physical address apart from the areas:
+        * 0x00000000 -> 0x000fffff which is mapped to
+        * top 1MB of physical memory
+        * 0xf0000000 -> 0xf0ffffff wich is mapped to
+        * physical address 0x01000000 -> 0x01ffffff (DRAM0a, dram[0])
+        *
+        * This means that the kernel is mapped suitably for continuing
+        * execution, all I/O is mapped 1:1 virtual to physical and
+        * physical memory is accessable.
+        *
+        * The initarm() has the responcibility for creating the kernel
+        * page tables.
+        * It must also set up various memory pointers that are used
+        * by pmap etc. 
+        */
+
+       printf("  DRAM block 0a at %08x size %08x  DRAM block 0b at %08x size %08x\n\r",
+           bootconfig.dram[0].address,
+           bootconfig.dram[0].pages * bootconfig.pagesize,
+           bootconfig.dram[1].address,
+           bootconfig.dram[1].pages * bootconfig.pagesize);
+       printf("  DRAM block 1a at %08x size %08x  DRAM block 1b at %08x size %08x\n\r",
+           bootconfig.dram[2].address,
+           bootconfig.dram[2].pages * bootconfig.pagesize,
+           bootconfig.dram[3].address,
+           bootconfig.dram[3].pages * bootconfig.pagesize);
+       printf("  VRAM block 0  at %08x size %08x\n\r",
+           bootconfig.vram[0].address,
+           bootconfig.vram[0].pages * bootconfig.pagesize);
+
+/*     printf("  videomem: VA=%08x PA=%08x\n", videomemory.vidm_vbase, videomemory.vidm_pbase);*/
+
+       /* Check to make sure the page size is correct */
+       if (NBPG != bootconfig.pagesize)
+               panic("Page size is not %d bytes\n", NBPG);
+
+/** START OF REAL NEW STUFF */
+
+       /* Check if we are having the right kernel */
+       id = ReadByte(IOMD_HW_BASE + (IOMD_ID0 << 2))
+         | (ReadByte(IOMD_HW_BASE + (IOMD_ID1 << 2)) << 8);
+       switch (id) {
+       case ARM7500_IOC_ID:
+#ifndef CPU_ARM7500
+               panic("Encountered ARM7500 IOMD but no ARM7500 kernel support");
+#endif /* CPU_ARM7500 */
+               break;
+       case RPC600_IOMD_ID:
+#ifdef CPU_ARM7500
+               panic("Encountered ARM6/7 IOMD and ARM7500 kernel support");
+#endif /* CPU_ARM7500 */
+               break;
+       }
+
+       /* process arguments */
+       process_kernel_args();
+
+
+       /* Now set up the page tables for the kernel ... this part is copied
+        * in a (modified?) way from the EBSA machine port.... 
+        */
+
+#ifdef VERBOSE_INIT_ARM
+       printf("Allocating page tables\n");
+#endif
+       /*



Home | Main Index | Thread Index | Old Index