diff --git a/.github/workflows/analyze.yml b/.github/workflows/analyze.yml index abd9954..6a87b23 100644 --- a/.github/workflows/analyze.yml +++ b/.github/workflows/analyze.yml @@ -19,7 +19,7 @@ jobs: - name: Run shellcheck run: | - shellcheck ./releasetools/cdimage.sh ./releasetools/floppyimage.sh ./releasetools/hdimage.sh ./releasetools/image.defaults ./releasetools/image.functions + shellcheck ./releasetools/cdimage.sh ./releasetools/floppyimage.sh ./releasetools/hdimage.sh ./releasetools/image.defaults ./releasetools/image.functions ./tools/version.sh - name: Run CppCheck run: | diff --git a/boot/efi/Makefile b/boot/efi/Makefile index 86ee1ee..9cfd3b0 100644 --- a/boot/efi/Makefile +++ b/boot/efi/Makefile @@ -3,6 +3,8 @@ TARGET = BOOTIA32.EFI BOOTIA32_EFI_SRCS = bootia32.asm \ uefi.inc \ logger.inc \ + memory.inc \ + fs.inc \ ../common/const.inc \ ../common/macro.inc diff --git a/boot/efi/bootia32.asm b/boot/efi/bootia32.asm index f73ec8c..c134f9d 100644 --- a/boot/efi/bootia32.asm +++ b/boot/efi/bootia32.asm @@ -7,6 +7,8 @@ include 'uefi.inc' include '../../kernel/sys/bootinfo.inc' include 'logger.inc' + include 'memory.inc' + include 'fs.inc' section '.text' code executable readable @@ -33,26 +35,20 @@ efimain: mov ebx, [eax + EFI_SYSTEM_TABLE.BootServices] mov [pBootServices], ebx - mov ecx, [ebx + EFI_BOOT_SERVICES.AllocatePool] - mov [fnAllocatePool], ecx - - mov ecx, [ebx + EFI_BOOT_SERVICES.FreePool] - mov [fnFreePool], ecx - - mov ecx, [ebx + EFI_BOOT_SERVICES.GetMemoryMap] - mov [fnGetMemoryMap], ecx - mov ecx, [ebx + EFI_BOOT_SERVICES.OpenProtocol] mov [fnOpenProtocol], ecx mov ecx, [ebx + EFI_BOOT_SERVICES.Exit] mov [fnExit], ecx + call efi_memory_init call efi_log_init mov esi, szHelloMsg call efi_log + call efi_fs_init + ; #=======================# ; search and load kernel ; openVolume() @@ -93,9 +89,6 @@ pSystemTable dd ? ;; Variable: pBootServices pBootServices dd ? -fnAllocatePool dd ? -fnFreePool dd ? -fnGetMemoryMap dd ? fnOpenProtocol dd ? fnCloseProtocol dd ? fnExit dd ? diff --git a/boot/efi/fs.inc b/boot/efi/fs.inc new file mode 100644 index 0000000..677dac3 --- /dev/null +++ b/boot/efi/fs.inc @@ -0,0 +1,29 @@ + ;; File: fs.inc + + section '.text' code executable readable + +efi_fs_init: + + ; OpenProtocol(EFI_HANDLE Handle, EFI_GUID *proto, VOID **Interface, EFI_HANDLE AgentHandle, UINT32 Attrs) + push 0 + push [hImage] + push pLoadedImage + push aFSProtoGUID + push [hImage] + call [fnOpenProtocol] + add esp, 20 + + or eax, eax + jnz .error + ret +.error: + mov esi, szErrTmp + call efi_log + + ret + + section '.data' data readable writeable + +szErrTmp du "Can't OpenProtocol(Simple fs)", 0 +aFSProtoGUID db EFI_SIMPLE_FILE_SYSTEM_PROTOCOL_GUID +pLoadedImage dd 0 diff --git a/boot/efi/logger.inc b/boot/efi/logger.inc index f973735..b127399 100644 --- a/boot/efi/logger.inc +++ b/boot/efi/logger.inc @@ -1,3 +1,5 @@ + ;; File: logger.inc + section '.text' code executable readable ;; Function: efi_log_init diff --git a/boot/efi/memory.inc b/boot/efi/memory.inc new file mode 100644 index 0000000..5f93007 --- /dev/null +++ b/boot/efi/memory.inc @@ -0,0 +1,25 @@ + ;; File: memory.inc + + section '.text' code executable readable + +efi_memory_init: + mov eax, [pBootServices] + mov ecx, [eax + EFI_BOOT_SERVICES.AllocatePool] + mov [fnAllocatePool], ecx + + mov ecx, [eax + EFI_BOOT_SERVICES.FreePool] + mov [fnFreePool], ecx + + mov ecx, [eax + EFI_BOOT_SERVICES.GetMemoryMap] + mov [fnGetMemoryMap], ecx + + ret + + section '.data' data readable writeable + + ;; Variable: fnAllocatePool +fnAllocatePool dd ? + ;; Variable: fnFreePool +fnFreePool dd ? + ;; Variable: fnGetMemoryMap +fnGetMemoryMap dd ? diff --git a/boot/efi/uefi.inc b/boot/efi/uefi.inc index 490f679..ea9ea04 100644 --- a/boot/efi/uefi.inc +++ b/boot/efi/uefi.inc @@ -364,7 +364,8 @@ EFI_LOAD_FILE2_PROTOCOL equ EFI_LOAD_FILE_PROTOCOL ;; ======================================================================== ;; EFI_SIMPLE_FILE_SYSTEM_PROTOCOL ;; ======================================================================== -EFI_SIMPLE_FILE_SYSTEM_PROTOCOL_GUID equ 0x0964e5b22, 0x6459, 0x11d2, 0x8e, 0x39, 0x00, 0xa0, 0xc9, 0x69, 0x72, 0x3b +EFI_SIMPLE_FILE_SYSTEM_PROTOCOL_GUID equ 0x022, 0x5b, 0x4e, 0x96, 0x59, 0x64, 0xd2, 0x11, 0x8e, 0x39, 0x00, 0xa0, 0xc9, 0x69, 0x72, 0x3b +;EFI_SIMPLE_FILE_SYSTEM_PROTOCOL_GUID equ 0x0964e5b22, 0x6459, 0x11d2, 0x8e, 0x39, 0x00, 0xa0, 0xc9, 0x69, 0x72, 0x3b EFI_SIMPLE_FILE_SYSTEM_PROTOCOL_REVISION = 0x00010000 diff --git a/tools/version.sh b/tools/version.sh index 2b7c198..c0e970d 100644 --- a/tools/version.sh +++ b/tools/version.sh @@ -2,12 +2,12 @@ vers="$(git describe --abbrev=4 --match='v[0-9]*' HEAD 2>/dev/null)" -if [ ! -n "$vers" ]; then +if [ -z "$vers" ]; then vers="0.0" fi -major="$(echo -n "${vers}" | cut -d. -f1)" -minor="$(echo -n "${vers}" | cut -d. -f1)" +major="$(printf "%s" "${vers}" | cut -d. -f1)" +minor="$(printf "%s" "${vers}" | cut -d. -f1)" commit="$(git rev-parse --short HEAD)"