Continuing terminal I/O

- Made stdio.h work
- Moved printFiletable back into kernel.c
- TODO: Add stdio.h to all files that should use it (probably next commmit)
- Added some more global addresses. There's a memory layout, but i'm not using it
- Got cursor to be drawn
- Calc program now gets user input
This commit is contained in:
2024-05-28 17:08:49 +02:00
parent 536f6b2320
commit ff07696dc6
17 changed files with 185 additions and 203 deletions
+3
View File
@@ -4,5 +4,8 @@
__attribute__ ((section("entry")))
void main() {
print("Hello, World!\n");
char in[32];
read(in);
print(in);
return;
}
+46 -5
View File
@@ -1,6 +1,7 @@
#include <stdio.h> // TODO: Add stdio.h to every header that needs it
#include <interrupt/idt.h>
#include <interrupt/exceptions.h>
#include <interrupt/syscall.h>
#include <interrupt/syscalls.h>
#include <interrupt/pic.h>
#include <interrupt/pit.h>
#include <interrupt/rtc.h>
@@ -25,6 +26,7 @@
#define PROMPT "#> "
// Function declarations
void printFiletable(char* ft);
void printPhysicalMemmap();
__attribute__ ((section("entry")))
@@ -49,15 +51,15 @@ void main() {
setupKeyboard();
// Screen setup
readFile("term16n.fnt", font);
loadFont("term16n.fnt");
clear();
print("kern.\n\n");
// Run Interactive Shell Program
// TODO: Make it in another file
while (1) {
print(PROMPT);
char input[MAX_INPUT_LENGTH];
char input[256];
read(input);
if (input[0] == '\n') continue;
@@ -300,7 +302,7 @@ void main() {
print("Loading ");
print(file->filename);
print("...\n");
memcpy(entryPoint, font, file->length * 512);
memcpy(entryPoint, (char*)FONT_LOC, file->length * 512);
print("Font loaded\n");
} else {
for (size_t i = 0; i < file->length * 512; i++) {
@@ -326,6 +328,45 @@ void main() {
while (1); // Just hang
}
void printFiletable(char* ft) {
while (*ft != '\0') {
char filename[15] = { 0 };
uint8_t offset = 0;
for (uint8_t i = 0; i < 14; i++) {
if (i == 9) {
filename[offset++] = '.';
continue;
}
if (*ft != '\0') { filename[offset++] = *ft; }
ft++;
}
ft++; // RESERVED
uint8_t sector = *ft++;
uint8_t size = *ft++;
if (sector < 10) putc('0');
if (sector == 0) putc('0');
else print(itoa(sector, 10));
print(": ");
print(filename);
for (uint8_t i = 14 - strlen(filename); i > 0; i--) {
putc(' ');
}
print(" | ");
if (size >> 1) {
print(itoa(size >> 1, 10));
if (size & 0x01) { print(".5"); }
print("kB\n");
} else {
print(itoa(size*512, 10));
print("B\n");
}
}
}
void printPhysicalMemmap() {
uint32_t entryCount = *(uint32_t*)SMAP_ADDRESS;
smapEntry_t* smapEntry = (smapEntry_t*)(SMAP_ADDRESS+4);
+5 -4
View File
@@ -3,6 +3,7 @@
%define STAGE3_LOC 0x50000
%define VIDMEM 0xb800
%define MODE_INFO_BLOCK_LOC 0x9000
start:
mov [driveNum], dl
@@ -319,7 +320,7 @@ protected_start:
; Store VBE Mode Info Block in memory
mov esi, modeInfoBlock
mov edi, 0x9000 ; Destination
mov edi, MODE_INFO_BLOCK_LOC ; Destination
mov ecx, 64 ; 64 * 4 = 256B (size of modeInfoBlock)
rep movsd
@@ -369,9 +370,9 @@ DATA_SEG equ GDT.dataDescriptor - GDT.start
;; VBE Stuff
;; !! IF YOU WANT TO SELECT ANY VALUE IN THE SETUP, SET THESE TO ZERO !!
width: dw 0
height: dw 0
bpp: db 0
width: dw 1920
height: dw 1080
bpp: db 32
offset: dw 0
_segment: dw 0 ; segment is a keyword
+1 -1
View File
@@ -3,7 +3,7 @@
#include <memory/addresses.h>
#include <disk/disk.h>
#include <disk/filesys.h>
#include <screen/text.h>
#include <screen/gfxmode.h>
__attribute__ ((section("entry")))
void main() {