Merge pull request #26 from E-Almqvist/dev

Ports I/O
pull/34/head
Elias Almqvist 3 years ago committed by GitHub
commit af4411ef20
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 2
      Makefile
  2. 2
      TODO.md
  3. 8
      drivers/vga.h
  4. 26
      kernel/io.c
  5. 5
      kernel/io.h
  6. 2
      kernel/kernel.c

@ -24,7 +24,7 @@ os-image: bootloader/bootloader.bin kernel.bin
kernel.bin: kernel/kernel_entry.o $(OBJ) kernel.bin: kernel/kernel_entry.o $(OBJ)
gcc -o $@ $^ -Wl,--oformat=binary -ffreestanding -nostdlib -shared -Ttext 0x1000 -m32 gcc -o $@ $^ -Wl,--oformat=binary -ffreestanding -nostdlib -shared -Ttext 0x1000 -m32
%.o : %.c %.o : %.c ${HEADERS}
gcc -fno-pie -m32 -Os -ffreestanding -c $< -o $@ gcc -fno-pie -m32 -Os -ffreestanding -c $< -o $@
%.o : %.asm %.o : %.asm

@ -1,6 +1,4 @@
# TO DO # TO DO
- Refactor Makefile
- Refactor file structure
- Finish the book! - Finish the book!
- Multiboot support (for grub etc) - Multiboot support (for grub etc)
- VGA Library (Graphics) - VGA Library (Graphics)

@ -0,0 +1,8 @@
char* get_vga_charpos_pointer(unsigned int col, unsigned int row);
void writechar(char c, unsigned int col, unsigned int row, int colorcode);
void clear_screen();
void disable_cursor();
void set_cursor_pos();
void print();
void println();
void vga_init();

@ -0,0 +1,26 @@
// Function to read a byte from port
unsigned char port_byte_in(unsigned short port) {
unsigned char res;
__asm__("in %%dx, %%al" : "=a" (res) : "d" (port));
return res;
}
// to write a byte to port
void port_byte_out(unsigned short port, unsigned char data) {
__asm__("out %%al, %%dx" : :"a" (data), "d" (port));
}
// Read word from port
unsigned short port_word_in(unsigned short port) {
unsigned short res;
__asm__("in %%dx, %%ax" : "=a" (res) : "d" (port));
return res;
}
// write word to port
void port_word_out(unsigned short port, unsigned short data) {
__asm__("out %%ax, %%dx" : :"a" (data), "d" (port));
}

@ -0,0 +1,5 @@
unsigned char port_byte_in();
void port_byte_out();
unsigned short port_word_in();
void port_word_out();

@ -1,3 +1,5 @@
#include "../drivers/vga.h"
void main() { void main() {
vga_init(); // Initialize the screen first vga_init(); // Initialize the screen first
// i.e. clear the screen et cetera. // i.e. clear the screen et cetera.

Loading…
Cancel
Save