Merge pull request #37 from E-Almqvist/refactor

Refactor
paging
Elias Almqvist 3 years ago committed by GitHub
commit 33e8976fd8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 2
      bootloader/bootloader.asm
  2. 2
      bootloader/pm/vga/print.asm
  3. 19
      drivers/vga.c
  4. 2
      drivers/vga.h
  5. 29
      kernel/kernel.c
  6. 2
      kernel/kernel.h
  7. 4
      kernel/kernel_entry.asm
  8. 7
      kernel/memory.c

@ -87,7 +87,7 @@ load_kernel:
stat_pm_init: db "Entering 32bit Protected Mode...", ASCII_END
stat_kernel_load: db "Loading kernel into memory...", ASCII_END
stat_boot_success: db "Booting complete!", ASCII_END
stat_boot_success: db "Booting finished. Loading kernel...", ASCII_END
BOOT_DRIVE: db 0

@ -3,7 +3,7 @@
; VGA base address: 0xb8000
; Charpos = 0xb8000 + 2(row*80 + col)
vga_color_buf: db 0x0f ; Buffer to be changed so that we can choose colors!
vga_color_buf: db 0x7f ; Buffer to be changed so that we can choose colors!
vga_print:
pusha

@ -12,7 +12,10 @@ void vga_init() {
port_outb(0x3d5, 0x20);
// Clear screen
clear_screen();
// clear_row(0);
// clear_screen();
set_cursor_pos(0, 11);
}
/*
@ -23,8 +26,9 @@ char* get_memory_charpos(unsigned int col, unsigned int row) {
}
void writechar(char c, unsigned int col, unsigned int row, int attribute_byte) {
if( !attribute_byte )
attribute_byte = 0x0f;
attribute_byte = DEFAULT_COLOR;
char* mem = get_memory_charpos(col, row);
*mem = c; // Write the character
@ -41,10 +45,15 @@ void set_cursor_pos(unsigned int col, unsigned int row) {
/*
Graphics Functions
*/
void clear_screen() {
void clear_row(unsigned int row) {
for( int c = 0; c < MAX_COLS; c++ )
for( int r = 0; r < MAX_ROWS; r++ )
writechar(0x20, c, r, 0xf0);
writechar(0x20, c, row, 0x0);
}
void clear_screen() {
for( int r = 0; r < MAX_ROWS; r++ )
clear_row(r);
}
/*

@ -1,6 +1,7 @@
#define VGA_ADDRESS (char*)0xb8000
#define VGA_ADDRESS_MAX (char*)0xb8fa0
#define DEFAULT_COLOR 0x07
#define MAX_ROWS 25
#define MAX_COLS 80
@ -12,6 +13,7 @@ enum align {LEFT, RIGHT, MIDDLE};
char* get_memory_charpos(unsigned int col, unsigned int row);
void writechar(char c, unsigned int col, unsigned int row, int colorcode);
void clear_screen();
void clear_row(unsigned int row);
void set_cursor_pos();
void print();
void println();

@ -1,24 +1,35 @@
#include "kernel.h"
#include "memory.h"
#include "../drivers/vga.h"
#include "../lib/str.h"
#include "../lib/strf.h"
void main() {
void display_status(char* status_text) {
clear_row(0);
set_cursor_pos(0, 0);
print(status_text, 0x7f);
}
void init() {
display_status("Kernel loaded");
vga_init(); // Initialize the screen first
// i.e. clear the screen et cetera.
char* title = "eOS Version 0.2 2021";
set_cursor_pos(0, 2);
printalign(title, 0xf0, MIDDLE);
println(title, DEFAULT_COLOR);
char* subtitle = "A x86 operating system, licenced under GPL-2.0";
set_cursor_pos(0, 3);
printalign(subtitle, 0xf8, MIDDLE);
println(subtitle, DEFAULT_COLOR);
/*
print("Kernel offset: ", DEFAULT_COLOR);
println("0x1000", DEFAULT_COLOR);
*/
char* strbuf = "String concat: ";
char* str2 = "WORKS! :D";
char* strbuf = "Concat test: ";
char* str2 = "Works!";
strbuf = strcat(strbuf, str2);
set_cursor_pos(0, 0);
println(strbuf, 0xf0);
println(strbuf, DEFAULT_COLOR);
}

@ -0,0 +1,2 @@
void init();
void display_status(char*);

@ -1,5 +1,5 @@
[bits 32]
[extern main]
[extern init]
call main
call init
jmp $

@ -1,9 +1,2 @@
#include "memory.h"
char* malloc(unsigned int size) {
return " ";
}
void mfree(char* p) {
}

Loading…
Cancel
Save