reduced complexity on master branch for now as i setup for gdt things
This commit is contained in:
parent
9e7effcc7f
commit
ec9cd34dc6
5
gdt.s
Normal file
5
gdt.s
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
global load_gdt
|
||||||
|
|
||||||
|
; lgdt can only be used from assembly so here we are
|
||||||
|
load_gdt:
|
||||||
|
lgdt [eax]
|
5
loader.s
5
loader.s
@ -10,6 +10,8 @@ CHECKSUM equ -MAGIC_NUMBER
|
|||||||
; size in bytes of stack
|
; size in bytes of stack
|
||||||
KERNEL_STACK_SIZE equ 4096
|
KERNEL_STACK_SIZE equ 4096
|
||||||
extern test_dispatcher
|
extern test_dispatcher
|
||||||
|
extern load_gdt
|
||||||
|
extern struct example
|
||||||
|
|
||||||
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
|
||||||
@ -19,7 +21,10 @@ align 4
|
|||||||
dd FLAGS
|
dd FLAGS
|
||||||
dd CHECKSUM
|
dd CHECKSUM
|
||||||
|
|
||||||
|
; sets up our gdt and segment selectors for later use
|
||||||
|
|
||||||
loader:
|
loader:
|
||||||
|
call load_gdt
|
||||||
call test_dispatcher
|
call test_dispatcher
|
||||||
|
|
||||||
.loop:
|
.loop:
|
||||||
|
2
makefile
2
makefile
@ -33,7 +33,7 @@ os.iso: kernel.elf
|
|||||||
$(ASM) $(AFLAGS) $< -o $@
|
$(ASM) $(AFLAGS) $< -o $@
|
||||||
|
|
||||||
# Building C objecets
|
# Building C objecets
|
||||||
core/%.o: %.c
|
%.o: %.c
|
||||||
$(CC) $(CFLAGS) $< -o $@
|
$(CC) $(CFLAGS) $< -o $@
|
||||||
|
|
||||||
# Running (no recipes called)
|
# Running (no recipes called)
|
||||||
|
2
ports.s
2
ports.s
@ -1,4 +1,4 @@
|
|||||||
; Helpers for frame buffer which pretty much have to to be
|
; Helpers for serial ports which pretty much have to to be
|
||||||
; written in asm
|
; written in asm
|
||||||
|
|
||||||
global serialport_write_byte
|
global serialport_write_byte
|
||||||
|
59
stlio.c
59
stlio.c
@ -31,65 +31,16 @@ u32 read(const u32 n) {
|
|||||||
return n;
|
return n;
|
||||||
}
|
}
|
||||||
|
|
||||||
char* tohex(u32* data, u32 size) {
|
|
||||||
static char ret[19] = {'\0'}; // 8 bytes + \0
|
|
||||||
ret[0] = '0'; ret[1] = 'x';
|
|
||||||
const char* map = "0123456789abcdef"; // muh 'tism
|
|
||||||
switch(size) {
|
|
||||||
// (unsigned)char/u8/s8
|
|
||||||
case (1): {
|
|
||||||
u8 idx;
|
|
||||||
u8 val = (u8)*data;
|
|
||||||
for(u32 i = 0; i<2; i++ ) {
|
|
||||||
idx = val & 0x0f;
|
|
||||||
ret[19-i] = map[idx];
|
|
||||||
vall >>= 4;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
// s16/u16
|
|
||||||
case (2): {
|
|
||||||
for(u32 i = 0; i<4; i++) {
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
// s32/u64
|
|
||||||
case (4): {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
// s64/u64
|
|
||||||
case (8): {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
default: return "Bad-Size";
|
|
||||||
}
|
|
||||||
return "sadf";
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void printf(char* fmt) {
|
void printf(char* fmt) {
|
||||||
u32 i;
|
// Variadic fuller version of print on seperate branch but its nowhere near stable/ready/working
|
||||||
u32 size = strlen(fmt);
|
u32 size = strlen(fmt);
|
||||||
for(i = 0; i < size;i++) {
|
for(u32 i = 0; i < size;i++) {
|
||||||
char c = fmt[i];
|
if(fmt[i] == '\n') {
|
||||||
switch(c) {
|
|
||||||
case '\n': {
|
|
||||||
frame_buffer_newline();
|
frame_buffer_newline();
|
||||||
break;
|
|
||||||
}
|
|
||||||
case '%': {
|
|
||||||
/* only do something if the situation calls for it
|
|
||||||
* NOTE: this call might not do anything interesting
|
|
||||||
*/
|
|
||||||
if((i+1) < size) {
|
|
||||||
write_char(c);
|
|
||||||
i += 2;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
default: {
|
|
||||||
write_char(c);
|
|
||||||
}
|
}
|
||||||
|
else {
|
||||||
|
write_char(fmt[i]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
4
stlio.h
4
stlio.h
@ -2,7 +2,11 @@
|
|||||||
#include "framebuffer.h"
|
#include "framebuffer.h"
|
||||||
// Frame buffer driver
|
// Frame buffer driver
|
||||||
|
|
||||||
|
// NOTE: not getting computed at compile time so we always have a call
|
||||||
u32 strlen(char*);
|
u32 strlen(char*);
|
||||||
|
|
||||||
u32 write(const char*, const u32);
|
u32 write(const char*, const u32);
|
||||||
|
|
||||||
u32 read(const u32);
|
u32 read(const u32);
|
||||||
|
|
||||||
void printf(char*);
|
void printf(char*);
|
||||||
|
Loading…
Reference in New Issue
Block a user