Compare commits
2 commits
c2e69b6f7f
...
f9e2dc33e9
Author | SHA1 | Date | |
---|---|---|---|
f9e2dc33e9 | |||
0d9fcf5ae4 |
5 changed files with 53 additions and 36 deletions
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -4,3 +4,4 @@
|
||||||
*.bin
|
*.bin
|
||||||
mnt/
|
mnt/
|
||||||
build/
|
build/
|
||||||
|
bx_enh_dbg.ini
|
||||||
|
|
9
Makefile
9
Makefile
|
@ -8,11 +8,10 @@ image: start32.bin mount grub-cfg roska.img mnt/roska/
|
||||||
cp start32.bin mnt/roska/
|
cp start32.bin mnt/roska/
|
||||||
sync
|
sync
|
||||||
|
|
||||||
qemu-multiboot: start32.bin
|
qemu-run: image roska.img
|
||||||
qemu-system-i386 -kernel start32.bin -serial stdio
|
|
||||||
qemu-image: image roska.img
|
|
||||||
qemu-system-i386 roska.img -serial stdio
|
qemu-system-i386 roska.img -serial stdio
|
||||||
|
bochs-run: image roska.img
|
||||||
|
bochs -qf bochsrc.txt
|
||||||
mount: roska.img mnt/
|
mount: roska.img mnt/
|
||||||
@if ! mountpoint -q "mnt/"; then \
|
@if ! mountpoint -q "mnt/"; then \
|
||||||
sudo mount -o loop,offset=1048576,umask=177,dmask=022,uid=$(shell id -u),gid=$(shell id -g) roska.img mnt/; \
|
sudo mount -o loop,offset=1048576,umask=177,dmask=022,uid=$(shell id -u),gid=$(shell id -g) roska.img mnt/; \
|
||||||
|
@ -29,7 +28,7 @@ build/:
|
||||||
@mkdir build
|
@mkdir build
|
||||||
|
|
||||||
roska.img: mnt/
|
roska.img: mnt/
|
||||||
dd if=/dev/zero of=roska.img bs=16M count=1
|
dd if=/dev/zero of=roska.img bs=1k count=16128
|
||||||
echo 'type=83' | sudo sfdisk roska.img
|
echo 'type=83' | sudo sfdisk roska.img
|
||||||
sudo losetup /dev/loop0 roska.img
|
sudo losetup /dev/loop0 roska.img
|
||||||
sudo losetup /dev/loop1 roska.img -o1048576
|
sudo losetup /dev/loop1 roska.img -o1048576
|
||||||
|
|
13
bochsrc.txt
Normal file
13
bochsrc.txt
Normal file
|
@ -0,0 +1,13 @@
|
||||||
|
display_library: x, options="gui_debug"
|
||||||
|
magic_break: enabled=1
|
||||||
|
romimage: file=$BXSHARE/BIOS-bochs-legacy
|
||||||
|
vgaromimage: file=$BXSHARE/VGABIOS-lgpl-latest
|
||||||
|
clock: sync=realtime
|
||||||
|
cpu: ips=4294967295, reset_on_triple_fault=false
|
||||||
|
megs: 128
|
||||||
|
ata0: enabled=1, ioaddr1=0x1f0, ioaddr2=0x3f0, irq=14
|
||||||
|
ata0-master: type=disk, mode=flat, path=roska.img, cylinders=32, heads=16, spt=63
|
||||||
|
boot: disk
|
||||||
|
|
||||||
|
# Use `bximage` to get disk geometry
|
||||||
|
# TODO: Figure out how to get sensible TTY serial
|
23
src/itoa.asm
23
src/itoa.asm
|
@ -1,8 +1,12 @@
|
||||||
;; Modified from: https://gist.github.com/SplittyDev/8e728627012e57ac0deac196660014fb
|
;; Modified from: https://gist.github.com/SplittyDev/8e728627012e57ac0deac196660014fb
|
||||||
|
|
||||||
|
; __itoa(src int, target addr, base)
|
||||||
|
;target address returned in EAX
|
||||||
|
;EBX, EBP, ESP preserved as our calling convention,
|
||||||
|
;refer to docs or something
|
||||||
|
|
||||||
;
|
;
|
||||||
; Routine to convert a 32-bit integer to a string.
|
; Routine to convert a 32-bit integer to a string.
|
||||||
; Registers are preserved.
|
|
||||||
;
|
;
|
||||||
; EAX: Source integer
|
; EAX: Source integer
|
||||||
; EBX: Target address
|
; EBX: Target address
|
||||||
|
@ -26,9 +30,13 @@
|
||||||
; ECX: Target address (active)
|
; ECX: Target address (active)
|
||||||
; EDX: Target address (temporary)
|
; EDX: Target address (temporary)
|
||||||
;
|
;
|
||||||
|
; return:
|
||||||
|
; put original target at EAX
|
||||||
|
; (we trust this blindly)
|
||||||
|
|
||||||
macro kuitoa src*, dest*, base* {
|
macro kuitoa src*, dest*, base* {
|
||||||
push dest
|
|
||||||
push base
|
push base
|
||||||
|
push dest
|
||||||
push src
|
push src
|
||||||
call __uitoa
|
call __uitoa
|
||||||
add esp, 3*4
|
add esp, 3*4
|
||||||
|
@ -39,14 +47,11 @@ __uitoa:
|
||||||
push ebp
|
push ebp
|
||||||
mov ebp, esp
|
mov ebp, esp
|
||||||
|
|
||||||
push eax
|
|
||||||
push ebx
|
push ebx
|
||||||
push ecx
|
|
||||||
push edx
|
|
||||||
|
|
||||||
mov eax, [ebp+8]
|
mov eax, [ebp+8]
|
||||||
mov ecx, [ebp+12]
|
mov ebx, [ebp+12]
|
||||||
mov ebx, [ebp+16]
|
mov ecx, [ebp+16]
|
||||||
|
|
||||||
mov edx, ecx
|
mov edx, ecx
|
||||||
mov ecx, ebx
|
mov ecx, ebx
|
||||||
|
@ -83,11 +88,9 @@ __uitoa:
|
||||||
dec ecx
|
dec ecx
|
||||||
jmp .reverse
|
jmp .reverse
|
||||||
.end:
|
.end:
|
||||||
pop edx
|
|
||||||
pop ecx
|
|
||||||
pop ebx
|
pop ebx
|
||||||
pop eax
|
|
||||||
|
|
||||||
|
mov eax, [ebp+12] ; Return target address
|
||||||
pop ebp
|
pop ebp
|
||||||
ret
|
ret
|
||||||
|
|
||||||
|
|
|
@ -52,45 +52,46 @@ start:
|
||||||
add esp, 2*4
|
add esp, 2*4
|
||||||
|
|
||||||
sub esp, 36 ;Reserve stack for return
|
sub esp, 36 ;Reserve stack for return
|
||||||
kuitoa [mbootinfo.fb_addr], esp, 16
|
mov ebx, esp ;Store str buff addr
|
||||||
serw stuff.fbaddrmsgpfx, esp
|
|
||||||
|
|
||||||
kuitoa [mbootinfo.fb_width], esp, 10
|
kuitoa [mbootinfo.fb_addr], ebx, 16
|
||||||
serw stuff.fbdimensionsmsgpfx, esp, stuff.x
|
serw stuff.fbaddrmsgpfx, ebx
|
||||||
|
|
||||||
kuitoa [mbootinfo.fb_height], esp, 10
|
kuitoa [mbootinfo.fb_width], ebx, 10
|
||||||
serw esp, stuff.x
|
serw stuff.fbdimensionsmsgpfx, ebx, stuff.x
|
||||||
|
|
||||||
|
kuitoa [mbootinfo.fb_height], ebx, 10
|
||||||
|
serw ebx, stuff.x
|
||||||
|
|
||||||
movzx eax, byte [mbootinfo.fb_bpp]
|
movzx eax, byte [mbootinfo.fb_bpp]
|
||||||
kuitoa eax, esp, 10
|
kuitoa eax, ebx, 10
|
||||||
serw esp
|
serw ebx
|
||||||
|
|
||||||
|
|
||||||
movzx eax, byte [mbootinfo.fb_rpos]
|
movzx eax, byte [mbootinfo.fb_rpos]
|
||||||
kuitoa eax, esp, 10
|
kuitoa eax, ebx, 10
|
||||||
serw stuff.rpostxt, esp
|
serw stuff.rpostxt, ebx
|
||||||
|
|
||||||
movzx eax, byte [mbootinfo.fb_gpos]
|
movzx eax, byte [mbootinfo.fb_gpos]
|
||||||
kuitoa eax, esp, 10
|
kuitoa eax, ebx, 10
|
||||||
serw stuff.gpostxt, esp
|
serw stuff.gpostxt, ebx
|
||||||
|
|
||||||
movzx eax, byte [mbootinfo.fb_bpos]
|
movzx eax, byte [mbootinfo.fb_bpos]
|
||||||
kuitoa eax, esp, 10
|
kuitoa eax, ebx, 10
|
||||||
serw stuff.bpostxt, esp
|
serw stuff.bpostxt, ebx
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
movzx eax, byte [mbootinfo.fb_rmasksize]
|
movzx eax, byte [mbootinfo.fb_rmasksize]
|
||||||
kuitoa eax, esp, 10
|
kuitoa eax, ebx, 10
|
||||||
serw stuff.rmasksizetxt, esp
|
serw stuff.rmasksizetxt, ebx
|
||||||
|
|
||||||
movzx eax, byte [mbootinfo.fb_gmasksize]
|
movzx eax, byte [mbootinfo.fb_gmasksize]
|
||||||
kuitoa eax, esp, 10
|
kuitoa eax, ebx, 10
|
||||||
serw stuff.gmasksizetxt, esp
|
serw stuff.gmasksizetxt, ebx
|
||||||
|
|
||||||
movzx eax, byte [mbootinfo.fb_bmasksize]
|
movzx eax, byte [mbootinfo.fb_bmasksize]
|
||||||
kuitoa eax, esp, 10
|
kuitoa eax, ebx, 10
|
||||||
serw stuff.bmasksizetxt, esp
|
serw stuff.bmasksizetxt, ebx
|
||||||
|
|
||||||
add esp, 36 ;Clean reserved uitoa return string from stack
|
add esp, 36 ;Clean reserved uitoa return string from stack
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue