1 Index: rtems/c/src/lib/libbsp/arm/csb336/times
2 ===================================================================
3 --- rtems/c/src/lib/libbsp/arm/csb336/times (revision 42)
4 +++ rtems/c/src/lib/libbsp/arm/csb336/times (working copy)
8 == ==================================================================== ===
9 - 1 rtems_semaphore_create 16
10 - 1 rtems_semaphore_delete 17
11 - 1 rtems_semaphore_obtain: available 2
12 - 1 rtems_semaphore_obtain: not available -- NO_WAIT 2
13 - 1 rtems_semaphore_release: no waiting tasks 5
14 + 1 rtems_semaphore_create 15
15 + 1 rtems_semaphore_delete 15
16 + 1 rtems_semaphore_obtain: available 0
17 + 1 rtems_semaphore_obtain: not available -- NO_WAIT 0
18 + 1 rtems_semaphore_release: no waiting tasks 0
20 - 2 rtems_semaphore_obtain: not available -- caller blocks 20
21 + 2 rtems_semaphore_obtain: not available -- caller blocks 12
23 - 3 rtems_semaphore_release: task readied -- preempts caller 16
24 + 3 rtems_semaphore_release: task readied -- preempts caller 11
26 - 4 rtems_task_restart: blocked task -- preempts caller 48
27 - 4 rtems_task_restart: ready task -- preempts caller 36
28 - 4 rtems_semaphore_release: task readied -- returns to caller 9
29 - 4 rtems_task_create 33
30 - 4 rtems_task_start 12
31 - 4 rtems_task_restart: suspended task -- returns to caller 14
32 - 4 rtems_task_delete: suspended task 31
33 - 4 rtems_task_restart: ready task -- returns to caller 14
34 - 4 rtems_task_restart: blocked task -- returns to caller 19
35 - 4 rtems_task_delete: blocked task 32
36 + 4 rtems_task_restart: blocked task -- preempts caller 38
37 + 4 rtems_task_restart: ready task -- preempts caller 29
38 + 4 rtems_semaphore_release: task readied -- returns to caller 5
39 + 4 rtems_task_create 24
40 + 4 rtems_task_start 8
41 + 4 rtems_task_restart: suspended task -- returns to caller 9
42 + 4 rtems_task_delete: suspended task 20
43 + 4 rtems_task_restart: ready task -- returns to caller 10
44 + 4 rtems_task_restart: blocked task -- returns to caller 11
45 + 4 rtems_task_delete: blocked task 21
47 - 5 rtems_task_suspend: calling task 14
48 - 5 rtems_task_resume: task readied -- preempts caller 12
49 + 5 rtems_task_suspend: calling task 9
50 + 5 rtems_task_resume: task readied -- preempts caller 8
52 - 6 rtems_task_restart: calling task 14
53 - 6 rtems_task_suspend: returns to caller 6
54 - 6 rtems_task_resume: task readied -- returns to caller 6
55 - 6 rtems_task_delete: ready task 32
56 + 6 rtems_task_restart: calling task 8
57 + 6 rtems_task_suspend: returns to caller 3
58 + 6 rtems_task_resume: task readied -- returns to caller 3
59 + 6 rtems_task_delete: ready task 22
61 - 7 rtems_task_restart: suspended task -- preempts caller 24
62 + 7 rtems_task_restart: suspended task -- preempts caller 14
64 - 8 rtems_task_set_priority: obtain current priority 4
65 - 8 rtems_task_set_priority: returns to caller 8
66 - 8 rtems_task_mode: obtain current mode 2
67 - 8 rtems_task_mode: no reschedule 2
68 - 8 rtems_task_mode: reschedule -- returns to caller 4
69 - 8 rtems_task_mode: reschedule -- preempts caller 19
70 - 8 rtems_task_set_note 4
71 - 8 rtems_task_get_note 4
73 + 8 rtems_task_set_priority: obtain current priority 1
74 + 8 rtems_task_set_priority: returns to caller 3
75 + 8 rtems_task_mode: obtain current mode 0
76 + 8 rtems_task_mode: no reschedule 0
77 + 8 rtems_task_mode: reschedule -- returns to caller 3
78 + 8 rtems_task_mode: reschedule -- preempts caller 13
79 + 8 rtems_task_set_note 1
80 + 8 rtems_task_get_note 1
84 - 9 rtems_message_queue_create 54
85 - 9 rtems_message_queue_send: no waiting tasks 8
86 - 9 rtems_message_queue_urgent: no waiting tasks 8
87 - 9 rtems_message_queue_receive: available 7
88 - 9 rtems_message_queue_flush: no messages flushed 4
89 - 9 rtems_message_queue_flush: messages flushed 5
90 - 9 rtems_message_queue_delete 21
91 + 9 rtems_message_queue_create 38
92 + 9 rtems_message_queue_send: no waiting tasks 4
93 + 9 rtems_message_queue_urgent: no waiting tasks 4
94 + 9 rtems_message_queue_receive: available 4
95 + 9 rtems_message_queue_flush: no messages flushed 2
96 + 9 rtems_message_queue_flush: messages flushed 3
97 + 9 rtems_message_queue_delete 19
99 -10 rtems_message_queue_receive: not available -- NO_WAIT 4
100 -10 rtems_message_queue_receive: not available -- caller blocks 20
101 +10 rtems_message_queue_receive: not available -- NO_WAIT 2
102 +10 rtems_message_queue_receive: not available -- caller blocks 12
104 -11 rtems_message_queue_send: task readied -- preempts caller 18
105 +11 rtems_message_queue_send: task readied -- preempts caller 13
107 -12 rtems_message_queue_send: task readied -- returns to caller 11
108 +12 rtems_message_queue_send: task readied -- returns to caller 7
110 -13 rtems_message_queue_urgent: task readied -- preempts caller 19
111 +13 rtems_message_queue_urgent: task readied -- preempts caller 13
113 -14 rtems_message_queue_urgent: task readied -- returns to caller 11
114 +14 rtems_message_queue_urgent: task readied -- returns to caller 7
116 15 rtems_event_receive: obtain current events 0
117 -15 rtems_event_receive: not available -- NO_WAIT 3
118 -15 rtems_event_receive: not available -- caller blocks 17
119 -15 rtems_event_send: no task readied 3
120 -15 rtems_event_receive: available 5
121 -15 rtems_event_send: task readied -- returns to caller 10
122 +15 rtems_event_receive: not available -- NO_WAIT 1
123 +15 rtems_event_receive: not available -- caller blocks 11
124 +15 rtems_event_send: no task readied 1
125 +15 rtems_event_receive: available 3
126 +15 rtems_event_send: task readied -- returns to caller 7
128 -16 rtems_event_send: task readied -- preempts caller 16
129 +16 rtems_event_send: task readied -- preempts caller 12
131 -17 rtems_task_set_priority: preempts caller 19
132 +17 rtems_task_set_priority: preempts caller 13
134 -18 rtems_task_delete: calling task 41
135 +18 rtems_task_delete: calling task 26
137 -19 rtems_signal_catch 6
138 -19 rtems_signal_send: returns to caller 15
139 -19 rtems_signal_send: signal to self 25
140 -19 exit ASR overhead: returns to calling task 11
141 -19 exit ASR overhead: returns to preempting task 12
142 +19 rtems_signal_catch 5
143 +19 rtems_signal_send: returns to caller 12
144 +19 rtems_signal_send: signal to self 19
145 +19 exit ASR overhead: returns to calling task 7
146 +19 exit ASR overhead: returns to preempting task 10
148 -20 rtems_partition_create 22
149 -20 rtems_region_create 30
150 -20 rtems_partition_get_buffer: available 10
151 -20 rtems_partition_get_buffer: not available 4
152 -20 rtems_partition_return_buffer 9
153 -20 rtems_partition_delete 10
154 -20 rtems_region_get_segment: available 15
155 -20 rtems_region_get_segment: not available -- NO_WAIT 16
156 -20 rtems_region_return_segment: no waiting tasks 13
157 -20 rtems_region_get_segment: not available -- caller blocks 47
158 -20 rtems_region_return_segment: task readied -- preempts caller 45
159 -20 rtems_region_return_segment: task readied -- returns to caller 25
160 -20 rtems_region_delete 23
161 -20 rtems_io_initialize 1
162 +20 rtems_partition_create 21
163 +20 rtems_region_create 33
164 +20 rtems_partition_get_buffer: available 9
165 +20 rtems_partition_get_buffer: not available 3
166 +20 rtems_partition_return_buffer 8
167 +20 rtems_partition_delete 8
168 +20 rtems_region_get_segment: available 7
169 +20 rtems_region_get_segment: not available -- NO_WAIT 7
170 +20 rtems_region_return_segment: no waiting tasks 6
171 +20 rtems_region_get_segment: not available -- caller blocks 36
172 +20 rtems_region_return_segment: task readied -- preempts caller 33
173 +20 rtems_region_return_segment: task readied -- returns to caller 13
174 +20 rtems_region_delete 18
175 +20 rtems_io_initialize 0
180 20 rtems_io_control 0
182 -21 rtems_task_ident 39
183 -21 rtems_message_queue_ident 38
184 -21 rtems_semaphore_ident 43
185 -21 rtems_partition_ident 38
186 -21 rtems_region_ident 38
187 -21 rtems_port_ident 37
188 -21 rtems_timer_ident 38
189 -21 rtems_rate_monotonic_ident 38
190 +21 rtems_task_ident 8
191 +21 rtems_message_queue_ident 8
192 +21 rtems_semaphore_ident 9
193 +21 rtems_partition_ident 8
194 +21 rtems_region_ident 8
195 +21 rtems_port_ident 8
196 +21 rtems_timer_ident 8
197 +21 rtems_rate_monotonic_ident 8
199 22 rtems_message_queue_broadcast: task readied -- returns to caller 27
200 -22 rtems_message_queue_broadcast: no waiting tasks 6
201 -22 rtems_message_queue_broadcast: task readied -- preempts caller 22
202 +22 rtems_message_queue_broadcast: no waiting tasks 2
203 +22 rtems_message_queue_broadcast: task readied -- preempts caller 16
205 -23 rtems_timer_create 4
206 -23 rtems_timer_fire_after: inactive 7
207 -23 rtems_timer_fire_after: active 7
208 -23 rtems_timer_cancel: active 4
209 -23 rtems_timer_cancel: inactive 3
210 -23 rtems_timer_reset: inactive 6
211 -23 rtems_timer_reset: active 7
212 -23 rtems_timer_fire_when: inactive 9
213 -23 rtems_timer_fire_when: active 9
214 -23 rtems_timer_delete: active 5
215 -23 rtems_timer_delete: inactive 4
216 -23 rtems_task_wake_when 21
217 +23 rtems_timer_create 3
218 +23 rtems_timer_fire_after: inactive 4
219 +23 rtems_timer_fire_after: active 4
220 +23 rtems_timer_cancel: active 2
221 +23 rtems_timer_cancel: inactive 1
222 +23 rtems_timer_reset: inactive 3
223 +23 rtems_timer_reset: active 3
224 +23 rtems_timer_fire_when: inactive 4
225 +23 rtems_timer_fire_when: active 4
226 +23 rtems_timer_delete: active 3
227 +23 rtems_timer_delete: inactive 3
228 +23 rtems_task_wake_when 12
230 -24 rtems_task_wake_after: yield -- returns to caller 2
231 -24 rtems_task_wake_after: yields -- preempts caller 12
232 +24 rtems_task_wake_after: yield -- returns to caller 1
233 +24 rtems_task_wake_after: yields -- preempts caller 9
235 -25 rtems_clock_tick 13
236 +25 rtems_clock_tick 10
242 26 _Thread_Disable_dispatch 1
243 26 _Thread_Enable_dispatch 3
244 26 _Thread_Set_state 6
245 -26 _Thread_Disptach (NO FP) 13
246 -26 context switch: no floating point contexts 10
247 +26 _Thread_Disptach (NO FP) 9
248 +26 context switch: no floating point contexts 7
249 26 context switch: self 1
250 26 context switch: to another task 2
251 26 fp context switch: restore 1st FP task - NA
252 26 fp context switch: save idle, restore initialized - NA
253 26 fp context switch: save idle, restore idle - NA
254 26 fp context switch: save initialized, restore initialized - NA
256 -26 _Thread_Unblock 8
260 +26 _Thread_Unblock 7
264 26 _Thread_Get: invalid id 0
266 @@ -175,15 +175,15 @@
267 27 interrupt entry overhead: returns to nested interrupt 0
268 27 interrupt exit overhead: returns to nested interrupt 0
270 -28 rtems_port_create 13
271 -28 rtems_port_external_to_internal 3
272 -28 rtems_port_internal_to_external 3
273 -28 rtems_port_delete 11
274 +28 rtems_port_create 10
275 +28 rtems_port_external_to_internal 1
276 +28 rtems_port_internal_to_external 1
277 +28 rtems_port_delete 8
279 -29 rtems_rate_monotonic_create 13
280 -29 rtems_rate_monotonic_period: initiate period -- returns to caller 24
281 -29 rtems_rate_monotonic_period: obtain status 5
282 -29 rtems_rate_monotonic_cancel 15
283 +29 rtems_rate_monotonic_create 12
284 +29 rtems_rate_monotonic_period: initiate period -- returns to caller 17
285 +29 rtems_rate_monotonic_period: obtain status 3
286 +29 rtems_rate_monotonic_cancel 12
287 29 rtems_rate_monotonic_delete: inactive 12
288 -29 rtems_rate_monotonic_delete: active 7
289 -29 rtems_rate_monotonic_period: conclude periods -- caller blocks 13
290 +29 rtems_rate_monotonic_delete: active 4
291 +29 rtems_rate_monotonic_period: conclude periods -- caller blocks 9
292 Index: rtems/c/src/lib/libbsp/arm/csb336/console/uart.c
293 ===================================================================
294 --- rtems/c/src/lib/libbsp/arm/csb336/console/uart.c (revision 42)
295 +++ rtems/c/src/lib/libbsp/arm/csb336/console/uart.c (working copy)
298 - * console driver for MC9328XML UARTs
299 + * Console driver for MC9328XML UARTs.
301 - * This driver uses the shared console driver in
302 - * ...../libbsp/shared/console.c
303 + * Written Jay Monkman <jtm@lopingdog.com>
304 + * Copyright (c) 2005 by Loping Dog Embedded Systems
306 - * If you want the driver to be interrupt driven, you
307 - * need to write the ISR, and in the ISR insert the
308 - * chars into termios's queue.
309 + * The license and distribution terms for this file may be
310 + * found in the file LICENSE in this distribution or at
311 + * http://www.rtems.com/license
313 - * Copyright (c) 2004 Cogent Computer Systems
314 - * Written by Jay Monkman <jtm@lopingdog.com>
316 - * The license and distribution terms for this file may be
317 - * found in the file LICENSE in this distribution or at
319 - * http://www.OARcorp.com/rtems/license.html.
324 -#include <bsp.h> /* Must be before libio.h */
328 #include <rtems/libio.h>
329 +#include <libchip/sersupp.h>
330 +#include <rtems/error.h>
331 +#include <rtems/bspIo.h>
333 -#include <rtems/bspIo.h>
335 -/* Put the CPU (or UART) specific header file #include here */
337 #include <mc9328mxl.h>
338 -#include <libchip/serial.h>
339 -#include <libchip/sersupp.h>
342 +/* Define this to use interrupt driver UART driver */
343 +#define USE_INTERRUPTS 1
345 /* How many serial ports? */
347 +#define poll_write(c) imx_uart_poll_write_char(0, c)
348 +#define poll_read() imx_uart_poll_read_char(0)
350 -int uart_poll_read(int minor);
351 +static int imx_uart_first_open(int, int, void *);
352 +static int imx_uart_last_close(int, int, void *);
353 +static int imx_uart_poll_read(int);
354 +static int imx_uart_set_attrs(int, const struct termios *);
355 +static void imx_uart_init(int minor);
356 +static void imx_uart_set_baud(int, int);
357 +static int imx_uart_poll_write(int, const char *, int);
360 +#if defined(USE_INTERRUPTS)
361 +static void imx_uart_tx_isr(rtems_irq_hdl_param);
362 +static void imx_uart_rx_isr(rtems_irq_hdl_param);
363 +static void imx_uart_isr_on(const rtems_irq_connect_data *irq);
364 +static void imx_uart_isr_off(const rtems_irq_connect_data *irq);
365 +static int imx_uart_isr_is_on(const rtems_irq_connect_data *irq);
366 +static int imx_uart_intr_write(int, const char *, int);
369 -/* static function prototypes */
370 -static int uart_first_open(int major, int minor, void *arg);
371 -static int uart_last_close(int major, int minor, void *arg);
372 -static int uart_read(int minor);
373 -static int uart_write(int minor, const char *buf, int len);
374 -static void uart_init(int minor);
375 -static void uart_write_polled(int minor, char c);
376 -static int uart_set_attributes(int minor, const struct termios *t);
378 -/* These are used by code in console.c */
379 -unsigned long Console_Port_Count = NUM_DEVS;
380 -console_data Console_Port_Data[NUM_DEVS];
382 -/* rtems console uses the following minor number */
383 -rtems_device_minor_number Console_Port_Minor = 0;
385 -/* Pointers to functions for handling the UART. */
386 -console_fns uart_fns =
388 - libchip_serial_default_probe,
394 - uart_write_polled, /* not used in this driver */
395 - uart_set_attributes,
396 - FALSE /* TRUE if interrupt driven, FALSE if not. */
397 +/* TERMIOS callbacks */
398 +#if defined(USE_INTERRUPTS)
399 +rtems_termios_callbacks imx_uart_cbacks = {
400 + .firstOpen = imx_uart_first_open,
401 + .lastClose = imx_uart_last_close,
403 + .write = imx_uart_intr_write,
404 + .setAttributes = imx_uart_set_attrs,
405 + .stopRemoteTx = NULL,
406 + .startRemoteTx = NULL,
407 + .outputUsesInterrupts = 1,
410 +rtems_termios_callbacks imx_uart_cbacks = {
411 + .firstOpen = imx_uart_first_open,
412 + .lastClose = imx_uart_last_close,
413 + .pollRead = imx_uart_poll_read,
414 + .write = imx_uart_poll_write,
415 + .setAttributes = imx_uart_set_attrs,
416 + .stopRemoteTx = NULL,
417 + .startRemoteTx = NULL,
418 + .outputUsesInterrupts = 0,
423 - * There's one item in array for each UART.
425 - * Some of these fields are marked "NOT USED". They are not used
426 - * by console.c, but may be used by drivers in libchip
429 -console_tbl Console_Port_Tbl[] = {
431 - "/dev/com0", /* sDeviceName */
432 - SERIAL_CUSTOM, /* deviceType */
433 - &uart_fns, /* pDeviceFns */
434 - NULL, /* deviceProbe */
435 - NULL, /* pDeviceFlow */
436 - 0, /* ulMargin - NOT USED */
437 - 0, /* ulHysteresis - NOT USED */
438 - NULL, /* pDeviceParams */
439 - 0, /* ulCtrlPort1 - NOT USED */
440 - 0, /* ulCtrlPort2 - NOT USED */
441 - 0, /* ulDataPort - NOT USED */
442 - NULL, /* getRegister - NOT USED */
443 - NULL, /* setRegister - NOT USED */
444 - NULL, /* getData - NOT USED */
445 - NULL, /* setData - NOT USED */
446 - 0, /* ulClock - NOT USED */
447 - 0 /* ulIntVector - NOT USED */
450 - "/dev/com1", /* sDeviceName */
451 - SERIAL_CUSTOM, /* deviceType */
452 - &uart_fns, /* pDeviceFns */
453 - NULL, /* deviceProbe */
454 - NULL, /* pDeviceFlow */
455 - 0, /* ulMargin - NOT USED */
456 - 0, /* ulHysteresis - NOT USED */
457 - NULL, /* pDeviceParams */
458 - 0, /* ulCtrlPort1 - NOT USED */
459 - 0, /* ulCtrlPort2 - NOT USED */
460 - 0, /* ulDataPort - NOT USED */
461 - NULL, /* getRegister - NOT USED */
462 - NULL, /* setRegister - NOT USED */
463 - NULL, /* getData - NOT USED */
464 - NULL, /* setData - NOT USED */
465 - 0, /* ulClock - NOT USED */
466 - 0 /* ulIntVector - NOT USED */
467 +#if defined(USE_INTERRUPTS)
468 +static rtems_irq_connect_data imx_uart_tx_isr_data[NUM_DEVS];
469 +static rtems_irq_connect_data imx_uart_rx_isr_data[NUM_DEVS];
474 + mc9328mxl_uart_regs_t * regs;
475 + volatile const char *buf;
481 +static imx_uart_data_t imx_uart_data[NUM_DEVS];
483 +rtems_device_driver console_initialize(
484 + rtems_device_major_number major,
485 + rtems_device_minor_number minor,
489 + rtems_status_code status;
492 + for (i = 0; i < NUM_DEVS; i++) {
497 -/*********************************************************************/
498 -/* Functions called via termios callbacks (i.e. the ones in uart_fns */
499 -/*********************************************************************/
500 + rtems_termios_initialize();
503 - * This is called the first time each device is opened. If the driver
504 - * is interrupt driven, you should enable interrupts here. Otherwise,
505 - * it's probably safe to do nothing.
507 - * Since micromonitor already set up the UART, we do nothing.
509 -static int uart_first_open(int major, int minor, void *arg)
512 + /* /dev/console and /dev/tty0 are the same */
513 + status = rtems_io_register_name("/dev/console", major, 0);
514 + if (status != RTEMS_SUCCESSFUL) {
515 + rtems_panic("%s:%d Error registering /dev/console :: %d\n",
516 + __FUNCTION__, __LINE__, status);
519 + status = rtems_io_register_name("/dev/tty0", major, 0);
520 + if (status != RTEMS_SUCCESSFUL) {
521 + rtems_panic("%s:%d Error registering /dev/tty0 :: %d\n",
522 + __FUNCTION__, __LINE__, status);
525 + status = rtems_io_register_name("/dev/tty1", major, 1);
526 + if (status != RTEMS_SUCCESSFUL) {
527 + rtems_panic("%s:%d Error registering /dev/tty1 :: %d\n",
528 + __FUNCTION__, __LINE__, status);
530 + return RTEMS_SUCCESSFUL;
533 +rtems_device_driver console_open(
534 + rtems_device_major_number major,
535 + rtems_device_minor_number minor,
539 + rtems_status_code rc;
542 - * This is called the last time each device is closed. If the driver
543 - * is interrupt driven, you should disable interrupts here. Otherwise,
544 - * it's probably safe to do nothing.
546 -static int uart_last_close(int major, int minor, void *arg)
547 + if (minor > (NUM_DEVS - 1)) {
548 + return RTEMS_INVALID_NUMBER;
551 + rc = rtems_termios_open(major, minor, arg, &imx_uart_cbacks);
556 +rtems_device_driver console_close(
557 + rtems_device_major_number major,
558 + rtems_device_minor_number minor,
563 + return rtems_termios_close(arg);
566 +rtems_device_driver console_read(
567 + rtems_device_major_number major,
568 + rtems_device_minor_number minor,
572 + return rtems_termios_read(arg);
575 +rtems_device_driver console_write(
576 + rtems_device_major_number major,
577 + rtems_device_minor_number minor,
581 + return rtems_termios_write(arg);
584 +rtems_device_driver console_control(
585 + rtems_device_major_number major,
586 + rtems_device_minor_number minor,
590 + return rtems_termios_ioctl(arg);
595 - * Read one character from UART.
597 - * Return -1 if there's no data, otherwise return
598 - * the character in lowest 8 bits of returned int.
600 -static int uart_read(int minor)
601 +static void imx_uart_init(int minor)
604 + imx_uart_data[minor].minor = minor;
605 + imx_uart_data[minor].buf = NULL;
606 + imx_uart_data[minor].len = 0;
607 + imx_uart_data[minor].idx = 0;
610 - if (MC9328MXL_UART1_SR2 & MC9328MXL_UART_SR2_RDR) {
611 - c = MC9328MXL_UART1_RXD & MC9328MXL_UART_RXD_CHARMASK;
616 +#if defined(USE_INTERRUPTS)
617 + imx_uart_tx_isr_data[minor].name = BSP_INT_UART1_TX;
618 + imx_uart_rx_isr_data[minor].name = BSP_INT_UART1_RX;
620 + imx_uart_data[minor].regs =
621 + (mc9328mxl_uart_regs_t *) MC9328MXL_UART1_BASE;
622 } else if (minor == 1) {
623 - if (MC9328MXL_UART2_SR2 & MC9328MXL_UART_SR2_RDR) {
624 - c = MC9328MXL_UART2_RXD & MC9328MXL_UART_RXD_CHARMASK;
629 +#if defined(USE_INTERRUPTS)
630 + imx_uart_tx_isr_data[minor].name = BSP_INT_UART2_TX;
631 + imx_uart_rx_isr_data[minor].name = BSP_INT_UART2_RX;
633 + imx_uart_data[minor].regs =
634 + (mc9328mxl_uart_regs_t *) MC9328MXL_UART2_BASE;
636 - printk("Unknown console minor number: %d\n", minor);
638 + rtems_panic("%s:%d Unknown UART minor number %d\n",
639 + __FUNCTION__, __LINE__, minor);
642 +#if defined(USE_INTERRUPTS)
643 + imx_uart_tx_isr_data[minor].hdl = imx_uart_tx_isr;
644 + imx_uart_tx_isr_data[minor].handle = &imx_uart_data[minor];
645 + imx_uart_tx_isr_data[minor].on = imx_uart_isr_on;
646 + imx_uart_tx_isr_data[minor].off = imx_uart_isr_off;
647 + imx_uart_tx_isr_data[minor].isOn = imx_uart_isr_is_on;
649 + imx_uart_rx_isr_data[minor].hdl = imx_uart_rx_isr;
650 + imx_uart_rx_isr_data[minor].handle = &imx_uart_data[minor];
651 + imx_uart_rx_isr_data[minor].on = imx_uart_isr_on;
652 + imx_uart_rx_isr_data[minor].off = imx_uart_isr_off;
653 + imx_uart_rx_isr_data[minor].isOn = imx_uart_isr_is_on;
656 + imx_uart_data[minor].regs->cr1 = (
657 + MC9328MXL_UART_CR1_UARTCLKEN |
658 + MC9328MXL_UART_CR1_UARTEN);
660 + imx_uart_data[minor].regs->cr2 = (
661 + MC9328MXL_UART_CR2_IRTS |
662 + MC9328MXL_UART_CR2_WS |
663 + MC9328MXL_UART_CR2_TXEN |
664 + MC9328MXL_UART_CR2_RXEN |
665 + MC9328MXL_UART_CR2_SRST);
667 + imx_uart_data[minor].regs->cr3 = 0;
669 + imx_uart_data[minor].regs->cr4 = 0;
671 + imx_uart_data[minor].regs->fcr = (
672 + MC9328MXL_UART_FCR_TXTL(32) |
673 + MC9328MXL_UART_FCR_RFDIV_1 |
674 + MC9328MXL_UART_FCR_RXTL(1));
676 + imx_uart_set_baud(minor, 38400);
680 +static int imx_uart_first_open(int major, int minor, void *arg)
682 + rtems_libio_open_close_args_t *args = arg;
685 - * Write buffer to UART
687 - * return 1 on success, -1 on error
689 -static int uart_write(int minor, const char *buf, int len)
690 + imx_uart_data[minor].tty = args->iop->data1;
692 +#if defined(USE_INTERRUPTS)
693 + BSP_install_rtems_irq_handler(&imx_uart_tx_isr_data[minor]);
694 + BSP_install_rtems_irq_handler(&imx_uart_rx_isr_data[minor]);
696 + imx_uart_data[minor].regs->cr1 |= MC9328MXL_UART_CR1_RRDYEN;
702 +static int imx_uart_last_close(int major, int minor, void *arg)
705 +#if defined(USE_INTERRUPTS)
706 + BSP_remove_rtems_irq_handler(&imx_uart_tx_isr_data[minor]);
707 + BSP_remove_rtems_irq_handler(&imx_uart_rx_isr_data[minor]);
711 - for (i = 0; i < len; i++) {
712 - /* Wait for fifo to have room */
713 - while(!(MC9328MXL_UART1_SR2 & MC9328MXL_UART_SR2_TXDC)) {
717 - MC9328MXL_UART1_TXD = (char) buf[i];
719 - } else if (minor == 1) {
720 - for (i = 0; i < len; i++) {
721 - /* Wait for fifo to have room */
722 - while(!(MC9328MXL_UART2_SR2 & MC9328MXL_UART_SR2_TXDC)) {
726 - MC9328MXL_UART2_TXD = (char) buf[i];
731 +static int imx_uart_poll_read(int minor)
733 + if (imx_uart_data[minor].regs->sr2 & MC9328MXL_UART_SR2_RDR) {
734 + return imx_uart_data[minor].regs->rxd & 0xff;
736 - printk("Unknown console minor number: %d\n", minor);
744 -/* Set up the UART. */
745 -static void uart_init(int minor)
746 +static int imx_uart_poll_write(int minor, const char *buf, int len)
748 - /* leave the debug sio port as setup by umon */
750 + for (i = 0; i < len; i++) {
751 + /* Wait for there to be room in the fifo */
752 + while (!(imx_uart_data[minor].regs->sr2 & MC9328MXL_UART_SR2_TXDC)) {
756 + imx_uart_data[minor].regs->txd = buf[i];
762 -/* I'm not sure this is needed for the shared console driver. */
763 -static void uart_write_polled(int minor, char c)
764 +#if defined(USE_INTERRUPTS)
765 +static int imx_uart_intr_write(int minor, const char *buf, int len)
767 - uart_write(minor, &c, 1);
768 + imx_uart_data[minor].buf = buf;
769 + imx_uart_data[minor].len = len;
770 + imx_uart_data[minor].idx = 0;
772 + imx_uart_data[minor].regs->cr1 |= MC9328MXL_UART_CR1_TXMPTYEN;
779 /* This is for setting baud rate, bits, etc. */
780 -static int uart_set_attributes(int minor, const struct termios *t)
781 +static int imx_uart_set_attrs(int minor, const struct termios *t)
785 + baud = termios_baud_to_number(t->c_cflag & CBAUD);
786 + imx_uart_set_baud(minor, baud);
791 -/***********************************************************************/
792 +#if defined(USE_INTERRUPTS)
793 +static void imx_uart_isr_on(const rtems_irq_connect_data *irq)
795 + MC9328MXL_AITC_INTENNUM = irq->name;
797 +static void imx_uart_isr_off(const rtems_irq_connect_data *irq)
799 + MC9328MXL_AITC_INTDISNUM = irq->name;
801 +static int imx_uart_isr_is_on(const rtems_irq_connect_data *irq)
803 + int irq_num = (int)irq->name;
804 + if (irq_num < 32) {
805 + return MC9328MXL_AITC_INTENABLEL & (1 << irq_num);
807 + return MC9328MXL_AITC_INTENABLEH & (1 << (irq_num - 32));
811 +static void imx_uart_rx_isr(rtems_irq_hdl_param param)
813 + imx_uart_data_t *uart_data = param;
817 + while (uart_data->regs->sr2 & MC9328MXL_UART_SR2_RDR) {
818 + buf[i] = uart_data->regs->rxd & 0xff;
822 + rtems_termios_enqueue_raw_characters(uart_data->tty, buf, i);
825 +static void imx_uart_tx_isr(rtems_irq_hdl_param param)
827 + imx_uart_data_t *uart_data = param;
829 + int minor = uart_data->minor;
832 + if (uart_data->idx < uart_data->len) {
833 + while ( (uart_data->regs->sr1 & MC9328MXL_UART_SR1_TRDY) &&
834 + (uart_data->idx < uart_data->len)) {
835 + uart_data->regs->txd = uart_data->buf[uart_data->idx];
839 + len = uart_data->len;
840 + uart_data->len = 0;
841 + imx_uart_data[minor].regs->cr1 &= ~MC9328MXL_UART_CR1_TXMPTYEN;
842 + rtems_termios_dequeue_characters(uart_data->tty, len);
848 - * The following functions are not used by TERMIOS, but other RTEMS
849 - * functions use them instead.
850 + * Set the UART's baud rate. The calculation is:
851 + * (baud * 16) / ref_freq = num/demom
853 + * ref_freq = perclk1 / RFDIV[2:0]
857 + * Setting 'num' to 16 yields this equation:
858 + * demom = ref_freq / baud
860 -/***********************************************************************/
861 +static void imx_uart_set_baud(int minor, int baud)
863 + unsigned int perclk1;
864 + unsigned int denom;
865 + unsigned int ref_freq = 0;
868 + perclk1 = get_perclk1_freq();
869 + fcr = imx_uart_data[minor].regs->fcr;
871 + switch(fcr & MC9328MXL_UART_FCR_RFDIV_MASK) {
872 + case MC9328MXL_UART_FCR_RFDIV_1: ref_freq = perclk1/1; break;
873 + case MC9328MXL_UART_FCR_RFDIV_2: ref_freq = perclk1/2; break;
874 + case MC9328MXL_UART_FCR_RFDIV_3: ref_freq = perclk1/3; break;
875 + case MC9328MXL_UART_FCR_RFDIV_4: ref_freq = perclk1/4; break;
876 + case MC9328MXL_UART_FCR_RFDIV_5: ref_freq = perclk1/5; break;
877 + case MC9328MXL_UART_FCR_RFDIV_6: ref_freq = perclk1/6; break;
878 + case MC9328MXL_UART_FCR_RFDIV_7: ref_freq = perclk1/7; break;
880 + rtems_panic("%s:%d Unknown RFDIV: 0x%x",
881 + __FUNCTION__, __LINE__,
882 + fcr & MC9328MXL_UART_FCR_RFDIV_MASK);
886 + denom = ref_freq / baud;
888 + imx_uart_data[minor].regs->bir = 0xf;
889 + imx_uart_data[minor].regs->bmr = denom;
894 - * Read from UART. This is used in the exit code, and can't
895 - * rely on interrupts.
897 -int uart_poll_read(int minor)
898 + * Polled, non-blocking read from UART
900 +int imx_uart_poll_read_char(int minor)
902 - return uart_read(minor);
903 + return imx_uart_poll_read(minor);
907 + * Polled, blocking write from UART
909 +void imx_uart_poll_write_char(int minor, char c)
911 + imx_uart_poll_write(minor, &c, 1);
915 - * Write a character to the console. This is used by printk() and
916 - * maybe other low level functions. It should not use interrupts or any
917 - * RTEMS system calls. It needs to be very simple
918 + * Functions for printk() and friends.
920 -static void _BSP_put_char( char c ) {
921 - uart_write_polled(0, c);
922 +void _BSP_output_char(char c)
926 - uart_write_polled(0, '\r');
930 +BSP_output_char_function_type BSP_output_char = _BSP_output_char;
932 -BSP_output_char_function_type BSP_output_char = _BSP_put_char;
934 +char _BSP_poll_char()
936 + return poll_read();
938 +BSP_polling_getchar_function_type BSP_poll_char = _BSP_poll_char;
941 Index: rtems/c/src/lib/libbsp/arm/csb336/startup/bspstart.c
942 ===================================================================
943 --- rtems/c/src/lib/libbsp/arm/csb336/startup/bspstart.c (revision 42)
944 +++ rtems/c/src/lib/libbsp/arm/csb336/startup/bspstart.c (working copy)
946 /* Since RTEMS is not configured, no RTEMS functions can be called. */
948 /**************************************************************************/
949 +void mmu_set_cpu_async_mode(void);
950 void bsp_start_default( void )
954 + /* Set the MCU prescaler to divide by 1 */
955 + MC9328MXL_PLL_CSCR &= ~MC9328MXL_PLL_CSCR_PRESC;
957 + /* Enable the MCU PLL */
958 + MC9328MXL_PLL_CSCR |= MC9328MXL_PLL_CSCR_MPEN;
960 + /* Delay to allow time for PLL to get going */
961 + for (i = 0; i < 100; i++) {
962 + asm volatile ("nop\n");
965 + /* Set the CPU to asynchrous clock mode, so it uses its fastest clock */
966 + mmu_set_cpu_async_mode();
968 /* disable interrupts */
969 MC9328MXL_AITC_INTENABLEL = 0;
970 MC9328MXL_AITC_INTENABLEH = 0;
971 @@ -153,12 +169,12 @@
972 /* Calcuate the frequency for perclk1 */
973 int get_perclk1_freq(void)
990 @@ -187,13 +203,14 @@
991 printk("mfd = %d\n", mfd);
992 printk("mfi = %d\n", mfi);
993 printk("mfn = %d\n", mfn);
994 - printk("(fin * mfi) / (pd + 1) = %d\n", (fin * mfi) / (pd + 1));
995 - printk("(fin * mfn) / ((pd + 1) * (mfd + 1)) = %d\n",
996 - (fin * mfn) / ((pd + 1) * (mfd + 1)));
997 + printk("rounded (fin * mfi) / (pd + 1) = %d\n", (fin * mfi) / (pd + 1));
998 + printk("rounded (fin * mfn) / ((pd + 1) * (mfd + 1)) = %d\n",
999 + ((long long)fin * mfn) / ((pd + 1) * (mfd + 1)));
1002 - fpll = 2 * ( ((fin * mfi) / (pd + 1)) +
1003 - ((fin * mfn) / ((pd + 1) * (mfd + 1))) );
1004 + fpll = 2 * ( ((fin * mfi + (pd + 1) / 2) / (pd + 1)) +
1005 + (((long long)fin * mfn + ((pd + 1) * (mfd + 1)) / 2) /
1006 + ((pd + 1) * (mfd + 1))) );
1008 /* calculate the output of the PERCLK1 divider */
1009 reg = MC9328MXL_PLL_PCDR;
1010 Index: rtems/c/src/lib/libbsp/arm/csb336/startup/linkcmds
1011 ===================================================================
1012 --- rtems/c/src/lib/libbsp/arm/csb336/startup/linkcmds (revision 42)
1013 +++ rtems/c/src/lib/libbsp/arm/csb336/startup/linkcmds (working copy)
1015 rtems_vector_table = .;
1016 . += (8 * 4); /* 8 ARM interrupts */
1018 - bsp_vector_table = .;
1019 - . += (64 * 4); /* 64 MC9328MXL interrupts */
1024 Index: rtems/c/src/lib/libbsp/arm/csb336/startup/exit.c
1025 ===================================================================
1026 --- rtems/c/src/lib/libbsp/arm/csb336/startup/exit.c (revision 42)
1027 +++ rtems/c/src/lib/libbsp/arm/csb336/startup/exit.c (working copy)
1032 - while (uart_poll_read(0) < 0) continue;
1033 + while (BSP_poll_char() < 0) continue;
1037 Index: rtems/c/src/lib/libbsp/arm/csb336/Makefile.am
1038 ===================================================================
1039 --- rtems/c/src/lib/libbsp/arm/csb336/Makefile.am (revision 42)
1040 +++ rtems/c/src/lib/libbsp/arm/csb336/Makefile.am (working copy)
1042 startup_rel_LDFLAGS = $(RTEMS_RELLDFLAGS)
1044 noinst_PROGRAMS += console.rel
1045 -console_rel_SOURCES = console/uart.c ../../shared/console.c
1046 +console_rel_SOURCES = console/uart.c
1047 console_rel_CPPFLAGS = $(AM_CPPFLAGS)
1048 console_rel_LDFLAGS = $(RTEMS_RELLDFLAGS)
1050 Index: rtems/c/src/lib/libbsp/arm/csb336/network/network.c
1051 ===================================================================
1052 --- rtems/c/src/lib/libbsp/arm/csb336/network/network.c (revision 42)
1053 +++ rtems/c/src/lib/libbsp/arm/csb336/network/network.c (working copy)
1055 /* RTEMS event used to start transmit daemon. */
1056 #define START_TRANSMIT_EVENT RTEMS_EVENT_2
1058 -static rtems_isr enet_isr(rtems_vector_number vector);
1059 +static void enet_isr(rtems_irq_hdl_param);
1060 static void enet_isr_on(const rtems_irq_connect_data *unused);
1061 static void enet_isr_off(const rtems_irq_connect_data *unused);
1062 static int enet_isr_is_on(const rtems_irq_connect_data *irq);
1064 /* Replace the first value with the clock's interrupt name. */
1065 -rtems_irq_connect_data mc9328mxl_enet_isr_data = {BSP_INT_GPIO_PORTA,
1066 - (rtems_irq_hdl)enet_isr,
1070 - 3, /* unused for ARM */
1071 - 0 }; /* unused for ARM */
1073 +rtems_irq_connect_data mc9328mxl_enet_isr_data = {
1074 + .name = BSP_INT_GPIO_PORTA,
1075 + .hdl = (rtems_irq_hdl)enet_isr,
1076 + .handle = (void *)BSP_INT_GPIO_PORTA,
1077 + .on = enet_isr_on,
1078 + .off = enet_isr_off,
1079 + .isOn = enet_isr_is_on,
1082 unsigned long rx_packets; /* total packets received */
1083 unsigned long tx_packets; /* total packets transmitted */
1085 void mc9328mxl_enet_sendpacket (struct ifnet *ifp, struct mbuf *m);
1086 void mc9328mxl_enet_rx_task(void *arg);
1087 void mc9328mxl_enet_stats(mc9328mxl_enet_softc_t *sc);
1088 -static int mc9328mxl_enet_ioctl(struct ifnet *ifp, int command, caddr_t data);
1089 +static int mc9328mxl_enet_ioctl(struct ifnet *ifp,
1090 + unsigned long command, caddr_t data);
1093 int rtems_mc9328mxl_enet_attach (
1096 /* Driver ioctl handler */
1098 -mc9328mxl_enet_ioctl (struct ifnet *ifp, int command, caddr_t data)
1099 +mc9328mxl_enet_ioctl (struct ifnet *ifp, unsigned long command, caddr_t data)
1101 mc9328mxl_enet_softc_t *sc = ifp->if_softc;
1106 /* interrupt handler */
1107 -rtems_isr enet_isr (rtems_vector_number v)
1108 +static void enet_isr(rtems_irq_hdl_param unused)
1112 Index: rtems/c/src/lib/libbsp/arm/shared/irq/irq_init.c
1113 ===================================================================
1114 --- rtems/c/src/lib/libbsp/arm/shared/irq/irq_init.c (revision 42)
1115 +++ rtems/c/src/lib/libbsp/arm/shared/irq/irq_init.c (working copy)
1117 void rtems_irq_mngt_init()
1120 - long *vectorTable;
1121 rtems_interrupt_level level;
1123 - vectorTable = (long *) VECTOR_TABLE;
1125 _CPU_ISR_Disable(level);
1127 /* First, connect the ISR_Handler for IRQ and FIQ interrupts */
1128 _CPU_ISR_install_vector(ARM_EXCEPTION_IRQ, _ISR_Handler, NULL);
1129 _CPU_ISR_install_vector(ARM_EXCEPTION_FIQ, _ISR_Handler, NULL);
1131 - /* Initialize the vector table contents with default handler */
1132 - for (i=0; i<BSP_MAX_INT; i++)
1133 - *(vectorTable + i) = (long)(default_int_handler);
1135 /* Initialize the INT at the BSP level */
1136 BSP_rtems_irq_mngt_init();
1138 Index: rtems/c/src/lib/libbsp/arm/edb7312/irq/bsp_irq_init.c
1139 ===================================================================
1140 --- rtems/c/src/lib/libbsp/arm/edb7312/irq/bsp_irq_init.c (revision 42)
1141 +++ rtems/c/src/lib/libbsp/arm/edb7312/irq/bsp_irq_init.c (working copy)
1143 void BSP_rtems_irq_mngt_init()
1146 + long *vectorTable;
1149 + vectorTable = (long *) VECTOR_TABLE;
1151 + /* Initialize the vector table contents with default handler */
1152 + for (i=0; i<BSP_MAX_INT; i++) {
1153 + *(vectorTable + i) = (long)(default_int_handler);
1156 /* mask all interrupts */
1157 *EP7312_INTMR1 = 0x0;
1158 *EP7312_INTMR2 = 0x0;
1159 Index: rtems/c/src/lib/libbsp/arm/gba/irq/bsp_irq_init.c
1160 ===================================================================
1161 --- rtems/c/src/lib/libbsp/arm/gba/irq/bsp_irq_init.c (revision 42)
1162 +++ rtems/c/src/lib/libbsp/arm/gba/irq/bsp_irq_init.c (working copy)
1165 void BSP_rtems_irq_mngt_init(void)
1167 + long *vectorTable;
1170 + vectorTable = (long *) VECTOR_TABLE;
1172 + /* Initialize the vector table contents with default handler */
1173 + for (i=0; i<BSP_MAX_INT; i++) {
1174 + *(vectorTable + i) = (long)(default_int_handler);
1177 /* clear all interrupt status flags */
1178 GBA_REG_IF = 0xffff;
1179 /* disable all interrupts */
1180 Index: rtems/c/src/lib/libcpu/arm/mc9328mxl/include/mc9328mxl.h
1181 ===================================================================
1182 --- rtems/c/src/lib/libcpu/arm/mc9328mxl/include/mc9328mxl.h (revision 42)
1183 +++ rtems/c/src/lib/libcpu/arm/mc9328mxl/include/mc9328mxl.h (working copy)
1184 @@ -131,6 +131,33 @@
1185 #define MC9328MXL_UART2_MPR4 (*((volatile uint32_t *)((MC9328MXL_UART2_BASE) + 0xcc)))
1186 #define MC9328MXL_UART2_TS (*((volatile uint32_t *)((MC9328MXL_UART2_BASE) + 0xd0)))
1189 + volatile uint32_t rxd;
1190 + volatile uint32_t _res0[15];
1191 + volatile uint32_t txd;
1192 + volatile uint32_t _res1[15];
1193 + volatile uint32_t cr1;
1194 + volatile uint32_t cr2;
1195 + volatile uint32_t cr3;
1196 + volatile uint32_t cr4;
1197 + volatile uint32_t fcr;
1198 + volatile uint32_t sr1;
1199 + volatile uint32_t sr2;
1200 + volatile uint32_t esc;
1201 + volatile uint32_t tim;
1202 + volatile uint32_t bir;
1203 + volatile uint32_t bmr;
1204 + volatile uint32_t brc;
1205 + volatile uint32_t ipr1;
1206 + volatile uint32_t ipr2;
1207 + volatile uint32_t ipr3;
1208 + volatile uint32_t ipr4;
1209 + volatile uint32_t mpr1;
1210 + volatile uint32_t mpr2;
1211 + volatile uint32_t mpr3;
1212 + volatile uint32_t mpr4;
1213 + volatile uint32_t ts;
1214 +} mc9328mxl_uart_regs_t;
1216 #define MC9328MXL_UART_RXD_CHARRDY (bit(15))
1217 #define MC9328MXL_UART_RXD_ERR (bit(14))
1218 @@ -205,6 +232,17 @@
1219 #define MC9328MXL_UART_CR4_OREN (bit(1))
1220 #define MC9328MXL_UART_CR4_DREN (bit(0))
1222 +#define MC9328MXL_UART_FCR_TXTL(x) (((x) & 0x3f) << 10)
1223 +#define MC9328MXL_UART_FCR_RFDIV_1 (5 << 7)
1224 +#define MC9328MXL_UART_FCR_RFDIV_2 (4 << 7)
1225 +#define MC9328MXL_UART_FCR_RFDIV_3 (3 << 7)
1226 +#define MC9328MXL_UART_FCR_RFDIV_4 (2 << 7)
1227 +#define MC9328MXL_UART_FCR_RFDIV_5 (1 << 7)
1228 +#define MC9328MXL_UART_FCR_RFDIV_6 (0 << 7)
1229 +#define MC9328MXL_UART_FCR_RFDIV_7 (6 << 7)
1230 +#define MC9328MXL_UART_FCR_RFDIV_MASK (7 << 7)
1231 +#define MC9328MXL_UART_FCR_RXTL(x) (((x) & 0x3f) << 0)
1233 #define MC9328MXL_UART_SR1_PARERR (bit(15))
1234 #define MC9328MXL_UART_SR1_RTSS (bit(14))
1235 #define MC9328MXL_UART_SR1_TRDY (bit(13))
1236 Index: rtems/c/src/lib/libcpu/arm/mc9328mxl/clock/clockdrv.c
1237 ===================================================================
1238 --- rtems/c/src/lib/libcpu/arm/mc9328mxl/clock/clockdrv.c (revision 42)
1239 +++ rtems/c/src/lib/libcpu/arm/mc9328mxl/clock/clockdrv.c (working copy)
1241 static int clock_isr_is_on(const rtems_irq_connect_data *irq);
1243 /* Replace the first value with the clock's interrupt name. */
1244 -rtems_irq_connect_data clock_isr_data = {BSP_INT_TIMER1,
1245 - (rtems_irq_hdl)Clock_isr,
1249 - 3, /* unused for ARM cpus */
1250 - 0 }; /* unused for ARM cpus */
1251 +rtems_irq_connect_data clock_isr_data = {
1252 + .name = BSP_INT_TIMER1,
1253 + .hdl = (rtems_irq_hdl)Clock_isr,
1254 + .handle = (void *)BSP_INT_TIMER1,
1255 + .on = clock_isr_on,
1256 + .off = clock_isr_off,
1257 + .isOn = clock_isr_is_on,
1260 /* If you follow the code, this is never used, so any value
1264 freq = get_perclk1_freq(); \
1265 printk("perclk1 freq is %d\n", freq); \
1266 - cnt = ((freq / 1000) * BSP_Configuration.microseconds_per_tick) / 1000;\
1267 + cnt = ((long long)freq * BSP_Configuration.microseconds_per_tick + 500000) / 1000000;\
1268 printk("cnt freq is %d\n", cnt); \
1269 MC9328MXL_TMR1_TCMP = cnt; \
1270 /* use PERCLK1 as input, enable timer */ \
1271 Index: rtems/c/src/lib/libcpu/arm/mc9328mxl/irq/bsp_irq_asm.S
1272 ===================================================================
1273 --- rtems/c/src/lib/libcpu/arm/mc9328mxl/irq/bsp_irq_asm.S (revision 42)
1274 +++ rtems/c/src/lib/libcpu/arm/mc9328mxl/irq/bsp_irq_asm.S (working copy)
1277 /* find the ISR's address based on the vector */
1278 ldr r0, =bsp_vector_table
1279 - ldr r0, [r0, r1, LSL #2] /* Read the address */
1280 + mov r1, r1, LSL #3 /* Shift vector to get offset into table */
1281 + add r1, r0, r1 /* r1 has address of vector entry */
1282 + ldr r0, [r1, #4] /* Get the data pointer */
1283 + ldr r1, [r1] /* Get the vector */
1287 ldr lr, =IRQ_return /* prepare the return from handler */
1289 - mov pc, r0 /* EXECUTE INT HANDLER */
1290 + mov pc, r1 /* EXECUTE INT HANDLER */
1294 Index: rtems/c/src/lib/libcpu/arm/mc9328mxl/irq/irq.h
1295 ===================================================================
1296 --- rtems/c/src/lib/libcpu/arm/mc9328mxl/irq/irq.h (revision 42)
1297 +++ rtems/c/src/lib/libcpu/arm/mc9328mxl/irq/irq.h (working copy)
1302 +#include <rtems/irq.h>
1309 **********************************************************************/
1311 -/* possible interrupt sources on the AT91RM9200 */
1312 +/* possible interrupt sources on the MC9328MXL */
1313 #define BSP_INT_UART3_PFERR 0
1314 #define BSP_INT_UART3_RTS 1
1315 #define BSP_INT_UART3_DTR 2
1316 @@ -101,64 +103,21 @@
1317 #define BSP_INT_WDT 63
1318 #define BSP_MAX_INT 64
1320 -typedef unsigned char rtems_irq_level;
1321 -typedef unsigned char rtems_irq_trigger;
1323 + rtems_irq_hdl vector;
1324 + rtems_irq_hdl_param data;
1325 +} mc9328mxl_irq_info_t;
1327 -typedef unsigned int rtems_irq_number;
1328 -struct __rtems_irq_connect_data__; /* forward declaratiuon */
1330 -typedef void (*rtems_irq_hdl) (void);
1331 -typedef void (*rtems_irq_enable) (const struct __rtems_irq_connect_data__*);
1332 -typedef void (*rtems_irq_disable) (const struct __rtems_irq_connect_data__*);
1333 -typedef int (*rtems_irq_is_enabled)(const struct __rtems_irq_connect_data__*);
1335 -extern rtems_irq_hdl bsp_vector_table[BSP_MAX_INT];
1336 -#define VECTOR_TABLE bsp_vector_table
1338 -typedef struct __rtems_irq_connect_data__ {
1340 - rtems_irq_number name;
1341 +extern mc9328mxl_irq_info_t bsp_vector_table[BSP_MAX_INT];
1344 - rtems_irq_hdl hdl;
1346 - /* function for enabling interrupts at device level. */
1347 - rtems_irq_enable on;
1349 - /* function for disabling interrupts at device level. */
1350 - rtems_irq_disable off;
1352 - /* Function to test if interrupt is enabled */
1353 - rtems_irq_is_enabled isOn;
1355 - /* priority level of interrupt */
1356 - rtems_irq_level irqLevel;
1358 - /* Trigger method (rising/falling edge or high/low level) */
1359 - rtems_irq_trigger irqTrigger;
1360 -} rtems_irq_connect_data;
1363 * function to initialize the interrupt for a specific BSP
1365 void BSP_rtems_irq_mngt_init();
1369 - * function to connect a particular irq handler.
1371 -int BSP_install_rtems_irq_handler (const rtems_irq_connect_data*);
1374 - * function to get the current RTEMS irq handler for ptr->name.
1376 -int BSP_get_current_rtems_irq_handler (rtems_irq_connect_data* ptr);
1379 - * function to disconnect the RTEMS irq handler for ptr->name.
1381 -int BSP_remove_rtems_irq_handler (const rtems_irq_connect_data*);
1383 #endif /* __asm__ */
1386 Index: rtems/c/src/lib/libcpu/arm/mc9328mxl/irq/bsp_irq_init.c
1387 ===================================================================
1388 --- rtems/c/src/lib/libcpu/arm/mc9328mxl/irq/bsp_irq_init.c (revision 42)
1389 +++ rtems/c/src/lib/libcpu/arm/mc9328mxl/irq/bsp_irq_init.c (working copy)
1392 void BSP_rtems_irq_mngt_init()
1395 - /* disable all interrupts */
1396 - AIC_CTL_REG(AIC_IDCR) = 0xffffffff;
1400 + for (i = 0; i < BSP_MAX_INT; i++) {
1401 + bsp_vector_table[i].vector = default_int_handler;
1402 + bsp_vector_table[i].data = NULL;
1406 Index: rtems/c/src/lib/libcpu/arm/mc9328mxl/irq/irq.c
1407 ===================================================================
1408 --- rtems/c/src/lib/libcpu/arm/mc9328mxl/irq/irq.c (revision 42)
1409 +++ rtems/c/src/lib/libcpu/arm/mc9328mxl/irq/irq.c (working copy)
1411 #include <rtems/score/apiext.h>
1412 #include <mc9328mxl.h>
1414 +mc9328mxl_irq_info_t bsp_vector_table[BSP_MAX_INT];
1417 * This function check that the value given for the irq line
1420 int BSP_install_rtems_irq_handler (const rtems_irq_connect_data* irq)
1422 rtems_interrupt_level level;
1423 - rtems_irq_hdl *bsp_tbl;
1425 - bsp_tbl = (rtems_irq_hdl *)&bsp_vector_table;
1427 if (!isValidInterrupt(irq->name)) {
1431 * Check if default handler is actually connected. If not issue an error.
1433 - if (bsp_tbl[irq->name] != default_int_handler) {
1435 + if (bsp_vector_table[irq->name].vector != default_int_handler) {
1439 _CPU_ISR_Disable(level);
1442 * store the new handler
1444 - bsp_tbl[irq->name] = irq->hdl;
1445 + bsp_vector_table[irq->name].vector = irq->hdl;
1446 + bsp_vector_table[irq->name].data = irq->handle;
1449 * Enable interrupt on device
1451 int BSP_remove_rtems_irq_handler (const rtems_irq_connect_data* irq)
1453 rtems_interrupt_level level;
1454 - rtems_irq_hdl *bsp_tbl;
1456 - bsp_tbl = (rtems_irq_hdl *)&bsp_vector_table;
1458 if (!isValidInterrupt(irq->name)) {
1462 * Check if the handler is actually connected. If not issue an error.
1464 - if (bsp_tbl[irq->name] != irq->hdl) {
1466 + if (bsp_vector_table[irq->name].vector != irq->hdl) {
1470 _CPU_ISR_Disable(level);
1473 * restore the default irq value
1475 - bsp_tbl[irq->name] = default_int_handler;
1477 + bsp_vector_table[irq->name].vector = default_int_handler;
1478 + bsp_vector_table[irq->name].data = NULL;
1480 _CPU_ISR_Enable(level);
1482 Index: rtems/c/src/lib/libcpu/arm/shared/arm920/mmu.c
1483 ===================================================================
1484 --- rtems/c/src/lib/libcpu/arm/shared/arm920/mmu.c (revision 42)
1485 +++ rtems/c/src/lib/libcpu/arm/shared/arm920/mmu.c (working copy)
1487 static inline uint32_t mmu_get_ctrl(void)
1490 - asm volatile ("msr 15, 0, %0, cr1, cr0\n" : "=r" (val));
1491 + asm volatile ("mrc 15, 0, %0, cr1, cr0\n" : "=r" (val));
1495 @@ -240,3 +240,13 @@
1496 base[i] = MMU_SET_LVL1_INVAL;
1501 +void mmu_set_cpu_async_mode(void)
1504 + reg = mmu_get_ctrl();
1505 + reg |= 0xc0000000;
1506 + mmu_set_ctrl(reg);
1509 Index: rtems/c/src/lib/libcpu/arm/at91rm9200/irq/bsp_irq_init.c
1510 ===================================================================
1511 --- rtems/c/src/lib/libcpu/arm/at91rm9200/irq/bsp_irq_init.c (revision 42)
1512 +++ rtems/c/src/lib/libcpu/arm/at91rm9200/irq/bsp_irq_init.c (working copy)
1515 void BSP_rtems_irq_mngt_init()
1517 + long *vectorTable;
1520 + vectorTable = (long *) VECTOR_TABLE;
1522 + /* Initialize the vector table contents with default handler */
1523 + for (i=0; i<BSP_MAX_INT; i++) {
1524 + *(vectorTable + i) = (long)(default_int_handler);
1527 /* disable all interrupts */
1528 AIC_CTL_REG(AIC_IDCR) = 0xffffffff;
1530 Index: rtems/c/src/lib/libcpu/arm/s3c2400/irq/bsp_irq_init.c
1531 ===================================================================
1532 --- rtems/c/src/lib/libcpu/arm/s3c2400/irq/bsp_irq_init.c (revision 42)
1533 +++ rtems/c/src/lib/libcpu/arm/s3c2400/irq/bsp_irq_init.c (working copy)
1536 void BSP_rtems_irq_mngt_init()
1538 + long *vectorTable;
1541 + vectorTable = (long *) VECTOR_TABLE;
1543 + /* Initialize the vector table contents with default handler */
1544 + for (i=0; i<BSP_MAX_INT; i++) {
1545 + *(vectorTable + i) = (long)(default_int_handler);
1549 * Here is the code to initialize the INT for
1551 Index: rtems/make/custom/csb336.cfg
1552 ===================================================================
1553 --- rtems/make/custom/csb336.cfg (revision 42)
1554 +++ rtems/make/custom/csb336.cfg (working copy)
1556 # -O4 is ok for RTEMS
1557 # NOTE2: some level of -O may be actually required by inline assembler (at least
1559 -CFLAGS_OPTIMIZE_V=-O3
1560 +CFLAGS_OPTIMIZE_V=-O3 -g
1561 #CFLAGS_OPTIMIZE_V=-O4 -mmultiple -mstring -mstrict-align
1563 # debug flags: typically none, but at least -O1 is required due to this
1564 # BSP using inlined code
1565 -CFLAGS_DEBUG_V = -O1
1566 +CFLAGS_DEBUG_V = -O1 -g
1567 #CFLAGS_DEBUG_V = -O1 -mmultiple -mstring -mstrict-align