This shit is super hard to automate... trust me

This commit is contained in:
Tyler McGurrin 2025-06-06 03:33:25 -04:00
parent 7e6b8626c1
commit c4c7b881aa
7 changed files with 99 additions and 23 deletions

View File

@ -2,7 +2,7 @@ include build_scripts/config.mk
.PHONY: all floppy_image kernel bootloader clean always tools_fat .PHONY: all floppy_image kernel bootloader clean always tools_fat
all: floppy_image tools_fat all: image
include build_scripts/toolchain.mk include build_scripts/toolchain.mk
# oldnum = cat version # oldnum = cat version
@ -11,17 +11,20 @@ include build_scripts/toolchain.mk
# export newnum # export newnum
# #
# Floppy image # Image
# #
floppy_image: $(BUILD_DIR)/main_floppy.img image: $(BUILD_DIR)/main.img
$(BUILD_DIR)/main_floppy.img: bootloader kernel $(BUILD_DIR)/main.img: bootloader kernel
dd if=/dev/zero of=$(BUILD_DIR)/main_floppy.img bs=512 count=2880 dd if=/dev/zero of=$(BUILD_DIR)/main.img bs=512 count=20000
mkfs.fat -F 12 -n "NANITE" $(BUILD_DIR)/main_floppy.img mkfs.ext2 $(BUILD_DIR)/main.img
mmd -i $(BUILD_DIR)/main_floppy.img "::boot" e2mkdir $(BUILD_DIR)/main.img:boot
mmd -i $(BUILD_DIR)/main_floppy.img "::misc" e2mkdir $(BUILD_DIR)/main.img:misc
mmd -i $(BUILD_DIR)/main_floppy.img "::misc/src" e2mkdir $(BUILD_DIR)/main.img:misc/src
mcopy -s -i $(BUILD_DIR)/main_floppy.img src/* "::misc/src" e2mkdir $(BUILD_DIR)/main.img:boot/grub
# e2cp -v -s src/ -d $(BUILD_DIR)/main.img:misc/src really, really, really slow...
e2cp grub/* $(BUILD_DIR)/main.img:boot/grub
mkdir -p $(BUILD_DIR)/mnt
# #
# Kernel # Kernel

View File

@ -6,15 +6,14 @@
![repo size](https://img.shields.io/github/repo-size/PKM74/Nanite) ![repo size](https://img.shields.io/github/repo-size/PKM74/Nanite)
![license](https://img.shields.io/github/license/PKM74/Nanite) ![license](https://img.shields.io/github/license/PKM74/Nanite)
Very small OS that can run on X86 Hardware. A Very small OS that can run on X86 Hardware.
Designed to run from just one 1.44MB floppy disk, ATA support coming soon! (TM)
Good luck figuring out the spagetti code i write... (sorry not sorry ;D) Good luck figuring out the spagetti code i write... (sorry not sorry ;D)
Designed for older computers such as a Pentium (i586) Class Machine. I would recomend atleast a Pentium 2 Class System or higher however. Designed for older computers such as a Pentium (i586) Class Machine. I however would recomend atleast a Pentium 2 Class System or higher.
## Features ## Features
- Support for the GNU GRUB Bootloader - Support for the GNU GRUB 2 Bootloader and Multiboot V2
- Custom Theme for GRUB (Coming Soon!) - Custom Theme for GRUB (Coming Soon!)
- Basic Memory Paging - Basic Memory Paging
- Support for Floppy Disk Drives (FDDs) - Support for Floppy Disk Drives (FDDs)
@ -32,11 +31,11 @@ To write to a disk, use `./write.sh` WARNING: **is hard coded to /dev/sdb** (sor
You could also run `make all` but the scripts a bit better tbh, it even automates starting QEMU. You could also run `make all` but the scripts a bit better tbh, it even automates starting QEMU.
### Build Requirements ### Build Requirements
- mtools
- make - make
- gcc (or really any C compiler) - gcc (or really any C compiler)
- nasm - nasm
- grub - grub2
- e2tools
## How is Testing Done ## How is Testing Done
Testing is mostly done with QEMU These days, but I do sometimes pull out my Dell Latitude D610 to test on (for anyone wondering its completely maxed out. [2GB of ram Pentium M @ 2.23GHz]) Testing is mostly done with QEMU These days, but I do sometimes pull out my Dell Latitude D610 to test on (for anyone wondering its completely maxed out. [2GB of ram Pentium M @ 2.23GHz])

View File

@ -31,6 +31,33 @@ make -s
echo --------- echo ---------
echo Finished! echo Finished!
echo --------- echo ---------
read -p "Do you want to make to make image bootable? [Requires sudo] (y/n) " yn
case $yn in
y)
echo ----------------
echo Installing GRUB!
echo ----------------
sudo losetup -d /dev/loop500
sudo losetup /dev/loop500 build/main.img
sudo grub-install \
--modules="part_msdos" \
--boot-directory=build/mnt/boot \
--target=i386-pc \
--bootloader-id=GRUB \
/dev/loop500 -v
sudo losetup -d /dev/loop500
;;
n ) echo exiting...;
exit;;
* ) echo invalid response;
exit 1;;
esac
echo ---------
echo Finished!
echo ---------
read -p "Do you want to Start QEMU? (y/n) " yn read -p "Do you want to Start QEMU? (y/n) " yn
case $yn in case $yn in
@ -44,7 +71,7 @@ case $yn in
-serial chardev:serial1 \ -serial chardev:serial1 \
-audiodev pa,id=speaker \ -audiodev pa,id=speaker \
-machine pcspk-audiodev=speaker \ -machine pcspk-audiodev=speaker \
-fda build/main_floppy.img \ -hda build/main.img \
-m size=512M -m size=512M
echo -------- echo --------
echo Finshed! echo Finshed!

50
src/kernel/boot.asm Normal file
View File

@ -0,0 +1,50 @@
;/////////////////////;
;Nanite OS ;
;COPYRIGHT (C) 2024 ;
;Tyler McGurrin ;
;/////////////////////;
[bits 32]
section .entry
extern __bss_start
extern __end
extern start
global entry
; My Life is totally funnnn
global entry
entry:
; 6 - setup segment registers
mov ax, 0x10
mov ds, ax
mov ss, ax
mov al, 0
cld
rep stosb
; clear BSS (uninit data)
mov edi, __bss_start
mov ecx, __end
sub ecx, edi
xor edx, edx
push edx
call start
cli
hlt
section .multiboot_header
header_start:
dd 0xe85250d6 ; magic number
dd 0 ; protected mode code
dd header_end - header_start ; header length
dd 0x100000000 - (0xe85250d6 + 0 + (header_end - header_start)) ; checksum
; required end tag
dw 0 ; type
dw 0 ; flags
dd 8 ; size
header_end:

View File

@ -1,4 +1,4 @@
ENTRY(start) ENTRY(entry)
OUTPUT_FORMAT("binary") OUTPUT_FORMAT("binary")
phys = 0x00100000; phys = 0x00100000;
@ -7,7 +7,7 @@ SECTIONS
. = phys; . = phys;
.entry : { __entry_start = .; *(.entry) } .entry : { __entry_start = .; *(.entry) }
.text : { __text_start = .; *(.text) } .text : { __text_start = ALIGN(8); KEEP(*(multiboot_header)) *(.text) }
.data : { __data_start = .; *(.data) } .data : { __data_start = .; *(.data) }
.rodata : { __rodata_start = .; *(.rodata) } .rodata : { __rodata_start = .; *(.rodata) }
.bss : { __bss_start = .; *(.bss) } .bss : { __bss_start = .; *(.bss) }

View File

@ -21,9 +21,6 @@
#include <util/util.h> #include <util/util.h>
#include <version.h> #include <version.h>
extern uint8_t __bss_start;
extern uint8_t __end;
uint16_t DEBUG_COM_PORT = COM1_PORT; uint16_t DEBUG_COM_PORT = COM1_PORT;
void __attribute__((section(".entry"))) start() { void __attribute__((section(".entry"))) start() {

View File

@ -6,4 +6,4 @@
#pragma once #pragma once
#define LOGO " _ _____ _ __________________\n / | / / | / | / / _/_ __/ ____/\n / |/ / /| | / |/ // / / / / __/ \n / /| / ___ |/ /| // / / / / /___ \n/_/ |_/_/ |_/_/ |_/___/ /_/ /_____/ \n" #define LOGO " _ _____ _ __________________\n / | / / | / | / / _/_ __/ ____/\n / |/ / /| | / |/ // / / / / __/ \n / /| / ___ |/ /| // / / / / /___ \n/_/ |_/_/ |_/_/ |_/___/ /_/ /_____/ \n"
#define VERSION "RD-00037" #define VERSION "RD-00038"