From 5427e7f2ca49277f9ef896e107b1ed65225ca33e Mon Sep 17 00:00:00 2001 From: Alex Date: Sat, 25 Feb 2023 07:23:25 +0200 Subject: [PATCH] Set baud rate to 115200 --- ...iversalAsynchronousReceiverTransmitter.cpp | 20 ++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/Core/UniversalAsynchronousReceiverTransmitter.cpp b/Core/UniversalAsynchronousReceiverTransmitter.cpp index 81ae47e..039d297 100644 --- a/Core/UniversalAsynchronousReceiverTransmitter.cpp +++ b/Core/UniversalAsynchronousReceiverTransmitter.cpp @@ -27,10 +27,16 @@ __no_instrument_function void NoProfiler_outportb(uint16_t Port, uint8_t Data) namespace UniversalAsynchronousReceiverTransmitter { #define SERIAL_ENABLE_DLAB 0x80 +#define SERIAL_RATE_115200_LO 0x01 +#define SERIAL_RATE_115200_HI 0x00 +#define SERIAL_RATE_57600_LO 0x02 +#define SERIAL_RATE_57600_HI 0x00 #define SERIAL_RATE_38400_LO 0x03 #define SERIAL_RATE_38400_HI 0x00 #define SERIAL_BUFFER_EMPTY 0x20 + /* TODO: Serial Port implementation needs reword. https://wiki.osdev.org/Serial_Ports */ + SafeFunction __no_instrument_function UART::UART(SerialPorts Port) { #if defined(__amd64__) || defined(__i386__) @@ -74,13 +80,13 @@ namespace UniversalAsynchronousReceiverTransmitter return; // Initialize the serial port - NoProfiler_outportb(Port + 1, 0x00); // Disable all interrupts - NoProfiler_outportb(Port + 3, SERIAL_ENABLE_DLAB); // Enable DLAB (set baud rate divisor) - NoProfiler_outportb(Port + 0, SERIAL_RATE_38400_LO); // Set divisor to 3 (lo byte) 38400 baud - NoProfiler_outportb(Port + 1, SERIAL_RATE_38400_HI); // (hi byte) - NoProfiler_outportb(Port + 3, 0x03); // 8 bits, no parity, one stop bit - NoProfiler_outportb(Port + 2, 0xC7); // Enable FIFO, clear them, with 14-byte threshold - NoProfiler_outportb(Port + 4, 0x0B); // IRQs enabled, RTS/DSR set + NoProfiler_outportb(Port + 1, 0x00); // Disable all interrupts + NoProfiler_outportb(Port + 3, SERIAL_ENABLE_DLAB); // Enable DLAB (set baud rate divisor) + NoProfiler_outportb(Port + 0, SERIAL_RATE_115200_LO); // Set divisor to 1 (lo byte) 115200 baud + NoProfiler_outportb(Port + 1, SERIAL_RATE_115200_HI); // (hi byte) + NoProfiler_outportb(Port + 3, 0x03); // 8 bits, no parity, one stop bit + NoProfiler_outportb(Port + 2, 0xC7); // Enable FIFO, clear them, with 14-byte threshold + NoProfiler_outportb(Port + 4, 0x0B); // IRQs enabled, RTS/DSR set // Check if the serial port is faulty. if (NoProfiler_inportb(Port + 0) != 0xAE)