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

Subversion Repositories openrisc_me

[/] [openrisc/] [trunk/] [rtos/] [rtems/] [c/] [src/] [lib/] [libbsp/] [m68k/] [gen68302/] [start/] [start.S] - Blame information for rev 173

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 30 unneback
/*  entry.s
2
 *
3
 *  This file contains the entry point for the application.
4
 *  The name of this entry point is compiler dependent.
5
 *  It jumps to the BSP which is responsible for performing
6
 *  all initialization.
7
 *
8
 *  COPYRIGHT (c) 1989-1999.
9
 *  On-Line Applications Research Corporation (OAR).
10
 *
11
 *  The license and distribution terms for this file may be
12
 *  found in the file LICENSE in this distribution or at
13
 *  http://www.OARcorp.com/rtems/license.html.
14
 *
15
 *  $Id: start.S,v 1.2 2001-09-27 12:00:05 chris Exp $
16
 */
17
 
18
#include "asm.h"
19
 
20
  .set  BAR,            0xF2            | Base Address Register location
21
  .set  SCR,            0xF4            | System Control Register location
22
  .set  BAR_VAL,        0x0f7f          | BAR value
23
  .set  SCR_VAL,        0x00080f00      | SCR value
24
  .set  GIMR_VAL,       0x8780          |Global Interrupt Mode Register. (MUST BE WRITTEN).
25
  .set  BaseAddr,(BAR_VAL&0x0fff)<<12   | MC68302 internal base address
26
 
27
  .set  oSYSRAM,        0x000           | 576 bytes of internal system RAM
28
 
29
  .set  oGIMR,          0x812
30
 
31
  .set  oCS0_Base,      0x830           | 16 bits, Chip Sel 0 Base Reg
32
  .set  oCS0_Option,    0x832           | 16 bits, Chip Sel 0 Option Reg
33
  .set  oCS1_Base,      0x834           | 16 bits, Chip Sel 1 Base Reg
34
  .set  oCS1_Option,    0x836           | 16 bits, Chip Sel 1 Option Reg
35
  .set  oCS2_Base,      0x838           | 16 bits, Chip Sel 2 Base Reg
36
  .set  oCS2_Option,    0x83a           | 16 bits, Chip Sel 2 Option Reg
37
  .set  oCS3_Base,      0x83c           | 16 bits, Chip Sel 3 Base Reg
38
  .set  oCS3_Option,    0x83e           | 16 bits, Chip Sel 3 Option Reg
39
 
40
  .set  tmpSRAM_BASE,   0x400000        | start of temporary SRAM
41
  .set  FLASH_BASE,     0xc00000        | start of FLASH''s normal location
42
 
43
 
44
BEGIN_CODE
45
         PUBLIC (M68Kvec)               | Vector Table
46
SYM (M68Kvec):                          | standard location for vectors
47
V___ISSP: .long 0x00001000              |00  0 Reset: Initial SSP
48
V____IPC: .long SYM(start)-V___ISSP     |04  1 Reset: Initial PC
49
V_BUSERR: .long Bad-V___ISSP            |08  2 Bus Error
50
V_ADRERR: .long Bad-V___ISSP            |0c  3 Address Error
51
        .space  240                     | reserve space for reset of vectors
52
 
53
#if ( M68K_HAS_SEPARATE_STACKS == 1 )
54
SYM (lowintstack):
55
        .space   4092                   | reserve for interrupt stack
56
SYM (hiintstack):
57
        .space   4                      | end of interrupt stack
58
#endif
59
 
60
        PUBLIC (start)                 | Default entry point for GNU
61
SYM (start):
62
        move.w  #0x2700,sr              | Disable all interrupts
63
        move.w  #BAR_VAL,BAR            | Set Base Address Register
64
        move.l  #SCR_VAL,SCR            | Set System Control Register
65
        lea     BaseAddr,a5
66
        move.w  #GIMR_VAL,a5@(oGIMR)    | Set Global Interrupt Mode Register
67
 
68
|
69
| Set up chip select registers for the remapping process.
70
|
71
 
72
|
73
|      0      X      x    x    x    x
74
| 0  000 0  0-- -  --- ---- ---- ----
75
| x  xxx x  xxx x  xx
76
|
77
        move.w  #0xc001,a5@(oCS0_Base)   | Expand CS0 to full size (FLASH)
78
        move.w  #0x1f82,a5@(oCS0_Option) | 000000-03ffff, R, 0 WS
79
 
80
|
81
|      X      x      x    x    x    x
82
| 0  100 0  0-- -  --- ---- ---- ----
83
| x  xxx x  xxx x  xx
84
|
85
        move.w  #0xa801,a5@(oCS1_Base)   | Set up and enable CS1 (SRAM)
86
        move.w  #0x1f80,a5@(oCS1_Option) | 400000-43ffff, RW, 0 WS
87
 
88
|
89
| Copy the initial boot FLASH area to the temporary SRAM location.
90
|
91
                moveq   #0,d0
92
                movea.l d0,a0                   | a0 -> start of FLASH
93
                lea     tmpSRAM_BASE,a1         | a1 -> start of tmp SRAM
94
|               moveq   #(endPreBoot-V___ISSP)/4,d0     | # longs to copy
95
                moveq   #127,d0
96
cpy_flash:      move.l  (a0)+,(a1)+             | copy
97
                subq.l  #1,d0
98
                bne     cpy_flash
99
 
100
|
101
| Copy remap code to 68302''s internal system RAM.
102
|
103
                movea.w #begRemap-V___ISSP,a0   | a0 -> remap code
104
                lea     a5@(oSYSRAM),a1 | a1 -> internal system RAM
105
|               moveq   #(endRemap-begRemap)/2-1,d0     | d0 = # words to copy
106
                moveq   #11,d0
107
cpy_remap:      move.w  (a0)+,(a1)+             | copy
108
                dbra    d0,cpy_remap
109
 
110
|
111
| Jump to the remap code in the 68302''s internal system RAM.
112
|
113
                jmp     a5@(oSYSRAM)            | (effectively a jmp begRemap)
114
 
115
|
116
| This remap code, when executed from the 68302''s internal system RAM
117
| will 1) remap CS1 so that SRAM is at 0
118
|      2) remap CS0 so that FLASH is at FLASH_BASE
119
|  and 3) jump to executable code in the remapped FLASH.
120
|
121
begRemap:       move.w  #0xa001,a5@(oCS1_Base)  | Move CS1 (SRAM)
122
                move.w  #0xd801,a5@(oCS0_Base)  | Move CS0 (FLASH)
123
                lea     FLASH_BASE,a0
124
                jmp     a0@(endRemap-V___ISSP.w)        | Jump back to FLASH
125
endRemap:
126
|
127
| Now set up the remaining chip select registers.
128
|
129
 
130
|
131
|      4      0      x    x    x    x
132
| 1  000 1  111 0  000 0--- ---- ----
133
| x  xxx x  xxx x  xx
134
|
135
        move.w  #0xb1e1,a5@(oCS2_Base)          | Set up and enable CS2 (dpRAM)
136
        move.w  #0x1ff0,a5@(oCS2_Option)        | 8f0000-8f07ff, RW, 0 WS
137
 
138
|
139
|      8      X      x    x    x    x
140
| 1  000 0  0-- -  --- ---- ---- ----
141
| x  xxx x  xxx x  xx
142
|
143
        move.w  #0xd001,a5@(oCS3_Base)          | Set up and enable CS3 (IO)
144
        move.w  #0x1f80,a5@(oCS3_Option)        | 800000-83ffff, RW, 0 WS
145
 
146
endPreBoot:
147
 
148
        move.b  #0x30,0x800001                  | set status LED amber
149
 
150
 .set   oPIOB_Ctrl,     0x824
151
 .set   oPIOB_DDR,      0x826
152
 .set   oPIOB_Data,     0x828
153
 
154
 .set   oPIOA_Ctrl,     0x81e
155
 .set   oPIOA_DDR,      0x820
156
 .set   oPIOA_Data,     0x822
157
 
158
        move.w  #0x0ff8,a5@(oPIOB_Data) | Make output follow resistors.
159
        move.w  #0x00ff,a5@(oPIOB_DDR)          | Set up PB7-PB0 for output.
160
        move.w  #0x0080,a5@(oPIOB_Ctrl) | Set up WDOG* as dedicated
161
                                                | peripheral pins.
162
 
163
        move.w  #0x1fff,a5@(oPIOA_Data) | Make output follow resistors.
164
        move.w  #0xea2a,a5@(oPIOA_DDR)          | Set up PA15-PA0 for in/output.
165
        move.w  #0x0003,a5@(oPIOA_Ctrl) | Set up TXD2/RXD2 as dedicated
166
                                                | peripheral pins.
167
 
168
|
169
| Place "Bad" in all vectors from 010 thru 0ec.  Vectors 0f0 and 0f4
170
| are not set because they are the 68302''s BAR and SCR.
171
|
172
                movea.w #0x010,a0
173
                moveq   #(0x0f0-0x010)/4-1,d0
174
                move.l  #Bad,d1
175
cpy_Bad:        move.l  d1,(a0)+
176
                dbra    d0,cpy_Bad
177
 
178
 .set   vbase,  0x0200
179
 
180
                lea     vbase,a0
181
                moveq   #31,d0
182
cpy_Bad1:       move.l  d1,(a0)+
183
                dbra    d0,cpy_Bad1
184
 
185
|
186
| Fill in special locations to configure OS
187
|
188
                move.l  #Bad,0x008              | Bus Error
189
                move.l  #Bad,0x00c              | Address Error
190
                move.l  #Bad,0x024              | Trace
191
|               move.l  #KE_IRET,$0b4           | pSOS+ RET_I Call
192
 
193
|               move.l  #_cnsl_isr,vbase+0x028  | SCC2
194
                move.l  #timerisr,vbase+0x018   | Timer ISR
195
 
196
        |
197
        | zero out uninitialized data area
198
        |
199
zerobss:
200
        moveal  # SYM (_clear_end),a0            | find end of .bss
201
        moveal  # SYM (_clear_start),a1          | find beginning of .bss
202
        moveq   #0,d0
203
 
204
loop:   movel   d0,a1@+                | to zero out uninitialized
205
        cmpal   a0,a1
206
        jlt     loop                    | loop until _clear_end reached
207
 
208
        movel   d0, SYM (_stack_init)  | Set Stack pointer
209
        movw    #0x3700,sr             | SUPV MODE,INTERRUPTS OFF!!!
210
        movel   d0,a7                  | set master stack pointer
211
        movel   d0,a6                  | set base pointer
212
 
213
      /*
214
       *  RTEMS should maintain a separate interrupt stack on CPUs
215
       *  without one in hardware.  This is currently not supported
216
       *  on versions of the m68k without a HW intr stack.
217
       */
218
 
219
#if ( M68K_HAS_SEPARATE_STACKS == 1 )
220
        lea     SYM (hiintstack),a0          | a0 = high end of intr stack
221
        movec   a0,isp                | set interrupt stack
222
#endif
223
 
224
        move.l  #0,a7@-               | environp
225
        move.l  #0,a7@-               | argv
226
        move.l  #0,a7@-               | argc
227
        jsr     SYM (boot_card)
228
 
229
        nop
230
Bad:    bra     Bad
231
 
232
        nop
233
END_CODE
234
 
235
 
236
BEGIN_DATA
237
 
238
        PUBLIC (start_frame)
239
SYM (start_frame):
240
        .space  4,0
241
 
242
        PUBLIC (stack_start)
243
SYM (stack_start):
244
        .space  4,0
245
END_DATA
246
 
247
BEGIN_BSS
248
 
249
        PUBLIC (environ)
250
        .align 2
251
SYM (environ):
252
        .long  0
253
 
254
        PUBLIC (heap_size)
255
        .set   SYM (heap_size),0x2000
256
 
257
        PUBLIC (stack_size)
258
        .set   SYM (stack_size),0x1000
259
 
260
 
261
END_DATA
262
END

powered by: WebSVN 2.1.0

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