summaryrefslogtreecommitdiffstats
path: root/c/src/lib/libbsp/m68k
diff options
context:
space:
mode:
authorChris Johns <chrisj@rtems.org>2008-06-19 05:46:19 +0000
committerChris Johns <chrisj@rtems.org>2008-06-19 05:46:19 +0000
commit9374e9b082bf80e68aaa747dd26a5a3b01bc6626 (patch)
tree34f5294796594c22925d520e20e0c8c2560ac3d4 /c/src/lib/libbsp/m68k
parent2008-06-19 Matthew Riek <matthew.riek@ibiscomputer.com.au> (diff)
downloadrtems-9374e9b082bf80e68aaa747dd26a5a3b01bc6626.tar.bz2
2008-06-19 Matthew Riek <matthew.riek@ibiscomputer.com.au>
* mcf52235/README, mcf52235/gdb-init, mcf52235/clock/clock.c, mcf52235/console/console.c, mcf52235/include/bsp.h, mcf52235/include/coverhd.h, mcf52235/start/start.S, mcf52235/startup/bspclean.c, mcf52235/startup/bspstart.c, mcf52235/startup/linkcmds, mcf52235/timer/timer.c: Cleaned up white space and code formmated to adhere to RTEMS standards. Fixed a bug in the nano seconds since last tick support. Fixed a bug with the location of the start stack (no longer within .bss). Removed double definition of IPSBAR and some type defs etc.. Added timing test overhead results.
Diffstat (limited to 'c/src/lib/libbsp/m68k')
-rw-r--r--c/src/lib/libbsp/m68k/mcf52235/ChangeLog13
-rw-r--r--c/src/lib/libbsp/m68k/mcf52235/README123
-rw-r--r--c/src/lib/libbsp/m68k/mcf52235/clock/clock.c72
-rw-r--r--c/src/lib/libbsp/m68k/mcf52235/console/console.c1049
-rw-r--r--c/src/lib/libbsp/m68k/mcf52235/gdb-init6
-rw-r--r--c/src/lib/libbsp/m68k/mcf52235/include/bsp.h16
-rw-r--r--c/src/lib/libbsp/m68k/mcf52235/include/coverhd.h8
-rw-r--r--c/src/lib/libbsp/m68k/mcf52235/start/start.S29
-rw-r--r--c/src/lib/libbsp/m68k/mcf52235/startup/bspclean.c14
-rw-r--r--c/src/lib/libbsp/m68k/mcf52235/startup/bspstart.c4
-rw-r--r--c/src/lib/libbsp/m68k/mcf52235/startup/linkcmds11
-rw-r--r--c/src/lib/libbsp/m68k/mcf52235/timer/timer.c33
12 files changed, 700 insertions, 678 deletions
diff --git a/c/src/lib/libbsp/m68k/mcf52235/ChangeLog b/c/src/lib/libbsp/m68k/mcf52235/ChangeLog
index 9745b63614..c67a9346ff 100644
--- a/c/src/lib/libbsp/m68k/mcf52235/ChangeLog
+++ b/c/src/lib/libbsp/m68k/mcf52235/ChangeLog
@@ -1,3 +1,16 @@
+2008-06-19 Matthew Riek <matthew.riek@ibiscomputer.com.au>
+
+ * mcf52235/README, mcf52235/gdb-init, mcf52235/clock/clock.c,
+ mcf52235/console/console.c, mcf52235/include/bsp.h,
+ mcf52235/include/coverhd.h, mcf52235/start/start.S,
+ mcf52235/startup/bspclean.c, mcf52235/startup/bspstart.c,
+ mcf52235/startup/linkcmds, mcf52235/timer/timer.c: Cleaned up
+ white space and code formmated to adhere to RTEMS standards. Fixed
+ a bug in the nano seconds since last tick support. Fixed a bug
+ with the location of the start stack (no longer within
+ .bss). Removed double definition of IPSBAR and some type defs
+ etc.. Added timing test overhead results.
+
2008-06-10 Matthew Riek <matthew.riek@ibiscomputer.com.au>
* .cvsignore, ChangeLog, Makefile.am, README, bsp_specs,
diff --git a/c/src/lib/libbsp/m68k/mcf52235/README b/c/src/lib/libbsp/m68k/mcf52235/README
index b52aa5de91..469499e581 100644
--- a/c/src/lib/libbsp/m68k/mcf52235/README
+++ b/c/src/lib/libbsp/m68k/mcf52235/README
@@ -3,7 +3,7 @@
#
Description: Motorola MCF52235EVB
-============
+============================================================================
CPU: MCF52235, 60MHz
SRAM: 32K
FLASH: 256K
@@ -11,10 +11,10 @@ FLASH: 256K
This is a Motorola evaluation board that uses the MCF52235 Coldfire CPU.
This board is running at 60MHz scaled from a 25MHz oscillator.
+============================================================================
NOTES:
-======
-Currently this BSP must be configured with most (all?) RTEMS features turned
+Currently this BSP must be configured with most RTEMS features turned
off as RAM usage is too high.
Configure as follows:
@@ -22,17 +22,35 @@ configure --target=m68k-rtems4.9 --enable-rtemsbsp=mcf52235 \
--disable-networking --disable-posix --disable-itron --disable-cxx \
--disable-tests
+To get the tests to compile (but not run) change the linkcmds to specify
+a larger sram memory region (256K works). This of course will let you
+compile all tests, but many or most of them wont run.
+
+See testsuites/samples/minumum for an example of what type of config flags
+you need for this BSP!
+
+In you project before you include confdefs.h, define some or all of the
+following:
+
+#define CONFIGURE_DISABLE_CLASSIC_API_NOTEPADS
+#define CONFIGURE_DISABLE_CLASSIC_NOTEPADS
+#define CONFIGURE_INIT_TASK_STACK_SIZE x
+#define CONFIGURE_MINIMUM_TASK_STACK_SIZE x
+#define CONFIGURE_INTERRUPT_STACK_SIZE x
+
+Note that the default stack size is 1K
+Note that the default number of priorities is 15
+
+============================================================================
TODO:
-=====
-*) Work with TINY RTEMS to get the ram usage down.
*) Add drivers for I2C, ADC, FEC
*) Support for LWIP
*) Update the coverhd.h (calling overheads) page 21 of the BSP guide
-*) Adjust initial stack so that it's space is not forever unusable after init
-*) Fix up constants used by cfinit such as clockspeed, rambase, flashbase etc.
+*) Recover the 1K stack space reserved in linkcmds used for board startup.
============================================================================
+
Interrupt map
+-----+-----------------------------------------------------------------------+
@@ -46,7 +64,7 @@ TODO:
+-----+--------+--------+--------+--------+--------+--------+--------+--------+
| 5 | | | | | | | | |
+-----+--------+--------+--------+--------+--------+--------+--------+--------+
-| 4 | FEC RX | FEC TX | | | | | | PIT |
+| 4 | | | | | | | | PIT |
+-----+--------+--------+--------+--------+--------+--------+--------+--------+
| 3 | UART 0 | UART 1 | UART 2 | | | | | |
+-----+--------+--------+--------+--------+--------+--------+--------+--------+
@@ -54,3 +72,92 @@ TODO:
+-----+--------+--------+--------+--------+--------+--------+--------+--------+
| 1 | | | | | | | | |
+-----+--------+--------+--------+--------+--------+--------+--------+--------+
+
+============================================================================
+
+*** TIME TEST 1 ***
+rtems_semaphore_create 8
+rtems_semaphore_delete 10
+rtems_semaphore_obtain: available 3
+rtems_semaphore_obtain: not available -- NO_WAIT 3
+rtems_semaphore_release: no waiting tasks 7
+*** END OF TEST 1 ***
+
+
+*** TIME TEST OVERHEAD ***
+rtems_shutdown_executive 0
+rtems_task_create 0
+rtems_task_ident 0
+rtems_task_start 0
+rtems_task_restart 0
+rtems_task_delete 0
+rtems_task_suspend 0
+rtems_task_resume 0
+rtems_task_set_priority 0
+rtems_task_mode 0
+rtems_task_get_note 0
+rtems_task_set_note 0
+rtems_task_wake_when 0
+rtems_task_wake_after 0
+rtems_interrupt_catch 0
+rtems_clock_get 0
+rtems_clock_set 0
+rtems_clock_tick 0
+<pause>
+rtems_timer_create 0
+rtems_timer_delete 0
+rtems_timer_ident 0
+rtems_timer_fire_after 0
+rtems_timer_fire_when 1
+rtems_timer_reset 0
+rtems_timer_cancel 0
+rtems_semaphore_create 0
+rtems_semaphore_delete 0
+rtems_semaphore_ident 0
+rtems_semaphore_obtain 0
+rtems_semaphore_release 0
+rtems_message_queue_create 0
+rtems_message_queue_ident 0
+rtems_message_queue_delete 0
+rtems_message_queue_send 0
+rtems_message_queue_urgent 0
+rtems_message_queue_broadcast 0
+rtems_message_queue_receive 0
+rtems_message_queue_flush 0
+<pause>
+rtems_event_send 0
+rtems_event_receive 0
+rtems_signal_catch 0
+rtems_signal_send 0
+rtems_partition_create 0
+rtems_partition_ident 0
+rtems_partition_delete 0
+rtems_partition_get_buffer 0
+rtems_partition_return_buffer 0
+rtems_region_create 0
+rtems_region_ident 0
+rtems_region_delete 0
+rtems_region_get_segment 0
+rtems_region_return_segment 0
+rtems_port_create 0
+rtems_port_ident 0
+rtems_port_delete 0
+rtems_port_external_to_internal 0
+rtems_port_internal_to_external 0
+<pause>
+rtems_io_initialize 0
+rtems_io_open 0
+rtems_io_close 0
+rtems_io_read 0
+rtems_io_write 0
+rtems_io_control 0
+rtems_fatal_error_occurred 0
+rtems_rate_monotonic_create 0
+rtems_rate_monotonic_ident 0
+rtems_rate_monotonic_delete 0
+rtems_rate_monotonic_cancel 0
+rtems_rate_monotonic_period 0
+rtems_multiprocessing_announce 0
+*** END OF TIME OVERHEAD ***
+
+
diff --git a/c/src/lib/libbsp/m68k/mcf52235/clock/clock.c b/c/src/lib/libbsp/m68k/mcf52235/clock/clock.c
index 9e7b3dd346..c52c4918e0 100644
--- a/c/src/lib/libbsp/m68k/mcf52235/clock/clock.c
+++ b/c/src/lib/libbsp/m68k/mcf52235/clock/clock.c
@@ -17,15 +17,19 @@ static uint32_t s_nanoScale = 0;
/*
* Provide nanosecond extension
+ * Interrupts are disabled when this is called
*/
static uint32_t bsp_clock_nanoseconds_since_last_tick(void)
{
- uint32_t i = MCF_PIT1_PCNTR;
- if(MCF_PIT1_PCSR & MCF_PIT_PCSR_PIF)
- {
- i = MCF_PIT1_PCNTR + MCF_PIT1_PMR;
- }
- return (i - s_pcntrAtTick) * s_nanoScale;
+ uint32_t i;
+
+ if (MCF_PIT1_PCSR & MCF_PIT_PCSR_PIF) {
+ i = s_pcntrAtTick + (MCF_PIT1_PMR - MCF_PIT1_PCNTR);
+ }
+ else {
+ i = s_pcntrAtTick - MCF_PIT1_PCNTR;
+ }
+ return i * s_nanoScale;
}
#define Clock_driver_nanoseconds_since_last_tick bsp_clock_nanoseconds_since_last_tick
@@ -50,9 +54,9 @@ static uint32_t bsp_clock_nanoseconds_since_last_tick(void)
/*
* Turn off the clock
*/
-static void Clock_driver_support_shutdown_hardware()
+static void Clock_driver_support_shutdown_hardware()
{
- MCF_PIT1_PCSR &= ~MCF_PIT_PCSR_EN;
+ MCF_PIT1_PCSR &= ~MCF_PIT_PCSR_EN;
}
/*
@@ -62,35 +66,33 @@ static void Clock_driver_support_shutdown_hardware()
*/
static void Clock_driver_support_initialize_hardware()
{
- int level;
- uint32_t pmr;
- uint32_t preScaleCode = 0;
- uint32_t clk = bsp_get_CPU_clock_speed() >> 1;
- uint32_t tps = 1000000 / Configuration.microseconds_per_tick;
- while (preScaleCode < 15) {
- pmr = (clk >> preScaleCode) / tps;
- if(pmr < (1 << 15)) break;
- preScaleCode++;
- }
- s_nanoScale = 1000000000 / (clk >> preScaleCode);
+ int level;
+ uint32_t pmr;
+ uint32_t preScaleCode = 0;
+ uint32_t clk = bsp_get_CPU_clock_speed() >> 1;
+ uint32_t tps = 1000000 / Configuration.microseconds_per_tick;
+
+ while (preScaleCode < 15) {
+ pmr = (clk >> preScaleCode) / tps;
+ if (pmr < (1 << 15))
+ break;
+ preScaleCode++;
+ }
+ s_nanoScale = 1000000000 / (clk >> preScaleCode);
- MCF_INTC0_ICR56 = MCF_INTC_ICR_IL(PIT3_IRQ_LEVEL) |
- MCF_INTC_ICR_IP(PIT3_IRQ_PRIORITY);
- rtems_interrupt_disable( level );
- MCF_INTC0_IMRH &= ~MCF_INTC_IMRH_MASK56;
- MCF_PIT1_PCSR &= ~MCF_PIT_PCSR_EN;
- rtems_interrupt_enable( level );
+ MCF_INTC0_ICR56 = MCF_INTC_ICR_IL(PIT3_IRQ_LEVEL) |
+ MCF_INTC_ICR_IP(PIT3_IRQ_PRIORITY);
+ rtems_interrupt_disable(level);
+ MCF_INTC0_IMRH &= ~MCF_INTC_IMRH_MASK56;
+ MCF_PIT1_PCSR &= ~MCF_PIT_PCSR_EN;
+ rtems_interrupt_enable(level);
- MCF_PIT1_PCSR = MCF_PIT_PCSR_PRE(preScaleCode) |
- MCF_PIT_PCSR_OVW |
- MCF_PIT_PCSR_PIE |
- MCF_PIT_PCSR_RLD;
- MCF_PIT1_PMR = pmr;
- MCF_PIT1_PCSR = MCF_PIT_PCSR_PRE(preScaleCode) |
- MCF_PIT_PCSR_PIE |
- MCF_PIT_PCSR_RLD |
- MCF_PIT_PCSR_EN;
- s_pcntrAtTick = MCF_PIT1_PCNTR;
+ MCF_PIT1_PCSR = MCF_PIT_PCSR_PRE(preScaleCode) |
+ MCF_PIT_PCSR_OVW | MCF_PIT_PCSR_PIE | MCF_PIT_PCSR_RLD;
+ MCF_PIT1_PMR = pmr;
+ MCF_PIT1_PCSR = MCF_PIT_PCSR_PRE(preScaleCode) |
+ MCF_PIT_PCSR_PIE | MCF_PIT_PCSR_RLD | MCF_PIT_PCSR_EN;
+ s_pcntrAtTick = MCF_PIT1_PCNTR;
}
#include "../../../shared/clockdrv_shell.c"
diff --git a/c/src/lib/libbsp/m68k/mcf52235/console/console.c b/c/src/lib/libbsp/m68k/mcf52235/console/console.c
index eee826847f..b99f127109 100644
--- a/c/src/lib/libbsp/m68k/mcf52235/console/console.c
+++ b/c/src/lib/libbsp/m68k/mcf52235/console/console.c
@@ -23,23 +23,23 @@
MCF_UART_USR_OE )
static int IntUartPollWrite(int minor, const char *buf, int len);
-static int IntUartInterruptWrite (int minor, const char *buf, int len);
+static int IntUartInterruptWrite(int minor, const char *buf, int len);
-static void
-_BSP_null_char( char c )
-{
- int level;
-
- if (c == '\n')
- _BSP_null_char('\r');
- rtems_interrupt_disable(level);
- while ( (MCF_UART_USR(CONSOLE_PORT) & MCF_UART_USR_TXRDY) == 0 )
- continue;
- MCF_UART_UTB(CONSOLE_PORT) = c;
- while ( (MCF_UART_USR(CONSOLE_PORT) & MCF_UART_USR_TXRDY) == 0 )
- continue;
- rtems_interrupt_enable(level);
+static void _BSP_null_char(char c)
+{
+ int level;
+
+ if (c == '\n')
+ _BSP_null_char('\r');
+ rtems_interrupt_disable(level);
+ while ((MCF_UART_USR(CONSOLE_PORT) & MCF_UART_USR_TXRDY) == 0)
+ continue;
+ MCF_UART_UTB(CONSOLE_PORT) = c;
+ while ((MCF_UART_USR(CONSOLE_PORT) & MCF_UART_USR_TXRDY) == 0)
+ continue;
+ rtems_interrupt_enable(level);
}
+
BSP_output_char_function_type BSP_output_char = _BSP_null_char;
#define MAX_UART_INFO 3
@@ -47,17 +47,17 @@ BSP_output_char_function_type BSP_output_char = _BSP_null_char;
struct IntUartInfoStruct
{
- int iomode;
- volatile int uimr;
- int baud;
- int databits;
- int parity;
- int stopbits;
- int hwflow;
- int rx_in;
- int rx_out;
- char rx_buffer[RX_BUFFER_SIZE];
- void *ttyp;
+ int iomode;
+ volatile int uimr;
+ int baud;
+ int databits;
+ int parity;
+ int stopbits;
+ int hwflow;
+ int rx_in;
+ int rx_out;
+ char rx_buffer[RX_BUFFER_SIZE];
+ void *ttyp;
};
struct IntUartInfoStruct IntUartInfo[MAX_UART_INFO];
@@ -68,89 +68,84 @@ struct IntUartInfoStruct IntUartInfo[MAX_UART_INFO];
Description : This updates the hardware UART settings.
***************************************************************************/
static void
-IntUartSet(int minor, int baud, int databits, int parity, int stopbits, int hwflow)
+IntUartSet(int minor, int baud, int databits, int parity, int stopbits,
+ int hwflow)
{
- int divisor;
- uint32_t clock_speed;
- uint8_t umr1 = 0;
- uint8_t umr2 = 0;
- struct IntUartInfoStruct *info = &IntUartInfo[minor];
- int level;
-
- rtems_interrupt_disable(level);
-
-
- /* disable interrupts, clear RTS line, and disable the UARTS */
- MCF_UART_UIMR(minor) = 0;
- MCF_UART_UOP0(minor) = 1;
- MCF_UART_UCR(minor) = (MCF_UART_UCR_TX_DISABLED | MCF_UART_UCR_RX_DISABLED);
-
- /* save the current values */
- info->uimr = 0;
- info->baud = baud;
- info->databits = databits;
- info->parity = parity;
- info->stopbits = stopbits;
- info->hwflow = hwflow;
-
- clock_speed = bsp_get_CPU_clock_speed();
- /* determine the baud divisor value */
- // MRTODO
- //divisor = ((clock_speed/2) / ( 32 * baud ));
- divisor = ((clock_speed) / ( 32 * baud ));
- if ( divisor < 2 )
- divisor = 2;
-
- /* check to see if doing hardware flow control */
- if ( hwflow )
- {
- /* set hardware flow options */
- umr1 |= MCF_UART_UMR_RXRTS;
- umr2 |= MCF_UART_UMR_TXCTS;
- }
-
- /* determine the new umr values */
- umr1 |= (parity | databits);
- umr2 |= (stopbits);
-
- /* reset the uart */
- MCF_UART_UCR(minor) = MCF_UART_UCR_RESET_ERROR;
- MCF_UART_UCR(minor) = MCF_UART_UCR_RESET_RX;
- MCF_UART_UCR(minor) = MCF_UART_UCR_RESET_TX;
-
- /* reset the uart mode register and update values */
- MCF_UART_UCR(minor) = MCF_UART_UCR_RESET_MR;
- MCF_UART_UMR(minor) = umr1;
- MCF_UART_UMR(minor) = umr2;
-
- /* set the baud rate values */
- MCF_UART_UCSR(minor) = (MCF_UART_UCSR_RCS_SYS_CLK | MCF_UART_UCSR_TCS_SYS_CLK);
- MCF_UART_UBG1(minor) = (divisor & 0xff00) >> 8;
- MCF_UART_UBG2(minor) = (divisor & 0x00ff);
-
- /* enable the uart */
- MCF_UART_UCR(minor) = (MCF_UART_UCR_TX_ENABLED | MCF_UART_UCR_RX_ENABLED);
-
- /* check to see if interrupts need to be enabled */
- if ( info->iomode != TERMIOS_POLLED )
- {
- /* enable rx interrupts */
- info->uimr |= MCF_UART_UIMR_RXRDY_FU;
- MCF_UART_UIMR(minor) = info->uimr;
- }
-
- /* check to see if doing hardware flow control */
- if ( hwflow )
- {
- /* assert the RTS line */
- MCF_UART_UOP1(minor) = 1;
- }
-
- rtems_interrupt_enable(level);
+ int divisor;
+ uint32_t clock_speed;
+ uint8_t umr1 = 0;
+ uint8_t umr2 = 0;
+ struct IntUartInfoStruct *info = &IntUartInfo[minor];
+ int level;
+
+ rtems_interrupt_disable(level);
+
+ /* disable interrupts, clear RTS line, and disable the UARTS */
+ MCF_UART_UIMR(minor) = 0;
+ MCF_UART_UOP0(minor) = 1;
+ MCF_UART_UCR(minor) = (MCF_UART_UCR_TX_DISABLED | MCF_UART_UCR_RX_DISABLED);
+
+ /* save the current values */
+ info->uimr = 0;
+ info->baud = baud;
+ info->databits = databits;
+ info->parity = parity;
+ info->stopbits = stopbits;
+ info->hwflow = hwflow;
+
+ clock_speed = bsp_get_CPU_clock_speed();
+ /* determine the baud divisor value */
+ divisor = ((clock_speed) / (32 * baud));
+ if (divisor < 2)
+ divisor = 2;
+
+ /* check to see if doing hardware flow control */
+ if (hwflow) {
+ /* set hardware flow options */
+ umr1 |= MCF_UART_UMR_RXRTS;
+ umr2 |= MCF_UART_UMR_TXCTS;
+ }
+
+ /* determine the new umr values */
+ umr1 |= (parity | databits);
+ umr2 |= (stopbits);
+
+ /* reset the uart */
+ MCF_UART_UCR(minor) = MCF_UART_UCR_RESET_ERROR;
+ MCF_UART_UCR(minor) = MCF_UART_UCR_RESET_RX;
+ MCF_UART_UCR(minor) = MCF_UART_UCR_RESET_TX;
+
+ /* reset the uart mode register and update values */
+ MCF_UART_UCR(minor) = MCF_UART_UCR_RESET_MR;
+ MCF_UART_UMR(minor) = umr1;
+ MCF_UART_UMR(minor) = umr2;
+
+ /* set the baud rate values */
+ MCF_UART_UCSR(minor) =
+ (MCF_UART_UCSR_RCS_SYS_CLK | MCF_UART_UCSR_TCS_SYS_CLK);
+ MCF_UART_UBG1(minor) = (divisor & 0xff00) >> 8;
+ MCF_UART_UBG2(minor) = (divisor & 0x00ff);
+
+ /* enable the uart */
+ MCF_UART_UCR(minor) = (MCF_UART_UCR_TX_ENABLED | MCF_UART_UCR_RX_ENABLED);
+
+ /* check to see if interrupts need to be enabled */
+ if (info->iomode != TERMIOS_POLLED) {
+ /* enable rx interrupts */
+ info->uimr |= MCF_UART_UIMR_RXRDY_FU;
+ MCF_UART_UIMR(minor) = info->uimr;
+ }
+
+ /* check to see if doing hardware flow control */
+ if (hwflow) {
+ /* assert the RTS line */
+ MCF_UART_UOP1(minor) = 1;
+ }
+
+ rtems_interrupt_enable(level);
}
-
/***************************************************************************
Function : IntUartSetAttributes
@@ -160,82 +155,71 @@ IntUartSet(int minor, int baud, int databits, int parity, int stopbits, int hwfl
Note: The highest baudrate is 115200 as this stays within
an error of +/- 5% at 25MHz processor clock
***************************************************************************/
-static int
-IntUartSetAttributes(int minor, const struct termios *t)
+static int IntUartSetAttributes(int minor, const struct termios *t)
{
- /* set default index values */
- int baud = (int)19200;
- int databits = (int)MCF_UART_UMR_BC_8;
- int parity = (int)MCF_UART_UMR_PM_NONE;
- int stopbits = (int)MCF_UART_UMR_SB_STOP_BITS_1;
- int hwflow = (int)0;
- struct IntUartInfoStruct *info = &IntUartInfo[minor];
-
- /* check to see if input is valid */
- if ( t != (const struct termios *)0 )
- {
- /* determine baud rate index */
- baud = termios_baud_to_number(t->c_cflag & CBAUD);
-
- /* determine data bits */
- switch ( t->c_cflag & CSIZE )
- {
- case CS5:
- databits = (int)MCF_UART_UMR_BC_5;
- break;
- case CS6:
- databits = (int)MCF_UART_UMR_BC_6;
- break;
- case CS7:
- databits = (int)MCF_UART_UMR_BC_7;
- break;
- case CS8:
- databits = (int)MCF_UART_UMR_BC_8;
- break;
- }
-
- /* determine if parity is enabled */
- if ( t->c_cflag & PARENB )
- {
- if ( t->c_cflag & PARODD )
- {
- /* odd parity */
- parity = (int)MCF_UART_UMR_PM_ODD;
- }
- else
- {
- /* even parity */
- parity = (int)MCF_UART_UMR_PM_EVEN;
- }
- }
-
- /* determine stop bits */
- if ( t->c_cflag & CSTOPB )
- {
- /* two stop bits */
- stopbits = (int)MCF_UART_UMR_SB_STOP_BITS_2;
- }
-
- /* check to see if hardware flow control */
- if ( t->c_cflag & CRTSCTS )
- {
- hwflow = 1;
- }
- }
-
- /* check to see if values have changed */
- if ( ( baud != info->baud ) ||
- ( databits != info->databits ) ||
- ( parity != info->parity ) ||
- ( stopbits != info->stopbits ) ||
- ( hwflow != info->hwflow ) )
- {
-
- /* call function to set values */
- IntUartSet(minor, baud, databits, parity, stopbits, hwflow);
- }
-
- return( RTEMS_SUCCESSFUL );
+ /* set default index values */
+ int baud = (int) 19200;
+ int databits = (int) MCF_UART_UMR_BC_8;
+ int parity = (int) MCF_UART_UMR_PM_NONE;
+ int stopbits = (int) MCF_UART_UMR_SB_STOP_BITS_1;
+ int hwflow = (int) 0;
+ struct IntUartInfoStruct *info = &IntUartInfo[minor];
+
+ /* check to see if input is valid */
+ if (t != (const struct termios *) 0) {
+ /* determine baud rate index */
+ baud = termios_baud_to_number(t->c_cflag & CBAUD);
+
+ /* determine data bits */
+ switch (t->c_cflag & CSIZE) {
+ case CS5:
+ databits = (int) MCF_UART_UMR_BC_5;
+ break;
+ case CS6:
+ databits = (int) MCF_UART_UMR_BC_6;
+ break;
+ case CS7:
+ databits = (int) MCF_UART_UMR_BC_7;
+ break;
+ case CS8:
+ databits = (int) MCF_UART_UMR_BC_8;
+ break;
+ }
+
+ /* determine if parity is enabled */
+ if (t->c_cflag & PARENB) {
+ if (t->c_cflag & PARODD) {
+ /* odd parity */
+ parity = (int) MCF_UART_UMR_PM_ODD;
+ } else {
+ /* even parity */
+ parity = (int) MCF_UART_UMR_PM_EVEN;
+ }
+ }
+
+ /* determine stop bits */
+ if (t->c_cflag & CSTOPB) {
+ /* two stop bits */
+ stopbits = (int) MCF_UART_UMR_SB_STOP_BITS_2;
+ }
+
+ /* check to see if hardware flow control */
+ if (t->c_cflag & CRTSCTS) {
+ hwflow = 1;
+ }
+ }
+
+ /* check to see if values have changed */
+ if ((baud != info->baud) ||
+ (databits != info->databits) ||
+ (parity != info->parity) ||
+ (stopbits != info->stopbits) || (hwflow != info->hwflow)) {
+
+ /* call function to set values */
+ IntUartSet(minor, baud, databits, parity, stopbits, hwflow);
+ }
+
+ return (RTEMS_SUCCESSFUL);
}
@@ -246,71 +230,60 @@ IntUartSetAttributes(int minor, const struct termios *t)
determines which channel caused the interrupt before queueing any received
chars and dequeueing chars waiting for transmission.
***************************************************************************/
-static rtems_isr
-IntUartInterruptHandler(rtems_vector_number v)
+static rtems_isr IntUartInterruptHandler(rtems_vector_number v)
{
- unsigned int chan = v - UART_INTC0_IRQ_VECTOR(0);
- struct IntUartInfoStruct *info = &IntUartInfo[chan];
-
- /* check to see if received data */
- if ( MCF_UART_UISR(chan) & MCF_UART_UISR_RXRDY_FU )
- {
- /* read data and put into the receive buffer */
- while ( MCF_UART_USR(chan) & MCF_UART_USR_RXRDY )
- {
-
- if ( MCF_UART_USR(chan) & MCF_UART_USR_ERROR )
- {
- /* clear the error */
- MCF_UART_UCR(chan) = MCF_UART_UCR_RESET_ERROR;
- }
- /* put data in rx buffer and check for errors */
- info->rx_buffer[info->rx_in] = MCF_UART_URB(chan);
-
- /* update buffer values */
- info->rx_in++;
-
- if ( info->rx_in >= RX_BUFFER_SIZE )
- {
- info->rx_in = 0;
- }
- }
- /* Make sure the port has been opened */
- if ( info->ttyp )
- {
-
- /* check to see if task driven */
- if ( info->iomode == TERMIOS_TASK_DRIVEN )
- {
- /* notify rx task that rx buffer has data */
- rtems_termios_rxirq_occured(info->ttyp);
- }
- else
- {
- /* Push up the received data */
- rtems_termios_enqueue_raw_characters(info->ttyp, info->rx_buffer, info->rx_in);
- info->rx_in = 0;
- }
- }
- }
-
- /* check to see if data needs to be transmitted */
- if ( ( info->uimr & MCF_UART_UIMR_TXRDY ) &&
- ( MCF_UART_UISR(chan) & MCF_UART_UISR_TXRDY ) )
- {
-
- /* disable tx interrupts */
- info->uimr &= ~MCF_UART_UIMR_TXRDY;
- MCF_UART_UIMR(chan) = info->uimr;
-
- /* tell upper level that character has been sent */
- if ( info->ttyp )
- rtems_termios_dequeue_characters(info->ttyp, 1);
- }
+ unsigned int chan = v - UART_INTC0_IRQ_VECTOR(0);
+ struct IntUartInfoStruct *info = &IntUartInfo[chan];
+
+ /* check to see if received data */
+ if (MCF_UART_UISR(chan) & MCF_UART_UISR_RXRDY_FU) {
+ /* read data and put into the receive buffer */
+ while (MCF_UART_USR(chan) & MCF_UART_USR_RXRDY) {
+
+ if (MCF_UART_USR(chan) & MCF_UART_USR_ERROR) {
+ /* clear the error */
+ MCF_UART_UCR(chan) = MCF_UART_UCR_RESET_ERROR;
+ }
+ /* put data in rx buffer and check for errors */
+ info->rx_buffer[info->rx_in] = MCF_UART_URB(chan);
+
+ /* update buffer values */
+ info->rx_in++;
+
+ if (info->rx_in >= RX_BUFFER_SIZE) {
+ info->rx_in = 0;
+ }
+ }
+ /* Make sure the port has been opened */
+ if (info->ttyp) {
+
+ /* check to see if task driven */
+ if (info->iomode == TERMIOS_TASK_DRIVEN) {
+ /* notify rx task that rx buffer has data */
+ rtems_termios_rxirq_occured(info->ttyp);
+ } else {
+ /* Push up the received data */
+ rtems_termios_enqueue_raw_characters(info->ttyp, info->rx_buffer,
+ info->rx_in);
+ info->rx_in = 0;
+ }
+ }
+ }
+
+ /* check to see if data needs to be transmitted */
+ if ((info->uimr & MCF_UART_UIMR_TXRDY) &&
+ (MCF_UART_UISR(chan) & MCF_UART_UISR_TXRDY)) {
+
+ /* disable tx interrupts */
+ info->uimr &= ~MCF_UART_UIMR_TXRDY;
+ MCF_UART_UIMR(chan) = info->uimr;
+
+ /* tell upper level that character has been sent */
+ if (info->ttyp)
+ rtems_termios_dequeue_characters(info->ttyp, 1);
+ }
}
-
-
/***************************************************************************
Function : IntUartInitialize
@@ -318,71 +291,62 @@ IntUartInterruptHandler(rtems_vector_number v)
internal uarts. If the internal uart is to be interrupt driven then the
interrupt vectors are hooked.
***************************************************************************/
-static void
-IntUartInitialize(void)
+static void IntUartInitialize(void)
{
- unsigned int chan;
- struct IntUartInfoStruct *info;
- rtems_isr_entry old_handler;
- int level;
-
- for ( chan = 0; chan < MAX_UART_INFO; chan++ )
- {
- info = &IntUartInfo[chan];
-
- info->ttyp = NULL;
- info->rx_in = 0;
- info->rx_out = 0;
- info->baud = -1;
- info->databits = -1;
- info->parity = -1;
- info->stopbits = -1;
- info->hwflow = -1;
- info->iomode = TERMIOS_POLLED; /*polled console io */
-
- MCF_UART_UACR(chan) = 0;
- MCF_UART_UIMR(chan) = 0;
- if ( info->iomode != TERMIOS_POLLED )
- {
- rtems_interrupt_catch (IntUartInterruptHandler,
- UART_INTC0_IRQ_VECTOR(chan),
- &old_handler);
- }
-
- /* set uart default values */
- IntUartSetAttributes(chan, NULL);
-
- /* unmask interrupt */
- rtems_interrupt_disable(level);
- switch(chan) {
- case 0:
- MCF_INTC0_ICR13 = MCF_INTC_ICR_IL(UART0_IRQ_LEVEL) |
- MCF_INTC_ICR_IP(UART0_IRQ_PRIORITY);
- MCF_INTC0_IMRL &= ~(MCF_INTC_IMRL_MASK13 |
- MCF_INTC_IMRL_MASKALL);
- break;
-
- case 1:
- MCF_INTC0_ICR14 = MCF_INTC_ICR_IL(UART1_IRQ_LEVEL) |
- MCF_INTC_ICR_IP(UART1_IRQ_PRIORITY);
- MCF_INTC0_IMRL &= ~(MCF_INTC_IMRL_MASK14 |
- MCF_INTC_IMRL_MASKALL);
- break;
-
- case 2:
- MCF_INTC0_ICR15 = MCF_INTC_ICR_IL(UART2_IRQ_LEVEL) |
- MCF_INTC_ICR_IP(UART2_IRQ_PRIORITY);
- MCF_INTC0_IMRL &= ~(MCF_INTC_IMRL_MASK15 |
- MCF_INTC_IMRL_MASKALL);
- break;
- }
- rtems_interrupt_enable(level);
-
- } /* of chan loop */
-
-
-} /* IntUartInitialise */
-
+ unsigned int chan;
+ struct IntUartInfoStruct *info;
+ rtems_isr_entry old_handler;
+ int level;
+
+ for (chan = 0; chan < MAX_UART_INFO; chan++) {
+ info = &IntUartInfo[chan];
+
+ info->ttyp = NULL;
+ info->rx_in = 0;
+ info->rx_out = 0;
+ info->baud = -1;
+ info->databits = -1;
+ info->parity = -1;
+ info->stopbits = -1;
+ info->hwflow = -1;
+ info->iomode = TERMIOS_POLLED; /*polled console io */
+
+ MCF_UART_UACR(chan) = 0;
+ MCF_UART_UIMR(chan) = 0;
+ if (info->iomode != TERMIOS_POLLED) {
+ rtems_interrupt_catch(IntUartInterruptHandler,
+ UART_INTC0_IRQ_VECTOR(chan), &old_handler);
+ }
+
+ /* set uart default values */
+ IntUartSetAttributes(chan, NULL);
+
+ /* unmask interrupt */
+ rtems_interrupt_disable(level);
+ switch (chan) {
+ case 0:
+ MCF_INTC0_ICR13 = MCF_INTC_ICR_IL(UART0_IRQ_LEVEL) |
+ MCF_INTC_ICR_IP(UART0_IRQ_PRIORITY);
+ MCF_INTC0_IMRL &= ~(MCF_INTC_IMRL_MASK13 | MCF_INTC_IMRL_MASKALL);
+ break;
+
+ case 1:
+ MCF_INTC0_ICR14 = MCF_INTC_ICR_IL(UART1_IRQ_LEVEL) |
+ MCF_INTC_ICR_IP(UART1_IRQ_PRIORITY);
+ MCF_INTC0_IMRL &= ~(MCF_INTC_IMRL_MASK14 | MCF_INTC_IMRL_MASKALL);
+ break;
+
+ case 2:
+ MCF_INTC0_ICR15 = MCF_INTC_ICR_IL(UART2_IRQ_LEVEL) |
+ MCF_INTC_ICR_IP(UART2_IRQ_PRIORITY);
+ MCF_INTC0_IMRL &= ~(MCF_INTC_IMRL_MASK15 | MCF_INTC_IMRL_MASKALL);
+ break;
+ }
+ rtems_interrupt_enable(level);
+
+ } /* of chan loop */
+
+} /* IntUartInitialise */
/***************************************************************************
Function : IntUartInterruptWrite
@@ -392,22 +356,21 @@ IntUartInitialize(void)
to initiate a transmit sequence. Calling this routine enables Tx
interrupts.
***************************************************************************/
-static int
-IntUartInterruptWrite (int minor, const char *buf, int len)
+static int IntUartInterruptWrite(int minor, const char *buf, int len)
{
- int level;
+ int level;
- rtems_interrupt_disable(level);
+ rtems_interrupt_disable(level);
- /* write out character */
- MCF_UART_UTB(minor) = *buf;
+ /* write out character */
+ MCF_UART_UTB(minor) = *buf;
- /* enable tx interrupt */
- IntUartInfo[minor].uimr |= MCF_UART_UIMR_TXRDY;
- MCF_UART_UIMR(minor) = IntUartInfo[minor].uimr;
+ /* enable tx interrupt */
+ IntUartInfo[minor].uimr |= MCF_UART_UIMR_TXRDY;
+ MCF_UART_UIMR(minor) = IntUartInfo[minor].uimr;
- rtems_interrupt_enable(level);
- return( 0 );
+ rtems_interrupt_enable(level);
+ return (0);
}
/***************************************************************************
@@ -415,55 +378,49 @@ IntUartInterruptWrite (int minor, const char *buf, int len)
Description : This enables interrupts when the tty is opened.
***************************************************************************/
-static int
-IntUartInterruptOpen(int major, int minor, void *arg)
+static int IntUartInterruptOpen(int major, int minor, void *arg)
{
- struct IntUartInfoStruct *info = &IntUartInfo[minor];
-
- /* enable the uart */
- MCF_UART_UCR(minor) = (MCF_UART_UCR_TX_ENABLED | MCF_UART_UCR_RX_ENABLED);
-
- /* check to see if interrupts need to be enabled */
- if ( info->iomode != TERMIOS_POLLED )
- {
- /* enable rx interrupts */
- info->uimr |= MCF_UART_UIMR_RXRDY_FU;
- MCF_UART_UIMR(minor) = info->uimr;
- }
-
- /* check to see if doing hardware flow control */
- if ( info->hwflow )
- {
- /* assert the RTS line */
- MCF_UART_UOP1(minor) = 1;
- }
-
- return( 0 );
-}
+ struct IntUartInfoStruct *info = &IntUartInfo[minor];
+ /* enable the uart */
+ MCF_UART_UCR(minor) = (MCF_UART_UCR_TX_ENABLED | MCF_UART_UCR_RX_ENABLED);
+ /* check to see if interrupts need to be enabled */
+ if (info->iomode != TERMIOS_POLLED) {
+ /* enable rx interrupts */
+ info->uimr |= MCF_UART_UIMR_RXRDY_FU;
+ MCF_UART_UIMR(minor) = info->uimr;
+ }
+
+ /* check to see if doing hardware flow control */
+ if (info->hwflow) {
+ /* assert the RTS line */
+ MCF_UART_UOP1(minor) = 1;
+ }
+
+ return (0);
+}
/***************************************************************************
Function : IntUartInterruptClose
Description : This disables interrupts when the tty is closed.
***************************************************************************/
-static int
-IntUartInterruptClose(int major, int minor, void *arg)
+static int IntUartInterruptClose(int major, int minor, void *arg)
{
- struct IntUartInfoStruct *info = &IntUartInfo[minor];
+ struct IntUartInfoStruct *info = &IntUartInfo[minor];
- /* disable the interrupts and the uart */
- MCF_UART_UIMR(minor) = 0;
- MCF_UART_UCR(minor) = (MCF_UART_UCR_TX_DISABLED | MCF_UART_UCR_RX_DISABLED);
+ /* disable the interrupts and the uart */
+ MCF_UART_UIMR(minor) = 0;
+ MCF_UART_UCR(minor) = (MCF_UART_UCR_TX_DISABLED | MCF_UART_UCR_RX_DISABLED);
- /* reset values */
- info->ttyp = NULL;
- info->uimr = 0;
- info->rx_in = 0;
- info->rx_out = 0;
+ /* reset values */
+ info->ttyp = NULL;
+ info->uimr = 0;
+ info->rx_in = 0;
+ info->rx_out = 0;
- return( 0 );
+ return (0);
}
/***************************************************************************
@@ -473,69 +430,58 @@ IntUartInterruptClose(int major, int minor, void *arg)
and places them into the termios buffer. The rx interrupts will be
re-enabled after all data has been read.
***************************************************************************/
-static int
-IntUartTaskRead(int minor)
+static int IntUartTaskRead(int minor)
{
- char buffer[RX_BUFFER_SIZE];
- int count;
- int rx_in;
- int index = 0;
- struct IntUartInfoStruct *info = &IntUartInfo[minor];
-
- /* determine number of values to copy out */
- rx_in = info->rx_in;
- if ( info->rx_out <= rx_in )
- {
- count = rx_in - info->rx_out;
- }
- else
- {
- count = (RX_BUFFER_SIZE - info->rx_out) + rx_in;
- }
-
- /* copy data into local buffer from rx buffer */
- while ( ( index < count ) && ( index < RX_BUFFER_SIZE ) )
- {
- /* copy data byte */
- buffer[index] = info->rx_buffer[info->rx_out];
- index++;
-
- /* increment rx buffer values */
- info->rx_out++;
- if ( info->rx_out >= RX_BUFFER_SIZE )
- {
- info->rx_out = 0;
- }
- }
-
- /* check to see if buffer is not empty */
- if ( count > 0 )
- {
- /* set characters into termios buffer */
- rtems_termios_enqueue_raw_characters(info->ttyp, buffer, count);
- }
-
- return( EOF );
+ char buffer[RX_BUFFER_SIZE];
+ int count;
+ int rx_in;
+ int index = 0;
+ struct IntUartInfoStruct *info = &IntUartInfo[minor];
+
+ /* determine number of values to copy out */
+ rx_in = info->rx_in;
+ if (info->rx_out <= rx_in) {
+ count = rx_in - info->rx_out;
+ } else {
+ count = (RX_BUFFER_SIZE - info->rx_out) + rx_in;
+ }
+
+ /* copy data into local buffer from rx buffer */
+ while ((index < count) && (index < RX_BUFFER_SIZE)) {
+ /* copy data byte */
+ buffer[index] = info->rx_buffer[info->rx_out];
+ index++;
+
+ /* increment rx buffer values */
+ info->rx_out++;
+ if (info->rx_out >= RX_BUFFER_SIZE) {
+ info->rx_out = 0;
+ }
+ }
+
+ /* check to see if buffer is not empty */
+ if (count > 0) {
+ /* set characters into termios buffer */
+ rtems_termios_enqueue_raw_characters(info->ttyp, buffer, count);
+ }
+
+ return (EOF);
}
-
-
/***************************************************************************
Function : IntUartPollRead
Description : This reads a character from the internal uart. It returns
to the caller without blocking if not character is waiting.
***************************************************************************/
-static int
-IntUartPollRead (int minor)
+static int IntUartPollRead(int minor)
{
- if ( (MCF_UART_USR(minor) & MCF_UART_USR_RXRDY) == 0 )
- return(-1);
+ if ((MCF_UART_USR(minor) & MCF_UART_USR_RXRDY) == 0)
+ return (-1);
- return(MCF_UART_URB(minor));
+ return (MCF_UART_URB(minor));
}
-
/***************************************************************************
Function : IntUartPollWrite
@@ -543,69 +489,59 @@ IntUartPollRead (int minor)
appropriate internal uart channel waiting till each one is sucessfully
transmitted.
***************************************************************************/
-static int
-IntUartPollWrite (int minor, const char *buf, int len)
+static int IntUartPollWrite(int minor, const char *buf, int len)
{
- /* loop over buffer */
- while ( len-- )
- {
- /* block until we can transmit */
- while ( (MCF_UART_USR(minor) & MCF_UART_USR_TXRDY) == 0 )
- continue;
- /* transmit data byte */
- MCF_UART_UTB(minor) = *buf++;
- }
- return(0);
+ /* loop over buffer */
+ while (len--) {
+ /* block until we can transmit */
+ while ((MCF_UART_USR(minor) & MCF_UART_USR_TXRDY) == 0)
+ continue;
+ /* transmit data byte */
+ MCF_UART_UTB(minor) = *buf++;
+ }
+ return (0);
}
-
/***************************************************************************
Function : console_initialize
Description : This initialises termios, both sets of uart hardware before
registering /dev/tty devices for each channel and the system /dev/console.
***************************************************************************/
-rtems_device_driver console_initialize(
- rtems_device_major_number major,
- rtems_device_minor_number minor,
- void *arg )
+rtems_device_driver console_initialize(rtems_device_major_number major,
+ rtems_device_minor_number minor,
+ void *arg)
{
- rtems_status_code status;
-
-
- /* Set up TERMIOS */
- rtems_termios_initialize ();
-
- /* set io modes for the different channels and initialize device */
- IntUartInfo[minor].iomode = TERMIOS_IRQ_DRIVEN;
- IntUartInitialize();
-
- /* Register the console port */
- status = rtems_io_register_name ("/dev/console", major, CONSOLE_PORT);
- if ( status != RTEMS_SUCCESSFUL )
- {
- rtems_fatal_error_occurred (status);
- }
-
- /* Register the other port */
- if ( CONSOLE_PORT != 0 )
- {
- status = rtems_io_register_name ("/dev/tty00", major, 0);
- if ( status != RTEMS_SUCCESSFUL )
- {
- rtems_fatal_error_occurred (status);
- }
- }
- if ( CONSOLE_PORT != 1 )
- {
- status = rtems_io_register_name ("/dev/tty01", major, 1);
- if ( status != RTEMS_SUCCESSFUL )
- {
- rtems_fatal_error_occurred (status);
- }
- }
-
- return(RTEMS_SUCCESSFUL);
+ rtems_status_code status;
+
+ /* Set up TERMIOS */
+ rtems_termios_initialize();
+
+ /* set io modes for the different channels and initialize device */
+ IntUartInfo[minor].iomode = TERMIOS_IRQ_DRIVEN;
+ IntUartInitialize();
+
+ /* Register the console port */
+ status = rtems_io_register_name("/dev/console", major, CONSOLE_PORT);
+ if (status != RTEMS_SUCCESSFUL) {
+ rtems_fatal_error_occurred(status);
+ }
+
+ /* Register the other port */
+ if (CONSOLE_PORT != 0) {
+ status = rtems_io_register_name("/dev/tty00", major, 0);
+ if (status != RTEMS_SUCCESSFUL) {
+ rtems_fatal_error_occurred(status);
+ }
+ }
+ if (CONSOLE_PORT != 1) {
+ status = rtems_io_register_name("/dev/tty01", major, 1);
+ if (status != RTEMS_SUCCESSFUL) {
+ rtems_fatal_error_occurred(status);
+ }
+ }
+
+ return (RTEMS_SUCCESSFUL);
}
/***************************************************************************
@@ -616,82 +552,77 @@ rtems_device_driver console_initialize(
passed to termios when the devices is opened depending on whether it is
polled or not.
***************************************************************************/
-rtems_device_driver console_open(
- rtems_device_major_number major,
- rtems_device_minor_number minor,
- void * arg)
+rtems_device_driver console_open(rtems_device_major_number major,
+ rtems_device_minor_number minor, void *arg)
{
- rtems_status_code status = RTEMS_INVALID_NUMBER;
- rtems_libio_open_close_args_t *args = (rtems_libio_open_close_args_t *)arg;
- struct IntUartInfoStruct *info;
-
- static const rtems_termios_callbacks IntUartPollCallbacks = {
- NULL, /* firstOpen */
- NULL, /* lastClose */
- IntUartPollRead, /* pollRead */
- IntUartPollWrite, /* write */
- IntUartSetAttributes, /* setAttributes */
- NULL, /* stopRemoteTx */
- NULL, /* startRemoteTx */
- TERMIOS_POLLED /* mode */
- };
- static const rtems_termios_callbacks IntUartIntrCallbacks = {
- IntUartInterruptOpen, /* firstOpen */
- IntUartInterruptClose, /* lastClose */
- NULL, /* pollRead */
- IntUartInterruptWrite, /* write */
- IntUartSetAttributes, /* setAttributes */
- NULL, /* stopRemoteTx */
- NULL, /* startRemoteTx */
- TERMIOS_IRQ_DRIVEN /* mode */
- };
-
- static const rtems_termios_callbacks IntUartTaskCallbacks = {
- IntUartInterruptOpen, /* firstOpen */
- IntUartInterruptClose, /* lastClose */
- IntUartTaskRead, /* pollRead */
- IntUartInterruptWrite, /* write */
- IntUartSetAttributes, /* setAttributes */
- NULL, /* stopRemoteTx */
- NULL, /* startRemoteTx */
- TERMIOS_TASK_DRIVEN /* mode */
- };
-
- /* open the port depending on the minor device number */
- if ( ( minor >= 0 ) && ( minor < MAX_UART_INFO ) )
- {
- info = &IntUartInfo[minor];
- switch ( info->iomode )
- {
- case TERMIOS_POLLED:
- status = rtems_termios_open(major, minor, arg, &IntUartPollCallbacks);
- break;
- case TERMIOS_IRQ_DRIVEN:
- status = rtems_termios_open(major, minor, arg, &IntUartIntrCallbacks);
- info->ttyp = args->iop->data1;
- break;
- case TERMIOS_TASK_DRIVEN:
- status = rtems_termios_open(major, minor, arg, &IntUartTaskCallbacks);
- info->ttyp = args->iop->data1;
- break;
- }
- }
-
- if (status == RTEMS_SUCCESSFUL)
- {
- /*
- * Reset the default baudrate.
- */
- struct termios term;
- if (tcgetattr (STDIN_FILENO, &term) >= 0)
- {
- term.c_cflag &= ~(CBAUD | CSIZE);
- term.c_cflag |= CS8 | B19200;
- tcsetattr (STDIN_FILENO, TCSANOW, &term);
- }
- }
-
- return( status );
+ rtems_status_code status = RTEMS_INVALID_NUMBER;
+ rtems_libio_open_close_args_t *args = (rtems_libio_open_close_args_t *) arg;
+ struct IntUartInfoStruct *info;
+
+ static const rtems_termios_callbacks IntUartPollCallbacks = {
+ NULL, /* firstOpen */
+ NULL, /* lastClose */
+ IntUartPollRead, /* pollRead */
+ IntUartPollWrite, /* write */
+ IntUartSetAttributes, /* setAttributes */
+ NULL, /* stopRemoteTx */
+ NULL, /* startRemoteTx */
+ TERMIOS_POLLED /* mode */
+ };
+ static const rtems_termios_callbacks IntUartIntrCallbacks = {
+ IntUartInterruptOpen, /* firstOpen */
+ IntUartInterruptClose, /* lastClose */
+ NULL, /* pollRead */
+ IntUartInterruptWrite, /* write */
+ IntUartSetAttributes, /* setAttributes */
+ NULL, /* stopRemoteTx */
+ NULL, /* startRemoteTx */
+ TERMIOS_IRQ_DRIVEN /* mode */
+ };
+
+ static const rtems_termios_callbacks IntUartTaskCallbacks = {
+ IntUartInterruptOpen, /* firstOpen */
+ IntUartInterruptClose, /* lastClose */
+ IntUartTaskRead, /* pollRead */
+ IntUartInterruptWrite, /* write */
+ IntUartSetAttributes, /* setAttributes */
+ NULL, /* stopRemoteTx */
+ NULL, /* startRemoteTx */
+ TERMIOS_TASK_DRIVEN /* mode */
+ };
+
+ /* open the port depending on the minor device number */
+ if ((minor >= 0) && (minor < MAX_UART_INFO)) {
+ info = &IntUartInfo[minor];
+ switch (info->iomode) {
+ case TERMIOS_POLLED:
+ status = rtems_termios_open(major, minor, arg, &IntUartPollCallbacks);
+ break;
+ case TERMIOS_IRQ_DRIVEN:
+ status = rtems_termios_open(major, minor, arg, &IntUartIntrCallbacks);
+ info->ttyp = args->iop->data1;
+ break;
+ case TERMIOS_TASK_DRIVEN:
+ status = rtems_termios_open(major, minor, arg, &IntUartTaskCallbacks);
+ info->ttyp = args->iop->data1;
+ break;
+ }
+ }
+
+ if (status == RTEMS_SUCCESSFUL) {
+ /*
+ * Reset the default baudrate.
+ */
+ struct termios term;
+
+ if (tcgetattr(STDIN_FILENO, &term) >= 0) {
+ term.c_cflag &= ~(CBAUD | CSIZE);
+ term.c_cflag |= CS8 | B19200;
+ tcsetattr(STDIN_FILENO, TCSANOW, &term);
+ }
+ }
+
+ return (status);
}
/***************************************************************************
@@ -699,12 +630,10 @@ rtems_device_driver console_open(
Description : This closes the device via termios
***************************************************************************/
-rtems_device_driver console_close(
- rtems_device_major_number major,
- rtems_device_minor_number minor,
- void * arg)
+rtems_device_driver console_close(rtems_device_major_number major,
+ rtems_device_minor_number minor, void *arg)
{
- return(rtems_termios_close (arg));
+ return (rtems_termios_close(arg));
}
/******************
@@ -713,12 +642,10 @@ rtems_device_driver console_close(
Description : Read from the device via termios
***************************************************************************/
-rtems_device_driver console_read(
- rtems_device_major_number major,
- rtems_device_minor_number minor,
- void * arg)
+rtems_device_driver console_read(rtems_device_major_number major,
+ rtems_device_minor_number minor, void *arg)
{
- return(rtems_termios_read (arg));
+ return (rtems_termios_read(arg));
}
/***************************************************************************
@@ -726,12 +653,10 @@ rtems_device_driver console_read(
Description : Write to the device via termios
***************************************************************************/
-rtems_device_driver console_write(
- rtems_device_major_number major,
- rtems_device_minor_number minor,
- void * arg)
+rtems_device_driver console_write(rtems_device_major_number major,
+ rtems_device_minor_number minor, void *arg)
{
- return(rtems_termios_write (arg));
+ return (rtems_termios_write(arg));
}
/***************************************************************************
@@ -739,30 +664,30 @@ rtems_device_driver console_write(
Description : Pass the IOCtl call to termios
***************************************************************************/
-rtems_device_driver console_control(
- rtems_device_major_number major,
- rtems_device_minor_number minor,
- void * arg)
+rtems_device_driver console_control(rtems_device_major_number major,
+ rtems_device_minor_number minor,
+ void *arg)
{
- return( rtems_termios_ioctl (arg) );
+ return (rtems_termios_ioctl(arg));
}
int DEBUG_OUTCHAR(int c)
{
- if(c == '\n')
- DEBUG_OUTCHAR('\r');
- _BSP_null_char(c);
- return c;
+ if (c == '\n')
+ DEBUG_OUTCHAR('\r');
+ _BSP_null_char(c);
+ return c;
}
void DEBUG_OUTSTR(const char *msg)
{
- while (*msg)
- DEBUG_OUTCHAR(*msg++);
+ while (*msg)
+ DEBUG_OUTCHAR(*msg++);
}
void DEBUG_OUTNUM(int i)
{
- int n;
- static const char map[] = "0123456789ABCDEF";
- DEBUG_OUTCHAR(' ');
- for (n = 28 ; n >= 0 ; n -= 4)
- DEBUG_OUTCHAR(map[(i >> n) & 0xF]);
+ int n;
+ static const char map[] = "0123456789ABCDEF";
+
+ DEBUG_OUTCHAR(' ');
+ for (n = 28; n >= 0; n -= 4)
+ DEBUG_OUTCHAR(map[(i >> n) & 0xF]);
}
diff --git a/c/src/lib/libbsp/m68k/mcf52235/gdb-init b/c/src/lib/libbsp/m68k/mcf52235/gdb-init
index fc86b13e35..cb94382b4d 100644
--- a/c/src/lib/libbsp/m68k/mcf52235/gdb-init
+++ b/c/src/lib/libbsp/m68k/mcf52235/gdb-init
@@ -24,10 +24,12 @@ define show-exception-sframe
end
# Add -v and -d flags for bdm info
+# Add -B flags to utilize hardware breakpoints when they are availiable
+
#target remote | m68k-bdm-gdbserver pipe /dev/bdmcf0
target remote | m68k-bdm-gdbserver pipe /dev/tblcf2 -B
-
#monitor set remote-debug 1
+
monitor bdm-reset
# Set VBR to the beginning of what will be SRAM
@@ -42,5 +44,5 @@ monitor bdm-ctl-set 0x0C04 0x00000061
# Enable PST[3:0] signals
set *((char*) 0x40100074) = 0x0F
-# Add the load when debugging from ram, should never happen with rtems
+# Add the load when debugging from ram which won't happen with rtems!
#load
diff --git a/c/src/lib/libbsp/m68k/mcf52235/include/bsp.h b/c/src/lib/libbsp/m68k/mcf52235/include/bsp.h
index 307f0f5325..42aa4b3eb5 100644
--- a/c/src/lib/libbsp/m68k/mcf52235/include/bsp.h
+++ b/c/src/lib/libbsp/m68k/mcf52235/include/bsp.h
@@ -19,16 +19,13 @@ extern "C" {
/***************************************************************************/
/** Hardware data structure headers **/
-#include <mcf52235/mcf52235.h> /* internal MCF52235 modules */
+#include <mcf5223x/mcf5223x.h>
+
+/* Declare base address of peripherals area */
+#define __IPSBAR ((vuint8 *) 0x40000000)
/***************************************************************************/
/** Network driver configuration **/
-#if 0
-struct rtems_bsdnet_ifconfig;
-extern int rtems_fec_driver_attach (struct rtems_bsdnet_ifconfig *config, int attaching );
-#define RTEMS_BSP_NETWORK_DRIVER_NAME "fs1"
-#define RTEMS_BSP_NETWORK_DRIVER_ATTACH rtems_fec_driver_attach
-#endif
/***************************************************************************/
/** User Definable configuration **/
@@ -58,7 +55,9 @@ extern int rtems_fec_driver_attach (struct rtems_bsdnet_ifconfig *config, int at
/* functions */
uint32_t bsp_get_CPU_clock_speed(void);
+
void bsp_cleanup(void);
+
m68k_isr_entry set_vector(
rtems_isr_entry handler,
rtems_vector_number vector,
@@ -69,9 +68,6 @@ m68k_isr_entry set_vector(
* Interrupt assignments
* Highest-priority listed first
*/
-#define FEC_IRQ_LEVEL 4
-#define FEC_IRQ_RX_PRIORITY 7
-#define FEC_IRQ_TX_PRIORITY 6
#define PIT3_IRQ_LEVEL 4
#define PIT3_IRQ_PRIORITY 0
diff --git a/c/src/lib/libbsp/m68k/mcf52235/include/coverhd.h b/c/src/lib/libbsp/m68k/mcf52235/include/coverhd.h
index a0aaa20535..8dec5878ba 100644
--- a/c/src/lib/libbsp/m68k/mcf52235/include/coverhd.h
+++ b/c/src/lib/libbsp/m68k/mcf52235/include/coverhd.h
@@ -40,17 +40,17 @@
#define CALLING_OVERHEAD_TASK_MODE 0
#define CALLING_OVERHEAD_TASK_GET_NOTE 0
#define CALLING_OVERHEAD_TASK_SET_NOTE 0
-#define CALLING_OVERHEAD_TASK_WAKE_WHEN 1
+#define CALLING_OVERHEAD_TASK_WAKE_WHEN 0
#define CALLING_OVERHEAD_TASK_WAKE_AFTER 0
#define CALLING_OVERHEAD_INTERRUPT_CATCH 0
-#define CALLING_OVERHEAD_CLOCK_GET 1
-#define CALLING_OVERHEAD_CLOCK_SET 1
+#define CALLING_OVERHEAD_CLOCK_GET 0
+#define CALLING_OVERHEAD_CLOCK_SET 0
#define CALLING_OVERHEAD_CLOCK_TICK 0
#define CALLING_OVERHEAD_TIMER_CREATE 0
#define CALLING_OVERHEAD_TIMER_IDENT 0
#define CALLING_OVERHEAD_TIMER_DELETE 0
-#define CALLING_OVERHEAD_TIMER_FIRE_AFTER 1
+#define CALLING_OVERHEAD_TIMER_FIRE_AFTER 0
#define CALLING_OVERHEAD_TIMER_FIRE_WHEN 1
#define CALLING_OVERHEAD_TIMER_RESET 0
#define CALLING_OVERHEAD_TIMER_CANCEL 0
diff --git a/c/src/lib/libbsp/m68k/mcf52235/start/start.S b/c/src/lib/libbsp/m68k/mcf52235/start/start.S
index ff4e7dc8c2..386924c0d3 100644
--- a/c/src/lib/libbsp/m68k/mcf52235/start/start.S
+++ b/c/src/lib/libbsp/m68k/mcf52235/start/start.S
@@ -31,7 +31,7 @@ SYM(_INTERRUPT_VECTOR):
.long SYM(_uhoh) /* 02 Access Error */
.long SYM(_uhoh) /* 03 Address Error */
.long SYM(_uhoh) /* 04 Illegal Instruction */
- .long SYM(_uhoh) /* 05 Reserved */
+ .long SYM(_uhoh) /* 05 Divide by Zero */
.long SYM(_uhoh) /* 06 Reserved */
.long SYM(_uhoh) /* 07 Reserved */
.long SYM(_uhoh) /* 08 Privilege Violation */
@@ -41,7 +41,7 @@ SYM(_INTERRUPT_VECTOR):
.long SYM(_uhoh) /* 12 Debug Interrupt */
.long SYM(_uhoh) /* 13 Reserved */
.long SYM(_uhoh) /* 14 Format Error */
- .long SYM(_uhoh) /* 15 Unitialized Int. */
+ .long SYM(_uhoh) /* 15 Reserved */
.long SYM(_uhoh) /* 16 Reserved */
.long SYM(_uhoh) /* 17 Reserved */
.long SYM(_uhoh) /* 18 Reserved */
@@ -51,13 +51,13 @@ SYM(_INTERRUPT_VECTOR):
.long SYM(_uhoh) /* 22 Reserved */
.long SYM(_uhoh) /* 23 Reserved */
.long SYM(_spuriousInterrupt) /* 24 Spurious Interrupt */
- .long SYM(_uhoh) /* 25 Autovector Level 1 */
- .long SYM(_uhoh) /* 26 Autovector Level 2 */
- .long SYM(_uhoh) /* 27 Autovector Level 3 */
- .long SYM(_uhoh) /* 28 Autovector Level 4 */
- .long SYM(_uhoh) /* 29 Autovector Level 5 */
- .long SYM(_uhoh) /* 30 Autovector Level 6 */
- .long SYM(_uhoh) /* 31 Autovector Level 7 */
+ .long SYM(_uhoh) /* 25 Reserved */
+ .long SYM(_uhoh) /* 26 Reserved */
+ .long SYM(_uhoh) /* 27 Reserved */
+ .long SYM(_uhoh) /* 28 Reserved */
+ .long SYM(_uhoh) /* 29 Reserved */
+ .long SYM(_uhoh) /* 30 Reserved */
+ .long SYM(_uhoh) /* 31 Reserved */
.long SYM(_uhoh) /* 32 TRAP #0 */
.long SYM(_uhoh) /* 33 TRAP #1 */
.long SYM(_uhoh) /* 34 TRAP #2 */
@@ -314,17 +314,6 @@ _cfm_msec: .long 0x00000000
.align 4
PUBLIC (_uhoh)
SYM(_uhoh):
-/*
- link a6,#0
- lea -20(sp), sp
- movem.l d0-d2/a0-a1, (sp)
- pea.l 20(sp) | push exception frame address
- jsr mcf5xxx_exception_handler
- movem.l 4(sp), d0-d2/a0-a1
- lea 24(sp), sp
- unlk a6
- rte
-*/
nop | Leave spot for breakpoint
stop #0x2700 | Stop with interrupts disabled
bra.w SYM(_uhoh) | Stuck forever
diff --git a/c/src/lib/libbsp/m68k/mcf52235/startup/bspclean.c b/c/src/lib/libbsp/m68k/mcf52235/startup/bspclean.c
index 7bddc13392..75d0a0c569 100644
--- a/c/src/lib/libbsp/m68k/mcf52235/startup/bspclean.c
+++ b/c/src/lib/libbsp/m68k/mcf52235/startup/bspclean.c
@@ -22,13 +22,11 @@
#include <bsp.h>
#include <rtems/bspIo.h>
-void bsp_cleanup( void )
+void bsp_cleanup(void)
{
- printk("\nRTEMS exited!\n");
- for ( ;; )
- {
- asm volatile ( " nop " );
- asm volatile ( " nop " );
- }
-
+ printk("\nRTEMS exited!\n");
+ for (;;) {
+ asm volatile (" nop ");
+ asm volatile (" nop ");
+ }
}
diff --git a/c/src/lib/libbsp/m68k/mcf52235/startup/bspstart.c b/c/src/lib/libbsp/m68k/mcf52235/startup/bspstart.c
index bb57277dc7..2ce509c7fc 100644
--- a/c/src/lib/libbsp/m68k/mcf52235/startup/bspstart.c
+++ b/c/src/lib/libbsp/m68k/mcf52235/startup/bspstart.c
@@ -54,11 +54,11 @@ void _CPU_cache_invalidate_1_data_line(const void *addr) {}
*
* This routine does the bulk of the system initialisation.
*/
-void bsp_start( void )
+void bsp_start(void)
{
}
uint32_t bsp_get_CPU_clock_speed(void)
{
- return 60000000;
+ return 60000000;
}
diff --git a/c/src/lib/libbsp/m68k/mcf52235/startup/linkcmds b/c/src/lib/libbsp/m68k/mcf52235/startup/linkcmds
index 1f3343f69f..a61e000a59 100644
--- a/c/src/lib/libbsp/m68k/mcf52235/startup/linkcmds
+++ b/c/src/lib/libbsp/m68k/mcf52235/startup/linkcmds
@@ -21,7 +21,6 @@ _HeapSize = DEFINED(_HeapSize) ? _HeapSize : 0x0;
_StackSize = DEFINED(_StackSize) ? _StackSize : 0x400;
_FlashBase = DEFINED(_FlashBase) ? _FlashBase : 0x00000000;
-__IPSBAR = DEFINED(__IPSBAR) ? __IPSBAR : 0x40000000;
_VBR = 0x20000000;
ENTRY(start)
@@ -143,21 +142,23 @@ SECTIONS
.bss :
{
- _clear_start = .;
+ PROVIDE (_clear_start = .);
*(.bss*)
*(COMMON)
. = ALIGN (16);
PROVIDE (_end = .);
+ PROVIDE (_clear_end = .);
+ } >sram
+ .stack :
+ {
/*
* Starting Stack
*/
. += _StackSize;
. = ALIGN (16);
PROVIDE(_StackInit = .);
-
- _clear_end = .;
- _WorkspaceBase = .;
+ PROVIDE(_WorkspaceBase = .);
} >sram
/* Stabs debugging sections. */
diff --git a/c/src/lib/libbsp/m68k/mcf52235/timer/timer.c b/c/src/lib/libbsp/m68k/mcf52235/timer/timer.c
index fbf075028a..3e3f9befe5 100644
--- a/c/src/lib/libbsp/m68k/mcf52235/timer/timer.c
+++ b/c/src/lib/libbsp/m68k/mcf52235/timer/timer.c
@@ -16,43 +16,32 @@
#include <rtems.h>
#include <bsp.h>
-typedef volatile unsigned char vuint8;
-typedef volatile unsigned short vuint16;
-typedef volatile unsigned long vuint32;
-
-/* Declare base address of peripherals area */
-#define __IPSBAR ((vuint8 *) 0x40000000)
-
-void
-Timer_initialize(void)
+void Timer_initialize(void)
{
- uint32_t preScaleDivisor = bsp_get_CPU_clock_speed() / 1000000;
- MCF_DTIM3_DTMR = 0;
- MCF_DTIM3_DTMR = MCF_DTIM_DTMR_PS(preScaleDivisor - 1) |
- MCF_DTIM_DTMR_CLK_DIV1 |
- MCF_DTIM_DTMR_RST;
+ uint32_t preScaleDivisor = bsp_get_CPU_clock_speed() / 1000000;
+
+ MCF_DTIM3_DTMR = 0;
+ MCF_DTIM3_DTMR = MCF_DTIM_DTMR_PS(preScaleDivisor - 1) |
+ MCF_DTIM_DTMR_CLK_DIV1 | MCF_DTIM_DTMR_RST;
}
/*
* Return timer value in microsecond units
*/
-int
-Read_timer(void)
+int Read_timer(void)
{
- return MCF_DTIM3_DTCN;
+ return MCF_DTIM3_DTCN;
}
/*
* Empty function call used in loops to measure basic cost of looping
* in Timing Test Suite.
*/
-rtems_status_code
-Empty_function(void)
+rtems_status_code Empty_function(void)
{
- return RTEMS_SUCCESSFUL;
+ return RTEMS_SUCCESSFUL;
}
-void
-Set_find_average_overhead(rtems_boolean find_flag)
+void Set_find_average_overhead(rtems_boolean find_flag)
{
}