diff options
Diffstat (limited to 'dev')
| -rw-r--r-- | dev/boot/BootKit/BootKit.h | 4 | ||||
| -rw-r--r-- | dev/boot/amd64-ci.make | 2 | ||||
| -rw-r--r-- | dev/boot/amd64-desktop.make | 16 | ||||
| -rw-r--r-- | dev/boot/arm64-desktop.make | 14 | ||||
| -rw-r--r-- | dev/boot/src/BootTextWriter.cc | 4 | ||||
| -rw-r--r-- | dev/boot/src/HEL/AMD64/BootEFI.cc | 43 | ||||
| -rw-r--r-- | dev/kernel/FirmwareKit/EFI/EFI.h | 14 | ||||
| -rw-r--r-- | dev/kernel/KernelKit/DebugOutput.h | 2 |
8 files changed, 54 insertions, 45 deletions
diff --git a/dev/boot/BootKit/BootKit.h b/dev/boot/BootKit/BootKit.h index e845e6ce..b5062eab 100644 --- a/dev/boot/BootKit/BootKit.h +++ b/dev/boot/BootKit/BootKit.h @@ -61,10 +61,10 @@ namespace Boot */ class BootTextWriter final { - BootTextWriter& _Write(const Long& num); + BootTextWriter& _Write(const UInt64& num); public: - BootTextWriter& Write(const Long& num); + BootTextWriter& Write(const UInt64& num); BootTextWriter& Write(const Char* str); BootTextWriter& Write(const CharacterTypeUTF16* str); BootTextWriter& WriteCharacter(CharacterTypeUTF16 c); diff --git a/dev/boot/amd64-ci.make b/dev/boot/amd64-ci.make index a77806c4..21c797f6 100644 --- a/dev/boot/amd64-ci.make +++ b/dev/boot/amd64-ci.make @@ -85,7 +85,7 @@ invalid-recipe: # CI doesn't do anything than build. .PHONY: all all: compile-amd64 - mkdir -p src/Root/EFI/BOOT + mkdir -p src/root/EFI/BOOT $(LD_GNU) $(OBJ) $(LD_FLAGS) -o src/$(BOOTLOADER) .PHONY: disk diff --git a/dev/boot/amd64-desktop.make b/dev/boot/amd64-desktop.make index 649e0925..95ccac2e 100644 --- a/dev/boot/amd64-desktop.make +++ b/dev/boot/amd64-desktop.make @@ -84,15 +84,15 @@ invalid-recipe: .PHONY: all all: compile-amd64 - mkdir -p src/Root/EFI/BOOT + mkdir -p src/root/EFI/BOOT $(LD_GNU) $(OBJ) $(LD_FLAGS) -o src/$(BOOTLOADER) - $(COPY) src/$(BOOTLOADER) src/Root/EFI/BOOT/BOOTX64.EFI - $(COPY) src/$(BOOTLOADER) src/Root/EFI/BOOT/BOOTZ.EFI - $(COPY) ../kernel/$(KERNEL) src/Root/$(KERNEL) - $(COPY) ./modules/SysChk/$(SYSCHK) src/Root/$(SYSCHK) - $(COPY) ./modules/BootNet/$(BOOTNET) src/Root/$(BOOTNET) - $(COPY) ../user/$(SCIKIT) src/Root/$(SCIKIT) - $(COPY) src/$(BOOTLOADER) src/Root/$(BOOTLOADER) + $(COPY) src/$(BOOTLOADER) src/root/EFI/BOOT/BOOTX64.EFI + $(COPY) src/$(BOOTLOADER) src/root/EFI/BOOT/BOOTZ.EFI + $(COPY) ../kernel/$(KERNEL) src/root/$(KERNEL) + $(COPY) ./modules/SysChk/$(SYSCHK) src/root/$(SYSCHK) + $(COPY) ./modules/BootNet/$(BOOTNET) src/root/$(BOOTNET) + $(COPY) ../user/$(SCIKIT) src/root/$(SCIKIT) + $(COPY) src/$(BOOTLOADER) src/root/$(BOOTLOADER) .PHONY: disk disk: diff --git a/dev/boot/arm64-desktop.make b/dev/boot/arm64-desktop.make index d17c2ae2..a862b5b8 100644 --- a/dev/boot/arm64-desktop.make +++ b/dev/boot/arm64-desktop.make @@ -31,7 +31,7 @@ EMU_FLAGS=-net none -smp 4 -m 8G -cpu max -M virt \ -bios $(BIOS) \ -drive id=disk,file=$(IMG),format=raw,if=none \ -drive \ - file=fat:rw:src/Root/,index=2,format=raw \ + file=fat:rw:src/root/,index=2,format=raw \ -no-shutdown -no-reboot -cpu cortex-a72 -device virtio-gpu-pci LD_FLAGS=-subsystem:efi_application -entry:Main /nodefaultlib @@ -58,13 +58,13 @@ invalid-recipe: .PHONY: all all: compile - mkdir -p src/Root/EFI/BOOT + mkdir -p src/root/EFI/BOOT $(LD_GNU) $(OBJ) $(LD_FLAGS) /out:src/$(BOOT_LOADER) - $(COPY) src/$(BOOT_LOADER) src/Root/EFI/BOOT/BOOTAA64.EFI - $(COPY) src/$(BOOT_LOADER) src/Root/EFI/BOOT/BootZ.EFI - $(COPY) ../kernel/$(KERNEL) src/Root/$(KERNEL) - $(COPY) ./modules/SysChk/$(SYSCHK) src/Root/$(SYSCHK) - $(COPY) src/$(BOOT_LOADER) src/Root/$(BOOT_LOADER) + $(COPY) src/$(BOOT_LOADER) src/root/EFI/BOOT/BOOTAA64.EFI + $(COPY) src/$(BOOT_LOADER) src/root/EFI/BOOT/BootZ.EFI + $(COPY) ../kernel/$(KERNEL) src/root/$(KERNEL) + $(COPY) ./modules/SysChk/$(SYSCHK) src/root/$(SYSCHK) + $(COPY) src/$(BOOT_LOADER) src/root/$(BOOT_LOADER) ifneq ($(DEBUG_SUPPORT), ) DEBUG = -D__DEBUG__ diff --git a/dev/boot/src/BootTextWriter.cc b/dev/boot/src/BootTextWriter.cc index bc93b133..0b132f83 100644 --- a/dev/boot/src/BootTextWriter.cc +++ b/dev/boot/src/BootTextWriter.cc @@ -131,7 +131,7 @@ Boot::BootTextWriter& Boot::BootTextWriter::WriteCharacter(CharacterTypeUTF16 c) return *this; } -Boot::BootTextWriter& Boot::BootTextWriter::Write(const Long& x) +Boot::BootTextWriter& Boot::BootTextWriter::Write(const UInt64& x) { #ifdef __DEBUG__ this->_Write(x); @@ -141,7 +141,7 @@ Boot::BootTextWriter& Boot::BootTextWriter::Write(const Long& x) return *this; } -Boot::BootTextWriter& Boot::BootTextWriter::_Write(const Long& x) +Boot::BootTextWriter& Boot::BootTextWriter::_Write(const UInt64& x) { #ifdef __DEBUG__ UInt64 y = (x > 0 ? x : -x) / 16; diff --git a/dev/boot/src/HEL/AMD64/BootEFI.cc b/dev/boot/src/HEL/AMD64/BootEFI.cc index 7b912025..5f89aae6 100644 --- a/dev/boot/src/HEL/AMD64/BootEFI.cc +++ b/dev/boot/src/HEL/AMD64/BootEFI.cc @@ -91,9 +91,9 @@ EFI_EXTERN_C EFI_API Int32 Main(EfiHandlePtr image_handle, new HEL::BootInfoHeader(); UInt32 map_key = 0; - UInt32 size_struct_ptr = sizeof(EfiMemoryDescriptor); + UInt32 size_struct_ptr = 0; EfiMemoryDescriptor* struct_ptr = nullptr; - UInt32 sz_desc = sizeof(EfiMemoryDescriptor); + UInt32 sz_desc = 0; UInt32 rev_desc = 0; #ifdef ZBA_USE_FB @@ -176,33 +176,52 @@ EFI_EXTERN_C EFI_API Int32 Main(EfiHandlePtr image_handle, // format the disk. // ---------------------------------------------------- // - BS->GetMemoryMap(&size_struct_ptr, struct_ptr, &map_key, &sz_desc, &rev_desc); + Boot::BootTextWriter writer; + + auto ret = BS->GetMemoryMap(&size_struct_ptr, struct_ptr, &map_key, &sz_desc, &rev_desc); - struct_ptr = new EfiMemoryDescriptor[sz_desc]; + if (ret == kEfiFail) + { + writer.Write("BootZ: GetMemoryMap failed (x1)\r"); + Boot::Stop(); + } - BS->GetMemoryMap(&size_struct_ptr, struct_ptr, &map_key, &sz_desc, &rev_desc); + size_struct_ptr += sz_desc * 2; + BS->AllocatePool(EfiMemoryType::EfiBootServicesData, size_struct_ptr, reinterpret_cast<VoidPtr*>(&struct_ptr)); - auto kDefaultMemoryMap = 0; // Grab any usable entries. + ret = BS->GetMemoryMap(&size_struct_ptr, struct_ptr, &map_key, &sz_desc, &rev_desc); + + if (ret == kEfiFail) + { + writer.Write("BootZ: GetMemoryMap failed (x2)\r"); + Boot::Stop(); + } //-----------------------------------------------------------// // A simple loop which finds a usable memory region for us. //-----------------------------------------------------------// SizeT lookup_index = 0UL; + SizeT entry_count = size_struct_ptr / sz_desc; - for (; struct_ptr[lookup_index].Kind != EfiMemoryType::EfiConventionalMemory; ++lookup_index) + for (; lookup_index < entry_count; ++lookup_index) { - NE_UNUSED(0); + if (struct_ptr[lookup_index].Kind == EfiMemoryType::EfiConventionalMemory) + break; } - kDefaultMemoryMap = lookup_index; + if (lookup_index > entry_count) + { + writer.Write("BootZ: No usable entries.\r"); + Boot::Stop(); + } //-------------------------------------------------------------// // Update handover file specific table and phyiscal start field. //-------------------------------------------------------------// - handover_hdr->f_BitMapStart = (VoidPtr)struct_ptr[kDefaultMemoryMap].VirtualStart; /* Start of bitmap. */ - handover_hdr->f_BitMapSize = struct_ptr[kDefaultMemoryMap].NumberOfPages * sizeof(UIntPtr); /* Size of bitmap. */ + handover_hdr->f_BitMapStart = (VoidPtr)struct_ptr[lookup_index].VirtualStart; /* Start of bitmap. */ + handover_hdr->f_BitMapSize = struct_ptr[lookup_index].NumberOfPages * kib_cast(4); /* Size of bitmap in bytes. */ handover_hdr->f_FirmwareCustomTables[0] = (VoidPtr)BS; handover_hdr->f_FirmwareCustomTables[1] = (VoidPtr)ST; @@ -287,8 +306,6 @@ EFI_EXTERN_C EFI_API Int32 Main(EfiHandlePtr image_handle, ST->RuntimeServices->GetVariable(L"/props/kern_ver", kEfiGlobalNamespaceVarGUID, nullptr, &sz_ver, &ver); - Boot::BootTextWriter writer; - if (ver != KERNEL_VERSION_BCD) { ver = KERNEL_VERSION_BCD; diff --git a/dev/kernel/FirmwareKit/EFI/EFI.h b/dev/kernel/FirmwareKit/EFI/EFI.h index 3c3ffa09..1e6de42c 100644 --- a/dev/kernel/FirmwareKit/EFI/EFI.h +++ b/dev/kernel/FirmwareKit/EFI/EFI.h @@ -201,18 +201,10 @@ typedef enum EfiAllocateType typedef struct EfiMemoryDescriptor { - /// - /// Kind of the memory region. - /// Kind EFI_MEMORY_TYPE is defined in the - /// AllocatePages() function description. - /// + /// @brief Kind of the memory region. UInt32 Kind; - /// - /// Physical address of the first byte in the memory region. PhysicalStart - /// must be aligned on a 4 KiB boundary, and must not be above - /// 0xfffffffffffff000. Kind EFI_PHYSICAL_ADDRESS is defined in the - /// AllocatePages() function description - /// + + /// @brief Physical address of the first byte in the memory region. PhysicalStart EfiPhysicalAddress PhysicalStart; /// /// Virtual address of the first byte in the memory region. diff --git a/dev/kernel/KernelKit/DebugOutput.h b/dev/kernel/KernelKit/DebugOutput.h index cb22ac6b..448e6208 100644 --- a/dev/kernel/KernelKit/DebugOutput.h +++ b/dev/kernel/KernelKit/DebugOutput.h @@ -208,6 +208,6 @@ namespace Kernel #undef kout #endif // ifdef kout -#define kout Kernel::TerminalDevice::The() << "[NeKernel] *" << __FILE__ << "*: " +#define kout Kernel::TerminalDevice::The() #define kendl Kernel::TerminalDevice::The() << Kernel::end_line() |
