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
|
||||
KERNEL_STACK_SIZE equ 4096
|
||||
extern test_dispatcher
|
||||
extern load_gdt
|
||||
extern struct example
|
||||
|
||||
section .text
|
||||
; align all instructions to 4 byte boundary by the x86 instruction set law
|
||||
@ -19,7 +21,10 @@ align 4
|
||||
dd FLAGS
|
||||
dd CHECKSUM
|
||||
|
||||
; sets up our gdt and segment selectors for later use
|
||||
|
||||
loader:
|
||||
call load_gdt
|
||||
call test_dispatcher
|
||||
|
||||
.loop:
|
||||
|
2
makefile
2
makefile
@ -33,7 +33,7 @@ os.iso: kernel.elf
|
||||
$(ASM) $(AFLAGS) $< -o $@
|
||||
|
||||
# Building C objecets
|
||||
core/%.o: %.c
|
||||
%.o: %.c
|
||||
$(CC) $(CFLAGS) $< -o $@
|
||||
|
||||
# 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
|
||||
|
||||
global serialport_write_byte
|
||||
|
63
stlio.c
63
stlio.c
@ -31,65 +31,16 @@ u32 read(const u32 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) {
|
||||
u32 i;
|
||||
// Variadic fuller version of print on seperate branch but its nowhere near stable/ready/working
|
||||
u32 size = strlen(fmt);
|
||||
for(i = 0; i < size;i++) {
|
||||
char c = fmt[i];
|
||||
switch(c) {
|
||||
case '\n': {
|
||||
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);
|
||||
}
|
||||
for(u32 i = 0; i < size;i++) {
|
||||
if(fmt[i] == '\n') {
|
||||
frame_buffer_newline();
|
||||
}
|
||||
else {
|
||||
write_char(fmt[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user