Okay, just create a console object when you need one... for now
This commit is contained in:
parent
e86960a283
commit
a7d0607c92
3 changed files with 10 additions and 41 deletions
|
@ -10,16 +10,6 @@
|
||||||
|
|
||||||
namespace kernel {
|
namespace kernel {
|
||||||
|
|
||||||
/*
|
|
||||||
* TODO: The build currently complains about missing __cxa_guard_acquire and
|
|
||||||
* __cxa_guard_release symbols if I add it there though. Once I've written
|
|
||||||
* those, this can be moved Console::systemConsole().
|
|
||||||
*
|
|
||||||
* See http://wiki.osdev.org/C%2B%2B for details.
|
|
||||||
*/
|
|
||||||
static Console sSystemConsole;
|
|
||||||
|
|
||||||
|
|
||||||
/** Create a VGA color pair. */
|
/** Create a VGA color pair. */
|
||||||
static inline uint8_t
|
static inline uint8_t
|
||||||
makeVGAColor(Console::Color fg,
|
makeVGAColor(Console::Color fg,
|
||||||
|
@ -39,21 +29,10 @@ makeVGAEntry(char c,
|
||||||
return c16 | color16 << 8;
|
return c16 | color16 << 8;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
* Static
|
|
||||||
*/
|
|
||||||
|
|
||||||
auto
|
|
||||||
Console::systemConsole() -> Console&
|
|
||||||
{
|
|
||||||
return sSystemConsole;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Public
|
* Public
|
||||||
*/
|
*/
|
||||||
|
|
||||||
// TODO: Make this private once the kernel supports local static variables.
|
|
||||||
Console::Console()
|
Console::Console()
|
||||||
: mBase(reinterpret_cast<uint16_t *>(0xB8000)),
|
: mBase(reinterpret_cast<uint16_t *>(0xB8000)),
|
||||||
mCursor{0, 0},
|
mCursor{0, 0},
|
||||||
|
|
|
@ -41,8 +41,6 @@ struct Console
|
||||||
static const size_t Width = 80;
|
static const size_t Width = 80;
|
||||||
static const size_t Height = 25;
|
static const size_t Height = 25;
|
||||||
|
|
||||||
static auto systemConsole() -> Console&;
|
|
||||||
|
|
||||||
Console();
|
Console();
|
||||||
|
|
||||||
/** Clear the console to the provided color. */
|
/** Clear the console to the provided color. */
|
||||||
|
|
28
src/Main.cc
28
src/Main.cc
|
@ -14,38 +14,30 @@
|
||||||
extern "C"
|
extern "C"
|
||||||
void
|
void
|
||||||
kearly()
|
kearly()
|
||||||
{ }
|
|
||||||
|
|
||||||
|
|
||||||
/** The beginning of the world... */
|
|
||||||
extern "C"
|
|
||||||
void
|
|
||||||
kmain()
|
|
||||||
{
|
{
|
||||||
auto console = kernel::Console::systemConsole();
|
kernel::Console console;
|
||||||
console.clear(kernel::Console::Color::Blue);
|
console.clear(kernel::Console::Color::Blue);
|
||||||
console.writeString("Hello world!\n");
|
console.writeString("Loading system ...\n");
|
||||||
|
|
||||||
/*
|
|
||||||
* TODO: The performance of this loop slowed down a _lot_ (7 to 8 orders of
|
|
||||||
* magnitude according to the busy loop) when I moved this code from
|
|
||||||
* kearly() to here. I wonder if it has something to do with object
|
|
||||||
* initialization? Should probably investigate some.
|
|
||||||
*/
|
|
||||||
volatile int foo = 0;
|
volatile int foo = 0;
|
||||||
int j = 0;
|
|
||||||
int i = 0;
|
int i = 0;
|
||||||
for (;;) {
|
for (;;) {
|
||||||
if (j == 0) {
|
if (i == 0) {
|
||||||
console.writeString("--- MARK ---\n");
|
console.writeString("--- MARK ---\n");
|
||||||
}
|
}
|
||||||
console.writeChar('a' + i);
|
console.writeChar('a' + i);
|
||||||
console.writeChar('\n');
|
console.writeChar('\n');
|
||||||
i = (i + 1) % 26;
|
i = (i + 1) % 26;
|
||||||
j = (j + 1) % 500;
|
|
||||||
|
|
||||||
for (uint32_t k = 0; k < (2u << 20) - 1; k++) {
|
for (uint32_t k = 0; k < (2u << 20) - 1; k++) {
|
||||||
foo /= 2;
|
foo /= 2;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/** The beginning of the world... */
|
||||||
|
extern "C"
|
||||||
|
void
|
||||||
|
kmain()
|
||||||
|
{ }
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue