Correct run-time selection of console port.

This was broken by conversion of console driver to libchip style.
This commit is contained in:
Jennifer Averett
2012-02-01 14:32:28 -06:00
committed by Joel Sherrill
parent 41572c40c3
commit 441b90e6c9
6 changed files with 190 additions and 561 deletions
+1 -1
View File
@@ -79,7 +79,7 @@ libbsp_a_SOURCES += console/inch.c console/outch.c \
console/vgainit.c console/vt.c console/videoAsm.S \
console/kbd_parser.c console/serial_mouse_config.c \
../../i386/shared/comm/uart.c ../../i386/shared/comm/tty_drv.c \
../../shared/console.c ../../shared/console_select.c \
../../shared/console.c console/console_select.c \
../../shared/console_read.c ../../shared/console_write.c \
console/console_control.c console/conscfg.c console/printk_support.c \
console/vgacons.c
File diff suppressed because it is too large Load Diff
@@ -0,0 +1,157 @@
/**
* @file
*
* @ingroup Console
*
* @brief Generic libchip console select
*/
/*
* This file contains a routine to select the
* console based upon a number of criteria.
*
* COPYRIGHT (c) 2011.
* On-Line Applications Research Corporation (OAR).
*
* The license and distribution terms for this file may be
* found in the file LICENSE in this distribution or at
* http://www.rtems.com/license/LICENSE.
*
* $Id: console_select.c,v 1.1 2012/02/01 16:03:14 jennifer Exp $
*/
#include <bsp.h>
#include <rtems/libio.h>
#include <stdlib.h>
#include <assert.h>
#include <termios.h>
#include <rtems/termiostypes.h>
#include <libchip/serial.h>
#include "../../../shared/console_private.h"
#ifdef RTEMS_RUNTIME_CONSOLE_SELECT
#include <crt.h>
#endif
/*
* Method to return true if the device associated with the
* minor number probs available.
*/
static bool bsp_Is_Available( rtems_device_minor_number minor )
{
console_tbl *cptr = Console_Port_Tbl[minor];
/*
* First perform the configuration dependent probe, then the
* device dependent probe
*/
if ((!cptr->deviceProbe || cptr->deviceProbe(minor)) &&
cptr->pDeviceFns->deviceProbe(minor)) {
return true;
}
return false;
}
/*
* Method to return the first available device.
*/
static rtems_device_minor_number bsp_First_Available_Device( void )
{
rtems_device_minor_number minor;
for (minor=0; minor < Console_Port_Count ; minor++) {
console_tbl *cptr = Console_Port_Tbl[minor];
/*
* First perform the configuration dependent probe, then the
* device dependent probe
*/
if ((!cptr->deviceProbe || cptr->deviceProbe(minor)) &&
cptr->pDeviceFns->deviceProbe(minor)) {
return minor;
}
}
/*
* Error No devices were found. We will want to bail here.
*/
rtems_fatal_error_occurred(RTEMS_IO_ERROR);
}
void bsp_console_select(void)
{
static const char* opt;
/*
* Check the command line for the type of mode the console is.
*/
opt = bsp_cmdline_arg ("--console=");
if (opt) {
const char* comma;
opt += sizeof ("--console=") - 1;
if (strncmp (opt, "console", sizeof ("console") - 1) == 0) {
Console_Port_Minor = BSP_CONSOLE_VGA;
BSPPrintkPort = BSP_CONSOLE_VGA;
} else if (strncmp (opt, "com1", sizeof ("com1") - 1) == 0) {
Console_Port_Minor = BSP_CONSOLE_COM1;
BSPPrintkPort = BSP_CONSOLE_COM1;
} else if (strncmp (opt, "com2", sizeof ("com2") - 1) == 0) {
Console_Port_Minor = BSP_CONSOLE_COM2;
BSPPrintkPort = BSP_CONSOLE_COM2;
}
comma = strchr (opt, ',');
if (comma) {
console_tbl *conscfg;
comma += 1;
conscfg = &Console_Configuration_Ports[Console_Port_Minor];
if (strncmp (opt, "115200", sizeof ("115200") - 1) == 0)
conscfg->pDeviceParams = (void *)115200;
else if (strncmp (opt, "57600", sizeof ("57600") - 1) == 0)
conscfg->pDeviceParams = (void *)57600;
else if (strncmp (opt, "38400", sizeof ("38400") - 1) == 0)
conscfg->pDeviceParams = (void *)38400;
else if (strncmp (opt, "19200", sizeof ("19200") - 1) == 0)
conscfg->pDeviceParams = (void *)19200;
else if (strncmp (opt, "9600", sizeof ("9600") - 1) == 0)
conscfg->pDeviceParams = (void *)9600;
else if (strncmp (opt, "4800", sizeof ("4800") - 1) == 0)
conscfg->pDeviceParams = (void *)4800;
}
}
#ifdef RTEMS_RUNTIME_CONSOLE_SELECT
if ( BSP_runtime_console_select )
BSP_runtime_console_select(&BSPPrintkPort, &Console_Port_Minor);
/*
* If no video card, fall back to serial port console
*/
if((Console_Port_Minor == BSP_CONSOLE_VGA)
&& (*(unsigned char*) NB_MAX_ROW_ADDR == 0)
&& (*(unsigned short*)NB_MAX_COL_ADDR == 0)) {
Console_Port_Minor = BSP_CONSOLE_COM2;
BSPPrintkPort = BSP_CONSOLE_COM1;
}
#endif
/*
* If the device that was selected isn't available then
* let the user know and select the first available device.
*/
if ( !bsp_Is_Available( Console_Port_Minor ) ) {
printk(
"Error finding %s setting console to first available\n",
Console_Port_Tbl[Console_Port_Minor]->sDeviceName
);
Console_Port_Minor = bsp_First_Available_Device();
}
if (opt != NULL)
printk("cmdline==>%s<<==\n", opt);
}
@@ -22,9 +22,7 @@
#include <bsp.h>
#include <libchip/serial.h>
#include <libchip/ns16550.h>
BSP_output_char_function_type BSP_output_char = _IBMPC_outch;
BSP_polling_getchar_function_type BSP_poll_char = BSP_wait_polled_input;
#include "../../../shared/console_private.h"
rtems_device_minor_number BSPPrintkPort = 0;
@@ -32,26 +30,35 @@ int ns16550_inbyte_nonblocking_polled(
int minor
);
void BSP_com_outch(char ch)
void BSP_outch(char ch);
int BSP_inch(void);
void BSP_outch(char ch)
{
console_tbl *cptr;
if ( BSPPrintkPort == BSP_CONSOLE_VGA ) {
_IBMPC_outch( ch );
} else {
console_tbl *cptr;
cptr = &Console_Configuration_Ports[BSPPrintkPort];
return cptr->pDeviceFns->deviceWritePolled( BSPPrintkPort, ch );
cptr = &Console_Configuration_Ports[BSPPrintkPort];
cptr->pDeviceFns->deviceWritePolled( BSPPrintkPort, ch );
}
}
int BSP_com_inch( void )
int BSP_inch(void)
{
int result;
console_tbl *cptr;
cptr = &Console_Configuration_Ports[BSPPrintkPort];
do {
result = ns16550_inbyte_nonblocking_polled( BSPPrintkPort );
} while (result == -1);
if ( BSPPrintkPort == BSP_CONSOLE_VGA ) {
result = BSP_wait_polled_input();
} else {
do {
result = ns16550_inbyte_nonblocking_polled( BSPPrintkPort );
} while (result == -1);
}
return result;
}
BSP_output_char_function_type BSP_output_char = BSP_outch;
BSP_polling_getchar_function_type BSP_poll_char = BSP_inch;
@@ -133,6 +133,15 @@ extern int rtems_dec21140_driver_attach(struct rtems_bsdnet_ifconfig *, int);
#define TIMER_TICK 1193182 /* The internal tick rate in ticks per second */
/*-------------------------------------------------------------------------+
| Console Defines
| WARNING: These Values MUST match the order in
| Console_Configuration_Ports
+--------------------------------------------------------------------------*/
#define BSP_CONSOLE_VGA 0
#define BSP_CONSOLE_COM1 1
#define BSP_CONSOLE_COM2 2
/*-------------------------------------------------------------------------+
| Macros
+--------------------------------------------------------------------------*/
@@ -68,7 +68,6 @@ BEGIN_CODE
EXTERN (_IBMPC_initVideo)
EXTERN (debugPollingGetChar)
EXTERN (checkCPUtypeSetCr0)
EXTERN (BSP_console_select)
EXTERN (printk)
#ifdef __SSE__
EXTERN (x86_capability)