source: rtems/c/src/lib/libbsp/m68k/gen68302/start/start302.s @ 03f2154e

4.104.114.84.95
Last change on this file since 03f2154e was 03f2154e, checked in by Joel Sherrill <joel.sherrill@…>, on 04/22/97 at 17:20:27

headers updated to reflect new style copyright notice as part
of switching to the modified GNU GPL.

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