]> rtime.felk.cvut.cz Git - rtems-devel.git/blob - rtems-patches/current/rtems-clone-mrm332-to-mo376.patch
Lower resources demands of OMK LwIP test fit in internal eSRAM for such TMS570 link...
[rtems-devel.git] / rtems-patches / current / rtems-clone-mrm332-to-mo376.patch
1 ---
2  c/src/lib/libbsp/m68k/mo376/ChangeLog                     |  567 ++++
3  c/src/lib/libbsp/m68k/mo376/Makefile.am                   |   50 
4  c/src/lib/libbsp/m68k/mo376/README                        |   24 
5  c/src/lib/libbsp/m68k/mo376/bsp_specs                     |   13 
6  c/src/lib/libbsp/m68k/mo376/clock/ckinit.c                |   96 
7  c/src/lib/libbsp/m68k/mo376/configure.ac                  |   20 
8  c/src/lib/libbsp/m68k/mo376/console/console.c             |  171 +
9  c/src/lib/libbsp/m68k/mo376/console/sci.c                 | 1596 ++++++++++++++
10  c/src/lib/libbsp/m68k/mo376/console/sci.h                 |  234 ++
11  c/src/lib/libbsp/m68k/mo376/include/bsp.h                 |  131 +
12  c/src/lib/libbsp/m68k/mo376/include/bspopts.h.in          |   16 
13  c/src/lib/libbsp/m68k/mo376/include/mrm332.h              |   70 
14  c/src/lib/libbsp/m68k/mo376/include/tm27.h                |   34 
15  c/src/lib/libbsp/m68k/mo376/misc/dotests                  |   15 
16  c/src/lib/libbsp/m68k/mo376/misc/gdbinit68                |   16 
17  c/src/lib/libbsp/m68k/mo376/misc/interr.c                 |   99 
18  c/src/lib/libbsp/m68k/mo376/preinstall.am                 |   66 
19  c/src/lib/libbsp/m68k/mo376/spurious/spinit.c             |  105 
20  c/src/lib/libbsp/m68k/mo376/start/start.S                 |  150 +
21  c/src/lib/libbsp/m68k/mo376/startup/bspclean.c            |   27 
22  c/src/lib/libbsp/m68k/mo376/startup/bspstart.c            |   59 
23  c/src/lib/libbsp/m68k/mo376/startup/except_vect_332_ROM.S |  293 ++
24  c/src/lib/libbsp/m68k/mo376/startup/linkcmds              |  164 +
25  c/src/lib/libbsp/m68k/mo376/startup/linkcmds_ROM          |  200 +
26  c/src/lib/libbsp/m68k/mo376/startup/start_c.c             |  125 +
27  c/src/lib/libbsp/m68k/mo376/timer/timer.c                 |   61 
28  c/src/lib/libbsp/m68k/mo376/times                         |  195 +
29  make/custom/mo376.cfg                                     |   55 
30  28 files changed, 4652 insertions(+)
31
32 Index: rtems/make/custom/mo376.cfg
33 ===================================================================
34 --- /dev/null   1970-01-01 00:00:00.000000000 +0000
35 +++ rtems/make/custom/mo376.cfg 2009-11-29 01:21:43.173939736 +0100
36 @@ -0,0 +1,55 @@
37 +#
38 +#  Config file for the mrm332 BSP
39 +#
40 +#  $Id: mrm332.cfg,v 1.18 2008/06/11 08:17:27 ccj Exp $
41 +#
42 +
43 +include $(RTEMS_ROOT)/make/custom/default.cfg
44 +
45 +RTEMS_CPU=m68k
46 +RTEMS_CPU_MODEL=m68332
47 +
48 +# This is the actual bsp directory used during the build process.
49 +RTEMS_BSP_FAMILY=mrm332
50 +
51 +#  This contains the compiler options necessary to select the CPU model
52 +#  and (hopefully) optimize for it. 
53 +CPU_CFLAGS = -mcpu=cpu32
54 +
55 +# optimize flag: typically -O2
56 +CFLAGS_OPTIMIZE_V = -O2 -g -fomit-frame-pointer
57 +
58 +ifeq ($(MRM_IN_ROM),yes)
59 +# Build a rommable image - move the .data section after the .text section
60 +# in the image.
61 +CPU_CFLAGS += -qnolinkcmds -T $(exec_prefix)/mrm332/lib/linkcmds_ROM
62 +endif
63 +
64 +ifeq ($(MRM_IN_ROM),yes)
65 +define bsp-post-link
66 +       $(OBJCOPY) --adjust-section-vma \
67 +         .data=`m68k-rtems-objdump --section-headers $(basename $@).pxe | \
68 +         awk 'function h2d(x) { x=toupper(x); digits=length(x); s=0 ; \
69 +              for (p=digits; p>0; p--) \
70 +              s += (16^(p-1)) * ( index("0123456789ABCDEF",\
71 +               substr(x,1+digits-p,1)) -1 );\
72 +               return s } ;\
73 +               /\.text/ { base = $$4 ; size = $$3 };\
74 +               END { printf("0x%x", h2d(base) + h2d(size)) }'\
75 +              ` $(basename $@).pxe $(basename $@).exe
76 +       $(OBJCOPY) -O srec $(basename $@).exe $(basename $@).srec
77 +       sed -e 's/.$$//' -e '/^S0/d' $(basename $@).srec | \
78 +           $(PACKHEX) > $(basename $@)$(DOWNEXT)
79 +       $(NM) -g -n $(basename $@).pxe > $(basename $@).pnum
80 +       rm -f $(basename $@).srec $(basename $@).srec
81 +       $(default-bsp-post-link)
82 +endef
83 +else
84 +define bsp-post-link
85 +       $(OBJCOPY) -O srec $(basename $@).exe $(basename $@).srec
86 +       sed -e 's/.$$//' -e '/^S0/d' $(basename $@).srec | \
87 +           $(PACKHEX) > $(basename $@)$(DOWNEXT)
88 +       rm -f $(basename $@).srec
89 +       $(default-bsp-post-link)
90 +endef
91 +endif
92 Index: rtems/c/src/lib/libbsp/m68k/mo376/console/sci.h
93 ===================================================================
94 --- /dev/null   1970-01-01 00:00:00.000000000 +0000
95 +++ rtems/c/src/lib/libbsp/m68k/mo376/console/sci.h     2006-09-11 23:43:55.000000000 +0200
96 @@ -0,0 +1,234 @@
97 +/****************************************************************************
98 +* File:     sci.h
99 +*
100 +* Desc:     This is the include file for the serial communications interface.
101 +*
102 +* Note:     See bsp.h,confdefs.h,system.h for installing drivers into RTEMS.
103 +*
104 +* $Id: sci.h,v 1.5 2006/09/11 21:43:55 joel Exp $
105 +****************************************************************************/
106 +
107 +#ifndef _sci_h_
108 +#define _sci_h_
109 +
110 +/*******************************************************************************
111 +  IOCTL commands for the sci driver.
112 +  I'm still working on these...
113 +*******************************************************************************/
114 +
115 +#define SCI_IOCTL_PARITY_NONE           0x00    /* no parity bit after the data bits */
116 +#define SCI_IOCTL_PARITY_ODD            0x01    /* parity bit added after data bits */
117 +#define SCI_IOCTL_PARITY_EVEN           0x02    /* parity bit added after data bits */
118 +#define SCI_IOCTL_PARITY_MARK           0x03    /* parity bit is lo, -12 volts, logical 1 */
119 +#define SCI_IOCTL_PARITY_SPACE          0x04    /* parity bit is hi, +12 volts, logical 0 */
120 +#define SCI_IOCTL_PARITY_FORCED_ON      0x03    /* parity bit is forced hi or lo */
121 +#define SCI_IOCTL_PARITY_FORCED_OFF     0x04    /* parity bit is forced hi or lo */
122 +
123 +#define SCI_IOCTL_BAUD_RATE             0x20    /* set the baud rate, arg is baud */
124 +
125 +#define SCI_IOCTL_DATA_BITS             0x30    /* set the data bits, arg is # bits */
126 +
127 +#define SCI_IOCTL_STOP_BITS_1           0x40    /* 1 stop bit after char frame */
128 +#define SCI_IOCTL_STOP_BITS_2           0x41    /* 2 stop bit after char frame */
129 +
130 +#define SCI_IOCTL_MODE_NORMAL           0x50    /* normal operating mode */
131 +#define SCI_IOCTL_MODE_LOOP             0x51    /* internal loopback mode */
132 +
133 +#define SCI_IOCTL_FLOW_NONE             0x60    /* no flow control */
134 +#define SCI_IOCTL_FLOW_RTS_CTS          0x61    /* hardware flow control */
135 +
136 +#define SCI_IOCTL_SEND_BREAK            0x70    /* send an rs-232 break */
137 +
138 +#define SCI_IOCTL_MODE_1200             0x80    /* 1200,n,8,1 download mode */
139 +#define SCI_IOCTL_MODE_9600             0x81    /* 9600,n,8,1 download mode */
140 +#define SCI_IOCTL_MODE_9_BIT            0x82    /* 9600,forced,8,1 command mode */
141 +\f
142 +
143 +/*******************************************************************************
144 +  SCI Registers
145 +*******************************************************************************/
146 +
147 +/* SCI Control Register 0  (SCCR0)  $FFFC08
148 +
149 +    8 4 2 1 - 8 4 2 1 - 8 4 2 1 - 8 4 2 1
150 +    ^ ^ ^ ^   ^ ^ ^ ^   ^ ^ ^ ^   ^ ^ ^ ^
151 +    | | | |   | | | |   | | | |   | | | |
152 +    | | | |   | | | |   | | | |   | | | +-----   0 baud rate divisor
153 +    | | | |   | | | |   | | | |   | | +-------   1 baud rate divisor
154 +    | | | |   | | | |   | | | |   | +---------   2 baud rate divisor
155 +    | | | |   | | | |   | | | |   +-----------   3 baud rate divisor
156 +    | | | |   | | | |   | | | |
157 +    | | | |   | | | |   | | | +---------------   4 baud rate divisor
158 +    | | | |   | | | |   | | +-----------------   5 baud rate divisor
159 +    | | | |   | | | |   | +-------------------   6 baud rate divisor
160 +    | | | |   | | | |   +---------------------   7 baud rate divisor
161 +    | | | |   | | | |
162 +    | | | |   | | | +-------------------------   8 baud rate divisor
163 +    | | | |   | | +---------------------------   9 baud rate divisor
164 +    | | | |   | +-----------------------------  10 baud rate divisor
165 +    | | | |   +-------------------------------  11 baud rate divisor
166 +    | | | |
167 +    | | | +-----------------------------------  12 baud rate divisor
168 +    | | +-------------------------------------  13 unused
169 +    | +---------------------------------------  14 unused
170 +    +-----------------------------------------  15 unused
171 +
172 +    0 0 0 0 - 0 0 0 0 - 0 0 0 0 - 0 1 0 0       reset value - (64k baud?)
173 + */
174 +
175 +#define SCI_BAUD_57_6K            9
176 +#define SCI_BAUD_38_4K           14
177 +#define SCI_BAUD_19_2K           27
178 +#define SCI_BAUD_9600            55
179 +#define SCI_BAUD_4800           109
180 +#define SCI_BAUD_2400           218
181 +#define SCI_BAUD_1200           437
182 +\f
183 +
184 +/*  SCI Control Register 1  (SCCR1)  $FFFC0A
185 +
186 +    8 4 2 1 - 8 4 2 1 - 8 4 2 1 - 8 4 2 1
187 +    ^ ^ ^ ^   ^ ^ ^ ^   ^ ^ ^ ^   ^ ^ ^ ^
188 +    | | | |   | | | |   | | | |   | | | |
189 +    | | | |   | | | |   | | | |   | | | +-----   0 send a break
190 +    | | | |   | | | |   | | | |   | | +-------   1 rcvr wakeup mode
191 +    | | | |   | | | |   | | | |   | +---------   2 rcvr enable
192 +    | | | |   | | | |   | | | |   +-----------   3 xmtr enable
193 +    | | | |   | | | |   | | | |
194 +    | | | |   | | | |   | | | +---------------   4 idle line intr enable
195 +    | | | |   | | | |   | | +-----------------   5 rcvr intr enable
196 +    | | | |   | | | |   | +-------------------   6 xmit complete intr enable
197 +    | | | |   | | | |   +---------------------   7 xmtr intr enable
198 +    | | | |   | | | |
199 +    | | | |   | | | +-------------------------   8 wakeup on address mark
200 +    | | | |   | | +---------------------------   9 mode 1=9 bits, 0=8 bits
201 +    | | | |   | +-----------------------------  10 parity enable 1=on, 0=off
202 +    | | | |   +-------------------------------  11 parity type 1=odd, 0=even
203 +    | | | |
204 +    | | | +-----------------------------------  12 idle line select
205 +    | | +-------------------------------------  13 wired-or mode
206 +    | +---------------------------------------  14 loop mode
207 +    +-----------------------------------------  15 unused
208 +  
209 +    0 0 0 0 - 0 0 0 0 - 0 0 0 0 - 0 0 0 0       reset value
210 +*/
211 +
212 +#define SCI_SEND_BREAK          0x0001          /* 0000-0000-0000-0001 */
213 +#define SCI_RCVR_WAKEUP         0x0002          /* 0000-0000-0000-0010 */
214 +#define SCI_ENABLE_RCVR         0x0004          /* 0000-0000-0000-0100 */
215 +#define SCI_ENABLE_XMTR         0x0008          /* 0000-0000-0000-1000 */
216 +
217 +#define SCI_DISABLE_RCVR        0xFFFB          /* 1111-1111-1111-1011 */
218 +#define SCI_DISABLE_XMTR        0xFFF7          /* 1111-1111-1111-0111 */
219 +
220 +#define SCI_ENABLE_INT_IDLE     0x0010          /* 0000-0000-0001-0000 */
221 +#define SCI_ENABLE_INT_RX       0x0020          /* 0000-0000-0010-0000 */
222 +#define SCI_ENABLE_INT_TX_DONE  0x0040          /* 0000-0000-0100-0000 */
223 +#define SCI_ENABLE_INT_TX       0x0080          /* 0000-0000-1000-0000 */
224 +
225 +#define SCI_DISABLE_INT_ALL     0xFF00          /* 1111-1111-0000-0000 ??? */
226 +
227 +#define SCI_DISABLE_INT_RX      0xFFDF          /* 1111-1111-1101-1111 */
228 +#define SCI_CLEAR_RX_INT        0xFFBF          /* 1111-1111-1011-1111 */
229 +#define SCI_DISABLE_INT_TX      0xFF7F          /* 1111-1111-0111-1111 */
230 +#define SCI_CLEAR_TDRE          0xFEFF          /* 1111-1110-1111-1111 */
231 +
232 +#define SCI_RCVR_WAKE_ON_MARK   0x0100          /* 0000-0001-0000-0000 */
233 +#define SCI_9_DATA_BITS         0x0200          /* 0000-0010-0000-0000 */
234 +#define SCI_PARITY_ENABLE       0x0400          /* 0000-0100-0000-0000 */
235 +#define SCI_PARITY_ODD          0x0800          /* 0000-1000-0000-0000 */
236 +
237 +#define SCI_RCVR_WAKE_ON_IDLE   0xFEFF          /* 1111-1110-1111-1111 */
238 +#define SCI_8_DATA_BITS         0xFDFF          /* 1111-1101-1111-1111 */
239 +#define SCI_PARITY_DISABLE      0xFBFF          /* 1111-1011-1111-1111 */
240 +#define SCI_PARITY_EVEN         0xF7FF          /* 1111-0111-1111-1111 */
241 +
242 +#define SCI_PARITY_NONE         0xF3FF          /* 1111-0011-1111-1111 */
243 +
244 +#define SCI_IDLE_LINE_LONG      0x1000          /* 0001-0000-0000-0000 */
245 +#define SCI_TXD_OPEN_DRAIN      0x2000          /* 0010-0000-0000-0000 */
246 +#define SCI_LOOPBACK_MODE       0x4000          /* 0100-0000-0000-0000 */
247 +#define SCI_SCCR1_UNUSED        0x8000          /* 1000-0000-0000-0000 */
248 +\f
249 +
250 +/*  SCI Status Register  (SCSR)  $FFFC0C
251 +
252 +    8 4 2 1 - 8 4 2 1 - 8 4 2 1 - 8 4 2 1
253 +    ^ ^ ^ ^   ^ ^ ^ ^   ^ ^ ^ ^   ^ ^ ^ ^
254 +    | | | |   | | | |   | | | |   | | | |
255 +    | | | |   | | | |   | | | |   | | | +-----   0 PF - parity error
256 +    | | | |   | | | |   | | | |   | | +-------   1 FE - framing error
257 +    | | | |   | | | |   | | | |   | +---------   2 NF - noise flag
258 +    | | | |   | | | |   | | | |   +-----------   3 OR - overrun flag
259 +    | | | |   | | | |   | | | |
260 +    | | | |   | | | |   | | | +---------------   4 IDLE - idle line detected
261 +    | | | |   | | | |   | | +-----------------   5 RAF  - rcvr active flag
262 +    | | | |   | | | |   | +-------------------   6 RDRF - rcv data reg full
263 +    | | | |   | | | |   +---------------------   7 TC   - xmt complete flag
264 +    | | | |   | | | |
265 +    | | | |   | | | +-------------------------   8 TDRE - xmt data reg empty
266 +    | | | |   | | +---------------------------   9 always zero
267 +    | | | |   | +-----------------------------  10 always zero
268 +    | | | |   +-------------------------------  11 always zero
269 +    | | | |
270 +    | | | +-----------------------------------  12 always zero
271 +    | | +-------------------------------------  13 always zero
272 +    | +---------------------------------------  14 always zero
273 +    +-----------------------------------------  15 always zero
274 +  
275 +    0 0 0 0 - 0 0 0 1 - 1 0 0 0 - 0 0 0 0       reset value
276 +*/
277 +
278 +#define SCI_ERROR_PARITY        0x0001          /* 0000-0000-0000-0001 */
279 +#define SCI_ERROR_FRAMING       0x0002          /* 0000-0000-0000-0010 */
280 +#define SCI_ERROR_NOISE         0x0004          /* 0000-0000-0000-0100 */
281 +#define SCI_ERROR_OVERRUN       0x0008          /* 0000-0000-0000-1000 */
282 +
283 +#define SCI_IDLE_LINE           0x0010          /* 0000-0000-0001-0000 */
284 +#define SCI_RCVR_ACTIVE         0x0020          /* 0000-0000-0010-0000 */
285 +#define SCI_RCVR_READY          0x0040          /* 0000-0000-0100-0000 */
286 +#define SCI_XMTR_IDLE           0x0080          /* 0000-0000-1000-0000 */
287 +
288 +#define SCI_CLEAR_RX_INT        0xFFBF          /* 1111-1111-1011-1111 */
289 +
290 +#define SCI_XMTR_READY          0x0100          /* 0000-0001-0000-0000 */
291 +
292 +#define SCI_CLEAR_TDRE          0xFEFF          /* 1111-1110-1111-1111 */
293 +
294 +#define SCI_XMTR_AVAILABLE      0x0180          /* 0000-0001-1000-0000 */
295 +
296 +\f
297 +
298 +/*******************************************************************************
299 +  Function prototypes
300 +*******************************************************************************/
301 +
302 +#ifdef __cplusplus
303 +extern "C" {
304 +#endif
305 +
306 +/* look at console_open to see how this is called */
307 +
308 +const rtems_termios_callbacks * SciGetTermiosHandlers( int32_t   polled );
309 +
310 +/* SCI interrupt */
311 +
312 +/*rtems_isr SciIsr( rtems_vector_number vector ); */
313 +
314 +/*int32_t   SciOpenPolled    ( int32_t   major, int32_t   minor, void *arg ); */
315 +/*int32_t   SciOpenInterrupt ( int32_t   major, int32_t   minor, void *arg ); */
316 +
317 +/*int32_t   SciClose         ( int32_t   major, int32_t   minor, void *arg ); */
318 +
319 +/*int32_t   SciWritePolled   ( int32_t   minor, const char *buf, int32_t   len ); */
320 +/*int32_t   SciWriteInterrupt( int32_t   minor, const char *buf, int32_t   len ); */
321 +
322 +/*int32_t   SciReadPolled    ( int32_t   minor ); */
323 +
324 +/*int32_t   SciSetAttributes ( int32_t   minor, const struct termios *t ); */
325 +
326 +#ifdef __cplusplus
327 +}
328 +#endif
329 +
330 +#endif  /* _sci_h_ */
331 Index: rtems/c/src/lib/libbsp/m68k/mo376/startup/linkcmds_ROM
332 ===================================================================
333 --- /dev/null   1970-01-01 00:00:00.000000000 +0000
334 +++ rtems/c/src/lib/libbsp/m68k/mo376/startup/linkcmds_ROM      2008-03-04 00:06:30.000000000 +0100
335 @@ -0,0 +1,200 @@
336 +/*  linkcmds
337 + *
338 + *  $Id: linkcmds_ROM,v 1.5 2008/03/03 23:06:30 joel Exp $
339 + */
340 +
341 +OUTPUT_ARCH(m68k)
342 +STARTUP(except_vect_332_ROM.o)
343 +__DYNAMIC  =  0;
344 +
345 +/*
346 + * ROM:
347 + * +--------------------+ <- low memory
348 + * | .text              |
349 + * |        etext       |
350 + * |        ctor list   | the ctor and dtor lists are for
351 + * |        dtor list   | C++ support
352 + * |        _endtext    |
353 + * | temporary .data    | .data is moved to RAM by crt0
354 + * |                    |
355 + * +--------------------+ <- high memory
356 + *
357 + *
358 + * RAM:
359 + * +--------------------+ <- low memory
360 + * | .data              | initialized data goes here
361 + * |        _sdata      |
362 + * |        _edata      |
363 + * +--------------------+
364 + * | .bss               |
365 + * |        __bss_start | start of bss, cleared by crt0
366 + * |        _end        | start of heap, used by sbrk()
367 + * +--------------------+
368 + * |    heap space      |
369 + * |        _ENDHEAP    |
370 + * |    stack space     | 
371 + * |        __stack     | top of stack
372 + * +--------------------+ <- high memory
373 + */
374 +
375 +MEMORY
376 +{
377 +  rom     : ORIGIN = 0x90000, LENGTH = 0x70000
378 +  ram     : ORIGIN = 0x03000, LENGTH = 0x7d000
379 +}
380 +
381 +_RamBase = DEFINED(_RamBase) ? _RamBase : 0x003000;
382 +_RamSize = DEFINED(_RamSize) ? _RamSize : 0x7d000;
383 +_RamEnd = _RamBase + _RamSize;
384 +
385 +__end_of_ram = 0x080000;
386 +_copy_data_from_rom = 1;
387 +_HeapSize = DEFINED(_HeapSize) ? _HeapSize : 0x10000;
388 +_StackSize = DEFINED(_StackSize) ? _StackSize : 0x2000;
389 +
390 +/*
391 + * 
392 + */
393 +SECTIONS
394 +{
395 +  .text :
396 +  {
397 +    . = .;
398 +    CREATE_OBJECT_SYMBOLS
399 +    text_start = .;
400 +    _text_start = .;
401 +    *(.text*)
402 +    . = ALIGN (16);
403 +
404 +
405 +    /*
406 +     * Initialization and finalization code.
407 +     *
408 +     * Various files can provide initialization and finalization
409 +     * functions.  crtbegin.o and crtend.o are two instances. The
410 +     * body of these functions are in .init and .fini sections. We
411 +     * accumulate the bodies here, and prepend function prologues
412 +     * from crti.o and function epilogues from crtn.o. crti.o must
413 +     * be linked first; crtn.o must be linked last.  Because these
414 +     * are wildcards, it doesn't matter if the user does not
415 +     * actually link against crti.o and crtn.o; the linker won't
416 +     * look for a file to match a wildcard.  The wildcard also
417 +     * means that it doesn't matter which directory crti.o and
418 +     * crtn.o are in. 
419 +     */
420 +    PROVIDE (_init = .);
421 +    *crti.o(.init)
422 +    *(.init)
423 +    *crtn.o(.init)
424 +    PROVIDE (_fini = .);
425 +    *crti.o(.fini)
426 +    *(.fini)
427 +    *crtn.o(.fini)
428 +
429 +    /*
430 +     * Special FreeBSD sysctl sections.
431 +     */
432 +    . = ALIGN (16);
433 +    __start_set_sysctl_set = .;
434 +    *(set_sysctl_*);
435 +    __stop_set_sysctl_set = ABSOLUTE(.);
436 +    *(set_domain_*);
437 +    *(set_pseudo_*);
438 +
439 +    /*
440 +     * C++ constructors/destructors
441 +     *
442 +     * gcc uses crtbegin.o to find the start of the constructors
443 +     * and destructors so we make sure it is first.  Because this
444 +     * is a wildcard, it doesn't matter if the user does not
445 +     * actually link against crtbegin.o; the linker won't look for
446 +     * a file to match a wildcard.  The wildcard also means that
447 +     * it doesn't matter which directory crtbegin.o is in. The
448 +     * constructor and destructor list are terminated in
449 +     * crtend.o.  The same comments apply to it.
450 +     */
451 +    . = ALIGN (16);
452 +    *crtbegin.o(.ctors)
453 +    *(.ctors)
454 +    *crtend.o(.ctors)
455 +    *crtbegin.o(.dtors)
456 +    *(.dtors)
457 +    *crtend.o(.dtors)
458 +
459 +    *(.eh_frame)
460 +    . = ALIGN (16);
461 +
462 +    /*
463 +     * Read-only data
464 +     */
465 +    . = ALIGN (16);
466 +    _rodata_start = . ;
467 +    *(.rodata*)
468 +    *(.gnu.linkonce.r*)
469 +
470 +    etext = ALIGN(0x10);
471 +    __CTOR_LIST__ = .;
472 +    LONG((__CTOR_END__ - __CTOR_LIST__) / 4 - 2)
473 +    *(.ctors)
474 +    LONG(0)
475 +    __CTOR_END__ = .;
476 +    __DTOR_LIST__ = .;
477 +    LONG((__DTOR_END__ - __DTOR_LIST__) / 4 - 2)
478 +    *(.dtors)
479 +    LONG(0)
480 +    __DTOR_END__ = .;
481 +    *(.lit)
482 +    *(.shdata)
483 +    _etext = .;
484 +    _endtext = .;
485 +  } > rom
486 +  .gcc_exc :
487 +  AT ( ADDR(.text) + SIZEOF( .text ) )
488 +  {
489 +    *(.gcc_exc)
490 +  } > ram
491 +  .data :
492 +  {
493 +    data_start = .;
494 +    _data_start = .;
495 +    _copy_start = .;
496 +    _sdata = . ;
497 +    *(.data)
498 +    *(.gnu.linkonce.d*)
499 +    *(.gcc_except_table*)
500 +    *(.jcr)
501 +
502 +    CONSTRUCTORS
503 +    edata = ALIGN(0x10);
504 +    _edata = .;
505 +  } > ram
506 +  .shbss :
507 +  {
508 +    *(.shbss)
509 +  } > ram
510 +  .bss :
511 +  {
512 +    __bss_start = ALIGN(0x8);
513 +    bss_start = .;
514 +    _bss_start = .;
515 +    _clear_start = .;
516 +    *(.shbss)
517 +    *(.dynbss)
518 +    *(.bss* .gnu.linkonce.b.*)
519 +    *(COMMON)
520 +    . = ALIGN (16);
521 +    end = .;
522 +    _end = ALIGN(0x8);
523 +    __end = ALIGN(0x8);
524 +
525 +    _WorkspaceBase = . + _StackSize;
526 +  } > ram
527 +  .stab . (NOLOAD) :
528 +  {
529 +    [ .stab ]
530 +  }
531 +  .stabstr . (NOLOAD) :
532 +  {
533 +    [ .stabstr ]
534 +  }
535 +}
536 Index: rtems/c/src/lib/libbsp/m68k/mo376/startup/except_vect_332_ROM.S
537 ===================================================================
538 --- /dev/null   1970-01-01 00:00:00.000000000 +0000
539 +++ rtems/c/src/lib/libbsp/m68k/mo376/startup/except_vect_332_ROM.S     2004-04-21 18:01:35.000000000 +0200
540 @@ -0,0 +1,293 @@
541 +/*
542 + *  $Id: except_vect_332_ROM.S,v 1.3 2004/04/21 16:01:35 ralf Exp $
543 + */
544 +
545 +/* Exception Vector definitions follow */
546 +
547 +       /* !!! Warning !!! This table is not tested, and
548 +          the user must make sure it is complete. */
549 +
550 +       /* If we use TRAP #15 for reboot, note that group 0 and 1 exceptions
551 +          will have priority. */
552 +
553 +       /* This is the "magic word" that CPU32bug uses to indicate that
554 +          there is a bootable image here. */
555 +       .long   0xBEEFBEEF
556 +
557 +       /* Vector 0:    RESET:  Initial SSP */
558 +       .long   _RamEnd
559 +       /* Vector 1:    RESET:  Initial PC */
560 +       .long   start
561 +
562 +       /* default action for undefined vectors is to re-boot */
563 +
564 +       /* Note group 0 and 1 exception (like trace) have priority
565 +          over other exceptions (like trap #15) that may call this. */
566 +
567 +       /* Vectors 2-255 */
568 +       .long reboot   /* exception vector:   2 */
569 +       .long reboot   /* exception vector:   3 */
570 +       .long reboot   /* exception vector:   4 */
571 +       .long reboot   /* exception vector:   5 */
572 +       .long reboot   /* exception vector:   6 */
573 +       .long reboot   /* exception vector:   7 */
574 +       .long reboot   /* exception vector:   8 */
575 +       .long reboot   /* exception vector:   9 */
576 +       .long reboot   /* exception vector:  10 */
577 +       .long reboot   /* exception vector:  11 */
578 +       .long reboot   /* exception vector:  12 */
579 +       .long reboot   /* exception vector:  13 */
580 +       .long reboot   /* exception vector:  14 */
581 +       .long reboot   /* exception vector:  15 */
582 +       .long reboot   /* exception vector:  16 */
583 +       .long reboot   /* exception vector:  17 */
584 +       .long reboot   /* exception vector:  18 */
585 +       .long reboot   /* exception vector:  19 */
586 +       .long reboot   /* exception vector:  20 */
587 +       .long reboot   /* exception vector:  21 */
588 +       .long reboot   /* exception vector:  22 */
589 +       .long reboot   /* exception vector:  23 */
590 +       .long reboot   /* exception vector:  24 */
591 +       .long reboot   /* exception vector:  25 */
592 +       .long reboot   /* exception vector:  26 */
593 +       .long reboot   /* exception vector:  27 */
594 +       .long reboot   /* exception vector:  28 */
595 +       .long reboot   /* exception vector:  29 */
596 +       .long reboot   /* exception vector:  30 */
597 +       .long reboot   /* exception vector:  31 */
598 +       .long reboot   /* exception vector:  32 */
599 +       .long reboot   /* exception vector:  33 */
600 +       .long reboot   /* exception vector:  34 */
601 +       .long reboot   /* exception vector:  35 */
602 +       .long reboot   /* exception vector:  36 */
603 +       .long reboot   /* exception vector:  37 */
604 +       .long reboot   /* exception vector:  38 */
605 +       .long reboot   /* exception vector:  39 */
606 +       .long reboot   /* exception vector:  40 */
607 +       .long reboot   /* exception vector:  41 */
608 +       .long reboot   /* exception vector:  42 */
609 +       .long reboot   /* exception vector:  43 */
610 +       .long reboot   /* exception vector:  44 */
611 +       .long reboot   /* exception vector:  45 */
612 +       .long reboot   /* exception vector:  46 */
613 +       .long _reboot  /* the reboot trap:   47 */
614 +       .long reboot   /* exception vector:  48 */
615 +       .long reboot   /* exception vector:  49 */
616 +       .long reboot   /* exception vector:  50 */
617 +       .long reboot   /* exception vector:  51 */
618 +       .long reboot   /* exception vector:  52 */
619 +       .long reboot   /* exception vector:  53 */
620 +       .long reboot   /* exception vector:  54 */
621 +       .long reboot   /* exception vector:  55 */
622 +       .long reboot   /* exception vector:  56 */
623 +       .long reboot   /* exception vector:  57 */
624 +       .long reboot   /* exception vector:  58 */
625 +       .long reboot   /* exception vector:  59 */
626 +       .long reboot   /* exception vector:  60 */
627 +       .long reboot   /* exception vector:  61 */
628 +       .long reboot   /* exception vector:  62 */
629 +       .long reboot   /* exception vector:  63 */
630 +       .long reboot   /* exception vector:  64 */
631 +       .long reboot   /* exception vector:  65 */
632 +       .long reboot   /* exception vector:  66 */
633 +       .long reboot   /* exception vector:  67 */
634 +       .long reboot   /* exception vector:  68 */
635 +       .long reboot   /* exception vector:  69 */
636 +       .long reboot   /* exception vector:  70 */
637 +       .long reboot   /* exception vector:  71 */
638 +       .long reboot   /* exception vector:  72 */
639 +       .long reboot   /* exception vector:  73 */
640 +       .long reboot   /* exception vector:  74 */
641 +       .long reboot   /* exception vector:  75 */
642 +       .long reboot   /* exception vector:  76 */
643 +       .long reboot   /* exception vector:  77 */
644 +       .long reboot   /* exception vector:  78 */
645 +       .long reboot   /* exception vector:  79 */
646 +       .long reboot   /* exception vector:  80 */
647 +       .long reboot   /* exception vector:  81 */
648 +       .long reboot   /* exception vector:  82 */
649 +       .long reboot   /* exception vector:  83 */
650 +       .long reboot   /* exception vector:  84 */
651 +       .long reboot   /* exception vector:  85 */
652 +       .long reboot   /* exception vector:  86 */
653 +       .long reboot   /* exception vector:  87 */
654 +       .long reboot   /* exception vector:  88 */
655 +       .long reboot   /* exception vector:  89 */
656 +       .long reboot   /* exception vector:  90 */
657 +       .long reboot   /* exception vector:  91 */
658 +       .long reboot   /* exception vector:  92 */
659 +       .long reboot   /* exception vector:  93 */
660 +       .long reboot   /* exception vector:  94 */
661 +       .long reboot   /* exception vector:  95 */
662 +       .long reboot   /* exception vector:  96 */
663 +       .long reboot   /* exception vector:  97 */
664 +       .long reboot   /* exception vector:  98 */
665 +       .long reboot   /* exception vector:  99 */
666 +       .long reboot   /* exception vector: 100 */
667 +       .long reboot   /* exception vector: 101 */
668 +       .long reboot   /* exception vector: 102 */
669 +       .long reboot   /* exception vector: 103 */
670 +       .long reboot   /* exception vector: 104 */
671 +       .long reboot   /* exception vector: 105 */
672 +       .long reboot   /* exception vector: 106 */
673 +       .long reboot   /* exception vector: 107 */
674 +       .long reboot   /* exception vector: 108 */
675 +       .long reboot   /* exception vector: 109 */
676 +       .long reboot   /* exception vector: 110 */
677 +       .long reboot   /* exception vector: 111 */
678 +       .long reboot   /* exception vector: 112 */
679 +       .long reboot   /* exception vector: 113 */
680 +       .long reboot   /* exception vector: 114 */
681 +       .long reboot   /* exception vector: 115 */
682 +       .long reboot   /* exception vector: 116 */
683 +       .long reboot   /* exception vector: 117 */
684 +       .long reboot   /* exception vector: 118 */
685 +       .long reboot   /* exception vector: 119 */
686 +       .long reboot   /* exception vector: 120 */
687 +       .long reboot   /* exception vector: 121 */
688 +       .long reboot   /* exception vector: 122 */
689 +       .long reboot   /* exception vector: 123 */
690 +       .long reboot   /* exception vector: 124 */
691 +       .long reboot   /* exception vector: 125 */
692 +       .long reboot   /* exception vector: 126 */
693 +       .long reboot   /* exception vector: 127 */
694 +       .long reboot   /* exception vector: 128 */
695 +       .long reboot   /* exception vector: 129 */
696 +       .long reboot   /* exception vector: 130 */
697 +       .long reboot   /* exception vector: 131 */
698 +       .long reboot   /* exception vector: 132 */
699 +       .long reboot   /* exception vector: 133 */
700 +       .long reboot   /* exception vector: 134 */
701 +       .long reboot   /* exception vector: 135 */
702 +       .long reboot   /* exception vector: 136 */
703 +       .long reboot   /* exception vector: 137 */
704 +       .long reboot   /* exception vector: 138 */
705 +       .long reboot   /* exception vector: 139 */
706 +       .long reboot   /* exception vector: 140 */
707 +       .long reboot   /* exception vector: 141 */
708 +       .long reboot   /* exception vector: 142 */
709 +       .long reboot   /* exception vector: 143 */
710 +       .long reboot   /* exception vector: 144 */
711 +       .long reboot   /* exception vector: 145 */
712 +       .long reboot   /* exception vector: 146 */
713 +       .long reboot   /* exception vector: 147 */
714 +       .long reboot   /* exception vector: 148 */
715 +       .long reboot   /* exception vector: 149 */
716 +       .long reboot   /* exception vector: 150 */
717 +       .long reboot   /* exception vector: 151 */
718 +       .long reboot   /* exception vector: 152 */
719 +       .long reboot   /* exception vector: 153 */
720 +       .long reboot   /* exception vector: 154 */
721 +       .long reboot   /* exception vector: 155 */
722 +       .long reboot   /* exception vector: 156 */
723 +       .long reboot   /* exception vector: 157 */
724 +       .long reboot   /* exception vector: 158 */
725 +       .long reboot   /* exception vector: 159 */
726 +       .long reboot   /* exception vector: 160 */
727 +       .long reboot   /* exception vector: 161 */
728 +       .long reboot   /* exception vector: 162 */
729 +       .long reboot   /* exception vector: 163 */
730 +       .long reboot   /* exception vector: 164 */
731 +       .long reboot   /* exception vector: 165 */
732 +       .long reboot   /* exception vector: 166 */
733 +       .long reboot   /* exception vector: 167 */
734 +       .long reboot   /* exception vector: 168 */
735 +       .long reboot   /* exception vector: 169 */
736 +       .long reboot   /* exception vector: 170 */
737 +       .long reboot   /* exception vector: 171 */
738 +       .long reboot   /* exception vector: 172 */
739 +       .long reboot   /* exception vector: 173 */
740 +       .long reboot   /* exception vector: 174 */
741 +       .long reboot   /* exception vector: 175 */
742 +       .long reboot   /* exception vector: 176 */
743 +       .long reboot   /* exception vector: 177 */
744 +       .long reboot   /* exception vector: 178 */
745 +       .long reboot   /* exception vector: 179 */
746 +       .long reboot   /* exception vector: 180 */
747 +       .long reboot   /* exception vector: 181 */
748 +       .long reboot   /* exception vector: 182 */
749 +       .long reboot   /* exception vector: 183 */
750 +       .long reboot   /* exception vector: 184 */
751 +       .long reboot   /* exception vector: 185 */
752 +       .long reboot   /* exception vector: 186 */
753 +       .long reboot   /* exception vector: 187 */
754 +       .long reboot   /* exception vector: 188 */
755 +       .long reboot   /* exception vector: 189 */
756 +       .long reboot   /* exception vector: 190 */
757 +       .long reboot   /* exception vector: 191 */
758 +       .long reboot   /* exception vector: 192 */
759 +       .long reboot   /* exception vector: 193 */
760 +       .long reboot   /* exception vector: 194 */
761 +       .long reboot   /* exception vector: 195 */
762 +       .long reboot   /* exception vector: 196 */
763 +       .long reboot   /* exception vector: 197 */
764 +       .long reboot   /* exception vector: 198 */
765 +       .long reboot   /* exception vector: 199 */
766 +       .long reboot   /* exception vector: 200 */
767 +       .long reboot   /* exception vector: 201 */
768 +       .long reboot   /* exception vector: 202 */
769 +       .long reboot   /* exception vector: 203 */
770 +       .long reboot   /* exception vector: 204 */
771 +       .long reboot   /* exception vector: 205 */
772 +       .long reboot   /* exception vector: 206 */
773 +       .long reboot   /* exception vector: 207 */
774 +       .long reboot   /* exception vector: 208 */
775 +       .long reboot   /* exception vector: 209 */
776 +       .long reboot   /* exception vector: 210 */
777 +       .long reboot   /* exception vector: 211 */
778 +       .long reboot   /* exception vector: 212 */
779 +       .long reboot   /* exception vector: 213 */
780 +       .long reboot   /* exception vector: 214 */
781 +       .long reboot   /* exception vector: 215 */
782 +       .long reboot   /* exception vector: 216 */
783 +       .long reboot   /* exception vector: 217 */
784 +       .long reboot   /* exception vector: 218 */
785 +       .long reboot   /* exception vector: 219 */
786 +       .long reboot   /* exception vector: 220 */
787 +       .long reboot   /* exception vector: 221 */
788 +       .long reboot   /* exception vector: 222 */
789 +       .long reboot   /* exception vector: 223 */
790 +       .long reboot   /* exception vector: 224 */
791 +       .long reboot   /* exception vector: 225 */
792 +       .long reboot   /* exception vector: 226 */
793 +       .long reboot   /* exception vector: 227 */
794 +       .long reboot   /* exception vector: 228 */
795 +       .long reboot   /* exception vector: 229 */
796 +       .long reboot   /* exception vector: 230 */
797 +       .long reboot   /* exception vector: 231 */
798 +       .long reboot   /* exception vector: 232 */
799 +       .long reboot   /* exception vector: 233 */
800 +       .long reboot   /* exception vector: 234 */
801 +       .long reboot   /* exception vector: 235 */
802 +       .long reboot   /* exception vector: 236 */
803 +       .long reboot   /* exception vector: 237 */
804 +       .long reboot   /* exception vector: 238 */
805 +       .long reboot   /* exception vector: 239 */
806 +       .long reboot   /* exception vector: 240 */
807 +       .long reboot   /* exception vector: 241 */
808 +       .long reboot   /* exception vector: 242 */
809 +       .long reboot   /* exception vector: 243 */
810 +       .long reboot   /* exception vector: 244 */
811 +       .long reboot   /* exception vector: 245 */
812 +       .long reboot   /* exception vector: 246 */
813 +       .long reboot   /* exception vector: 247 */
814 +       .long reboot   /* exception vector: 248 */
815 +       .long reboot   /* exception vector: 249 */
816 +       .long reboot   /* exception vector: 250 */
817 +       .long reboot   /* exception vector: 251 */
818 +       .long reboot   /* exception vector: 252 */
819 +       .long reboot   /* exception vector: 253 */
820 +       .long reboot   /* exception vector: 254 */
821 +       .long reboot   /* exception vector: 255 */
822 +
823 +_reboot:
824 +       move    #0x2700,%sr     /* mask interrupts */
825 +       movea.l (0x0).w,%a7     /* load stack */
826 +       movea.l (0x4).w,%a0     /* jmp to location of reset vector */
827 +       jmp     (%a0)
828 +
829 +reboot:
830 +       trap    #15             /* use trap exception to enter supervisor
831 +                                  state. Trace mode ( and other group 0
832 +                                  and 1 exceptions) *could* screw this up if
833 +                                  not vectored to reboot or did not return. */
834 Index: rtems/c/src/lib/libbsp/m68k/mo376/console/console.c
835 ===================================================================
836 --- /dev/null   1970-01-01 00:00:00.000000000 +0000
837 +++ rtems/c/src/lib/libbsp/m68k/mo376/console/console.c 2008-05-12 20:43:28.000000000 +0200
838 @@ -0,0 +1,171 @@
839 +/*
840 + *  This file contains the generic console driver shell used
841 + *  by all console drivers using libchip.
842 + *
843 + *  This driver uses the termios pseudo driver.
844 + *
845 + *  COPYRIGHT (c) 1989-1997.
846 + *  On-Line Applications Research Corporation (OAR).
847 + *
848 + *  The license and distribution terms for this file may be
849 + *  found in the file LICENSE in this distribution or at
850 + *  http://www.rtems.com/license/LICENSE.
851 + *
852 + *  $Id: console.c,v 1.9 2008/05/12 18:43:28 joel Exp $
853 + */
854 +
855 +#include <bsp.h>
856 +#include <rtems/libio.h>
857 +#include <termios.h>
858 +#include "sci.h"
859 +
860 +/*PAGE
861 + *
862 + *  console_open
863 + *
864 + *  open a port as a termios console.
865 + */
866 +
867 +rtems_device_driver console_open(
868 +  rtems_device_major_number major,
869 +  rtems_device_minor_number minor,
870 +  void                    * arg
871 +)
872 +{
873 +    rtems_status_code status;
874 +
875 +    /* the console is opened three times at startup */
876 +    /* for standard input, output, and error */
877 +
878 +    /* Get correct callback structure for the device */
879 +
880 +    /* argument of FALSE gives us interrupt driven serial io */
881 +    /* argument of TRUE  gives us polling   based  serial io */
882 +
883 +    /* SCI internal uart */
884 +
885 +    status = rtems_termios_open( major, minor, arg, SciGetTermiosHandlers( TRUE ) );
886 +
887 +    return status;
888 +}
889 +
890 +/*PAGE
891 + *
892 + *  console_close
893 + *
894 + *  This routine closes a port that has been opened as console.
895 + */
896 +
897 +rtems_device_driver console_close(
898 +  rtems_device_major_number major,
899 +  rtems_device_minor_number minor,
900 +  void                    * arg
901 +)
902 +{
903 +  return rtems_termios_close (arg);
904 +}
905 +
906 +/*PAGE
907 + *
908 + *  console_read
909 + *
910 + *  This routine uses the termios driver to read a character.
911 + */
912 +
913 +rtems_device_driver console_read(
914 +  rtems_device_major_number major,
915 +  rtems_device_minor_number minor,
916 +  void                    * arg
917 +)
918 +{
919 +  return rtems_termios_read (arg);
920 +}
921 +
922 +/*PAGE
923 + *
924 + *  console_write
925 + *
926 + *  this routine uses the termios driver to write a character.
927 + */
928 +
929 +rtems_device_driver console_write(
930 +  rtems_device_major_number major,
931 +  rtems_device_minor_number minor,
932 +  void                    * arg
933 +)
934 +{
935 +  return rtems_termios_write (arg);
936 +}
937 +
938 +/*PAGE
939 + *
940 + *  console_control
941 + *
942 + *  this routine uses the termios driver to process io
943 + */
944 +
945 +rtems_device_driver console_control(
946 +  rtems_device_major_number major,
947 +  rtems_device_minor_number minor,
948 +  void                    * arg
949 +)
950 +{
951 +  return rtems_termios_ioctl (arg);
952 +}
953 +
954 +/*PAGE
955 + *
956 + *  console_initialize
957 + *
958 + *  Routine called to initialize the console device driver.
959 + */
960 +
961 +rtems_device_driver console_initialize(
962 +  rtems_device_major_number  major,
963 +  rtems_device_minor_number  minor_arg,
964 +  void                      *arg
965 +)
966 +{
967 +  rtems_status_code          status;
968 +
969 +  /*
970 +   * initialize the termio interface.
971 +   */
972 +  rtems_termios_initialize();
973 +
974 +  /*
975 +   * register the SCI device name for termios
976 +   * do this over in the sci driver init routine?
977 +   */
978 +
979 +  status = rtems_io_register_name( "/dev/sci", major, 0 );
980 +
981 +  if (status != RTEMS_SUCCESSFUL)
982 +  {
983 +    rtems_fatal_error_occurred(status);
984 +  }
985 +
986 +  /*
987 +   * Link the uart device to the console device
988 +   */
989 +
990 +#if 1
991 +  status = rtems_io_register_name( "/dev/console", major, 0 );
992 +
993 +  if (status != RTEMS_SUCCESSFUL)
994 +  {
995 +    rtems_fatal_error_occurred(status);
996 +  }
997 +#else
998 +  if ( link( "/dev/sci", "/dev/console") < 0 )
999 +  {
1000 +    rtems_fatal_error_occurred( RTEMS_IO_ERROR );
1001 +  }
1002 +#endif
1003 +
1004 +  /*
1005 +   * Console Initialize Succesful
1006 +   */
1007 +
1008 +  return RTEMS_SUCCESSFUL;
1009 +}
1010 Index: rtems/c/src/lib/libbsp/m68k/mo376/start/start.S
1011 ===================================================================
1012 --- /dev/null   1970-01-01 00:00:00.000000000 +0000
1013 +++ rtems/c/src/lib/libbsp/m68k/mo376/start/start.S     2009-11-29 01:11:56.463558538 +0100
1014 @@ -0,0 +1,150 @@
1015 +/*
1016 + *  $Id
1017 + */
1018 +
1019 +#include "mrm332.h"
1020 +#include <rtems/asm.h>
1021 +#include <rtems/m68k/sim.h>
1022 +
1023 +BEGIN_CODE
1024 +
1025 +  /* Put the header necessary for the modified CPU32bug to automatically
1026 +     start up rtems: */
1027 +#if 0
1028 +.long 0xbeefbeef ;
1029 +#endif
1030 +.long 0 ;
1031 +.long start ;
1032 +
1033 +.global start
1034 +       start:
1035 +
1036 +       oriw   #0x0700,sr
1037 +       movel  #end, d0
1038 +       addl   #_StackSize,d0
1039 +       movel  d0,sp
1040 +       movel  d0,a6
1041 +
1042 +  /* include in ram_init.S */
1043 +  /*
1044 +   * Initalize the SIM module.
1045 +   * The stack pointer is not usable until the RAM chip select lines
1046 +   * are configured. The following code must remain inline.
1047 +   */
1048 +
1049 +  /* Module Configuration Register */
1050 +  /*    see section(s) 3.1.3-3.1.6 of the SIM Reference Manual */
1051 +       lea     SIMCR, a0
1052 +       movew   #FRZSW,d0
1053 +       oriw    #SAM(0,8,SHEN),d0
1054 +       oriw    #(MM*SIM_MM),d0
1055 +       oriw    #SAM(SIM_IARB,0,IARB),d0
1056 +       movew   d0, a0@
1057 +
1058 +       jsr     start_c /* Jump to the C startup code */
1059 +
1060 +END_CODE
1061 +
1062 +#if 0
1063 +
1064 +  /* Synthesizer Control Register */
1065 +  /*    see section(s) 4.8 */
1066 +  /* end include in ram_init.S */
1067 +  *SYNCR = (unsigned short int)
1068 +    ( SAM(MRM_W,15,VCO) | SAM(0x0,14,PRESCALE) | SAM(MRM_Y,8,COUNTER) );
1069 +  while (! (*SYNCR & SLOCK));  /* protect from clock overshoot */
1070 +  /* include in ram_init.S */
1071 +  *SYNCR = (unsigned short int)
1072 +    ( SAM(MRM_W,15,VCO) | SAM(MRM_X,14,PRESCALE) | SAM(MRM_Y,8,COUNTER) );
1073 +
1074 +  /* System Protection Control Register */
1075 +  /*    !!! can only write to once after reset !!! */
1076 +  /*    see section 3.8.4 of the SIM Reference Manual */
1077 +  *SYPCR = (unsigned char)( HME | BME );
1078 +
1079 +  /* Periodic Interrupr Control Register */
1080 +  /*    see section 3.8.2 of the SIM Reference Manual */
1081 +  *PICR = (unsigned short int)
1082 +    ( SAM(0,8,PIRQL) | SAM(MRM_PIV,0,PIV) );
1083 +  /*     ^^^ zero disables interrupt, don't enable here or ram_init will
1084 +        be wrong. It's enabled below. */
1085 +
1086 +  /* Periodic Interrupt Timer Register */
1087 +  /*    see section 3.8.3 of the SIM Reference Manual */
1088 +  *PITR = (unsigned short int)( SAM(0x09,0,PITM) );
1089 +  /*    1.098mS interrupt, assuming 32.768 KHz input clock */
1090 +
1091 +  /* Port C Data */
1092 +  /*    load values before enabled */
1093 +  *PORTC = (unsigned char) 0x0;
1094 +
1095 +  /* Port E and F Data Register */
1096 +  /*    see section 9 of the SIM Reference Manual */
1097 +  *PORTE0 = (unsigned char) 0;
1098 +  *PORTF0 = (unsigned char) 0;
1099 +
1100 +  /* Port E and F Data Direction Register */
1101 +  /*    see section 9 of the SIM Reference Manual */
1102 +  *DDRE = (unsigned char) 0xff;
1103 +  *DDRF = (unsigned char) 0xfd;
1104 +
1105 +  /* Port E and F Pin Assignment Register */
1106 +  /*    see section 9 of the SIM Reference Manual */
1107 +  *PEPAR = (unsigned char) 0;
1108 +  *PFPAR = (unsigned char) 0;
1109 +
1110 +  /* end of SIM initalization code */
1111 +  /* end include in ram_init.S */
1112 +
1113 +  /*
1114 +   * Initialize RAM by copying the .data section out of ROM (if
1115 +   * needed) and "zero-ing" the .bss section.
1116 +   */
1117 +  {
1118 +    register char *src = _etext;
1119 +    register char *dst = _copy_start;
1120 +
1121 +    if (_copy_data_from_rom)
1122 +      /* ROM has data at end of text; copy it. */
1123 +      while (dst < _edata)
1124 +       *dst++ = *src++;
1125 +
1126 +    /* Zero bss */
1127 +    for (dst = _clear_start; dst< end; dst++)
1128 +      {
1129 +       *dst = 0;
1130 +      }
1131 +  }
1132 +
1133 +  /*
1134 +   * Initialize vector table.
1135 +   */
1136 +  {
1137 +    m68k_isr_entry *monitors_vector_table;
1138 +
1139 +    m68k_get_vbr(monitors_vector_table);
1140 +
1141 +    M68Kvec[  4 ] = monitors_vector_table[  4 ];   /* breakpoints vector */
1142 +    M68Kvec[  9 ] = monitors_vector_table[  9 ];   /* trace vector */
1143 +    M68Kvec[ 31 ] = monitors_vector_table[ 31 ];   /* level 7 interrupt */
1144 +    M68Kvec[ 47 ] = monitors_vector_table[ 47 ];   /* system call vector */
1145 +    M68Kvec[ 66 ] = monitors_vector_table[ 66 ];   /* user defined */
1146 +
1147 +    m68k_set_vbr(&M68Kvec);
1148 +  }
1149 +
1150 +  /*
1151 +   * Initalize the board.
1152 +   */
1153 +  Spurious_Initialize();
1154 +  console_init();
1155 +
1156 +  /*
1157 +   * Execute main with arguments argc and agrv.
1158 +   */
1159 +  boot_card(1,__argv);
1160 +  reboot();
1161 +
1162 +}
1163 +
1164 +#endif
1165 Index: rtems/c/src/lib/libbsp/m68k/mo376/misc/dotests
1166 ===================================================================
1167 --- /dev/null   1970-01-01 00:00:00.000000000 +0000
1168 +++ rtems/c/src/lib/libbsp/m68k/mo376/misc/dotests      2009-11-29 01:11:56.463558538 +0100
1169 @@ -0,0 +1,15 @@
1170 +#! /bin/bash
1171 +#
1172 +#  $Id: dotests,v 1.1 2001/05/25 16:28:46 joel Exp $
1173 +#
1174 +
1175 +mkdir MyTests
1176 +find -name MyTests -prune -or -name "*.nxe" -exec cp {} MyTests \;
1177 +
1178 +stty 1:0:80001cb2:0:3:1c:7f:15:4:5:1:0:11:13:1a:0:12:f:17:16:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0 </dev/ttyS1
1179 +/bin/cp /dev/ttyS1 screen &
1180 +cpJob=$!
1181 +
1182 +( cd MyTests; for f in *nxe; do m68k-elf-gdb ${f} </dev/null; done )
1183 +
1184 +kill -9 $cpJob
1185 Index: rtems/c/src/lib/libbsp/m68k/mo376/include/bsp.h
1186 ===================================================================
1187 --- /dev/null   1970-01-01 00:00:00.000000000 +0000
1188 +++ rtems/c/src/lib/libbsp/m68k/mo376/include/bsp.h     2007-12-11 16:49:20.000000000 +0100
1189 @@ -0,0 +1,131 @@
1190 +/*  bsp.h
1191 + *
1192 + *  This include file contains all mrm board IO definitions.
1193 + *
1194 + *  COPYRIGHT (c) 1989-1999.
1195 + *  On-Line Applications Research Corporation (OAR).
1196 + *
1197 + *  The license and distribution terms for this file may be
1198 + *  found in the file LICENSE in this distribution or at
1199 + *  http://www.rtems.com/license/LICENSE.
1200 + *
1201 + *  $Id: bsp.h,v 1.17 2007/12/11 15:49:20 joel Exp $
1202 + */
1203 +
1204 +#ifndef _BSP_H
1205 +#define _BSP_H
1206 +
1207 +#ifdef __cplusplus
1208 +extern "C" {
1209 +#endif
1210 +
1211 +#include <bspopts.h>
1212 +
1213 +#include <rtems.h>
1214 +#include <rtems/bspIo.h>
1215 +#include <rtems/clockdrv.h>
1216 +#include <rtems/console.h>
1217 +#include <rtems/iosupp.h>
1218 +#include <mrm332.h>
1219 +#include <rtems/m68k/sim.h>
1220 +#include <rtems/m68k/qsm.h>
1221 +
1222 +/*
1223 + *  confdefs.h overrides for this BSP:
1224 + *   - number of termios serial ports (defaults to 1)
1225 + *   - Interrupt stack space is not minimum if defined.
1226 + */
1227 +
1228 +#define CONSOLE_SCI
1229 +/* #define CONFIGURE_NUMBER_OF_TERMIOS_PORTS 2 */
1230 +
1231 +/*
1232 + *  Simple spin delay in microsecond units for device drivers.
1233 + *  This is very dependent on the clock speed of the target.
1234 + */
1235 +
1236 +#define rtems_bsp_delay( microseconds ) \
1237 +  { register uint32_t         _delay=(microseconds); \
1238 +    register uint32_t         _tmp=123; \
1239 +    asm volatile( "0: \
1240 +                     nbcd      %0 ; \
1241 +                     nbcd      %0 ; \
1242 +                     dbf       %1,0b" \
1243 +                  : "=d" (_tmp), "=d" (_delay) \
1244 +                  : "0"  (_tmp), "1"  (_delay) ); \
1245 +  }
1246 +
1247 +/* externals */
1248 +
1249 +extern char _etext[];
1250 +extern char _copy_start[];
1251 +extern char _edata[];
1252 +extern char _clear_start[];
1253 +extern char end[];
1254 +extern char _copy_data_from_rom[];
1255 +
1256 +/* constants */
1257 +
1258 +#ifdef __START_C__
1259 +#define STACK_SIZE "#0x800"
1260 +#else
1261 +#define STACK_SIZE 0x800
1262 +#endif
1263 +
1264 +/* macros */
1265 +
1266 +#define RAW_PUTS(str) \
1267 +  { register char *ptr = str; \
1268 +    while (*ptr) SCI_output_char(*ptr++); \
1269 +  }
1270 +
1271 +#define RAW_PUTI(n) { \
1272 +    register int i, j; \
1273 +    \
1274 +    RAW_PUTS("0x"); \
1275 +    for (i=28;i>=0;i -= 4) { \
1276 +      j = (n>>i) & 0xf; \
1277 +      SCI_output_char( (j>9 ? j-10+'a' : j+'0') ); \
1278 +    } \
1279 +  }
1280 +
1281 +/* miscellaneous stuff assumed to exist */
1282 +
1283 +extern m68k_isr_entry M68Kvec[];   /* vector table address */
1284 +
1285 +extern int stack_size;
1286 +extern int stack_start;
1287 +
1288 +/*
1289 + *  Device Driver Table Entries
1290 + */
1291 +
1292 +/*
1293 + * NOTE: Use the standard Console driver entry
1294 + */
1295 +
1296 +/*
1297 + * NOTE: Use the standard Clock driver entry
1298 + */
1299 +
1300 +/* functions */
1301 +
1302 +void bsp_cleanup( void );
1303 +
1304 +m68k_isr_entry set_vector(
1305 +  rtems_isr_entry     handler,
1306 +  rtems_vector_number vector,
1307 +  int                 type
1308 +);
1309 +
1310 +void Spurious_Initialize(void);
1311 +
1312 +void _UART_flush(void);
1313 +
1314 +void outbyte(char);
1315 +
1316 +#ifdef __cplusplus
1317 +}
1318 +#endif
1319 +
1320 +#endif
1321 Index: rtems/c/src/lib/libbsp/m68k/mo376/misc/interr.c
1322 ===================================================================
1323 --- /dev/null   1970-01-01 00:00:00.000000000 +0000
1324 +++ rtems/c/src/lib/libbsp/m68k/mo376/misc/interr.c     2008-09-06 19:09:08.000000000 +0200
1325 @@ -0,0 +1,99 @@
1326 +/*
1327 + *  Internal Error Handler
1328 + *
1329 + *  COPYRIGHT (c) 1989-1999.
1330 + *  On-Line Applications Research Corporation (OAR).
1331 + *
1332 + *  The license and distribution terms for this file may be
1333 + *  found in the file LICENSE in this distribution or at
1334 + *  http://www.rtems.com/license/LICENSE.
1335 + *
1336 + *  $Id: interr.c,v 1.5 2008/09/06 17:09:08 ralf Exp $
1337 + */
1338 +
1339 +#include <rtems/system.h>
1340 +#include <rtems/score/interr.h>
1341 +#include <rtems/score/sysstate.h>
1342 +#include <rtems/score/userext.h>
1343 +
1344 +/*PAGE
1345 + *
1346 + *  _Internal_error_Occurred
1347 + *
1348 + *  This routine will invoke the fatal error handler supplied by the user
1349 + *  followed by the the default one provided by the executive.  The default
1350 + *  error handler assumes no hardware is present to help inform the user
1351 + *  of the problem.  Halt stores the error code in a known register,
1352 + *  disables interrupts, and halts the CPU.  If the CPU does not have a
1353 + *  halt instruction, it will loop to itself.
1354 + *
1355 + *  Input parameters:
1356 + *    the_source  - what subsystem the error originated in
1357 + *    is_internal - if the error was internally generated
1358 + *    the_error   - fatal error status code
1359 + *
1360 + *  Output parameters:
1361 + *    As much information as possible is stored in a CPU dependent fashion.
1362 + *    See the CPU dependent code for more information.
1363 + *
1364 + *  NOTE: The the_error is not necessarily a directive status code.
1365 + */
1366 +
1367 +/*
1368 + * Ugly hack.... _CPU_Fatal_halt() disonnects the bdm. Without this
1369 + * change, the_error is only known only to the cpu :).
1370 + *
1371 + * From "bsp.h" which is not yet available in the arch tree during
1372 + * this phase of install. jsg
1373 + */
1374 +void outbyte(char);
1375 +void bsp_cleanup( void );
1376 +
1377 +#define RAW_PUTS(str) \
1378 +  { register char *ptr = str; \
1379 +    while (*ptr) outbyte(*ptr++); \
1380 +  }
1381 +
1382 +#define RAW_PUTI(n) { \
1383 +    register int i, j; \
1384 +    \
1385 +    RAW_PUTS("0x"); \
1386 +    for (i=28;i>=0;i -= 4) { \
1387 +      j = (n>>i) & 0xf; \
1388 +      outbyte( (j>9 ? j-10+'a' : j+'0') ); \
1389 +    } \
1390 +  }
1391 +
1392 +void volatile _Internal_error_Occurred(
1393 +  Internal_errors_Source  the_source,
1394 +  bool                    is_internal,
1395 +  uint32_t                the_error
1396 +)
1397 +{
1398 +
1399 +  _Internal_errors_What_happened.the_source  = the_source;
1400 +  _Internal_errors_What_happened.is_internal = is_internal;
1401 +  _Internal_errors_What_happened.the_error   = the_error;
1402 +
1403 +  _User_extensions_Fatal( the_source, is_internal, the_error );
1404 +
1405 +  _System_state_Set( SYSTEM_STATE_FAILED );
1406 +
1407 +  /* try to print error message to outbyte */
1408 +  RAW_PUTS("\r\nRTEMS: A fatal error has occured.\r\n");
1409 +  RAW_PUTS("RTEMS:    fatal error ");
1410 +  RAW_PUTI( the_error );
1411 +  RAW_PUTS(" (");
1412 +  outbyte( (char)((the_error>>24) & 0xff) );
1413 +  outbyte( (char)((the_error>>16) & 0xff) );
1414 +  outbyte( (char)((the_error>>8) & 0xff) );
1415 +  outbyte( (char)(the_error & 0xff) );
1416 +  RAW_PUTS(").\r\n");
1417 +
1418 +  /* configure peripherals for a safe exit */
1419 +  bsp_cleanup();
1420 +
1421 +  _CPU_Fatal_halt( the_error );
1422 +
1423 +  /* will not return from this routine */
1424 +}
1425 Index: rtems/c/src/lib/libbsp/m68k/mo376/ChangeLog
1426 ===================================================================
1427 --- /dev/null   1970-01-01 00:00:00.000000000 +0000
1428 +++ rtems/c/src/lib/libbsp/m68k/mo376/ChangeLog 2008-12-08 06:15:06.000000000 +0100
1429 @@ -0,0 +1,567 @@
1430 +2008-12-08     Ralf Corsépius <ralf.corsepius@rtems.org>
1431 +
1432 +       * bsp_specs: Backport from CVS-HEAD.
1433 +
1434 +2008-09-30     Joel Sherrill <joel.sherrill@oarcorp.com>
1435 +
1436 +       * timer/timer.c: Eliminate uses of old benchmark timer names.
1437 +
1438 +2008-09-29     Ralf Corsépius <ralf.corsepius@rtems.org>
1439 +
1440 +       * Makefile.am: Remove noinst_PROGRAMS (Unused).
1441 +
1442 +2008-09-06     Ralf Corsépius <ralf.corsepius@rtems.org>
1443 +
1444 +       * misc/interr.c: Convert to "bool".
1445 +
1446 +2008-09-05     Joel Sherrill <joel.sherrill@OARcorp.com>
1447 +
1448 +       * clock/ckinit.c: The Shared Memory Driver no longer requires the
1449 +       special IOCTL in Clock_control. This was a hack which has existed
1450 +       since before the Classic API Timer Manager was implemented. All
1451 +       implementations of and references to Clock_control were removed.
1452 +
1453 +2008-09-05     Ralf Corsépius <ralf.corsepius@rtems.org>
1454 +
1455 +       * timer/timer.c: Convert to "bool".
1456 +
1457 +2008-08-31     Joel Sherrill <joel.sherrill@oarcorp.com>
1458 +
1459 +       * timer/timer.c: Eliminate empty function from every benchmark timer
1460 +       driver. Fix spelling.
1461 +
1462 +2008-08-31     Joel Sherrill <joel.sherrill@oarcorp.com>
1463 +
1464 +       * timer/timer.c: Rename timer driver methods to follow RTEMS
1465 +       programming conventions.
1466 +
1467 +2008-08-19     Ralf Corsépius <ralf.corsepius@rtems.org>
1468 +
1469 +       * console/sci.c, startup/bspstart.c, startup/start_c.c,
1470 +       timer/timer.c: Add missing prototypes.
1471 +
1472 +2008-06-02     Joel Sherrill <joel.sherrill@oarcorp.com>
1473 +
1474 +       * misc/interr.c: Convention calls for leading underscore on private
1475 +       RTEMS variables.
1476 +
1477 +2008-05-14     Joel Sherrill <joel.sherrill@OARcorp.com>
1478 +
1479 +       * Makefile.am: Rework to avoid .rel files.
1480 +
1481 +2008-05-12     Joel Sherrill <joel.sherrill@OARcorp.com>
1482 +
1483 +       * console/console.c, startup/bspstart.c: Refactored and renamed
1484 +       initialization routines to rtems_initialize_data_structures,
1485 +       rtems_initialize_before_drivers, rtems_initialize_device_drivers, and
1486 +       rtems_initialize_start_multitasking. This opened the sequence up so
1487 +       that bootcard() could provide a more robust and flexible framework
1488 +       which is easier to explain and understand. This also lays the
1489 +       groundwork for sharing the division of available memory between the
1490 +       RTEMS workspace and heap and the C library initialization across all
1491 +       BSPs.
1492 +
1493 +2008-03-03     Joel Sherrill <joel.sherrill@OARcorp.com>
1494 +
1495 +       * startup/linkcmds, startup/linkcmds_ROM: Add wildcard to
1496 +       gcc_except_table section so programs compiled with gcc 4.3.x can
1497 +       link.
1498 +
1499 +2007-12-11     Joel Sherrill <joel.sherrill@OARcorp.com>
1500 +
1501 +       * clock/ckinit.c, include/bsp.h, startup/bspstart.c: Eliminate copies
1502 +       of the Configuration Table. Use the RTEMS provided accessor macros to
1503 +       obtain configuration fields.
1504 +
1505 +2007-12-04     Joel Sherrill <joel.sherrill@OARcorp.com>
1506 +
1507 +       * include/bsp.h, startup/bspstart.c: Move interrupt_stack_size field
1508 +       from CPU Table to Configuration Table. Eliminate CPU Table from all
1509 +       ports. Delete references to CPU Table in all forms.
1510 +
1511 +2007-12-03     Joel Sherrill <joel.sherrill@OARcorp.com>
1512 +
1513 +       * startup/bspstart.c: Moved most of the remaining CPU Table fields to
1514 +       the Configuration Table. This included pretasking_hook,
1515 +       predriver_hook, postdriver_hook, idle_task, do_zero_of_workspace,
1516 +       extra_mpci_receive_server_stack, stack_allocate_hook, and
1517 +       stack_free_hook. As a side-effect of this effort some multiprocessing
1518 +       code was made conditional and some style clean up occurred.
1519 +
1520 +2007-11-26     Joel Sherrill <joel.sherrill@oarcorp.com>
1521 +
1522 +       * startup/bspstart.c: Eliminate the interrupt_vector_table field in the
1523 +       m68k CPU Table since it is never read.
1524 +
1525 +2007-05-03     Joel Sherrill <joel@OARcorp.com>
1526 +
1527 +       * startup/linkcmds: Handle .data.* sections
1528 +
1529 +2007-04-12     Ralf Corsépius <ralf.corsepius@rtems.org>
1530 +
1531 +       * bsp_specs: Remove qrtems_debug.
1532 +
1533 +2007-03-13     Joel Sherrill <joel@OARcorp.com>
1534 +
1535 +       * include/bsp.h: Remove redundant prototypes.
1536 +
1537 +2006-12-02     Ralf Corsépius <ralf.corsepius@rtems.org>
1538 +
1539 +       * configure.ac: New BUG-REPORT address.
1540 +
1541 +2006-11-15     Joel Sherrill <joel@OARcorp.com>
1542 +
1543 +       * Makefile.am: Merge c_rtems_main() into boot_card(). This eliminated a
1544 +       file and simplified initialization.
1545 +
1546 +2006-10-17     Ralf Corsépius <ralf.corsepius@rtems.org>
1547 +
1548 +       * Makefile.am: Remove superfluous -DASM.
1549 +
1550 +2006-10-17     Ralf Corsépius <ralf.corsepius@rtems.org>
1551 +
1552 +       * configure.ac: Require autoconf-2.60. Require automake-1.10.
1553 +
1554 +2006-09-11     Joel Sherrill <joel@OARcorp.com>
1555 +
1556 +       * console/console.c, console/sci.c, console/sci.h, spurious/spinit.c,
1557 +       startup/bspclean.c, startup/start_c.c: Convert C++ style comments to
1558 +       C style.
1559 +
1560 +2006-02-08     Joel Sherrill <joel@OARcorp.com>
1561 +
1562 +       * startup/linkcmds, startup/linkcmds_ROM: Add sections required by
1563 +       newer gcc versions.
1564 +
1565 +2006-01-11     Ralf Corsepius <ralf.corsepius@rtems.org>
1566 +
1567 +       * Makefile.am: Add preinstall.am.
1568 +
1569 +2005-05-26     Ralf Corsepius <ralf.corsepius@rtems.org>
1570 +
1571 +       * include/bsp.h: New header guard.
1572 +
1573 +2005-01-07     Ralf Corsepius <ralf.corsepius@rtems.org>
1574 +
1575 +       * Makefile.am: Eliminate CFLAGS_OPTIMIZE_V.
1576 +
1577 +2005-01-05     Ralf Corsepius <ralf.corsepius@rtems.org>
1578 +
1579 +       * console/sci.c: Remove CVS Log.
1580 +
1581 +2005-01-04     Joel Sherrill <joel@OARcorp.com>
1582 +
1583 +       * console/sci.c: Remove warnings.
1584 +
1585 +2005-01-02     Ralf Corsepius <ralf.corsepius@rtems.org>
1586 +
1587 +       * Makefile.am: Remove build-variant support.
1588 +
1589 +2004-11-25     Joel Sherrill <joel@OARcorp.com>
1590 +
1591 +       * startup/linkcmds, startup/linkcmds_ROM: Add new bss sections .bss.*
1592 +       and .gnu.linkonce.b*.
1593 +
1594 +2004-09-24     Ralf Corsepius <ralf_corsepius@rtems.org>
1595 +
1596 +       * configure.ac: Require automake > 1.9.
1597 +
1598 +2004-04-23     Ralf Corsepius <ralf_corsepius@rtems.org>
1599 +
1600 +       PR 610/bsps
1601 +       * Makefile.am: Add include/tm27.h, Cosmetics.
1602 +       * include/tm27.h: Final cosmetics.
1603 +
1604 +2004-04-22     Ralf Corsepius <ralf_corsepius@rtems.org>
1605 +
1606 +       * include/bsp.h: Split out tmtest27 support.
1607 +       * include/tm27.h: New.
1608 +
1609 +2004-04-21     Ralf Corsepius <ralf_corsepius@rtems.org>
1610 +
1611 +       PR 613/bsps
1612 +       * include/bsp.h: Remove MAX_LONG_TEST_DURATION.
1613 +
1614 +2004-04-21     Ralf Corsepius <ralf_corsepius@rtems.org>
1615 +
1616 +       PR 614/bsps
1617 +       * include/bsp.h: Remove MAX_SHORT_TEST_DURATION (Unused).
1618 +
1619 +2004-04-03     Ralf Corsepiu <ralf_corsepiu@rtems.org>
1620 +
1621 +       * c/src/lib/libbsp/m68k/mrm332/include/bsp.h,
1622 +       c/src/lib/libbsp/m68k/mrm332/start/start.S,
1623 +       c/src/lib/libbsp/m68k/mrm332/startup/start_c.c: Include
1624 +       <rtems/m68k/sim.h> instead of <sim.h>.
1625 +       * c/src/lib/libbsp/m68k/mrm332/include/bsp.h: Include
1626 +       <rtems/m68k/qsm.h> instead of <qsm.h>.
1627 +
1628 +2004-04-02     Ralf Corsepius <ralf_corsepius@rtems.org>
1629 +
1630 +       * start/start.S: Include <rtems/asm.h> instead of <asm.h>.
1631 +
1632 +2004-04-01     Ralf Corsepius <ralf_corsepius@rtems.org>
1633 +
1634 +       * include/bsp.h: Include <rtems/clockdrv.h> instead of <clockdrv.h>.
1635 +       * include/bsp.h: Include <rtems/console.h> instead of <console.h>.
1636 +       * include/bsp.h: Include <rtems/iosupp.h> instead of <iosupp.h>.
1637 +
1638 +2004-03-31     Ralf Corsepius <ralf_corsepius@rtems.org>
1639 +
1640 +       * clock/ckinit.c, console/sci.c, console/sci.h, include/bsp.h,
1641 +       misc/interr.c, startup/bspstart.c, timer/timer.c: Convert to using
1642 +       c99 fixed size types.
1643 +
1644 +2004-02-19     Ralf Corsepius <corsepiu@faw.uni-ulm.de>
1645 +
1646 +       * Makefile.am: Reflect changes to bsp.am. 
1647 +       Preinstall dist_project_lib*.
1648 +
1649 +2004-02-14     Ralf Corsepius <corsepiu@faw.uni-ulm.de>
1650 +
1651 +       * Makefile.am: Reflect changes to bsp.am.
1652 +
1653 +2004-02-12     Ralf Corsepius <corsepiu@faw.uni-ulm.de>
1654 +
1655 +       * Makefile.am: Use CPPASCOMPILE instead of CCASCOMPILE.
1656 +
1657 +2004-02-06     Ralf Corsepius <corsepiu@faw.uni-ulm.de>
1658 +
1659 +       * Makefile.am: Pickup files from ../../m68k/shared instead of
1660 +       ../shared. Reformat.
1661 +
1662 +2004-01-28     Ralf Corsepius <corsepiu@faw.uni-ulm.de>
1663 +
1664 +       * configure.ac: Add nostdinc to AUTOMAKE_OPTIONS.
1665 +
1666 +2004-01-28     Ralf Corsepius <corsepiu@faw.uni-ulm.de>
1667 +
1668 +       * Makefile.am: Don't include subdirs.am.
1669 +
1670 +2004-01-28     Ralf Corsepius <corsepiu@faw.uni-ulm.de>
1671 +
1672 +       * Makefile.am: Fix typo.
1673 +
1674 +2004-01-28     Ralf Corsepius <corsepiu@faw.uni-ulm.de>
1675 +
1676 +       * Makefile.am: Merge-in clock/Makefile.am, console/Makefile.am,
1677 +       spurious/Makefile.am, startup/Makefile.am, timer/Makefile.am,
1678 +       wrapup/Makefile.am.
1679 +       Use automake compilation rules.
1680 +       * clock/Makefile.am, console/Makefile.am, spurious/Makefile.am,
1681 +       startup/Makefile.am, timer/Makefile.am, wrapup/Makefile.am:
1682 +       Remove.
1683 +       * configure.ac: Reflect changes above.
1684 +
1685 +2004-01-21     Ralf Corsepius <corsepiu@faw.uni-ulm.de>
1686 +
1687 +       * Makefile.am: Add PREINSTALL_DIRS.
1688 +       * wrapup/Makefile.am: Reflect changes to libcpu.
1689 +
1690 +2004-01-20     Ralf Corsepius <corsepiu@faw.uni-ulm.de>
1691 +
1692 +       * wrapup/Makefile.am: Reflect changes to libcpu.
1693 +
1694 +2004-01-14     Ralf Corsepius <corsepiu@faw.uni-ulm.de>
1695 +
1696 +       * Makefile.am: Re-add dirstamps to PRE/TMPINSTALL_FILES.
1697 +       Add PRE/TMPINSTALL_FILES to CLEANFILES.
1698 +       * startup/Makefile.am: Ditto.
1699 +
1700 +2004-01-07     Joel Sherrill <joel@OARcorp.com>
1701 +
1702 +       * times, console/sci.c: Remove efi68k and efi332 references as they are
1703 +       no longer in the tree.
1704 +
1705 +2004-01-07     Joel Sherrill <joel@OARcorp.com>
1706 +
1707 +       * timer/timer.c: Remove efi68k and efi332 references as they are no
1708 +       longer in the tree.
1709 +
1710 +2004-01-07     Ralf Corsepius <corsepiu@faw.uni-ulm.de>
1711 +
1712 +       * start/Makefile.am: Remove.
1713 +       * Makefile.am: Merge-in start/Makefile.am.
1714 +       * configure.ac: Reflect changes above.
1715 +
1716 +2004-01-05     Ralf Corsepius <corsepiu@faw.uni-ulm.de>
1717 +
1718 +       * wrapup/Makefile.am: Eliminate $(LIB). 
1719 +       Use noinst_DATA to trigger building libbsp.a.
1720 +
1721 +2003-12-13     Ralf Corsepius <corsepiu@faw.uni-ulm.de>
1722 +
1723 +       * start/Makefile.am: s,${PROJECT_RELEASE}/lib,$(PROJECT_LIB),g.
1724 +       * startup/Makefile.am: s,${PROJECT_RELEASE}/lib,$(PROJECT_LIB),g.
1725 +
1726 +2003-12-12     Ralf Corsepius <corsepiu@faw.uni-ulm.de>
1727 +
1728 +       * start/Makefile.am: Use mkdir_p. Remove dirs from PRE/TMPINSTALL_FILES.
1729 +       * startup/Makefile.am: Use mkdir_p. Remove dirs from PRE/TMPINSTALL_FILES.
1730 +
1731 +2003-12-12     Ralf Corsepius <corsepiu@faw.uni-ulm.de>
1732 +
1733 +       * configure.ac: Require automake >= 1.8, autoconf >= 2.59.
1734 +
1735 +2003-12-10     Ralf Corsepius <corsepiu@faw.uni-ulm.de>
1736 +
1737 +       * start/Makefile.am: Misc cleanups and fixes.
1738 +       * startup/Makefile.am: Misc cleanups and fixes.
1739 +       * wrapup/Makefile.am: Misc cleanups and fixes.
1740 +
1741 +2003-12-03     Ralf Corsepius <corsepiu@faw.uni-ulm.de>
1742 +
1743 +       * Makefile.am: Add preinstallation dirstamp support.
1744 +       * clock/Makefile.am: Cosmetics.
1745 +       * console/Makefile.am: Cosmetics.
1746 +       * spurious/Makefile.am: Cosmetics.
1747 +       * startup/Makefile.am: Cosmetics.
1748 +       * timer/Makefile.am: Cosmetics.
1749 +       * wrapup/Makefile.am: Cosmetics.
1750 +
1751 +2003-12-02     Ralf Corsepius <corsepiu@faw.uni-ulm.de>
1752 +
1753 +       * clock/Makefile.am: Remove all-local: $(ARCH).
1754 +       * console/Makefile.am: Remove all-local: $(ARCH).
1755 +       * spurious/Makefile.am: Remove all-local: $(ARCH).
1756 +       * start/Makefile.am: Remove all-local: $(ARCH).
1757 +       * startup/Makefile.am: Remove all-local: $(ARCH).
1758 +       * timer/Makefile.am: Remove all-local: $(ARCH).
1759 +       * wrapup/Makefile.am: Remove all-local: $(ARCH).
1760 +
1761 +2003-09-29     Ralf Corsepius <corsepiu@faw.uni-ulm.de>
1762 +
1763 +       * Makefile.am: Merge-in include/Makefile.am.
1764 +       Reflect changes to bsp.am.
1765 +       * include/Makefile.am: Remove.
1766 +       * configure.ac: Reflect changes above.
1767 +
1768 +2003-09-19     Ralf Corsepius <corsepiu@faw.uni-ulm.de>
1769 +
1770 +       * bsp_specs: Remove *lib:.
1771 +
1772 +2003-09-15     Joel Sherrill <joel@OARcorp.com>
1773 +
1774 +       PR 483/bsps
1775 +       * startup/bspstart.c, startup/start_c.c: Spurious interrupt handlers
1776 +       cannot be installed until RTEMS has initialized the vector table.
1777 +
1778 +2003-09-04     Joel Sherrill <joel@OARcorp.com>
1779 +
1780 +       * clock/ckinit.c, console/console.c, include/bsp.h, misc/interr.c,
1781 +       spurious/spinit.c, startup/bspclean.c, startup/bspstart.c,
1782 +       timer/timer.c: URL for license changed.
1783 +
1784 +2003-08-20     Joel Sherrill <joel@OARcorp.com>
1785 +
1786 +       * console/console.c: Correct copyright statements.
1787 +
1788 +2003-08-18     Ralf Corsepius <corsepiu@faw.uni-ulm.de>
1789 +
1790 +       * Makefile.am: Reflect having moved aclocal/.
1791 +
1792 +2003-08-16     Ralf Corsepius <corsepiu@faw.uni-ulm.de>
1793 +
1794 +       * Makefile.am: Reflect having moved automake/.
1795 +       * clock/Makefile.am: Reflect having moved automake/.
1796 +       * console/Makefile.am: Reflect having moved automake/.
1797 +       * include/Makefile.am: Reflect having moved automake/.
1798 +       * spurious/Makefile.am: Reflect having moved automake/.
1799 +       * start/Makefile.am: Reflect having moved automake/.
1800 +       * startup/Makefile.am: Reflect having moved automake/.
1801 +       * timer/Makefile.am: Reflect having moved automake/.
1802 +       * wrapup/Makefile.am: Reflect having moved automake/.
1803 +
1804 +2003-08-11     Ralf Corsepius <corsepiu@faw.uni-ulm.de>
1805 +
1806 +       PR 452/bsps
1807 +       * startup/Makefile.am: Remove USE_INIT_FINI.
1808 +
1809 +2003-08-11     Ralf Corsepius <corsepiu@faw.uni-ulm.de>
1810 +
1811 +       * configure.ac: Use rtems-bugs@rtems.com as bug report email address.
1812 +
1813 +2003-08-06     Ralf Corsepius <corsepiu@faw.uni-ulm.de>
1814 +
1815 +       PR 445/bsps
1816 +       * bsp_specs: Remove -D__embedded__ -Asystem(embedded) from cpp.
1817 +       Remove cpp, old_cpp (now unused).
1818 +
1819 +2003-03-06     Ralf Corsepius <corsepiu@faw.uni-ulm.de>
1820 +
1821 +       * configure.ac: Remove AC_CONFIG_AUX_DIR.
1822 +
1823 +2003-02-11     Ralf Corsepius <corsepiu@faw.uni-ulm.de>
1824 +
1825 +       * configure.ac: AM_INIT_AUTOMAKE([1.7.2]).
1826 +
1827 +2003-02-11     Ralf Corsepius <corsepiu@faw.uni-ulm.de>
1828 +
1829 +       * configure.ac: AC_PREREQ(2.57).
1830 +
1831 +2003-01-20     Duane Gustavus <duane@unt.edu>
1832 +
1833 +       * console/sci.c, include/mrm332.h, startup/linkcmds,
1834 +       startup/linkcmds_ROM: Various updates to make this run properly
1835 +       from ROM.
1836 +
1837 +2002-12-20     Ralf Corsepius <corsepiu@faw.uni-ulm.de>
1838 +
1839 +       * clock/Makefile.am: Don't include @RTEMS_BSP@.cfg.
1840 +       * console/Makefile.am: Don't include @RTEMS_BSP@.cfg.
1841 +       * spurious/Makefile.am: Don't include @RTEMS_BSP@.cfg.
1842 +       * start/Makefile.am: Don't include @RTEMS_BSP@.cfg.
1843 +       * startup/Makefile.am: Don't include @RTEMS_BSP@.cfg.
1844 +       * timer/Makefile.am: Don't include @RTEMS_BSP@.cfg.
1845 +
1846 +2002-12-12     Ralf Corsepius <corsepiu@faw.uni-ulm.de>
1847 +
1848 +       * start/Makefile.am: Use install-data-local to install startfile.
1849 +
1850 +2002-12-10     Ralf Corsepius <corsepiu@faw.uni-ulm.de>
1851 +
1852 +       * wrapup/Makefile.am: Don't include @RTEMS_BSP@.cfg.
1853 +
1854 +2002-11-04     Joel Sherrill <joel@OARcorp.com>
1855 +
1856 +       * console/sci.c, spurious/spinit.c: Removed warnings.
1857 +
1858 +2002-10-21     Ralf Corsepius <corsepiu@faw.uni-ulm.de>
1859 +
1860 +       * .cvsignore: Reformat.
1861 +       Add autom4te*cache.
1862 +       Remove autom4te.cache.
1863 +
1864 +2002-09-08     Ralf Corsepius <corsepiu@faw.uni-ulm.de>
1865 +
1866 +       * Makefile.am: ACLOCAL_AMFLAGS = -I ../../../../../../aclocal.
1867 +
1868 +2002-08-21     Joel Sherrill <joel@OARcorp.com>
1869 +
1870 +       * wrapup/Makefile.am: PR217 required that the idle task be moved to
1871 +       libcpu so it could be more acutely aware of the CPU model.  This
1872 +       file was modified to pick up the idle task from there.
1873 +
1874 +2002-08-21     Joel Sherrill <joel@OARcorp.com>
1875 +
1876 +       * bsp_specs: Added support for -nostdlibs.
1877 +
1878 +2002-08-11     Ralf Corsepius <corsepiu@faw.uni-ulm.de>
1879 +
1880 +       * clock/Makefile.am: Use .$(OBJEXT) instead of .o.
1881 +       * console/Makefile.am: Use .$(OBJEXT) instead of .o.
1882 +       * spurious/Makefile.am: Use .$(OBJEXT) instead of .o.
1883 +       * start/Makefile.am: Use .$(OBJEXT) instead of .o.
1884 +       * startup/Makefile.am: Use .$(OBJEXT) instead of .o.
1885 +       * timer/Makefile.am: Use .$(OBJEXT) instead of .o.
1886 +       * wrapup/Makefile.am: Use .$(OBJEXT) instead of .o.
1887 +
1888 +2002-08-05     Joel Sherrill <joel@OARcorp.com>
1889 +
1890 +       * Per PR260 eliminate use of make-target-options.  This impacted
1891 +       RTEMS allowing a distinction between the CPU32 and CPU32+ in the
1892 +       SuperCore and required that the m68k optimized memcpy be moved
1893 +       to libcpu.
1894 +       * wrapup/Makefile.am: Pick up memcpy.o from libcpu.
1895 +
1896 +2002-07-21     Ralf Corsepius <corsepiu@faw.uni-ulm.de>
1897 +
1898 +       * start/Makefile.am: Eliminate PGM.
1899 +       Add bsplib_DATA = $(PROJECT_RELEASE)/lib/start$(LIB_VARIANT).o.
1900 +
1901 +2002-07-19     Ralf Corsepius <corsepiu@faw.uni-ulm.de>
1902 +
1903 +       * startup/Makefile.am: Add bsplib_DATA = linkcmds linkcmds_ROM.
1904 +
1905 +2002-07-04     Ralf Corsepius <corsepiu@faw.uni-ulm.de>
1906 +
1907 +       * wrapup/Makefile.am: Eliminate TMPINSTALL_FILES.
1908 +       Remove $(OBJS) from all-local.
1909 +
1910 +2002-06-29     Ralf Corsepius <corsepiu@faw.uni-ulm.de>
1911 +
1912 +       * wrapup/Makefile.am: Remove preinstallation of libbsp.a,
1913 +
1914 +2001-05-09     Joel Sherrill <joel@OARcorp.com>
1915 +
1916 +       * startup/linkcmds: In support of gcc 3.1, added one of more
1917 +       of the sections .jcr, .rodata*, .data.*, .gnu.linkonce.s2.*,
1918 +       .gnu.linkonce.sb2.*, and .gnu.linkonce.s.*.  Spacing corrections
1919 +       and direction of segments to memory regions may also have been
1920 +       addressed.  This was a sweep across all BSPs.
1921
1922 +2002-03-27     Ralf Corsepius <corsepiu@faw.uni-ulm.de>
1923 +
1924 +       * configure.ac:
1925 +       AC_INIT(package,_RTEMS_VERSION,_RTEMS_BUGS).
1926 +       AM_INIT_AUTOMAKE([no-define foreign 1.6]).
1927 +       * clock/Makefile.am: Remove AUTOMAKE_OPTIONS.
1928 +       * Makefile.am: Remove AUTOMAKE_OPTIONS.
1929 +       * console/Makefile.am: Remove AUTOMAKE_OPTIONS.
1930 +       * include/Makefile.am: Remove AUTOMAKE_OPTIONS.
1931 +       * spurious/Makefile.am: Remove AUTOMAKE_OPTIONS.
1932 +       * start/Makefile.am: Remove AUTOMAKE_OPTIONS.
1933 +       * startup/Makefile.am: Remove AUTOMAKE_OPTIONS.
1934 +       * timer/Makefile.am: Remove AUTOMAKE_OPTIONS.
1935 +       * wrapup/Makefile.am: Remove AUTOMAKE_OPTIONS.
1936 +
1937 +2002-02-28     Mike Panetta <ahuitzot@mindspring.com>
1938 +
1939 +       * console/sci.c, console/sci.h, 
1940 +       console/console.c: Added new SCI driver.
1941 +       * start/start.c: Removed file.
1942 +       * start/start.S: New file, the asm portion of the updated start code.
1943 +       * start/configure.am: Added start.S, removed start.c
1944 +       * startup/start_c.c: New file, the C portion of the updated start code.         Contains most of the code that was in the old start.c. 
1945 +       * startup/configure.am: Added start_c.c to C_FILES.
1946 +       * include/bsp.h: Added include <rtems/bspIo.h>
1947 +
1948 +2001-11-30     Ralf Corsepius <corsepiu@faw.uni-ulm.de>
1949 +
1950 +       * configure.ac: Introduce RTEMS_BSP_CONFIGURE.
1951 +
1952 +2001-10-11     Ralf Corsepius <corsepiu@faw.uni-ulm.de>
1953 +
1954 +       * .cvsignore: Add autom4te.cache for autoconf > 2.52.
1955 +       * configure.in: Remove.
1956 +       * configure.ac: New file, generated from configure.in by autoupdate.
1957 +
1958 +2001-09-27     Joel Sherrill <joel@OARcorp.com>
1959 +
1960 +       * include/bsp.h: Renamed delay() to rtems_bsp_delay().
1961 +
1962 +2001-09-27     Ralf Corsepius <corsepiu@faw.uni-ulm.de>
1963 +
1964 +       * include/Makefile.am: Use 'TMPINSTALL_FILES ='.
1965 +
1966 +2001-05-26     Ralf Corsepius <corsepiu@faw.uni-ulm.de>
1967 +
1968 +       * configure.in: Add bspopts.h.
1969 +       * include/.cvsignore: Add bspopts.h*, stamp-h*.
1970 +       * include/Makefile.am: Use *_HEADERS instead of *H_FILES.
1971 +       * include/bsp.h: Include bspopts.h.
1972 +
1973 +2001-05-25     Joel Sherrill <joel@OARcorp.com>
1974 +
1975 +       * clock/Makefile.am, console/Makefile.am, spurious/Makefile.am,
1976 +       start/Makefile.am, startup/Makefile.am, timer/Makefile.am,
1977 +       wrapup/Makefile.am: Modified to include compile.am.
1978 +       * startup/bspstart.c: Removed include of <libcsupport.h>
1979 +
1980 +2000-05-25     Matt Cross <profesor@gweep.net>
1981 +
1982 +       * New MRM332 BSP for the Mini RoboMind board based
1983 +       on the 68332 microcontroller designed and build by Mark
1984 +       Castelluccio.  For details on the MRM see http://www.robominds.com.
1985 +       * .cvsignore, ChangeLog Makefile.am, README, bsp_specs,
1986 +       clock/.cvsignore, clock/Makefile.am, clock/ckinit.c, configure.in,
1987 +       console/.cvsignore, console/Makefile.am, console/console.c,
1988 +       include/.cvsignore, include/Makefile.am, include/bsp.h,
1989 +       include/mrm332.h, misc/dotests, misc/gdbinit68, misc/interr.c,
1990 +       spurious/.cvsignore, spurious/Makefile.am, spurious/spinit.c,
1991 +       start/.cvsignore, start/Makefile.am, start/start.c, startup/.cvsignore,
1992 +       startup/Makefile.am, startup/bspclean.c, startup/bspstart.c,
1993 +       startup/except_vect_332_ROM.S, startup/linkcmds, startup/linkcmds_ROM,
1994 +       timer/.cvsignore, timer/Makefile.am, timer/timer.c, times,
1995 +       wrapup/.cvsignore, wrapup/Makefile.am: Initial files.
1996 +
1997 Index: rtems/c/src/lib/libbsp/m68k/mo376/startup/bspclean.c
1998 ===================================================================
1999 --- /dev/null   1970-01-01 00:00:00.000000000 +0000
2000 +++ rtems/c/src/lib/libbsp/m68k/mo376/startup/bspclean.c        2006-09-11 23:43:56.000000000 +0200
2001 @@ -0,0 +1,27 @@
2002 +/*  bsp_cleanup()
2003 + *
2004 + *  This routine cleans up in the sense that it places the board
2005 + *  in a safe state and flushes the I/O buffers before exiting.
2006 + *
2007 + *  INPUT:  NONE
2008 + *
2009 + *  OUTPUT: NONE
2010 + *
2011 + *  COPYRIGHT (c) 1989-1999.
2012 + *  On-Line Applications Research Corporation (OAR).
2013 + *
2014 + *  The license and distribution terms for this file may be
2015 + *  found in the file LICENSE in this distribution or at
2016 + *  http://www.rtems.com/license/LICENSE.
2017 + *
2018 + *  $Id: bspclean.c,v 1.5 2006/09/11 21:43:56 joel Exp $
2019 + */
2020 +
2021 +#include <bsp.h>
2022 +
2023 +void bsp_cleanup(void)
2024 +{
2025 +    /* interrupt driven stdio must be flushed */
2026 +    _CPU_ISR_Set_level( 7 );
2027 +    /*_UART_flush(); */
2028 +}
2029 Index: rtems/c/src/lib/libbsp/m68k/mo376/timer/timer.c
2030 ===================================================================
2031 --- /dev/null   1970-01-01 00:00:00.000000000 +0000
2032 +++ rtems/c/src/lib/libbsp/m68k/mo376/timer/timer.c     2008-09-30 18:28:07.000000000 +0200
2033 @@ -0,0 +1,61 @@
2034 +/*
2035 + *  COPYRIGHT (c) 1989-1999.
2036 + *  On-Line Applications Research Corporation (OAR).
2037 + *
2038 + *  The license and distribution terms for this file may be
2039 + *  found in the file LICENSE in this distribution or at
2040 + *  http://www.rtems.com/license/LICENSE.
2041 + *
2042 + *  $Id: timer.c,v 1.10.2.1 2008/09/30 16:28:07 joel Exp $
2043 + */
2044 +
2045 +#include <bsp.h>
2046 +
2047 +bool benchmark_timer_find_average_overhead;
2048 +
2049 +extern rtems_isr Clock_isr(void);
2050 +
2051 +void benchmark_timer_initialize( void )
2052 +{
2053 +}
2054 +
2055 +/*
2056 + *  The following controls the behavior of benchmark_timer_read().
2057 + *
2058 + *  FIND_AVG_OVERHEAD *  instructs the routine to return the "raw" count.
2059 + *
2060 + *  AVG_OVEREHAD is the overhead for starting and stopping the timer.  It
2061 + *  is usually deducted from the number returned.
2062 + *
2063 + *  LEAST_VALID is the lowest number this routine should trust.  Numbers
2064 + *  below this are "noise" and zero is returned.
2065 + */
2066 +
2067 +#define AVG_OVERHEAD      0  /* It typically takes X.X microseconds */
2068 +                             /* (Y countdowns) to start/stop the timer. */
2069 +                             /* This value is in microseconds. */
2070 +#define LEAST_VALID       1  /* Don't trust a clicks value lower than this */
2071 +
2072 +/*
2073 + * Return timer value in 1/2-microsecond units
2074 + */
2075 +int benchmark_timer_read( void )
2076 +{
2077 +  uint32_t         total;
2078 +  total = 0;
2079 +
2080 +  if ( benchmark_timer_find_average_overhead == true )
2081 +    return total;          /* in XXX microsecond units */
2082 +
2083 +  if ( total < LEAST_VALID )
2084 +    return 0;            /* below timer resolution */
2085 +
2086 +  return (total - AVG_OVERHEAD);
2087 +}
2088 +
2089 +void benchmark_timer_disable_subtracting_average_overhead(
2090 +  bool find_flag
2091 +)
2092 +{
2093 +  benchmark_timer_find_average_overhead = find_flag;
2094 +}
2095 Index: rtems/c/src/lib/libbsp/m68k/mo376/clock/ckinit.c
2096 ===================================================================
2097 --- /dev/null   1970-01-01 00:00:00.000000000 +0000
2098 +++ rtems/c/src/lib/libbsp/m68k/mo376/clock/ckinit.c    2008-09-06 00:05:15.000000000 +0200
2099 @@ -0,0 +1,96 @@
2100 +/*  Clock_init()
2101 + *
2102 + *  This routine initailizes the periodic interrupt timer on
2103 + *  the Motorola 68332.
2104 + *
2105 + *  Input parameters:  NONE
2106 + *
2107 + *  Output parameters:  NONE
2108 + *
2109 + *  COPYRIGHT (c) 1989-1999.
2110 + *  On-Line Applications Research Corporation (OAR).
2111 + *
2112 + *  The license and distribution terms for this file may be
2113 + *  found in the file LICENSE in this distribution or at
2114 + *  http://www.rtems.com/license/LICENSE.
2115 + *
2116 + *  $Id: ckinit.c,v 1.7 2008/09/05 22:05:15 joel Exp $
2117 + */
2118 +
2119 +#include <stdlib.h>
2120 +#include <bsp.h>
2121 +#include <rtems/libio.h>
2122 +#include <mrm332.h>
2123 +
2124 +#define CLOCK_VECTOR   MRM_PIV
2125 +
2126 +uint32_t         Clock_isrs;        /* ISRs until next tick */
2127 +volatile uint32_t         Clock_driver_ticks;
2128 +                                    /* ticks since initialization */
2129 +rtems_isr_entry  Old_ticker;
2130 +
2131 +void Clock_exit( void );
2132 +
2133 +/*
2134 + * These are set by clock driver during its init
2135 + */
2136 +
2137 +rtems_device_major_number rtems_clock_major = ~0;
2138 +rtems_device_minor_number rtems_clock_minor;
2139 +
2140 +rtems_isr Clock_isr(rtems_vector_number vector)
2141 +{
2142 +  Clock_driver_ticks += 1;
2143 +
2144 +  if ( Clock_isrs == 1 ) {
2145 +    rtems_clock_tick();
2146 +    Clock_isrs = rtems_configuration_get_microseconds_per_tick() / 1000;
2147 +  }
2148 +  else
2149 +    Clock_isrs -= 1;
2150 +}
2151 +
2152 +void Install_clock(
2153 +  rtems_isr_entry clock_isr
2154 +)
2155 +{
2156 +  Clock_driver_ticks = 0;
2157 +  Clock_isrs = rtems_configuration_get_microseconds_per_tick() / 1000;
2158 +
2159 +  Old_ticker = (rtems_isr_entry) set_vector( clock_isr, CLOCK_VECTOR, 1 );
2160 +
2161 +  /* enable 1mS interrupts */
2162 +  *PITR = (unsigned short int)( SAM(0x09,0,PITM) );/* load counter */
2163 +  *PICR = (unsigned short int)                     /* enable interrupt */
2164 +    ( SAM(ISRL_PIT,8,PIRQL) | SAM(CLOCK_VECTOR,0,PIV) );
2165 +
2166 +  atexit( Clock_exit );
2167 +}
2168 +
2169 +void Clock_exit( void )
2170 +{
2171 +  /* shutdown the periodic interrupt */
2172 +  *PICR = (unsigned short int)
2173 +    ( SAM(0,8,PIRQL) | SAM(CLOCK_VECTOR,0,PIV) );
2174 +  /*     ^^ zero disables interrupt */
2175 +
2176 +  /* do not restore old vector */
2177 +}
2178 +
2179 +rtems_device_driver Clock_initialize(
2180 +  rtems_device_major_number major,
2181 +  rtems_device_minor_number minor,
2182 +  void *pargp
2183 +)
2184 +{
2185 +  Install_clock( Clock_isr );
2186 +
2187 +  /*
2188 +   * make major/minor avail to others such as shared memory driver
2189 +   */
2190 +
2191 +  rtems_clock_major = major;
2192 +  rtems_clock_minor = minor;
2193 +
2194 +  return RTEMS_SUCCESSFUL;
2195 +}
2196 Index: rtems/c/src/lib/libbsp/m68k/mo376/misc/gdbinit68
2197 ===================================================================
2198 --- /dev/null   1970-01-01 00:00:00.000000000 +0000
2199 +++ rtems/c/src/lib/libbsp/m68k/mo376/misc/gdbinit68    2009-11-29 01:11:56.471556761 +0100
2200 @@ -0,0 +1,16 @@
2201 +#
2202 +#  $Id: gdbinit68,v 1.1 2001/05/25 16:28:46 joel Exp $
2203 +#
2204 +echo Setting up the environment for mrm debuging.\n
2205 +
2206 +target bdm /dev/bdmcpu320
2207 +bdm_setdelay 1000
2208 +bdm_autoreset on
2209 +set remotecache off
2210 +bdm_timetocomeup 0
2211 +bdm_init
2212 +bdm_reset
2213 +set $sfc=5
2214 +set $dfc=5
2215 +r
2216 +q
2217 Index: rtems/c/src/lib/libbsp/m68k/mo376/configure.ac
2218 ===================================================================
2219 --- /dev/null   1970-01-01 00:00:00.000000000 +0000
2220 +++ rtems/c/src/lib/libbsp/m68k/mo376/configure.ac      2006-12-02 06:55:13.000000000 +0100
2221 @@ -0,0 +1,20 @@
2222 +## Process this file with autoconf to produce a configure script.
2223 +## 
2224 +## $Id: configure.ac,v 1.16 2006/12/02 05:55:13 ralf Exp $
2225 +
2226 +AC_PREREQ(2.60)
2227 +AC_INIT([rtems-c-src-lib-libbsp-m68k-mrm332],[_RTEMS_VERSION],[http://www.rtems.org/bugzilla])
2228 +AC_CONFIG_SRCDIR([bsp_specs])
2229 +RTEMS_TOP(../../../../../..)
2230 +
2231 +RTEMS_CANONICAL_TARGET_CPU
2232 +AM_INIT_AUTOMAKE([no-define nostdinc foreign 1.10])
2233 +RTEMS_BSP_CONFIGURE
2234 +
2235 +RTEMS_PROG_CC_FOR_TARGET
2236 +RTEMS_CANONICALIZE_TOOLS
2237 +RTEMS_PROG_CCAS
2238 +
2239 +# Explicitly list all Makefiles here
2240 +AC_CONFIG_FILES([Makefile])
2241 +AC_OUTPUT
2242 Index: rtems/c/src/lib/libbsp/m68k/mo376/README
2243 ===================================================================
2244 --- /dev/null   1970-01-01 00:00:00.000000000 +0000
2245 +++ rtems/c/src/lib/libbsp/m68k/mo376/README    2009-11-29 01:11:56.471556761 +0100
2246 @@ -0,0 +1,24 @@
2247 +#
2248 +#  $Id: README,v 1.1 2001/05/25 16:28:46 joel Exp $
2249 +#
2250 +
2251 +Description: mrm332
2252 +============
2253 +CPU: MC68332 @16 or 25MHz
2254 +RAM: 32k or 512k
2255 +ROM: 512k flash
2256 +
2257 +   The Mini RoboMind is a small board based on the 68332 microcontroller
2258 +designed and build by Mark Castelluccio.  For details, see:
2259 +
2260 +        http://www.robominds.com
2261 +
2262 +   This BSP was ported from the efi332 BSP by Matt Cross (profesor@gweep.net),
2263 +the efi332 BSP was written by John S Gwynne.
2264 +
2265 +TODO:
2266 +=====
2267 +- integrate the interrupt driven stdin/stdout into RTEMS to (a) reduce
2268 +  the interrupt priority and (2) to prevent it from blocking.
2269 +- add a timer driver for the tmtest set.
2270 +
2271 Index: rtems/c/src/lib/libbsp/m68k/mo376/Makefile.am
2272 ===================================================================
2273 --- /dev/null   1970-01-01 00:00:00.000000000 +0000
2274 +++ rtems/c/src/lib/libbsp/m68k/mo376/Makefile.am       2008-09-29 03:47:41.000000000 +0200
2275 @@ -0,0 +1,50 @@
2276 +##
2277 +## $Id: Makefile.am,v 1.27.2.1 2008/09/29 01:47:41 ralf Exp $
2278 +##
2279 +
2280 +ACLOCAL_AMFLAGS = -I ../../../../aclocal
2281 +
2282 +include $(top_srcdir)/../../../../automake/compile.am
2283 +include $(top_srcdir)/../../bsp.am
2284 +
2285 +dist_project_lib_DATA = bsp_specs
2286 +
2287 +include_HEADERS = include/bsp.h
2288 +include_HEADERS += include/tm27.h
2289 +
2290 +nodist_include_HEADERS = include/bspopts.h
2291 +DISTCLEANFILES = include/bspopts.h
2292 +
2293 +include_HEADERS += include/mrm332.h
2294 +nodist_include_HEADERS += ../../shared/include/coverhd.h
2295 +
2296 +EXTRA_DIST = times
2297 +
2298 +EXTRA_DIST += start/start.S
2299 +start.$(OBJEXT): start/start.S
2300 +       $(CPPASCOMPILE) -o $@ -c $<
2301 +
2302 +project_lib_DATA = start.$(OBJEXT)
2303 +
2304 +dist_project_lib_DATA += startup/linkcmds startup/linkcmds_ROM
2305 +
2306 +startup_SOURCES = startup/start_c.c ../../shared/bsplibc.c \
2307 +    ../../shared/bsppost.c startup/bspstart.c startup/bspclean.c \
2308 +    ../../shared/bootcard.c ../../m68k/shared/m68kpretaskinghook.c \
2309 +    ../../shared/sbrk.c ../../m68k/shared/setvec.c \
2310 +    ../../shared/gnatinstallhandler.c startup/except_vect_332_ROM.S
2311 +clock_SOURCES = clock/ckinit.c
2312 +console_SOURCES = console/console.c console/sci.c console/sci.h
2313 +spurious_SOURCES = spurious/spinit.c
2314 +timer_SOURCES = timer/timer.c
2315 +
2316 +noinst_LIBRARIES = libbsp.a
2317 +libbsp_a_SOURCES = $(startup_SOURCES) $(clock_SOURCES) $(console_SOURCES) \
2318 +    $(spurious_SOURCES) $(timer_SOURCES)
2319 +
2320 +libbsp_a_LIBADD = \
2321 +    ../../../libcpu/@RTEMS_CPU@/shared/cache.rel \
2322 +    ../../../libcpu/@RTEMS_CPU@/shared/misc.rel
2323 +
2324 +include $(srcdir)/preinstall.am
2325 +include $(top_srcdir)/../../../../automake/local.am
2326 Index: rtems/c/src/lib/libbsp/m68k/mo376/console/sci.c
2327 ===================================================================
2328 --- /dev/null   1970-01-01 00:00:00.000000000 +0000
2329 +++ rtems/c/src/lib/libbsp/m68k/mo376/console/sci.c     2008-08-19 12:23:15.000000000 +0200
2330 @@ -0,0 +1,1596 @@
2331 +/*****************************************************************************
2332 +* File:     sci.c
2333 +*
2334 +* Desc:     This file contains the console IO routines for the SCI port.
2335 +*           There are two interfaces in this module. One is for the rtems
2336 +*           termios/console code and the other is a device driver interface.
2337 +*           This module works together with the termio module which is
2338 +*           sometimes referred to as the "line disciplines" which implements
2339 +*           terminal i/o processing like tabs, backspaces, and newlines.
2340 +*           The rtems printf uses interrupt io and the rtems printk routine
2341 +*           uses polled io which is better for debugging.
2342 +*
2343 +* Index:    Documentation
2344 +*           Section A  - Include Files
2345 +*           Section B  - Manifest Constants
2346 +*           Section C  - External Data
2347 +*           Section D  - External Functions
2348 +*           Section E  - Local Functions
2349 +*           Section F  - Local Variables
2350 +*           Section G  - A circular data buffer for rcv chars
2351 +*           Section H  - RTEMS termios callbacks for the interrupt api
2352 +*           Section I  - RTEMS termios callbacks for the polled api
2353 +
2354 +*           Section 0  - Miscellaneous routines
2355 +*           Section 1  - Routines to manipulate the circular buffer
2356 +*           Section 2  - Interrupt based entry points for the termios module
2357 +*           Section 3  - Polling based entry points for the termios module
2358 +*           Section 4  - Device driver public api entry points
2359 +*           Section 5  - Hardware level routines
2360 +*           Section 6  - Testing and debugging code
2361 +*
2362 +* Refer:    Motorola QSM Reference Manual - Chapter 5 - SCI sub-module
2363 +*
2364 +* Note:     See bsp.h,confdefs.h,system.h for installing drivers into RTEMS.
2365 +*
2366 +* $Id: sci.c,v 1.12 2008/08/19 10:23:15 ralf Exp $
2367 +*
2368 +*****************************************************************************/
2369 +\f
2370 +/*****************************************************************************
2371 +  Overview of serial port console terminal input/output
2372 +*****************************************************************************/
2373 +
2374 +/*
2375 +   +-----------+                               +---------+
2376 +   |    app    |                               |   app   |
2377 +   +-----------+                               +---------+
2378 +         |                                          |
2379 +         | (printf,scanf,etc.)                      |
2380 +         v                                          |
2381 +   +-----------+                                    |
2382 +   |    libc   |                                    |
2383 +   +-----------+                                    |
2384 +         |                                          |
2385 +         |                                          |
2386 +         |     (open,close,read,write,ioctl)        |
2387 +   ======|==========================================|========================
2388 +         | /dev/console                             | /dev/sci
2389 +         | (stdin,stdout,stderr)                    |
2390 +   ======|==========================================|========================
2391 +         |                                          |
2392 +         |                                          |
2393 +         v                                          v
2394 +   +-----------+         +-----------+         +---------+
2395 +   |  console  |  <--->  |  termios  |  <--->  |   sci   |
2396 +   |  driver   |         |  module   |         |  driver |
2397 +   +-----------+         +-----------+         +---------+
2398 +                                                    |
2399 +                                                    |
2400 +                                                    v
2401 +                                               +---------+
2402 +                                               |         |
2403 +                                               |  uart   |
2404 +                                               |         |
2405 +                                               +---------+
2406 +*/
2407 +\f
2408 +
2409 +/*****************************************************************************
2410 +  Section A - Include Files
2411 +*****************************************************************************/
2412 +
2413 +#include <rtems.h>
2414 +#include <bsp.h>
2415 +#include <rtems/bspIo.h>
2416 +#include <stdio.h>
2417 +#include <rtems/libio.h>
2418 +#include <libchip/serial.h>
2419 +#include <libchip/sersupp.h>
2420 +#include "sci.h"
2421 +/*#include "../misc/include/cpu332.h" */
2422 +\f
2423 +
2424 +/*****************************************************************************
2425 +  Section B - Manifest Constants
2426 +*****************************************************************************/
2427 +
2428 +#define SCI_MINOR       0                   /* minor device number */
2429 +
2430 +/* IMPORTANT - if the device driver api is opened, it means the sci is being
2431 + * used for direct hardware access, so other users (like termios) get ignored
2432 + */
2433 +#define DRIVER_CLOSED   0                   /* the device driver api is closed */
2434 +#define DRIVER_OPENED   1                   /* the device driver api is opened */
2435 +
2436 +/* system clock definitions, i dont have documentation on this... */
2437 +
2438 +#if 0 /* Not needed, this is provided in mrm332.h */
2439 +#define XTAL            32768.0    /* crystal frequency in Hz */
2440 +#define NUMB_W          0          /* system clock parameters */
2441 +#define NUMB_X          1
2442 +#define NUMB_Y          0x38       /* for 14.942 Mhz */
2443 +#define NUMB_Y          0x3F       /* for 16.777 Mhz */
2444 +
2445 +#define SYS_CLOCK       (XTAL * 4.0 * (NUMB_Y+1) * (1 << (2 * NUMB_W + NUMB_X)))
2446 +
2447 +#endif
2448 +\f
2449 +
2450 +/*****************************************************************************
2451 +  Section C - External Data
2452 +*****************************************************************************/
2453 +
2454 +\f
2455 +
2456 +/*****************************************************************************
2457 +  Section D - External Functions
2458 +*****************************************************************************/
2459 +
2460 +\f
2461 +
2462 +/*****************************************************************************
2463 +  Section E - Local Functions
2464 +*****************************************************************************/
2465 +
2466 +void SCI_output_char(char c);
2467 +
2468 +/*rtems_isr SciIsr( rtems_vector_number vector );   interrupt handler */
2469 +
2470 +const rtems_termios_callbacks * SciGetTermiosHandlers( int32_t   polled );
2471 +
2472 +rtems_device_driver SciInitialize(                     /* device driver api */
2473 +    rtems_device_major_number, rtems_device_minor_number, void *);
2474 +rtems_device_driver SciOpen(                           /* device driver api */
2475 +    rtems_device_major_number, rtems_device_minor_number, void *);
2476 +rtems_device_driver SciClose(                          /* device driver api */
2477 +    rtems_device_major_number, rtems_device_minor_number, void *);
2478 +rtems_device_driver SciRead(                           /* device driver api */
2479 +    rtems_device_major_number, rtems_device_minor_number, void *);
2480 +rtems_device_driver SciWrite(                          /* device driver api */
2481 +    rtems_device_major_number, rtems_device_minor_number, void *);
2482 +rtems_device_driver SciControl(                        /* device driver api */
2483 +    rtems_device_major_number, rtems_device_minor_number, void *);
2484 +rtems_device_driver SciRead (
2485 +    rtems_device_major_number, rtems_device_minor_number, void *);
2486 +
2487 +int   SciInterruptOpen(int, int, void *);               /* termios api */
2488 +int   SciInterruptClose(int, int, void *);              /* termios api */
2489 +int   SciInterruptWrite(int, const char *, int);        /* termios api */
2490 +
2491 +int   SciSetAttributes(int, const struct termios*);     /* termios api */
2492 +int   SciPolledOpen(int, int, void *);                  /* termios api */
2493 +int   SciPolledClose(int, int, void *);                 /* termios api */
2494 +int   SciPolledRead(int);                               /* termios api */
2495 +int   SciPolledWrite(int, const char *, int);           /* termios api */
2496 +
2497 +static void SciSetBaud(uint32_t   rate);                /* hardware routine */
2498 +static void SciSetDataBits(uint16_t   bits);            /* hardware routine */
2499 +static void SciSetParity(uint16_t   parity);            /* hardware routine */
2500 +
2501 +static void inline SciDisableAllInterrupts( void );     /* hardware routine */
2502 +static void inline SciDisableTransmitInterrupts( void );/* hardware routine */
2503 +static void inline SciDisableReceiveInterrupts( void ); /* hardware routine */
2504 +
2505 +static void inline SciEnableTransmitInterrupts( void ); /* hardware routine */
2506 +static void inline SciEnableReceiveInterrupts( void );  /* hardware routine */
2507 +
2508 +static void inline SciDisableReceiver( void );          /* hardware routine */
2509 +static void inline SciDisableTransmitter( void );       /* hardware routine */
2510 +
2511 +static void inline SciEnableReceiver( void );           /* hardware routine */
2512 +static void inline SciEnableTransmitter( void );        /* hardware routine */
2513 +
2514 +void SciWriteCharWait  ( uint8_t );                     /* hardware routine */
2515 +void SciWriteCharNoWait( uint8_t );                     /* hardware routine */
2516 +
2517 +uint8_t   inline SciCharAvailable( void );              /* hardware routine */
2518 +
2519 +uint8_t   inline SciReadCharWait( void );               /* hardware routine */
2520 +uint8_t   inline SciReadCharNoWait( void );             /* hardware routine */
2521 +
2522 +void SciSendBreak( void );                              /* test routine */
2523 +
2524 +static int8_t   SciRcvBufGetChar(void);                 /* circular rcv buf */
2525 +static void    SciRcvBufPutChar( uint8_t);              /* circular rcv buf */
2526 +#if 0
2527 +static void    SciRcvBufFlush( void );                  /* unused routine */
2528 +#endif
2529 +
2530 +void SciUnitTest(void);                                 /* test routine */
2531 +void SciPrintStats(void);                               /* test routine */
2532 +\f
2533 +
2534 +/*****************************************************************************
2535 +  Section F - Local Variables
2536 +*****************************************************************************/
2537 +
2538 +static struct rtems_termios_tty *SciTermioTty;
2539 +
2540 +static uint8_t   SciInited = 0;             /* has the driver been inited */
2541 +
2542 +static uint8_t   SciOpened;                 /* has the driver been opened */
2543 +
2544 +static uint8_t   SciMajor;                  /* major device number */
2545 +
2546 +static uint16_t   SciBaud;                  /* current value in baud register */
2547 +
2548 +static uint32_t   SciBytesIn  = 0;          /* bytes received */
2549 +static uint32_t   SciBytesOut = 0;          /* bytes transmitted */
2550 +
2551 +static uint32_t   SciErrorsParity  = 0;     /* error counter */
2552 +static uint32_t   SciErrorsNoise   = 0;     /* error counter */
2553 +static uint32_t   SciErrorsFraming = 0;     /* error counter */
2554 +static uint32_t   SciErrorsOverrun = 0;     /* error counter */
2555 +
2556 +#if defined(CONSOLE_SCI)
2557 +
2558 +/* this is what rtems printk uses to do polling based output */
2559 +
2560 +BSP_output_char_function_type      BSP_output_char = SCI_output_char;
2561 +BSP_polling_getchar_function_type  BSP_poll_char   = NULL;
2562 +
2563 +#endif
2564 +
2565 +/* cvs id string so you can use the unix ident command on the object */
2566 +
2567 +#ifdef ID_STRINGS
2568 +static const char SciIdent[]="$Id: sci.c,v 1.12 2008/08/19 10:23:15 ralf Exp $";
2569 +#endif
2570 +\f
2571 +
2572 +/*****************************************************************************
2573 +  Section G - A circular buffer for rcv chars when the driver interface is used.
2574 +*****************************************************************************/
2575 +
2576 +/* it is trivial to wrap your buffer pointers when size is a power of two */
2577 +
2578 +#define SCI_RCV_BUF_SIZE        256         /* must be a power of 2 !!! */
2579 +
2580 +/* if someone opens the sci device using the device driver interface,
2581 + * then the receive data interrupt handler will put characters in this buffer
2582 + * instead of sending them up to the termios module for the console
2583 + */
2584 +static uint8_t   SciRcvBuffer[SCI_RCV_BUF_SIZE];
2585 +
2586 +static uint8_t   SciRcvBufPutIndex = 0; /* array index to put in next char */
2587 +
2588 +static uint8_t   SciRcvBufGetIndex = 0; /* array index to take out next char */
2589 +
2590 +static uint16_t  SciRcvBufCount = 0;   /* how many bytes are in the buffer */
2591 +
2592 +\f
2593 +
2594 +/*****************************************************************************
2595 +  Section H - RTEMS termios callbacks for the interrupt version of the driver
2596 +*****************************************************************************/
2597 +
2598 +static const rtems_termios_callbacks SciInterruptCallbacks =
2599 +{
2600 +    SciInterruptOpen,                       /* first open */
2601 +    SciInterruptClose,                      /* last close */
2602 +    NULL,                                   /* polled read (not required) */
2603 +    SciInterruptWrite,                      /* write */
2604 +    SciSetAttributes,                       /* set attributes */
2605 +    NULL,                                   /* stop remote xmit */
2606 +    NULL,                                   /* start remote xmit */
2607 +    TRUE                                    /* output uses interrupts */
2608 +};
2609 +
2610 +/*****************************************************************************
2611 +  Section I - RTEMS termios callbacks for the polled version of the driver
2612 +*****************************************************************************/
2613 +
2614 +static const rtems_termios_callbacks SciPolledCallbacks =
2615 +{
2616 +    SciPolledOpen,                          /* first open */
2617 +    SciPolledClose,                         /* last close */
2618 +    SciPolledRead,                          /* polled read */
2619 +    SciPolledWrite,                         /* write */
2620 +    SciSetAttributes,                       /* set attributes */
2621 +    NULL,                                   /* stop remote xmit */
2622 +    NULL,                                   /* start remote xmit */
2623 +    FALSE                                   /* output uses interrupts */
2624 +};
2625 +\f
2626 +
2627 +/*
2628 + *                              SECTION 0
2629 + *                        MISCELLANEOUS ROUTINES
2630 + */
2631 +
2632 +/****************************************************************************
2633 + * Func:     SCI_output_char
2634 + * Desc:     used by rtems printk function to send a char to the uart
2635 + * Inputs:   the character to transmit
2636 + * Outputs:  none
2637 + * Errors:   none
2638 + * Scope:    public
2639 + ****************************************************************************/
2640 +
2641 +void SCI_output_char(char c)
2642 +{
2643 +/*  ( minor device number, pointer to the character, length ) */
2644 +
2645 +    SciPolledWrite( SCI_MINOR, &c, 1);
2646 +
2647 +    return;
2648 +}
2649 +\f
2650 +
2651 +/****************************************************************************
2652 +* Func:     SciGetTermiosHandlers
2653 +* Desc:     returns a pointer to the table of serial io functions
2654 +*           this is called from console_open with polled set to false
2655 +* Inputs:   flag indicating whether we want polled or interrupt driven io
2656 +* Outputs:  pointer to function table
2657 +* Errors:   none
2658 +* Scope:    public
2659 +****************************************************************************/
2660 +
2661 +const rtems_termios_callbacks * SciGetTermiosHandlers( int32_t   polled )
2662 +{
2663 +    if ( polled )
2664 +    {
2665 +        return &SciPolledCallbacks;             /* polling based */
2666 +    }
2667 +    else
2668 +    {
2669 +        return &SciInterruptCallbacks;          /* interrupt driven */
2670 +    }
2671 +}
2672 +\f
2673 +
2674 +/****************************************************************************
2675 +* Func:     SciIsr
2676 +* Desc:     interrupt handler for serial communications interface
2677 +* Inputs:   vector number - unused
2678 +* Outputs:  none
2679 +* Errors:   none
2680 +* Scope:    public API
2681 +****************************************************************************/
2682 +
2683 +rtems_isr SciIsr( rtems_vector_number vector )
2684 +{
2685 +    uint8_t   ch;
2686 +
2687 +    if ( (*SCSR) & SCI_ERROR_PARITY  )   SciErrorsParity  ++;
2688 +    if ( (*SCSR) & SCI_ERROR_FRAMING )   SciErrorsFraming ++;
2689 +    if ( (*SCSR) & SCI_ERROR_NOISE   )   SciErrorsNoise   ++;
2690 +    if ( (*SCSR) & SCI_ERROR_OVERRUN )   SciErrorsOverrun ++;
2691 +
2692 +    /* see if it was a transmit interrupt */
2693 +
2694 +    if ( (*SCSR) & SCI_XMTR_AVAILABLE )         /* data reg empty, xmt complete */
2695 +    {
2696 +        SciDisableTransmitInterrupts();
2697 +
2698 +        /* tell termios module that the charcter was sent */
2699 +        /* he will call us later to transmit more if there are any */
2700 +
2701 +        if (rtems_termios_dequeue_characters( SciTermioTty, 1 ))
2702 +        {
2703 +            /* there are more bytes to transmit so enable TX interrupt */
2704 +
2705 +            SciEnableTransmitInterrupts();
2706 +        }
2707 +    }
2708 +
2709 +    /* see if it was a receive interrupt */
2710 +    /* on the sci uart we just get one character per interrupt */
2711 +
2712 +    while (  SciCharAvailable() )               /* char in data register? */
2713 +    {
2714 +        ch = SciReadCharNoWait();               /* get the char from the uart */
2715 +
2716 +        /* IMPORTANT!!! */
2717 +        /* either send it to the termios module or keep it locally */
2718 +
2719 +        if ( SciOpened == DRIVER_OPENED )       /* the driver is open */
2720 +        {
2721 +            SciRcvBufPutChar(ch);               /* keep it locally */
2722 +        }
2723 +        else                                    /* put in termios buffer */
2724 +        {
2725 +            char c = (char) ch;
2726 +            rtems_termios_enqueue_raw_characters( SciTermioTty, &c, 1 );
2727 +        }
2728 +
2729 +        *SCSR &= SCI_CLEAR_RX_INT;              /* clear the interrupt */
2730 +    }
2731 +}
2732 +\f
2733 +
2734 +/*
2735 + *                              SECTION 1
2736 + *                ROUTINES TO MANIPULATE THE CIRCULAR BUFFER
2737 + */
2738 +
2739 +/****************************************************************************
2740 +* Func:     SciRcvBufGetChar
2741 +* Desc:     read a character from the circular buffer
2742 +*           make sure there is data before you call this!
2743 +* Inputs:   none
2744 +* Outputs:  the character or -1
2745 +* Errors:   none
2746 +* Scope:    private
2747 +****************************************************************************/
2748 +
2749 +static int8_t   SciRcvBufGetChar(void)
2750 +{
2751 +    rtems_interrupt_level level;
2752 +    uint8_t   ch;
2753 +
2754 +    if ( SciRcvBufCount == 0 )
2755 +    {
2756 +        rtems_fatal_error_occurred(0xDEAD);     /* check the count first! */
2757 +    }
2758 +
2759 +    rtems_interrupt_disable( level );           /* disable interrupts */
2760 +
2761 +    ch = SciRcvBuffer[SciRcvBufGetIndex];       /* get next byte */
2762 +
2763 +    SciRcvBufGetIndex++;                        /* bump the index */
2764 +
2765 +    SciRcvBufGetIndex &= SCI_RCV_BUF_SIZE - 1;  /* and wrap it */
2766 +
2767 +    SciRcvBufCount--;                           /* decrement counter */
2768 +
2769 +    rtems_interrupt_enable( level );            /* restore interrupts */
2770 +
2771 +    return ch;                                  /* return the char */
2772 +}
2773 +\f
2774 +
2775 +/****************************************************************************
2776 +* Func:     SciRcvBufPutChar
2777 +* Desc:     put a character into the rcv data circular buffer
2778 +* Inputs:   the character
2779 +* Outputs:  none
2780 +* Errors:   none
2781 +* Scope:    private
2782 +****************************************************************************/
2783 +
2784 +static void SciRcvBufPutChar( uint8_t   ch )
2785 +{
2786 +    rtems_interrupt_level level;
2787 +
2788 +    if ( SciRcvBufCount == SCI_RCV_BUF_SIZE )   /* is there room? */
2789 +    {
2790 +        return;                                 /* no, throw it away */
2791 +    }
2792 +
2793 +    rtems_interrupt_disable( level );           /* disable interrupts */
2794 +
2795 +    SciRcvBuffer[SciRcvBufPutIndex] = ch;       /* put it in the buf */
2796 +
2797 +    SciRcvBufPutIndex++;                        /* bump the index */
2798 +
2799 +    SciRcvBufPutIndex &= SCI_RCV_BUF_SIZE - 1;  /* and wrap it */
2800 +
2801 +    SciRcvBufCount++;                           /* increment counter */
2802 +
2803 +    rtems_interrupt_enable( level );            /* restore interrupts */
2804 +
2805 +    return;                                     /* return */
2806 +}
2807 +\f
2808 +
2809 +/****************************************************************************
2810 +* Func:     SciRcvBufFlush
2811 +* Desc:     completely reset and clear the rcv buffer
2812 +* Inputs:   none
2813 +* Outputs:  none
2814 +* Errors:   none
2815 +* Scope:    private
2816 +****************************************************************************/
2817 +
2818 +#if 0                                           /* prevents compiler warning */
2819 +static void SciRcvBufFlush( void )
2820 +{
2821 +    rtems_interrupt_level level;
2822 +
2823 +    rtems_interrupt_disable( level );           /* disable interrupts */
2824 +
2825 +    memset( SciRcvBuffer, 0, sizeof(SciRcvBuffer) );
2826 +
2827 +    SciRcvBufPutIndex = 0;                      /* clear */
2828 +
2829 +    SciRcvBufGetIndex = 0;                      /* clear */
2830 +
2831 +    SciRcvBufCount = 0;                         /* clear */
2832 +
2833 +    rtems_interrupt_enable( level );            /* restore interrupts */
2834 +
2835 +    return;                                     /* return */
2836 +}
2837 +#endif
2838 +\f
2839 +
2840 +/*
2841 + *
2842 + *                              SECTION 2
2843 + *            INTERRUPT BASED ENTRY POINTS FOR THE TERMIOS MODULE
2844 + */
2845 +
2846 +/****************************************************************************
2847 +* Func:     SciInterruptOpen
2848 +* Desc:     open routine for the interrupt based device driver
2849 +*           Default state is 9600 baud, 8 bits, No parity, and 1 stop bit. ??
2850 +**CHANGED** Default baud rate is now 19200, 8N1
2851 +*           called from rtems_termios_open which is called from console_open
2852 +* Inputs:   major - device number
2853 +*           minor - device number
2854 +*           args - points to terminal info
2855 +* Outputs:  success/fail
2856 +* Errors:   none
2857 +* Scope:    public API
2858 +****************************************************************************/
2859 +
2860 +int   SciInterruptOpen(
2861 +    int    major,
2862 +    int    minor,
2863 +    void  *arg
2864 +)
2865 +{
2866 +    rtems_libio_open_close_args_t * args = arg;
2867 +    rtems_isr_entry old_vector;
2868 +
2869 +    if ( minor != SCI_MINOR )                   /* check minor device num */
2870 +    {
2871 +        return -1;
2872 +    }
2873 +
2874 +    if ( !args )                                /* must have args */
2875 +    {
2876 +        return -1;
2877 +    }
2878 +
2879 +    SciTermioTty = args->iop->data1;            /* save address of struct */
2880 +
2881 +    SciDisableAllInterrupts();                  /* turn off sci interrupts */
2882 +
2883 +    /* THIS IS ACTUALLY A BAD THING - SETTING LINE PARAMETERS HERE */
2884 +    /* IT SHOULD BE DONE THROUGH TCSETATTR() WHEN THE CONSOLE IS OPENED!!! */
2885 +
2886 +/*  SciSetBaud(115200);                         set the baud rate */
2887 +/*  SciSetBaud( 57600);                         set the baud rate */
2888 +/*  SciSetBaud( 38400);                         set the baud rate */
2889 +    SciSetBaud( 19200);                      /* set the baud rate */
2890 +/*  SciSetBaud(  9600);                         set the baud rate */
2891 +
2892 +    SciSetParity(SCI_PARITY_NONE);              /* set parity to none */
2893 +
2894 +    SciSetDataBits(SCI_8_DATA_BITS);            /* set data bits to 8 */
2895 +
2896 +    /* Install our interrupt handler into RTEMS, where does 66 come from? */
2897 +
2898 +    rtems_interrupt_catch( SciIsr, 66, &old_vector );
2899 +
2900 +    *QIVR  = 66;
2901 +    *QIVR &= 0xf8;
2902 +    *QILR |= 0x06 & 0x07;
2903 +
2904 +    SciEnableTransmitter();                     /* enable the transmitter */
2905 +
2906 +    SciEnableReceiver();                        /* enable the receiver */
2907 +
2908 +    SciEnableReceiveInterrupts();               /* enable rcv interrupts */
2909 +
2910 +    return RTEMS_SUCCESSFUL;
2911 +}
2912 +\f
2913 +
2914 +/****************************************************************************
2915 +* Func:     SciInterruptClose
2916 +* Desc:     close routine called by the termios module
2917 +* Inputs:   major - device number
2918 +*           minor - device number
2919 +*           args - unused
2920 +* Outputs:  success/fail
2921 +* Errors:   none
2922 +* Scope:    public - termio entry point
2923 +****************************************************************************/
2924 +
2925 +int   SciInterruptClose(
2926 +    int    major,
2927 +    int    minor,
2928 +    void  *arg
2929 +)
2930 +{
2931 +    SciDisableAllInterrupts();
2932 +
2933 +    return RTEMS_SUCCESSFUL;
2934 +}
2935 +\f
2936 +
2937 +/****************************************************************************
2938 +* Func:     SciInterruptWrite
2939 +* Desc:     writes data to the uart using transmit interrupts
2940 +* Inputs:   minor - device number
2941 +*           buf - points to the data
2942 +*           len - number of bytes to send
2943 +* Outputs:  success/fail
2944 +* Errors:   none
2945 +* Scope:    public API
2946 +****************************************************************************/
2947 +
2948 +int   SciInterruptWrite(
2949 +    int         minor,
2950 +    const char *buf,
2951 +    int         len
2952 +)
2953 +{
2954 +    /* We are using interrupt driven output so termios only sends us */
2955 +    /* one character at a time. The sci does not have a fifo. */
2956 +
2957 +    if ( !len )                                 /* no data? */
2958 +    {
2959 +        return 0;                               /* return error */
2960 +    }
2961 +
2962 +    if ( minor != SCI_MINOR )                   /* check the minor dev num */
2963 +    {
2964 +        return 0;                               /* return error */
2965 +    }
2966 +
2967 +    if ( SciOpened == DRIVER_OPENED )           /* is the driver api open? */
2968 +    {
2969 +        return 1;                               /* yep, throw this away */
2970 +    }
2971 +
2972 +    SciWriteCharNoWait(*buf);                   /* try to send a char */
2973 +
2974 +    *SCSR &= SCI_CLEAR_TDRE;                    /* clear tx data reg empty flag */
2975 +
2976 +    SciEnableTransmitInterrupts();              /* enable the tx interrupt */
2977 +
2978 +    return 1;                                   /* return success */
2979 +}
2980 +\f
2981 +
2982 +/****************************************************************************
2983 +* Func:     SciSetAttributes
2984 +* Desc:     setup the uart based on the termios modules requests
2985 +* Inputs:   minor - device number
2986 +*           t - pointer to the termios info struct
2987 +* Outputs:  none
2988 +* Errors:   none
2989 +* Scope:    public API
2990 +****************************************************************************/
2991 +
2992 +int   SciSetAttributes(
2993 +    int                   minor,
2994 +    const struct termios *t
2995 +)
2996 +{
2997 +    uint32_t    baud_requested;
2998 +    uint32_t    sci_rate = 0;
2999 +    uint16_t    sci_parity = 0;
3000 +    uint16_t    sci_databits = 0;
3001 +
3002 +    if ( minor != SCI_MINOR )                   /* check the minor dev num */
3003 +    {
3004 +        return -1;                              /* return error */
3005 +    }
3006 +
3007 +    /* if you look closely you will see this is the only thing we use */
3008 +    /* set the baud rate */
3009 +
3010 +    baud_requested = t->c_cflag & CBAUD;        /* baud rate */
3011 +
3012 +    if (!baud_requested)
3013 +    {
3014 +/*        baud_requested = B9600;                   default to 9600 baud */
3015 +        baud_requested = B19200;                 /* default to 19200 baud */
3016 +    }
3017 +
3018 +    sci_rate = termios_baud_to_number( baud_requested );
3019 +
3020 +    /* parity error detection */
3021 +
3022 +    if (t->c_cflag & PARENB)                    /* enable parity detection? */
3023 +    {
3024 +        if (t->c_cflag & PARODD)
3025 +        {
3026 +            sci_parity = SCI_PARITY_ODD;        /* select odd parity */
3027 +        }
3028 +        else
3029 +        {
3030 +            sci_parity = SCI_PARITY_EVEN;       /* select even parity */
3031 +        }
3032 +    }
3033 +    else
3034 +    {
3035 +        sci_parity = SCI_PARITY_NONE;           /* no parity, most common */
3036 +    }
3037 +
3038 +    /*  set the number of data bits, 8 is most common */
3039 +
3040 +    if (t->c_cflag & CSIZE)                     /* was it specified? */
3041 +    {
3042 +        switch (t->c_cflag & CSIZE)
3043 +        {
3044 +            case CS8:   sci_databits = SCI_8_DATA_BITS;   break;
3045 +            default :   sci_databits = SCI_9_DATA_BITS;   break;
3046 +        }
3047 +    }
3048 +    else
3049 +    {
3050 +        sci_databits = SCI_8_DATA_BITS;         /* default to 8 data bits */
3051 +    }
3052 +
3053 +    /*  the number of stop bits; always 1 for SCI */
3054 +
3055 +    if (t->c_cflag & CSTOPB)
3056 +    {
3057 +        /* do nothing */
3058 +    }
3059 +
3060 +    /* setup the hardware with these serial port parameters */
3061 +
3062 +    SciSetBaud(sci_rate);                       /* set the baud rate */
3063 +    SciSetParity(sci_parity);                   /* set the parity type */
3064 +    SciSetDataBits(sci_databits);               /* set the data bits */
3065 +
3066 +    return RTEMS_SUCCESSFUL;
3067 +}
3068 +\f
3069 +
3070 +/*
3071 + *
3072 + *                              SECTION 3
3073 + *            POLLING BASED ENTRY POINTS FOR THE TERMIOS MODULE
3074 + */
3075 +
3076 +/****************************************************************************
3077 +* Func:     SciPolledOpen
3078 +* Desc:     open routine for the polled i/o version of the driver
3079 +*           called from rtems_termios_open which is called from console_open
3080 +* Inputs:   major - device number
3081 +*           minor - device number
3082 +*           args - points to terminal info struct
3083 +* Outputs:  success/fail
3084 +* Errors:   none
3085 +* Scope:    public - termios entry point
3086 +****************************************************************************/
3087 +
3088 +int   SciPolledOpen(
3089 +    int   major,
3090 +    int   minor,
3091 +    void *arg
3092 +)
3093 +{
3094 +    rtems_libio_open_close_args_t * args = arg;
3095 +
3096 +    if ( minor != SCI_MINOR )                   /* check minor device num */
3097 +    {
3098 +        return -1;
3099 +    }
3100 +
3101 +    if ( !args )                                /* must have args */
3102 +    {
3103 +        return -1;
3104 +    }
3105 +
3106 +    SciTermioTty = args->iop->data1;            /* Store tty pointer */
3107 +
3108 +    SciDisableAllInterrupts();                  /* don't generate interrupts */
3109 +
3110 +    /* THIS IS ACTUALLY A BAD THING - SETTING LINE PARAMETERS HERE */
3111 +    /* IT SHOULD BE DONE THROUGH TCSETATTR() WHEN THE CONSOLE IS OPENED!!! */
3112 +
3113 +/*  SciSetBaud(115200);                            set the baud rate */
3114 +/*  SciSetBaud( 57600);                            set the baud rate */
3115 +/*  SciSetBaud( 38400);                            set the baud rate */
3116 +  SciSetBaud( 19200);                         /* set the baud rate */
3117 +/*  SciSetBaud(  9600);                            set the baud rate */
3118 +
3119 +    SciSetParity(SCI_PARITY_NONE);              /* set no parity */
3120 +
3121 +    SciSetDataBits(SCI_8_DATA_BITS);            /* set 8 data bits */
3122 +
3123 +    SciEnableTransmitter();                     /* enable the xmitter */
3124 +
3125 +    SciEnableReceiver();                        /* enable the rcvr */
3126 +
3127 +    return RTEMS_SUCCESSFUL;
3128 +}
3129 +\f
3130 +
3131 +/****************************************************************************
3132 +* Func:     SciPolledClose
3133 +* Desc:     close routine for the device driver, same for both
3134 +* Inputs:   major - device number
3135 +*           minor - device number
3136 +*           args - unused
3137 +* Outputs:  success/fail
3138 +* Errors:   none
3139 +* Scope:    public termios API
3140 +****************************************************************************/
3141 +
3142 +int   SciPolledClose(
3143 +    int    major,
3144 +    int    minor,
3145 +    void  *arg
3146 +)
3147 +{
3148 +    SciDisableAllInterrupts();
3149 +
3150 +    return RTEMS_SUCCESSFUL;
3151 +}
3152 +\f
3153 +
3154 +/****************************************************************************
3155 +* Func:     SciPolledRead
3156 +* Desc:     polling based read routine for the uart
3157 +* Inputs:   minor - device number
3158 +* Outputs:  error or the character read
3159 +* Errors:   none
3160 +* Scope:    public API
3161 +****************************************************************************/
3162 +
3163 +int   SciPolledRead(
3164 +    int   minor
3165 +)
3166 +{
3167 +    if ( minor != SCI_MINOR )               /* check the type-punned dev num */
3168 +    {
3169 +        return -1;                          /* return error */
3170 +    }
3171 +
3172 +    if ( SciCharAvailable() )               /* if a char is available */
3173 +    {
3174 +        return SciReadCharNoWait();         /* read the rx data register */
3175 +    }
3176 +
3177 +    return -1;                              /* return error */
3178 +}
3179 +\f
3180 +
3181 +/****************************************************************************
3182 +* Func:     SciPolledWrite
3183 +* Desc:     writes out characters in polled mode, waiting for the uart
3184 +*           check in console_open, but we only seem to use interrupt mode
3185 +* Inputs:   minor - device number
3186 +*           buf - points to the data
3187 +*           len - how many bytes
3188 +* Outputs:  error or number of bytes written
3189 +* Errors:   none
3190 +* Scope:    public termios API
3191 +****************************************************************************/
3192 +
3193 +int   SciPolledWrite(
3194 +    int         minor,
3195 +    const char *buf,
3196 +    int         len
3197 +)
3198 +{
3199 +    int32_t   written = 0;
3200 +
3201 +    if ( minor != SCI_MINOR )                   /* check minor device num */
3202 +    {
3203 +        return -1;
3204 +    }
3205 +
3206 +    if ( SciOpened == DRIVER_OPENED )           /* is the driver api open? */
3207 +    {
3208 +        return -1;                              /* toss the data */
3209 +    }
3210 +
3211 +    /* send each byte in the string out the port */
3212 +
3213 +    while ( written < len )
3214 +    {
3215 +        SciWriteCharWait(*buf++);               /* send a byte */
3216 +
3217 +        written++;                              /* increment counter */
3218 +    }
3219 +
3220 +    return written;                             /* return count */
3221 +}
3222 +\f
3223 +
3224 +/*
3225 + *
3226 + *                              SECTION 4
3227 + *                 DEVICE DRIVER PUBLIC API ENTRY POINTS
3228 + */
3229 +
3230 +/****************************************************************************
3231 +* Func:     SciInit
3232 +* Desc:     Initialize the lasers device driver and hardware
3233 +* Inputs:   major - the major device number which is assigned by rtems
3234 +*           minor - the minor device number which is undefined at this point
3235 +*           arg - ?????
3236 +* Outputs:  RTEMS_SUCCESSFUL
3237 +* Errors:   None.
3238 +* Scope:    public API
3239 +****************************************************************************/
3240 +
3241 +rtems_device_driver SciInitialize (
3242 +    rtems_device_major_number major,
3243 +    rtems_device_minor_number minor,
3244 +    void * arg
3245 +)
3246 +{
3247 +/*     rtems_status_code status; */
3248 +
3249 +/*printk("%s\r\n", __FUNCTION__); */
3250 +
3251 +    /* register the SCI device name for termios console i/o
3252 +     * this is done over in console.c which doesn't seem exactly right
3253 +     * but there were problems doing it here...
3254 +     */
3255 +
3256 +/*  status = rtems_io_register_name( "/dev/sci", major, 0 ); */
3257 +
3258 +/*  if (status != RTEMS_SUCCESSFUL) */
3259 +/*      rtems_fatal_error_occurred(status); */
3260 +
3261 +    SciMajor = major;                           /* save the rtems major number */
3262 +
3263 +    SciOpened = DRIVER_CLOSED;                  /* initial state is closed */
3264 +
3265 +    /* if you have an interrupt handler, install it here */
3266 +
3267 +    SciInited = 1;                              /* set the inited flag */
3268 +
3269 +    return RTEMS_SUCCESSFUL;
3270 +}
3271 +\f
3272 +
3273 +/****************************************************************************
3274 +* Func:     SciOpen
3275 +* Desc:     device driver open routine
3276 +*           you must open a device before you can anything else
3277 +*           only one process can have the device opened at a time
3278 +*           you could look at the task id to restrict access if you want
3279 +* Inputs:   major - the major device number assigned by rtems
3280 +*           minor - the minor device number assigned by us
3281 +*           arg - ?????
3282 +* Outputs:  see below
3283 +* Errors:   none
3284 +* Scope:    public API
3285 +****************************************************************************/
3286 +
3287 +rtems_device_driver SciOpen (
3288 +    rtems_device_major_number major,
3289 +    rtems_device_minor_number minor,
3290 +    void * arg
3291 +)
3292 +{
3293 +/*printk("%s major=%d minor=%d\r\n", __FUNCTION__,major,minor); */
3294 +
3295 +    if (SciInited == 0)                         /* must be initialized first! */
3296 +    {
3297 +        return RTEMS_NOT_CONFIGURED;
3298 +    }
3299 +
3300 +    if (minor != SCI_MINOR)
3301 +    {
3302 +        return RTEMS_INVALID_NAME;              /* verify minor number */
3303 +    }
3304 +
3305 +    if (SciOpened == DRIVER_OPENED)
3306 +    {
3307 +        return RTEMS_RESOURCE_IN_USE;           /* already opened! */
3308 +    }
3309 +
3310 +    SciOpened = DRIVER_OPENED;                  /* set the opened flag */
3311 +
3312 +    return RTEMS_SUCCESSFUL;
3313 +}
3314 +\f
3315 +
3316 +/****************************************************************************
3317 +* Func:     SciClose
3318 +* Desc:     device driver close routine
3319 +*           the device must be opened before you can close it
3320 +*           the device must be closed before someone (else) can open it
3321 +* Inputs:   major - the major device number
3322 +*           minor - the minor device number
3323 +*           arg - ?????
3324 +* Outputs:  see below
3325 +* Errors:   none
3326 +* Scope:    public API
3327 +****************************************************************************/
3328 +
3329 +rtems_device_driver SciClose (
3330 +    rtems_device_major_number major,
3331 +    rtems_device_minor_number minor,
3332 +    void * arg
3333 +)
3334 +{
3335 +/*printk("%s major=%d minor=%d\r\n", __FUNCTION__,major,minor); */
3336 +
3337 +    if (minor != SCI_MINOR)
3338 +    {
3339 +        return RTEMS_INVALID_NAME;              /* check the minor number */
3340 +    }
3341 +
3342 +    if (SciOpened != DRIVER_OPENED)
3343 +    {
3344 +        return RTEMS_INCORRECT_STATE;           /* must be opened first */
3345 +    }
3346 +
3347 +    SciOpened = DRIVER_CLOSED;                  /* set the flag */
3348 +
3349 +    return RTEMS_SUCCESSFUL;
3350 +}
3351 +\f
3352 +
3353 +/****************************************************************************
3354 +* Func:     SciRead
3355 +* Desc:     device driver read routine
3356 +*           this function is not meaningful for the laser devices
3357 +* Inputs:   major - the major device number
3358 +*           minor - the minor device number
3359 +*           arg - read/write arguments
3360 +* Outputs:  see below
3361 +* Errors:   none
3362 +* Scope:    public API
3363 +****************************************************************************/
3364 +
3365 +rtems_device_driver SciRead (
3366 +    rtems_device_major_number major,
3367 +    rtems_device_minor_number minor,
3368 +    void *arg
3369 +)
3370 +{
3371 +    rtems_libio_rw_args_t *rw_args;             /* ptr to argument struct */
3372 +    char      *buffer;
3373 +    uint16_t   length;
3374 +
3375 +    rw_args = (rtems_libio_rw_args_t *) arg;    /* arguments to read() */
3376 +
3377 +    if (minor != SCI_MINOR)
3378 +    {
3379 +        return RTEMS_INVALID_NAME;              /* check the minor number */
3380 +    }
3381 +
3382 +    if (SciOpened == DRIVER_CLOSED)
3383 +    {
3384 +        return RTEMS_INCORRECT_STATE;           /* must be opened first */
3385 +    }
3386 +
3387 +    buffer = rw_args->buffer;                   /* points to user's buffer */
3388 +
3389 +    length = rw_args->count;                    /* how many bytes they want */
3390 +
3391 +/*  *buffer = SciReadCharWait();                   wait for a character */
3392 +
3393 +    /* if there isn't a character available, wait until one shows up */
3394 +    /* or the timeout period expires, which ever happens first */
3395 +
3396 +    if ( SciRcvBufCount == 0 )                  /* no chars */
3397 +    {
3398 +        /* wait for someone to wake me up... */
3399 +        /*rtems_task_wake_after(SciReadTimeout); */
3400 +    }
3401 +
3402 +    if ( SciRcvBufCount )                       /* any characters locally? */
3403 +    {
3404 +        *buffer = SciRcvBufGetChar();           /* get the character */
3405 +
3406 +        rw_args->bytes_moved = 1;               /* how many we actually read */
3407 +    }
3408 +
3409 +    return RTEMS_SUCCESSFUL;
3410 +}
3411 +\f
3412 +
3413 +/****************************************************************************
3414 +* Func:     SciWrite
3415 +* Desc:     device driver write routine
3416 +*           this function is not meaningful for the laser devices
3417 +* Inputs:   major - the major device number
3418 +*           minor - the minor device number
3419 +*           arg - read/write arguments
3420 +* Outputs:  see below
3421 +* Errors:   non3
3422 +* Scope:    public API
3423 +****************************************************************************/
3424 +
3425 +rtems_device_driver SciWrite (
3426 +    rtems_device_major_number major,
3427 +    rtems_device_minor_number minor,
3428 +    void * arg
3429 +)
3430 +{
3431 +    rtems_libio_rw_args_t *rw_args;             /* ptr to argument struct */
3432 +    uint8_t   *buffer;
3433 +    uint16_t   length;
3434 +
3435 +    rw_args = (rtems_libio_rw_args_t *) arg;
3436 +
3437 +    if (minor != SCI_MINOR)
3438 +    {
3439 +        return RTEMS_INVALID_NAME;              /* check the minor number */
3440 +    }
3441 +
3442 +    if (SciOpened == DRIVER_CLOSED)
3443 +    {
3444 +        return RTEMS_INCORRECT_STATE;           /* must be opened first */
3445 +    }
3446 +
3447 +    buffer = (uint8_t*)rw_args->buffer;       /* points to data */
3448 +
3449 +    length = rw_args->count;                    /* how many bytes */
3450 +
3451 +    while (length--)
3452 +    {
3453 +        SciWriteCharWait(*buffer++);            /* send the bytes out */
3454 +    }
3455 +
3456 +    rw_args->bytes_moved = rw_args->count;      /* how many we wrote */
3457 +
3458 +    return RTEMS_SUCCESSFUL;
3459 +}
3460 +\f
3461 +
3462 +/****************************************************************************
3463 +* Func:     SciControl
3464 +* Desc:     device driver control routine
3465 +*           see below for an example of how to use the ioctl interface
3466 +* Inputs:   major - the major device number
3467 +*           minor - the minor device number
3468 +*           arg - io control args
3469 +* Outputs:  see below
3470 +* Errors:   none
3471 +* Scope:    public API
3472 +****************************************************************************/
3473 +
3474 +rtems_device_driver SciControl (
3475 +    rtems_device_major_number major,
3476 +    rtems_device_minor_number minor,
3477 +    void * arg
3478 +)
3479 +{
3480 +    rtems_libio_ioctl_args_t *args = arg;       /* rtems arg struct */
3481 +    uint16_t   command;                         /* the cmd to execute */
3482 +    uint16_t   unused;                          /* maybe later */
3483 +    uint16_t   *ptr;                            /* ptr to user data */
3484 +
3485 +/*printk("%s major=%d minor=%d\r\n", __FUNCTION__,major,minor); */
3486 +
3487 +    /* do some sanity checking */
3488 +
3489 +    if (minor != SCI_MINOR)
3490 +    {
3491 +        return RTEMS_INVALID_NAME;              /* check the minor number */
3492 +    }
3493 +
3494 +    if (SciOpened == DRIVER_CLOSED)
3495 +    {
3496 +        return RTEMS_INCORRECT_STATE;           /* must be open first */
3497 +    }
3498 +
3499 +    if (args == 0)
3500 +    {
3501 +        return RTEMS_INVALID_ADDRESS;           /* must have args */
3502 +    }
3503 +
3504 +    args->ioctl_return = -1;                    /* assume an error */
3505 +
3506 +    command = args->command;                    /* get the command */
3507 +    ptr     = args->buffer;                     /* this is an address */
3508 +    unused  = *ptr;                             /* brightness */
3509 +
3510 +    if (command == SCI_SEND_BREAK)              /* process the command */
3511 +    {
3512 +        SciSendBreak();                         /* send break char */
3513 +    }
3514 +
3515 +    args->ioctl_return = 0;                     /* return status */
3516 +
3517 +    return RTEMS_SUCCESSFUL;
3518 +}
3519 +\f
3520 +
3521 +/*
3522 + *
3523 + *                              SECTION 5
3524 + *                       HARDWARE LEVEL ROUTINES
3525 + */
3526 +
3527 +/****************************************************************************
3528 +* Func:     SciSetBaud
3529 +* Desc:     setup the uart based on the termios modules requests
3530 +* Inputs:   baud rate
3531 +* Outputs:  none
3532 +* Errors:   none
3533 +* Scope:    private
3534 +****************************************************************************/
3535 +
3536 +static void SciSetBaud(uint32_t   rate)
3537 +{
3538 +    uint16_t   value;
3539 +    uint16_t   save_sccr1;
3540 +
3541 +/* when you open the console you need to set the termio struct baud rate */
3542 +/* it has a default value of 9600, when someone calls tcsetattr it reverts! */
3543 +
3544 +    SciBaud = rate;                             /* save the rate */
3545 +
3546 +    /* calculate the register value as a float and convert to an int */
3547 +    /* set baud rate - you must define the system clock constant */
3548 +    /* see mrm332.h for an example */
3549 +
3550 +    value = ( (uint16_t) ( SYS_CLOCK / rate / 32.0 + 0.5 ) & 0x1fff );
3551 +
3552 +    save_sccr1 = *SCCR1;                        /* save register */
3553 +
3554 +    /* also turns off the xmtr and rcvr */
3555 +
3556 +    *SCCR1 &= SCI_DISABLE_INT_ALL;              /* disable interrupts */
3557 +
3558 +    *SCCR0 = value;                             /* write the register */
3559 +
3560 +    *SCCR1 = save_sccr1;                        /* restore register */
3561 +
3562 +    return;
3563 +}
3564 +\f
3565 +
3566 +/****************************************************************************
3567 +* Func:     SciSetParity
3568 +* Desc:     setup the uart based on the termios modules requests
3569 +* Inputs:   parity
3570 +* Outputs:  none
3571 +* Errors:   none
3572 +* Scope:    private
3573 +****************************************************************************/
3574 +
3575 +static void SciSetParity(uint16_t   parity)
3576 +{
3577 +    uint16_t   value;
3578 +
3579 +    value = *SCCR1;                             /* get the register */
3580 +
3581 +    if (parity == SCI_PARITY_ODD)
3582 +    {
3583 +        value |= SCI_PARITY_ENABLE;             /* parity enabled */
3584 +        value |= SCI_PARITY_ODD;                /* parity odd */
3585 +    }
3586 +
3587 +    else if (parity == SCI_PARITY_EVEN)
3588 +    {
3589 +        value |= SCI_PARITY_ENABLE;             /* parity enabled */
3590 +        value &= ~SCI_PARITY_ODD;               /* parity even */
3591 +    }
3592 +
3593 +    else if (parity == SCI_PARITY_NONE)
3594 +    {
3595 +        value &= ~SCI_PARITY_ENABLE;            /* disabled, most common */
3596 +    }
3597 +
3598 +    /* else no changes */
3599 +
3600 +    *SCCR1 = value;                             /* write the register */
3601 +
3602 +    return;
3603 +}
3604 +\f
3605 +
3606 +/****************************************************************************
3607 +* Func:     SciSetDataBits
3608 +* Desc:     setup the uart based on the termios modules requests
3609 +* Inputs:   data bits
3610 +* Outputs:  none
3611 +* Errors:   none
3612 +* Scope:    private
3613 +****************************************************************************/
3614 +
3615 +static void SciSetDataBits(uint16_t   bits)
3616 +{
3617 +    uint16_t   value;
3618 +
3619 +    value = *SCCR1;                             /* get the register */
3620 +
3621 +    /* note - the parity setting affects the number of data bits */
3622 +
3623 +    if (bits == SCI_9_DATA_BITS)
3624 +    {
3625 +        value |= SCI_9_DATA_BITS;               /* 9 data bits */
3626 +    }
3627 +
3628 +    else if (bits == SCI_8_DATA_BITS)
3629 +    {
3630 +        value &= SCI_8_DATA_BITS;               /* 8 data bits */
3631 +    }
3632 +
3633 +    /* else no changes */
3634 +
3635 +    *SCCR1 = value;                             /* write the register */
3636 +
3637 +    return;
3638 +}
3639 +\f
3640 +
3641 +/****************************************************************************
3642 +* Func:     SciDisableAllInterrupts
3643 +* Func:     SciEnableTransmitInterrupts
3644 +* Func:     SciEnableReceiveInterrupts
3645 +* Desc:     handles generation of interrupts by the sci module
3646 +* Inputs:   none
3647 +* Outputs:  none
3648 +* Errors:   none
3649 +* Scope:    private
3650 +****************************************************************************/
3651 +
3652 +static void inline SciDisableAllInterrupts( void )
3653 +{
3654 +    /* this also turns off the xmtr and rcvr */
3655 +
3656 +    *SCCR1 &= SCI_DISABLE_INT_ALL;
3657 +}
3658 +
3659 +static void inline SciEnableReceiveInterrupts( void )
3660 +{
3661 +    *SCCR1 |= SCI_ENABLE_INT_RX;
3662 +}
3663 +
3664 +static void inline SciDisableReceiveInterrupts( void )
3665 +{
3666 +    *SCCR1 &= SCI_DISABLE_INT_RX;
3667 +}
3668 +
3669 +static void inline SciEnableTransmitInterrupts( void )
3670 +{
3671 +    *SCCR1 |= SCI_ENABLE_INT_TX;
3672 +}
3673 +
3674 +static void inline SciDisableTransmitInterrupts( void )
3675 +{
3676 +    *SCCR1 &= SCI_DISABLE_INT_TX;
3677 +}
3678 +\f
3679 +
3680 +/****************************************************************************
3681 +* Func:     SciEnableTransmitter, SciDisableTransmitter
3682 +* Func:     SciEnableReceiver,    SciDisableReceiver
3683 +* Desc:     turns the transmitter and receiver on and off
3684 +* Inputs:   none
3685 +* Outputs:  none
3686 +* Errors:   none
3687 +* Scope:    private
3688 +****************************************************************************/
3689 +
3690 +static void inline SciEnableTransmitter( void )
3691 +{
3692 +    *SCCR1 |= SCI_ENABLE_XMTR;
3693 +}
3694 +
3695 +static void inline SciDisableTransmitter( void )
3696 +{
3697 +    *SCCR1 &= SCI_DISABLE_XMTR;
3698 +}
3699 +
3700 +static void inline SciEnableReceiver( void )
3701 +{
3702 +    *SCCR1 |= SCI_ENABLE_RCVR;
3703 +}
3704 +
3705 +static void inline SciDisableReceiver( void )
3706 +{
3707 +    *SCCR1 &= SCI_DISABLE_RCVR;
3708 +}
3709 +\f
3710 +
3711 +/****************************************************************************
3712 +* Func:     SciWriteCharWait
3713 +* Desc:     wait for room in the fifo and then put a char in
3714 +* Inputs:   a byte to send
3715 +* Outputs:  none
3716 +* Errors:   none
3717 +* Scope:    public
3718 +****************************************************************************/
3719 +
3720 +void SciWriteCharWait(uint8_t   c)
3721 +{
3722 +    /* poll the fifo, waiting for room for another character */
3723 +
3724 +    while ( ( *SCSR & SCI_XMTR_AVAILABLE ) == 0 )
3725 +    {
3726 +        /* Either we are writing to the fifo faster than
3727 +         * the uart can clock bytes out onto the cable,
3728 +         * or we are in flow control (actually no, we
3729 +         * are ignoring flow control from the other end).
3730 +         * In the first case, higher baud rates will help.
3731 +         */
3732 +      /* relinquish processor while waiting */
3733 +      rtems_task_wake_after(RTEMS_YIELD_PROCESSOR);
3734 +    }
3735 +
3736 +    *SCDR = c;                                  /* send the charcter */
3737 +
3738 +    SciBytesOut++;                              /* increment the counter */
3739 +
3740 +    return;
3741 +}
3742 +
3743 +/****************************************************************************
3744 +* Func:     SciWriteCharNoWait
3745 +* Desc:     if no room in the fifo throw the char on the floor
3746 +* Inputs:   a byte to send
3747 +* Outputs:  none
3748 +* Errors:   none
3749 +* Scope:    public
3750 +****************************************************************************/
3751 +
3752 +void SciWriteCharNoWait(uint8_t   c)
3753 +{
3754 +    if ( ( *SCSR & SCI_XMTR_AVAILABLE ) == 0 )
3755 +    {
3756 +        return;                                 /* no room, throw it away */
3757 +    }
3758 +
3759 +    *SCDR = c;                                  /* put the char in the fifo */
3760 +
3761 +    SciBytesOut++;                              /* increment the counter */
3762 +
3763 +    return;
3764 +}
3765 +\f
3766 +
3767 +/****************************************************************************
3768 +* Func:     SciReadCharWait
3769 +* Desc:     read a character, waiting for one to show up, if need be
3770 +* Inputs:   none
3771 +* Outputs:  a character
3772 +* Errors:   none
3773 +* Scope:    public
3774 +****************************************************************************/
3775 +
3776 +uint8_t   inline SciReadCharWait( void )
3777 +{
3778 +    uint8_t   ch;
3779 +
3780 +    while ( SciCharAvailable() == 0 )           /* anything there? */
3781 +    {
3782 +      /* relinquish processor while waiting */
3783 +      rtems_task_wake_after(RTEMS_YIELD_PROCESSOR);
3784 +    }
3785 +
3786 +    /* if you have rcv ints enabled, then the isr will probably */
3787 +    /* get the character before you will unless you turn off ints */
3788 +    /* ie polling and ints don't mix that well */
3789 +
3790 +    ch = *SCDR;                                 /* get the charcter */
3791 +
3792 +    SciBytesIn++;                               /* increment the counter */
3793 +
3794 +    return ch;                                  /* return the char */
3795 +}
3796 +
3797 +/****************************************************************************
3798 +* Func:     SciReadCharNoWait
3799 +* Desc:     try to get a char but dont wait for one
3800 +* Inputs:   none
3801 +* Outputs:  a character or -1 if none
3802 +* Errors:   none
3803 +* Scope:    public
3804 +****************************************************************************/
3805 +
3806 +uint8_t   inline SciReadCharNoWait( void )
3807 +{
3808 +    uint8_t   ch;
3809 +
3810 +    if ( SciCharAvailable() == 0 )              /* anything there? */
3811 +        return -1;
3812 +
3813 +    ch = *SCDR;                                 /* get the character */
3814 +
3815 +    SciBytesIn++;                               /* increment the count */
3816 +
3817 +    return ch;                                  /* return the char */
3818 +}
3819 +\f
3820 +
3821 +/****************************************************************************
3822 +* Func:     SciCharAvailable
3823 +* Desc:     is there a receive character in the data register
3824 +* Inputs:   none
3825 +* Outputs:  false if no char available, else true
3826 +* Errors:   none
3827 +* Scope:    public
3828 +****************************************************************************/
3829 +
3830 +uint8_t   inline SciCharAvailable( void )
3831 +{
3832 +    return ( *SCSR & SCI_RCVR_READY );          /* char in data register? */
3833 +}
3834 +\f
3835 +
3836 +/****************************************************************************
3837 +* Func:     SciSendBreak
3838 +* Desc:     send 1 or tow breaks (all zero bits)
3839 +* Inputs:   none
3840 +* Outputs:  none
3841 +* Errors:   none
3842 +* Scope:    public
3843 +****************************************************************************/
3844 +
3845 +void SciSendBreak( void )
3846 +{
3847 +    /* From the Motorola QSM reference manual - */
3848 +
3849 +    /* "if SBK is toggled by writing it first to a one and then immediately */
3850 +    /* to a zero (in less than one serial frame interval), the transmitter */
3851 +    /* sends only one or two break frames before reverting to mark (idle) */
3852 +    /* or before commencing to send more data" */
3853 +
3854 +    *SCCR1 |=  SCI_SEND_BREAK;                  /* set the bit */
3855 +
3856 +    *SCCR1 &= ~SCI_SEND_BREAK;                  /* clear the bit */
3857 +
3858 +    return;
3859 +}
3860 +\f
3861 +
3862 +/*
3863 + *
3864 + *                             SECTION 6
3865 + *                             TEST CODE
3866 + */
3867 +
3868 +/****************************************************************************
3869 +* Func:     SciUnitTest
3870 +* Desc:     test the device driver
3871 +* Inputs:   nothing
3872 +* Outputs:  nothing
3873 +* Scope:    public
3874 +****************************************************************************/
3875 +
3876 +#if 0
3877 +#define O_RDWR LIBIO_FLAGS_READ_WRITE           /* dont like this but... */
3878 +
3879 +void SciUnitTest()
3880 +{
3881 +    uint8_t   byte;                             /* a character */
3882 +    uint16_t   fd;                              /* file descriptor for device */
3883 +    uint16_t   result;                          /* result of ioctl */
3884 +
3885 +    fd = open("/dev/sci",O_RDWR);               /* open the device */
3886 +
3887 +printk("SCI open fd=%d\r\n",fd);
3888 +
3889 +    result = write(fd, "abcd\r\n", 6);          /* send a string */
3890 +
3891 +printk("SCI write result=%d\r\n",result);
3892 +
3893 +    result = read(fd, &byte, 1);                /* read a byte */
3894 +
3895 +printk("SCI read result=%d,byte=%x\r\n",result,byte);
3896 +
3897 +    return;
3898 +}
3899 +#endif
3900 +\f
3901 +
3902 +/****************************************************************************
3903 +* Func:     SciPrintStats
3904 +* Desc:     print out some driver information
3905 +* Inputs:   nothing
3906 +* Outputs:  nothing
3907 +* Scope:    public
3908 +****************************************************************************/
3909 +
3910 +void SciPrintStats ( void )
3911 +{
3912 +    printk("\r\n");
3913 +
3914 +    printk( "SYS_CLOCK is %2.6f Mhz\r\n\n", SYS_CLOCK / 1000000.0 );
3915 +
3916 +    printk( "Current baud rate is %d bps or %d cps\r\n\n", SciBaud, SciBaud / 10 );
3917 +
3918 +    printk( "SCI Uart chars in       %8d\r\n", SciBytesIn       );
3919 +    printk( "SCI Uart chars out      %8d\r\n", SciBytesOut      );
3920 +    printk( "SCI Uart framing errors %8d\r\n", SciErrorsFraming );
3921 +    printk( "SCI Uart parity  errors %8d\r\n", SciErrorsParity  );
3922 +    printk( "SCI Uart overrun errors %8d\r\n", SciErrorsOverrun );
3923 +    printk( "SCI Uart noise   errors %8d\r\n", SciErrorsNoise   );
3924 +
3925 +    return;
3926 +}
3927 Index: rtems/c/src/lib/libbsp/m68k/mo376/startup/bspstart.c
3928 ===================================================================
3929 --- /dev/null   1970-01-01 00:00:00.000000000 +0000
3930 +++ rtems/c/src/lib/libbsp/m68k/mo376/startup/bspstart.c        2008-08-19 12:23:15.000000000 +0200
3931 @@ -0,0 +1,59 @@
3932 +/*
3933 + *  This routine starts the application.  It includes application,
3934 + *  board, and monitor specific initialization and configuration.
3935 + *  The generic CPU dependent initialization has been performed
3936 + *  before this routine is invoked.
3937 + *
3938 + *  COPYRIGHT (c) 1989-1999.
3939 + *  On-Line Applications Research Corporation (OAR).
3940 + *
3941 + *  The license and distribution terms for this file may be
3942 + *  found in the file LICENSE in this distribution or at
3943 + *  http://www.rtems.com/license/LICENSE.
3944 + *
3945 + *  $Id: bspstart.c,v 1.13 2008/08/19 10:23:15 ralf Exp $
3946 + */
3947 +
3948 +#include <bsp.h>
3949 +#include <rtems/libio.h>
3950 +
3951 +#include <string.h>
3952 +
3953 +/*
3954 + *  Use the shared implementations of the following routines
3955 + */
3956 +
3957 +void bsp_libc_init( void *, uint32_t, int );
3958 +void bsp_pretasking_hook(void);               /* m68k version */
3959 +
3960 +/*
3961 + *  Call Spurious_Initialize in bsp_predriver_hook because
3962 + *  bsp_predriver_hook is call after the _ISR_Vector_Table allocation
3963 + */
3964 +
3965 +void bsp_predriver_hook(void)
3966 +{
3967 +  extern void Spurious_Initialize(void);
3968 +  Spurious_Initialize();
3969 +}
3970 +
3971 +/*
3972 + *  bsp_start
3973 + *
3974 + *  This routine does the bulk of the system initialization.
3975 + */
3976 +
3977 +void bsp_start( void )
3978 +{
3979 +  void           *vbr;
3980 +  extern void    *_WorkspaceBase;
3981 +  extern void    *_RamSize;
3982 +  extern unsigned long _M68k_Ramsize;
3983 +
3984 +  /* RAM size set in linker script */
3985 +  _M68k_Ramsize = (unsigned long)&_RamSize;
3986 +
3987 +  m68k_get_vbr( vbr );
3988 +
3989 +  Configuration.work_space_start = (void *) &_WorkspaceBase;
3990 +}
3991 Index: rtems/c/src/lib/libbsp/m68k/mo376/startup/start_c.c
3992 ===================================================================
3993 --- /dev/null   1970-01-01 00:00:00.000000000 +0000
3994 +++ rtems/c/src/lib/libbsp/m68k/mo376/startup/start_c.c 2008-08-19 12:23:15.000000000 +0200
3995 @@ -0,0 +1,125 @@
3996 +/*
3997 + *  $Id
3998 + */
3999 +
4000 +#include <mrm332.h>
4001 +#include <rtems/m68k/sim.h>
4002 +#define __START_C__
4003 +#include "bsp.h"
4004 +
4005 +m68k_isr_entry M68Kvec[256];
4006 +m68k_isr_entry vectors[256];
4007 +char * const __argv[]= {"main", ""};
4008 +
4009 +void  boot_card(int argc, char * const argv[]);
4010 +
4011 +/*
4012 + *  This prototype really should have the noreturn attribute but
4013 + *  that causes a warning. Not sure how to fix that.
4014 + */
4015 +/* void dumby_start ()  __attribute__ ((noreturn)); */
4016 +void start_c(void);
4017 +
4018 +void start_c(void) {
4019 +
4020 +  /* Synthesizer Control Register */
4021 +  /*    see section(s) 4.8 */
4022 +  /* end include in ram_init.S */
4023 +  *SYNCR = (unsigned short int)
4024 +    ( SAM(MRM_W,15,VCO) | SAM(0x0,14,PRESCALE) | SAM(MRM_Y,8,COUNTER) );
4025 +  while (! (*SYNCR & SLOCK));  /* protect from clock overshoot */
4026 +  /* include in ram_init.S */
4027 +  *SYNCR = (unsigned short int)
4028 +    ( SAM(MRM_W,15,VCO) | SAM(MRM_X,14,PRESCALE) | SAM(MRM_Y,8,COUNTER) );
4029 +
4030 +  /* System Protection Control Register */
4031 +  /*    !!! can only write to once after reset !!! */
4032 +  /*    see section 3.8.4 of the SIM Reference Manual */
4033 +  *SYPCR = (unsigned char)( HME | BME );
4034 +
4035 +  /* Periodic Interrupr Control Register */
4036 +  /*    see section 3.8.2 of the SIM Reference Manual */
4037 +  *PICR = (unsigned short int)
4038 +    ( SAM(0,8,PIRQL) | SAM(MRM_PIV,0,PIV) );
4039 +  /*     ^^^ zero disables interrupt, don't enable here or ram_init will
4040 +        be wrong. It's enabled below. */
4041 +
4042 +  /* Periodic Interrupt Timer Register */
4043 +  /*    see section 3.8.3 of the SIM Reference Manual */
4044 +  *PITR = (unsigned short int)( SAM(0x09,0,PITM) );
4045 +  /*    1.098mS interrupt, assuming 32.768 KHz input clock */
4046 +
4047 +  /* Port C Data */
4048 +  /*    load values before enabled */
4049 +  *PORTC = (unsigned char) 0x0;
4050 +
4051 +  /* Port E and F Data Register */
4052 +  /*    see section 9 of the SIM Reference Manual */
4053 +  *PORTE0 = (unsigned char) 0;
4054 +  *PORTF0 = (unsigned char) 0;
4055 +
4056 +  /* Port E and F Data Direction Register */
4057 +  /*    see section 9 of the SIM Reference Manual */
4058 +  *DDRE = (unsigned char) 0xff;
4059 +  *DDRF = (unsigned char) 0xfd;
4060 +
4061 +  /* Port E and F Pin Assignment Register */
4062 +  /*    see section 9 of the SIM Reference Manual */
4063 +  *PEPAR = (unsigned char) 0;
4064 +  *PFPAR = (unsigned char) 0;
4065 +
4066 +  /* end of SIM initalization code */
4067 +  /* end include in ram_init.S */
4068 +
4069 +  /*
4070 +   * Initialize RAM by copying the .data section out of ROM (if
4071 +   * needed) and "zero-ing" the .bss section.
4072 +   */
4073 +  {
4074 +    register char *src = _etext;
4075 +    register char *dst = _copy_start;
4076 +
4077 +    if (_copy_data_from_rom)
4078 +      /* ROM has data at end of text; copy it. */
4079 +      while (dst < _edata)
4080 +       *dst++ = *src++;
4081 +
4082 +    /* Zero bss */
4083 +    for (dst = _clear_start; dst< end; dst++)
4084 +      {
4085 +       *dst = 0;
4086 +      }
4087 +  }
4088 +
4089 +  /*
4090 +   * Initialize vector table.
4091 +   */
4092 +  {
4093 +    m68k_isr_entry *monitors_vector_table;
4094 +
4095 +    m68k_get_vbr(monitors_vector_table);
4096 +
4097 +    M68Kvec[  4 ] = monitors_vector_table[  4 ];   /* breakpoints vector */
4098 +    M68Kvec[  9 ] = monitors_vector_table[  9 ];   /* trace vector */
4099 +    M68Kvec[ 31 ] = monitors_vector_table[ 31 ];   /* level 7 interrupt */
4100 +    M68Kvec[ 47 ] = monitors_vector_table[ 47 ];   /* system call vector */
4101 +    M68Kvec[ 66 ] = monitors_vector_table[ 66 ];   /* user defined */
4102 +
4103 +    m68k_set_vbr(&M68Kvec);
4104 +  }
4105 +
4106 +  /*
4107 +   * Initalize the board.
4108 +   */
4109 +
4110 +  /* Spurious should be called in the predriver hook */
4111 +  /* Spurious_Initialize(); */
4112 +  /*console_init(); */
4113 +
4114 +  /*
4115 +   * Execute main with arguments argc and agrv.
4116 +   */
4117 +  boot_card(1,__argv);
4118 +  reboot();
4119 +
4120 +}
4121 Index: rtems/c/src/lib/libbsp/m68k/mo376/include/tm27.h
4122 ===================================================================
4123 --- /dev/null   1970-01-01 00:00:00.000000000 +0000
4124 +++ rtems/c/src/lib/libbsp/m68k/mo376/include/tm27.h    2009-11-29 01:11:56.475557339 +0100
4125 @@ -0,0 +1,34 @@
4126 +/*
4127 + *  tm27.h
4128 + *
4129 + *  The license and distribution terms for this file may be
4130 + *  found in the file LICENSE in this distribution or at
4131 + *  http://www.rtems.com/license/LICENSE.
4132 + *
4133 + *  $Id: tm27.h,v 1.2 2004/04/23 04:47:36 ralf Exp $
4134 + */
4135 +
4136 +#ifndef _RTEMS_TMTEST27
4137 +#error "This is an RTEMS internal file you must not include directly."
4138 +#endif
4139 +
4140 +#ifndef __tm27_h
4141 +#define __tm27_h
4142 +
4143 +/*
4144 + *  Define the interrupt mechanism for Time Test 27
4145 + */
4146 +
4147 +/* XXX - JRS - I want to compile the tmtests */
4148 +
4149 +#define MUST_WAIT_FOR_INTERRUPT 1
4150 +
4151 +#define Install_tm27_vector( handler ) /* empty */
4152 +
4153 +#define Cause_tm27_intr() /* empty */
4154 +
4155 +#define Clear_tm27_intr() /* empty */
4156 +
4157 +#define Lower_tm27_intr() /* empty */
4158 +
4159 +#endif
4160 Index: rtems/c/src/lib/libbsp/m68k/mo376/times
4161 ===================================================================
4162 --- /dev/null   1970-01-01 00:00:00.000000000 +0000
4163 +++ rtems/c/src/lib/libbsp/m68k/mo376/times     2009-11-29 01:11:56.479557220 +0100
4164 @@ -0,0 +1,195 @@
4165 +#
4166 +#  Timing Test Suite Results for the MRM332 BSP
4167 +#
4168 +#  $Id: times,v 1.2 2004/01/07 21:13:50 joel Exp $
4169 +#
4170 +
4171 +NOTE:  This BSP is user submitted and no information is currently available. 
4172 +
4173 +TBD: MATT - update this with real times!
4174 +
4175 +Board:                MRM332 
4176 +CPU:                  68332
4177 +Clock Speed:          20 Mhz
4178 +Memory Configuration: SRAM, DRAM, cache, etc
4179 +Wait States:          
4180 +
4181 +Times Reported in:    cycles, microseconds, etc
4182 +Timer Source:         Count Down Timer, on-CPU cycle counter, etc
4183 +
4184 +Column A:             unused
4185 +Column B:             unused
4186 +
4187 +#                          DESCRIPTION                                 A    B
4188 +== =================================================================  ==== ====
4189 + 1 rtems_semaphore_create                                               20
4190 +   rtems_semaphore_delete                                               21
4191 +   rtems_semaphore_obtain: available                                    15
4192 +   rtems_semaphore_obtain: not available -- NO_WAIT                     15
4193 +   rtems_semaphore_release: no waiting tasks                            16
4194 +
4195 + 2 rtems_semaphore_obtain: not available -- caller blocks               62
4196 +
4197 + 3 rtems_semaphore_release: task readied -- preempts caller             55
4198 +
4199 + 4 rtems_task_restart: blocked task -- preempts caller                  77
4200 +   rtems_task_restart: ready task -- preempts caller                    70
4201 +   rtems_semaphore_release: task readied -- returns to caller           25
4202 +   rtems_task_create                                                    57
4203 +   rtems_task_start                                                     31
4204 +   rtems_task_restart: suspended task -- returns to caller              36
4205 +   rtems_task_delete: suspended task                                    47
4206 +   rtems_task_restart: ready task -- returns to caller                  37
4207 +   rtems_task_restart: blocked task -- returns to caller                46
4208 +   rtems_task_delete: blocked task                                      50
4209 +
4210 + 5 rtems_task_suspend: calling task                                     51
4211 +   rtems_task_resume: task readied -- preempts caller                   49
4212 +
4213 + 6 rtems_task_restart: calling task                                     59
4214 +   rtems_task_suspend: returns to caller                                18
4215 +   rtems_task_resume: task readied -- returns to caller                 19
4216 +   rtems_task_delete: ready task                                        50
4217 +
4218 + 7 rtems_task_restart: suspended task -- preempts caller                70
4219 +
4220 + 8 rtems_task_set_priority: obtain current priority                     12
4221 +   rtems_task_set_priority: returns to caller                           27
4222 +   rtems_task_mode: obtain current mode                                  5
4223 +   rtems_task_mode: no reschedule                                        5
4224 +   rtems_task_mode: reschedule -- returns to caller                      8
4225 +   rtems_task_mode: reschedule -- preempts caller                       39
4226 +   rtems_task_set_note                                                  13
4227 +   rtems_task_get_note                                                  13
4228 +   rtems_clock_set                                                      33
4229 +   rtems_clock_get                                                       3
4230 +
4231 + 9 rtems_message_queue_create                                          110
4232 +   rtems_message_queue_send: no waiting tasks                           37
4233 +   rtems_message_queue_urgent: no waiting tasks                         37
4234 +   rtems_message_queue_receive: available                               31
4235 +   rtems_message_queue_flush: no messages flushed                       12
4236 +   rtems_message_queue_flush: messages flushed                          16
4237 +   rtems_message_queue_delete                                           26
4238 +
4239 +10 rtems_message_queue_receive: not available -- NO_WAIT                15
4240 +   rtems_message_queue_receive: not available -- caller blocks          62
4241 +
4242 +11 rtems_message_queue_send: task readied -- preempts caller            72
4243 +
4244 +12 rtems_message_queue_send: task readied -- returns to caller          39
4245 +
4246 +13 rtems_message_queue_urgent: task readied -- preempts caller          72
4247 +
4248 +14 rtems_message_queue_urgent: task readied -- returns to caller        39
4249 +
4250 +15 rtems_event_receive: obtain current events                            1
4251 +   rtems_event_receive: not available -- NO_WAIT                        12
4252 +   rtems_event_receive: not available -- caller blocks                  56
4253 +   rtems_event_send: no task readied                                    12
4254 +   rtems_event_receive: available                                       12
4255 +   rtems_event_send: task readied -- returns to caller                  24
4256 +
4257 +16 rtems_event_send: task readied -- preempts caller                    55
4258 +
4259 +17 rtems_task_set_priority: preempts caller                             62
4260 +
4261 +18 rtems_task_delete: calling task                                      83
4262 +
4263 +19 rtems_signal_catch                                                    9
4264 +   rtems_signal_send: returns to caller                                 15
4265 +   rtems_signal_send: signal to self                                    18
4266 +   exit ASR overhead: returns to calling task                           22
4267 +   exit ASR overhead: returns to preempting task                        49
4268 +
4269 +20 rtems_partition_create                                               35
4270 +   rtems_region_create                                                  23
4271 +   rtems_partition_get_buffer: available                                15
4272 +   rtems_partition_get_buffer: not available                            13
4273 +   rtems_partition_return_buffer                                        18
4274 +   rtems_partition_delete                                               16
4275 +   rtems_region_get_segment: available                                  22
4276 +   rtems_region_get_segment: not available -- NO_WAIT                   21
4277 +   rtems_region_return_segment: no waiting tasks                        19
4278 +   rtems_region_get_segment: not available -- caller blocks             64
4279 +   rtems_region_return_segment: task readied -- preempts caller         74
4280 +   rtems_region_return_segment: task readied -- returns to caller       44
4281 +   rtems_region_delete                                                  16
4282 +   rtems_io_initialize                                                   2
4283 +   rtems_io_open                                                         1
4284 +   rtems_io_close                                                        1
4285 +   rtems_io_read                                                         1
4286 +   rtems_io_write                                                        1
4287 +   rtems_io_control                                                      1
4288 +
4289 +21 rtems_task_ident                                                    149
4290 +   rtems_message_queue_ident                                           145
4291 +   rtems_semaphore_ident                                               156
4292 +   rtems_partition_ident                                               145
4293 +   rtems_region_ident                                                  148
4294 +   rtems_port_ident                                                    145
4295 +   rtems_timer_ident                                                   145
4296 +   rtems_rate_monotonic_ident                                          145
4297 +
4298 +22 rtems_message_queue_broadcast: task readied -- returns to caller     42
4299 +   rtems_message_queue_broadcast: no waiting tasks                      17
4300 +   rtems_message_queue_broadcast: task readied -- preempts caller       78
4301 +
4302 +23 rtems_timer_create                                                   14
4303 +   rtems_timer_fire_after: inactive                                     22
4304 +   rtems_timer_fire_after: active                                       24
4305 +   rtems_timer_cancel: active                                           15
4306 +   rtems_timer_cancel: inactive                                         13
4307 +   rtems_timer_reset: inactive                                          21
4308 +   rtems_timer_reset: active                                            23
4309 +   rtems_timer_fire_when: inactive                                      34
4310 +   rtems_timer_fire_when: active                                        34
4311 +   rtems_timer_delete: active                                           19
4312 +   rtems_timer_delete: inactive                                         17
4313 +   rtems_task_wake_when                                                 69
4314 +
4315 +24 rtems_task_wake_after: yield -- returns to caller                     9
4316 +   rtems_task_wake_after: yields -- preempts caller                     45
4317 +
4318 +25 rtems_clock_tick                                                      4
4319 +
4320 +26 _ISR_Disable                                                          0
4321 +   _ISR_Flash                                                            1
4322 +   _ISR_Enable                                                           1
4323 +   _Thread_Disable_dispatch                                              0
4324 +   _Thread_Enable_dispatch                                               7
4325 +   _Thread_Set_state                                                    11
4326 +   _Thread_Disptach (NO FP)                                             31
4327 +   context switch: no floating point contexts                           21
4328 +   context switch: self                                                 10
4329 +   context switch: to another task                                      10
4330 +   context switch: restore 1st FP task                                  25
4331 +   fp context switch: save idle, restore idle                           31
4332 +   fp context switch: save idle, restore initialized                    19
4333 +   fp context switch: save initialized, restore initialized             20
4334 +   _Thread_Resume                                                        7
4335 +   _Thread_Unblock                                                       7
4336 +   _Thread_Ready                                                         9
4337 +   _Thread_Get                                                           4
4338 +   _Semaphore_Get                                                        2
4339 +   _Thread_Get: invalid id                                               0
4340 +
4341 +27 interrupt entry overhead: returns to interrupted task                 6
4342 +   interrupt exit overhead: returns to interrupted task                  6
4343 +   interrupt entry overhead: returns to nested interrupt                 6
4344 +   interrupt exit overhead: returns to nested interrupt                  5
4345 +   interrupt entry overhead: returns to preempting task                  7
4346 +   interrupt exit overhead: returns to preempting task                  36
4347 +
4348 +28 rtems_port_create                                                    16
4349 +   rtems_port_external_to_internal                                      11
4350 +   rtems_port_internal_to_external                                      11
4351 +   rtems_port_delete                                                    16
4352 +
4353 +29 rtems_rate_monotonic_create                                          15
4354 +   rtems_rate_monotonic_period: initiate period -- returns to caller    21
4355 +   rtems_rate_monotonic_period: obtain status                           13
4356 +   rtems_rate_monotonic_cancel                                          16
4357 +   rtems_rate_monotonic_delete: inactive                                18
4358 +   rtems_rate_monotonic_delete: active                                  20
4359 +   rtems_rate_monotonic_period: conclude periods -- caller blocks       53
4360 Index: rtems/c/src/lib/libbsp/m68k/mo376/include/mrm332.h
4361 ===================================================================
4362 --- /dev/null   1970-01-01 00:00:00.000000000 +0000
4363 +++ rtems/c/src/lib/libbsp/m68k/mo376/include/mrm332.h  2009-11-29 01:11:56.479557220 +0100
4364 @@ -0,0 +1,70 @@
4365 +/*  mrm332.h
4366 + *
4367 + *  $Id: mrm332.h,v 1.5 2004/04/21 16:01:35 ralf Exp $
4368 + */
4369 +
4370 +#ifndef _MRM332_H_
4371 +#define _MRM332_H_
4372 +
4373 +/* SIM_MM (SIM Module Mapping) determines the location of the control
4374 +   register block. When MM=0, register addresses range fom 0x7ff000 to
4375 +   0x7FFFFF. When MM=1, register addresses range from 0xfff000 to
4376 +   0xffffff. */
4377 +#define SIM_MM 1
4378 +
4379 +/* Interrupt related definitions */
4380 +#define SIM_IARB 15
4381 +#define QSM_IARB 10
4382 +
4383 +#define MRM_PIV 64
4384 +#define ISRL_PIT 4             /* zero disables PIT */
4385 +
4386 +#define EFI_QIVR 66            /* 66=>SCI and 67=>QSPI interrupt */
4387 +#define ISRL_QSPI 0
4388 +
4389 +#define EFI_SPINT 24           /* spurious interrupt */
4390 +#define EFI_INT1 25            /* CTS interrupt */
4391 +#define ISRL_SCI 6
4392 +
4393 +/* System Clock definitions */
4394 +#define XTAL 32768.0           /* crystal frequency in Hz */
4395 +
4396 +#if 0
4397 +/* Default MRM clock rate (8.388688 MHz) set by CPU32: */
4398 +#define MRM_W 0                        /* system clock parameters */
4399 +#define MRM_X 0
4400 +#define MRM_Y 0x3f
4401 +#endif
4402 +
4403 +#if 1
4404 +/* 16.77722 MHz: */
4405 +#define MRM_W 1                        /* system clock parameters */
4406 +#define MRM_X 1
4407 +#define MRM_Y 0x0f
4408 +#endif
4409 +
4410 +#if 0
4411 +/* 25.16582 MHz: */
4412 +#define MRM_W 1                        /* system clock parameters */
4413 +#define MRM_X 1
4414 +#define MRM_Y 0x17
4415 +#endif
4416 +
4417 +#define SYS_CLOCK (XTAL*4.0*(MRM_Y+1)*(1 << (2*MRM_W+MRM_X)))
4418 +#define SCI_BAUD 19200         /* RS232 Baud Rate */
4419 +
4420 +/* macros/functions */
4421 +
4422 +#ifndef ASM
4423 +
4424 +/*
4425 + *  This prototype really should have the noreturn attribute but
4426 + *  that causes a warning. Not sure how to fix that.
4427 + */
4428 +/*   static void reboot(void) __attribute__ ((noreturn)); */
4429 +static void reboot(void);
4430 +__inline__ static void reboot() {asm("trap #15; .word 0x0063");}
4431 +
4432 +#endif /* ASM */
4433 +
4434 +#endif /* _MRM_H_ */
4435 Index: rtems/c/src/lib/libbsp/m68k/mo376/include/bspopts.h.in
4436 ===================================================================
4437 --- /dev/null   1970-01-01 00:00:00.000000000 +0000
4438 +++ rtems/c/src/lib/libbsp/m68k/mo376/include/bspopts.h.in      2009-11-29 01:11:56.479557220 +0100
4439 @@ -0,0 +1,16 @@
4440 +/* include/bspopts.h.in.  Generated from configure.ac by autoheader.  */
4441 +
4442 +/* Define to the address where bug reports for this package should be sent. */
4443 +#undef PACKAGE_BUGREPORT
4444 +
4445 +/* Define to the full name of this package. */
4446 +#undef PACKAGE_NAME
4447 +
4448 +/* Define to the full name and version of this package. */
4449 +#undef PACKAGE_STRING
4450 +
4451 +/* Define to the one symbol short name of this package. */
4452 +#undef PACKAGE_TARNAME
4453 +
4454 +/* Define to the version of this package. */
4455 +#undef PACKAGE_VERSION
4456 Index: rtems/c/src/lib/libbsp/m68k/mo376/spurious/spinit.c
4457 ===================================================================
4458 --- /dev/null   1970-01-01 00:00:00.000000000 +0000
4459 +++ rtems/c/src/lib/libbsp/m68k/mo376/spurious/spinit.c 2009-11-29 01:11:56.479557220 +0100
4460 @@ -0,0 +1,105 @@
4461 +/*  Spurious_driver
4462 + *
4463 + *  This routine installs spurious interrupt handlers for the mrm.
4464 + *
4465 + *  Input parameters:  NONE
4466 + *
4467 + *  Output parameters:  NONE
4468 + *
4469 + *  COPYRIGHT (c) 1989, 1990, 1991, 1992, 1993.
4470 + *  On-Line Applications Research Corporation (OAR).
4471 + *
4472 + *  The license and distribution terms for this file may be
4473 + *  found in the file LICENSE in this distribution or at
4474 + *  http://www.rtems.com/license/LICENSE.
4475 + *
4476 + *  $Id: spinit.c,v 1.6 2006/09/11 21:43:55 joel Exp $
4477 + */
4478 +
4479 +#include <bsp.h>
4480 +#include <stdio.h>
4481 +
4482 +const char * const _Spurious_Error_[] = {"Reset","Bus Error","Address Error",
4483 +   "Illegal Instruction","Zero Division","CHK, CHK2 Instruction",
4484 +   "TRAPcc, TRAPV Instruction","Privilege Violation","Trace",
4485 +   "Line 1010 Emulation","Line 1111 Emulation","Hardware Breakpoint",
4486 +   "Coprocessor Protocal Violation",
4487 +   "Format Error ans Uninitialized Interrupt","Unassigned",
4488 +   "Spurious Interrupt","AVec1","AVec2","AVec3","AVec4","AVec5","AVec6",
4489 +   "AVec7","Trap Instruction","Debug","Reboot","Reserved Coprocessor",
4490 +   "Reserved Unassigned","User Defined"};
4491 +
4492 +rtems_isr Spurious_Isr(
4493 +  rtems_vector_number vector
4494 +)
4495 +{
4496 +  /*int sp = 0; */
4497 +#if 0
4498 +  const char * const VectDescrip[] = {
4499 +    _Spurious_Error_[0],   _Spurious_Error_[0],  _Spurious_Error_[1],
4500 +    _Spurious_Error_[2],   _Spurious_Error_[3],  _Spurious_Error_[4],
4501 +    _Spurious_Error_[5],   _Spurious_Error_[6],  _Spurious_Error_[7],
4502 +    _Spurious_Error_[8],   _Spurious_Error_[9], _Spurious_Error_[10],
4503 +    _Spurious_Error_[11], _Spurious_Error_[12], _Spurious_Error_[13],
4504 +    _Spurious_Error_[13], _Spurious_Error_[14], _Spurious_Error_[14],
4505 +    _Spurious_Error_[14], _Spurious_Error_[14], _Spurious_Error_[14],
4506 +    _Spurious_Error_[14], _Spurious_Error_[14], _Spurious_Error_[14],
4507 +    _Spurious_Error_[15], _Spurious_Error_[16], _Spurious_Error_[17],
4508 +    _Spurious_Error_[18], _Spurious_Error_[19], _Spurious_Error_[20],
4509 +    _Spurious_Error_[21], _Spurious_Error_[22], _Spurious_Error_[23],
4510 +    _Spurious_Error_[24], _Spurious_Error_[23], _Spurious_Error_[23],
4511 +    _Spurious_Error_[23], _Spurious_Error_[23], _Spurious_Error_[23],
4512 +    _Spurious_Error_[23], _Spurious_Error_[23], _Spurious_Error_[23],
4513 +    _Spurious_Error_[23], _Spurious_Error_[23], _Spurious_Error_[23],
4514 +    _Spurious_Error_[23], _Spurious_Error_[23], _Spurious_Error_[25],
4515 +    _Spurious_Error_[26], _Spurious_Error_[26], _Spurious_Error_[26],
4516 +    _Spurious_Error_[26], _Spurious_Error_[26], _Spurious_Error_[26],
4517 +    _Spurious_Error_[26], _Spurious_Error_[26], _Spurious_Error_[26],
4518 +    _Spurious_Error_[26], _Spurious_Error_[26], _Spurious_Error_[27],
4519 +    _Spurious_Error_[27], _Spurious_Error_[27], _Spurious_Error_[27],
4520 +    _Spurious_Error_[27], _Spurious_Error_[28]};
4521 +#endif
4522 +
4523 +  /*asm volatile ( "movea.l   %%sp,%0 " : "=a" (sp) : "0" (sp) ); */
4524 +
4525 +  _CPU_ISR_Set_level( 7 );
4526 +  /*_UART_flush(); */
4527 +#if 0
4528 +  RAW_PUTS("\n\rRTEMS: Spurious interrupt: ");
4529 +  RAW_PUTS((char *)VectDescrip[( (vector>64) ? 64 : vector )]);
4530 +  RAW_PUTS("\n\rRTEMS:    Vector: ");
4531 +  RAW_PUTI(vector);
4532 +  RAW_PUTS(" sp: ");
4533 +  RAW_PUTI(sp);
4534 +  RAW_PUTS("\n\r");
4535 +#endif
4536 +  bsp_cleanup();
4537 +
4538 +  /* BDM SIGEMT */
4539 +  asm("  .word  0x4afa");
4540 +
4541 +  for(;;);
4542 +}
4543 +
4544 +void Spurious_Initialize(void)
4545 +{
4546 +  rtems_vector_number vector;
4547 +
4548 +  for ( vector = 0x0 ; vector <= 0xFF ; vector++ )
4549 +    {
4550 +      switch (vector)
4551 +       {
4552 +       case 4:
4553 +       case 9:
4554 +       case 31:
4555 +       case 47:
4556 +       case 66:
4557 +         /* These vectors used by CPU32bug - don't overwrite them. */
4558 +         break;
4559 +
4560 +       default:
4561 +         (void) set_vector( Spurious_Isr, vector, 1 );
4562 +         break;
4563 +       }
4564 +    }
4565 +}
4566 Index: rtems/c/src/lib/libbsp/m68k/mo376/startup/linkcmds
4567 ===================================================================
4568 --- /dev/null   1970-01-01 00:00:00.000000000 +0000
4569 +++ rtems/c/src/lib/libbsp/m68k/mo376/startup/linkcmds  2008-03-04 00:06:30.000000000 +0100
4570 @@ -0,0 +1,164 @@
4571 +/*  linkcmds
4572 + *
4573 + *  $Id: linkcmds,v 1.8 2008/03/03 23:06:30 joel Exp $
4574 + */
4575 +
4576 +OUTPUT_ARCH(m68k)
4577 +__DYNAMIC  =  0;
4578 +
4579 +/*
4580 + * The memory map looks like this:
4581 + * +--------------------+ <- low memory
4582 + * | .text              |
4583 + * |        etext       |
4584 + * |        ctor list   | the ctor and dtor lists are for
4585 + * |        dtor list   | C++ support
4586 + * |        _endtext    |
4587 + * +--------------------+
4588 + * | .data              | initialized data goes here
4589 + * |        _sdata      |
4590 + * |        _edata      |
4591 + * +--------------------+
4592 + * | .bss               |
4593 + * |        _clear_start| start of bss, cleared by crt0
4594 + * |        _end        | start of heap, used by sbrk()
4595 + * +--------------------+
4596 + * |    heap space      |
4597 + * |        _ENDHEAP    |
4598 + * |    stack space     | 
4599 + * |        __stack     | top of stack
4600 + * +--------------------+ <- high memory
4601 + */
4602 +
4603 +/*
4604 + * Declare some sizes.
4605 + */
4606 +_RamBase = DEFINED(_RamBase) ? _RamBase : 0x10000;
4607 +_RamSize = DEFINED(_RamSize) ? _RamSize : 0x70000;
4608 +_RamEnd = _RamBase + _RamSize;
4609 +_HeapSize = DEFINED(_HeapSize) ? _HeapSize : 0x10000;
4610 +_StackSize = DEFINED(_StackSize) ? _StackSize : 0x2000;
4611 +
4612 +MEMORY
4613 +{
4614 +  ram     : ORIGIN = 0x10000, LENGTH = 0x70000
4615 +}
4616 +
4617 +_copy_data_from_rom = 0;
4618 +
4619 +/*
4620 + * stick everything in ram (of course)
4621 + */
4622 +SECTIONS
4623 +{
4624 +       ram : {
4625 +               . = .;
4626 +       } >ram
4627 +
4628 +        /*
4629 +         * Text, data and bss segments
4630 +         */
4631 +        .text : {
4632 +                *(.text*)
4633 +
4634 +               /*
4635 +                * C++ constructors/destructors
4636 +                */
4637 +               *(.gnu.linkonce.t.*)
4638 +
4639 +               /*
4640 +                * Initialization and finalization code.
4641 +                *
4642 +                * Various files can provide initialization and finalization
4643 +                * functions.  crtbegin.o and crtend.o are two instances. The
4644 +                * body of these functions are in .init and .fini sections. We
4645 +                * accumulate the bodies here, and prepend function prologues
4646 +                * from crti.o and function epilogues from crtn.o. crti.o must
4647 +                * be linked first; crtn.o must be linked last.  Because these
4648 +                * are wildcards, it doesn't matter if the user does not
4649 +                * actually link against crti.o and crtn.o; the linker won't
4650 +                * look for a file to match a wildcard.  The wildcard also
4651 +                * means that it doesn't matter which directory crti.o and
4652 +                * crtn.o are in. 
4653 +                */
4654 +               PROVIDE (_init = .);
4655 +               *crti.o(.init)
4656 +               *(.init)
4657 +               *crtn.o(.init)
4658 +               PROVIDE (_fini = .);
4659 +               *crti.o(.fini)
4660 +               *(.fini)
4661 +               *crtn.o(.fini)
4662 +
4663 +               /*
4664 +                * Special FreeBSD sysctl sections.
4665 +                */
4666 +               . = ALIGN (16);
4667 +               __start_set_sysctl_set = .;
4668 +               *(set_sysctl_*);
4669 +               __stop_set_sysctl_set = ABSOLUTE(.);
4670 +               *(set_domain_*);
4671 +               *(set_pseudo_*);
4672 +
4673 +               /*
4674 +                * C++ constructors/destructors
4675 +                *
4676 +                * gcc uses crtbegin.o to find the start of the constructors
4677 +                * and destructors so we make sure it is first.  Because this
4678 +                * is a wildcard, it doesn't matter if the user does not
4679 +                * actually link against crtbegin.o; the linker won't look for
4680 +                * a file to match a wildcard.  The wildcard also means that
4681 +                * it doesn't matter which directory crtbegin.o is in. The
4682 +                * constructor and destructor list are terminated in
4683 +                * crtend.o.  The same comments apply to it.
4684 +                */
4685 +               . = ALIGN (16);
4686 +               *crtbegin.o(.ctors)
4687 +               *(.ctors)
4688 +               *crtend.o(.ctors)
4689 +               *crtbegin.o(.dtors)
4690 +               *(.dtors)
4691 +               *crtend.o(.dtors)
4692 +
4693 +               /*
4694 +                * Exception frame info
4695 +                */
4696 +               . = ALIGN (16);
4697 +               *(.eh_frame)
4698 +
4699 +               /*
4700 +                * Read-only data
4701 +                */
4702 +               . = ALIGN (16);
4703 +               _rodata_start = .;
4704 +               *(.rodata*)
4705 +               *(.gnu.linkonce.r*)
4706 +
4707 +                 . = ALIGN (16);
4708 +                PROVIDE (_etext = .);
4709 +        } >ram
4710 +        .data : {
4711 +                PROVIDE (_copy_start = .);
4712 +                *(.data*)
4713 +               *(.gnu.linkonce.d*)
4714 +               *(.gcc_except_table*)
4715 +               *(.jcr)
4716 +                . = ALIGN (16);
4717 +                PROVIDE (_edata = .);
4718 +                PROVIDE (_copy_end = .);
4719 +        } >ram
4720 +        .bss : {
4721 +                _clear_start = .;
4722 +                *(.dynbss)
4723 +                *(.bss* .gnu.linkonce.b.*)
4724 +                *(COMMON)
4725 +                . = ALIGN (16);
4726 +                PROVIDE (end = .);
4727 +                . += _StackSize;
4728 +                . = ALIGN (16);
4729 +                _stack_init = .;
4730 +                _clear_end = .;
4731 +
4732 +                _WorkspaceBase = .;
4733 +        } >ram
4734 +}
4735 Index: rtems/c/src/lib/libbsp/m68k/mo376/bsp_specs
4736 ===================================================================
4737 --- /dev/null   1970-01-01 00:00:00.000000000 +0000
4738 +++ rtems/c/src/lib/libbsp/m68k/mo376/bsp_specs 2008-12-08 06:15:06.000000000 +0100
4739 @@ -0,0 +1,13 @@
4740 +%rename endfile old_endfile
4741 +%rename startfile old_startfile
4742 +%rename link old_link
4743 +
4744 +*startfile:
4745 +%{!qrtems: %(old_startfile)} \
4746 +%{!nostdlib: %{qrtems: start.o%s crti.o%s crtbegin.o%s -e start}}
4747 +
4748 +*link:
4749 +%{!qrtems: %(old_link)} %{qrtems: -dc -dp -N}
4750 +
4751 +*endfile:
4752 +%{!qrtems: %(old_endfile)} %{qrtems: crtend.o%s crtn.o%s}
4753 Index: rtems/c/src/lib/libbsp/m68k/mo376/preinstall.am
4754 ===================================================================
4755 --- /dev/null   1970-01-01 00:00:00.000000000 +0000
4756 +++ rtems/c/src/lib/libbsp/m68k/mo376/preinstall.am     2009-11-29 01:11:56.483556820 +0100
4757 @@ -0,0 +1,66 @@
4758 +## Automatically generated by ampolish3 - Do not edit
4759 +
4760 +if AMPOLISH3
4761 +$(srcdir)/preinstall.am: Makefile.am
4762 +       $(AMPOLISH3) $(srcdir)/Makefile.am > $(srcdir)/preinstall.am
4763 +endif
4764 +
4765 +PREINSTALL_DIRS =
4766 +DISTCLEANFILES += $(PREINSTALL_DIRS)
4767 +
4768 +all-local: $(TMPINSTALL_FILES)
4769 +
4770 +TMPINSTALL_FILES =
4771 +CLEANFILES = $(TMPINSTALL_FILES)
4772 +
4773 +all-am: $(PREINSTALL_FILES)
4774 +
4775 +PREINSTALL_FILES =
4776 +CLEANFILES += $(PREINSTALL_FILES)
4777 +
4778 +$(PROJECT_LIB)/$(dirstamp):
4779 +       @$(MKDIR_P) $(PROJECT_LIB)
4780 +       @: > $(PROJECT_LIB)/$(dirstamp)
4781 +PREINSTALL_DIRS += $(PROJECT_LIB)/$(dirstamp)
4782 +
4783 +$(PROJECT_INCLUDE)/$(dirstamp):
4784 +       @$(MKDIR_P) $(PROJECT_INCLUDE)
4785 +       @: > $(PROJECT_INCLUDE)/$(dirstamp)
4786 +PREINSTALL_DIRS += $(PROJECT_INCLUDE)/$(dirstamp)
4787 +
4788 +$(PROJECT_LIB)/bsp_specs: bsp_specs $(PROJECT_LIB)/$(dirstamp)
4789 +       $(INSTALL_DATA) $< $(PROJECT_LIB)/bsp_specs
4790 +PREINSTALL_FILES += $(PROJECT_LIB)/bsp_specs
4791 +
4792 +$(PROJECT_INCLUDE)/bsp.h: include/bsp.h $(PROJECT_INCLUDE)/$(dirstamp)
4793 +       $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/bsp.h
4794 +PREINSTALL_FILES += $(PROJECT_INCLUDE)/bsp.h
4795 +
4796 +$(PROJECT_INCLUDE)/tm27.h: include/tm27.h $(PROJECT_INCLUDE)/$(dirstamp)
4797 +       $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/tm27.h
4798 +PREINSTALL_FILES += $(PROJECT_INCLUDE)/tm27.h
4799 +
4800 +$(PROJECT_INCLUDE)/bspopts.h: include/bspopts.h $(PROJECT_INCLUDE)/$(dirstamp)
4801 +       $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/bspopts.h
4802 +PREINSTALL_FILES += $(PROJECT_INCLUDE)/bspopts.h
4803 +
4804 +$(PROJECT_INCLUDE)/mrm332.h: include/mrm332.h $(PROJECT_INCLUDE)/$(dirstamp)
4805 +       $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/mrm332.h
4806 +PREINSTALL_FILES += $(PROJECT_INCLUDE)/mrm332.h
4807 +
4808 +$(PROJECT_INCLUDE)/coverhd.h: ../../shared/include/coverhd.h $(PROJECT_INCLUDE)/$(dirstamp)
4809 +       $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/coverhd.h
4810 +PREINSTALL_FILES += $(PROJECT_INCLUDE)/coverhd.h
4811 +
4812 +$(PROJECT_LIB)/start.$(OBJEXT): start.$(OBJEXT) $(PROJECT_LIB)/$(dirstamp)
4813 +       $(INSTALL_DATA) $< $(PROJECT_LIB)/start.$(OBJEXT)
4814 +TMPINSTALL_FILES += $(PROJECT_LIB)/start.$(OBJEXT)
4815 +
4816 +$(PROJECT_LIB)/linkcmds: startup/linkcmds $(PROJECT_LIB)/$(dirstamp)
4817 +       $(INSTALL_DATA) $< $(PROJECT_LIB)/linkcmds
4818 +PREINSTALL_FILES += $(PROJECT_LIB)/linkcmds
4819 +
4820 +$(PROJECT_LIB)/linkcmds_ROM: startup/linkcmds_ROM $(PROJECT_LIB)/$(dirstamp)
4821 +       $(INSTALL_DATA) $< $(PROJECT_LIB)/linkcmds_ROM
4822 +PREINSTALL_FILES += $(PROJECT_LIB)/linkcmds_ROM
4823 +