pc386: Add --disable-com1-com4 boot argument

This commit is contained in:
Joel Sherrill
2016-03-09 12:48:39 -06:00
parent efbf6c910a
commit 22bbb9f165
3 changed files with 54 additions and 16 deletions

View File

@@ -1,11 +1,13 @@
/* /**
* This file contains the libchip configuration information * @file
* to instantiate the libchip driver for the VGA console *
* and serial ports on a PC. * 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). * On-Line Applications Research Corporation (OAR).
* *
* The license and distribution terms for this file may be * The license and distribution terms for this file may be
@@ -13,8 +15,6 @@
* http://www.rtems.org/license/LICENSE. * http://www.rtems.org/license/LICENSE.
*/ */
#include <unistd.h> /* write */
#include <bsp.h> #include <bsp.h>
#include <libchip/serial.h> #include <libchip/serial.h>
#include <libchip/ns16550.h> #include <libchip/ns16550.h>
@@ -23,7 +23,6 @@
#endif #endif
#include <bsp/irq.h> #include <bsp/irq.h>
#include <rtems/pci.h> #include <rtems/pci.h>
#include <bsp/rtd316.h>
#if BSP_ENABLE_VGA #if BSP_ENABLE_VGA
#define VGA_CONSOLE_FUNCTIONS &vgacons_fns #define VGA_CONSOLE_FUNCTIONS &vgacons_fns
@@ -49,7 +48,7 @@
static uint8_t com_get_register(uint32_t addr, uint8_t i) static uint8_t com_get_register(uint32_t addr, uint8_t i)
{ {
register uint8_t val; register uint8_t val;
inport_byte( (addr + i),val ); inport_byte( (addr + i),val );
return val; return val;
} }
@@ -58,6 +57,8 @@
{ {
outport_byte( (addr + i),val ); outport_byte( (addr + i),val );
} }
extern bool pc386_com1_com4_enabled(int);
#endif #endif
#if (BSP_IS_EDISON == 1 ) #if (BSP_IS_EDISON == 1 )
@@ -68,7 +69,7 @@ console_tbl Console_Configuration_Ports[] = {
#if (BSP_IS_EDISON == 1) #if (BSP_IS_EDISON == 1)
{ {
"/dev/vgacons", /* sDeviceName */ "/dev/vgacons", /* sDeviceName */
-1, /* deviceType */ -1, /* deviceType */
&edison_fns, /* pDeviceFns */ &edison_fns, /* pDeviceFns */
NULL, /* deviceProbe */ NULL, /* deviceProbe */
NULL, /* pDeviceFlow */ NULL, /* pDeviceFlow */
@@ -112,7 +113,7 @@ console_tbl Console_Configuration_Ports[] = {
"/dev/com1", /* sDeviceName */ "/dev/com1", /* sDeviceName */
SERIAL_NS16550, /* deviceType */ SERIAL_NS16550, /* deviceType */
COM_CONSOLE_FUNCTIONS, /* pDeviceFns */ COM_CONSOLE_FUNCTIONS, /* pDeviceFns */
NULL, /* deviceProbe, assume it is there */ pc386_com1_com4_enabled, /* deviceProbe */
NULL, /* pDeviceFlow */ NULL, /* pDeviceFlow */
16, /* ulMargin */ 16, /* ulMargin */
8, /* ulHysteresis */ 8, /* ulHysteresis */
@@ -131,7 +132,7 @@ console_tbl Console_Configuration_Ports[] = {
"/dev/com2", /* sDeviceName */ "/dev/com2", /* sDeviceName */
SERIAL_NS16550, /* deviceType */ SERIAL_NS16550, /* deviceType */
COM_CONSOLE_FUNCTIONS, /* pDeviceFns */ COM_CONSOLE_FUNCTIONS, /* pDeviceFns */
NULL, /* deviceProbe, assume it is there */ pc386_com1_com4_enabled, /* deviceProbe */
NULL, /* pDeviceFlow */ NULL, /* pDeviceFlow */
16, /* ulMargin */ 16, /* ulMargin */
8, /* ulHysteresis */ 8, /* ulHysteresis */
@@ -151,7 +152,7 @@ console_tbl Console_Configuration_Ports[] = {
"/dev/com3", /* sDeviceName */ "/dev/com3", /* sDeviceName */
SERIAL_NS16550, /* deviceType */ SERIAL_NS16550, /* deviceType */
COM_CONSOLE_FUNCTIONS, /* pDeviceFns */ COM_CONSOLE_FUNCTIONS, /* pDeviceFns */
NULL, /* deviceProbe, assume it is there */ pc386_com1_com4_enabled, /* deviceProbe */
NULL, /* pDeviceFlow */ NULL, /* pDeviceFlow */
16, /* ulMargin */ 16, /* ulMargin */
8, /* ulHysteresis */ 8, /* ulHysteresis */
@@ -171,7 +172,7 @@ console_tbl Console_Configuration_Ports[] = {
"/dev/com4", /* sDeviceName */ "/dev/com4", /* sDeviceName */
SERIAL_NS16550, /* deviceType */ SERIAL_NS16550, /* deviceType */
COM_CONSOLE_FUNCTIONS, /* pDeviceFns */ COM_CONSOLE_FUNCTIONS, /* pDeviceFns */
NULL, /* deviceProbe, assume it is there */ pc386_com1_com4_enabled, /* deviceProbe */
NULL, /* pDeviceFlow */ NULL, /* pDeviceFlow */
16, /* ulMargin */ 16, /* ulMargin */
8, /* ulHysteresis */ 8, /* ulHysteresis */

View File

@@ -31,6 +31,22 @@
#include <crt.h> #include <crt.h>
#endif #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 * Method to return true if the device associated with the
* minor number probs available. * minor number probs available.
@@ -103,6 +119,22 @@ static bool bsp_find_console_entry(
return false; 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( static bool parse_printk_or_console(
const char *param, const char *param,
rtems_device_minor_number *minor_out rtems_device_minor_number *minor_out
@@ -197,6 +229,11 @@ void pc386_parse_console_arguments(void)
*/ */
console_initialize_data(); console_initialize_data();
/*
* Determine if COM1-COM4 were disabled.
*/
parse_com1_com4_enable();
/* /*
* Assume that if only --console is specified, that printk() should * Assume that if only --console is specified, that printk() should
* follow that selection by default. * follow that selection by default.

View File

@@ -117,12 +117,12 @@ void console_register_devices(
*/ */
Console_Port_Data = realloc( Console_Port_Data = realloc(
Console_Port_Data, Console_Port_Data,
Console_Port_Count * sizeof(console_tbl *) Console_Port_Count * sizeof(console_data)
); );
if ( Console_Port_Data == NULL ) { if ( Console_Port_Data == NULL ) {
bsp_fatal( BSP_FATAL_CONSOLE_NO_MEMORY_2 ); 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. * Now add the new devices at the end.