Colours
This commit is contained in:
@@ -14,19 +14,21 @@ include_directories(OwOS "./")
|
||||
|
||||
|
||||
# Kernel source
|
||||
file(GLOB KERN_SRC "*.asm" "*.cpp" "kernel/*.asm" "kernel/*.cpp")
|
||||
file(GLOB KERN_SRC "*.asm" "*.cpp")
|
||||
file(GLOB KERN_LIB_SRC "kernel/*.cpp" "kernel/*.asm")
|
||||
|
||||
# Driver source
|
||||
file(GLOB DRIV_DISP_VGA "kernel/drivers/VGA/*.asm" "kernel/drivers/VGA/*.cpp")
|
||||
file(GLOB DRIV_DISP_TERM "kernel/drivers/terminal/*.asm" "kernel/drivers/terminal/*.cpp")
|
||||
file(GLOB DRIV_DISP_VGA "kernel/drivers/VGA/*.cpp" "kernel/drivers/VGA/*.asm")
|
||||
file(GLOB DRIV_DISP_TERM "kernel/drivers/terminal/*.cpp" "kernel/drivers/terminal/*.asm")
|
||||
|
||||
# Lib source
|
||||
file(GLOB LIB_STD "lib/std/*.asm" "lib/std/*.cpp")
|
||||
file(GLOB LIB_STD "lib/std/*.cpp" "lib/std/*.asm")
|
||||
|
||||
|
||||
set(SRCS ${KERN_SRC})
|
||||
|
||||
add_executable(OwOS ${SRCS} ${DRIV_DISP_VGA} ${LIB_STD})
|
||||
add_executable(OwOS ${KERN_SRC} ${KERN_LIB_SRC}
|
||||
${DRIV_DISP_VGA} ${DRIV_DISP_TERM}
|
||||
${LIB_STD})
|
||||
|
||||
set_target_properties(OwOS PROPERTIES OUTPUT_NAME "OwOS.bin")
|
||||
|
||||
|
||||
BIN
build/OwOS.bin
BIN
build/OwOS.bin
Binary file not shown.
BIN
build/OwOS.iso
BIN
build/OwOS.iso
Binary file not shown.
Binary file not shown.
28
kernel.cpp
28
kernel.cpp
@@ -1,21 +1,25 @@
|
||||
#include <kernel/drivers/VGA/vga.h>
|
||||
#include <kernel/drivers/terminal/terminal.h>
|
||||
|
||||
extern "C"
|
||||
|
||||
int kernel_main() {
|
||||
|
||||
putchar(0, 0, 'H', 0x01, 0x07);
|
||||
putchar(1, 0, 'A', 0x01, 0x07);
|
||||
putchar(2, 0, 'H', 0x01, 0x07);
|
||||
putchar(3, 0, 'A', 0x01, 0x07);
|
||||
putchar(4, 0, '!', 0x01, 0x07);
|
||||
putchar(5, 0, ' ', 0x01, 0x07);
|
||||
putchar(6, 0, 'P', 0x01, 0x07);
|
||||
putchar(7, 0, 'E', 0x01, 0x07);
|
||||
putchar(8, 0, 'N', 0x01, 0x07);
|
||||
putchar(9, 0, 'I', 0x01, 0x07);
|
||||
putchar(10, 0, 'S', 0x01, 0x07);
|
||||
putchar(11, 0, '!', 0x01, 0x07);
|
||||
cls();
|
||||
showCursor();
|
||||
|
||||
putcar(0, 0, 'H', 0x01, 0x07);
|
||||
putcar(1, 0, 'A', 0x01, 0x07);
|
||||
putcar(2, 0, 'H', 0x01, 0x07);
|
||||
putcar(3, 0, 'A', 0x01, 0x07);
|
||||
putcar(4, 0, '!', 0x01, 0x07);
|
||||
putcar(5, 0, ' ', 0x01, 0x07);
|
||||
putcar(6, 0, 'P', 0x01, 0x07);
|
||||
putcar(7, 0, 'E', 0x01, 0x07);
|
||||
putcar(8, 0, 'N', 0x01, 0x07);
|
||||
putcar(9, 0, 'I', 0x01, 0x07);
|
||||
putcar(10, 0, 'S', 0x01, 0x07);
|
||||
putcar(11, 0, '!', 0x01, 0x07);
|
||||
|
||||
for (;;)
|
||||
asm("hlt");
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
VGAChar_t* framebuffer = (VGAChar_t*)0xB8000;
|
||||
|
||||
void putchar(int x, int y, char c, char foreground, char background) {
|
||||
void putcar(int x, int y, char c, char foreground, char background) {
|
||||
framebuffer[(y * TERM_WIDTH) + x].c = c;
|
||||
framebuffer[(y * TERM_WIDTH) + x].foreground = foreground;
|
||||
framebuffer[(y * TERM_WIDTH) + x].background = background;
|
||||
|
||||
@@ -7,4 +7,4 @@ struct VGAChar_t {
|
||||
char background:4;
|
||||
}__attribute__((packed));
|
||||
|
||||
void putchar(int x, int y, char c, char foreground, char background);
|
||||
void putcar(int x, int y, char c, char foreground, char background);
|
||||
|
||||
@@ -0,0 +1,72 @@
|
||||
#include "terminal.h"
|
||||
|
||||
#include <kernel/kernio.h>
|
||||
|
||||
static const int TERMINAL_WIDTH = 80;
|
||||
static const int TERMINAL_HEIGHT = 24;
|
||||
|
||||
static char* frameBuffer = (char*)0xB8000;
|
||||
|
||||
static char clearColour = 0x0;
|
||||
static char bgColour = 0x0;
|
||||
static char fgColour = 0xF;
|
||||
|
||||
struct Cursor {
|
||||
uint8_t x;
|
||||
uint8_t y;
|
||||
} __attribute__((packed));
|
||||
|
||||
Cursor cursor;
|
||||
|
||||
void cls() {
|
||||
for (uint8_t x = 0; x < TERMINAL_WIDTH; x++) {
|
||||
for (uint8_t y = 0; y < TERMINAL_HEIGHT; y++) {
|
||||
frameBuffer[x + TERMINAL_WIDTH * y] = 0;
|
||||
}
|
||||
}
|
||||
|
||||
moveCursor(0,0);
|
||||
}
|
||||
|
||||
void putchar(char input) {
|
||||
|
||||
}
|
||||
|
||||
void write(char* input) {
|
||||
|
||||
}
|
||||
|
||||
void writeln(char* input) {
|
||||
write(input);
|
||||
nline();
|
||||
}
|
||||
|
||||
void nline() {
|
||||
|
||||
}
|
||||
|
||||
void setClearColour(char col) {
|
||||
clearColour = col;
|
||||
}
|
||||
|
||||
void showCursor() {
|
||||
outb(0x3D4, 0x0A);
|
||||
outb(0x3D5, (inb(0x3D5) & 0xC0) | 1);
|
||||
|
||||
outb(0x3D4, 0x0B);
|
||||
outb(0x3D5, (inb(0x3D5) & 0xE0) | 1);
|
||||
}
|
||||
|
||||
void hideCursor() {
|
||||
outb(0x3D4, 0x0A);
|
||||
outb(0x3D5, 0x20);
|
||||
}
|
||||
|
||||
void moveCursor(int x, int y) {
|
||||
uint16_t pos = y * TERMINAL_WIDTH + x;
|
||||
|
||||
outb(0x3D4, 0x0F);
|
||||
outb(0x3D5, (uint8_t) (pos & 0xFF));
|
||||
outb(0x3D4, 0x0E);
|
||||
outb(0x3D5, (uint8_t) ((pos >> 8) & 0xFF));
|
||||
}
|
||||
|
||||
@@ -1,5 +1,37 @@
|
||||
#include <kernel/drivers/VGA/vga.h>
|
||||
#include <lib/std/string.h>
|
||||
#include <lib/stdint.h>
|
||||
|
||||
void clear();
|
||||
template <typename T>
|
||||
void print(T input);
|
||||
enum {
|
||||
BLACK = 0x0,
|
||||
BLUE = 0x1,
|
||||
GREEN = 0x2,
|
||||
CYAN = 0x3,
|
||||
RED = 0x4,
|
||||
MAGENTA = 0x5,
|
||||
BROWN = 0x6,
|
||||
GREY = 0x7,
|
||||
DARK_GREY = 0x8,
|
||||
BRIGHT_BLUE = 0x9,
|
||||
BRIGHT_GREEN = 0xA,
|
||||
BRIGHT_CYAN = 0xB,
|
||||
BRIGHT_RED = 0xC,
|
||||
BRIGHT_MAGENTA = 0xD,
|
||||
YELLOW = 0xE,
|
||||
WHITE = 0xF,
|
||||
};
|
||||
|
||||
void cls();
|
||||
|
||||
void putchar(char input);
|
||||
|
||||
void write(char* input);
|
||||
void writeln(char* input);
|
||||
|
||||
void nline();
|
||||
|
||||
void setClearColour(char col);
|
||||
|
||||
void showCursor();
|
||||
void hideCursor();
|
||||
|
||||
void moveCursor(int x, int y);
|
||||
|
||||
@@ -1,13 +1 @@
|
||||
#include "kernio.h"
|
||||
|
||||
inline void outb(uint16_t port, uint8_t b) {
|
||||
asm("outb %0, %1" : : "a"(b), "Nd"(port));
|
||||
}
|
||||
|
||||
inline uint8_t inb(uint16_t port) {
|
||||
uint8_t ret;
|
||||
asm volatile ( "inb %1, %0"
|
||||
: "=a"(ret) // Output
|
||||
: "Nd"(port)); // Input
|
||||
return ret;
|
||||
}
|
||||
|
||||
@@ -1,4 +1,14 @@
|
||||
#include <lib/stdint.h>
|
||||
|
||||
inline void outb(uint16_t port, uint8_t b);
|
||||
inline uint8_t inb(uint16_t port);
|
||||
inline void outb(uint16_t port, uint8_t b) {
|
||||
asm("outb %0, %1" : : "a"(b), "Nd"(port));
|
||||
}
|
||||
|
||||
inline uint8_t inb(uint16_t port) {
|
||||
uint8_t ret;
|
||||
asm ( "inb %1, %0"
|
||||
: "=a"(ret) // Output
|
||||
: "Nd"(port)); // Input
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user