From 22bbb9f16589322fb979bacc79f50b02ef34f57a Mon Sep 17 00:00:00 2001 From: Joel Sherrill Date: Wed, 9 Mar 2016 12:48:39 -0600 Subject: pc386: Add --disable-com1-com4 boot argument --- c/src/lib/libbsp/i386/pc386/console/conscfg.c | 29 +++++++++-------- .../lib/libbsp/i386/pc386/console/console_select.c | 37 ++++++++++++++++++++++ c/src/lib/libbsp/shared/console.c | 4 +-- 3 files changed, 54 insertions(+), 16 deletions(-) diff --git a/c/src/lib/libbsp/i386/pc386/console/conscfg.c b/c/src/lib/libbsp/i386/pc386/console/conscfg.c index d5586d74db..e59498b691 100644 --- a/c/src/lib/libbsp/i386/pc386/console/conscfg.c +++ b/c/src/lib/libbsp/i386/pc386/console/conscfg.c @@ -1,11 +1,13 @@ -/* - * This file contains the libchip configuration information - * to instantiate the libchip driver for the VGA console - * and serial ports on a PC. +/** + * @file + * + * This file contains the libchip configuration information + * to instantiate the libchip driver for the VGA console + * and serial ports on a PC. */ /* - * COPYRIGHT (c) 1989-2014. + * COPYRIGHT (c) 1989-2014, 2016. * On-Line Applications Research Corporation (OAR). * * The license and distribution terms for this file may be @@ -13,8 +15,6 @@ * http://www.rtems.org/license/LICENSE. */ -#include /* write */ - #include #include #include @@ -23,7 +23,6 @@ #endif #include #include -#include #if BSP_ENABLE_VGA #define VGA_CONSOLE_FUNCTIONS &vgacons_fns @@ -49,7 +48,7 @@ static uint8_t com_get_register(uint32_t addr, uint8_t i) { register uint8_t val; - + inport_byte( (addr + i),val ); return val; } @@ -58,6 +57,8 @@ { outport_byte( (addr + i),val ); } + + extern bool pc386_com1_com4_enabled(int); #endif #if (BSP_IS_EDISON == 1 ) @@ -68,7 +69,7 @@ console_tbl Console_Configuration_Ports[] = { #if (BSP_IS_EDISON == 1) { "/dev/vgacons", /* sDeviceName */ - -1, /* deviceType */ + -1, /* deviceType */ &edison_fns, /* pDeviceFns */ NULL, /* deviceProbe */ NULL, /* pDeviceFlow */ @@ -112,7 +113,7 @@ console_tbl Console_Configuration_Ports[] = { "/dev/com1", /* sDeviceName */ SERIAL_NS16550, /* deviceType */ COM_CONSOLE_FUNCTIONS, /* pDeviceFns */ - NULL, /* deviceProbe, assume it is there */ + pc386_com1_com4_enabled, /* deviceProbe */ NULL, /* pDeviceFlow */ 16, /* ulMargin */ 8, /* ulHysteresis */ @@ -131,7 +132,7 @@ console_tbl Console_Configuration_Ports[] = { "/dev/com2", /* sDeviceName */ SERIAL_NS16550, /* deviceType */ COM_CONSOLE_FUNCTIONS, /* pDeviceFns */ - NULL, /* deviceProbe, assume it is there */ + pc386_com1_com4_enabled, /* deviceProbe */ NULL, /* pDeviceFlow */ 16, /* ulMargin */ 8, /* ulHysteresis */ @@ -151,7 +152,7 @@ console_tbl Console_Configuration_Ports[] = { "/dev/com3", /* sDeviceName */ SERIAL_NS16550, /* deviceType */ COM_CONSOLE_FUNCTIONS, /* pDeviceFns */ - NULL, /* deviceProbe, assume it is there */ + pc386_com1_com4_enabled, /* deviceProbe */ NULL, /* pDeviceFlow */ 16, /* ulMargin */ 8, /* ulHysteresis */ @@ -171,7 +172,7 @@ console_tbl Console_Configuration_Ports[] = { "/dev/com4", /* sDeviceName */ SERIAL_NS16550, /* deviceType */ COM_CONSOLE_FUNCTIONS, /* pDeviceFns */ - NULL, /* deviceProbe, assume it is there */ + pc386_com1_com4_enabled, /* deviceProbe */ NULL, /* pDeviceFlow */ 16, /* ulMargin */ 8, /* ulHysteresis */ diff --git a/c/src/lib/libbsp/i386/pc386/console/console_select.c b/c/src/lib/libbsp/i386/pc386/console/console_select.c index c78b4b89bf..1d938a1ebd 100644 --- a/c/src/lib/libbsp/i386/pc386/console/console_select.c +++ b/c/src/lib/libbsp/i386/pc386/console/console_select.c @@ -31,6 +31,22 @@ #include #endif +/* + * Forward prototype + */ +extern bool pc386_com1_com4_enabled(int); + +/* + * This method is used to determine if COM1-COM4 are enabled based upon + * boot command line arguments. + */ +static bool are_com1_com4_enabled; + +bool pc386_com1_com4_enabled(int minor) +{ + return are_com1_com4_enabled; +} + /* * Method to return true if the device associated with the * minor number probs available. @@ -103,6 +119,22 @@ static bool bsp_find_console_entry( return false; } +static void parse_com1_com4_enable(void) +{ + static const char *opt; + + /* + * Check the command line to see if com1-com4 are disabled. + */ + opt = bsp_cmdline_arg("--disable-com1-com4"); + if ( opt ) { + printk( "Disable COM1-COM4 per boot argument\n" ); + are_com1_com4_enabled = false; + } else { + are_com1_com4_enabled = true; + } +} + static bool parse_printk_or_console( const char *param, rtems_device_minor_number *minor_out @@ -197,6 +229,11 @@ void pc386_parse_console_arguments(void) */ console_initialize_data(); + /* + * Determine if COM1-COM4 were disabled. + */ + parse_com1_com4_enable(); + /* * Assume that if only --console is specified, that printk() should * follow that selection by default. diff --git a/c/src/lib/libbsp/shared/console.c b/c/src/lib/libbsp/shared/console.c index d0300654a5..d2261723f8 100644 --- a/c/src/lib/libbsp/shared/console.c +++ b/c/src/lib/libbsp/shared/console.c @@ -117,12 +117,12 @@ void console_register_devices( */ Console_Port_Data = realloc( Console_Port_Data, - Console_Port_Count * sizeof(console_tbl *) + Console_Port_Count * sizeof(console_data) ); if ( Console_Port_Data == NULL ) { bsp_fatal( BSP_FATAL_CONSOLE_NO_MEMORY_2 ); } - memset(&Console_Port_Data, '\0', Console_Port_Count * sizeof(console_tbl *)); + memset(Console_Port_Data, '\0', Console_Port_Count * sizeof(console_data)); /* * Now add the new devices at the end. -- cgit v1.2.3