-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
383 additions
and
374 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,66 +1,66 @@ | ||
.EXPORT_ALL_VARIABLES: | ||
|
||
TOPDIR := $(dir $(realpath $(lastword $(MAKEFILE_LIST)))) | ||
SYSROOTDIR := $(TOPDIR)/sysroot | ||
TOOLSDIR := $(TOPDIR)/tools | ||
|
||
RM = echo | ||
|
||
MK_BUGREPORT := \"https://git.cute.engineering/d0p1/StupidOS/issues\" | ||
MK_COMMIT := \"$(shell git rev-parse --short HEAD)\" | ||
|
||
SUBDIRS := tools boot kernel lib bin | ||
|
||
TARGET = stupid.tar.gz floppy_boot.img | ||
ifneq ($(OS),Windows_NT) | ||
EXEXT = | ||
TARGET += stupid.iso stdupid.hdd | ||
else | ||
EXEXT = .exe | ||
endif | ||
|
||
.PHONY: all | ||
all: $(TARGET) | ||
|
||
GOAL:=install | ||
clean: GOAL:=clean | ||
|
||
.PHONY: $(SUBDIRS) | ||
$(SUBDIRS): | ||
@echo "📁 $@" | ||
DESTDIR=$(SYSROOTDIR) $(MAKE) -C $@ $(GOAL) | ||
|
||
.PHONY: stupid.iso | ||
stupid.iso: $(SUBDIRS) | ||
$(TOPDIR)/tools/create-iso $@ sysroot | ||
|
||
.PHONY: stupid.hdd | ||
stupid.hdd: $(SUBDIRS) | ||
@echo "" | ||
|
||
.PHONY: stupid.tar.gz | ||
stupid.tar.gz: $(SUBDIRS) | ||
tar -czvf $@ sysroot | ||
|
||
.PHONY: floppy_boot.img | ||
floppy_boot.img: $(SUBDIRS) | ||
dd if=/dev/zero of=$@ bs=512 count=1440 | ||
mformat -C -f 1440 -i $@ | ||
dd if=boot/bootsector.bin of=$@ conv=notrunc | ||
mcopy -i $@ boot/stpdboot.sys ::/STPDBOOT.SYS | ||
mcopy -i $@ kernel/vmstupid.sys ::/VMSTUPID.SYS | ||
|
||
.PHONY: run | ||
run: all | ||
qemu-system-i386 \ | ||
-rtc base=localtime \ | ||
-drive file=floppy_boot.img,if=none,format=raw,id=boot \ | ||
-drive file=fat:rw:./sysroot,if=none,id=hdd \ | ||
-device floppy,drive=boot \ | ||
-device ide-hd,drive=hdd \ | ||
-global isa-fdc.bootindexA=0 \ | ||
-serial mon:stdio | ||
|
||
.PHONY: clean | ||
clean: $(SUBDIRS) | ||
$(RM) $(TARGET) $(SYSROOTDIR) | ||
.EXPORT_ALL_VARIABLES: | ||
|
||
TOPDIR := $(dir $(realpath $(lastword $(MAKEFILE_LIST)))) | ||
SYSROOTDIR := $(TOPDIR)/sysroot | ||
TOOLSDIR := $(TOPDIR)/tools | ||
|
||
RM = echo | ||
|
||
MK_BUGREPORT := \"https://git.cute.engineering/d0p1/StupidOS/issues\" | ||
MK_COMMIT := \"$(shell git rev-parse --short HEAD)\" | ||
|
||
SUBDIRS := tools boot kernel lib bin | ||
|
||
TARGET = stupid.tar.gz floppy_boot.img | ||
ifneq ($(OS),Windows_NT) | ||
EXEXT = | ||
TARGET += stupid.iso stupid.hdd | ||
else | ||
EXEXT = .exe | ||
endif | ||
|
||
.PHONY: all | ||
all: $(TARGET) | ||
|
||
GOAL:=install | ||
clean: GOAL:=clean | ||
|
||
.PHONY: $(SUBDIRS) | ||
$(SUBDIRS): | ||
@echo "📁 $@" | ||
DESTDIR=$(SYSROOTDIR) $(MAKE) -C $@ $(GOAL) | ||
|
||
.PHONY: stupid.iso | ||
stupid.iso: $(SUBDIRS) | ||
$(TOPDIR)/tools/create-iso $@ sysroot | ||
|
||
.PHONY: stupid.hdd | ||
stupid.hdd: $(SUBDIRS) | ||
@echo "" | ||
|
||
.PHONY: stupid.tar.gz | ||
stupid.tar.gz: $(SUBDIRS) | ||
tar -czvf $@ sysroot | ||
|
||
.PHONY: floppy_boot.img | ||
floppy_boot.img: $(SUBDIRS) | ||
dd if=/dev/zero of=$@ bs=512 count=1440 | ||
mformat -C -f 1440 -i $@ | ||
dd if=boot/bootsector.bin of=$@ conv=notrunc | ||
mcopy -i $@ boot/stpdboot.sys ::/STPDBOOT.SYS | ||
mcopy -i $@ kernel/vmstupid.sys ::/VMSTUPID.SYS | ||
|
||
.PHONY: run | ||
run: all | ||
qemu-system-i386 \ | ||
-rtc base=localtime \ | ||
-drive file=floppy_boot.img,if=none,format=raw,id=boot \ | ||
-drive file=fat:rw:./sysroot,if=none,id=hdd \ | ||
-device floppy,drive=boot \ | ||
-device ide-hd,drive=hdd \ | ||
-global isa-fdc.bootindexA=0 \ | ||
-serial mon:stdio | ||
|
||
.PHONY: clean | ||
clean: $(SUBDIRS) | ||
$(RM) $(TARGET) $(SYSROOTDIR) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,120 +1,120 @@ | ||
INCLUDE 'const.inc' | ||
|
||
ORG STAGE0_BASE | ||
USE16 | ||
|
||
jmp short _start | ||
nop | ||
|
||
; Boot Record | ||
OEM_identifier db 'STUPID ' | ||
bytes_per_sector dw 512 | ||
sectors_per_cluster db 1 | ||
reserved_sectors dw 1 | ||
FAT_count db 2 | ||
root_dir_entries dw 224 | ||
total_sectors dw 2880 | ||
media_desc_type db 0xF0 | ||
sectors_per_FAT dw 9 | ||
sectors_per_track dw 18 | ||
heads_per_cylinder dw 2 | ||
hidden_sectors dd 0 | ||
large_sector_count dd 0 | ||
|
||
; Extended Boot Record | ||
drive_number db 0x0 | ||
reserved db 0x0 | ||
signature db 0x29 ; 0x28 or 0x29 | ||
volume_id dd 0xB00B135 ; hope mine will grow :'( | ||
volume_label db 'Stupid Boot' | ||
system_id db 'FAT12 ' | ||
|
||
|
||
_start: | ||
cli | ||
cld | ||
jmp 0x0:.canonicalize_cs | ||
|
||
.canonicalize_cs: | ||
xor ax, ax | ||
mov ds, ax | ||
mov ss, ax | ||
mov es, ax | ||
mov sp, 0x7c00 | ||
|
||
mov [drive_number], dl | ||
|
||
; reset floppy disk | ||
@@: | ||
mov dl, [drive_number] | ||
xor ah, ah | ||
int 0x13 | ||
jc @b | ||
|
||
call fat_load_root | ||
|
||
; search in root directory | ||
|
||
mov si, kernel_file | ||
call fat_search_root | ||
jc .error_not_found | ||
mov [kernel_start], ax | ||
|
||
mov si, stage1_file | ||
call fat_search_root | ||
jc .error_not_found | ||
mov [stage1_start], ax | ||
|
||
; load fat | ||
xor ax, ax | ||
mov al, [FAT_count] | ||
mul word [sectors_per_FAT] | ||
mov cx, ax | ||
mov ax, [reserved_sectors] | ||
|
||
xor bx, bx | ||
|
||
call disk_read_sectors | ||
|
||
; preload kernel | ||
mov ax, KERNEL_PRELOAD/0x10 | ||
mov es, ax | ||
mov ax, [kernel_start] | ||
xor bx, bx | ||
call fat_load_binary | ||
|
||
; load stage 2 | ||
mov ax, STAGE1_BASE/0x10 | ||
mov es, ax | ||
mov ax, [stage1_start] | ||
xor bx, bx | ||
call fat_load_binary | ||
|
||
jmp 0x0:STAGE1_BASE | ||
|
||
.error_not_found: | ||
push si | ||
mov si, msg_error | ||
call bios_print | ||
pop si | ||
call bios_print | ||
mov si, msg_not_found | ||
call bios_print | ||
hlt | ||
jmp $ | ||
|
||
INCLUDE "utils.inc" | ||
INCLUDE "fat12.inc" | ||
|
||
msg_error db "ERROR: ", 0 | ||
msg_not_found db " not found", CR, LF, 0 | ||
|
||
kernel_file db "VMSTUPIDSYS", 0 | ||
stage1_file db "STPDBOOTSYS", 0 | ||
|
||
kernel_start dw 0x0 | ||
stage1_start dw 0x0 | ||
|
||
|
||
rb 0x7C00+512-2-$ | ||
db 0x55, 0xAA | ||
INCLUDE 'const.inc' | ||
|
||
ORG STAGE0_BASE | ||
USE16 | ||
|
||
jmp short _start | ||
nop | ||
|
||
; Boot Record | ||
OEM_identifier db 'STUPID ' | ||
bytes_per_sector dw 512 | ||
sectors_per_cluster db 1 | ||
reserved_sectors dw 1 | ||
FAT_count db 2 | ||
root_dir_entries dw 224 | ||
total_sectors dw 2880 | ||
media_desc_type db 0xF0 | ||
sectors_per_FAT dw 9 | ||
sectors_per_track dw 18 | ||
heads_per_cylinder dw 2 | ||
hidden_sectors dd 0 | ||
large_sector_count dd 0 | ||
|
||
; Extended Boot Record | ||
drive_number db 0x0 | ||
reserved db 0x0 | ||
signature db 0x29 ; 0x28 or 0x29 | ||
volume_id dd 0xB00B135 ; hope mine will grow :'( | ||
volume_label db 'Stupid Boot' | ||
system_id db 'FAT12 ' | ||
|
||
|
||
_start: | ||
cli | ||
cld | ||
jmp 0x0:.canonicalize_cs | ||
|
||
.canonicalize_cs: | ||
xor ax, ax | ||
mov ds, ax | ||
mov ss, ax | ||
mov es, ax | ||
mov sp, 0x7c00 | ||
|
||
mov [drive_number], dl | ||
|
||
; reset floppy disk | ||
@@: | ||
mov dl, [drive_number] | ||
xor ah, ah | ||
int 0x13 | ||
jc @b | ||
|
||
call fat_load_root | ||
|
||
; search in root directory | ||
|
||
mov si, kernel_file | ||
call fat_search_root | ||
jc .error_not_found | ||
mov [kernel_start], ax | ||
|
||
mov si, stage1_file | ||
call fat_search_root | ||
jc .error_not_found | ||
mov [stage1_start], ax | ||
|
||
; load fat | ||
xor ax, ax | ||
mov al, [FAT_count] | ||
mul word [sectors_per_FAT] | ||
mov cx, ax | ||
mov ax, [reserved_sectors] | ||
|
||
xor bx, bx | ||
|
||
call disk_read_sectors | ||
|
||
; preload kernel | ||
mov ax, KERNEL_PRELOAD/0x10 | ||
mov es, ax | ||
mov ax, [kernel_start] | ||
xor bx, bx | ||
call fat_load_binary | ||
|
||
; load stage 2 | ||
mov ax, STAGE1_BASE/0x10 | ||
mov es, ax | ||
mov ax, [stage1_start] | ||
xor bx, bx | ||
call fat_load_binary | ||
|
||
jmp 0x0:STAGE1_BASE | ||
|
||
.error_not_found: | ||
push si | ||
mov si, msg_error | ||
call bios_print | ||
pop si | ||
call bios_print | ||
mov si, msg_not_found | ||
call bios_print | ||
hlt | ||
jmp $ | ||
|
||
INCLUDE "utils.inc" | ||
INCLUDE "fat12.inc" | ||
|
||
msg_error db "ERROR: ", 0 | ||
msg_not_found db " not found", CR, LF, 0 | ||
|
||
kernel_file db "VMSTUPIDSYS", 0 | ||
stage1_file db "STPDBOOTSYS", 0 | ||
|
||
kernel_start dw 0x0 | ||
stage1_start dw 0x0 | ||
|
||
|
||
rb 0x7C00+512-2-$ | ||
db 0x55, 0xAA |
Oops, something went wrong.