OpenCores
URL https://opencores.org/ocsvn/openrisc/openrisc/trunk

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [rtos/] [ecos-3.0/] [packages/] [hal/] [arm/] [gps4020/] [current/] [support/] [download/] [gps4020_start.S] - Blame information for rev 786

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 786 skrzyp
//-------------------------------------------------------------------
2
//
3
// gp4020_start.S
4
//
5
//-------------------------------------------------------------------
6
//
7
// Copyright (C) 2003, MLB Associates.
8
//
9
// This file contains basic startup code for the GPS4020 platform.
10
// After initialization, it will call a single "C" function 'main()'
11
//
12
// Note: this program assumes that it has been downloaded into the
13
// on-chip SRAM via the BOOTSTRAP mechanism, so on-chip SRAM is
14
// located at address 0x00000000 and external ROM/FLASH is at
15
// address 0x60000000
16
//
17
 
18
        .macro  lab,lbl
19
.\lbl:  .long   \lbl
20
        .endm
21
 
22
        .macro  blr
23
        mov     pc,lr
24
        .endm
25
 
26
        .equ    MPC_BASE_ADDRESS,         0xE0008000
27
        .equ    MPC_AREA1_CONFIG,         0x00000000
28
        .equ    MPC_AREA2_CONFIG,         0x00000004
29
        .equ    MPC_AREA3_CONFIG,         0x00000008
30
        .equ    MPC_AREA4_CONFIG,         0x0000000C
31
        .equ    GPIO_BASE_ADDRESS,        0xE0005000
32
        .equ    GPIO_DIRECTION_REG_OFFSET,0x00000000
33
        .equ    GPIO_READ_REG_OFFSET,     0x00000004
34
        .equ    GPIO_WRITE_REG_OFFSET,    0x00000008
35
        .equ    UART1_BASE_ADDRESS,       0xE0018000
36
        .equ    UART_TXBUF,               0x00000010
37
        .equ    UART_STATUS,              0x0000000C
38
        .equ    UART_STATUS_TXEMPTY,      0x00000002
39
 
40
        .text
41
        .global __exception_handlers
42
__exception_handlers:
43
         b       reset                           // 0x00
44
         ldr     pc,.undefined_instruction       // 0x04
45
         ldr     pc,.software_interrupt          // 0x08 start && software int
46
         ldr     pc,.abort_prefetch              // 0x0C
47
         ldr     pc,.abort_data                  // 0x10
48
         .word   0                               // unused
49
         ldr     pc,.IRQ                         // 0x18
50
         ldr     pc,.FIQ                         // 0x1C
51
 
52
         .global vectors
53
vectors:
54
         .long   reset                           // 0x20
55
         lab     undefined_instruction           // 0x24
56
         lab     software_interrupt              // 0x28
57
         lab     abort_prefetch                  // 0x2C
58
         lab     abort_data                      // 0x30
59
         .word   0                               // 0x34
60
         lab     IRQ                             // 0x38
61
         lab     FIQ                             // 0x3C
62
 
63
        .arm        @ AKA ".code32"
64
        .align 2     @ Align code on 2^2 = 4 byte intervals
65
 
66
        .global start
67
start:
68
reset:
69
 
70
/*--------------------------------------------------------------------------*/
71
// Setup the GPIO and the ARM registers
72
 
73
// make GPIO[0..7] outputs - note: GPIO4 is used for Rx on UART1!
74
 
75
        ldr     r1,=GPIO_BASE_ADDRESS
76
        ldr    r0, [r1,#GPIO_DIRECTION_REG_OFFSET]
77
        and    r0, r0, #0b00010000    @ 0 = output, 1 = input
78
        str    r0, [r1,#GPIO_DIRECTION_REG_OFFSET]        @ Store value (DON'T use strb)
79
 
80
        ldr     r1,=MPC_BASE_ADDRESS
81
        ldr     r2,=0xFF00002D                  // 0x6xxxxxxx, 16bit R/W RAM
82
        str     r2,[r1,#MPC_AREA1_CONFIG]
83
 
84
        ldr     r1,=MPC_BASE_ADDRESS
85
        ldr     r2,=0x00000069                  // 0x2xxxxxxx, 16bit R/W RAM
86
        str     r2,[r1,#MPC_AREA2_CONFIG]
87
 
88
        ldr     r2,[r1,#MPC_AREA3_CONFIG]
89
        ldr     r2,=0x00000021                  // 0x4xxxxxxx, 16bit peripheral
90
        str     r2,[r1,#MPC_AREA3_CONFIG]
91
 
92
        ldr     r2,[r1,#MPC_AREA4_CONFIG]
93
        ldr     r2,=0x0000006E                  // 0x0xxxxxxx, 32bit memory
94
        str     r2,[r1,#MPC_AREA4_CONFIG]
95
 
96
        ldr     sp,=_stack
97
        bl      main
98
 
99
10:     ldr     r1,=GPIO_BASE_ADDRESS
100
        mov     r0,#0
101
        str    r0, [r1,#GPIO_WRITE_REG_OFFSET]
102
        b       10b
103
 
104
//
105
// Exception handlers
106
//
107
undefined_instruction:      // 0x24
108
        mov     r0,#0x24
109
        b       exception
110
software_interrupt:         // 0x28
111
        mov     r0,#0x28
112
        b       exception
113
abort_prefetch:             // 0x2C
114
        mov     r0,#0x2C
115
        b       exception
116
abort_data:                 // 0x30
117
        mov     r0,#0x30
118
        b       exception
119
IRQ:                        // 0x38
120
        mov     r0,#0x38
121
        b       exception
122
FIQ:                        // 0x3C
123
        mov     r0,#0x3C
124
        b       exception
125
 
126
exception:
127
        mov     r8,lr       // Location of failure
128
        mov     r9,r0
129
00:
130
        ldr     r1,=GPIO_BASE_ADDRESS
131
        str    r9, [r1,#GPIO_WRITE_REG_OFFSET]
132
        ldr     r3,=0x100000
133
10:     nop
134
        sub     r3,r3,#1
135
        cmp     r3,#0
136
        bne     10b
137
        str     r3,[r1,#GPIO_WRITE_REG_OFFSET]
138
        ldr     r3,=0x80000
139
20:     nop
140
        sub     r3,r3,#1
141
        cmp     r3,#0
142
        bne     20b
143
 
144
        ldr     r1,=msg
145
        bl      _puts
146
        mov     r1,r8,lsr #24
147
        bl      _puthex
148
        mov     r1,r8,lsr #16
149
        bl      _puthex
150
        mov     r1,r8,lsr #8
151
        bl      _puthex
152
        mov     r1,r8
153
        bl      _puthex
154
        mov     r0,#'\n'
155
        bl      _putc
156
        mov     r0,#'\r'
157
        bl      _putc
158
        b       00b
159
 
160
//
161
// Write the character in r0
162
//
163
_putc:
164
        ldr     r2,=UART1_BASE_ADDRESS
165
10:     ldrb    r3,[r2,#UART_STATUS]
166
        and     r3,r3,#UART_STATUS_TXEMPTY
167
        cmp     r3,#0
168
        beq     10b
169
        strb    r0,[r2,#UART_TXBUF]
170
        blr
171
 
172
//
173
// Write the string pointed to by r1
174
//
175
_puts:
176
        mov     r7,lr
177
10:     ldrb    r0,[r1],#1
178
        cmp     r0,#0
179
        moveq   pc,r7
180
        bl      _putc
181
        b       10b
182
 
183
//
184
// Print the byte in r1 in hex
185
//
186
_puthex:
187
        mov     r7,lr
188
        mov     r2,r1,lsr #4
189
        and     r2,r2,#0x0F
190
        cmp     r2,#0x0A
191
        addge   r2,r2,#'A'-'0'-0x0A
192
        add     r0,r2,#'0'
193
        bl      _putc
194
        and     r2,r1,#0x0F
195
        cmp     r2,#0x0A
196
        addge   r2,r2,#'A'-'0'-0x0A
197
        add     r0,r2,#'0'
198
        bl      _putc
199
        mov     lr,r7
200
        blr
201
 
202
msg:    .string "PC=0x"
203
 
204
        .section ".data"
205
        .align  2
206
_leds:  .long   0x77
207
 
208
        .section ".bss"
209
_stack_base:
210
        .rept 512
211
        .byte 0
212
        .endr
213
        .balign 16
214
_stack:
215
 
216
        .end

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.