1
1
Fork 0

stuff and things

This commit is contained in:
Lauren Toivanen 2025-07-28 06:50:19 +03:00
commit 4b85060139
3 changed files with 146 additions and 0 deletions

4
.gitignore vendored Normal file
View file

@ -0,0 +1,4 @@
*.bin
*.elf
*.o
*.img

52
README.md Normal file
View file

@ -0,0 +1,52 @@
# rOSka
Compile with `fasm boot.asm`
## Reguirements
Pentium or newer should have all the bells and whistles needed.
In case you want all the details:
- 32bit 80386 or newer CPU
- VGA compatible graphics adapter
(640x480 graphics mode with 16 colours and a text mode)
- BIOS (or CSM, can't take anything granted these days...)
- RAM as I'm sure I'll just yank hard coded assumptions here and there
Like 1MB should be enough for now
- Hard disk access requires extended BIOS support (i486 CPU?)
Youknow, we support big disk like here in modern times.
- Floppies can't usually be accessed with extended calls, too bad.
As a workaround get USB or something and chainload with PLOP bootmgr
if direct USB boot is unavailable. Might make a floppy image at some
point.
## Preparing a bootable disk
- We use standard MBR, even on a floppy. Eat shit MSLosdows.
- We use partition 1 as our partition. This is ext2. Again, deal with it.
So make a new partition table, partition it, and format it on Lunix.
Or Losdows, but there you're on your own!
!!! WARNING
This will wipe the entire drive
Replace /dev/sdX accordingly and triplecheck
```
sudo parted -s /dev/sdX mklabel msdos
sudo parted -s /dev/sdX mkpart primary ext2 0 100% --align cylinder
sudo mkfs.ext2 -L rOSka /dev/sdX1
```
Now put the thinking part to the MBR preserving partitiontable
```
sudo dd bs=1 count=446 if=boot.bin of=/dev/sdX conv=notrunc
```
And wow, you have a disk with a filesystem that boots the fancy loader
```
TODO: set bootable flag in fdisk and use VBR instead of MBR?
```

90
boot.asm Executable file
View file

@ -0,0 +1,90 @@
format binary
org 0x7c00
use16
jmp short start
nop
;; reserved for (E)BPB (which BIOS might scramble)
;; you could also have one that *could* work
times 0x3B db 0
start:
;; setup segments
;; setup stack
;; trust nothing
cld
mov ax, 0
mov ds, ax
mov es, ax
mov ss, ax
mov sp, 0x7c00 ;stack down from our load address
mov bp, sp
;; ensure VGA textmode
mov ah, 0x00
mov al, 0x03 ;Colour Text mode 3 80x25
int 0x10
;; storeBootdiskNum
mov [diskNum], dl
checkLBASupport:
;; Set AH = 0x41
;; BX = 0x55AA
;; DL = drive
;; INT 0x13
mov si, msg.lba
mov ah, 0x41
mov bx, 0x55AA
int 0x13
jc msg.error
test bx, 0xAA55
jz msg.error
test cx, cx
jp msg.error
getPartitionLBA:
;; 1st partition entry at 0x1BE (16 bytes)
;; LBA start 4bytes at 0x1BE + 0x08
;; Sectors count 4bytes at 0x1BE + 0x0C
;; so uhmmmm, read those and use 'em to find next peace of data?
;; Wait is my MBR one block that is read at once? Lol wait MBR
;; is also part of my own current loaded memory!
nomoreThings:
mov si, msg.nop
jmp msg.ok
endloop:
nop
jmp endloop
msg:
.ok:
mov ah, 0x20 ;greenblack
jmp .prepare
.error:
mov ah, 0x47 ;redgray
.prepare:
mov bx, 0xb800
mov es, bx
mov edi, 0
.loop:
lodsb
test al, al
jz endloop
stosw
jmp .loop
.lba db "Inadequate LBA support: Ancient computor or floppy?", 0
.nop db "Nothingtodo :'(", 0
;; Store some data
diskNum db 0x00