Source-Changes-HG archive

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

[src/trunk]: src/sys/arch/netwinder Clean up Netwinder bootstrap:



details:   https://anonhg.NetBSD.org/src/rev/bdf86ac7ad6a
branches:  trunk
changeset: 524964:bdf86ac7ad6a
user:      thorpej <thorpej%NetBSD.org@localhost>
date:      Wed Apr 03 02:06:33 2002 +0000

description:
Clean up Netwinder bootstrap:
* Put the code that runs with the MMU off in a separate section (.start).
* Use a linker script to set the VMA/LMA appropriately for each section.
* Fix kernel page table allocation and mapping of kernel text/data/bss.

...and now that kernel images > 2MB work:
* Add SYMTAB_SPACE to the GENERIC kernel so that we have DDB symbols.
* Use dbsym to load the kernel's DDB symbol area.

diffstat:

 sys/arch/netwinder/conf/GENERIC                  |    5 +-
 sys/arch/netwinder/conf/Makefile.netwinder.inc   |    8 +-
 sys/arch/netwinder/conf/kern.ldscript            |   77 ++++++
 sys/arch/netwinder/netwinder/netwinder_machdep.c |  269 +++++++---------------
 sys/arch/netwinder/netwinder/nwmmu.S             |  168 +++++++-------
 5 files changed, 258 insertions(+), 269 deletions(-)

diffs (truncated from 727 to 300 lines):

diff -r db53a337addb -r bdf86ac7ad6a sys/arch/netwinder/conf/GENERIC
--- a/sys/arch/netwinder/conf/GENERIC   Wed Apr 03 00:46:53 2002 +0000
+++ b/sys/arch/netwinder/conf/GENERIC   Wed Apr 03 02:06:33 2002 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: GENERIC,v 1.16 2002/04/02 05:30:45 lukem Exp $
+# $NetBSD: GENERIC,v 1.17 2002/04/03 02:06:33 thorpej Exp $
 #
 # GENERIC machine description file
 # 
@@ -142,7 +142,8 @@
 #options       IPKDB           # remote kernel debugging
 options        DDB             # in-kernel debugger
 options        DDB_HISTORY_SIZE=100    # Enable history editing in DDB
-#makeoptions   DEBUG="-g"      # compile full symbol table
+makeoptions    DEBUG="-g"      # compile full symbol table
+options        SYMTAB_SPACE=210000
 
 config         netbsd  root on ? type ?
 
diff -r db53a337addb -r bdf86ac7ad6a sys/arch/netwinder/conf/Makefile.netwinder.inc
--- a/sys/arch/netwinder/conf/Makefile.netwinder.inc    Wed Apr 03 00:46:53 2002 +0000
+++ b/sys/arch/netwinder/conf/Makefile.netwinder.inc    Wed Apr 03 02:06:33 2002 +0000
@@ -1,6 +1,12 @@
-#      $NetBSD: Makefile.netwinder.inc,v 1.4 2001/11/27 00:16:01 thorpej Exp $
+#      $NetBSD: Makefile.netwinder.inc,v 1.5 2002/04/03 02:06:33 thorpej Exp $
+
+SYSTEM_LD_TAIL_EXTRA=; \
+       echo "${DBSYM} $@ || true"; \
+       ${DBSYM} $@ || true
 
 GENASSYM_EXTRAS+=      ${ARM}/footbridge/genassym.cf
 
 SYSTEM_FIRST_OBJ=      nwmmu.o
 SYSTEM_FIRST_SFILE=    ${THISARM}/${MACHINE}/nwmmu.S
+
+LINKFLAGS=             -T ${THISARM}/conf/kern.ldscript
diff -r db53a337addb -r bdf86ac7ad6a sys/arch/netwinder/conf/kern.ldscript
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/sys/arch/netwinder/conf/kern.ldscript     Wed Apr 03 02:06:33 2002 +0000
@@ -0,0 +1,77 @@
+/*     $NetBSD: kern.ldscript,v 1.1 2002/04/03 02:06:33 thorpej Exp $  */
+
+OUTPUT_FORMAT("elf32-littlearm-nbsd", "elf32-bigarm-nbsd",
+             "elf32-littlearm-nbsd")
+OUTPUT_ARCH(arm)
+ENTRY(KERNEL_BASE_phys)
+SECTIONS
+{
+  KERNEL_BASE_phys = 0x0000c000;
+  KERNEL_BASE_virt = 0xf000c000;
+
+  /* Kernel start: */
+  .start (KERNEL_BASE_phys) :
+  {
+    *(.start)
+  } =0
+
+  /* Read-only sections, merged into text segment: */
+  .text (KERNEL_BASE_virt + SIZEOF(.start)) :
+  AT (LOADADDR(.start) + SIZEOF(.start))
+  {
+    *(.text)
+    *(.text.*)
+    *(.stub)
+    *(.glue_7t) *(.glue_7)
+    *(.rodata) *(.rodata.*)
+  } =0
+  PROVIDE (__etext = .);
+  PROVIDE (_etext = .);
+  PROVIDE (etext = .);
+  /* Adjust the address for the data segment to start on the next page
+     boundary.  */
+  . = ALIGN(0x8000);
+  .data    :
+  AT ((LOADADDR(.text) + SIZEOF(.text) + (0x8000 - 1)) & ~(0x8000 - 1))
+  {
+    __data_start = . ;
+    *(.data)
+    *(.data.*)
+  }
+  .sdata     : 
+  AT (LOADADDR(.data) + SIZEOF(.data))
+  {
+    *(.sdata) 
+    *(.sdata.*)
+  }
+  _edata = .;
+  PROVIDE (edata = .);
+  __bss_start = .;
+  __bss_start__ = .;
+  .sbss      :
+  {
+    PROVIDE (__sbss_start = .);
+    PROVIDE (___sbss_start = .);
+    *(.dynsbss)
+    *(.sbss)
+    *(.sbss.*)
+    *(.scommon)
+    PROVIDE (__sbss_end = .);
+    PROVIDE (___sbss_end = .);
+  }
+  .bss       :
+  {
+   *(.dynbss)
+   *(.bss)
+   *(.bss.*)
+   *(COMMON)
+   /* Align here to ensure that the .bss section occupies space up to
+      _end.  Align after .bss to ensure correct alignment even if the
+      .bss section disappears because there are no input sections.  */
+   . = ALIGN(32 / 8);
+  }
+  . = ALIGN(32 / 8);
+  _end = .;
+  _bss_end__ = . ; __bss_end__ = . ; __end__ = . ;
+  PROVIDE (end = .);
+}
diff -r db53a337addb -r bdf86ac7ad6a sys/arch/netwinder/netwinder/netwinder_machdep.c
--- a/sys/arch/netwinder/netwinder/netwinder_machdep.c  Wed Apr 03 00:46:53 2002 +0000
+++ b/sys/arch/netwinder/netwinder/netwinder_machdep.c  Wed Apr 03 02:06:33 2002 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: netwinder_machdep.c,v 1.26 2002/03/25 04:51:21 thorpej Exp $   */
+/*     $NetBSD: netwinder_machdep.c,v 1.27 2002/04/03 02:06:33 thorpej Exp $   */
 
 /*
  * Copyright (c) 1997,1998 Mark Brinicombe.
@@ -85,13 +85,12 @@
 #define        ISA_GETBYTE(r)          footbridge_bs_r_1(0, isa_base, (r))
 #define        ISA_PUTBYTE(r,v)        footbridge_bs_w_1(0, isa_base, (r), (v))
 
-static void netwinder_reset(void);
 /*
  * Address to call from cpu_reset() to reset the machine.
  * This is machine architecture dependant as it varies depending
  * on where the ROM appears when you turn the MMU off.
  */
-
+static void netwinder_reset(void);
 u_int cpu_reset_address = (u_int) netwinder_reset;
 
 u_int dc21285_fclk = 63750000;
@@ -360,96 +359,65 @@
        int loop1;
        u_int l1pagetable;
        extern char page0[], page0_end[];
-#if 0
-       extern int end[];
-       extern int *esym;
-#endif
+       extern char _end[];
        pv_addr_t kernel_l1pt;
        pv_addr_t kernel_ptpt;
 
+       /*
+        * Set up a diagnostic console so we can see what's going
+        * on.
+        */
        cn_tab = &kcomcons;
+
+       /* Talk to the user */
+       printf("\nNetBSD/netwinder booting ...\n");
+
        /*
         * Heads up ... Setup the CPU / MMU / TLB functions
         */
        if (set_cpufuncs())
                panic("cpu not recognized!");
 
-       /* Fake bootconfig structure for the benefit of pmap.c */
-       /* XXX must make the memory description h/w independant */
-       bootconfig.dramblocks = 1;
-       bootconfig.dram[0].address = 0;
-       bootconfig.dram[0].pages = 0x04000000 / NBPG; /* nwbootinfo.bi_nrpages */
-       /*    - nwbootinfo.bt_memstart) / NBPG */;
-
        /*
-        * 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.
+        * We are currently running with the MMU enabled and the
+        * entire address space mapped VA==PA, except for the
+        * first 64MB of RAM is also double-mapped at 0xf0000000.
+        * There is an L1 page table at 0x00008000.
+        *
+        * We also have the 21285's PCI I/O space mapped where
+        * we expect it.
         */
-/*     fcomcnattach(DC21285_ARMCSR_BASE, comcnspeed, comcnmode);*/
-
-       /* Talk to the user */
-       printf("\nNetBSD/netwinder booting ...\n");
-
-#if 0
-       if (nwbootinfo.bt_magic != BT_MAGIC_NUMBER_EBSA
-           && nwbootinfo.bt_magic != BT_MAGIC_NUMBER_CATS)
-               panic("Incompatible magic number passed in boot args\n");
-#endif
-
-/*     {
-       int loop;
-       for (loop = 0; loop < 8; ++loop) {
-               printf("%08x\n", *(((int *)bootinfo)+loop));
-       }
-       }*/
-
-       /*
-        * Ok we have the following memory map
-        *
-        * virtual address == physical address apart from the areas:
-        * 0x00000000 -> 0x000fffff which is mapped to
-        * top 1MB of physical memory
-        * 0x00100000 -> 0x0fffffff which is mapped to
-        * physical addresses 0x00100000 -> 0x0fffffff
-        * 0x10000000 -> 0x1fffffff which is mapped to
-        * physical addresses 0x00000000 -> 0x0fffffff
-        * 0x20000000 -> 0xefffffff which is mapped to
-        * physical addresses 0x20000000 -> 0xefffffff
-        * 0xf0000000 -> 0xf03fffff which is mapped to
-        * physical addresses 0x00000000 -> 0x003fffff
-        *
-        * 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 accessible.
-        *
-        * The initarm() has the responsibility for creating the kernel
-        * page tables.
-        * It must also set up various memory pointers that are used
-        * by pmap etc. 
-        */
-
-       /*
-        * Examine the boot args string for options we need to know about
-        * now.
-        */
-#if 0
-       process_kernel_args((char *)nwbootinfo.bt_args);
-#endif
 
        printf("initarm: Configuring system ...\n");
 
+       /* Fake bootconfig structure for the benefit of pmap.c */
+       /* XXX must make the memory description h/w independant */
+       /* XXX must query 21285, or something... */
+       bootconfig.dramblocks = 1;
+       bootconfig.dram[0].address = 0;
+       bootconfig.dram[0].pages = 0x04000000 / NBPG;
+
        /*
         * Set up the variables that define the availablilty of
-        * physical memory
+        * physical memory.
+        *
+        * Since the NetWinder NeTTrom doesn't load ELF symbols
+        * for us, we can safely assume that everything after end[]
+        * is free.  We start there and allocate upwards.
         */
-       physical_start = 0 /*nwbootinfo.bt_memstart*/;
-       physical_freestart = physical_start;
-       physical_end = /*nwbootinfo.bt_memend*/ /*nwbootinfo.bi_nrpages * NBPG */ 64*1024*1024;
+       physical_start = bootconfig.dram[0].address;
+       physical_end = physical_start + (bootconfig.dram[0].pages * NBPG);
+
+       physical_freestart = ((((vaddr_t) _end) + PGOFSET) & ~PGOFSET) -
+           KERNEL_BASE;
        physical_freeend = physical_end;
-       free_pages = (physical_end - physical_start) / NBPG;
-    
+       free_pages = (physical_freeend - physical_freestart) / NBPG;
+
+#ifdef VERBOSE_INIT_ARM
+       printf("freestart = 0x%08lx, free_pages = %d (0x%x)\n",
+              physical_freestart, free_pages, free_pages);
+#endif
+
        physmem = (physical_end - physical_start) / NBPG;
 
        /* Tell the user about the memory */
@@ -457,48 +425,23 @@
            physical_start, physical_end - 1);
 
        /*
-        * Ok the kernel occupies the bottom of physical memory.
-        * The first free page after the kernel can be found in
-        * nwbootinfo->bt_memavail
-        * We now need to allocate some fixed page tables to get the kernel
-        * going.
-        * We allocate one page directory and a number page tables and store
-        * the physical addresses in the kernel_pt_table array.
+        * Okay, we need to allocate some fixed page tables to get the
+        * kernel going.  We allocate one page directory and a number
+        * of page tables and store the physical addresses in the
+        * kernel_pt_table array.
         *
-        * Ok the next bit of physical allocation may look complex but it is
-        * simple really. I have done it like this so that no memory gets
-        * wasted during the allocation of various pages and tables that are
-        * all different sizes.
-        * The start addresses will be page aligned.
-        * We allocate the kernel page directory on the first free 16KB boundry



Home | Main Index | Thread Index | Old Index