implemented basic keyboard input getting
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
# Define the object files
|
||||
OBJS = bin/boot.o bin/kernel.o bin/idt.o bin/isr.o bin/screen.o
|
||||
OBJS = bin/boot.o bin/kernel.o bin/idt.o bin/isr.o bin/screen.o bin/utils.o
|
||||
|
||||
# Define the compiler and assembler
|
||||
CC = gcc
|
||||
@@ -36,6 +36,9 @@ bin/isr.o: src/isr.c
|
||||
bin/idt.o: src/idt.c
|
||||
$(CC) $(CFLAGS) -c $< -o $@
|
||||
|
||||
bin/utils.o: src/utils.c
|
||||
$(CC) $(CFLAGS) -c $< -o $@
|
||||
|
||||
clean:
|
||||
rm -rf bin/
|
||||
rm -f $(OUTPUT)
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
#ifndef UTILS_H
|
||||
#define UTILS_H
|
||||
#include "../include/types.h"
|
||||
|
||||
uint8 inportb(uint16 _port);
|
||||
void outportb(uint16 _port, uint8 _data);
|
||||
|
||||
#endif
|
||||
|
||||
@@ -38,7 +38,7 @@ void isr_install() {
|
||||
idt_set_descriptor(31, (uint32)isr31, 0x8E);
|
||||
|
||||
idt_set(); // Load with ASM
|
||||
terminal_writestring("isr_install done");
|
||||
terminal_writestring("isr_install done\n");
|
||||
}
|
||||
|
||||
void isr0()
|
||||
|
||||
+18
-3
@@ -1,5 +1,6 @@
|
||||
#include "../include/isr.h"
|
||||
#include "../include/screen.h"
|
||||
#include "../include/utils.h"
|
||||
|
||||
/* Check if the compiler thinks you are targeting the wrong operating system. */
|
||||
/*#if defined(__linux__)
|
||||
@@ -15,8 +16,22 @@
|
||||
void kmain()
|
||||
{
|
||||
terminal_initialize();
|
||||
terminal_writestring("KatauOS booting up");
|
||||
terminal_writestring("KatauOS booting up\n");
|
||||
isr_install();
|
||||
terminal_writestring("Kernel init sequence completed");
|
||||
return;
|
||||
terminal_writestring("Kernel init sequence completed\n");
|
||||
|
||||
while(1)
|
||||
{
|
||||
if(inportb(0x64) & 0x1)
|
||||
{
|
||||
unsigned char key = inportb(0x60);
|
||||
if(key == 2)
|
||||
terminal_writestring("1\n");
|
||||
else if(key == 4)
|
||||
terminal_writestring("3\n");
|
||||
else
|
||||
terminal_writestring("dunno what is it\n");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+25
-9
@@ -6,12 +6,12 @@ static size_t terminal_column;
|
||||
static uint8_t terminal_color;
|
||||
static uint16_t* terminal_buffer;
|
||||
|
||||
uint8_t vga_entry_color(enum vga_color fg, enum vga_color bg)
|
||||
inline uint8_t vga_entry_color(enum vga_color fg, enum vga_color bg)
|
||||
{
|
||||
return fg | bg << 4;
|
||||
}
|
||||
|
||||
uint16_t vga_entry(unsigned char uc, uint8_t color)
|
||||
inline uint16_t vga_entry(unsigned char uc, uint8_t color)
|
||||
{
|
||||
return (uint16_t) uc | (uint16_t) color << 8;
|
||||
}
|
||||
@@ -51,12 +51,30 @@ void terminal_putentryat(char c, uint8_t color, size_t x, size_t y)
|
||||
|
||||
void terminal_putchar(char c)
|
||||
{
|
||||
terminal_putentryat(c, terminal_color, terminal_column, terminal_row);
|
||||
if (++terminal_column == VGA_WIDTH) {
|
||||
/*if(c == '\n')
|
||||
{
|
||||
terminal_column = 0;
|
||||
terminal_row++;
|
||||
}*/
|
||||
if(c != '\n')
|
||||
terminal_putentryat(c, terminal_color, terminal_column, terminal_row);
|
||||
|
||||
if (++terminal_column >= VGA_WIDTH){
|
||||
terminal_column = 0;
|
||||
if (++terminal_row == VGA_HEIGHT)
|
||||
terminal_row = 0;
|
||||
}
|
||||
terminal_initialize();
|
||||
if (++terminal_row >= VGA_HEIGHT)
|
||||
terminal_row = 0;
|
||||
}
|
||||
if(terminal_row >= VGA_HEIGHT){
|
||||
terminal_row = 0;
|
||||
}
|
||||
|
||||
if(c == '\n')
|
||||
{
|
||||
terminal_column = 0;
|
||||
terminal_row++;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void terminal_write(const char* data, size_t size)
|
||||
@@ -68,6 +86,4 @@ void terminal_write(const char* data, size_t size)
|
||||
void terminal_writestring(const char* data)
|
||||
{
|
||||
terminal_write(data, strlen(data));
|
||||
terminal_row++;
|
||||
terminal_column = 0;
|
||||
}
|
||||
|
||||
+14
@@ -0,0 +1,14 @@
|
||||
#include "../include/types.h"
|
||||
#include "../include/utils.h"
|
||||
|
||||
uint8 inportb(uint16 _port)
|
||||
{
|
||||
uint8 rv;
|
||||
__asm__ __volatile__ ("inb %1, %0" : "=a" (rv) : "dN" (_port));
|
||||
return rv;
|
||||
}
|
||||
|
||||
void outportb(uint16 _port, uint8 _data)
|
||||
{
|
||||
__asm__ __volatile__ ("outb %1, %0" : : "dN" (_port), "a" (_data));
|
||||
}
|
||||
Reference in New Issue
Block a user