Add support for relocating gzboot's .text out of flash and into

RAM (while still decompressing the image directly from flash).

This makes gzboot run a LOT faster.
This commit is contained in:
thorpej 2002-02-24 20:29:44 +00:00
parent 5f15cedc89
commit 39c165f331
5 changed files with 107 additions and 11 deletions

View File

@ -1,7 +1,7 @@
OUTPUT_FORMAT("elf32-littlearm", "elf32-bigarm",
"elf32-littlearm")
OUTPUT_ARCH(arm)
ENTRY(start)
ENTRY(FLASH)
MEMORY
{
/* We will locate the .text section in flash, and run directly
@ -12,27 +12,32 @@ MEMORY
}
SECTIONS
{
FLASH = 0x80000;
/* Read-only sections, merged into text segment: */
__text_store = FLASH;
.text :
AT (FLASH)
{
*(.text)
*(.text.*)
*(.stub)
*(.glue_7t) *(.glue_7)
*(.rodata) *(.rodata.*)
} > flash =0
} > sdram =0
PROVIDE (__etext = .);
PROVIDE (_etext = .);
PROVIDE (etext = .);
__data_store = FLASH + SIZEOF(.text);
.data :
AT (ADDR(.text) + SIZEOF(.text))
AT (FLASH + SIZEOF(.text))
{
__data_start = . ;
*(.data)
*(.data.*)
} > sdram
.sdata :
AT (ADDR(.text) + SIZEOF(.text) + SIZEOF(.data))
AT (FLASH + SIZEOF(.text) + SIZEOF(.data))
{
*(.sdata)
*(.sdata.*)
@ -67,4 +72,9 @@ SECTIONS
_end = .;
_bss_end__ = . ; __bss_end__ = . ; __end__ = . ;
PROVIDE (end = .);
.image (FLASH + SIZEOF(.text) + SIZEOF(.data) + SIZEOF(.sdata)) :
AT (FLASH + SIZEOF(.text) + SIZEOF(.data) + SIZEOF(.sdata))
{
*(.image)
}
}

View File

@ -1,4 +1,4 @@
# $NetBSD: Makefile.gzboot,v 1.3 2002/02/23 20:19:52 thorpej Exp $
# $NetBSD: Makefile.gzboot,v 1.4 2002/02/24 20:29:44 thorpej Exp $
NOMAN= # defined
@ -26,7 +26,7 @@ LIBCRTEND=
.PATH: ${EVBARM_STAND}/gzboot
.PATH: ${EVBARM_STAND}/board
SRCS+= gzboot.c image.c
SRCS+= gzboot.c image.S
STARTFILE= srtbegin.o
@ -86,7 +86,7 @@ cleandir distclean: cleanlibdir
cleanlibdir:
rm -rf lib
LDFLAGS= -M -e start -T ${LDSCRIPT}
LDFLAGS= -M -T ${LDSCRIPT}
LIBLIST=${LIBSA} ${LIBZ} ${LIBSA} ${LIBKERN} ${LIBSA}

View File

@ -0,0 +1,53 @@
/* $NetBSD: image.S,v 1.1 2002/02/24 20:29:44 thorpej Exp $ */
/*
* Copyright (c) 2002 Wasabi Systems, Inc.
* All rights reserved.
*
* Written by Jason R. Thorpe for Wasabi Systems, Inc.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed for the NetBSD Project by
* Wasabi Systems, Inc.
* 4. The name of Wasabi Systems, Inc. may not be used to endorse
* or promote products derived from this software without specific prior
* written permission.
*
* THIS SOFTWARE IS PROVIDED BY WASABI SYSTEMS, INC. ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL WASABI SYSTEMS, INC
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
#include <machine/asm.h>
.section .image,"a",%progbits
.global _C_LABEL(md_root_loadaddr)
_C_LABEL(md_root_loadaddr):
.word LOADADDR
.global _C_LABEL(md_root_size)
_C_LABEL(md_root_size):
.word MAXIMAGESIZE
.global _C_LABEL(md_root_image)
_C_LABEL(md_root_image):
.asciz "|This is the gzboot image!\n"
.org _C_LABEL(md_root_image) + MAXIMAGESIZE;

View File

@ -1,4 +1,4 @@
/* $NetBSD: srtbegin.S,v 1.2 2002/02/23 18:19:09 thorpej Exp $ */
/* $NetBSD: srtbegin.S,v 1.3 2002/02/24 20:29:44 thorpej Exp $ */
/*
* Copyright (c) 2002 Wasabi Systems, Inc.
@ -55,7 +55,31 @@ ENTRY(start)
nop
/*
* Check to see if &_etext == &__data_start. If not,
* Check to see if __text_store == &start. If not, we're most
* likely running from flash. Flash is slow, and we'd
* really like to run the code from RAM. Copy it out.
*/
add r1, pc, #(Ltext - . - 8)
ldmia r1, {r1-r3}
cmp r1, r2 /* RELOC == &start? */
beq relocated /* yes, in RAM */
/* Copy text segment from ROM to RAM */
1: ldrb r0, [r1], #0x01
strb r0, [r2], #0x01
cmp r2, r3 /* copy done? */
bne 1b
/*
* Okay, we are finished relocating the text segment. Now
* we need to leap to the next instruction.
*/
add r1, pc, #(Lrelocated - . - 8)
ldr pc, [r1]
relocated:
/*
* Check to see if __data_store == __data_start. If not,
* we're most likely built for running from flash,
* and must copy the data segment out to RAM.
*/
@ -88,8 +112,16 @@ ENTRY(start)
b _C_LABEL(main)
Ldata:
Lrelocated:
.word relocated
Ltext:
.word _C_LABEL(__text_store)
.word _C_LABEL(start)
.word _C_LABEL(_etext)
Ldata:
.word _C_LABEL(__data_store)
.word _C_LABEL(__data_start)
Lbss:

View File

@ -1,7 +1,8 @@
$NetBSD: version,v 1.1 2002/02/23 05:41:14 thorpej Exp $
$NetBSD: version,v 1.2 2002/02/24 20:29:44 thorpej Exp $
NOTE ANY CHANGES YOU MAKE TO THE BOOTBLOCKS HERE. The format of this
file is important - make sure the entries are appended on end, last item
is taken as the current.
1.0: Gzip Boot, for booting compressed kernel images from flash.
1.1: Add support for relocating gzboot .text from flash to RAM.