Update serial functions for new WritePort system.

This commit is contained in:
Curle 2019-07-24 21:49:35 +01:00
parent ebbe1d9346
commit 5ed922bd20

View File

@ -12,10 +12,7 @@
* Some testing will be needed to know for certain whether this will work.
* Until then, this is to be put on hold. 21/07/19 - Curle */
#include <kernel/utils.h>
#include <stdarg.h>
#include <stdint.h>
#include <stddef.h>
#include <kernel.h>
#define SERIAL_DATA_PORT(base) (base)
#define SERIAL_FIFO_COMMAND_PORT(base) (base + 2)
@ -37,14 +34,14 @@
*/
void serial_set_baud_rate(uint16_t com, uint16_t divisor) {
outb(SERIAL_LINE_COMMAND_PORT(com),
SERIAL_LINE_ENABLE_DLAB);
WritePort(SERIAL_LINE_COMMAND_PORT(com),
SERIAL_LINE_ENABLE_DLAB, 8);
outb(SERIAL_DATA_PORT(com),
(divisor >> 8) & 0x00FF);
WritePort(SERIAL_DATA_PORT(com),
(divisor >> 8) & 0x00FF, 8);
outb(SERIAL_DATA_PORT(com),
divisor & 0x00FF);
WritePort(SERIAL_DATA_PORT(com),
divisor & 0x00FF, 8);
}
@ -61,7 +58,7 @@ void serial_configure_line(uint16_t com) {
* Value: | 0 | 0 | 0 0 0 | 0 | 1 1 | = 0x03
*/
outb(SERIAL_LINE_COMMAND_PORT(com), 0x0B);
WritePort(SERIAL_LINE_COMMAND_PORT(com), 0x0B, 8);
}
/** serial_configure_buffers:
@ -78,7 +75,7 @@ void serial_configure_buffers(uint16_t com) {
* Value: | 1 1 | 0 | 0 | 0 | 1 | 1 | 1 | = 0xC7
*/
outb(SERIAL_FIFO_COMMAND_PORT(com), 0xC7);
WritePort(SERIAL_FIFO_COMMAND_PORT(com), 0xC7, 8);
}
/** serial_configure_modem
@ -91,7 +88,7 @@ void serial_configure_modem(uint16_t com) {
* Value: | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 1 | = 0x03
*/
outb(SERIAL_MODEM_COMMAND_PORT(com), 0x3);
WritePort(SERIAL_MODEM_COMMAND_PORT(com), 0x3, 8);
}
/** serial_check_tqueue:
@ -103,7 +100,7 @@ void serial_configure_modem(uint16_t com) {
*/
int serial_check_tqueue(uint16_t com) {
return inb(SERIAL_LINE_STATUS_PORT(com)) & 0x20;
return ReadPort(SERIAL_LINE_STATUS_PORT(com), 8) & 0x20;
}
/** serial_write:
@ -116,7 +113,7 @@ int serial_check_tqueue(uint16_t com) {
void serial_write(uint16_t com, const char chr) {
//Hang until we have access to the COM port.
while(serial_check_tqueue(com) == 0);
outb(com, chr);
WritePort(com, chr, 0);
}
/** serial_print:
@ -185,7 +182,7 @@ void serial_printf(uint16_t com, const char* format, ...) {
void init_serial() {
// Disable interrupts
outb(SERIAL_COM1_BASE + 1, 0x00);
WritePort(SERIAL_COM1_BASE + 1, 0x00, 0);
// Set baud rate divisor.
serial_set_baud_rate(SERIAL_COM1_BASE, 3);