Get console building
This commit is contained in:
parent
5f0c65bf81
commit
c6eaba487c
3 changed files with 16 additions and 9 deletions
|
@ -8,14 +8,17 @@
|
|||
|
||||
#include "Console.hh"
|
||||
|
||||
namespace kernel {
|
||||
|
||||
/** Create a VGA color pair. */
|
||||
static inline uint8_t
|
||||
makeVGAColor(Console::Color fg,
|
||||
Console::Color bg)
|
||||
{
|
||||
return fg | bg << 4;
|
||||
return uint8_t(fg) | uint8_t(bg) << 4;
|
||||
}
|
||||
|
||||
|
||||
/** Create a VGA character entry. */
|
||||
static inline uint16_t
|
||||
makeVGAEntry(char c,
|
||||
|
@ -27,21 +30,20 @@ makeVGAEntry(char c,
|
|||
}
|
||||
|
||||
|
||||
namespace kernel {
|
||||
|
||||
Console::Console()
|
||||
: mBase(0xB8000),
|
||||
mCursor({0, 0})
|
||||
: mBase(reinterpret_cast<uint16_t *>(0xB8000)),
|
||||
mCursor{0, 0}
|
||||
{ }
|
||||
|
||||
|
||||
void
|
||||
Console::clear(Console::Color color)
|
||||
{
|
||||
const uint16_t color = makeVGAColor(Color::LightGray, Color::Blue);
|
||||
const uint16_t vgaColor = makeVGAColor(Color::LightGray, color);
|
||||
for (size_t y = 0; y < Console::Height; y++) {
|
||||
for (size_t x = 0; x < Console::Width; x++) {
|
||||
const size_t index = y * Console::Width + x;
|
||||
mBase[index] = makeVGAEntry(' ', color);
|
||||
mBase[index] = makeVGAEntry(' ', vgaColor);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -6,6 +6,10 @@
|
|||
* Declaration of the Console class. Presents an API for a VGA console.
|
||||
*/
|
||||
|
||||
//#include <stdbool.h>
|
||||
#include <stddef.h>
|
||||
#include <stdint.h>
|
||||
|
||||
namespace kernel {
|
||||
|
||||
struct Console
|
||||
|
@ -40,11 +44,11 @@ struct Console
|
|||
Console();
|
||||
|
||||
/** Clear the console to the provided color. */
|
||||
clear(Color color = Color::Black);
|
||||
void clear(Color color = Color::Black);
|
||||
|
||||
private:
|
||||
uint16_t *const mBase;
|
||||
Cursor mCursor;
|
||||
};
|
||||
|
||||
|
||||
} /* namespace kernel */
|
||||
|
|
|
@ -10,6 +10,7 @@ files = [
|
|||
'crti.s',
|
||||
'crtn.s',
|
||||
'main.cc',
|
||||
'Console.cc'
|
||||
]
|
||||
|
||||
toolchain_bin = Dir(os.environ['POLKA_TOOLCHAIN']).Dir('bin')
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue