From d9553eebe38ed0eb10f20fd7a62789312d2087c9 Mon Sep 17 00:00:00 2001 From: Agnosto Dvonik Date: Sat, 17 Feb 2024 19:16:13 -0500 Subject: [PATCH] code fixed and stiupid build --- Makescript | 11 +++++++++++ boot/Makefile | 5 +++++ boot/boot.s | 13 +++++-------- link.ld | 9 +++++++++ omos | Bin 0 -> 7036 bytes sys/Makefile | 1 + sys/drv/vga/include/video.h | 2 +- sys/drv/vga/video.c | 4 +++- sys/sysinit.c | 6 ++++-- 9 files changed, 39 insertions(+), 12 deletions(-) create mode 100644 Makescript create mode 100644 boot/Makefile create mode 100644 link.ld create mode 100755 omos diff --git a/Makescript b/Makescript new file mode 100644 index 0000000..e85ac06 --- /dev/null +++ b/Makescript @@ -0,0 +1,11 @@ +#!/usr/bin/env sh + +INCLUDE="-Isys/drv/vga/include -Isys/include" +CFLAGS="-g -m32 -ffreestanding -Wall -Wextra -pedantic -nostdlib $INCLUDE" +ASFLAGS="-felf32" +LDFLAGS="-m elf_i386" + +cc $CFLAGS -c sys/drv/vga/video.c -o obj/vga.o +cc $CFLAGS -c sys/sysinit.c -o obj/sysinit.o +nasm $ASFLAGS boot/boot.s -o obj/boot.o +ld $LDFLAGS -T boot/link.ld -o omos obj/boot.o obj/vga.o obj/sysinit.o diff --git a/boot/Makefile b/boot/Makefile new file mode 100644 index 0000000..2e284ff --- /dev/null +++ b/boot/Makefile @@ -0,0 +1,5 @@ +AS=nasm +FLAGS=-felf32 + +boot.o: + $(AS) $(FLAGS) boot.s -o boot.o diff --git a/boot/boot.s b/boot/boot.s index b9f1494..c776932 100644 --- a/boot/boot.s +++ b/boot/boot.s @@ -1,15 +1,12 @@ ; only support mb1 -align equ 1 << 0 -info equ 1 << 1 -flags equ align | info -magic equ 0x1BADB002 -chksum equ - (magic + flags) + +bits 32 section .multiboot align 4 - dd magic - dd flags - dd chksum + dd 0x1badb002 + dd 0x00 + dd - (0x1badb002 + 0x00) global _start extern sysinit diff --git a/link.ld b/link.ld new file mode 100644 index 0000000..2bb394a --- /dev/null +++ b/link.ld @@ -0,0 +1,9 @@ +OUTPUT_FORMAT(elf32-i386) +ENTRY(_start) +SECTIONS +{ + . = 0x100000; + .text : {*(.text)} + .data : {*(.data)} + .bss : {*(.bss)} +} diff --git a/omos b/omos new file mode 100755 index 0000000000000000000000000000000000000000..e18b7573017f9685ce4692a9774ee10e60164949 GIT binary patch literal 7036 zcmeHMU2GIp6h1SvcRTGa+h3>%YDsF~0cT5Tuz^x+=_1uF)&3+@Y?kfrv|Z@V*8M3o zK`p6 zKi@s)-ZOLOrgz^A1otV5LXtGnh_(GxMJ?!GeXQVVp$00WEmTJ}wjXW~H&rx*me~bn z6OTWP{xB3~9}LXG;h(G~npCQ69)O+M?eH(czX(4w$7Pm&6|!^ue(22XXI$T{bkynR z*k^nNAJ6S&_|ZK;cKipdB}1tKr3#cPP^v(w0;LL+Dp0CGsRE@6lqyiFK&b-%zY6gG z$C4j+EKk}TCQ>h5*ueVT-oBszUit~ra&Nq$KORn|4T&3^ztunco4&;Q!IM{lh%+Bp zKHcNZ_UPFeFRYcH!;;GebO^IKs(foNjM>040H@by=NOV5%*}1AhGF&#Wgg>ta<-5= zJ?JgOfMu>u&jxa{R}=)heKDWU&o1hRhOZ*OBmK7s2LJWI3Isa&`pUUVOyJ!oIS1xo z&nMfna?PbfU$KL&-2R~uZ20Oopu&2*_IeJTx^eQ#35-2;V}3Zdv;bUoIQP!%*}M7t zysPngSECEzX(PiFJCuklm(;%2{n6{!CY7LZDu%hZh<9j1*H#8UD z3_Zc-aaBOtd)I=mfSp&^C^R$ zu(eiE%71}rGfaSq4gqxwg-x9ADRl1E6G69%gQ8P8T^n3sJPF|SgF{UWkwrfR+=K?;UrCsg+o)Z zXxxlbs+D>tO{=rNt06KGw#FK!%w#H-uo|}QFq(`Vl$uWY!7(eAHX`=GW64#9K zZu+BB2`hHgzc&#z{fT%Y^-MZq9cgZAZlO@9qpz=HDAeEmN+2{a^im)cvSUS)Q+}lP zBfXhG#FY73#Tq#>CHa27QN5e_QQbBf4fa^*Aun&rdAq@T>dbg#M_Q1MqQ4+Z|&NbBag(4x5UM zD6?|Mw+5|!d5YO6T(y`LnaD)#h56;GA7Ud)PfwaDW1RPRp(^A2ipv6Ni0{%!sJyg# z;i=Fshzj?paJQjr7v<<{+l1Pt9UB#OZmj|;OqwBlqoTS^c-^~&YeCd52o2_f%>|p9 z6^bV$=!o!DjEQ=;eo%9)S0~hpjQ&0n>O-md7ro`No)WeskyH$&&UZKf)GZTX<$BF~^_{{i&!&bb;pjqkN@ z!q4vy`^kt-TdC>9d?r=_$3IWV zcZP9HIH&A$lyQ7!ZYjod;uyOg%sY*7eCD|@?l?D_2HckeK8{QHO`s5W(=Wem@867M+wropF~%*VYBegVwG8OM9! zGH^J$S4ragVUaldw-w-|kHJ#rciu4_`VzPw8BiqY8-p%oc71>oxW!?RVycL1Vi4#C ziuYYXv|Gk8zftUMBbxJdL~~L>FXxwqEMv2~2_J=>4ucfW7I8A~k#+YzH^woa1M{<$ pGy~ivDEy4M{+ySe$$2o>SW;6x(PvUYFY|r`*@^oVxa31{{{Wy!>74)o literal 0 HcmV?d00001 diff --git a/sys/Makefile b/sys/Makefile index b87ea45..b974734 100644 --- a/sys/Makefile +++ b/sys/Makefile @@ -1,4 +1,5 @@ include sys/drv/vga/Makefile + CC=cc FLAGS=-Wall -c -g -Wextra -ffreestanding -m32 -nostdlib SRCS=$(wildcard sys/*.c) diff --git a/sys/drv/vga/include/video.h b/sys/drv/vga/include/video.h index 1c3ff3f..b9ec86a 100644 --- a/sys/drv/vga/include/video.h +++ b/sys/drv/vga/include/video.h @@ -8,6 +8,6 @@ s8 *vga_vidmem = (s8 *)0xb8000; void vga_write(s8 *, s8); -void vga_clearscreen(); +void vga_clearscreen(void); #endif diff --git a/sys/drv/vga/video.c b/sys/drv/vga/video.c index 1ace1b4..d8b607a 100644 --- a/sys/drv/vga/video.c +++ b/sys/drv/vga/video.c @@ -15,7 +15,9 @@ vga_write(s8 *sequence, s8 flags) } } -void vga_clearscreen() { +void +vga_clearscreen(void) +{ for (int i = 0; i <= SIZE; i++) { vga_vidmem[i] = 0; } diff --git a/sys/sysinit.c b/sys/sysinit.c index af45b09..9d57aa0 100644 --- a/sys/sysinit.c +++ b/sys/sysinit.c @@ -1,4 +1,6 @@ void -sysinit() { - write("Om Smart.", 0x0F, 10); +sysinit(void) +{ + vga_clearscreen(); + vga_write("Om Smart.", 0x0F); }