mirror of
https://github.com/wichtounet/thor-os.git
synced 2025-09-12 14:10:36 -04:00
Basic serial support
This commit is contained in:
parent
cda223cc11
commit
9efd6430c2
20
kernel/include/serial.hpp
Normal file
20
kernel/include/serial.hpp
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
//=======================================================================
|
||||||
|
// Copyright Baptiste Wicht 2013-2014.
|
||||||
|
// Distributed under the Boost Software License, Version 1.0.
|
||||||
|
// (See accompanying file LICENSE_1_0.txt or copy at
|
||||||
|
// http://www.boost.org/LICENSE_1_0.txt)
|
||||||
|
//=======================================================================
|
||||||
|
|
||||||
|
#ifndef SERIAL_H
|
||||||
|
#define SERIAL_H
|
||||||
|
|
||||||
|
namespace serial {
|
||||||
|
|
||||||
|
void init();
|
||||||
|
|
||||||
|
bool is_transmit_buffer_empty();
|
||||||
|
void transmit(char a);
|
||||||
|
|
||||||
|
} //end of serial namespace
|
||||||
|
|
||||||
|
#endif
|
@ -12,6 +12,7 @@
|
|||||||
#include "kalloc.hpp"
|
#include "kalloc.hpp"
|
||||||
#include "timer.hpp"
|
#include "timer.hpp"
|
||||||
#include "keyboard.hpp"
|
#include "keyboard.hpp"
|
||||||
|
#include "serial.hpp"
|
||||||
#include "disks.hpp"
|
#include "disks.hpp"
|
||||||
#include "acpi.hpp"
|
#include "acpi.hpp"
|
||||||
#include "interrupts.hpp"
|
#include "interrupts.hpp"
|
||||||
@ -85,6 +86,7 @@ void kernel_main(){
|
|||||||
kalloc::finalize();
|
kalloc::finalize();
|
||||||
|
|
||||||
//Install drivers
|
//Install drivers
|
||||||
|
serial::init();
|
||||||
timer::install();
|
timer::install();
|
||||||
//acpi::init();
|
//acpi::init();
|
||||||
keyboard::install_driver();
|
keyboard::install_driver();
|
||||||
@ -94,7 +96,7 @@ void kernel_main(){
|
|||||||
vfs::init();
|
vfs::init();
|
||||||
|
|
||||||
//Starting from here, the logging system can output logs to file
|
//Starting from here, the logging system can output logs to file
|
||||||
logging::to_file();
|
//TODO logging::to_file();
|
||||||
|
|
||||||
//Only install system calls when everything else is ready
|
//Only install system calls when everything else is ready
|
||||||
install_system_calls();
|
install_system_calls();
|
||||||
|
31
kernel/src/serial.cpp
Normal file
31
kernel/src/serial.cpp
Normal file
@ -0,0 +1,31 @@
|
|||||||
|
//=======================================================================
|
||||||
|
// Copyright Baptiste Wicht 2013-2014.
|
||||||
|
// Distributed under the Boost Software License, Version 1.0.
|
||||||
|
// (See accompanying file LICENSE_1_0.txt or copy at
|
||||||
|
// http://www.boost.org/LICENSE_1_0.txt)
|
||||||
|
//=======================================================================
|
||||||
|
|
||||||
|
#include "serial.hpp"
|
||||||
|
#include "kernel_utils.hpp"
|
||||||
|
|
||||||
|
#define COM1_PORT 0x3f8
|
||||||
|
|
||||||
|
void serial::init() {
|
||||||
|
out_byte(COM1_PORT + 1, 0x00); // Disable all interrupts
|
||||||
|
out_byte(COM1_PORT + 3, 0x80); // Enable DLAB
|
||||||
|
out_byte(COM1_PORT + 0, 0x03); // 38400 baud
|
||||||
|
out_byte(COM1_PORT + 1, 0x00);
|
||||||
|
out_byte(COM1_PORT + 3, 0x03); // 8 bits, no parity, one stop bit
|
||||||
|
out_byte(COM1_PORT + 2, 0xC7); // Enable FIFO, clear them, with 14-byte threshold
|
||||||
|
out_byte(COM1_PORT + 4, 0x0B); // IRQs enabled, RTS/DSR set
|
||||||
|
}
|
||||||
|
|
||||||
|
bool serial::is_transmit_buffer_empty() {
|
||||||
|
return in_byte(COM1_PORT + 5) & 0x20;
|
||||||
|
}
|
||||||
|
|
||||||
|
void serial::transmit(char a) {
|
||||||
|
while (is_transmit_buffer_empty() == 0){}
|
||||||
|
|
||||||
|
out_byte(COM1_PORT,a);
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user