diff --git a/boot/bootsect/floppy.asm b/boot/bootsect/floppy.asm index 25daef1..edf5756 100644 --- a/boot/bootsect/floppy.asm +++ b/boot/bootsect/floppy.asm @@ -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 diff --git a/boot/efi/bootia32.asm b/boot/efi/bootia32.asm index bdf399e..28301c8 100644 --- a/boot/efi/bootia32.asm +++ b/boot/efi/bootia32.asm @@ -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 ? diff --git a/boot/efi/uefi.inc b/boot/efi/uefi.inc index e13881c..ecce118 100644 --- a/boot/efi/uefi.inc +++ b/boot/efi/uefi.inc @@ -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 } ;; ======================================================================== @@ -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 + + } ;; ======================================================================== diff --git a/boot/loader/logger.inc b/boot/loader/logger.inc index c42078b..86fbb65 100644 --- a/boot/loader/logger.inc +++ b/boot/loader/logger.inc @@ -50,7 +50,7 @@ bios_log_number: push ebp mov ebp, esp sub esp, 10 - + leave ret diff --git a/build.sh b/build.sh old mode 100644 new mode 100755 index 28b1a18..f5ca05d --- a/build.sh +++ b/build.sh @@ -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 @@ -177,7 +179,7 @@ fi while [ $# -gt 0 ]; do op=$1; shift - + case "${op}" in help | --help | -h) usage 0 diff --git a/docs/coding-style.txt b/docs/coding-style.txt index d746c28..554c35b 100644 --- a/docs/coding-style.txt +++ b/docs/coding-style.txt @@ -2,6 +2,8 @@ File: Coding Style About: Assembly +The "Hungarian" notation conventions MUST be used. + Comments: TO BE ADDED diff --git a/releasetools/cdimage.sh b/releasetools/cdimage.sh old mode 100644 new mode 100755 diff --git a/releasetools/floppyimage.sh b/releasetools/floppyimage.sh old mode 100644 new mode 100755 diff --git a/releasetools/hdimage.sh b/releasetools/hdimage.sh old mode 100644 new mode 100755 index abdce9b..b2bdf0d --- a/releasetools/hdimage.sh +++ b/releasetools/hdimage.sh @@ -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}" diff --git a/releasetools/image.defaults b/releasetools/image.defaults index 36fc06a..4aadb83 100644 --- a/releasetools/image.defaults +++ b/releasetools/image.defaults @@ -1,3 +1,5 @@ -: ${BUILDDIR=.build} -: ${OBJ=${BUILDDIR}/obj} -: ${DESTDIR=${BUILDDIR}/dist} +#!/usr/bin/env bash + +: "${BUILDDIR=.build}" +: "${OBJ=${BUILDDIR}/obj}" +: "${DESTDIR=${BUILDDIR}/dist}" diff --git a/releasetools/image.functions b/releasetools/image.functions index 2e2b4de..660514d 100644 --- a/releasetools/image.functions +++ b/releasetools/image.functions @@ -1,6 +1,11 @@ +#!/usr/bin/env bash + create_grub_cfg() { - grub_config=$(cat < "$target" } +get_grub() +{ + echo +} +create_efi_image() +{ + echo +}