Skip to content

Commit

Permalink
refactor: hungarian notation
Browse files Browse the repository at this point in the history
  • Loading branch information
d0p1s4m4 committed Jun 5, 2024
1 parent dd117e9 commit d8f6861
Show file tree
Hide file tree
Showing 11 changed files with 189 additions and 34 deletions.
16 changes: 8 additions & 8 deletions boot/bootsect/floppy.asm
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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 $
Expand Down Expand Up @@ -160,7 +160,7 @@ disk_read_sectors:
loop disk_read_sectors
ret
@@:
mov si, msg_error_sector
mov si, szErrorSector
call bios_print
ret

Expand All @@ -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

Expand Down
66 changes: 52 additions & 14 deletions boot/efi/bootia32.asm
Original file line number Diff line number Diff line change
Expand Up @@ -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
; #=======================#
Expand All @@ -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

handle dd ?
system_table dd ?
szKernelFile du 'vmstupid.sys', 0
szConfigFile du 'stpdboot.cfg', 0

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 ?
87 changes: 86 additions & 1 deletion boot/efi/uefi.inc
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,73 @@ EFI_BOOT_SERVICES_REVISION = EFI_SPECIFICATION_VERSION
;; Struct: EFI_BOOT_SERVICES
struc EFI_BOOT_SERVICES
{
.Hdr EFI_TABLE_HEADER
.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
}

;; ========================================================================
Expand All @@ -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


}

;; ========================================================================
Expand Down
2 changes: 1 addition & 1 deletion boot/loader/logger.inc
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ bios_log_number:
push ebp
mov ebp, esp
sub esp, 10

leave
ret

Expand Down
12 changes: 7 additions & 5 deletions build.sh
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -177,7 +179,7 @@ fi

while [ $# -gt 0 ]; do
op=$1; shift

case "${op}" in
help | --help | -h)
usage 0
Expand Down
2 changes: 2 additions & 0 deletions docs/coding-style.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ File: Coding Style

About: Assembly

The "Hungarian" notation conventions MUST be used.

Comments:

TO BE ADDED
Expand Down
Empty file modified releasetools/cdimage.sh
100644 → 100755
Empty file.
Empty file modified releasetools/floppyimage.sh
100644 → 100755
Empty file.
10 changes: 10 additions & 0 deletions releasetools/hdimage.sh
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,10 +1,20 @@
#!/usr/bin/env bash
set -e

: "${IMG=disk.img}"

if [ ! -f build.sh ]
then
exit 1
fi

. ./releasetools/image.defaults
. ./releasetools/image.functions

if [ -f "${IMG}" ]
then
rm -f "${IMG}"
fi

echo ""
echo "Disk image at $(pwd)/${IMG}"
8 changes: 5 additions & 3 deletions releasetools/image.defaults
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
: ${BUILDDIR=.build}
: ${OBJ=${BUILDDIR}/obj}
: ${DESTDIR=${BUILDDIR}/dist}
#!/usr/bin/env bash

: "${BUILDDIR=.build}"
: "${OBJ=${BUILDDIR}/obj}"
: "${DESTDIR=${BUILDDIR}/dist}"
20 changes: 18 additions & 2 deletions releasetools/image.functions
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -11,8 +16,19 @@ menuentry "StupidOS" {
module /vmstupid.sys
boot
}
EOF )
EOF
)"

echo "$grub_cfg" > "$target"
}

get_grub()
{
echo
}

create_efi_image()
{
echo
}

0 comments on commit d8f6861

Please sign in to comment.