Merge branch 'master' of gitlab.com:shockrahwow/jankos

This commit is contained in:
shockrahwow 2019-02-18 15:04:35 -08:00
commit d14e1ea8d1
4 changed files with 36 additions and 30 deletions

View File

@ -10,25 +10,26 @@
static char* Frame_Buffer = (char*)FRAME_BUFFER_ADDR; static char* Frame_Buffer = (char*)FRAME_BUFFER_ADDR;
static char* Frame_Buffer_End = (char*)(FRAME_BUFFER_ADDR + AREA); static char* Frame_Buffer_End = (char*)(FRAME_BUFFER_ADDR + AREA);
// Writes character to a given cell in the framebuffer // Writes character to a given cell in the framebuffer
// Safety handled by caller function // @cell parameter is the logical (linear)index into the buffer
// _not_ the actual offset from the buffer addr
// also proper location is caller's responsibility // also proper location is caller's responsibility
void write_cell(unsigned cell, char c, char fg, char bg) { void writech_fb(unsigned cell, char c, char fg, char bg) {
Frame_Buffer[cell] = c; Frame_Buffer[cell] = c;
Frame_Buffer[cell+1] = (fg & 0x0f << 4) | (bg & 0x0f); Frame_Buffer[cell+1] = (fg & 0x0f << 4) | (bg & 0x0f);
} }
void clear_buffer() { /* this probably doesn't belong here */
char* fp = Frame_Buffer; void print_fb(char* str) {
while(fp!=Frame_Buffer_End) { for(unsigned i =0;i<strlen(str);i++) {
*fp = 0x00; writech_fb(FRAME_CELL(i), str[i], Green, White);
}
}
void print(char* str) {
for(unsigned i =0;i<strlen(str);i+=2) {
write_cell(i, str[i], Green, White);
} }
} }
void yote() { /* moving the cursor to our given position */
print("asdf"); void cursor_adjust() {
// TODO: c ipmle
}
/* generic test func for this module */
void test_fb() {
print_fb("adsf");
} }

View File

@ -4,7 +4,13 @@
#define AREA ( COLUMNS * ROWS ) #define AREA ( COLUMNS * ROWS )
// address of our frame buffer
#define FRAME_BUFFER_ADDR 0x000B8000 #define FRAME_BUFFER_ADDR 0x000B8000
// Logical index of a cell in the frame buffer
#define FRAME_CELL(cell_) (cell_ * 2)
// Colors available in text framebuffer
#define Black 0x01 #define Black 0x01
#define Blue 0x02 #define Blue 0x02
#define Green 0x03 #define Green 0x03
@ -22,10 +28,9 @@
#define LightBrown 0x0e #define LightBrown 0x0e
#define White 0x0f #define White 0x0f
void write_cell(unsigned cell, char c , char fg, char bg); void writech_fb(unsigned cell, char c , char fg, char bg);
void clear_buffer(); void print_fb(char* str);
void print(char* str); /* Testing function because yote squad in here yeye */
void test_fb();
void yote();

Binary file not shown.

View File

@ -1,6 +1,7 @@
; since we have no stack we have to create one for the OS ; since we have no stack we have to create one for the OS
global loader global loader
; this section is partly handled by nasm tolerating some minor bs
MAGIC_NUMBER equ 0x1BADB002 MAGIC_NUMBER equ 0x1BADB002
FLAGS equ 0x0 FLAGS equ 0x0
CHECKSUM equ -MAGIC_NUMBER CHECKSUM equ -MAGIC_NUMBER
@ -9,18 +10,9 @@ CHECKSUM equ -MAGIC_NUMBER
; size in bytes of stack ; size in bytes of stack
KERNEL_STACK_SIZE equ 4096 KERNEL_STACK_SIZE equ 4096
; external labels(cdecl) calling convention
extern yote
section .bss ; external labels(cdecl) calling convention
align 4 ; aligning to bytes for x86(32-bit) reasons extern test
; because this is the first thing we actually do (virual)address 0x00000000 will
; contain 4KB of memory for our stack
kernel_stack:
resb KERNEL_STACK_SIZE ; reserver bytes instruction
; point to what will be bottom of stack
; which will grow down towards (virtual)address 0x00000000
mov esp, kernel_stack + KERNEL_STACK_SIZE
section .text section .text
; align all instructions to 4 byte boundary by the x86 instruction set law ; align all instructions to 4 byte boundary by the x86 instruction set law
@ -31,7 +23,15 @@ align 4
dd CHECKSUM dd CHECKSUM
loader: loader:
call yote call test
.loop: .loop:
jmp .loop jmp .loop
section .bss
align 4 ; aligned to 4 bytes for performance
kernel_stack:
; (res)erve (b)ytes x
resb KERNEL_STACK_SIZE ; 4k of stack size in mem
; now we setup the stack pointer for our kernel
mov esp, kernel_stack + KERNEL_STACK_SIZE