Kernel load address can be changed now.

This commit is contained in:
nonaka 2012-01-20 15:00:27 +00:00
parent e8bec33be1
commit 9587ee6530
5 changed files with 40 additions and 28 deletions

View File

@ -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 @@ CPPFLAGS+= -D${MACHINE}
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 @@ SYSTEM_LD_TAIL_EXTRA+=; \
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 $@

View File

@ -1,11 +1,11 @@
/* $NetBSD: ldscript,v 1.1 2006/12/17 16:07:11 peter Exp $ */
/* $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 = 0xa0200000;
KERNEL_BASE_virt = 0xc0200000;
KERNEL_BASE_phys = @KERNEL_BASE_PHYS@;
KERNEL_BASE_virt = @KERNEL_BASE_VIRT@;
/* Kernel start: */
.start (KERNEL_BASE_phys) :

View File

@ -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 @@ options EXEC_SCRIPT
# 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>"

View File

@ -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 @@ __KERNEL_RCSID(0, "$NetBSD: kloader_machdep.c,v 1.4 2011/11/20 04:07:50 nonaka E
#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 @@ kloader_zaurus_jump(kloader_bootfunc_t func, vaddr_t sp,
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 @@ kloader_zaurus_jump(kloader_bootfunc_t func, vaddr_t sp,
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 @@ kloader_zaurus_jump(kloader_bootfunc_t func, vaddr_t sp,
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 @@ kloader_phystov(paddr_t pa)
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",

View File

@ -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 @@ __KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.27 2011/11/12 04:39:19 nonaka Exp $");
#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 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 @@ initarm(void *arg)
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 @@ initarm(void *arg)
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,