1

merged cleanup

This commit is contained in:
2022-07-24 21:12:31 +02:00
parent 5ff3d72bfd
commit 6481bae5f6
92 changed files with 663 additions and 755 deletions

View File

@ -1,6 +1,8 @@
#include "user/devices/SerialOut.h"
int SerialOut::init() const {
const IOport SerialOut::com1(0x3f8);
SerialOut::SerialOut() {
// NOTE: I could add different ports for every register but this was easier as it's that way on OSDev
com1.outb(1, 0x00); // Disable all interrupts
com1.outb(3, 0x80); // Enable DLAB (set baud rate divisor)
@ -13,14 +15,11 @@ int SerialOut::init() const {
com1.outb(0xAE); // Test serial chip (send byte 0xAE and check if serial returns same byte)
// Check if serial is faulty (i.e: not same byte as sent)
if (com1.inb() != 0xAE) {
return 1;
if (com1.inb() == 0xAE) {
// If serial is not faulty set it in normal operation mode
// (not-loopback with IRQs enabled and OUT#1 and OUT#2 bits enabled)
com1.outb(4, 0x0F);
}
// If serial is not faulty set it in normal operation mode
// (not-loopback with IRQs enabled and OUT#1 and OUT#2 bits enabled)
com1.outb(4, 0x0F);
return 0;
}
int SerialOut::serial_received() {
@ -44,11 +43,11 @@ void SerialOut::write(const char a) {
void SerialOut::write(const char* a) {
const char* current = a;
do {
this->write(*current);
write(*current);
current = current + 1;
} while (*current != '\0');
}
void SerialOut::write(const bse::string& a) {
write((const char*)a);
write(static_cast<const char*>(a));
}

View File

@ -1,5 +1,5 @@
#ifndef __SerialOut_Include_H_
#define __SerialOut_Include_H_
#ifndef SerialOut_Include_H_
#define SerialOut_Include_H_
#include "kernel/IOport.h"
#include "user/lib/String.h"
@ -8,24 +8,19 @@
class SerialOut {
private:
const IOport com1;
static const IOport com1;
SerialOut(const SerialOut& copy) = delete;
int serial_received();
int is_transmit_empty();
static int serial_received();
static int is_transmit_empty();
public:
SerialOut() : com1(0x3f8) {
this->init();
}
SerialOut(const SerialOut& copy) = delete;
SerialOut();
int init() const;
char read();
void write(char a);
void write(const char* a);
void write(const bse::string& a);
static char read();
static void write(char a);
static void write(const char* a);
static void write(const bse::string& a);
};
#endif