startup code

This commit is contained in:
Mariano Alvira 2009-04-15 15:03:47 -04:00
parent f4312f7cf6
commit 721173449c
7 changed files with 232 additions and 15 deletions

View file

@ -58,11 +58,11 @@ ALL = $(TESTS:.c=.srec) $(TESTS:.c=.bin) $(TESTS:.c=.dis)
.PRECIOUS: $(COBJS) $(TARGETS) $(TESTS:.c=.obj) .PRECIOUS: $(COBJS) $(TARGETS) $(TESTS:.c=.obj)
all: $(ALL) all: src/start.o $(ALL)
tests/nvm-read.obj: src/maca.o tests/nvm-read.obj: src/maca.o
tests/rftest-rx.obj: src/maca.o tests/rftest-rx.obj: src/maca.o
tests/rftest-tx.obj: src/maca.o tests/rftest-tx.obj: src/maca.o
%.srec: %.obj %.srec: %.obj
$(OBJCOPY) ${OBJCFLAGS} -O srec $< $@ $(OBJCOPY) ${OBJCFLAGS} -O srec $< $@
@ -74,10 +74,9 @@ tests/rftest-tx.obj: src/maca.o
$(OBJCOPY) ${OBJCFLAGS} -O binary $< $@ $(OBJCOPY) ${OBJCFLAGS} -O binary $< $@
%.dis: %.obj %.dis: %.obj
$(OBJDUMP) -d $< > $@ $(OBJDUMP) -D $< > $@
%.obj: $(LDSCRIPT) %.o %.obj: $(LDSCRIPT) %.o
echo $*.o
$(LD) $(LDFLAGS) $(AOBJS) \ $(LD) $(LDFLAGS) $(AOBJS) \
--start-group $(PLATFORM_LIBS) --end-group \ --start-group $(PLATFORM_LIBS) --end-group \
-Map $*.map $^ -o $@ -Map $*.map $^ -o $@

View file

@ -32,7 +32,7 @@ SECTIONS
. = ALIGN(4); . = ALIGN(4);
.text : .text :
{ {
*(startup) src/start.o (.text)
*(.text) *(.text)
} }

View file

@ -407,6 +407,7 @@ typedef union maca_maskirq_reg_tag
void reset_maca(void); void reset_maca(void);
void init_phy(void); void init_phy(void);
void vreg_init(void);
void ResumeMACASync(void); void ResumeMACASync(void);
void radio_init(void); void radio_init(void);
void set_power(uint8_t power); void set_power(uint8_t power);

40
include/nvm.h Normal file
View file

@ -0,0 +1,40 @@
#ifndef NVM_H
#define NVM_H
typedef enum
{
gNvmType_NoNvm_c,
gNvmType_SST_c,
gNvmType_ST_c,
gNvmType_ATM_c,
gNvmType_Max_c
} nvmType_t;
typedef enum
{
gNvmErrNoError_c = 0,
gNvmErrInvalidInterface_c,
gNvmErrInvalidNvmType_c,
gNvmErrInvalidPointer_c,
gNvmErrWriteProtect_c,
gNvmErrVerifyError_c,
gNvmErrAddressSpaceOverflow_c,
gNvmErrBlankCheckError_c,
gNvmErrRestrictedArea_c,
gNvmErrMaxError_c
} nvmErr_t;
typedef enum
{
gNvmInternalInterface_c,
gNvmExternalInterface_c,
gNvmInterfaceMax_c
} nvmInterface_t;
/* ROM code seems to be THUMB */
/* need to be in a THUMB block before calling them */
volatile nvmErr_t (*nvm_detect)(nvmInterface_t nvmInterface,nvmType_t* pNvmType) = 0x00006cb9;
volatile nvmErr_t (*nvm_read)(nvmInterface_t nvmInterface , nvmType_t nvmType , void *pDest, uint32_t address, uint32_t numBytes);
#endif //NVM_H

View file

@ -1,3 +1,4 @@
#include "embedded_types.h"
#include "maca.h" #include "maca.h"
#define reg(x) (*(volatile uint32_t *)(x)) #define reg(x) (*(volatile uint32_t *)(x))

177
src/start.S Normal file
View file

@ -0,0 +1,177 @@
/*
* armboot - Startup Code for ARM720 CPU-core
*
* Copyright (c) 2001 Marius Gröger <mag@sysgo.de>
* Copyright (c) 2002 Alex Züpke <azu@sysgo.de>
*
* 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
*/
/*
*************************************************************************
*
* Jump vector table as in table 3.1 in [1]
*
*************************************************************************
*/
.globl _start
_start: b main
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
/*
*************************************************************************
*
* Startup Code (reset vector)
*
* do important init only if we don't start from memory!
* relocate armboot to ram
* setup stack
* jump to second stage
*
*************************************************************************
*/
_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
_start_armboot: .word main
/*
*************************************************************************
*
* CPU_init_critical registers
*
*************************************************************************
*/
cpu_init_crit:
# actually do nothing for now!
mov pc, lr
/*
*************************************************************************
*
* Interrupt handling
*
*************************************************************************
*/
@
@ IRQ stack frame.
@
#define S_FRAME_SIZE 72
#define S_OLD_R0 68
#define S_PSR 64
#define S_PC 60
#define S_LR 56
#define S_SP 52
#define S_IP 48
#define S_FP 44
#define S_R10 40
#define S_R9 36
#define S_R8 32
#define S_R7 28
#define S_R6 24
#define S_R5 20
#define S_R4 16
#define S_R3 12
#define S_R2 8
#define S_R1 4
#define S_R0 0
#define MODE_SVC 0x13
#define I_BIT 0x80
.macro get_irq_stack @ setup IRQ stack
ldr sp, IRQ_STACK_START
.endm
.macro get_fiq_stack @ setup FIQ stack
ldr sp, FIQ_STACK_START
.endm
/*
* exception handlers
*/
.align 5
undefined_instruction:
.align 5
software_interrupt:
.align 5
prefetch_abort:
nop
.align 5
data_abort:
.align 5
not_used:
.align 5
irq:
.align 5
fiq:
.align 5
.globl reset_cpu
reset_cpu:
mov pc, r0

View file

@ -14,6 +14,7 @@
#include "embedded_types.h" #include "embedded_types.h"
#include "nvm.h" #include "nvm.h"
#include "maca.h"
#define reg(x) (*(volatile uint32_t *)(x)) #define reg(x) (*(volatile uint32_t *)(x))
@ -30,8 +31,7 @@ const uint8_t hex[16]={'0','1','2','3','4','5','6','7',
__attribute__ ((section ("startup"))) __attribute__ ((section ("startup")))
void main(void) { void main(void) {
uint8_t c; uint32_t type=0xdeadbeef;
uint32_t type;
nvmErr_t err; nvmErr_t err;
*(volatile uint32_t *)GPIO_PAD_DIR0 = 0x00000100; *(volatile uint32_t *)GPIO_PAD_DIR0 = 0x00000100;
@ -55,9 +55,9 @@ void main(void) {
vreg_init(); vreg_init();
puts("CRM status: 0x"); // puts("CRM status: 0x");
put_hex32(reg(0x80003018)); // put_hex32(reg(0x80003018));
puts("\n\r"); // puts("\n\r");
puts("Detecting internal nvm\n\r"); puts("Detecting internal nvm\n\r");
@ -66,11 +66,10 @@ void main(void) {
puts("nvm_detect returned: 0x"); puts("nvm_detect returned: 0x");
put_hex(err); put_hex(err);
puts(" type is: 0x"); puts(" type is: 0x");
put_hex(type); put_hex32(type);
puts("\n\r"); puts("\n\r");
while(1) { while(1) {continue;};
};
} }
void putc(uint8_t c) { void putc(uint8_t c) {