URL
https://opencores.org/ocsvn/amber/amber/trunk
Subversion Repositories amber
[/] [amber/] [trunk/] [sw/] [boot-loader-serial/] [start.S] - Rev 82
Go to most recent revision | Compare with Previous | Blame | View Log
/*----------------------------------------------------------------// //// start.S //// //// This file is part of the Amber project //// http://www.opencores.org/project,amber //// //// Description //// Assembly routines for boot-loader. //// As boot-loader is a stand-alone application, it needs a //// simple start function written in assembly to call the //// C code main() function. //// //// Author(s): //// - Conor Santifort, csantifort.amber@gmail.com //// ////////////////////////////////////////////////////////////////////// //// Copyright (C) 2010 Authors and OPENCORES.ORG //// //// This source file may be used and distributed without //// restriction provided that this copyright statement is not //// removed from the file and that any derivative work contains //// the original copyright notice and the associated disclaimer. //// //// This source file is free software; you can redistribute it //// and/or modify it under the terms of the GNU Lesser General //// Public License as published by the Free Software Foundation; //// either version 2.1 of the License, or (at your option) any //// later version. //// //// This source 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 Lesser General Public License for more //// details. //// //// You should have received a copy of the GNU Lesser General //// Public License along with this source; if not, download it //// from http://www.opencores.org/lgpl.shtml //// //----------------------------------------------------------------*/#include "amber_registers.h"/* Defined in vmlinux/include/asm-arm/setup.h */#define ATAG_CORE 0x54410001#define ATAG_MEM 0x54410002#define ATAG_INITRD 0x54410005#define ATAG_RAMDISK 0x54410004#define ATAG_NONE 0x00000000#define ATAG_CORE_SIZE ((2*4 + 3*4) >> 2)#define ATAG_MEM_SIZE ((2*4 + 2*4) >> 2)#define ATAG_INITRD_SIZE ((2*4 + 2*4) >> 2)#define ATAG_RAMDISK_SIZE ((2*4 + 3*4) >> 2)/* from vmlinux/arch/arm/kernel/compat.c */#define FLAG_READONLY 1/* from the list in wmlinux/arch/arm/tools/mach-types */#define MACH_TYPE_A5K 11.section .text.globl startstart:/* 0x00 Reset Interrupt vector address */b startup/* 0x04 Undefined Instruction Interrupt vector address */b _testfail/* 0x08 SWI Interrupt vector address */b _testfail/* 0x0c Prefetch abort Interrupt vector address */b _testfail/* 0x10 Data abort Interrupt vector address */b _testfailb _testfail/* 0x18 IRQ vector address */b _testfail/* 0x1c FIRQ vector address */b _testfailstartup:/* Unset interrupt mask bits, stay in svc mode */mov r0, #0x00000003teqp pc, r0@ Enable the cachemov r0, #0xffffffffmcr 15, 0, r0, cr3, cr0, 0 @ cacheable areamov r0, #1mcr 15, 0, r0, cr2, cr0, 0 @ cache enable@ init SPldr sp, AdrStack@ Set 32MB memory modeldr r0, AdrMemCtrlmov r1, #1str r1, [r0].extern mainbl main@ jump to program at r0.globl _jump_to_program_jump_to_program:@ ----------------------------------------------@ Copy ATAG structure to AdrBootParams@ ----------------------------------------------ldr r1, AdrBootParamsldr r2, AdrATAGBaseldr r3, AdeEndATAG1: cmp r2, r3beq 2fldr r4, [r2], #4str r4, [r1], #4b 1b@ Set memc page tables2: ldr r2, AdrPageTabesmov r3, #0mov r4, #403: str r3,[r2],#4subs r4, r4, #1bne 3b@ ----------------------------------------------@ jump to start of program in svc mode with interrupts disabled@ ----------------------------------------------mov r4, r0orr r4, #0x0c000003mov r0, #0mov pc, r4@ ----------------------------------------------@ Print CPU Core status@ ----------------------------------------------.globl _core_status_core_status:stmdb sp!,{lr}stmdb sp!,{r0-r12}mov r4, #0mov r5, spmov r6, lr1: ldr r0, =Status_Messagemov r1, r4ldr r2, [r5], #4bl printfcmp r4, #13addne r4, r4, #1bne 1b@ Stack Pointerldr r0, =SPStatus_Messagemov r1, spbl printf@ Program Counter - Use Link Register value because@ want the PC value of whatever called this functionldr r0, =PCStatus_Messagesub r1, r6, #4bl printfldmia sp!,{r0-r12}ldmia sp!,{pc}^/* stack at top of ddr3 memory space */AdrStack: .word 0x02000000AdrMemCtrl: .word ADR_AMBER_TEST_MEM_CTRL/* core status messages */Status_Message: .ascii "r%2d %08x\n\00"SPStatus_Message: .ascii "sp %08x\n\00"PCStatus_Message: .ascii "pc %08x\n\00".align 2AdrATAGBase: .word ATAGBaseAdeEndATAG: .word EndATAGATAGBase: .word ATAG_CORE_SIZE.word ATAG_CORE.word FLAG_READONLY @ flags.word 4096 @ page size.word 0x0 @ rootdev.word ATAG_MEM_SIZE.word ATAG_MEM.word 32*1024*1024 @ size - 32MB.word 0x0 @ start.word ATAG_RAMDISK_SIZE.word ATAG_RAMDISK.word 1 @ flags: bit 0 = load, bit 1 = prompt.word 0x000000d0 @ size in 1k blocks.word 0x00800000 @ physical address of start of ramdisk.word ATAG_INITRD_SIZE.word ATAG_INITRD.word 0x02800000 @ virtual address of start of initrd image.word 0x00032000 @ size = 200k.word ATAG_NONE.word 0x0EndATAG: .word 0x0AdrBootParams: .word 0x7c000AdrPageTabes: .word 0x3f01000
Go to most recent revision | Compare with Previous | Blame | View Log
