Fri Jan 20 15:00:27 2012 UTC ()
Kernel load address can be changed now.


(nonaka)
diff -r1.3 -r1.4 src/sys/arch/zaurus/conf/Makefile.zaurus.inc
diff -r1.3 -r1.4 src/sys/arch/zaurus/conf/std.zaurus
diff -r1.1 -r0 src/sys/arch/zaurus/conf/ldscript
diff -r0 -r1.3 src/sys/arch/zaurus/conf/ldscript.zaurus
diff -r1.4 -r1.5 src/sys/arch/zaurus/zaurus/kloader_machdep.c
diff -r1.27 -r1.28 src/sys/arch/zaurus/zaurus/machdep.c

cvs diff -r1.3 -r1.4 src/sys/arch/zaurus/conf/Makefile.zaurus.inc (expand / switch to context diff)
--- src/sys/arch/zaurus/conf/Makefile.zaurus.inc 2011/05/05 09:07:59 1.3
+++ src/sys/arch/zaurus/conf/Makefile.zaurus.inc 2012/01/20 15:00:27 1.4
@@ -1,4 +1,4 @@
-#	$NetBSD: Makefile.zaurus.inc,v 1.3 2011/05/05 09:07:59 nonaka Exp $
+#	$NetBSD: Makefile.zaurus.inc,v 1.4 2012/01/20 15:00:27 nonaka Exp $
 
 MACHINE_ARCH=		arm
 CPPFLAGS+=		-D${MACHINE}
@@ -6,10 +6,6 @@
 SYSTEM_FIRST_OBJ=	zaurus_start.o
 SYSTEM_FIRST_SFILE=	${THISARM}/zaurus/zaurus_start.S
 
-LINKFLAGS=		-T ${THISARM}/conf/ldscript
-
-EXTRA_CLEAN+= netbsd.map assym.d
-
 SYSTEM_LD_TAIL_EXTRA+=; \
 	echo "Checking kernel size..."; \
 	size=`wc -c "$@" | ${TOOL_AWK} '{ print $$1 }'`; \
@@ -20,3 +16,17 @@
 		echo "Fatal: kernel size: $$size, max kernel size: $$maxsize"; \
 		false; \
 	fi
+
+KERNEL_BASE_VIRT=	$(LOADADDRESS)
+
+LINKFLAGS=		-T ldscript
+
+EXTRA_CLEAN+=		netbsd.map assym.d ldscript tmp
+
+netbsd:	ldscript	# XXX
+
+# generate ldscript from common template
+ldscript: ${THISARM}/conf/ldscript.zaurus ${THISARM}/conf/Makefile.zaurus.inc Makefile
+	${TOOL_SED} -e 's/@KERNEL_BASE_PHYS@/${KERNEL_BASE_PHYS}/' \
+	    -e 's/@KERNEL_BASE_VIRT@/${KERNEL_BASE_VIRT}/' \
+	    ${THISARM}/conf/ldscript.zaurus > tmp && mv tmp $@

cvs diff -r1.3 -r1.4 src/sys/arch/zaurus/conf/std.zaurus (expand / switch to context diff)
--- src/sys/arch/zaurus/conf/std.zaurus 2008/01/27 12:37:12 1.3
+++ src/sys/arch/zaurus/conf/std.zaurus 2012/01/20 15:00:27 1.4
@@ -1,4 +1,4 @@
-#	$NetBSD: std.zaurus,v 1.3 2008/01/27 12:37:12 chris Exp $
+#	$NetBSD: std.zaurus,v 1.4 2012/01/20 15:00:27 nonaka Exp $
 #
 # standard NetBSD/zaurus options
 
@@ -13,7 +13,8 @@
 # To support easy transit to ../arch/arm/arm32
 options 	ARM32
 
-#options 	ARM32_NEW_VM_LAYOUT     # Not yet ready for prime-time
+makeoptions	KERNEL_BASE_PHYS="0xa0200000"
+makeoptions	LOADADDRESS="0xc0200000"
 
 options 	ARM_INTR_IMPL="<arch/arm/xscale/pxa2x0_intr.h>"
 

File Deleted: src/sys/arch/zaurus/conf/Attic/ldscript

File Added: src/sys/arch/zaurus/conf/ldscript.zaurus
/*	$NetBSD: ldscript.zaurus,v 1.3 2012/01/20 15:00:27 nonaka Exp $	*/

OUTPUT_ARCH(arm)
ENTRY(KERNEL_BASE_phys)
SECTIONS
{
  KERNEL_BASE_phys = @KERNEL_BASE_PHYS@;
  KERNEL_BASE_virt = @KERNEL_BASE_VIRT@;

  /* 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) + (ADDR(.data) - ADDR(.text)))
  {
    __data_start = . ;
    *(.data)
    *(.data.*)
  }
  .sdata     : 
  AT (LOADADDR(.data) + (ADDR(.sdata) - ADDR(.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 = .);
  .note.netbsd.ident :
  {
    KEEP(*(.note.netbsd.ident));
  }
}

cvs diff -r1.4 -r1.5 src/sys/arch/zaurus/zaurus/kloader_machdep.c (expand / switch to context diff)
--- src/sys/arch/zaurus/zaurus/kloader_machdep.c 2011/11/20 04:07:50 1.4
+++ src/sys/arch/zaurus/zaurus/kloader_machdep.c 2012/01/20 15:00:27 1.5
@@ -1,7 +1,7 @@
-/*	$NetBSD: kloader_machdep.c,v 1.4 2011/11/20 04:07:50 nonaka Exp $	*/
+/*	$NetBSD: kloader_machdep.c,v 1.5 2012/01/20 15:00:27 nonaka Exp $	*/
 
 /*-
- * Copyright (c) 2009 NONAKA Kimihiro <nonaka@netbsd.org>
+ * Copyright (c) 2009-2012 NONAKA Kimihiro <nonaka@netbsd.org>
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -27,7 +27,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: kloader_machdep.c,v 1.4 2011/11/20 04:07:50 nonaka Exp $");
+__KERNEL_RCSID(0, "$NetBSD: kloader_machdep.c,v 1.5 2012/01/20 15:00:27 nonaka Exp $");
 
 #include "debug_kloader.h"
 
@@ -44,9 +44,7 @@
 
 #include <zaurus/zaurus/zaurus_var.h>
 
-#ifndef KERNEL_BASE
-#define	KERNEL_BASE	0xc0000000
-#endif
+#define	KERNEL_TEXT_BASE	((vaddr_t)&KERNEL_BASE_virt)
 
 kloader_jumpfunc_t kloader_zaurus_jump __attribute__((__noreturn__));
 kloader_bootfunc_t kloader_zaurus_boot __attribute__((__noreturn__));
@@ -78,8 +76,9 @@
     struct kloader_bootinfo *kbi, struct kloader_page_tag *tag)
 {
 	extern int kloader_howto;
-	void (*bootinfop)(void *, void *) = (void *)(0xc0200000 - PAGE_SIZE);
-	uint32_t *bootmagicp = (uint32_t *)(0xc0200000 - BOOTARGS_BUFSIZ);
+	extern char KERNEL_BASE_virt[];
+	void (*bootinfop)(void *, void *);
+	uint32_t *bootmagicp;
 	vaddr_t top, ptr;
 	struct bootinfo *bootinfo;
 	struct btinfo_howto *bi_howto;
@@ -88,11 +87,13 @@
 	disable_interrupts(I32_bit|F32_bit);	
 
 	/* copy 2nd boot-loader to va=pa page */
+	bootinfop = (void *)(KERNEL_TEXT_BASE - PAGE_SIZE);
 	memmove(bootinfop, func, PAGE_SIZE);
 
 	/*
 	 * make bootinfo
 	 */
+	bootmagicp = (uint32_t *)(KERNEL_TEXT_BASE - BOOTARGS_BUFSIZ);
 	memset(bootmagicp, 0, BOOTARGS_BUFSIZ);
 	bootinfo = (struct bootinfo *)(bootmagicp + 1);
 	bootinfo->nentries = 0;
@@ -119,8 +120,7 @@
 		ptr += bi_rootdv->common.len;
 	}
 
-	if (bootinfo->nentries > 0)
-		*bootmagicp = BOOTARGS_MAGIC;
+	*bootmagicp = BOOTARGS_MAGIC;
 	cpu_idcache_wbinv_all();
 
 	/* jump to 2nd boot-loader */
@@ -140,7 +140,7 @@
 	vaddr_t va;
 	int error;
 
-	va = KERNEL_BASE + pa - 0xa0000000UL;
+	va = KERNEL_BASE + pa - PXA2X0_SDRAM0_START;
 	error = pmap_enter(pmap_kernel(), va, pa, VM_PROT_ALL, 0);
 	if (error) {
 		printf("%s: map failed: pa=0x%lx, va=0x%lx, error=%d\n",

cvs diff -r1.27 -r1.28 src/sys/arch/zaurus/zaurus/machdep.c (expand / switch to context diff)
--- src/sys/arch/zaurus/zaurus/machdep.c 2011/11/12 04:39:19 1.27
+++ src/sys/arch/zaurus/zaurus/machdep.c 2012/01/20 15:00:27 1.28
@@ -1,4 +1,4 @@
-/*	$NetBSD: machdep.c,v 1.27 2011/11/12 04:39:19 nonaka Exp $	*/
+/*	$NetBSD: machdep.c,v 1.28 2012/01/20 15:00:27 nonaka Exp $	*/
 /*	$OpenBSD: zaurus_machdep.c,v 1.25 2006/06/20 18:24:04 todd Exp $	*/
 
 /*
@@ -107,7 +107,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.27 2011/11/12 04:39:19 nonaka Exp $");
+__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.28 2012/01/20 15:00:27 nonaka Exp $");
 
 #include "opt_ddb.h"
 #include "opt_kgdb.h"
@@ -179,8 +179,7 @@
 #endif
 
 /* Kernel text starts 2MB in from the bottom of the kernel address space. */
-#define	KERNEL_TEXT_OFFSET	0x00200000
-#define	KERNEL_TEXT_BASE	(KERNEL_BASE + KERNEL_TEXT_OFFSET)
+#define	KERNEL_TEXT_BASE	((vaddr_t)&KERNEL_BASE_virt)
 #ifndef	KERNEL_VM_BASE
 #define	KERNEL_VM_BASE		(KERNEL_BASE + 0x01000000)
 #endif
@@ -265,7 +264,7 @@
 struct bootinfo *bootinfo;
 struct btinfo_howto *bi_howto;
 
-#define	KERNEL_BASE_PHYS	(PXA2X0_SDRAM0_START + KERNEL_TEXT_OFFSET)
+#define	KERNEL_BASE_PHYS	((paddr_t)&KERNEL_BASE_phys)
 #define	BOOTINFO_PAGE		(KERNEL_BASE_PHYS - PAGE_SIZE)
 
 /* Prototypes */
@@ -640,6 +639,7 @@
 	extern vsize_t xscale_minidata_clean_size; /* used in KASSERT */
 #endif
 	extern vaddr_t xscale_cache_clean_addr;
+	extern char KERNEL_BASE_phys[], KERNEL_BASE_virt[];
 	int loop;
 	int loop1;
 	u_int l1pagetable;
@@ -931,8 +931,9 @@
 
 		textsize = (textsize + PGOFSET) & ~PGOFSET;
 		totalsize = (totalsize + PGOFSET) & ~PGOFSET;
-		
-		logical = KERNEL_TEXT_OFFSET;	/* offset of kernel in RAM */
+
+		/* offset of kernel in RAM */
+		logical = KERNEL_TEXT_BASE - KERNEL_BASE;
 
 		logical += pmap_map_chunk(l1pagetable, KERNEL_BASE + logical,
 		    physical_start + logical, textsize,