source: rtems/c/src/lib/libbsp/m68k/efi332/start/start.c @ 437366f

4.104.114.84.95
Last change on this file since 437366f was 437366f, checked in by Joel Sherrill <joel.sherrill@…>, on 04/07/97 at 21:25:42

removed noreturn from prototype to avoid warnings.

  • Property mode set to 100644
File size: 5.9 KB
Line 
1#include <efi332.h>
2#include <sim.h>
3#define __START_C__
4#include "bsp.h"
5
6m68k_isr_entry M68Kvec[256];
7m68k_isr_entry vectors[256];
8char * const __argv[]= {"main", ""};
9char * const __env[]= {""};
10
11int main(const int argc, char * const argv[], char * const env[]);
12
13/*
14 *  This prototype really should have the noreturn attribute but
15 *  that causes a warning since it appears that the routine does
16 *  return.
17 *
18 *   void dumby_start ()  __attribute__ ((noreturn));
19 */
20
21void dumby_start ();
22void  dumby_start() {
23
24  /* We need to by-pass the link instruction since the RAM chip-
25     select pins are not yet configured. */
26  asm volatile ( ".global start ;
27                  start:");
28
29  /* disable interrupts, load stack pointer */
30  asm volatile ( "oriw  #0x0700, %sr;
31                  moveal #M68Kvec, %a0;
32                  movec %a0, %vbr;
33                  movel  #_end, %d0;
34                  addl   " STACK_SIZE ",%d0;
35                  movel  %d0,%sp;
36                  link %a6, #0"
37                  );
38
39  /* include in ram_init.S */
40  /*
41   * Initalize the SIM module.
42   * The stack pointer is not usable until the RAM chip select lines
43   * are configured. The following code must remain inline.
44   */
45
46  /* Module Configuration Register */
47  /*    see section(s) 3.1.3-3.1.6 of the SIM Reference Manual */
48  *SIMCR = (unsigned short int)
49    (FRZSW | FRZBM | SAM(0,8,SHEN) | (MM*SIM_MM) | SAM(SIM_IARB,0,IARB));
50
51  /* Synthesizer Control Register */
52  /*    see section(s) 4.8 */
53  /* end include in ram_init.S */
54  *SYNCR = (unsigned short int)
55    ( SAM(EFI_W,15,W) | SAM(0x0,14,X) | SAM(EFI_Y,8,Y) | STSIM );
56  while (! (*SYNCR & SLOCK));   /* protect from clock overshoot */
57  /* include in ram_init.S */
58  *SYNCR = (unsigned short int)
59    ( SAM(EFI_W,15,W) | SAM(EFI_X,14,X) | SAM(EFI_Y,8,Y) | STSIM );
60
61  /* System Protection Control Register */
62  /*    !!! can only write to once after reset !!! */
63  /*    see section 3.8.4 of the SIM Reference Manual */
64  *SYPCR = (unsigned char)( SAM(0x3,4,SWT) | HME | BME );
65
66  /* Periodic Interrupr Control Register */
67  /*    see section 3.8.2 of the SIM Reference Manual */
68  *PICR = (unsigned short int)
69    ( SAM(0,8,PIRQL) | SAM(EFI_PIV,0,PIV) );
70  /*     ^^^ zero disables interrupt, don't enable here or ram_init will
71         be wrong. It's enabled below. */
72
73  /* Periodic Interrupt Timer Register */
74  /*    see section 3.8.3 of the SIM Reference Manual */
75  *PITR = (unsigned short int)( SAM(0x09,0,PITM) );
76  /*    1.098mS interrupt */
77
78  /* Port C Data */
79  /*    load values before enabled */
80  *PORTC = (unsigned char) 0x0;
81
82  /* Chip-Select Base Address Register */
83  /*    see section 7 of the SIM Reference Manual */
84  *CSBARBT = (unsigned short int)
85    (((0x000000 >> 8)&0xfff8) | BS_512K ); /* 512k bytes located at 0x0000 */
86  *CSBAR0 = (unsigned short int)
87    (((0x000000 >> 8)&0xfff8) | BS_1M );   /* 1M bytes located at 0x0000 */
88  *CSBAR1 = (unsigned short int)
89    (((0x080000 >> 8)&0xfff8) | BS_256K ); /* 256k bytes located at 0x80000 */
90  *CSBAR2 = (unsigned short int)
91    (((0x080000 >> 8)&0xfff8) | BS_256K ); /* 256 bytes located at 0x80000 */
92  *CSBAR3 = (unsigned short int)         
93    (0xfff8 | BS_64K);                   /* AVEC interrupts */
94  *CSBAR10 = (unsigned short int)
95    (((0x000000 >> 8)&0xfff8) | BS_512K ); /* 512k bytes located at 0x0000 */
96
97  /* Chip-Select Options Registers */
98  /*    see section 7 of the SIM Reference Manual */
99  *CSORBT = (unsigned short int)
100    ( BothBytes | ReadWrite | SyncAS | WaitStates_13 | UserSupSpace );
101  *CSOR0 = (unsigned short int)
102    ( BothBytes | ReadOnly | SyncAS | External | UserSupSpace );
103  *CSOR1 = (unsigned short int)
104    ( LowerByte | ReadWrite | SyncAS | FastTerm | UserSupSpace );
105  *CSOR2 = (unsigned short int)
106    ( UpperByte | ReadWrite | SyncAS | FastTerm | UserSupSpace );
107  *CSOR3 = (unsigned short int)
108    ( BothBytes | ReadWrite | SyncAS | CPUSpace | IPLevel_any | AVEC );
109  *CSOR10 = (unsigned short int)
110    ( BothBytes | ReadOnly | SyncAS | External | UserSupSpace );
111
112  /* Chip Select Pin Assignment Register 0 */
113  /*    see section 7 of the SIM Reference Manual */
114  *CSPAR0 = (unsigned short int)(
115     SAM(DisOut,CS_5,0x3000) |  /* PC2 */
116     SAM(DisOut,CS_4,0x0c00) |  /* PC1 */
117     SAM(DisOut,CS_3,0x0300) |  /* AVEC (internally) */
118     SAM(CS16bit,CS_2,0x00c0)|  /* RAM UDS */
119     SAM(CS16bit,CS_1,0x0030)|  /* RAM LDS */
120     SAM(CS16bit,CS_0,0x000c)|  /* W/!R */
121     SAM(CS16bit,CSBOOT,0x0003) /* ROM DS */
122     );
123
124  /* Chip Select Pin Assignment Register 1 */
125  /*    see section 7 of the SIM Reference Manual */
126  *CSPAR1 = (unsigned short int)(
127     SAM(CS16bit,CS_10,0x300)|  /* ECLK */
128     SAM(DisOut,CS_9,0x0c0) |   /* PC6 */
129     SAM(DisOut,CS_8,0x030) |   /* PC5 */
130     SAM(DisOut,CS_7,0x00c) |   /* PC4 */
131     SAM(DisOut,CS_6,0x003)     /* PC3 */
132     );
133
134  /* Port E and F Data Register */
135  /*    see section 9 of the SIM Reference Manual */
136  *PORTE0 = (unsigned char) 0;
137  *PORTF0 = (unsigned char) 0;
138
139  /* Port E and F Data Direction Register */
140  /*    see section 9 of the SIM Reference Manual */
141  *DDRE = (unsigned char) 0xff;
142  *DDRF = (unsigned char) 0xfd;
143 
144  /* Port E and F Pin Assignment Register */
145  /*    see section 9 of the SIM Reference Manual */
146  *PEPAR = (unsigned char) 0;
147  *PFPAR = (unsigned char) 0;
148
149  /* end of SIM initalization code */
150  /* end include in ram_init.S */
151
152
153
154  /*
155   * Initialize RAM by copying the .data section out of ROM (if
156   * needed) and "zero-ing" the .bss section.
157   */
158  {
159    register char *src = _endtext;
160    register char *dst = _sdata;
161
162    if (_copy_data_from_rom)
163      /* ROM has data at end of text; copy it. */
164      while (dst < _edata)
165        *dst++ = *src++;
166   
167    /* Zero bss */
168    for (dst = __bss_start; dst< _end; dst++)
169      *dst = 0;
170  }
171
172  /*
173   * Initalize the board.
174   */
175  Spurious_Initialize();
176  console_init();
177
178  /*
179   * Execute main with arguments argv and environment env
180   */
181  main(1, __argv, __env);
182
183  reboot();
184}
185
186void reboot() {asm("trap #15");}
187
Note: See TracBrowser for help on using the repository browser.