Back to home page

LXR

 
 

    


File indexing completed on 2025-05-11 08:23:47

0001 /* SPDX-License-Identifier: BSD-2-Clause */
0002 
0003 /*
0004  *  mcf52235 startup code
0005  *
0006  *  This file contains the entry point for the application.
0007  *  The name of this entry point is compiler dependent.
0008  *  It jumps to the BSP which is responsible for performing
0009  *  all initialization.
0010  *
0011  *  COPYRIGHT (c) 1989-1998.
0012  *  On-Line Applications Research Corporation (OAR).
0013  *
0014  * Redistribution and use in source and binary forms, with or without
0015  * modification, are permitted provided that the following conditions
0016  * are met:
0017  * 1. Redistributions of source code must retain the above copyright
0018  *    notice, this list of conditions and the following disclaimer.
0019  * 2. Redistributions in binary form must reproduce the above copyright
0020  *    notice, this list of conditions and the following disclaimer in the
0021  *    documentation and/or other materials provided with the distribution.
0022  *
0023  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
0024  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
0025  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
0026  * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
0027  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
0028  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
0029  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
0030  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
0031  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
0032  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
0033  * POSSIBILITY OF SUCH DAMAGE.
0034  */
0035 
0036 #include <rtems/asm.h>
0037 
0038 BEGIN_CODE
0039 
0040     PUBLIC (_INTERRUPT_VECTOR)
0041 SYM(_INTERRUPT_VECTOR):
0042 
0043     .long   _ISR_Stack_area_end /* 00 Initial 'SSP' */
0044     .long   SYM(start) /* 01 Initial PC */
0045     .long   SYM(_uhoh) /* 02 Access Error */
0046     .long   SYM(_uhoh) /* 03 Address Error */
0047     .long   SYM(_uhoh) /* 04 Illegal Instruction */
0048     .long   SYM(_uhoh) /* 05 Divide by Zero */
0049     .long   SYM(_uhoh) /* 06 Reserved */
0050     .long   SYM(_uhoh) /* 07 Reserved */
0051     .long   SYM(_uhoh) /* 08 Privilege Violation */
0052     .long   SYM(_uhoh) /* 09 Trace */
0053     .long   SYM(_uhoh) /* 10 Unimplemented A-Line */
0054     .long   SYM(_uhoh) /* 11 Unimplemented F-Line */
0055     .long   SYM(_uhoh) /* 12 Debug Interrupt */
0056     .long   SYM(_uhoh) /* 13 Reserved */
0057     .long   SYM(_uhoh) /* 14 Format Error */
0058     .long   SYM(_uhoh) /* 15 Reserved */
0059     .long   SYM(_uhoh) /* 16 Reserved */
0060     .long   SYM(_uhoh) /* 17 Reserved */
0061     .long   SYM(_uhoh) /* 18 Reserved */
0062     .long   SYM(_uhoh) /* 19 Reserved */
0063     .long   SYM(_uhoh) /* 20 Reserved */
0064     .long   SYM(_uhoh) /* 21 Reserved */
0065     .long   SYM(_uhoh) /* 22 Reserved */
0066     .long   SYM(_uhoh) /* 23 Reserved */
0067     .long   SYM(_spuriousInterrupt) /* 24 Spurious Interrupt */
0068     .long   SYM(_uhoh) /* 25 Reserved */
0069     .long   SYM(_uhoh) /* 26 Reserved */
0070     .long   SYM(_uhoh) /* 27 Reserved */
0071     .long   SYM(_uhoh) /* 28 Reserved */
0072     .long   SYM(_uhoh) /* 29 Reserved */
0073     .long   SYM(_uhoh) /* 30 Reserved */
0074     .long   SYM(_uhoh) /* 31 Reserved */
0075     .long   SYM(_uhoh) /* 32 TRAP #0 */
0076     .long   SYM(_uhoh) /* 33 TRAP #1 */
0077     .long   SYM(_uhoh) /* 34 TRAP #2 */
0078     .long   SYM(_uhoh) /* 35 TRAP #3 */
0079     .long   SYM(_uhoh) /* 36 TRAP #4 */
0080     .long   SYM(_uhoh) /* 37 TRAP #5 */
0081     .long   SYM(_uhoh) /* 38 TRAP #6 */
0082     .long   SYM(_uhoh) /* 39 TRAP #7 */
0083     .long   SYM(_uhoh) /* 40 TRAP #8 */
0084     .long   SYM(_uhoh) /* 41 TRAP #9 */
0085     .long   SYM(_uhoh) /* 42 TRAP #10 */
0086     .long   SYM(_uhoh) /* 43 TRAP #11 */
0087     .long   SYM(_uhoh) /* 44 TRAP #12 */
0088     .long   SYM(_uhoh) /* 45 TRAP #13 */
0089     .long   SYM(_uhoh) /* 46 TRAP #14 */
0090     .long   SYM(_uhoh) /* 47 TRAP #15 */
0091     .long   SYM(_uhoh) /* 48 Reserved */
0092     .long   SYM(_uhoh) /* 49 Reserved */
0093     .long   SYM(_uhoh) /* 50 Reserved */
0094     .long   SYM(_uhoh) /* 51 Reserved */
0095     .long   SYM(_uhoh) /* 52 Reserved */
0096     .long   SYM(_uhoh) /* 53 Reserved */
0097     .long   SYM(_uhoh) /* 54 Reserved */
0098     .long   SYM(_uhoh) /* 55 Reserved */
0099     .long   SYM(_uhoh) /* 56 Reserved */
0100     .long   SYM(_uhoh) /* 57 Reserved */
0101     .long   SYM(_uhoh) /* 58 Reserved */
0102     .long   SYM(_uhoh) /* 59 Reserved */
0103     .long   SYM(_uhoh) /* 60 Reserved */
0104     .long   SYM(_uhoh) /* 61 Reserved */
0105     .long   SYM(_uhoh) /* 62 Reserved */
0106     .long   SYM(_uhoh) /* 63 Reserved */
0107 
0108     /* INTC0 */
0109 
0110     .long   SYM(_uhoh) /* 64*/
0111     .long   SYM(_uhoh) /* 65*/
0112     .long   SYM(_uhoh) /* 66*/
0113     .long   SYM(_uhoh) /* 67*/
0114     .long   SYM(_uhoh) /* 68*/
0115     .long   SYM(_uhoh) /* 69*/
0116     .long   SYM(_uhoh) /* 70*/
0117     .long   SYM(_uhoh) /* 71*/
0118     .long   SYM(_uhoh) /* 72*/
0119     .long   SYM(_uhoh) /* 73*/
0120     .long   SYM(_uhoh) /* 74*/
0121     .long   SYM(_uhoh) /* 75*/
0122     .long   SYM(_uhoh) /* 76*/
0123     .long   SYM(_uhoh) /* 77*/
0124     .long   SYM(_uhoh) /* 78*/
0125     .long   SYM(_uhoh) /* 79*/
0126     .long   SYM(_uhoh) /* 80*/
0127     .long   SYM(_uhoh) /* 81*/
0128     .long   SYM(_uhoh) /* 82*/
0129     .long   SYM(_uhoh) /* 83*/
0130     .long   SYM(_uhoh) /* 84*/
0131     .long   SYM(_uhoh) /* 85*/
0132     .long   SYM(_uhoh) /* 86*/
0133     .long   SYM(_uhoh) /* 87*/
0134     .long   SYM(_uhoh) /* 88*/
0135     .long   SYM(_uhoh) /* 89*/
0136     .long   SYM(_uhoh) /* 90*/
0137     .long   SYM(_uhoh) /* 91*/
0138     .long   SYM(_uhoh) /* 92*/
0139     .long   SYM(_uhoh) /* 93*/
0140     .long   SYM(_uhoh) /* 94*/
0141     .long   SYM(_uhoh) /* 95*/
0142     .long   SYM(_uhoh) /* 96*/
0143     .long   SYM(_uhoh) /* 97*/
0144     .long   SYM(_uhoh) /* 98*/
0145     .long   SYM(_uhoh) /* 99*/
0146     .long   SYM(_uhoh) /* 100*/
0147     .long   SYM(_uhoh) /* 101*/
0148     .long   SYM(_uhoh) /* 102*/
0149     .long   SYM(_uhoh) /* 103*/
0150     .long   SYM(_uhoh) /* 104*/
0151     .long   SYM(_uhoh) /* 105*/
0152     .long   SYM(_uhoh) /* 106*/
0153     .long   SYM(_uhoh) /* 107*/
0154     .long   SYM(_uhoh) /* 108*/
0155     .long   SYM(_uhoh) /* 109*/
0156     .long   SYM(_uhoh) /* 110*/
0157     .long   SYM(_uhoh) /* 111*/
0158     .long   SYM(_uhoh) /* 112*/
0159     .long   SYM(_uhoh) /* 113*/
0160     .long   SYM(_uhoh) /* 114*/
0161     .long   SYM(_uhoh) /* 115*/
0162     .long   SYM(_uhoh) /* 116*/
0163     .long   SYM(_uhoh) /* 117*/
0164     .long   SYM(_uhoh) /* 118*/
0165     .long   SYM(_uhoh) /* 119*/
0166     .long   SYM(_uhoh) /* 120*/
0167     .long   SYM(_uhoh) /* 121*/
0168     .long   SYM(_uhoh) /* 122*/
0169     .long   SYM(_uhoh) /* 123*/
0170     .long   SYM(_uhoh) /* 124*/
0171     .long   SYM(_uhoh) /* 125*/
0172     .long   SYM(_uhoh) /* 126*/
0173     .long   SYM(_uhoh) /* 127*/
0174 
0175     /* INTC1 */
0176 
0177     .long   SYM(_uhoh) /* 128*/
0178     .long   SYM(_uhoh) /* 129*/
0179     .long   SYM(_uhoh) /* 130*/
0180     .long   SYM(_uhoh) /* 131*/
0181     .long   SYM(_uhoh) /* 132*/
0182     .long   SYM(_uhoh) /* 133*/
0183     .long   SYM(_uhoh) /* 134*/
0184     .long   SYM(_uhoh) /* 135*/
0185     .long   SYM(_uhoh) /* 136*/
0186     .long   SYM(_uhoh) /* 137*/
0187     .long   SYM(_uhoh) /* 138*/
0188     .long   SYM(_uhoh) /* 139*/
0189     .long   SYM(_uhoh) /* 140*/
0190     .long   SYM(_uhoh) /* 141*/
0191     .long   SYM(_uhoh) /* 142*/
0192     .long   SYM(_uhoh) /* 143*/
0193     .long   SYM(_uhoh) /* 144*/
0194     .long   SYM(_uhoh) /* 145*/
0195     .long   SYM(_uhoh) /* 146*/
0196     .long   SYM(_uhoh) /* 147*/
0197     .long   SYM(_uhoh) /* 148*/
0198     .long   SYM(_uhoh) /* 149*/
0199     .long   SYM(_uhoh) /* 150*/
0200     .long   SYM(_uhoh) /* 151*/
0201     .long   SYM(_uhoh) /* 152*/
0202     .long   SYM(_uhoh) /* 153*/
0203     .long   SYM(_uhoh) /* 154*/
0204     .long   SYM(_uhoh) /* 155*/
0205     .long   SYM(_uhoh) /* 156*/
0206     .long   SYM(_uhoh) /* 157*/
0207     .long   SYM(_uhoh) /* 158*/
0208     .long   SYM(_uhoh) /* 159*/
0209     .long   SYM(_uhoh) /* 160*/
0210     .long   SYM(_uhoh) /* 161*/
0211     .long   SYM(_uhoh) /* 162*/
0212     .long   SYM(_uhoh) /* 163*/
0213     .long   SYM(_uhoh) /* 164*/
0214     .long   SYM(_uhoh) /* 165*/
0215     .long   SYM(_uhoh) /* 166*/
0216     .long   SYM(_uhoh) /* 167*/
0217     .long   SYM(_uhoh) /* 168*/
0218     .long   SYM(_uhoh) /* 169*/
0219     .long   SYM(_uhoh) /* 170*/
0220     .long   SYM(_uhoh) /* 171*/
0221     .long   SYM(_uhoh) /* 172*/
0222     .long   SYM(_uhoh) /* 173*/
0223     .long   SYM(_uhoh) /* 174*/
0224     .long   SYM(_uhoh) /* 175*/
0225     .long   SYM(_uhoh) /* 176*/
0226     .long   SYM(_uhoh) /* 177*/
0227     .long   SYM(_uhoh) /* 178*/
0228     .long   SYM(_uhoh) /* 179*/
0229     .long   SYM(_uhoh) /* 180*/
0230     .long   SYM(_uhoh) /* 181*/
0231     .long   SYM(_uhoh) /* 182*/
0232     .long   SYM(_uhoh) /* 183*/
0233     .long   SYM(_uhoh) /* 184*/
0234     .long   SYM(_uhoh) /* 185*/
0235     .long   SYM(_uhoh) /* 186*/
0236     .long   SYM(_uhoh) /* 187*/
0237     .long   SYM(_uhoh) /* 188*/
0238     .long   SYM(_uhoh) /* 189*/
0239     .long   SYM(_uhoh) /* 190*/
0240     .long   SYM(_uhoh) /* 191*/
0241     .long   SYM(_uhoh) /* 192*/
0242 
0243     /* */
0244 
0245     .long   SYM(_uhoh) /* 193*/
0246     .long   SYM(_uhoh) /* 194*/
0247     .long   SYM(_uhoh) /* 195*/
0248     .long   SYM(_uhoh) /* 196*/
0249     .long   SYM(_uhoh) /* 197*/
0250     .long   SYM(_uhoh) /* 198*/
0251     .long   SYM(_uhoh) /* 199*/
0252     .long   SYM(_uhoh) /* 200*/
0253     .long   SYM(_uhoh) /* 201*/
0254     .long   SYM(_uhoh) /* 202*/
0255     .long   SYM(_uhoh) /* 203*/
0256     .long   SYM(_uhoh) /* 204*/
0257     .long   SYM(_uhoh) /* 205*/
0258     .long   SYM(_uhoh) /* 206*/
0259     .long   SYM(_uhoh) /* 207*/
0260     .long   SYM(_uhoh) /* 208*/
0261     .long   SYM(_uhoh) /* 209*/
0262     .long   SYM(_uhoh) /* 210*/
0263     .long   SYM(_uhoh) /* 211*/
0264     .long   SYM(_uhoh) /* 212*/
0265     .long   SYM(_uhoh) /* 213*/
0266     .long   SYM(_uhoh) /* 214*/
0267     .long   SYM(_uhoh) /* 215*/
0268     .long   SYM(_uhoh) /* 216*/
0269     .long   SYM(_uhoh) /* 217*/
0270     .long   SYM(_uhoh) /* 218*/
0271     .long   SYM(_uhoh) /* 219*/
0272     .long   SYM(_uhoh) /* 220*/
0273     .long   SYM(_uhoh) /* 221*/
0274     .long   SYM(_uhoh) /* 222*/
0275     .long   SYM(_uhoh) /* 223*/
0276     .long   SYM(_uhoh) /* 224*/
0277     .long   SYM(_uhoh) /* 225*/
0278     .long   SYM(_uhoh) /* 226*/
0279     .long   SYM(_uhoh) /* 227*/
0280     .long   SYM(_uhoh) /* 228*/
0281     .long   SYM(_uhoh) /* 229*/
0282     .long   SYM(_uhoh) /* 230*/
0283     .long   SYM(_uhoh) /* 231*/
0284     .long   SYM(_uhoh) /* 232*/
0285     .long   SYM(_uhoh) /* 233*/
0286     .long   SYM(_uhoh) /* 234*/
0287     .long   SYM(_uhoh) /* 235*/
0288     .long   SYM(_uhoh) /* 236*/
0289     .long   SYM(_uhoh) /* 237*/
0290     .long   SYM(_uhoh) /* 238*/
0291     .long   SYM(_uhoh) /* 239*/
0292     .long   SYM(_uhoh) /* 240*/
0293     .long   SYM(_uhoh) /* 241*/
0294     .long   SYM(_uhoh) /* 242*/
0295     .long   SYM(_uhoh) /* 243*/
0296     .long   SYM(_uhoh) /* 244*/
0297     .long   SYM(_uhoh) /* 245*/
0298     .long   SYM(_uhoh) /* 246*/
0299     .long   SYM(_uhoh) /* 247*/
0300     .long   SYM(_uhoh) /* 248*/
0301     .long   SYM(_uhoh) /* 249*/
0302     .long   SYM(_uhoh) /* 250*/
0303     .long   SYM(_uhoh) /* 251*/
0304     .long   SYM(_uhoh) /* 252*/
0305     .long   SYM(_uhoh) /* 253*/
0306     .long   SYM(_uhoh) /* 254*/
0307     .long   SYM(_uhoh) /* 255*/
0308 
0309 /*
0310  * We must write the flash configuration here.  This portion of flash is shadowed
0311  * by some flash registers, so we can't put code here!
0312  */
0313 
0314     PUBLIC (_FLASH_CONFIGURATION_FIELD)
0315 SYM(_FLASH_CONFIGURATION_FIELD):
0316 
0317 _key_upper: .long   0x00000000
0318 _key_lower: .long   0x00000000
0319 _cfm_prot:  .long   0x00000000
0320 _cfm_sacc:  .long   0x00000000
0321 _cfm_dacc:  .long   0x00000000
0322 _cfm_msec:  .long   0x00000000
0323 
0324 /*
0325  * Default trap handler
0326  * With an oscilloscope you can see AS* stop
0327  */
0328 .align 4
0329     PUBLIC (_uhoh)
0330 SYM(_uhoh):
0331     nop                     | Leave spot for breakpoint
0332     stop    #0x2700         | Stop with interrupts disabled
0333     bra.w   SYM(_uhoh)      | Stuck forever
0334 
0335 /*
0336  * Spurious Interrupt Handler
0337  */
0338 .align 4
0339     PUBLIC (_spuriousInterrupt)
0340 SYM(_spuriousInterrupt):
0341     addql   #1, SYM(_M68kSpuriousInterruptCount)
0342     rte
0343 
0344 /*
0345  * Write VBR Register
0346  */
0347 .align 4
0348     PUBLIC (_wr_vbr)
0349 SYM(_wr_vbr):
0350     move.l  4(sp), d0
0351     movec   d0, vbr
0352     nop
0353     rts
0354 
0355 /*
0356  * Board startup
0357  * Disable watchdog, interrupts
0358  * Enable sram
0359  */
0360 .align 4
0361     PUBLIC (start)
0362 SYM(start):
0363 
0364     /* Mask off interupts */
0365     move.w   #0x2700, sr
0366 
0367     /* Save off reset values of D0 and D1 */
0368     move.l  d0, d6
0369     move.l  d1, d7
0370 
0371     /* Initialize RAMBAR: locate SRAM and validate it */
0372     move.l  #RamBase, d0
0373     add.l   #0x21, d0
0374     movec   d0, %rambar
0375 
0376     /* Locate Stack Pointer */
0377     move.l  #_ISR_Stack_area_end, sp
0378 
0379     /* Initialize FLASHBAR */
0380     move.l  #_FlashBase, d0
0381     cmp.l   #0x00000000, d0
0382     bne     _change_flashbar
0383     add.l   #0x61, d0
0384     movec   d0, %flashbar
0385 
0386 _continue_startup:
0387 
0388     /* Locate Stack Pointer */
0389     move.l  #_ISR_Stack_area_end, sp
0390 
0391     /* Save off intial D0 and D1 to RAM */
0392     move.l  d6, SYM(_d0_reset)
0393     move.l  d7, SYM(_d1_reset)
0394 
0395     /*
0396      * Remainder of the startup code is handled by C code
0397      * This never returns
0398      */
0399     jmp SYM(Init52235)
0400 
0401 _change_flashbar:
0402     /*
0403     * The following sequence is used to set FLASHBAR. Since we may
0404     * be executing from Flash, we must put the routine into SRAM for
0405     * execution and then jump back to Flash using the new address.
0406     *
0407     * The following instructions are coded into the SRAM:
0408     *
0409     * move.l    #(__FLASH + 0x61),d0
0410     * movec    d0, FLASHBAR
0411     * jmp        _continue_startup
0412     *
0413     * An arbitrary SRAM address is chosen until the real address
0414     * can be loaded.
0415     *
0416     * This routine is not necessary if the default Flash address
0417     * (0x00000000) is used.
0418     *
0419     * If running in SRAM, change_flashbar should not be executed
0420     */
0421 
0422     move.l  #RamBase, a0
0423 
0424     /* Code "move.l #(__FLASH + 0x61),d0" into SRAM */
0425     move.w  #0x203C, d0
0426     move.w  d0, (a0)+
0427     move.l  #_FlashBase, d0
0428     add.l   #0x61, d0
0429     move.l  d0, (a0)+
0430 
0431     /* Code "movec d0,FLASHBAR" into SRAM */
0432     move.l  #0x4e7b0C04, d0
0433     move.l  d0, (a0)+
0434 
0435     /* Code "jmp _continue_startup" into SRAM */
0436     move.w  #0x4EF9, d0
0437     move.w  d0, (a0)+
0438     move.l  #_continue_startup, d0
0439     move.l  d0, (a0)+
0440 
0441     /* Jump to code segment in internal SRAM */
0442     jmp     RamBase
0443 
0444 END_CODE
0445 
0446 
0447 BEGIN_DATA_DCL
0448 
0449     .align 4
0450 
0451 PUBLIC (_M68kSpuriousInterruptCount)
0452 SYM (_M68kSpuriousInterruptCount):
0453     .long   0
0454 
0455 PUBLIC (_d0_reset)
0456 SYM (_d0_reset):
0457     .long   0
0458 
0459 PUBLIC (_d1_reset)
0460 SYM (_d1_reset):
0461     .long   0
0462 
0463 END_DATA_DCL
0464 
0465 END
0466