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

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [rtos/] [freertos-6.1.1/] [Demo/] [lwIP_Demo_Rowley_ARM7/] [AT91SAM7_Startup.s] - Blame information for rev 866

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 583 jeremybenn
/*****************************************************************************
2
  Exception handlers and startup code for ATMEL AT91SAM7.
3
 
4
  Copyright (c) 2004 Rowley Associates Limited.
5
 
6
  This file may be distributed under the terms of the License Agreement
7
  provided with this software.
8
 
9
  THIS FILE IS PROVIDED AS IS WITH NO WARRANTY OF ANY KIND, INCLUDING THE
10
  WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
11
 *****************************************************************************/
12
 
13
#define REG_BASE 0xFFFFF000
14
#define CKGR_MOR_OFFSET 0xC20
15
#define CKGR_PLLR_OFFSET 0xC2C
16
#define PMC_MCKR_OFFSET 0xC30
17
#define PMC_SR_OFFSET 0xC68
18
#define WDT_MR_OFFSET 0xD44
19
#define MC_RCR_OFFSET 0xF00
20
#define MC_FMR_OFFSET 0xF60
21
 
22
#define CKGR_MOR_MOSCEN (1 << 0)
23
#define CKGR_MOR_OSCBYPASS (1 << 1)
24
#define CKGR_MOR_OSCOUNT_BIT_OFFSET (8)
25
 
26
#define CKGR_PLLR_DIV_BIT_OFFSET (0)
27
#define CKGR_PLLR_PLLCOUNT_BIT_OFFSET (8)
28
#define CKGR_PLLR_OUT_BIT_OFFSET (14)
29
#define CKGR_PLLR_MUL_BIT_OFFSET (16)
30
#define CKGR_PLLR_USBDIV_BIT_OFFSET (28)
31
 
32
#define PMC_MCKR_CSS_MAIN_CLOCK (0x1)
33
#define PMC_MCKR_CSS_PLL_CLOCK (0x3)
34
#define PMC_MCKR_PRES_CLK (0)
35
#define PMC_MCKR_PRES_CLK_2 (1 << 2)
36
#define PMC_MCKR_PRES_CLK_4 (2 << 2)
37
#define PMC_MCKR_PRES_CLK_8 (3 << 2)
38
#define PMC_MCKR_PRES_CLK_16 (4 << 2)
39
#define PMC_MCKR_PRES_CLK_32 (5 << 2)
40
#define PMC_MCKR_PRES_CLK_64 (6 << 2)
41
 
42
#define PMC_SR_MOSCS (1 << 0)
43
#define PMC_SR_LOCK (1 << 2)
44
#define PMC_SR_MCKRDY (1 << 3)
45
#define PMC_SR_PCKRDY0 (1 << 8)
46
#define PMC_SR_PCKRDY1 (1 << 9)
47
#define PMC_SR_PCKRDY2 (1 << 10)
48
 
49
#define MC_RCR_RCB (1 << 0)
50
 
51
#define MC_FMR_FWS_0FWS (0)
52
#define MC_FMR_FWS_1FWS (1 << 8)
53
#define MC_FMR_FWS_2FWS (2 << 8)
54
#define MC_FMR_FWS_3FWS (3 << 8)
55
#define MC_FMR_FMCN_BIT_OFFSET 16
56
 
57
#define WDT_MR_WDDIS (1 << 15)
58
 
59
  .section .vectors, "ax"
60
  .code 32
61
  .align 0
62
 
63
/*****************************************************************************
64
  Exception Vectors
65
 *****************************************************************************/
66
_vectors:
67
  ldr pc, [pc, #reset_handler_address - . - 8]  /* reset */
68
  ldr pc, [pc, #undef_handler_address - . - 8]  /* undefined instruction */
69
  ldr pc, [pc, #swi_handler_address - . - 8]    /* swi handler */
70
  ldr pc, [pc, #pabort_handler_address - . - 8] /* abort prefetch */
71
  ldr pc, [pc, #dabort_handler_address - . - 8] /* abort data */
72
  nop
73
  ldr pc, [PC, #-0xF20]    /* irq */
74
  ldr pc, [pc, #fiq_handler_address - . - 8]    /* fiq */
75
 
76
reset_handler_address:
77
  .word reset_handler
78
undef_handler_address:
79
  .word undef_handler
80
swi_handler_address:
81
  .word swi_handler
82
pabort_handler_address:
83
  .word pabort_handler
84
dabort_handler_address:
85
  .word dabort_handler
86
irq_handler_address:
87
  .word irq_handler
88
fiq_handler_address:
89
  .word fiq_handler
90
 
91
  .section .init, "ax"
92
  .code 32
93
  .align 0
94
 
95
/******************************************************************************
96
  Reset handler
97
 ******************************************************************************/
98
reset_handler:
99
 
100
 
101
  ldr r10, =REG_BASE
102
 
103
  /* Set up FLASH wait state */
104
  ldr r0, =(50 << MC_FMR_FMCN_BIT_OFFSET) | MC_FMR_FWS_1FWS
105
  str r0, [r10, #MC_FMR_OFFSET]
106
 
107
  /* Disable Watchdog */
108
  ldr r0, =WDT_MR_WDDIS
109
  str r0, [r10, #WDT_MR_OFFSET]
110
 
111
  /* Enable the main oscillator */
112
  ldr r0, =(6 << CKGR_MOR_OSCOUNT_BIT_OFFSET) | CKGR_MOR_MOSCEN
113
  str r0, [r10, #CKGR_MOR_OFFSET]
114
 
115
1:/* Wait for main oscillator to stabilize */
116
  ldr r0, [r10, #PMC_SR_OFFSET]
117
  tst r0, #PMC_SR_MOSCS
118
  beq 1b
119
 
120
  /* Set up the PLL */
121
  ldr r0, =(5 << CKGR_PLLR_DIV_BIT_OFFSET) | (28 << CKGR_PLLR_PLLCOUNT_BIT_OFFSET) | (25 << CKGR_PLLR_MUL_BIT_OFFSET)
122
  str r0, [r10, #CKGR_PLLR_OFFSET]
123
 
124
1:/* Wait for PLL to lock */
125
  ldr r0, [r10, #PMC_SR_OFFSET]
126
  tst r0, #PMC_SR_LOCK
127
  beq 1b
128
 
129
  /* Select PLL as clock source */
130
  ldr r0, =(PMC_MCKR_CSS_PLL_CLOCK | PMC_MCKR_PRES_CLK_2)
131
  str r0, [r10, #PMC_MCKR_OFFSET]
132
 
133
#ifdef __FLASH_BUILD
134
  /* Copy exception vectors into Internal SRAM */
135
  mov r8, #0x00200000
136
  ldr r9, =_vectors
137
  ldmia r9!, {r0-r7}
138
  stmia r8!, {r0-r7}
139
  ldmia r9!, {r0-r6}
140
  stmia r8!, {r0-r6}
141
 
142
  /* Remap Internal SRAM to 0x00000000 */
143
  ldr r0, =MC_RCR_RCB
144
  strb r0, [r10, #MC_RCR_OFFSET]
145
#endif
146
 
147
 
148
  /* Jump to the default C runtime startup code. */
149
  b _start
150
 
151
/******************************************************************************
152
  Default exception handlers
153
  (These are declared weak symbols so they can be redefined in user code)
154
 ******************************************************************************/
155
undef_handler:
156
  b undef_handler
157
 
158
swi_handler:
159
  b swi_handler
160
 
161
pabort_handler:
162
  b pabort_handler
163
 
164
dabort_handler:
165
  b dabort_handler
166
 
167
irq_handler:
168
  b irq_handler
169
 
170
fiq_handler:
171
  b fiq_handler
172
 
173
  .weak undef_handler, swi_handler, pabort_handler, dabort_handler, irq_handler, fiq_handler

powered by: WebSVN 2.1.0

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