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