Merge pull request #25 from E-Almqvist/dev

Makefile & File structure refactor
pull/34/head
Elias Almqvist 3 years ago committed by GitHub
commit c53e288529
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 24
      Makefile
  2. 7
      TODO.md
  3. 7
      bootloader/bios.asm
  4. 0
      bootloader/bios/convert.asm
  5. 0
      bootloader/bios/disk.asm
  6. 0
      bootloader/bios/print.asm
  7. 6
      bootloader/bootloader.asm
  8. 0
      bootloader/equ/ascii.asm
  9. 0
      bootloader/equ/bios.asm
  10. 0
      bootloader/equ/vga.asm
  11. 6
      bootloader/pm.asm
  12. 0
      bootloader/pm/gdt.asm
  13. 0
      bootloader/pm/vga/print.asm
  14. 13
      drivers/vga.c
  15. 0
      grub/grub.cfg
  16. 7
      kernel/kernel.c
  17. 0
      kernel/kernel_entry.asm
  18. 7
      src/bootloader/bios.asm
  19. 7
      src/kernel/kernel.c
  20. 8
      src/kernel/lib/string.c

@ -1,3 +1,7 @@
C_SOURCES = $(wildcard kernel/*.c drivers/*.c)
HEADERS = $(wildcard kernel/*.h drivers/*.h)
OBJ = $(C_SOURCES:.c=.o)
all: os-image
run: all
@ -8,29 +12,27 @@ drun: clean run
grub: eOS.iso
qemu-system-x86_64 eOS.iso
eOS.iso : kernel.bin src/grub/grub.cfg
eOS.iso : kernel/kernel.bin grub/grub.cfg
mkdir -p boot/grub
cp $< boot/eOS.bin
cp src/grub/grub.cfg boot/grub/grub.cfg
cp grub/grub.cfg boot/grub/grub.cfg
grub-mkrescue -o eOS.iso ./
os-image: bootloader.bin kernel.bin
os-image: bootloader/bootloader.bin kernel.bin
cat $^ > os-image
kernel.bin: kernel_entry.o kernel.o
gcc -o kernel.bin $^ -Wl,--oformat=binary -ffreestanding -nostdlib -shared -Ttext 0x1000 -m32
kernel.bin: kernel/kernel_entry.o $(OBJ)
gcc -o $@ $^ -Wl,--oformat=binary -ffreestanding -nostdlib -shared -Ttext 0x1000 -m32
kernel.o : src/kernel/kernel.c
%.o : %.c
gcc -fno-pie -m32 -Os -ffreestanding -c $< -o $@
kernel_entry.o : src/kernel/kernel_entry.asm
%.o : %.asm
nasm $< -f elf -o $@
bootloader.bin : src/bootloader/bootloader.asm
%.bin : %.asm
nasm $< -f bin -o $@
clean:
rm -fr *.bin *.dis *.o os-image *.map boot/ *.iso
kernel.dis : kernel.bin
ndisasm -b 32 $< > $@
rm -fr kernel/*.o boot/*.bin drivers/*.o

@ -1,3 +1,8 @@
# TO DO
- Refactor Makefile
- Refactor file structure
- Finish the book!
- Multiboot support (for grub etc)
- Expand os-image so there is no error 0x8b00!
- VGA Library (Graphics)
- User input (Keyboard)
- File system?

@ -0,0 +1,7 @@
; EQUs
%include "bootloader/equ/bios.asm"
; SRs
%include "bootloader/bios/convert.asm"
%include "bootloader/bios/print.asm"
%include "bootloader/bios/disk.asm"

@ -20,9 +20,9 @@
jmp $ ; inf loop
%include "src/bootloader/equ/ascii.asm"
%include "src/bootloader/bios.asm"
%include "src/bootloader/pm.asm"
%include "bootloader/equ/ascii.asm"
%include "bootloader/bios.asm"
%include "bootloader/pm.asm"
BEGIN_PM:
; Inform of mode switch

@ -1,9 +1,9 @@
; Utils
%include "src/bootloader/equ/vga.asm"
%include "src/bootloader/pm/vga/print.asm"
%include "bootloader/equ/vga.asm"
%include "bootloader/pm/vga/print.asm"
; GDT & switching to PM
%include "src/bootloader/pm/gdt.asm" ; GDT defined here
%include "bootloader/pm/gdt.asm" ; GDT defined here
; Switching to PM
[bits 16]

@ -1,4 +1,5 @@
// VGA Graphics Library
#include <sys/io.h>
// VGA base address: 0xb8000
// Charpos = 0xb8000 + 2(row*80 + col)
@ -34,6 +35,11 @@ void clear_screen() {
*c = 0x20;
}
void disable_cursor() {
outb(0x3d4, 0x0a);
outb(0x3d5, 0x20);
}
/*
General Printing Functions
@ -52,3 +58,10 @@ void println(char* str, int colorcode) {
print(str, colorcode);
cursor_row++; // Increment to next y-pos (newline)
}
// VGA Initialization Function
void vga_init() {
disable_cursor();
clear_screen();
}

@ -0,0 +1,7 @@
void main() {
vga_init(); // Initialize the screen first
// i.e. clear the screen et cetera.
set_cursor_pos(28, 2);
print("eOS Version 0.1 2021", 0xf0);
}

@ -1,7 +0,0 @@
; EQUs
%include "src/bootloader/equ/bios.asm"
; SRs
%include "src/bootloader/bios/convert.asm"
%include "src/bootloader/bios/print.asm"
%include "src/bootloader/bios/disk.asm"

@ -1,7 +0,0 @@
#include "lib/vga.c"
void main() {
clear_screen();
set_cursor_pos(28, 2);
print("eOS Version 0.1 2021", 0xf0);
}

@ -1,8 +0,0 @@
// Generic String Library
#define INDEX(s, c) (int)(c-s)
unsigned int length(char* str) {
char* p;
for( p = str; *p != '\0'; p++ ) {}
return (unsigned int)(p-str);
}
Loading…
Cancel
Save