fix(loader): log time

This commit is contained in:
d0p1 🏳️‍⚧️ 2024-05-03 12:00:17 +02:00
parent 6ff773de41
commit 974b0862bf
5 changed files with 121 additions and 13 deletions

View file

@ -24,6 +24,11 @@ CFLAGS = -DMK_COMMIT="$(MK_COMMIT)" -DMK_BUGREPORT="$(MK_BUGREPORT)" -I$(TOPDIR)
LDFLAGS =
endif
QEMU_COMMON = \
-rtc base=localtime \
-vga virtio \
-serial mon:stdio
SUBDIRS := external tools include boot kernel lib bin
TARGET = stupid.tar.gz floppy1440.img floppy2880.img
@ -80,22 +85,26 @@ OVMF32.fd:
.PHONY: run
run: all
qemu-system-i386 \
-rtc base=localtime \
$(QEMU_COMMON) \
-drive file=floppy1440.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: run-iso
run-iso: all
qemu-system-i386 \
$(QEMU_COMMON) \
-cdrom stupid.iso
.PHONY: run-efi
run-efi: all OVMF32.fd
qemu-system-i386 \
$(QEMU_COMMON) \
-bios OVMF32.fd \
-rtc base=localtime \
-drive file=fat:rw:./sysroot,if=none,id=hdd \
-device ide-hd,drive=hdd \
-serial stdio
-device ide-hd,drive=hdd
.PHONY: docs
docs:

View file

@ -38,6 +38,14 @@ efimain:
call [ebx + EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL.OutputString]
add esp, 8
; search and load kernel
; get memory map
; paging
; jump to kernel
jmp $
xor eax, eax
@ -47,9 +55,12 @@ efimain:
section '.data' data readable writeable
hello_msg du 'StupidOS EFI Bootloader', 13, 10, 0
hello_msg du 'StupidOS EFI Bootloader', CR, LF, 0
; Search path: / /boot /boot/efi
search_paths du '\\', 0, \
'\\boot', 0, \
'\\boot\\efi', 0, 0
kernel_file du 'vmstupid.sys', 0
handle dd ?

View file

@ -127,10 +127,10 @@ multiboot:
; get kernel from module
common32:
xchg bx, bx
mov dword [0xB8000], 0x07690748
common32:
mov [0xB8000], dword 0x07690748
; paging
; identity map first 1MB
; map kernel to 0xC0000000

View file

@ -4,21 +4,33 @@ bios_log_time:
int 0x1A
mov al, ch
aam
mov ah, al
shr ah, 4
and ah, 0xF
and al, 0xF
;aam
add ah, 0x30
add al, 0x30
mov [time + 1], ah
mov [time + 2], al
mov al, cl
aam
mov ah, al
shr ah, 4
and ah, 0xF
and al, 0xF
;aam
add ah, 0x30
add al, 0x30
mov [time + 4], ah
mov [time + 5], al
mov al, dh
aam
mov ah, al
shr ah, 4
and ah, 0xF
and al, 0xF
;aam
add ah, 0x30
add al, 0x30
mov [time + 7], ah
@ -130,7 +142,7 @@ bios_log:
ret
time db '[00:00.00] ', 0
time db '[00:00:00] ', 0
hex_prefix db '0x', 0
hex_digits db '0123456789ABCDEF'
endline db CR, LF, 0

76
lib/crypto/rc4/rc4.asm Normal file
View file

@ -0,0 +1,76 @@
format COFF
use32
section '.text' code
;; Function: rc4_init
;;
;; Parameters:
;;
;; [esp+8] - state
;; [esp+12] - key
;; [esp+16] - key length
;;
rc4_init:
push ebp
mov ebp, esp
mov eax, [ebp+8]
xor ecx, ecx
.loop:
.end:
leave
ret
;; Function: rc4
;;
;; Parameters:
;;
;; [esp+8] - state
;; [esp+12] - out buffer
;; [esp+16] - input buffer
;; [esp+20] - intput buffer size
rc4:
push ebp
mov ebp, esp
push esi
push edi
push ebx
xor esi, esi
xor edi, edi
xor ecx, ecx
.loop:
cmp ecx, [esp+20]
je .end
inc esi
mov eax, esi
movzx esi, al
add edi, esi
mov eax, edi
movzx edi, al
mov edx, [esp+8]
mov al, byte [edx+esi]
mov bl, byte [edx+edi]
mov byte [edx+esi], bl
mov byte [edx+edi], al
inc ecx
jmp .loop
.end:
pop ebx
pop edi
pop esi
leave
ret