summaryrefslogtreecommitdiffstats
path: root/c/src/lib/libbsp/powerpc/mbx8xx
diff options
context:
space:
mode:
authorJoel Sherrill <joel.sherrill@OARcorp.com>2000-08-25 17:24:49 +0000
committerJoel Sherrill <joel.sherrill@OARcorp.com>2000-08-25 17:24:49 +0000
commit00ff4cd6ac02a24f2c18d12a283edfc2144ef8a4 (patch)
tree8a38d4346d94d491f13d4bed8012f1fe2f3fea24 /c/src/lib/libbsp/powerpc/mbx8xx
parent2000-08-11 Charles-Antoine Gauthier <charles.gauthier@nrc.ca> (diff)
downloadrtems-00ff4cd6ac02a24f2c18d12a283edfc2144ef8a4.tar.bz2
2000-08-11 Charles-Antoine Gauthier <charles.gauthier@nrc.ca>
* README: * console/console.c: * include/bsp.h: * network/network.c: * startup/bspstart.c: Add support for configuration parameters in NVRAM
Diffstat (limited to 'c/src/lib/libbsp/powerpc/mbx8xx')
-rw-r--r--c/src/lib/libbsp/powerpc/mbx8xx/ChangeLog9
-rw-r--r--c/src/lib/libbsp/powerpc/mbx8xx/README211
-rw-r--r--c/src/lib/libbsp/powerpc/mbx8xx/console/console.c408
-rw-r--r--c/src/lib/libbsp/powerpc/mbx8xx/include/bsp.h29
-rw-r--r--c/src/lib/libbsp/powerpc/mbx8xx/network/network.c55
-rw-r--r--c/src/lib/libbsp/powerpc/mbx8xx/startup/bspstart.c20
6 files changed, 572 insertions, 160 deletions
diff --git a/c/src/lib/libbsp/powerpc/mbx8xx/ChangeLog b/c/src/lib/libbsp/powerpc/mbx8xx/ChangeLog
index 4157ef78f3..c9e49d5d8a 100644
--- a/c/src/lib/libbsp/powerpc/mbx8xx/ChangeLog
+++ b/c/src/lib/libbsp/powerpc/mbx8xx/ChangeLog
@@ -1,5 +1,14 @@
2000-08-11 Charles-Antoine Gauthier <charles.gauthier@nrc.ca>
+ * README:
+ * console/console.c:
+ * include/bsp.h:
+ * network/network.c:
+ * startup/bspstart.c:
+ Add support for configuration parameters in NVRAM
+
+2000-08-11 Charles-Antoine Gauthier <charles.gauthier@nrc.ca>
+
* console/console.c: Fix polled input.
2000-08-10 Charles-Antoine Gauthier <charles.gauthier@nrc.ca>
diff --git a/c/src/lib/libbsp/powerpc/mbx8xx/README b/c/src/lib/libbsp/powerpc/mbx8xx/README
index 58e1690075..ac8043baa9 100644
--- a/c/src/lib/libbsp/powerpc/mbx8xx/README
+++ b/c/src/lib/libbsp/powerpc/mbx8xx/README
@@ -1,16 +1,24 @@
+#
+# $Id$
+#
+
This is a README file for the MBX860/MBX821 port of RTEMS 4.5.0
Please send any comments, improvements, or bug reports to:
-Darlene A. Stewart
+Charles-Antoine Gauthier
+charles.gauthier@nrc.ca
+
+or
+
+Darlene Stewart
+Darlene.Stewart@nrc.ca
+
Software Engineering Group
Institute for Information Technology
National Research Council of Canada
Ottawa, ON, K1A 0R6
-Canada
-
-Darlene.Stewart@nrc.ca
-
+Canada
Disclaimer
@@ -124,10 +132,10 @@ On-chip resources:
Board description
-----------------
-Clock rate: 50MHz Entry level boards, 40 MHz others.
-Bus width: 8/32 bit Flash, 32 bit DRAM
-FLASH: 2-4MB, 120ns
-RAM: 4-16MB EDO, 60ns DRAM DIMM
+Clock rate: 50MHz Entry level boards, 40 MHz others.
+Bus width: 8/32 bit Flash, 32 bit DRAM
+FLASH: 2-4MB, 120ns
+RAM: 4-16MB EDO, 60ns DRAM DIMM
Installation
@@ -165,11 +173,12 @@ Port Description
Console driver
---------------
-This BSP includes an termios-capable asynchronous serial line driver
-that supports SMC1, SMC2, SCC2, and SCC3 and SCC4 if present. The RTEMS
-console is selected in rtems/make/custom/mbx8xx.cfg with the
-CONSOLE_MINOR variable. We normally run with the RTEMS application
-console on SMC2. SMC1 is used by the debugger.
+This BSP includes an termios-capable asynchronous serial line driver that
+supports SMC1, SMC2, SCC2, and SCC3 and SCC4 if present. The RTEMS console is
+selected in rtems/make/custom/mbx8xx.cfg with the CONSOLE_MINOR variable, or
+in NVRAM if that option is enabled in the rtems/make/custom/mbx8xx.cfg file.
+We normally run with the RTEMS application console on SMC2. SMC1 is used by
+the debugger.
Support is provided for five different modes of operation:
@@ -180,20 +189,24 @@ Support is provided for five different modes of operation:
5. interrupt-driven I/O done by the supplied device driver with termios
support.
-The mode of operation of the serial driver is determined at build time
-by the value of the UARTS_IO_MODE constant in rtems/make/custom/mbx8xx.cfg.
-Edit the file to select the type of I/O desired before building RTEMS.
-The choices are:
+If NVRAM_CONFIGURE is set to 1 in rtems/make/custom/mbx8xx.cfg, the mode of
+operation of the driver is determined at boot time from the values stored
+in the user area in NVRAM. See the Configuration Parameters section below for
+instructions on setting up NVRAM. Otherwise, the mode of operation of the
+serial driver is determined at build time in part by the value of the
+UARTS_IO_MODE constant in rtems/make/custom/mbx8xx.cfg. Edit the file to select
+the type of I/O desired before building RTEMS. The choices are:
0 - polled I/O done by the supplied device driver,
1 - interrupt-driven I/O done by the supplied device driver,
2 - polled I/O done by EPPC-Bug.
-Also set the value of UARTS_USE_TERMIOS to select whether termios should
-be used to perform buffering and input/output processing. Without termios
-support, input processing is limited to the substitution of LF for a
-received CR, and output processing is limited to the transmission of a
-CR following the transmission of a LF. The choices for UARTS_USE_TERMIOS are:
+Also, if NVRAM_CONFIGURE is not set to 1 in rtems/make/custom/mbx8xx.cfg, set
+the value of UARTS_USE_TERMIOS to select whether termios should be used to
+perform buffering and input/output processing. Without termios support, input
+processing is limited to the substitution of LF for a received CR, and output
+processing is limited to the transmission of a CR following the transmission of
+a LF. The choices for UARTS_USE_TERMIOS are:
0 - do not use termios
1 - use termios
@@ -226,21 +239,31 @@ interrupts disabled.
Support is provided to send printk output to any port. Specify the desired
port at build time in rtems/make/custom/mbx8xx.cfg by setting the value
of PRINTK_MINOR to one of SMC1_MINOR, SMC2_MINOR, SCC2_MINOR, SCC3_MINOR,
-or SCC4_MINOR.
+or SCC4_MINOR. Alternatively, if NVRAM_CONFIGURE is set to 1 in
+rtems/make/custom/mbx8xx.cfg, the printk port is selected based on data that
+is stored in the user area in NVRAM. See the Configuration Parameters section
+below for instructions on setting up NVRAM.
Select the type of output desired for printk() by setting the value of
PRINTK_IO_MODE in rtems/make/custom/mbx8xx.cfg. The choices are:
0 - polled I/O done by the supplied device driver,
- 1 - interrupt-driven I/O done by the supplied device driver,
+ 1 - polled I/O done by the supplied device driver,
2 - polled I/O done by EPPC-Bug.
printk() does not use termios.
If the printk() port is opened by RTEMS, then PRINK_IO_MODE mode must have
the same value as UARTS_IO_MODE, otherwise the I/O functions will be in
-conflict. Interrupt-driven printk() output is only possible if the port is
-opened before hand by an RTEMS application, and is of dubious value...
+conflict. Interrupt-driven printk() output did not work, although we think
+that it should have. It would have been of dubious value anyways. If
+interrupt-driven I/O is selected (value of 1), the driver defaults to using
+polled I/O through the RTEMS driver.
+
+IMPORTANT: Polled I/O through the RTEMS driver requires that the driver be
+initialized. Consequently, to debug startup code using printk prior to the
+initialization of the serial driver, use mode 2: polled I/O through EPPC-Bug,
+and read the next section.
EPPC-Bug and I/O
@@ -305,10 +328,15 @@ set language auto
end
IMPORTANT: When using EPPC-Bug on SMC1, either for debugging or for polled I/O,
-EPPCBUG_SMC1 must be defined in rtems/make/custom/mbx8xx.cfg. Defining this
-constant prevents the device driver from re-initializing SMC1. It also causes
-the network driver, the clock driver, and the asynchronous serial line driver
-to maintain simask_copy for use by gdb.
+EPPCBUG_SMC1 must be defined in rtems/make/custom/mbx8xx.cfg, or the eppc_bug
+field set to non-zero in NVRAM. Defining this constant prevents the device
+driver from re-initializing SMC1. It also causes the network driver, the clock
+driver, and the asynchronous serial line driver to maintain simask_copy for use
+by gdb.
+
+Polled I/O through EPPC-Bug is pretty funky... If your are old enough, it might
+bring back fond memories of the days of 300 baud modems. If not, you can
+experience for yourself what the state of the art used to be.
Floating-point
@@ -319,6 +347,89 @@ get compiled with the appropriate -mcpu flag. The nof variants of the gcc
runtime libraries should be used for linking.
+Configuration Parameters
+------------------------
+
+If NVRAM_CONFIGURE is set in rtems/make/custom/mbx8xx.cfg, certain
+configuration parameters will be read from the first 31 bytes of the NVRAM
+User Area, which starts at 0xFA001000. The user is responsible for writing
+the appropriate values in NVRAM (via EPPC-Bug). The paramaters
+that are configurable and their default settings are described below.
+
+ Cache Mode (0xFA001000 - 1 byte)
+ Set the following bits in the byte to control the caches:
+ bit 0
+ 0 - data cache disable
+ 1 - data cache enable
+ bit 1
+ 0 - instruction cache disable
+ 1 - instruction cache enable
+ If enabled, all of RAM except for the last 512 KB will be cached using
+ copyback mode. The last 512 KB of RAMis for the use of EPPC-Bug.
+
+ Console driver I/O mode (0xFA001001 - 1 byte)
+ Set the following bits in the byte to set the desired I/O mode
+ for the rtems ports:
+ bit 0
+ 0 - do not use termios
+ 1 - use termios
+ bit 2 & 1
+ 00 - polled I/O through RTEMS driver
+ 01 - interrupt-driven I/O
+ 10 - polled I/O through EPPC-Bug
+ Set the following bits in the byte to set the desired I/O mode
+ for printk:
+ bit 5 & 4
+ 00 - polled I/O through RTEMS driver
+ 01 - polled I/O through RTEMS driver
+ 10 - polled I/O through EPPC-Bug
+
+ Console driver ports (0xFA001002 - 1 byte)
+ Set the following bits in the byte to select the console and printk ports:
+ bit 2, 1 & 0 select the RTEMS console port
+ 000 - /dev/tty0, SMC1
+ 001 - /dev/tty1, SMC2
+ 011 - /dev/tty2, SCC2
+ 100 - /dev/tty3, SCC3
+ 101 - /dev/tty4, SCC4
+ bit 6, 5 & 4 select the RTEMS printk port
+ 000 - /dev/tty0, SMC1
+ 001 - /dev/tty1, SMC2
+ 011 - /dev/tty2, SCC2
+ 100 - /dev/tty3, SCC3
+ 101 - /dev/tty4, SCC4
+ If the printk port is the same as some other port that will be opened by an
+ RTEMS application, then the driver must use polled I/O, or the printk port
+ must not be used.
+
+ EPPC-Bug in use on SMC1 (0xFA001003 - 1 byte)
+ Set to non-zero to indicate that EPPC-Bug is using SMC1. This will prevent
+ the SMC1 port from being re-initialized.
+
+ IP Address (0xFA001004 - 4 bytes)
+ Write the hexadecimal representation of the IP address of the board in this
+ location, e.g. 192.168.1.2 = 0xC0A80102
+
+ Netmask (0xFA001008 - 4 bytes)
+ Write the hexadecimal representation of the netmask in this location
+ for example, 255.255.255.0 = 0xFFFFFF00
+
+ Ethernet Address (0xFA00100C - 6 bytes)
+ Write the Ethernet address of the board in this location
+
+ Processor ID (0xFA001012 - 2 bytes)
+ Reserved for future use
+
+ RMA start (0xFA001014 - 4 bytes)
+ Reserved for future use
+
+ VMA start (0xFA001018 - 4 bytes)
+ Reserved for future use
+
+ RamSize (0xFA00101C - 4 bytes)
+ Reserved for future use
+
+
Miscellaneous
-------------
@@ -349,42 +460,18 @@ should have been documented in the rtems/c/src/tests/PROBLEMS file. The moral
of this story is: do not do I/O from the constructors or destructors of static
objects.
-The cpuuse and malloctest tests do not work properly, either with polled I/O
-or interrupt-driven I/O. They are known not to work with interrupt-driven I/O,
-but should work with polled I/O?
-
-Output stops prematurely in the termios test when the console is operating in
-interrupt-driven mode because the serial port is re-initialized before all
-characters in the last raw output buffer are sent. Adding calls to tcdrain()
-in the test task helps, but it does not solve the problem. What happens is
-that the CD2401 raises a transmit interrupt when the last character in the
-DMA buffer is written into the transmit FIFO, not when the last character
-has been transmitted. When tcdrain() returns, there might be up to 16
-characters in the output FIFO. The call to tcsetattr() causes the serial port
-to re-initialize, at which point the output FIFO is cleared. We could not find
-a way to detect whether characters are still in the FIFO and to wait for them
-to be transmitted.
-
-The first raw buffer to be transmitted after the console is re-initialized
-with tcsetattr() is garbled. At this time, it does not seem worth while to
-track this problem down.
-
-In the stackchk test, an access fault exception is raised after the stack is
-blown. This is one case were overwritting the first or last 16 bytes of the
-stack does cause problems (but hey, an exception occurred, which is better
-than propagating the error).
-
-When using interrupt-driven I/O, psx08 produces all the expected output, but
-it does not return control to 167Bug. Is this test supposed to work with
-interrupt-driven console I/O?
-
-
-What's new
+When using interrupt-driven I/O, psx08 fails with an internal assertion error.
+
+
+What is new
----------
All known problems with use of the caches on the MBX860-002 and MBX821-001
have been resolved.
+Configuration of the console and network is now possible at boot time through
+NVRAM parameters.
+
Thanks
------
diff --git a/c/src/lib/libbsp/powerpc/mbx8xx/console/console.c b/c/src/lib/libbsp/powerpc/mbx8xx/console/console.c
index 3246bf5a8d..e5bf1a0816 100644
--- a/c/src/lib/libbsp/powerpc/mbx8xx/console/console.c
+++ b/c/src/lib/libbsp/powerpc/mbx8xx/console/console.c
@@ -81,19 +81,12 @@
#include <rtems/libio.h>
#include <termios.h>
-#if UARTS_IO_MODE == 0
-#define BSP_WRITE m8xx_uart_pollWrite
-#define BSP_READ m8xx_uart_pollRead
-#elif UARTS_IO_MODE == 1
-#define BSP_WRITE m8xx_uart_write
-#elif UARTS_IO_MODE == 2
-#define BSP_WRITE _EPPCBug_pollWrite
-#define BSP_READ _EPPCBug_pollRead
-#endif
-
static int _EPPCBug_pollRead( int minor );
static int _EPPCBug_pollWrite( int minor, const char *buf, int len );
static void _BSP_output_char( char c );
+static rtems_status_code do_poll_read( rtems_device_major_number major, rtems_device_minor_number minor, void * arg);
+static rtems_status_code do_poll_write( rtems_device_major_number major, rtems_device_minor_number minor, void * arg);
+
BSP_output_char_function_type BSP_output_char = _BSP_output_char;
@@ -112,7 +105,7 @@ BSP_output_char_function_type BSP_output_char = _BSP_output_char;
* Return value: char returned as positive signed int
* -1 if no character is present in the input FIFO.
*/
-int _EPPCBug_pollRead(
+static int _EPPCBug_pollRead(
int minor
)
{
@@ -220,7 +213,7 @@ int _EPPCBug_pollRead(
*
* Return value: IGNORED
*/
-int _EPPCBug_pollWrite(
+static int _EPPCBug_pollWrite(
int minor,
const char *buf,
int len
@@ -331,16 +324,182 @@ error:
/*
+ * do_poll_read
+ *
+ * Input characters through polled I/O. Returns has soon as a character has
+ * been received. Otherwise, if we wait for the number of requested characters,
+ * we could be here forever!
+ *
+ * CR is converted to LF on input. The terminal should not send a CR/LF pair
+ * when the return or enter key is pressed.
+ *
+ * Input parameters:
+ * major - ignored. Should be the major number for this driver.
+ * minor - selected channel.
+ * arg->buffer - where to put the received characters.
+ * arg->count - number of characters to receive before returning--Ignored.
+ *
+ * Output parameters:
+ * arg->bytes_moved - the number of characters read. Always 1.
+ *
+ * Return value: RTEMS_SUCCESSFUL
+ *
+ * CANNOT BE COMBINED WITH INTERRUPT DRIVEN I/O!
+ */
+static rtems_status_code do_poll_read(
+ rtems_device_major_number major,
+ rtems_device_minor_number minor,
+ void * arg
+)
+{
+ rtems_libio_rw_args_t *rw_args = arg;
+ int c;
+
+#if NVRAM_CONFIGURE == 1
+
+ int (*pollRead)( int minor );
+
+ if ( (nvram->console_mode & 0x06) == 0x04 )
+ pollRead = _EPPCBug_pollRead;
+ else
+ pollRead = m8xx_uart_pollRead;
+
+ while( (c = (*pollRead)(minor)) == -1 );
+ rw_args->buffer[0] = (unsigned8)c;
+ if( rw_args->buffer[0] == '\r' )
+ rw_args->buffer[0] = '\n';
+ rw_args->bytes_moved = 1;
+ return RTEMS_SUCCESSFUL;
+
+#else
+
+#if UARTS_IO_MODE == 2
+#define BSP_READ _EPPCBug_pollRead
+#else
+#define BSP_READ m8xx_uart_pollRead
+#endif
+
+ while( (c = BSP_READ(minor)) == -1 );
+ rw_args->buffer[0] = (unsigned8)c;
+ if( rw_args->buffer[0] == '\r' )
+ rw_args->buffer[0] = '\n';
+ rw_args->bytes_moved = 1;
+ return RTEMS_SUCCESSFUL;
+
+#endif
+}
+
+
+/*
+ * do_poll_write
+ *
+ * Output characters through polled I/O. Returns only once every character has
+ * been sent.
+ *
+ * CR is transmitted AFTER a LF on output.
+ *
+ * Input parameters:
+ * major - ignored. Should be the major number for this driver.
+ * minor - selected channel
+ * arg->buffer - where to get the characters to transmit.
+ * arg->count - the number of characters to transmit before returning.
+ *
+ * Output parameters:
+ * arg->bytes_moved - the number of characters read
+ *
+ * Return value: RTEMS_SUCCESSFUL
+ *
+ * CANNOT BE COMBINED WITH INTERRUPT DRIVEN I/O!
+ */
+static rtems_status_code do_poll_write(
+ rtems_device_major_number major,
+ rtems_device_minor_number minor,
+ void * arg
+)
+{
+ rtems_libio_rw_args_t *rw_args = arg;
+ unsigned32 i;
+ char cr ='\r';
+
+#if NVRAM_CONFIGURE == 1
+
+ int (*pollWrite)(int minor, const char *buf, int len);
+
+ if ( (nvram->console_mode & 0x06) == 0x04 )
+ pollWrite = _EPPCBug_pollWrite;
+ else
+ pollWrite = m8xx_uart_pollWrite;
+
+ for( i = 0; i < rw_args->count; i++ ) {
+ (*pollWrite)(minor, &(rw_args->buffer[i]), 1);
+ if ( rw_args->buffer[i] == '\n' )
+ (*pollWrite)(minor, &cr, 1);
+ }
+ rw_args->bytes_moved = i;
+ return RTEMS_SUCCESSFUL;
+
+#else
+
+#if UARTS_IO_MODE == 2
+#define BSP_WRITE _EPPCBug_pollWrite
+#else
+#define BSP_WRITE m8xx_uart_pollWrite
+#endif
+
+ for( i = 0; i < rw_args->count; i++ ) {
+ BSP_WRITE(minor, &(rw_args->buffer[i]), 1);
+ if ( rw_args->buffer[i] == '\n' )
+ BSP_WRITE(minor, &cr, 1);
+ }
+ rw_args->bytes_moved = i;
+ return RTEMS_SUCCESSFUL;
+
+#endif
+}
+
+
+/*
* Print functions prototyped in bspIo.h
*/
-void _BSP_output_char( char c )
+static void _BSP_output_char( char c )
{
char cr = '\r';
- BSP_WRITE( PRINTK_MINOR, &c, 1 );
+ /*
+ * Can't rely on console_initialize having been called before this function
+ * is used, so it may fail unless output is done through EPPC-Bug.
+ */
+#if NVRAM_CONFIGURE == 1
+
+ rtems_device_minor_number printk_minor;
+
+ /* Use NVRAM info for configuration */
+ printk_minor = (nvram->console_printk_port & 0x70) >> 4;
+ if( (nvram->console_mode & 0x30) == 0x20 ) {
+ _EPPCBug_pollWrite( printk_minor, &c, 1 );
+ if( c == '\n' )
+ _EPPCBug_pollWrite( printk_minor, &cr, 1 );
+ }
+ else {
+ m8xx_uart_pollWrite( printk_minor, &c, 1 );
+ if( c == '\n' )
+ m8xx_uart_pollWrite( PRINTK_MINOR, &cr, 1 );
+ }
+
+#else
+
+#if PRINTK_IO_MODE == 2
+#define PRINTK_WRITE _EPPCBug_pollWrite
+#else
+#define PRINTK_WRITE m8xx_uart_pollWrite
+#endif
+
+ PRINTK_WRITE( PRINTK_MINOR, &c, 1 );
if( c == '\n' )
- BSP_WRITE( PRINTK_MINOR, &cr, 1 );
+ PRINTK_WRITE( PRINTK_MINOR, &cr, 1 );
+
+#endif
}
@@ -362,13 +521,62 @@ rtems_device_driver console_initialize(
)
{
rtems_status_code status;
+ rtems_device_minor_number console_minor;
+
+ /*
+ * Set up TERMIOS if needed
+ */
+#if NVRAM_CONFIGURE == 1
+ /* Use NVRAM info for configuration */
+ console_minor = nvram->console_printk_port & 0x07;
+
+ if ( nvram->console_mode & 0x01 )
+ /* termios */
+ rtems_termios_initialize ();
+
+ /*
+ * Do common initialization.
+ */
+ m8xx_uart_initialize();
/*
- * Set up TERMIOS
+ * Do device-specific initialization
*/
+ if ( !nvram->eppcbug_smc1 &&
+ ( ((nvram->console_mode & 0x30) != 0x20) ||
+ (((nvram->console_printk_port & 0x30) >> 4) != SMC1_MINOR) ) )
+ m8xx_uart_smc_initialize(SMC1_MINOR); /* /dev/tty0 */
+
+ if ( ((nvram->console_mode & 0x30) != 0x20) ||
+ (((nvram->console_printk_port & 0x30) >> 4) != SMC2_MINOR) )
+ m8xx_uart_smc_initialize(SMC2_MINOR); /* /dev/tty1 */
+
+ if ( ((nvram->console_mode & 0x30) != 0x20) ||
+ (((nvram->console_printk_port & 0x30) >> 4) != SCC2_MINOR) )
+ m8xx_uart_scc_initialize(SCC2_MINOR); /* /dev/tty2 */
+
+#ifdef mpc860
+
+ if ( ((nvram->console_mode & 0x30) != 0x20) ||
+ (((nvram->console_printk_port & 0x30) >> 4) != SCC3_MINOR) )
+ m8xx_uart_scc_initialize(SCC3_MINOR); /* /dev/tty3 */
+
+ if ( ((nvram->console_mode & 0x30) != 0x20) ||
+ (((nvram->console_printk_port & 0x30) >> 4) != SCC4_MINOR) )
+ m8xx_uart_scc_initialize(SCC4_MINOR); /* /dev/tty4 */
+
+#endif /* mpc860 */
+
+#else /* NVRAM_CONFIGURE != 1 */
+
+ console_minor = CONSOLE_MINOR;
+
#if UARTS_USE_TERMIOS == 1
- rtems_termios_initialize();
-#endif
+
+ rtems_termios_initialize ();
+
+#endif /* UARTS_USE_TERMIOS */
+
/*
* Do common initialization.
*/
@@ -401,6 +609,9 @@ rtems_device_driver console_initialize(
#endif /* mpc860 */
+#endif /* NVRAM_CONFIGURE != 1 */
+
+
/*
* Set up interrupts
*/
@@ -430,7 +641,7 @@ rtems_device_driver console_initialize(
#endif /* mpc860 */
/* Now register the RTEMS console */
- status = rtems_io_register_name ("/dev/console", major, CONSOLE_MINOR);
+ status = rtems_io_register_name ("/dev/console", major, console_minor);
if (status != RTEMS_SUCCESSFUL)
rtems_fatal_error_occurred (status);
@@ -448,14 +659,11 @@ rtems_device_driver console_open(
)
{
/* Used to track termios private data for callbacks */
-#if UARTS_IO_MODE == 1
extern struct rtems_termios_tty *ttyp[];
+
rtems_libio_open_close_args_t *args = arg;
-#endif
-
rtems_status_code sc;
-
-#if UARTS_USE_TERMIOS == 1
+
static const rtems_termios_callbacks sccEPPCBugCallbacks = {
NULL, /* firstOpen */
NULL, /* lastClose */
@@ -465,6 +673,7 @@ rtems_device_driver console_open(
NULL, /* startRemoteTx */
0 /* outputUsesInterrupts */
};
+
static const rtems_termios_callbacks intrCallbacks = {
NULL, /* firstOpen */
NULL, /* lastClose */
@@ -475,6 +684,7 @@ rtems_device_driver console_open(
NULL, /* startRemoteTx */
1 /* outputUsesInterrupts */
};
+
static const rtems_termios_callbacks pollCallbacks = {
NULL, /* firstOpen */
NULL, /* lastClose */
@@ -485,35 +695,53 @@ rtems_device_driver console_open(
NULL, /* startRemoteTx */
0 /* outputUsesInterrupts */
};
-#endif
if ( minor > NUM_PORTS-1 )
return RTEMS_INVALID_NUMBER;
+#if NVRAM_CONFIGURE == 1
+
+ /* Use NVRAM info for configuration */
+ if ( nvram->console_mode & 0x01 ) {
+ /* Use termios */
+ if ( (nvram->console_mode & 0x06) == 0x02 ) {
+ /* interrupt-driven I/O */
+ sc = rtems_termios_open( major, minor, arg, &intrCallbacks );
+ ttyp[minor] = args->iop->data1; /* Keep cookie returned by termios_open */
+ return sc;
+ }
+ else if ( (nvram->console_mode & 0x06) == 0x04 )
+ /* polled I/O through EPPC-Bug, better be through SMC1 */
+ return rtems_termios_open( major, minor, arg, &sccEPPCBugCallbacks );
+ else
+ /* normal polled I/O */
+ return rtems_termios_open( major, minor, arg, &pollCallbacks );
+ }
+ else
+ /* no termios -- default to polled I/O */
+ return RTEMS_SUCCESSFUL;
+
+#else /* NVRAM_CONFIGURE != 1 */
+
#if UARTS_USE_TERMIOS == 1
#if UARTS_IO_MODE == 2 /* EPPCBug polled I/O with termios */
-
- sc = rtems_termios_open (major, minor, arg, &sccEPPCBugCallbacks);
-
+ sc = rtems_termios_open( major, minor, arg, &sccEPPCBugCallbacks );
#elif UARTS_IO_MODE == 1 /* RTEMS interrupt-driven I/O with termios */
-
- sc = rtems_termios_open (major, minor, arg, &intrCallbacks);
+ sc = rtems_termios_open( major, minor, arg, &intrCallbacks );
ttyp[minor] = args->iop->data1; /* Keep cookie returned by termios_open */
-
#else /* RTEMS polled I/O with termios */
-
- sc = rtems_termios_open (major, minor, arg, &pollCallbacks);
-
+ sc = rtems_termios_open( major, minor, arg, &pollCallbacks );
#endif
-#else /* Nothing to do if termios is not used */
-
+#else /* UARTS_USE_TERMIOS != 1 */
+ /* no termios -- default to polled I/O */
sc = RTEMS_SUCCESSFUL;
-
-#endif
+#endif /* UARTS_USE_TERMIOS != 1 */
return sc;
+
+#endif /* NVRAM_CONFIGURE != 1 */
}
@@ -529,11 +757,25 @@ rtems_device_driver console_close(
if ( minor > NUM_PORTS-1 )
return RTEMS_INVALID_NUMBER;
+#if NVRAM_CONFIGURE == 1
+
+ /* Use NVRAM info for configuration */
+ if ( nvram->console_mode & 0x01 )
+ /* use termios */
+ return rtems_termios_close( arg );
+ else
+ /* no termios */
+ return RTEMS_SUCCESSFUL;
+
+#else /* NVRAM_CONFIGURE != 1 */
+
#if UARTS_USE_TERMIOS == 1
- return rtems_termios_close (arg);
+ return rtems_termios_close( arg );
#else
return RTEMS_SUCCESSFUL;
#endif
+
+#endif /* NVRAM_CONFIGURE != 1 */
}
@@ -546,33 +788,25 @@ rtems_device_driver console_read(
void *arg
)
{
-#if UARTS_USE_TERMIOS != 1
- rtems_libio_rw_args_t *rw_args = arg;
- int c;
-#endif
-
if ( minor > NUM_PORTS-1 )
return RTEMS_INVALID_NUMBER;
-#if UARTS_USE_TERMIOS == 1
-
- return rtems_termios_read(arg);
-
-#else
+#if NVRAM_CONFIGURE == 1
-#if UARTS_IO_MODE != 1 /* Polled I/O without termios */
+ /* Use NVRAM info for configuration */
+ if ( nvram->console_mode & 0x01 )
+ /* use termios */
+ return rtems_termios_read( arg );
+ else
+ /* no termios -- default to polled */
+ return do_poll_read( major, minor, arg );
- while( (c = BSP_READ( minor )) == -1 );
- rw_args->buffer[0] = (unsigned8)c;
- if( rw_args->buffer[0] == '\r' )
- rw_args->buffer[0] = '\n';
- rw_args->bytes_moved = 1;
- return RTEMS_SUCCESSFUL;
-
-#else /* RTEMS interrupt-driven I/O without termios */
+#else
- #error "Interrupt-driven input without termios is not yet supported"
-
+#if UARTS_USE_TERMIOS == 1
+ return rtems_termios_read( arg );
+#else
+ return do_poll_read( major, minor, arg );
#endif
#endif
@@ -588,36 +822,26 @@ rtems_device_driver console_write(
void *arg
)
{
-#if UARTS_USE_TERMIOS != 1
- rtems_libio_rw_args_t *rw_args = arg;
- unsigned32 i;
- char cr = '\r';
-#endif
-
if ( minor > NUM_PORTS-1 )
return RTEMS_INVALID_NUMBER;
-#if UARTS_USE_TERMIOS == 1
-
- return rtems_termios_write(arg);
-
-#else
+#if NVRAM_CONFIGURE == 1
-#if UARTS_IO_MODE != 1 /* Polled I/O without termios*/
+ /* Use NVRAM info for configuration */
+ if ( nvram->console_mode & 0x01 )
+ /* use termios */
+ return rtems_termios_write( arg );
+ else
+ /* no termios -- default to polled */
+ return do_poll_write( major, minor, arg );
- /* Must add carriage return to line feeds */
- for( i = 0; i < rw_args->count; i++ ) {
- BSP_WRITE( minor, &(rw_args->buffer[i]), 1 );
- if( rw_args->buffer[i] == '\n' )
- BSP_WRITE( minor, &cr, 1 );
- }
- rw_args->bytes_moved = i;
- return RTEMS_SUCCESSFUL;
-
-#else /* RTEMS interrupt-driven I/O without termios */
+#else
- #error "Interrupt-driven output without termios is not yet supported"
-
+#if UARTS_USE_TERMIOS == 1
+ return rtems_termios_write( arg );
+#else
+ /* no termios -- default to polled */
+ return do_poll_write( major, minor, arg );
#endif
#endif
@@ -636,10 +860,24 @@ rtems_device_driver console_control(
if ( minor > NUM_PORTS-1 )
return RTEMS_INVALID_NUMBER;
+#if NVRAM_CONFIGURE == 1
+
+ /* Uuse NVRAM info for configuration */
+ if ( nvram->console_mode & 0x01 )
+ /* termios */
+ return rtems_termios_ioctl( arg );
+ else
+ /* no termios -- default to polled */
+ return RTEMS_SUCCESSFUL;
+
+#else
+
#if UARTS_USE_TERMIOS == 1
- return rtems_termios_ioctl (arg);
+ return rtems_termios_ioctl( arg );
#else
return RTEMS_SUCCESSFUL;
#endif
+
+#endif
}
diff --git a/c/src/lib/libbsp/powerpc/mbx8xx/include/bsp.h b/c/src/lib/libbsp/powerpc/mbx8xx/include/bsp.h
index 0f0b805a1e..a94603146f 100644
--- a/c/src/lib/libbsp/powerpc/mbx8xx/include/bsp.h
+++ b/c/src/lib/libbsp/powerpc/mbx8xx/include/bsp.h
@@ -30,6 +30,30 @@ extern "C" {
#include <mpc8xx/mmu.h>
#include <mpc8xx/console.h>
+
+/*
+ * Representation of initialization data in NVRAM
+ */
+typedef volatile struct nvram_config_ {
+ unsigned char cache_mode; /* 0xFA001000 */
+ unsigned char console_mode; /* 0xFA001001 */
+ unsigned char console_printk_port; /* 0xFA001002 */
+ unsigned char eppcbug_smc1; /* 0xFA001003 */
+ unsigned long ipaddr; /* 0xFA001004 */
+ unsigned long netmask; /* 0xFA001008 */
+ unsigned char enaddr[6]; /* 0xFA00100C */
+ unsigned short processor_id; /* 0xFA001012 */
+ unsigned long rma_start; /* 0xFA001014 */
+ unsigned long vma_start; /* 0xFA001018 */
+ unsigned long ramsize; /* 0xFA00101C */
+} nvram_config;
+
+/*
+ * Pointer to the base of User Area NVRAM
+ */
+#define nvram ((nvram_config * const) 0xFA001000)
+
+
/*
* Network driver configuration
*/
@@ -70,11 +94,6 @@ extern int rtems_enet_driver_attach (struct rtems_bsdnet_ifconfig *config, int a
#define Lower_tm27_intr()
-/* Constants -- THESE SHOULD BE DEFINED IN THE LINKER SCRIPT */
-
-#define RAM_START 0
-#define RAM_END 0x100000
-
/* miscellaneous stuff assumed to exist */
extern rtems_configuration_table BSP_Configuration;
diff --git a/c/src/lib/libbsp/powerpc/mbx8xx/network/network.c b/c/src/lib/libbsp/powerpc/mbx8xx/network/network.c
index 7538c7f46d..a491af5670 100644
--- a/c/src/lib/libbsp/powerpc/mbx8xx/network/network.c
+++ b/c/src/lib/libbsp/powerpc/mbx8xx/network/network.c
@@ -52,6 +52,9 @@
#define TX_BUF_COUNT 8
#define TX_BD_PER_BUF 4
+#define INET_ADDR_MAX_BUF_SIZE (sizeof "255.255.255.255")
+
+
/*
* RTEMS event used by interrupt handler to signal daemons.
* This must *not* be the same event used by the TCP/IP task synchronization.
@@ -1537,6 +1540,8 @@ rtems_scc1_driver_attach (struct rtems_bsdnet_ifconfig *config)
int mtu;
int unitNumber;
char *unitName;
+ char *pAddr;
+ unsigned long addr;
/*
* Parse driver name
@@ -1561,12 +1566,60 @@ rtems_scc1_driver_attach (struct rtems_bsdnet_ifconfig *config)
/*
* Process options
*/
+ #if NVRAM_CONFIGURE == 1
+
+ /* Configure from NVRAM */
+ if ( (addr = nvram->ipaddr) ) {
+ /* We have a non-zero entry, copy the value */
+ if ( (pAddr = malloc ( INET_ADDR_MAX_BUF_SIZE, 0, M_NOWAIT )) )
+ config->ip_address = (char *)inet_ntop(AF_INET, &addr, pAddr, INET_ADDR_MAX_BUF_SIZE -1 );
+ else
+ rtems_panic("Can't allocate ip_address buffer!\n");
+ }
+
+ if ( (addr = nvram->netmask) ) {
+ /* We have a non-zero entry, copy the value */
+ if ( (pAddr = malloc ( INET_ADDR_MAX_BUF_SIZE, 0, M_NOWAIT )) )
+ config->ip_netmask = (char *)inet_ntop(AF_INET, &addr, pAddr, INET_ADDR_MAX_BUF_SIZE -1 );
+ else
+ rtems_panic("Can't allocate ip_netmask buffer!\n");
+ }
+
+ /* Ethernet address requires special handling -- it must be copied into
+ * the arpcom struct. The following if construct serves only to give the
+ * User Area NVRAM parameter the highest priority.
+ *
+ * If the ethernet address is specified in NVRAM, go ahead and copy it.
+ * (ETHER_ADDR_LEN = 6 bytes).
+ */
+ if ( nvram->enaddr[0] || nvram->enaddr[1] || nvram->enaddr[2] ) {
+ /* Anything in the first three bytes indicates a non-zero entry, copy value */
+ memcpy ((void *)sc->arpcom.ac_enaddr, &nvram->enaddr, ETHER_ADDR_LEN);
+ }
+ else if ( config->hardware_address ) {
+ /* There is no entry in NVRAM, but there is in the ifconfig struct, so use it. */
+ memcpy ((void *)sc->arpcom.ac_enaddr, config->hardware_address, ETHER_ADDR_LEN);
+ }
+ else {
+ /* There is no ethernet address provided, so it could be read
+ * from the Ethernet protocol block of SCC1 in DPRAM.
+ */
+ rtems_panic("No Ethernet address specified!\n");
+ }
+
+ #else /* NVRAM_CONFIGURE != 1 */
+
if (config->hardware_address) {
memcpy (sc->arpcom.ac_enaddr, config->hardware_address, ETHER_ADDR_LEN);
}
else {
- /* FIXME to read the enaddr from NVRAM */
+ /* There is no ethernet address provided, so it could be read
+ * from the Ethernet protocol block of SCC1 in DPRAM.
+ */
+ rtems_panic("No Ethernet address specified!\n");
}
+
+#endif /* NVRAM_CONFIGURE != 1 */
if (config->mtu)
mtu = config->mtu;
diff --git a/c/src/lib/libbsp/powerpc/mbx8xx/startup/bspstart.c b/c/src/lib/libbsp/powerpc/mbx8xx/startup/bspstart.c
index 32061a9545..4f2f616184 100644
--- a/c/src/lib/libbsp/powerpc/mbx8xx/startup/bspstart.c
+++ b/c/src/lib/libbsp/powerpc/mbx8xx/startup/bspstart.c
@@ -135,13 +135,19 @@ void bsp_start(void)
/*
* Enable instruction and data caches. Do not force writethrough mode.
*/
- #ifdef INSTRUCTION_CACHE_ENABLE
- rtems_cache_enable_instruction();
- #endif
-
- #ifdef DATA_CACHE_ENABLE
- rtems_cache_enable_data();
- #endif
+#if NVRAM_CONFIGURE == 1
+ if ( nvram->cache_mode & 0x02 )
+ rtems_cache_enable_instruction();
+ if ( nvram->cache_mode & 0x01 )
+ rtems_cache_enable_data();
+#else
+#ifdef INSTRUCTION_CACHE_ENABLE
+ rtems_cache_enable_instruction();
+#endif
+#ifdef DATA_CACHE_ENABLE
+ rtems_cache_enable_data();
+#endif
+#endif
/*
* Allocate the memory for the RTEMS Work Space. This can come from