Moving components modules to a more proper directory

This commit is contained in:
shockrah committed 2023-03-30 22:40:08 -07:00
1 parent 044d5a75b5
commit cc1bb63e27
26 files changed
+11 -148

No files matched your search

File renamed without changes.
File renamed without changes.
View File
File renamed without changes.
+4 -1
View File
@@ -1,6 +1,7 @@
#ifndef GDT_H
#define GDT_H
#include "types.h"
#define NO_GDT_ENTRIES 5
struct GDT_Entry {
@@ -27,3 +28,5 @@ extern void load_gdt();
void gdt_configure_entry(u32 entry, u32 base, u32 limit, u8 access, u8 gran);
void gdt_configure();
#endif
File renamed without changes.
@@ -151,7 +151,7 @@ common_irq_handler:
; Remapped IRQ's for the APIC
# starting from irq 0 -> 15 but remapped to 32 -> 47
; starting from irq 0 -> 15 but remapped to 32 -> 47
irq 0, 32
irq 1, 33
irq 2, 34
File renamed without changes.
File renamed without changes.
View File
File renamed without changes.
View File
File renamed without changes.
View File
File renamed without changes.
View File
File renamed without changes.
View File
File renamed without changes.
View File
File renamed without changes.
File renamed without changes.
File renamed without changes.
+6
View File
@@ -0,0 +1,6 @@
# Components Library
These are the smaller components that give the kernel actual behaviors.
These are pieces that are *practically* required for the OS to function at a
basic level but otherwise are not *technically* required for sheer load-level
operations.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
View File
File renamed without changes.
View File
File renamed without changes.
-123
View File
@@ -1,123 +0,0 @@
#include "types.h"
#include "kbd.h"
#include "stlio.h"
#include "pit.h"
extern char kbd_key;
extern u8 kbd_state;
static u8 COLOR_FG = Green;
static u8 COLOR_BG = White;
#define write_char(c) write_cell_fb(c, COLOR_FG, COLOR_BG)
// We are assuming null-terminated strings here
u32 strlen(const char* buffer) {
u32 i = 0;
char c = buffer[i];
while(c != '\0') {
i++;
c = buffer[i];
}
return i;
}
u32 strcmp(const char* left, const char* right) {
u32 s = strlen(left);
for(u32 i = 0; i<s; i++) {
if(left[i] != right[i]) {
return 1;
}
}
return 0;
}
u32 write(const char* buffer, const u32 size) {
u32 i;
for(i = 0; i < size; i++) {
// cheesy but whatever
if(buffer[i] == '\n') {
frame_buffer_newline();
}
else {
write_char(buffer[i]);
}
}
return i;
}
// this is here to get around gcc's optimizations
static void __char_set(u8* dest, u8 desire) {
*dest = desire;
}
static inline void __put_ch(const char c) {
if(c == '\n') {
frame_buffer_newline();
}
else {
write_char(c);
}
}
u32 read(char* buffer, u32 size) {
// try the timing thing again after this
u32 bytes = 0;
u8 state = 0;
while(bytes < size) {
// All of these calls to __char_set is to avoid gcc from optimizing things away and ruining intended behavior
// Basically gcc will tread all assignments here as one time deals so we have to cram that operation into a routine
// by itself, that way the compiler won't try to optimize and do the assignment once. instead it does the call
// every iteration
__char_set(&state, kbd_state);
if(pit_timer_ticks - kbd_time < 0x20 && state == KBD_RELEASE) {
__char_set(&(buffer[bytes]), (u8)kbd_key);
if(kbd_key == '\n') {
__put_ch('\n');
return ++bytes;
}
bytes++;
__char_set(&kbd_state, KBD_WAITING); // reset the kbd_state since we've now used it
__put_ch(kbd_key);
}
pit_timer_wait(1);
}
kbd_key = KBD_RELEASE;
buffer[size-1] = '\0';
return bytes;
}
void printf(const char* fmt) {
// Variadic fuller version of print on seperate branch but its nowhere near stable/ready/working
u32 size = strlen(fmt);
for(u32 i = 0; i < size;i++) {
if(fmt[i] == '\n') {
frame_buffer_newline();
}
else {
write_char(fmt[i]);
}
}
}
void printhex(u32 num) {
// Prints our hex version of whatever is given
const char _chars[] = "0123456789abcdef";
u32 idx = 0; // used as hash into the _chars mapping
// iterate over each nibble
printf("0x");
for(u32 i = 0 ;i < 8;i++) {
idx = (num << (i * 4)) & 0xf0000000;
idx = idx >> 28;
putch(_chars[idx]);
}
}
void putch(const char c) {
if(c == '\n') {
frame_buffer_newline();
}
else {
write_char(c);
}
}
-23
View File
@@ -1,23 +0,0 @@
#ifndef STLIO_H
#define STLIO_H
#include "types.h"
#include "framebuffer.h"
// Frame buffer driver
// NOTE: not getting computed at compile time so we always have a call
#define LINE_LENGTH COLUMNS
u32 strlen(const char*);
u32 strcmp(const char*, const char*);
u32 write(const char*, const u32);
u32 read(char*, u32);
void printf(const char*);
void printhex(u32);
void putch(const char);
#endif