测试一下uclinux的时钟中断,最主要是测试一下移动中断向量到0x0c000000
环境: vmware + redhat 9, skyeye 1.2.6_rc1, arm-elf-gcc 2.95
1. boot.s
===============
.globl _start
_start:
ldr pc,=0x0c008000
ldr pc,=0x0c000004
ldr pc,=0x0c000008
ldr pc,=0x0c00000c
ldr pc,=0x0c000010
b .
ldr pc,=0x0c000018
ldr pc,=0x0c00001c
2. boot.lds
===============
OUTPUT_FORMAT("elf32-littlearm","elf32-littlearm","elf32-littlearm")
OUTPUT_ARCH(arm)
ENTRY(_start)
SECTIONS
{
. = 0x00000000;
.text :
{
boot.o (.text)
}
. = ALIGN(4);
.data :
{
*(.data)
}
}
3. start.s
===============
.equ INTCON, 0x01e00000
.equ INTMSK, 0x01e0000c
.equ LOCKTIME, 0x01d8000c
.equ PLLCON, 0x01d80000
.equ CLKCON, 0x01d80004
.equ WTCON, 0x01d30000
.equ I_ISPR, 0x01e00020
.equ I_ISPC, 0x01e00024
.equ TCFG0, 0x01d50000
.equ TCFG1, 0x01d50004
.equ TCON, 0x01d50008
.equ TCNTB5, 0X01d50048
.equ UTXH0, 0x01d00020
.equ UFCON0, 0x01d00008
.equ ULCON0, 0x01d00000
.equ UCON0, 0x01d00004
.equ UBRDIV0, 0x01d00028
.globl stext
stext:
mov r0,#0x80 | 0x40 | 0x12 @ irq mode, for set irq sp
msr cpsr_c,r0
ldr sp, =0x0c700000
mrs r0, cpsr @ to svc mode
and r0,r0,#0xffffffe0
orr r0,r0,#0x13
msr cpsr_c,r0
@ mov r0, #0x80 | 0x40 | 0x13
@ msr cpsr_c,r0
ldr r0,=WTCON @ disable watch dog
ldr r1, =0x0
str r1, [r0]
ldr r0, =INTCON @ non-vector mode, enable irq, diasable fiq
ldr r1, =0x5
str r1, [r0]
ldr r0, =LOCKTIME
ldrb r1, =800
strb r1, [r0]
ldr r0, =PLLCON
ldr r1, =0x34031
str r1,[r0]
ldr r0, =CLKCON
ldr r1, =0x7ff8
str r1, [r0]
@ UART 0
ldr r0,=UFCON0
mov r1,#0x0
str r1,[r0]
ldr r0,=ULCON0
mov r1,#0x03
str r1,[r0]
ldr r0,=UCON0
mov r1,#0x05
str r1,[r0]
ldr r0,=UBRDIV0
mov r1,#32
str r1,[r0]
@ set timer
ldr r0,=TCON
ldr r1,=0x0
str r1,[r0] @ clear bit 24,25,26
ldr r0,=TCFG0
ldr r2,[r0]
ldr r1,=0xff00ffff
and r2, r2, r1
ldr r1,=0x000f0000
orr r2, r2, r1
str r2,[r0]
ldr r0,=TCFG1
ldr r2,[r0]
ldr r1,=0x00f00000
and r2,r2,r1
str r2,[r0]
ldr r1, =20625 @ 66M / 32 (prescaler) / 100 (HZ)
ldr r0, =TCNTB5
str r1,[r0]
ldr r0, =TCON
ldr r1, [r0]
orr r1, r1,#0x06000000 @ update TCNT5,start
str r1,[r0]
ldr r1, [r0]
ldr r2, =0xfdffffff
and r1,r1,r2
ldr r2, =0x01000000
orr r1,r1,r2
str r1,[r0]
ldr r0,=UTXH0 @ 'C'
mov r1,#0x43
str r1,[r0]
@ sp
ldr sp,=0x0c700000
ldr r0, =INTMSK
ldr r1, =0x03fffeff @ enable global,timer5
str r1, [r0]
ldr r0,=0xffffff7f @ clear
mrs r1,cpsr
and r1,r1,r0
msr cpsr_c,r1
bl start_kernel
.ltorg
4. main.c
===============
void start_kernel(){
extern void __trap_init(void * ram_base);
__trap_init((void *)0x0c000000);
while(1);
}
5. entry.s
===============
.equ INTCON, 0x01e00000
.equ INTMSK, 0x01e0000c
.equ LOCKTIME, 0x01d8000c
.equ PLLCON, 0x01d80000
.equ CLKCON, 0x01d80004
.equ WTCON, 0x01d30000
.equ I_ISPR, 0x01e00020
.equ I_ISPC, 0x01e00024
.equ TCFG0, 0x01d50000
.equ TCFG1, 0x01d50004
.equ TCON, 0x01d50008
.equ TCNTB5, 0X01d50048
.equ UTXH0, 0x01d00020
.equ UFCON0, 0x01d00008
.equ ULCON0, 0x01d00000
.equ UCON0, 0x01d00004
.equ UBRDIV0, 0x01d00028
.equ jiffies, 0x0c600000
.section ".text.init",#alloc,#execinstr
__stubs_start:
.globl HandleUndef
HandlerUndef:
ldr r0,=UTXH0
mov r1,#0x47 @ 'G'
str r1,[r0]
mov pc,lr
.globl HandlerSWI
HandlerSWI:
ldr r0,=UTXH0
mov r1,#0x48 @ 'H'
str r1,[r0]
mov pc,lr
.globl HandlerPabort
HandlerPabort:
ldr r0,=UTXH0
mov r1,#0x49 @ 'I'
str r1,[r0]
mov pc,lr
.globl HandlerDabort
HandlerDabort:
ldr r0,=UTXH0
mov r1,#0x4A @ 'J'
str r1,[r0]
mov pc,lr
.globl HandlerFIQ
HandlerFIQ:
ldr r0,=UTXH0
mov r1,#0x4B @ 'K'
str r1,[r0]
mov pc,lr
.globl IrqISR
IrqISR:
sub sp,sp,#4
@str lr,[sp,#4] @ save lr
stmfd sp!,{r8,r9}
ldr r0,=UTXH0
mov r1,#0x45 @ print 'E'
str r1,[r0]
ldr r9,=I_ISPR
ldr r9,[r9]
cmp r9,#0x0
beq 2f
mov r8,#0
0: movs r9,r9,lsr #1
bcs 1f
add r8,r8,#4
b 0b
1: ldr r9,=HandleADC
add r9,r9,r8
ldr r9,[r9]
str r9,[sp,#8]
ldmfd sp!,{r8-r9,pc}
2: ldmfd sp!,{r8-r9}
add sp,sp,#4
subs pc,lr,#4
.ltorg
HandlerTimer5:
ldr r0, =jiffies
ldr r1,[r0]
add r1,r1,#1
str r1,[r0]
ldr r0,=UTXH0 @ display 'A'
mov r1,#0x41
str r1,[r0]
ldr r0,=I_ISPC
mov r2,#0x100 @ clear I_ISPR timer5 bit
str r2,[r0]
timer5_end:
subs pc,lr,#4 @ subs pc,r14_svc,#4
.ltorg
.align 4
HandleADC: .word 0
.word 0
.word 0
.word 0
.word 0
.word 0 @ 6th
.word 0
.word 0
HandleTimer5: .word HandlerTimer5
.word 0
.word 0
.word 0
.word 0
.word 0
.word 0
.word 0 @ 16th
.word 0
.word 0
.word 0
.word 0
.word 0
.word 0
.word 0
.word 0
.word 0
.word 0 @ 26th
__stubs_end:
@.equ __real_stubs_start, ram_vector + 0x200
ram_vector:
swi 0
b ram_vector + 0x200 + (HandlerUndef - __stubs_start)
b ram_vector + 0x200 + (HandlerSWI - __stubs_start)
b ram_vector + 0x200 + (HandlerPabort - __stubs_start)
b ram_vector + 0x200 + (HandlerDabort - __stubs_start)
b .
b ram_vector + 0x200 + (IrqISR - __stubs_start)
b ram_vector + 0x200 + (HandlerFIQ - __stubs_start)
.globl __trap_init
__trap_init:
stmfd sp!,{r4-r12,lr} @ Save link register
adr r1, ram_vector @ set up the vectors
ldmia r1, {r2-r12}
stmia r0, {r2-r12}
mov r4, r0
add r2, r0, #0x200
adr r0, __stubs_start @ copy stubs to 0x200
adr r1, __stubs_end
1: ldr r3, [r0], #4
str r3, [r2], #4
cmp r0, r1
blt 1b
mov r0, r4
ldr r0, =TCON
ldr r1, =0x05000000 @ update TCNT5,start
str r1,[r0]
ldmfd sp!,{r4-r12,pc}
6. timer5.lds
=====================
OUTPUT_FORMAT("elf32-littlearm","elf32-littlearm","elf32-littlearm")
OUTPUT_ARCH(arm)
ENTRY(stext)
SECTIONS
{
. = 0x0c008000;
.text :
{
start.o (.text)
*(.text.init)
*(.text)
}
. = ALIGN(4);
.data :
{
*(.data)
}
}
7. Makefile
======================
all: boot timer5
boot.o: boot.s
arm-elf-as -o boot.o boot.s
boot: boot.o
arm-elf-ld -T boot.lds -o boot boot.o
arm-elf-objcopy -O binary boot boot.bin
timer5: start.o main.o entry.o
arm-elf-ld -T timer5.lds -o timer5 start.o main.o entry.o
arm-elf-objcopy -O binary timer5 timer5.bin
start.o: start.s
arm-elf-as --gstabs -o start.o start.s
main.o: main.c
arm-elf-gcc -ggdb -c -o main.o main.c
entry.o: entry.s
arm-elf-as --gstabs -o entry.o entry.s
.PHONY: clean
clean:
rm -f boot boot.o boot.bin
rm -f timer5 timer5.bin start.o main.o entry.o
8. skyeye.conf
=================
# skyeye config file for S3C44B0X
cpu: arm7tdmi
mach: s3c44b0x
# physical memory
mem_bank: map=M, type=RW, addr=0x00000000, size=0x00200000, file=boot.bin
mem_bank: map=M, type=RW, addr=0x0c000000, size=0x00800000
# peripherals I/O mapping area
mem_bank: map=I, type=RW, addr=0x01c00000, size=0x00400000
上述所有文件在同一目录
9. 运行: skyeye -e timer5
阅读(883) | 评论(0) | 转发(0) |