From a5d33e1ab1b342bcf87ba7138ea72f94b496f2ac Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fran=C3=A7ois=20Revol?= Date: Thu, 28 Aug 2014 20:46:31 +0200 Subject: [PATCH] pc_serial: try to skip the port used for kernel debugging output Not that easy to handle all cases correctly, but should work for the default case. --- .../kernel/drivers/ports/pc_serial/Driver.cpp | 37 ++++++++++++++++++- 1 file changed, 36 insertions(+), 1 deletion(-) diff --git a/src/add-ons/kernel/drivers/ports/pc_serial/Driver.cpp b/src/add-ons/kernel/drivers/ports/pc_serial/Driver.cpp index 46f3ef311a..6b106f82c2 100644 --- a/src/add-ons/kernel/drivers/ports/pc_serial/Driver.cpp +++ b/src/add-ons/kernel/drivers/ports/pc_serial/Driver.cpp @@ -12,6 +12,7 @@ #include #include #include +#include #include #include #include @@ -32,6 +33,7 @@ dpc_module_info *gDPCModule = NULL; void* gDPCHandle = NULL; sem_id gDriverLock = -1; bool gHandleISA = false; +uint32 gKernelDebugPort = 0x3f8; // 24 MHz clock static const uint32 sDefaultRates[] = { @@ -512,8 +514,11 @@ scan_isa_hardcoded() #ifdef HANDLE_ISA_COM int i; - //TODO: check and filter out the kernel debug port for (i = 0; i < 4; i++) { + // skip the port used for kernel debugging... + if (sHardcodedPorts[i].ioBase == gKernelDebugPort) + continue; + SerialDevice *device; device = new(std::nothrow) SerialDevice(&sSupportedDevices[0], sHardcodedPorts[i].ioBase, sHardcodedPorts[i].irq); @@ -669,6 +674,34 @@ next_split_alt: } +static void +check_kernel_debug_port() +{ + void *handle; + long int value; + + handle = load_driver_settings("kernel"); + const char *str = get_driver_parameter(handle, "serial_debug_port", + NULL, NULL); + if (str != NULL) { + value = strtol(str, NULL, 0); + if (value >= 4) // XXX: actually should be MAX_SERIAL_PORTS... + gKernelDebugPort = (uint32)value; + else if (value >= 0) // XXX: we should use the kernel_arg's table... + gKernelDebugPort = sHardcodedPorts[value].ioBase; + } + + /* TODO: actually handle this in the kernel debugger too! + bool enabled = get_driver_boolean_parameter(handle, "serial_debug_output", + false, true); + if (!enabled) + gKernelDebugPort = 0; + */ + + unload_driver_settings(handle); +} + + //#pragma mark - @@ -730,6 +763,8 @@ init_driver() status = ENOENT; + check_kernel_debug_port(); + (void)scan_bus; //scan_bus(B_ISA_BUS); //scan_bus(B_PCI_BUS);