From 02fe96ba6f2235e3bfd7f6c76382b88e2d7d660e Mon Sep 17 00:00:00 2001 From: xiangfu Date: Tue, 17 Jun 2008 10:42:35 -0400 Subject: [PATCH] add neo_gta02.h lowlevel_init.S kboot-stage1.lds --- qiboot/src/Makefile | 12 ++--- qiboot/src/kboot.lds | 53 ------------------- qiboot/src/led.S | 118 ++++++++++++++++++++++++++++++++++++++++++- 3 files changed, 122 insertions(+), 61 deletions(-) delete mode 100644 qiboot/src/kboot.lds diff --git a/qiboot/src/Makefile b/qiboot/src/Makefile index 39d2d0d..1e052b2 100644 --- a/qiboot/src/Makefile +++ b/qiboot/src/Makefile @@ -14,18 +14,16 @@ # MA 02111-1307 USA # - - -TEXT_BASE =0x0000000 - +LDS =kboot-stage1.lds INCLUDE =../include IMAGE =../image -CFLAGS =-I $(INCLUDE) -g -c -o +CFLAGS =-Wall -I $(INCLUDE) -g -c -o -all:led.S led.c +all:led.S led.c lowlevel_init.S $(CC) $(CFLAGS) led_S.o led.S $(CC) $(CFLAGS) led_C.o led.c - $(LD) -Ttext $(TEXT_BASE) -g led_S.o led_C.o -o led.o + $(CC) $(CFLAGS) lowlevel_init.o lowlevel_init.S + $(LD) -T$(LDS) -g led_S.o led_C.o lowlevel_init.o -o led.o $(OBJCOPY) -O binary -S led.o $(IMAGE)/led_on clean: diff --git a/qiboot/src/kboot.lds b/qiboot/src/kboot.lds deleted file mode 100644 index 3cc3e58..0000000 --- a/qiboot/src/kboot.lds +++ /dev/null @@ -1,53 +0,0 @@ -/* - * (C) Copyright 2002 - * Gary Jennejohn, DENX Software Engineering, - * - * See file CREDITS for list of people who contributed to this - * project. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License as - * published by the Free Software Foundation; either version 2 of - * the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, - * MA 02111-1307 USA - */ - -OUTPUT_FORMAT("elf32-littlearm", "elf32-littlearm", "elf32-littlearm") -/*OUTPUT_FORMAT("elf32-arm", "elf32-arm", "elf32-arm")*/ -OUTPUT_ARCH(arm) -ENTRY(_start) -SECTIONS -{ - . = 0x00000000; - - . = ALIGN(4); - .text : - { - led_S.o (.text) - led_C.o (.text) - *(.text) - } - - . = ALIGN(4); - .rodata : { *(.rodata) } - - . = ALIGN(4); - .data : { *(.data) } - - . = ALIGN(4); - .got : { *(.got) } - - . = ALIGN(4); - __bss_start = .; - .bss (NOLOAD) : { *(.bss) } - _end = .; -} diff --git a/qiboot/src/led.S b/qiboot/src/led.S index 1d5ccc1..52c4bf5 100644 --- a/qiboot/src/led.S +++ b/qiboot/src/led.S @@ -1,5 +1,57 @@ + +#include .globl _start _start: b start_code +/* ldr pc, _undefined_instruction + ldr pc, _software_interrupt + ldr pc, _prefetch_abort + ldr pc, _data_abort + ldr pc, _not_used + ldr pc, _irq + ldr pc, _fiq + +_undefined_instruction: .word undefined_instruction +_software_interrupt: .word software_interrupt +_prefetch_abort: .word prefetch_abort +_data_abort: .word data_abort +_not_used: .word not_used +_irq: .word irq +_fiq: .word fiq + + .balignl 16,0xdeadbeef +*/ + +_TEXT_BASE: + .word TEXT_BASE + +.globl _armboot_start +_armboot_start: + .word _start + +/* + * These are defined in the board-specific linker script. + */ +.globl _bss_start +_bss_start: + .word __bss_start + +.globl _bss_end +_bss_end: + .word _end + +#ifdef CONFIG_USE_IRQ +/* IRQ stack memory (calculated at run-time) */ +.globl IRQ_STACK_START +IRQ_STACK_START: + .word 0x0badc0de + +/* IRQ stack memory (calculated at run-time) */ +.globl FIQ_STACK_START +FIQ_STACK_START: + .word 0x0badc0de +#endif + + start_code: @@ -65,8 +117,28 @@ start_code: mov r1, #0x1a str r1, [r0, #0x28] + bl cpu_init_crit + +stack_setup: + ldr r0, _TEXT_BASE /* upper 128 KiB: relocated uboot */ + sub r0, r0, #CFG_MALLOC_LEN /* malloc area */ + sub r0, r0, #CFG_GBL_DATA_SIZE /* bdinfo */ +#ifdef CONFIG_USE_IRQ + sub r0, r0, #(CONFIG_STACKSIZE_IRQ+CONFIG_STACKSIZE_FIQ) +#endif + sub sp, r0, #12 /* leave 3 words for abort-stack */ + +clear_bss: + ldr r0, _bss_start /* find start of bss segment */ + ldr r1, _bss_end /* stop here */ + mov r2, #0x00000000 /* clear */ + +clbss_l:str r2, [r0] /* clear loop... */ + add r0, r0, #4 + cmp r0, r1 + ble clbss_l + /* blink led */ - ldr sp,=1024*4 .extern blink_led bl blink_led @@ -76,3 +148,47 @@ delay: bne delay mov pc,lr + + +/* + ************************************************************************* + * + * CPU_init_critical registers + * + * setup important registers + * setup memory timing + * + ************************************************************************* + */ + +cpu_init_crit: + /* + * flush v4 I/D caches + */ + mov r0, #0 + mcr p15, 0, r0, c7, c7, 0 /* flush v3/v4 cache */ + mcr p15, 0, r0, c8, c7, 0 /* flush v4 TLB */ + + /* + * disable MMU stuff and caches + */ + mrc p15, 0, r0, c1, c0, 0 + bic r0, r0, #0x00002300 @ clear bits 13, 9:8 (--V- --RS) + bic r0, r0, #0x00000087 @ clear bits 7, 2:0 (B--- -CAM) + orr r0, r0, #0x00000002 @ set bit 2 (A) Align + orr r0, r0, #0x00001000 @ set bit 12 (I) I-Cache + mcr p15, 0, r0, c1, c0, 0 + + /* + * before relocating, we have to setup RAM timing + * because memory timing is board-dependend, you will + * find a lowlevel_init.S in your board directory. + */ + mov ip, lr + +/* bl lowlevel_init*/ + + mov lr, ip + mov pc, lr + +