source: rtems/c/src/lib/libbsp/m68k/mrm332/start/start.c @ 332484b5

4.104.114.84.95
Last change on this file since 332484b5 was 332484b5, checked in by Joel Sherrill <joel.sherrill@…>, on 05/25/01 at 16:28:46

2000-05-25 Matt Cross <profesor@…>

  • New MRM332 BSP for the Mini RoboMind? board based on the 68332 microcontroller designed and build by Mark Castelluccio. For details on the MRM see http://www.robominds.com.
  • .cvsignore, ChangeLog? Makefile.am, README, bsp_specs, clock/.cvsignore, clock/Makefile.am, clock/ckinit.c, configure.in, console/.cvsignore, console/Makefile.am, console/console.c, include/.cvsignore, include/Makefile.am, include/bsp.h, include/mrm332.h, misc/dotests, misc/gdbinit68, misc/interr.c, spurious/.cvsignore, spurious/Makefile.am, spurious/spinit.c, start/.cvsignore, start/Makefile.am, start/start.c, startup/.cvsignore, startup/Makefile.am, startup/bspclean.c, startup/bspstart.c, startup/except_vect_332_ROM.S, startup/linkcmds, startup/linkcmds_ROM, timer/.cvsignore, timer/Makefile.am, timer/timer.c, times, wrapup/.cvsignore, wrapup/Makefile.am: Initial files.
  • Property mode set to 100644
File size: 8.3 KB
Line 
1/*
2 *  $Id
3 */
4
5#include <mrm332.h>
6#include <sim.h>
7#define __START_C__
8#include "bsp.h"
9
10m68k_isr_entry M68Kvec[256];
11m68k_isr_entry vectors[256];
12char * const __argv[]= {"main", ""};
13
14void  boot_card(int argc, char * const argv[]);
15
16/*
17 *  This prototype really should have the noreturn attribute but
18 *  that causes a warning. Not sure how to fix that.
19 */
20/* void dumby_start ()  __attribute__ ((noreturn)); */
21void dumby_start ();
22
23void  dumby_start() {
24
25  /* Put the header necessary for the modified CPU32bug to automatically
26     start up rtems: */
27  asm volatile ( ".long 0xbeefbeef ;
28                  .long 0 ;
29                  .long start");
30
31  /* We need to by-pass the link instruction since the RAM chip-
32     select pins are not yet configured. */
33  asm volatile ( ".global start ;
34                  start:");
35
36  /* disable interrupts, copy CPU32bug vectors, load stack pointer */
37  asm volatile ( "oriw  #0x0700, %sr;
38                  movel  #end, %d0;
39                  addl   #_StackSize,%d0;
40                  movel  %d0,%sp;
41                  movel  %d0,%a6"
42                  );
43
44  /* include in ram_init.S */
45  /*
46   * Initalize the SIM module.
47   * The stack pointer is not usable until the RAM chip select lines
48   * are configured. The following code must remain inline.
49   */
50
51  /* Module Configuration Register */
52  /*    see section(s) 3.1.3-3.1.6 of the SIM Reference Manual */
53  *SIMCR = (unsigned short int)
54    (FRZSW | SAM(0,8,SHEN) | (MM*SIM_MM) | SAM(SIM_IARB,0,IARB));
55
56  /* Synthesizer Control Register */
57  /*    see section(s) 4.8 */
58  /* end include in ram_init.S */
59  *SYNCR = (unsigned short int)
60    ( SAM(MRM_W,15,VCO) | SAM(0x0,14,PRESCALE) | SAM(MRM_Y,8,COUNTER) );
61  while (! (*SYNCR & SLOCK));   /* protect from clock overshoot */
62  /* include in ram_init.S */
63  *SYNCR = (unsigned short int)
64    ( SAM(MRM_W,15,VCO) | SAM(MRM_X,14,PRESCALE) | SAM(MRM_Y,8,COUNTER) );
65
66  /* System Protection Control Register */
67  /*    !!! can only write to once after reset !!! */
68  /*    see section 3.8.4 of the SIM Reference Manual */
69  *SYPCR = (unsigned char)( HME | BME );
70
71  /* Periodic Interrupr Control Register */
72  /*    see section 3.8.2 of the SIM Reference Manual */
73  *PICR = (unsigned short int)
74    ( SAM(0,8,PIRQL) | SAM(MRM_PIV,0,PIV) );
75  /*     ^^^ zero disables interrupt, don't enable here or ram_init will
76         be wrong. It's enabled below. */
77
78  /* Periodic Interrupt Timer Register */
79  /*    see section 3.8.3 of the SIM Reference Manual */
80  *PITR = (unsigned short int)( SAM(0x09,0,PITM) );
81  /*    1.098mS interrupt, assuming 32.768 KHz input clock */
82
83  /* Port C Data */
84  /*    load values before enabled */
85  *PORTC = (unsigned char) 0x0;
86
87#if 0
88  /* Don't touch these on MRM, they are set up by CPU32bug at boot time. */
89
90  /* Chip-Select Base Address Register */
91  /*    see section 7 of the SIM Reference Manual */
92  *CSBARBT = (unsigned short int)
93    (((0x000000 >> 8)&0xfff8) | BS_512K ); /* 512k bytes located at 0x0000 */
94  *CSBAR0 = (unsigned short int)
95    (((0x000000 >> 8)&0xfff8) | BS_1M );   /* 1M bytes located at 0x0000 */
96  *CSBAR1 = (unsigned short int)
97    (((0x080000 >> 8)&0xfff8) | BS_256K ); /* 256k bytes located at 0x80000 */
98  *CSBAR2 = (unsigned short int)
99    (((0x080000 >> 8)&0xfff8) | BS_256K ); /* 256k bytes located at 0x80000 */
100  *CSBAR3 = (unsigned short int)         
101    (((0x0C0000 >> 8)&0xfff8) | BS_256K ); /* 256k bytes located at 0xC0000 */
102  *CSBAR4 = (unsigned short int)
103    (((0x0C0000 >> 8)&0xfff8) | BS_256K ); /* 256k bytes located at 0xC0000 */
104  *CSBAR5 = (unsigned short int)         
105    (0xfff8 | BS_64K);                   /* AVEC interrupts */
106
107#if 0
108#ifdef EFI332_v040b
109  *CSBAR6 = (unsigned short int)
110    (((0x000000 >> 8)&0xfff8) | BS_512K ); /* 512k bytes located at 0x0000 */
111  *CSBAR8 = (unsigned short int) /* PCMCIA IOCS */
112    (((0x0c0000 >> 8)&0xfff8) | BS_64K ); /* 64k bytes located at 0xc0000 */
113  *CSBAR9 = (unsigned short int) /* PCMCIA MEMCS */
114    (((0x0D0000 >> 8)&0xfff8) | BS_64K ); /* 64k bytes located at 0xd0000 */
115#else /* EFI332_v040b */
116  *CSBAR10 = (unsigned short int)
117    (((0x000000 >> 8)&0xfff8) | BS_512K ); /* 512k bytes located at 0x0000 */
118#endif /* EFI332_v040b */
119#endif
120
121  /* Chip-Select Options Registers */
122  /*    see section 7 of the SIM Reference Manual */
123#ifdef FLASHWRITE
124  *CSORBT = (unsigned short int)
125    ( BothBytes | ReadWrite | SyncAS | WaitStates_0 | UserSupSpace );
126#else /* FLASHWRITE */
127  *CSORBT = (unsigned short int)
128    ( BothBytes | ReadOnly | SyncAS | WaitStates_0 | UserSupSpace );
129#endif /* FLASHWRITE */
130  *CSOR0 = (unsigned short int)
131    ( BothBytes | ReadOnly | SyncAS | External | UserSupSpace );
132  *CSOR1 = (unsigned short int)
133    ( LowerByte | ReadWrite | SyncAS | FastTerm | UserSupSpace );
134  *CSOR2 = (unsigned short int)
135    ( UpperByte | ReadWrite | SyncAS | FastTerm | UserSupSpace );
136  *CSOR3 = (unsigned short int)
137    ( LowerByte | ReadWrite | SyncAS | FastTerm | UserSupSpace );
138  *CSOR4 = (unsigned short int)
139    ( UpperByte | ReadWrite | SyncAS | FastTerm | UserSupSpace );
140  *CSOR5 = (unsigned short int)
141    ( BothBytes | ReadWrite | SyncAS | CPUSpace | IPLevel_any | AVEC );
142
143#if 0
144#ifdef EFI332_v040b
145  *CSOR6 = (unsigned short int)
146    ( BothBytes | ReadOnly | SyncAS | External | UserSupSpace );
147  *CSOR8 = (unsigned short int)
148    ( BothBytes | ReadWrite | SyncAS | External | UserSupSpace );
149  *CSOR9 = (unsigned short int)
150    ( BothBytes | ReadWrite | SyncAS | External | UserSupSpace );
151#else /* EFI332_v040b */
152  *CSOR10 = (unsigned short int)
153    ( BothBytes | ReadOnly | SyncAS | External | UserSupSpace );
154#endif /* EFI332_v040b */
155#endif
156
157  /* Chip Select Pin Assignment Register 0 */
158  /*    see section 7 of the SIM Reference Manual */
159  *CSPAR0 = (unsigned short int)(
160     SAM(DisOut,CS_5,0x3000) |  /* AVEC (internally) */
161     SAM(CS16bit,CS_4,0x0c00) | /* RAM UDS, bank2 */
162     SAM(CS16bit,CS_3,0x0300) | /* RAM LDS, bank2 */
163     SAM(CS16bit,CS_2,0x00c0)|  /* RAM UDS, bank1 */
164     SAM(CS16bit,CS_1,0x0030)|  /* RAM LDS, bank1 */
165     SAM(CS16bit,CS_0,0x000c)|  /* W/!R */
166     SAM(CS16bit,CSBOOT,0x0003) /* ROM CS */
167     );
168
169  /* Chip Select Pin Assignment Register 1 */
170  /*    see section 7 of the SIM Reference Manual */
171#ifdef EFI332_v040b
172  *CSPAR1 = (unsigned short int)(
173     SAM(DisOut,CS_10,0x300)|   /* ECLK */
174     SAM(CS16bit,CS_9,0x0c0) |  /* PCMCIA MEMCS */
175     SAM(CS16bit,CS_8,0x030) |  /* PCMCIA IOCS */
176     SAM(DisOut,CS_7,0x00c) |   /* PC4 */
177     SAM(CS16bit,CS_6,0x003)    /* ROM !OE */
178     );
179#else /* EFI332_v040b */
180  *CSPAR1 = (unsigned short int)(
181     SAM(CS16bit,CS_10,0x300)|  /* ROM !OE */
182     SAM(DisOut,CS_9,0x0c0) |   /* PC6 */
183     SAM(DisOut,CS_8,0x030) |   /* PC5 */
184     SAM(DisOut,CS_7,0x00c) |   /* PC4 */
185     SAM(DisOut,CS_6,0x003)     /* PC3 */
186     );
187#endif /* EFI332_v040b */
188
189#endif /* Don't touch on MRM */
190
191  /* Port E and F Data Register */
192  /*    see section 9 of the SIM Reference Manual */
193  *PORTE0 = (unsigned char) 0;
194  *PORTF0 = (unsigned char) 0;
195
196  /* Port E and F Data Direction Register */
197  /*    see section 9 of the SIM Reference Manual */
198  *DDRE = (unsigned char) 0xff;
199  *DDRF = (unsigned char) 0xfd;
200 
201  /* Port E and F Pin Assignment Register */
202  /*    see section 9 of the SIM Reference Manual */
203  *PEPAR = (unsigned char) 0;
204  *PFPAR = (unsigned char) 0;
205
206  /* end of SIM initalization code */
207  /* end include in ram_init.S */
208
209  /*
210   * Initialize RAM by copying the .data section out of ROM (if
211   * needed) and "zero-ing" the .bss section.
212   */
213  {
214    register char *src = _etext;
215    register char *dst = _copy_start;
216
217    if (_copy_data_from_rom)
218      /* ROM has data at end of text; copy it. */
219      while (dst < _edata)
220        *dst++ = *src++;
221   
222    /* Zero bss */
223    for (dst = _clear_start; dst< end; dst++)
224      {
225        *dst = 0;
226      }
227  }
228
229  /*
230   * Initialize vector table.
231   */
232  {
233    m68k_isr_entry *monitors_vector_table;
234
235    m68k_get_vbr(monitors_vector_table);
236
237    M68Kvec[  4 ] = monitors_vector_table[  4 ];   /* breakpoints vector */
238    M68Kvec[  9 ] = monitors_vector_table[  9 ];   /* trace vector */
239    M68Kvec[ 31 ] = monitors_vector_table[ 31 ];   /* level 7 interrupt */
240    M68Kvec[ 47 ] = monitors_vector_table[ 47 ];   /* system call vector */
241    M68Kvec[ 66 ] = monitors_vector_table[ 66 ];   /* user defined */
242   
243    m68k_set_vbr(&M68Kvec);
244  }
245
246  /*
247   * Initalize the board.
248   */
249  Spurious_Initialize();
250  console_init();
251
252  /*
253   * Execute main with arguments argc and agrv.
254   */
255  boot_card(1,__argv);
256  reboot();
257
258}
259
Note: See TracBrowser for help on using the repository browser.