Skip to content

Commit

Permalink
refactor: switch from NASM to FASM
Browse files Browse the repository at this point in the history
  • Loading branch information
d0p1s4m4 committed Feb 4, 2024
1 parent 32f1956 commit 3fddd70
Show file tree
Hide file tree
Showing 61 changed files with 318 additions and 2,516 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ jobs:
- name: Install dependencies
run: |
sudo apt-get update
sudo apt-get install build-essential llvm lld nasm mtools
sudo apt-get install build-essential fasm mtools
- name: Build
run: |
make
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,4 @@ a.out
*.old
/bx_enh_dbg.ini
bochsrc.bxrc
/tmp
43 changes: 22 additions & 21 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,31 +1,32 @@
.DEFAULT_GOAL := all
TOPDIR := $(CURDIR)
export TOPDIR
TOPDIR := $(dir $(realpath $(lastword $(MAKEFILE_LIST))))
SYSROOTDIR := $(TOPDIR)/sysroot
TOOLSDIR := $(TOPDIR)/tools

SUBDIR := thirdparty lib bin kernel
RM = echo

CLEANFILES += stupid.iso stupid.tar.gz
SUBDIRS := kernel lib bin

.PHONY: docs
docs:
-mkdir -p docs/html
naturaldocs -p docs/config -img docs/img -xi tmp -i . -o HTML docs/html
cp docs/img/favicon.ico docs/html/
TARGET = stupid.iso stupid.tar.gz

.PHONY: all
all: $(TARGET)

GOAL:=install
clean: GOAL:=clean

.PHONY: $(SUBDIRS)
$(SUBDIRS):
@echo "📁 $@"
DESTDIR=$(SYSROOTDIR) $(MAKE) -C $@ $(GOAL)

.PHONY: stupid.iso
stupid.iso:
$(MAKE) all
DESTDIR=$(TOPDIR)/sysroot $(MAKE) install
stupid.iso: $(SUBDIRS)
$(TOPDIR)/tools/create-iso $@ sysroot

.PHONY: stupid.tar.gz
stupid.tar.gz:
$(MAKE) all
DESTDIR=$(TOPDIR)/sysroot $(MAKE) install
stupid.tar.gz: $(SUBDIRS)
tar -czvf $@ sysroot

run: stupid.iso
qemu-system-i386 -cdrom $< -serial stdio

include $(TOPDIR)/share/mk/stupid.subdir.mk
include $(TOPDIR)/share/mk/stupid.clean.mk
.PHONY: clean
clean: $(SUBDIRS)
$(RM) $(TARGET) $(SYSROOTDIR)
12 changes: 10 additions & 2 deletions bin/Makefile
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
NOSUBDIR := 1
SUBDIRS = cmd

include $(TOPDIR)/share/mk/stupid.subdir.mk
TOPGOALS = all clean install

.PHONY: $(SUBDIRS)
$(SUBDIRS):
@echo "📁 bin/$@"
DESTDIR=$(DESTDIR)/bin $(MAKE) -C $@ $(MAKECMDGOALS)

.PHONY: $(TOPGOALS)
$(TOPGOALS): $(SUBDIRS)
5 changes: 5 additions & 0 deletions bin/cmd/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
all:

clean:

install:
6 changes: 6 additions & 0 deletions bin/cmd/builtins.inc
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
builtins:
db 2, 'cd'
db 1, '.'
db 3, 'set'
db 5, 'unset'
db 4, 'exit'
8 changes: 8 additions & 0 deletions bin/cmd/cmd.asm
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
format ELF
entry start

include 'builtins.inc'

start:

int 0x2A
3 changes: 0 additions & 3 deletions docs/intro.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,7 @@ Donate:
- <Liberapay at https://liberapay.com/d0p1/>
- <Github Sponsors at https://github.com/sponsors/d0p1s4m4>
- Monero: 85cm3SuAs98dcqXcdiyCNz6hkb5fKwHbtJYr8cyFdAGWKgj8rG3kPENNv1BXVp2HsiaC8otTzxxaEEuUVZQFxrSr7eBY2uw
- Zcash: zs1sqsdn4acrqygvupmhwl5vvzcdjk6fd4p6n3k4nzdey0huq7cwkl2ca7dru8alhhtan47wjes0x9
- Bitcoin: bc1qhpxa0hgj0mjstttkjgg6ees9dj5kadty04kgpp
- Oxen: LDrNKN6iXh98zUZbwa9iGmeuiWbrzU2WTKWwcwMYFSeCj2QACxfyFXNVQyN8QBe61bFgqtykTYpgcaWvf2C1K77KMQ82DaC
- Gridcoin: S8tw8EWXQ6p529kLEniCePceNAFTyc3GKM

About: License

Expand Down
38 changes: 24 additions & 14 deletions kernel/Makefile
Original file line number Diff line number Diff line change
@@ -1,17 +1,27 @@
AS = fasm
RM = rm -f
INSTALL = install

KERNEL = vmstupid
SRCS = kernel.asm \
const.inc \
boot/multiboot.inc \
boot/boot.inc \
mm/mm.inc

.PHONY: all
all: $(KERNEL)

$(KERNEL): $(SRCS)
$(AS) kernel.asm $@

.PHONY: clean
clean:
$(RM) $(KERNEL)

SRCS = boot/head.s \
boot/gdt.s \
boot/idt.s \
boot/isr.s \
boot/tss.s \
kernel.s \
lib/log.s dev/at/serial.s \
i18n/msg_en.s
INCS = sys/multiboot.inc \
sys/i386/cpuid.inc \
sys/i386/mmu.inc \
sys/i386/registers.inc
.PHONY: install
install: $(KERNEL)
@ mkdir -p $(DESTDIR)
install $< $(DESTDIR)

include $(TOPDIR)/share/mk/stupid.kernel.mk
#include $(TOPDIR)/share/mk/stupid.inc.mk
.PHONY: all clean
4 changes: 0 additions & 4 deletions kernel/base/console.s

This file was deleted.

35 changes: 35 additions & 0 deletions kernel/boot/boot.inc
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
ORG 0x100000
ALIGN 4
USE32

INCLUDE 'boot/multiboot.inc'
INCLUDE 'const.inc'

mb_header MultibootHeader MB_FLAGS, mb_header, VIDEO_WIDTH, VIDEO_HEIGHT, VIDEO_DEPTH

_start:
cli
cmp eax, MULTIBOOT_MAGIC
jne hang

; iterate over memory

;

;
xor esi, esi
mov edi, kernel_page_table - KBASE

mov ecx, kernel_page_directory - KBASE
mov cr3, ecx

mov ecx, cr0


hang:
hlt
jmp $-1

; SEGMENT readable writable

boot_struct dd 0x0
94 changes: 0 additions & 94 deletions kernel/boot/gdt.s

This file was deleted.

Loading

0 comments on commit 3fddd70

Please sign in to comment.