diff options
| author | Amlal El Mahrouss <amlal.elmahrouss@icloud.com> | 2024-01-30 21:49:58 +0100 |
|---|---|---|
| committer | Amlal El Mahrouss <amlal.elmahrouss@icloud.com> | 2024-01-30 21:49:58 +0100 |
| commit | df44a789fc90497325ba91be515c02145ae39142 (patch) | |
| tree | 71fca5d75367399a38c37e9adc43ac5e816a0327 /Private | |
| parent | 08eeda990be33db8048031df2a40ec28955e6430 (diff) | |
Kernel: Provide platform specific code for IOArray.
Kernel: Add PE header for Kernel AND bootloader.
Signed-off-by: Amlal El Mahrouss <amlal.elmahrouss@icloud.com>
Diffstat (limited to 'Private')
| -rw-r--r-- | Private/EFIKit/EFILib.hxx | 2 | ||||
| -rw-r--r-- | Private/FSKit/NewFS.hxx | 221 | ||||
| -rw-r--r-- | Private/HALKit/AMD64/ACPI/ACPI.hpp | 3 | ||||
| -rw-r--r-- | Private/HALKit/AMD64/ACPI/ACPIManager.hpp | 3 | ||||
| -rw-r--r-- | Private/HALKit/AMD64/CoreInterruptHandlerAMD64.cpp | 8 | ||||
| -rw-r--r-- | Private/KernelKit/Framebuffer.hpp | 6 | ||||
| -rw-r--r-- | Private/KernelKit/PCI/IO-Impl-AMD64.inl | 46 | ||||
| -rw-r--r-- | Private/KernelKit/PCI/IO.hpp | 77 | ||||
| -rw-r--r-- | Private/KernelKit/PE.hpp | 72 | ||||
| -rw-r--r-- | Private/KernelKit/PEF.hpp | 90 | ||||
| -rw-r--r-- | Private/NewKit/Utils.hpp | 2 | ||||
| -rw-r--r-- | Private/Source/String.cxx | 2 | ||||
| -rw-r--r-- | Private/Source/Utils.cxx | 2 |
13 files changed, 306 insertions, 228 deletions
diff --git a/Private/EFIKit/EFILib.hxx b/Private/EFIKit/EFILib.hxx index 6925d89c..1648547b 100644 --- a/Private/EFIKit/EFILib.hxx +++ b/Private/EFIKit/EFILib.hxx @@ -17,7 +17,7 @@ inline EfiBootServices* BS = nullptr; namespace Detail { /** -@brief Stop Execution of Bootloader. +@brief Stop Execution of program. @param SystemTable EFI System Table. */ Void Stop(EfiSystemTable* SystemTable) noexcept { diff --git a/Private/FSKit/NewFS.hxx b/Private/FSKit/NewFS.hxx index 1d32e676..d197db80 100644 --- a/Private/FSKit/NewFS.hxx +++ b/Private/FSKit/NewFS.hxx @@ -9,8 +9,8 @@ #pragma once -#include <KernelKit/DriveManager.hpp> #include <CompilerKit/CompilerKit.hpp> +#include <KernelKit/DriveManager.hpp> #include <NewKit/Defines.hpp> #define kInvalidFork -1 @@ -23,180 +23,169 @@ #define kFilesystemVersion 1 -enum -{ - kHardDrive = 0xC0, // Hard Drive - kOpticalDrive = 0x0C, // Blu-Ray/DVD - kMassStorageDevice = 0xCC, // USB - kUnknowmn = 0xFF, // unknown device or unsupported (floppy) +enum { + kHardDrive = 0xC0, // Hard Drive + kOpticalDrive = 0x0C, // Blu-Ray/DVD + kMassStorageDevice = 0xCC, // USB + kUnknowmn = 0xFF, // unknown device or unsupported (floppy) }; -struct NewBootBlock -{ - HCore::Char Ident[kIdentLen]; - - HCore::Char Kernel[kNameLen]; - HCore::Char GUI[kNameLen]; +struct NewBootBlock final { + HCore::Char Ident[kIdentLen]; + HCore::Char Shell[kNameLen]; - HCore::Int64 NumParts; - HCore::Int64 FreeSectors; - HCore::Int64 SectorCount; - HCore::Int64 SectorSz; + HCore::Int64 NumParts; + HCore::Int64 FreeSectors; + HCore::Int64 SectorCount; + HCore::Int64 SectorSz; - HCore::Int64 DiskSize; - HCore::Int32 DiskKind; + HCore::Int64 DiskSize; + HCore::Int32 DiskKind; - HCore::Lba FirstPartBlock; - HCore::Lba LastPartBlock; + HCore::Lba FirstPartBlock; + HCore::Lba LastPartBlock; - HCore::Char Pad[kPadLen]; + HCore::Char Pad[kPadLen]; }; -#define kFlagDeleted 0xF0 +#define kFlagDeleted 0xF0 #define kFlagUnallocated 0x0F -#define kFlagCatalog 0xFF +#define kFlagCatalog 0xFF #define kKindCatalog 1 #define kKindDirectory 2 #define kKindSymlink 3 -struct NewCatalog -{ - HCore::Char Name[kNameLen]; +struct NewCatalog final { + HCore::Char Name[kNameLen]; - HCore::Int32 Flags; - HCore::Int32 Kind; + HCore::Int32 Flags; + HCore::Int32 Kind; - HCore::Lba FirstFork; - HCore::Lba LastFork; + HCore::Lba FirstFork; + HCore::Lba LastFork; }; -struct NewFork -{ - HCore::Int32 Flags; - HCore::Int32 Kind; +struct NewFork { + HCore::Int32 Flags; + HCore::Int32 Kind; - HCore::Int64 ID; + HCore::Int64 ID; - HCore::Int64 ResourceId; - HCore::Int32 ResourceKind; - HCore::Int32 ResourceFlags; + HCore::Int64 ResourceId; + HCore::Int32 ResourceKind; + HCore::Int32 ResourceFlags; - HCore::Lba DataOffset; - HCore::SizeT DataSize; - - HCore::Lba NextSibling; - HCore::Lba PreviousSibling; + HCore::Lba DataOffset; + HCore::SizeT DataSize; + + HCore::Lba NextSibling; + HCore::Lba PreviousSibling; }; #define kResourceTypeDialog 10 #define kResourceTypeString 11 -#define kResourceTypeMenu 12 +#define kResourceTypeMenu 12 #define kConfigLen 64 #define kPartLen 32 -struct NewPartitionBlock -{ - HCore::Char PartitionName[kPartLen]; - HCore::Char JsonPath[kConfigLen]; +struct NewPartitionBlock final { + HCore::Char PartitionName[kPartLen]; + HCore::Char JsonPath[kConfigLen]; - HCore::Int32 Flags; - HCore::Int32 Kind; + HCore::Int32 Flags; + HCore::Int32 Kind; - HCore::Lba StartCatalog; - HCore::SizeT CatalogCount; + HCore::Lba StartCatalog; + HCore::SizeT CatalogCount; - HCore::SizeT DiskSize; + HCore::SizeT DiskSize; - HCore::SizeT FreeCatalog; - HCore::SizeT FreeSectors; + HCore::SizeT FreeCatalog; + HCore::SizeT FreeSectors; - HCore::SizeT SectorCount; - HCore::SizeT SectorSize; + HCore::SizeT SectorCount; + HCore::SizeT SectorSize; - HCore::Char Pad[kPadLen]; + HCore::Char Pad[kPadLen]; }; -#define kCatalogKindFile 1 -#define kCatalogKindDir 2 -#define kCatalogKindAlias 3 +#define kCatalogKindFile 1 +#define kCatalogKindDir 2 +#define kCatalogKindAlias 3 //! shared between network or //! other filesystems. Export forks as .zip when copying. -#define kCatalogKindShared 4 - -#define kCatalogKindResource 5 -#define kCatalogKindExecutable 6 +#define kCatalogKindShared 4 -#define kCatalogKindPage 8 +#define kCatalogKindResource 5 +#define kCatalogKindExecutable 6 -#define kCatalogKindDevice 9 -#define kCatalogKindLock 10 +#define kCatalogKindPage 8 -#define kFilesystemSeparator '/' +#define kCatalogKindDevice 9 +#define kCatalogKindLock 10 -#define kFilesystemUpDir ".." -#define kFilesystemRoot "/" +#define kFilesystemSeparator '/' -#define kFilesystemLE '\r' -#define kFilesystemEOF 0xFF11 +#define kFilesystemUpDir ".." +#define kFilesystemRoot "/" -#define kFilesystemBitWidth sizeof(UInt16) -#define kFilesystemLbaType HCore::Lba +#define kFilesystemLE '\r' +#define kFilesystemEOF 0xFF11 -namespace HCore -{ - /// - /// \name NewFSImpl - /// NewFS filesystem operations. (catalog creation, remove removal, root fork...) - /// +#define kFilesystemBitWidth sizeof(HCore::WideChar) +#define kFilesystemLbaType HCore::Lba - class NewFSImpl - { - public: - explicit NewFSImpl() = default; - virtual ~NewFSImpl() = default; +namespace HCore { +/// +/// \name NewFSImpl +/// NewFS filesystem operations. (catalog creation, remove removal, root +/// fork...) +/// - public: - HCORE_COPY_DEFAULT(NewFSImpl); +class NewFSImpl { + public: + explicit NewFSImpl() = default; + virtual ~NewFSImpl() = default; - virtual NewFork* ForkFrom(NewCatalog& catalog, const Int64& id) = 0; + public: + HCORE_COPY_DEFAULT(NewFSImpl); - virtual NewCatalog* RootCatalog(void) = 0; - virtual NewCatalog* NextCatalog(NewCatalog& cur) = 0; - virtual NewCatalog* PrevCatalog(NewCatalog& cur) = 0; + virtual NewFork* ForkFrom(NewCatalog& catalog, const Int64& id) = 0; - virtual NewCatalog* GetCatalog(const char* name) = 0; + virtual NewCatalog* RootCatalog(void) = 0; + virtual NewCatalog* NextCatalog(NewCatalog& cur) = 0; + virtual NewCatalog* PrevCatalog(NewCatalog& cur) = 0; - virtual NewCatalog* CreateCatalog(const char* name, const Int32& flags, const Int32& kind) = 0; - virtual NewCatalog* CreateCatalog(const char* name) = 0; + virtual NewCatalog* GetCatalog(const char* name) = 0; - virtual bool WriteCatalog(NewCatalog& catalog, voidPtr data) = 0; - virtual bool RemoveCatalog(NewCatalog& catalog) = 0; + virtual NewCatalog* CreateCatalog(const char* name, const Int32& flags, + const Int32& kind) = 0; + virtual NewCatalog* CreateCatalog(const char* name) = 0; - virtual bool Format(DriveTraits& drive) = 0; + virtual bool WriteCatalog(NewCatalog& catalog, voidPtr data) = 0; + virtual bool RemoveCatalog(NewCatalog& catalog) = 0; - }; - - /// - /// \name MeFilesystemHelper - /// Filesystem helper and utils. - /// + virtual bool Format(DriveTraits& drive) = 0; +}; - class MeFilesystemHelper final - { - public: - static const char* Root() { return kFilesystemRoot; } - static const char* UpDir() { return kFilesystemUpDir; } - static const char Separator() { return kFilesystemSeparator; } +/// +/// \name MeFilesystemHelper +/// Filesystem helper and utils. +/// - }; -} +class MeFilesystemHelper final { + public: + static const char* Root() { return kFilesystemRoot; } + static const char* UpDir() { return kFilesystemUpDir; } + static const char Separator() { return kFilesystemSeparator; } +}; +} // namespace HCore -#define kNewFSAddressAsLba 5 -#define kNewFSAddressAsCHS 6 +#define kNewFSAddressAsLba 5 +#define kNewFSAddressAsCHS 6 // FSControl() syscall // FSOpen, FSClose, FSWhereAt, FSSetCursor, FSNodeSize, FSWrite, FSRead syscalls - diff --git a/Private/HALKit/AMD64/ACPI/ACPI.hpp b/Private/HALKit/AMD64/ACPI/ACPI.hpp index a9e9fa79..dbc7c52f 100644 --- a/Private/HALKit/AMD64/ACPI/ACPI.hpp +++ b/Private/HALKit/AMD64/ACPI/ACPI.hpp @@ -1,7 +1,8 @@ /* * ======================================================== * - * HCore Date Added: 13/02/2023 + * HCore + * Date Added: 13/02/2023 * Copyright Mahrouss Logic, all rights reserved. * * ======================================================== diff --git a/Private/HALKit/AMD64/ACPI/ACPIManager.hpp b/Private/HALKit/AMD64/ACPI/ACPIManager.hpp index 2eafe5ed..2b447216 100644 --- a/Private/HALKit/AMD64/ACPI/ACPIManager.hpp +++ b/Private/HALKit/AMD64/ACPI/ACPIManager.hpp @@ -1,7 +1,8 @@ /* * ======================================================== * - * HCore Date Added: 20/02/2023 + * HCore + * Date Added: 20/02/2023 * Copyright Mahrouss Logic, all rights reserved. * * ======================================================== diff --git a/Private/HALKit/AMD64/CoreInterruptHandlerAMD64.cpp b/Private/HALKit/AMD64/CoreInterruptHandlerAMD64.cpp index bed77b50..e5ba8a60 100644 --- a/Private/HALKit/AMD64/CoreInterruptHandlerAMD64.cpp +++ b/Private/HALKit/AMD64/CoreInterruptHandlerAMD64.cpp @@ -22,7 +22,7 @@ extern "C" void idt_handle_system_call(HCore::UIntPtr rsp) { extern "C" void idt_handle_gpf(HCore::UIntPtr rsp) { MUST_PASS(HCore::ProcessManager::Shared().Leak().GetCurrent()); - HCore::kcout << HCore::StringBuilder::FromInt("sp{%}", rsp); + HCore::kcout << HCore::StringBuilder::FromInt("rsp{%}", rsp); HCore::kcout << "General Protection Fault, Caused by " @@ -32,7 +32,7 @@ extern "C" void idt_handle_gpf(HCore::UIntPtr rsp) { } extern "C" void idt_handle_scheduler(HCore::UIntPtr rsp) { - HCore::kcout << HCore::StringBuilder::FromInt("sp{%}", rsp); + HCore::kcout << HCore::StringBuilder::FromInt("rsp{%}", rsp); HCore::kcout << "Will be scheduled back later " @@ -45,7 +45,7 @@ extern "C" void idt_handle_scheduler(HCore::UIntPtr rsp) { } extern "C" void idt_handle_pf(HCore::UIntPtr rsp) { - HCore::kcout << HCore::StringBuilder::FromInt("sp{%}", rsp); + HCore::kcout << HCore::StringBuilder::FromInt("rsp{%}", rsp); MUST_PASS(HCore::ProcessManager::Shared().Leak().GetCurrent()); @@ -57,7 +57,7 @@ extern "C" void idt_handle_pf(HCore::UIntPtr rsp) { } extern "C" void idt_handle_math(HCore::UIntPtr rsp) { - HCore::kcout << HCore::StringBuilder::FromInt("sp{%}", rsp); + HCore::kcout << HCore::StringBuilder::FromInt("rsp{%}", rsp); MUST_PASS(HCore::ProcessManager::Shared().Leak().GetCurrent()); diff --git a/Private/KernelKit/Framebuffer.hpp b/Private/KernelKit/Framebuffer.hpp index a0a0e4c5..4266220d 100644 --- a/Private/KernelKit/Framebuffer.hpp +++ b/Private/KernelKit/Framebuffer.hpp @@ -7,8 +7,8 @@ * ======================================================== */ -#ifndef _INC_FB_HPP__ -#define _INC_FB_HPP__ +#ifndef __INC_FB_HPP__ +#define __INC_FB_HPP__ #include <NewKit/Defines.hpp> #include <NewKit/Ref.hpp> @@ -56,4 +56,4 @@ namespace HCore }; } // namespace HCore -#endif /* ifndef _INC_FB_HPP__ */ +#endif /* ifndef __INC_FB_HPP__ */ diff --git a/Private/KernelKit/PCI/IO-Impl-AMD64.inl b/Private/KernelKit/PCI/IO-Impl-AMD64.inl new file mode 100644 index 00000000..c5247d13 --- /dev/null +++ b/Private/KernelKit/PCI/IO-Impl-AMD64.inl @@ -0,0 +1,46 @@ +/* ------------------------------------------- + + Copyright Mahrouss Logic + + File: IO-Impl-AMD64.hpp + Purpose: I/O for AMD64. + + Revision History: + + 30/01/24: Added file (amlel) + +------------------------------------------- */ + +namespace HCore { +template <SizeT Sz> +template <typename T> +T IOArray<Sz>::In(SizeT index) { + switch (sizeof(T)) { + case 4: + return HAL::in32(m_Ports[index].Leak()); + case 2: + return HAL::in16(m_Ports[index].Leak()); + case 1: + return HAL::in8(m_Ports[index].Leak()); + default: + return 0xFFFF; + } +} + +template <SizeT Sz> +template <typename T> +void IOArray<Sz>::Out(SizeT index, T value) { + switch (sizeof(T)) { +#ifdef __x86_64__ + case 4: + HAL::out32(m_Ports[index].Leak(), value); + case 2: + HAL::out16(m_Ports[index].Leak(), value); + case 1: + HAL::out8(m_Ports[index].Leak(), value); +#endif + default: + break; + } +} +} // namespace HCore diff --git a/Private/KernelKit/PCI/IO.hpp b/Private/KernelKit/PCI/IO.hpp index bcc728f4..778650b6 100644 --- a/Private/KernelKit/PCI/IO.hpp +++ b/Private/KernelKit/PCI/IO.hpp @@ -9,69 +9,44 @@ #pragma once -#include <NewKit/Defines.hpp> - #include <ArchKit/Arch.hpp> #include <NewKit/Array.hpp> +#include <NewKit/Defines.hpp> #include <NewKit/Ref.hpp> -namespace HCore -{ -template<SizeT Sz> -class IOArray final -{ - public: - IOArray() = delete; +namespace HCore { +template <SizeT Sz> +class IOArray final { + public: + IOArray() = delete; - IOArray(nullPtr) = delete; + IOArray(nullPtr) = delete; - explicit IOArray(Array <UShort, Sz> &ports) : m_Ports(ports) {} - ~IOArray() {} + explicit IOArray(Array<UShort, Sz> &ports) : m_Ports(ports) {} + ~IOArray() {} - IOArray &operator=(const IOArray &) = default; + IOArray &operator=(const IOArray &) = default; - IOArray(const IOArray &) = default; + IOArray(const IOArray &) = default; - operator bool() { - return !m_Ports.Empty(); - } + operator bool() { return !m_Ports.Empty(); } - public: - template<typename T> - T In(SizeT index) { - switch (sizeof(T)) { -#ifdef __x86_64__ - case 4: - return HAL::in32(m_Ports[index].Leak()); - case 2: - return HAL::in16(m_Ports[index].Leak()); - case 1: - return HAL::in8(m_Ports[index].Leak()); -#endif - default: - return 0xFFFF; - } - } + public: + template <typename T> + T In(SizeT index); - template<typename T> - void Out(SizeT index, T value) { - switch (sizeof(T)) { -#ifdef __x86_64__ - case 4: - HAL::out32(m_Ports[index].Leak(), value); - case 2: - HAL::out16(m_Ports[index].Leak(), value); - case 1: - HAL::out8(m_Ports[index].Leak(), value); -#endif - default: - break; - } - } + template <typename T> + void Out(SizeT index, T value); - private: - Array <UShort, Sz> m_Ports; + private: + Array<UShort, Sz> m_Ports; }; using IOArray16 = IOArray<16>; -} // namespace HCore +} // namespace HCore + +#ifdef __x86_64__ +#include <KernelKit/PCI/IO-Impl-AMD64.inl> +#else +#error Please provide platform specific code for the I/O +#endif // ifdef __x86_64__ diff --git a/Private/KernelKit/PE.hpp b/Private/KernelKit/PE.hpp new file mode 100644 index 00000000..6ac8d428 --- /dev/null +++ b/Private/KernelKit/PE.hpp @@ -0,0 +1,72 @@ +/* ------------------------------------------- + + Copyright Mahrouss Logic + + File: PE.hpp + Purpose: Portable Executable for HCore. + + Revision History: + + 30/01/24: Added file (amlel) + +------------------------------------------- */ + +#ifdef __PE__ +#define __PE__ + +#include <NewKit/Defines.hpp> + +typedef HCore::UInt32 U32; +typedef HCore::UInt16 U16; +typedef HCore::UInt8 U8; + +#define kPeMagic 0x00004550 + +struct ExecHeader final { + U32 mMagic; // PE\0\0 or 0x00004550 + U16 mMachine; + U16 mNumberOfSections; + U32 mTimeDateStamp; + U32 mPointerToSymbolTable; + U32 mNumberOfSymbols; + U16 mSizeOfOptionalHeader; + U16 mCharacteristics; +}; + +#define kMagPE32 0x010b +#define kMagPE64 0x020b + +struct ExecOptionalHeader { + U16 mMagic; // 0x010b - PE32, 0x020b - PE32+ (64 bit) + U8 mMajorLinkerVersion; + U8 mMinorLinkerVersion; + U32 mSizeOfCode; + U32 mSizeOfInitializedData; + U32 mSizeOfUninitializedData; + U32 mAddressOfEntryPoint; + U32 mBaseOfCode; + U32 mBaseOfData; + U32 mImageBase; + U32 mSectionAlignment; + U32 mFileAlignment; + U16 mMajorOperatingSystemVersion; + U16 mMinorOperatingSystemVersion; + U16 mMajorImageVersion; + U16 mMinorImageVersion; + U16 mMajorSubsystemVersion; + U16 mMinorSubsystemVersion; + U32 mWin32VersionValue; + U32 mSizeOfImage; + U32 mSizeOfHeaders; + U32 mCheckSum; + U16 mSubsystem; + U16 mDllCharacteristics; + U32 mSizeOfStackReserve; + U32 mSizeOfStackCommit; + U32 mSizeOfHeapReserve; + U32 mSizeOfHeapCommit; + U32 mLoaderFlags; + U32 mNumberOfRvaAndSizes; +}; + +#endif /* ifndef __PE__ */ diff --git a/Private/KernelKit/PEF.hpp b/Private/KernelKit/PEF.hpp index f259d8ac..d6c7ec87 100644 --- a/Private/KernelKit/PEF.hpp +++ b/Private/KernelKit/PEF.hpp @@ -7,8 +7,8 @@ * ======================================================== */ -#ifndef _INC_LOADER_PEF_HPP -#define _INC_LOADER_PEF_HPP +#ifndef __PEF_HPP__ +#define __PEF_HPP__ #include <CompilerKit/CompilerKit.hpp> #include <KernelKit/Loader.hpp> @@ -24,38 +24,34 @@ // @brief Preferred Executable Format, a format designed for any computer. -namespace HCore -{ -enum -{ - kPefArchIntel86S, - kPefArchAMD64, - kPefArchRISCV, - kPefArch64x0, /* 64x000. */ - kPefArch32x0, - kPefArchInvalid = 0xFF, +namespace HCore { +enum { + kPefArchIntel86S, + kPefArchAMD64, + kPefArchRISCV, + kPefArch64x0, /* 64x000. */ + kPefArch32x0, + kPefArchInvalid = 0xFF, }; -enum -{ - kPefKindExec = 1, /* .exe */ - kPefKindSharedObject = 2, /* .lib */ - kPefKindObject = 4, /* .obj */ - kPefKindDebug = 5, /* .debug */ +enum { + kPefKindExec = 1, /* .exe */ + kPefKindSharedObject = 2, /* .lib */ + kPefKindObject = 4, /* .obj */ + kPefKindDebug = 5, /* .debug */ }; -typedef struct PEFContainer final -{ - Char Magic[kPefMagicLen]; - UInt32 Linker; - UInt32 Version; - UInt32 Kind; - UInt32 Abi; - UInt32 Cpu; - UInt32 SubCpu; /* Cpu specific information */ - UIntPtr Start; - SizeT HdrSz; /* Size of header */ - SizeT Count; /* container header count */ +typedef struct PEFContainer final { + Char Magic[kPefMagicLen]; + UInt32 Linker; + UInt32 Version; + UInt32 Kind; + UInt32 Abi; + UInt32 Cpu; + UInt32 SubCpu; /* Cpu specific information */ + UIntPtr Start; + SizeT HdrSz; /* Size of header */ + SizeT Count; /* container header count */ } __attribute__((packed)) PEFContainer; /* First PEFCommandHeader starts after PEFContainer */ @@ -63,33 +59,31 @@ typedef struct PEFContainer final /* PEF executable section and commands. */ -typedef struct PEFCommandHeader final -{ - Char Name[kPefNameLen]; /* container name */ - UInt32 Flags; /* container flags */ - UInt16 Kind; /* container kind */ - UIntPtr Offset; /* content offset */ - SizeT Size; /* content Size */ +typedef struct PEFCommandHeader final { + Char Name[kPefNameLen]; /* container name */ + UInt32 Flags; /* container flags */ + UInt16 Kind; /* container kind */ + UIntPtr Offset; /* content offset */ + SizeT Size; /* content Size */ } __attribute__((packed)) PEFCommandHeader; -enum -{ - kPefCode = 0xC, - kPefData = 0xD, - kPefZero = 0xE, - kPefLinkerID = 0x1, +enum { + kPefCode = 0xC, + kPefData = 0xD, + kPefZero = 0xE, + kPefLinkerID = 0x1, }; -} // namespace HCore +} // namespace HCore -#define kPefExt ".cm" -#define kPefDylibExt ".dlib" +#define kPefExt ".exe" +#define kPefDylibExt ".dll" #define kPefLibExt ".lib" #define kPefObjectExt ".obj" -#define kPefDebugExt ".cmdbg" +#define kPefDebugExt ".pdb" // HCore System Binary Interface. #define kPefAbi (0xDEAD2) #define kPefStart "__start" -#endif /* ifndef _INC_LOADER_PEF_HPP */ +#endif /* ifndef __PEF_HPP__ */ diff --git a/Private/NewKit/Utils.hpp b/Private/NewKit/Utils.hpp index 42d3ca70..14987126 100644 --- a/Private/NewKit/Utils.hpp +++ b/Private/NewKit/Utils.hpp @@ -22,7 +22,7 @@ namespace HCore const Char *alloc_string(const Char *text); Size string_length(const Char *str); Size string_length(const Char *str, SizeT _len); - Boolean to_str(Char *buf, Int limit, Int base); + Boolean rt_to_string(Char *buf, Int limit, Int base); Boolean is_newln(Char chr); Boolean is_space(Char chr); Int rt_to_uppercase(Int c); diff --git a/Private/Source/String.cxx b/Private/Source/String.cxx index da1e2e84..ea371f93 100644 --- a/Private/Source/String.cxx +++ b/Private/Source/String.cxx @@ -77,7 +77,7 @@ const char *StringBuilder::FromInt(const char *fmt, int i) { Char result[8]; - if (!to_str(result, sizeof(int), i)) { + if (!rt_to_string(result, sizeof(int), i)) { return ("-1"); } diff --git a/Private/Source/Utils.cxx b/Private/Source/Utils.cxx index 7c61ec96..779016dc 100644 --- a/Private/Source/Utils.cxx +++ b/Private/Source/Utils.cxx @@ -119,7 +119,7 @@ Int rt_to_lower(Int character) { return character; } -bool to_str(Char *str, Int limit, Int base) { +bool rt_to_string(Char *str, Int limit, Int base) { if (limit == 0) return false; Int copy_limit = limit; |
