forked from Imagelibrary/rtems
i386/pc: Initialise the printk serial port on first use
This commit is contained in:
@@ -46,15 +46,14 @@
|
|||||||
|
|
||||||
#define CLOCK_RATE (115200 * 16)
|
#define CLOCK_RATE (115200 * 16)
|
||||||
|
|
||||||
static uint8_t com_get_register(uint32_t addr, uint8_t i)
|
static uint8_t com_get_register(uintptr_t addr, uint8_t i)
|
||||||
{
|
{
|
||||||
register uint8_t val;
|
uint8_t val;
|
||||||
|
|
||||||
inport_byte( (addr + i), val );
|
inport_byte( (addr + i), val );
|
||||||
return val;
|
return val;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void com_set_register(uint32_t addr, uint8_t i, uint8_t val)
|
static void com_set_register(uintptr_t addr, uint8_t i, uint8_t val)
|
||||||
{
|
{
|
||||||
outport_byte( (addr + i), val );
|
outport_byte( (addr + i), val );
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -29,6 +29,28 @@
|
|||||||
|
|
||||||
rtems_device_minor_number BSPPrintkPort = 0;
|
rtems_device_minor_number BSPPrintkPort = 0;
|
||||||
|
|
||||||
|
static bool serialInit;
|
||||||
|
static bool serialOK;
|
||||||
|
|
||||||
|
static bool serialValid(console_tbl *port)
|
||||||
|
{
|
||||||
|
if (port->pDeviceFns) {
|
||||||
|
if (!serialInit) {
|
||||||
|
serialOK = true;
|
||||||
|
if (port->pDeviceFns->deviceProbe != NULL) {
|
||||||
|
if (!port->pDeviceFns->deviceProbe( BSPPrintkPort ))
|
||||||
|
serialOK = false;
|
||||||
|
else if (port->pDeviceFns->deviceInitialize != NULL)
|
||||||
|
port->pDeviceFns->deviceInitialize( BSPPrintkPort );
|
||||||
|
else
|
||||||
|
serialOK = false;
|
||||||
|
}
|
||||||
|
serialInit = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return serialOK;
|
||||||
|
}
|
||||||
|
|
||||||
void BSP_outch(char ch);
|
void BSP_outch(char ch);
|
||||||
int BSP_inch(void);
|
int BSP_inch(void);
|
||||||
|
|
||||||
@@ -42,10 +64,12 @@ void BSP_outch(char ch)
|
|||||||
|
|
||||||
if ( !isVga ) {
|
if ( !isVga ) {
|
||||||
console_tbl *port = Console_Port_Tbl[BSPPrintkPort];
|
console_tbl *port = Console_Port_Tbl[BSPPrintkPort];
|
||||||
if (port->pDeviceFns && port->pDeviceFns->deviceWritePolled) {
|
if (serialValid(port)) {
|
||||||
port->pDeviceFns->deviceWritePolled( BSPPrintkPort, ch );
|
if (port->pDeviceFns->deviceWritePolled) {
|
||||||
|
port->pDeviceFns->deviceWritePolled( BSPPrintkPort, ch );
|
||||||
|
}
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#if BSP_ENABLE_VGA
|
#if BSP_ENABLE_VGA
|
||||||
@@ -65,11 +89,13 @@ int BSP_inch(void)
|
|||||||
|
|
||||||
if ( !isVga ) {
|
if ( !isVga ) {
|
||||||
console_tbl *port = Console_Port_Tbl[BSPPrintkPort];
|
console_tbl *port = Console_Port_Tbl[BSPPrintkPort];
|
||||||
if (port->pDeviceFns && port->pDeviceFns->deviceRead) {
|
if (serialValid(port)) {
|
||||||
do {
|
if (port->pDeviceFns->deviceRead) {
|
||||||
result = port->pDeviceFns->deviceRead( BSPPrintkPort );
|
do {
|
||||||
} while (result == -1);
|
result = port->pDeviceFns->deviceRead( BSPPrintkPort );
|
||||||
return result;
|
} while (result == -1);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user