diff options
author | Joel Sherrill <joel.sherrill@oarcorp.com> | 2014-12-14 16:27:06 -0600 |
---|---|---|
committer | Joel Sherrill <joel.sherrill@oarcorp.com> | 2015-01-04 13:44:57 -0600 |
commit | 7cdabc49ca3828c9aeeb6beca4a0beeb71bf23f1 (patch) | |
tree | 128664532dfebd50115c56f7c94d206c482a6c5e /c/src/lib/libbsp/i386/pc386/console | |
parent | untar.c: Coverity ID 26151 and reformat (diff) | |
download | rtems-7cdabc49ca3828c9aeeb6beca4a0beeb71bf23f1.tar.bz2 |
pc386: Add Edison base support
The current support for the Edison supports a single polled
UART for input and output plus a simulated clock tick. The
activities forward for supporting the Edison have been posted
on the RTEMS mailing lists and at:
http://rtemsramblings.blogspot.com/2014/12/intel-edison-and-rtems-road-forward.html
Diffstat (limited to 'c/src/lib/libbsp/i386/pc386/console')
-rw-r--r-- | c/src/lib/libbsp/i386/pc386/console/conscfg.c | 25 | ||||
-rw-r--r-- | c/src/lib/libbsp/i386/pc386/console/console_edison.c | 94 | ||||
-rw-r--r-- | c/src/lib/libbsp/i386/pc386/console/printk_support.c | 10 |
3 files changed, 129 insertions, 0 deletions
diff --git a/c/src/lib/libbsp/i386/pc386/console/conscfg.c b/c/src/lib/libbsp/i386/pc386/console/conscfg.c index a34f0e5217..d5586d74db 100644 --- a/c/src/lib/libbsp/i386/pc386/console/conscfg.c +++ b/c/src/lib/libbsp/i386/pc386/console/conscfg.c @@ -60,7 +60,32 @@ } #endif +#if (BSP_IS_EDISON == 1 ) + extern const console_fns edison_fns; +#endif + console_tbl Console_Configuration_Ports[] = { +#if (BSP_IS_EDISON == 1) + { + "/dev/vgacons", /* sDeviceName */ + -1, /* deviceType */ + &edison_fns, /* pDeviceFns */ + NULL, /* deviceProbe */ + NULL, /* pDeviceFlow */ + 16, /* ulMargin */ + 8, /* ulHysteresis */ + (void *) NULL, /* NULL */ /* pDeviceParams */ + 0x00000000, /* ulCtrlPort1 */ + 0x00000000, /* ulCtrlPort2 */ + 0x00000000, /* ulDataPort */ + NULL, /* getRegister */ + NULL, /* setRegister */ + NULL,/* unused */ /* getData */ + NULL,/* unused */ /* setData */ + 0X0, /* ulClock */ + 0x0 /* ulIntVector -- base for port */ + }, +#endif #if BSP_ENABLE_VGA { "/dev/vgacons", /* sDeviceName */ diff --git a/c/src/lib/libbsp/i386/pc386/console/console_edison.c b/c/src/lib/libbsp/i386/pc386/console/console_edison.c new file mode 100644 index 0000000000..d5e44aed86 --- /dev/null +++ b/c/src/lib/libbsp/i386/pc386/console/console_edison.c @@ -0,0 +1,94 @@ + +#include <bsp.h> +#include <libchip/serial.h> + +/* XXX hack until real support is available, code copied from libchip */ +#define NS16550_RECEIVE_BUFFER 0 +#define NS16550_TRANSMIT_BUFFER 0 +#define NS16550_INTERRUPT_ENABLE 1 +#define NS16550_INTERRUPT_ID 2 +#define NS16550_FIFO_CONTROL 2 +#define NS16550_LINE_CONTROL 3 +#define NS16550_MODEM_CONTROL 4 +#define NS16550_LINE_STATUS 5 +#define NS16550_MODEM_STATUS 6 +#define NS16550_SCRATCH_PAD 7 +#define NS16550_FRACTIONAL_DIVIDER 10 + +/* status bits we use in line status */ + +#define SP_LSR_TX 0x40 +#define SP_LSR_THOLD 0x20 +#define SP_LSR_RDY 0x01 +static volatile uint8_t *edison_com = (volatile uint8_t *)0xff010180; + +void edison_write_polled(int minor, char cChar); +int edison_inbyte_nonblocking_polled(int minor); + +static int edison_open(int major, int minor, void *arg) +{ + return 0; +} + +static int edison_close(int major, int minor, void *arg) +{ + return 0; +} + +int edison_inbyte_nonblocking_polled(int minor) +{ + if ( edison_com[NS16550_LINE_STATUS] & 0x01 ) + return (int) edison_com[NS16550_RECEIVE_BUFFER]; + return -1; +} + +static ssize_t edison_write_support_polled(int minor, const char *buf, size_t len) +{ + ssize_t i; + + for ( i=0 ; i<len ; i++ ) { +#if 0 + if ( (edison_com[NS16550_LINE_STATUS] & SP_LSR_TX) == 0 ) + break; +#else + while ( (edison_com[NS16550_LINE_STATUS] & SP_LSR_TX) == 0x00 ) + /* wait until ready */; +#endif + edison_com[NS16550_TRANSMIT_BUFFER] = (uint8_t) buf[i]; + } + return i; +} + +static void edison_init(int minor) +{ +} + +void edison_write_polled(int minor, char cChar) +{ + while ( (edison_com[NS16550_LINE_STATUS] & SP_LSR_TX) == 0x00 ) + /* wait until ready */; + edison_com[NS16550_TRANSMIT_BUFFER] = (uint8_t) cChar; +} + +static bool edison_probe(int minor) +{ + return true; +} + +static int edison_set_attributes(int minor, const struct termios *t) +{ + return 0; +} + +const console_fns edison_fns = +{ + edison_probe, /* deviceProbe */ + edison_open, /* deviceFirstOpen */ + edison_close, /* deviceLastClose */ + edison_inbyte_nonblocking_polled, /* deviceRead */ + edison_write_support_polled, /* deviceWrite */ + edison_init, /* deviceInitialize */ + edison_write_polled, /* deviceWritePolled */ + edison_set_attributes, /* deviceSetAttributes */ + FALSE, /* deviceOutputUsesInterrupts */ +}; diff --git a/c/src/lib/libbsp/i386/pc386/console/printk_support.c b/c/src/lib/libbsp/i386/pc386/console/printk_support.c index c6b0fe5c00..d4adf555e7 100644 --- a/c/src/lib/libbsp/i386/pc386/console/printk_support.c +++ b/c/src/lib/libbsp/i386/pc386/console/printk_support.c @@ -29,6 +29,11 @@ rtems_device_minor_number BSPPrintkPort = 0; +#if (BSP_IS_EDISON == 1) +void edison_write_polled(int minor, char cChar); /* XXX */ +int edison_inbyte_nonblocking_polled(int minor); +#endif + #if BSP_ENABLE_COM1_COM4 int ns16550_inbyte_nonblocking_polled( int minor ); #endif @@ -66,6 +71,11 @@ int BSP_inch(void) } while (result == -1); } #endif + #if (BSP_IS_EDISON == 1) + do { + result = edison_inbyte_nonblocking_polled( BSPPrintkPort ); + } while (result == -1); + #endif return result; } |