Look up the global constructor list that the linker outputs, and run them all. Required creation of the `kutil::no_construct` template for objects that are constructed before the global constructors are run. Also split the `memory_initialize` function into two - one for just those objects that need to happen before the global ctors, and one after. Tags: memory c++
32 lines
474 B
C++
32 lines
474 B
C++
#include "io.h"
|
|
#include "serial.h"
|
|
|
|
serial_port g_com1(COM1);
|
|
|
|
|
|
serial_port::serial_port() :
|
|
m_port(0)
|
|
{
|
|
}
|
|
|
|
serial_port::serial_port(uint16_t port) :
|
|
m_port(port)
|
|
{
|
|
}
|
|
|
|
bool serial_port::read_ready() { return (inb(m_port + 5) & 0x01) != 0; }
|
|
bool serial_port::write_ready() { return (inb(m_port + 5) & 0x20) != 0; }
|
|
|
|
char
|
|
serial_port::read() {
|
|
while (!read_ready());
|
|
return inb(m_port);
|
|
}
|
|
|
|
void
|
|
serial_port::write(char c) {
|
|
while (!write_ready());
|
|
outb(m_port, c);
|
|
}
|
|
|