Changed every include for using '#include "header.h"' to use '#include <header.h>', also got the keyboard and timer working again

This commit is contained in:
2024-05-06 19:57:53 +02:00
parent 1d71a4e384
commit b2248f1a7d
13 changed files with 61 additions and 70 deletions
+2 -2
View File
@@ -1,8 +1,8 @@
#ifndef DRIVE_H
#define DRIVE_H
#include "stdint.h"
#include "system.h"
#include <stdint.h>
#include <system.h>
#define PIO_PORT 0x1f0
#define READ_COMMAND 0x20
+2 -20
View File
@@ -1,26 +1,8 @@
#ifndef ISRS_H
#define ISRS_H
#include "idt.h"
#include "screen.h"
/*
Alignment Check
Machine Check
Reserved
...
Reserved
*/
// TODO: Make proper handlers
__attribute__ ((naked)) // Temporary handler
void excpHandler(void) {
__asm__ volatile (
".intel_syntax\n"
"iretd\n"
".att_syntax"
);
}
#include <idt.h>
#include <screen.h>
// Exception handlers
__attribute__ ((interrupt))
+3 -3
View File
@@ -1,9 +1,9 @@
#ifndef GRAPHICS_H
#define GRAPHICS_H
#include "stdint.h"
#include "screen.h"
#include "math.h"
#include <stdint.h>
#include <screen.h>
#include <math.h>
#define rgb(r,g,b) ( ((r) << 16 | (g) << 8 | (b)) & 0x00ffffff )
+2 -2
View File
@@ -1,8 +1,8 @@
#ifndef IDT_H
#define IDT_H
#include "stdint.h"
#include "screen.h"
#include <stdint.h>
#include <screen.h>
#define TRAP_GATE_FLAGS 0x8f // P = 1, DPL = 00, S = 0, Type = 1111 (32-bit Trap gate)
#define INT_GATE_FLAGS 0x8e // P = 1, DPL = 00, S = 0, Type = 1110 (32-bit Int gate)
+12 -9
View File
@@ -1,12 +1,12 @@
#ifndef KEYBOARD_H
#define KEYBOARD_H
#include "idt.h"
#include "pic.h"
#include "system.h"
#include "screen.h"
#include "stdint.h"
#include "stdbool.h"
#include <idt.h>
#include <pic.h>
#include <system.h>
#include <screen.h>
#include <stdint.h>
#include <stdbool.h>
// Keycodes
#define LEFT_SHIFT_PRESS 0x2a
@@ -52,7 +52,8 @@ bool echo = false;
bool canBackspace = false;
// TODO: Refactor this
void keyboardHandler() {
__attribute__ ((interrupt))
void keyboardHandler(intFrame_t* iframe) {
uint8_t scancode;
scancode = inb(0x60);
@@ -74,6 +75,8 @@ void keyboardHandler() {
if (bufferLen > 0) canBackspace = true;
else canBackspace = false;
}
sendPicEOI(1);
}
// TODO: Add a 'char readc();' function that returns a single read character and use it for read()
@@ -92,8 +95,8 @@ char* read(char terminator) {
}
void setupKeyboard() {
idtSetGate(33, keyboardHandler, INT_GATE_FLAGS);
setIrqMask(1);
idtSetGate(0x21, keyboardHandler, INT_GATE_FLAGS);
unsetIrqMask(1);
}
#endif
+2 -2
View File
@@ -1,8 +1,8 @@
#ifndef PHYSICAL_MEM_MANAGER_H
#define PHYSICAL_MEM_MANAGER_H
#include "string.h"
#include "stdint.h"
#include <string.h>
#include <stdint.h>
#define BLOCK_SIZE 4096 // 4kB
#define BLOCKS_PER_BYTE 8
+1 -1
View File
@@ -1,7 +1,7 @@
#ifndef PIC_H
#define PIC_H
#include "system.h"
#include <system.h>
// PIC I/O Ports
#define PIC_1_CMD 0x20
+2 -2
View File
@@ -1,8 +1,8 @@
#ifndef SCREEN_H
#define SCREEN_H
#include "stdint.h"
#include "string.h"
#include <stdint.h>
#include <string.h>
// Basic full saturation colors
#define BLACK 0x00000000 // 0
+1 -1
View File
@@ -1,7 +1,7 @@
#ifndef STRING_H
#define STRING_H
#include "stdint.h"
#include <stdint.h>
// Source: http://www.strudel.org.uk/itoa/
char* itoa(uint32_t val, uint8_t base) {
+1 -1
View File
@@ -1,7 +1,7 @@
#ifndef SYSCALL_H
#define SYSCALL_H
#include "screen.h"
#include <screen.h>
// System call count
#define MAX_SYSCALLS 2
+1 -1
View File
@@ -1,7 +1,7 @@
#ifndef SYSTEM_H
#define SYSTEM_H
#include "stdint.h"
#include <stdint.h>
// Port functions
uint8_t inb(uint16_t port) {
+11 -8
View File
@@ -1,27 +1,30 @@
#ifndef TIMER_H
#define TIMER_H
#include "stdint.h"
#include "idt.h"
#include "irq.h"
#include "system.h"
#include "screen.h"
#include <stdint.h>
#include <idt.h>
#include <pic.h>
#include <system.h>
#include <screen.h>
#define INPUT_CLK 1193180
uint32_t timerTicks = 0;
void timerHandler() {
__attribute__ ((interrupt))
void timerHandler(intFrame_t* iframe) {
timerTicks++;
// TODO: Improve the cursor rendering
if (timerTicks % 500 == 0) putcAt(127, cursor.x, cursor.y);
else if (timerTicks % 250 == 0) putcAt(' ', cursor.x, cursor.y);
sendPicEOI(0);
}
void setupTimer() {
installIrqHandler(0, timerHandler);
idtSetGate(32, timerHandler, INT_GATE_FLAGS);
unsetIrqMask(0);
}
// Source: https://en.wikibooks.org/wiki/X86_Assembly/Programmable_Interval_Timer
+21 -18
View File
@@ -1,14 +1,15 @@
#include "physicalMemManager.h" // TODO: Name this better
#include "disk.h"
#include "screen.h"
#include "idt.h"
#include "exceptions.h"
#include "syscall.h"
#include "pic.h"
#include "system.h"
#include "string.h"
#include "graphics.h"
#include "keyboard.h"
#include <physicalMemManager.h> // TODO: Name this better
#include <disk.h>
#include <screen.h>
#include <idt.h>
#include <exceptions.h>
#include <syscall.h>
#include <pic.h>
#include <system.h>
#include <string.h>
#include <graphics.h>
#include <keyboard.h>
#include <timer.h>
#define PROMPT "#> "
@@ -52,18 +53,16 @@ void main() {
remapPic();
__asm__ volatile ("sti");
// Syscall Test!
__asm__ volatile ("movl $0, %eax; int $0x80"); // Syscall(0);
__asm__ volatile ("movl $1, %eax; int $0x80"); // Syscall(1);
//setupKeyboard();
setupTimer();
timerPhase(1000); // 1 kHz
setupKeyboard();
// Run Interactive Shell Program
// TODO: Make it in another file
while (1) {
print(PROMPT);
char* input = read('\n');
if (input[0] == '\n') continue;
char* args;
@@ -207,7 +206,11 @@ void main() {
} else {
print("[ FAIL ]\n");
}
print("Tests Finished!\n");
print("Syscall Test:\n");
__asm__ volatile ("movl $0, %eax; int $0x80"); // Syscall(0);
__asm__ volatile ("movl $1, %eax; int $0x80"); // Syscall(1);
print("\nTests Finished!\n");
} else {
char* ft = filetable;
uint8_t found = 0;