refactor: hungarian notation

This commit is contained in:
d0p1 🏳️‍⚧️ 2024-06-05 17:15:00 +02:00
parent dd117e9a7c
commit d8f68619d6
11 changed files with 188 additions and 33 deletions

View file

@ -70,7 +70,7 @@ _start:
; search in root directory
mov si, stage1_file
mov si, szLoaderFile
call fat_search_root
jc .error_not_found
mov [stage1_start], ax
@ -99,11 +99,11 @@ _start:
.error_not_found:
push si
mov si, msg_error
mov si, szError
call bios_print
pop si
call bios_print
mov si, msg_not_found
mov si, szNotFound
call bios_print
hlt
jmp $
@ -160,7 +160,7 @@ disk_read_sectors:
loop disk_read_sectors
ret
@@:
mov si, msg_error_sector
mov si, szErrorSector
call bios_print
ret
@ -171,11 +171,11 @@ S dw 0x00
include '../common/bios.inc'
include '../common/fat12.inc'
msg_error db "ERROR: ", 0
msg_not_found db " not found", CR, LF, 0
msg_error_sector db "reading sector", CR, LF, 0
szError db "ERROR: ", 0
szNotFound db " not found", CR, LF, 0
szErrorSector db "reading sector", CR, LF, 0
stage1_file db "STPDLDR SYS", 0
szLoaderFile db "STPDLDR SYS", 0
stage1_start dw 0x0

View file

@ -21,24 +21,38 @@
;;
efimain:
mov eax, [esp+4]
mov [handle], eax
mov [hImage], eax
mov eax, [esp+8]
mov [system_table], eax
mov [pSystemTable], eax
mov ebx, [eax + EFI_SYSTEM_TABLE.RuntimeServices]
mov [pRuntimeServices], ebx
mov ebx, [eax + EFI_SYSTEM_TABLE.BootServices]
mov [pBootServices], ebx
;mov ecx, [ebx + EFI_BOOT_SERVICES.OpenProtocol]
;mov [fnOpenProtocol], ecx
mov ebx, [eax + EFI_SYSTEM_TABLE.ConOut]
mov [pConOut], ebx
mov ecx, [ebx + EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL.Reset]
mov [fnOutputReset], ecx
mov ecx, [ebx + EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL.OutputString]
mov [fnOutputStr], ecx
mov eax, 1
push eax
push ebx
call [ebx + EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL.Reset]
push [pConOut]
call [fnOutputReset]
add esp, 8
push hello_msg
push ebx
call [ebx + EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL.OutputString]
push szHelloMsg
push [pConOut]
call [fnOutputStr]
add esp, 8
; load config
; #=======================#
@ -65,13 +79,37 @@ efimain:
section '.data' data readable writeable
hello_msg du 'StupidOS EFI Bootloader', CR, LF, 0
szHelloMsg du 'StupidOS EFI Bootloader', CR, LF, 0
; Search path: / /boot /boot/efi
search_paths du '\\', 0, \
aSearchPaths du '\\', 0, \
'\\boot', 0, \
'\\boot\\efi', 0, 0
kernel_file du 'vmstupid.sys', 0
szKernelFile du 'vmstupid.sys', 0
szConfigFile du 'stpdboot.cfg', 0
handle dd ?
system_table dd ?
hImage dd ?
pSystemTable dd ?
;; Variable: pBootServices
pBootServices dd ?
fnAllocatePages dd ?
fnFreePages dd ?
fnGetMemoryMap dd ?
fnOpenProtocol dd ?
fnCloseProtocol dd ?
;; Variable: pRuntimeServices
pRuntimeServices dd ?
;; Variable: pConOut
;; Pointer to EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL
pConOut dd ?
fnOutputReset dd ?
fnOutputStr dd ?
;; Variable: pLoadFileProtocol
;; Pointer to EFI_LOAD_FILE_PROTOCOL
pLoadFileProtocol dd ?
fnLoadFile dd ?

View file

@ -143,6 +143,72 @@ EFI_BOOT_SERVICES_REVISION = EFI_SPECIFICATION_VERSION
struc EFI_BOOT_SERVICES
{
.Hdr EFI_TABLE_HEADER
; Task Priority Services
.RaiseTPL UINTPTR
.RestoreTPL UINTPTR
; Memory Services
.AllocatePages UINTPTR
.FreePages UINTPTR
.GetMemoryMap UINTPTR
.AllocatePool UINTPTR
.FreePool UINTPTR
; Event & Timer Services
.CreateEvent UINTPTR
.SetTimer UINTPTR
.WaitForEvent UINTPTR
.SignalEvent UINTPTR
.CloseEvent UINTPTR
.CheckEvent UINTPTR
; Protocol Handler Services
.InstallProtocolInterface UINTPTR
.ReinstallProtocolInterface UINTPTR
.UninstallProtocolInterface UINTPTR
.HandleProtocol UINTPTR
.Reserved UINTPTR
.RegisterProtocolNotify UINTPTR
.LocateHandle UINTPTR
.LocateDevicePath UINTPTR
.InstallConfigurationTable UINTPTR
; Image Services
.LoadImage UINTPTR
.StartImage UINTPTR
.Exit UINTPTR
.UnloadImage UINTPTR
.ExitBootServices UINTPTR
; Misc Services
.GetNextMonotonicCount UINTPTR
.Stall UINTPTR
.SetWatchdogTimer UINTPTR
; DriverSupport Service
.ConnectController UINTPTR
.DisconnectController UINTPTR
; Open and Close Protocol Services
.OpenProtocol UINTPTR
.CloseProtocol UINTPTR
.OpenProtocolInformation UINTPTR
; Library Services
.ProtocolsPerHandle UINTPTR
.LocateHandleBuffer UINTPTR
.LocateProtocol UINTPTR
.InstallMultipleProtocolInterfaces UINTPTR
.UninstallMultipleProtocolInterfaces UINTPTR
; 32bit CRC Services
.CalculateCrc32 UINTPTR
; Misc Services
.CopyMem UINTPTR
.SetMem UINTPTR
.CreateEventEx UINTPTR
}
;; ========================================================================
@ -155,6 +221,25 @@ EFI_RUNTIMES_SERVICES_REVISION = EFI_SPECIFICATION_VERSION
struc EFI_RUNTIMES_SERVICES
{
.Hdr EFI_TABLE_HEADER
; Time Services
.GetTime UINTPTR
.SetTime UINTPTR
.GetWakeupTime UINTPTR
.SetWakeupTime UINTPTR
; Virtual Memory Services
.SetVirtualAddressMap UINTPTR
.ConvertPointer UINTPTR
; Variable Services
.GetVariable UINTPTR
.GetNextVariableName UINTPTR
.SetVariable UINTPTR
; Misc Services
}
;; ========================================================================

10
build.sh Normal file → Executable file
View file

@ -74,10 +74,12 @@ check_tool() {
printf "checking for %s " "${tool}"
tool_path="$(which "${tool}" 2> /dev/null)"
if [ "x${tool_path}" = "x" ]; then
if [ -z "${tool_path}" ]; then
# shellcheck disable=SC2059
printf "${BOLD}${RED}NO${ALL_OFF}\n"
false;
else
# shellcheck disable=SC2059
printf "${GREEN}${tool_path}${ALL_OFF}\n"
true;
fi
@ -157,14 +159,14 @@ unset topdir prgname build_start
prgname="$(basename $0)"
topdir="$(realpath "$0")"
topdir="$(dirname "${topdir}")"
build_start="$(date)"
readonly topdir prgname build_start
#build_start="$(date)"
readonly topdir prgname
#build_start
SRC_DIR="${topdir}"
BUILD_DIR="${topdir}/.build"
TOOLS_DIR="${topdir}/.tools"
TOOLS_PREFIX="stpd-"
export PATH="$PATH:$TOOLS_DIR"
if [ ! -f Makefile ] || [ ! -f LICENSE ]; then

View file

@ -2,6 +2,8 @@ File: Coding Style
About: Assembly
The "Hungarian" notation conventions MUST be used.
Comments:
TO BE ADDED

0
releasetools/cdimage.sh Normal file → Executable file
View file

0
releasetools/floppyimage.sh Normal file → Executable file
View file

10
releasetools/hdimage.sh Normal file → Executable file
View file

@ -1,6 +1,8 @@
#!/usr/bin/env bash
set -e
: "${IMG=disk.img}"
if [ ! -f build.sh ]
then
exit 1
@ -8,3 +10,11 @@ fi
. ./releasetools/image.defaults
. ./releasetools/image.functions
if [ -f "${IMG}" ]
then
rm -f "${IMG}"
fi
echo ""
echo "Disk image at $(pwd)/${IMG}"

View file

@ -1,3 +1,5 @@
: ${BUILDDIR=.build}
: ${OBJ=${BUILDDIR}/obj}
: ${DESTDIR=${BUILDDIR}/dist}
#!/usr/bin/env bash
: "${BUILDDIR=.build}"
: "${OBJ=${BUILDDIR}/obj}"
: "${DESTDIR=${BUILDDIR}/dist}"

View file

@ -1,6 +1,11 @@
#!/usr/bin/env bash
create_grub_cfg()
{
grub_config=$(cat <<EOF
local target="$1"
local grub_cfg
grub_cfg="$(cat <<EOF
set timeout=15
set default=0
@ -11,8 +16,19 @@ menuentry "StupidOS" {
module /vmstupid.sys
boot
}
EOF )
EOF
)"
echo "$grub_cfg" > "$target"
}
get_grub()
{
echo
}
create_efi_image()
{
echo
}