diff options
| author | Amlal El Mahrouss <amlal.elmahrouss@icloud.com> | 2024-04-20 10:20:22 +0200 |
|---|---|---|
| committer | Amlal El Mahrouss <amlal.elmahrouss@icloud.com> | 2024-04-20 10:20:22 +0200 |
| commit | 7013c094668be2204b1245496236f0cf6afa07c2 (patch) | |
| tree | 2a15832577a580e51b55b758cb792d3225870157 | |
| parent | e5a591054ea0992acc3cb786d3af9f358febca6d (diff) | |
MHR-5/MHR-3: Rename PowerPC to POWER, implement NewFSParser::Format
method, documenting code.
Signed-off-by: Amlal El Mahrouss <amlal.elmahrouss@icloud.com>
| -rw-r--r-- | Private/ArchKit/ArchKit.hpp | 2 | ||||
| -rw-r--r-- | Private/Documentation/Spec.md | 2 | ||||
| -rw-r--r-- | Private/Drivers/SampleDriver/makefile | 2 | ||||
| -rw-r--r-- | Private/FSKit/NewFS.hxx | 9 | ||||
| -rw-r--r-- | Private/FirmwareKit/EPM.hxx | 2 | ||||
| -rw-r--r-- | Private/HALKit/64x0/HalVirtualMemory.cxx | 6 | ||||
| -rw-r--r-- | Private/HALKit/AMD64/HalKernelMain.cxx | 4 | ||||
| -rw-r--r-- | Private/HALKit/POWER/.gitkeep (renamed from Private/HALKit/PowerPC/.gitkeep) | 0 | ||||
| -rw-r--r-- | Private/HALKit/POWER/APM/.gitkeep (renamed from Private/HALKit/PowerPC/APM/.gitkeep) | 0 | ||||
| -rw-r--r-- | Private/HALKit/POWER/HalContextSwitchPowerPC.s | 28 | ||||
| -rw-r--r-- | Private/HALKit/POWER/HalHardware.cxx (renamed from Private/HALKit/PowerPC/HalHardware.cxx) | 2 | ||||
| -rw-r--r-- | Private/HALKit/POWER/HalHart.cxx (renamed from Private/HALKit/PowerPC/HalHart.cxx) | 4 | ||||
| -rw-r--r-- | Private/HALKit/POWER/HalSerialPort.cxx (renamed from Private/HALKit/PowerPC/HalSerialPort.cxx) | 6 | ||||
| -rw-r--r-- | Private/HALKit/POWER/HalStartSequence.s (renamed from Private/HALKit/PowerPC/HalStartSequence.s) | 0 | ||||
| -rw-r--r-- | Private/HALKit/POWER/HalThread.cxx (renamed from Private/HALKit/PowerPC/HalThread.cxx) | 2 | ||||
| -rw-r--r-- | Private/HALKit/POWER/HalVirtualMemory.cxx (renamed from Private/HALKit/PowerPC/HalVirtualMemory.cxx) | 6 | ||||
| -rw-r--r-- | Private/HALKit/POWER/Hart.hxx (renamed from Private/HALKit/PowerPC/Hart.hxx) | 2 | ||||
| -rw-r--r-- | Private/HALKit/POWER/MBCI/.gitkeep (renamed from Private/HALKit/PowerPC/MBCI/.gitkeep) | 0 | ||||
| -rw-r--r-- | Private/HALKit/POWER/MBCI/HalMBCIHost.cxx (renamed from Private/HALKit/PowerPC/MBCI/HalMBCIHost.cxx) | 2 | ||||
| -rw-r--r-- | Private/HALKit/POWER/Processor.hpp (renamed from Private/HALKit/PowerPC/Processor.hpp) | 2 | ||||
| -rw-r--r-- | Private/HALKit/POWER/ppc-cpu.h (renamed from Private/HALKit/PowerPC/ppc-cpu.h) | 8 | ||||
| -rw-r--r-- | Private/HALKit/POWER/ppc-mmu.h (renamed from Private/HALKit/PowerPC/ppc-mmu.h) | 11 | ||||
| -rw-r--r-- | Private/HALKit/PowerPC/HalCoreContextSwitchPowerPC.s | 30 | ||||
| -rw-r--r-- | Private/KernelKit/DriveManager.hxx | 8 | ||||
| -rw-r--r-- | Private/KernelKit/PEFCodeManager.hxx | 2 | ||||
| -rw-r--r-- | Private/KernelKit/SMPManager.hpp | 2 | ||||
| -rw-r--r-- | Private/KernelKit/XCOFF.hxx | 6 | ||||
| -rw-r--r-- | Private/NewBoot/Source/makefile | 2 | ||||
| -rw-r--r-- | Private/Source/AppMain.cxx (renamed from Private/Source/RuntimeMain.cxx) | 6 | ||||
| -rw-r--r-- | Private/Source/FS/NewFS.cxx | 123 | ||||
| -rw-r--r-- | Private/Source/PEFCodeManager.cxx | 15 | ||||
| -rw-r--r-- | Private/makefile | 6 |
32 files changed, 176 insertions, 124 deletions
diff --git a/Private/ArchKit/ArchKit.hpp b/Private/ArchKit/ArchKit.hpp index ddccbb47..49c9dc94 100644 --- a/Private/ArchKit/ArchKit.hpp +++ b/Private/ArchKit/ArchKit.hpp @@ -15,7 +15,7 @@ #include <HALKit/AMD64/Hypervisor.hpp> #include <HALKit/AMD64/Processor.hpp> #elif defined(__NEWOS_PPC__) -#include <HALKit/PowerPC/Processor.hpp> +#include <HALKit/POWER/Processor.hpp> #else #error Unknown architecture #endif diff --git a/Private/Documentation/Spec.md b/Private/Documentation/Spec.md index 69f6d87f..e218947e 100644 --- a/Private/Documentation/Spec.md +++ b/Private/Documentation/Spec.md @@ -6,7 +6,7 @@ - ABI and Format: PEF/PE32+. - Kernel architecture: Portable hybrid kernel. -- Language: C++/(Assembly (AMD64, X64000, X86S, ARM64, PowerPC, RISCV)) +- Language: C++/(Assembly (AMD64, X64000, X86S, ARM64, POWER, RISCV)) =================================== diff --git a/Private/Drivers/SampleDriver/makefile b/Private/Drivers/SampleDriver/makefile index 899b1491..19e88f8f 100644 --- a/Private/Drivers/SampleDriver/makefile +++ b/Private/Drivers/SampleDriver/makefile @@ -1,5 +1,5 @@ ################################################## -# (C) Mahrouss Logic, all rights reserved. +# (C) Mahrouss Logic, all rights reserved. # This is the sample driver makefile. ################################################## diff --git a/Private/FSKit/NewFS.hxx b/Private/FSKit/NewFS.hxx index 3f93700f..339b9832 100644 --- a/Private/FSKit/NewFS.hxx +++ b/Private/FSKit/NewFS.hxx @@ -30,7 +30,11 @@ default. #define kNewFSInvalidCatalog -1 #define kNewFSNodeNameLen 256 -#define kNewFSMinimumSectorSz 4096 +#ifdef __x86_64__ +#define kNewFSMinimumSectorSz (512) +#else +#define kNewFSMinimumSectorSz (1024) +#endif // ifdef __x86_64__ #define kNewFSIdentLen 8 #define kNewFSIdent " NewFS" @@ -105,6 +109,7 @@ enum { /// @brief Ccatalog type. struct PACKED NewCatalog final { NewCharType Name[kNewFSNodeNameLen]; + NewCharType Mime[kNewFSNodeNameLen]; NewOS::Int32 Flags; NewOS::Int32 Kind; @@ -173,7 +178,7 @@ enum { /// forks...) Designed like the DOM, detects the filesystem automatically. /// -class NewFSParser final { +class NewFSParser { public: explicit NewFSParser() = default; ~NewFSParser() = default; diff --git a/Private/FirmwareKit/EPM.hxx b/Private/FirmwareKit/EPM.hxx index 5cc743be..b7f77742 100644 --- a/Private/FirmwareKit/EPM.hxx +++ b/Private/FirmwareKit/EPM.hxx @@ -71,7 +71,7 @@ struct PACKED PartitionBlock { #define kEPMMagic32k "EPM32" -/* @brief PowerPC magic for EPM */ +/* @brief POWER magic for EPM */ #define kEPMMagicPPC "EPMPC" diff --git a/Private/HALKit/64x0/HalVirtualMemory.cxx b/Private/HALKit/64x0/HalVirtualMemory.cxx index 8fc08df0..2ae0f7ac 100644 --- a/Private/HALKit/64x0/HalVirtualMemory.cxx +++ b/Private/HALKit/64x0/HalVirtualMemory.cxx @@ -4,11 +4,11 @@ ------------------------------------------- */ -#include <HALKit/PowerPC/Processor.hpp> +#include <HALKit/POWER/Processor.hpp> #include <KernelKit/DebugOutput.hpp> using namespace NewOS; -/// @brief Flush system TLB, looks like the PowerPC version, as it acts the same, no specific instruction for that. +/// @brief Flush system TLB, looks like the POWER version, as it acts the same, no specific instruction for that. /// @note The 88K MMU should be present in the die. -EXTERN_C void hal_flush_tlb() { asm volatile("isync;invltlb;msync;isync"); } +EXTERN_C void hal_flush_tlb() { asm volatile("invltlb"); } diff --git a/Private/HALKit/AMD64/HalKernelMain.cxx b/Private/HALKit/AMD64/HalKernelMain.cxx index f6b8e957..7d8c516d 100644 --- a/Private/HALKit/AMD64/HalKernelMain.cxx +++ b/Private/HALKit/AMD64/HalKernelMain.cxx @@ -17,7 +17,7 @@ #include <NewKit/Json.hpp> EXTERN_C NewOS::VoidPtr kInterruptVectorTable[]; -EXTERN_C void RuntimeMain(); +EXTERN_C void AppMain(); namespace NewOS::HAL { /// @brief Gets the system cores using the MADT. @@ -83,7 +83,7 @@ EXTERN_C void hal_init_platform( ToolboxClearRsrc(); - RuntimeMain(); + AppMain(); NewOS::ke_stop(RUNTIME_CHECK_BOOTSTRAP); } diff --git a/Private/HALKit/PowerPC/.gitkeep b/Private/HALKit/POWER/.gitkeep index e69de29b..e69de29b 100644 --- a/Private/HALKit/PowerPC/.gitkeep +++ b/Private/HALKit/POWER/.gitkeep diff --git a/Private/HALKit/PowerPC/APM/.gitkeep b/Private/HALKit/POWER/APM/.gitkeep index e69de29b..e69de29b 100644 --- a/Private/HALKit/PowerPC/APM/.gitkeep +++ b/Private/HALKit/POWER/APM/.gitkeep diff --git a/Private/HALKit/POWER/HalContextSwitchPowerPC.s b/Private/HALKit/POWER/HalContextSwitchPowerPC.s new file mode 100644 index 00000000..75c9f37a --- /dev/null +++ b/Private/HALKit/POWER/HalContextSwitchPowerPC.s @@ -0,0 +1,28 @@ +/* ------------------------------------------- + + Copyright Mahrouss Logic + +------------------------------------------- */ + +.align 4 +.type name, @function +.text +.globl rt_do_context_switch + +/* r3 (3) = assigner stack, r4 (4) = assignee stack */ +rt_do_context_switch: + lwz 0(%4), 0(%3) + lwz 4(%4), 4(%3) + lwz 8(%4), 8(%3) + lwz 12(%4), 12(%3) + lwz 14(%4), 14(%3) + lwz 18(%4), 18(%3) + lwz 22(%4), 22(%3) + lwz 24(%4), 24(%3) + lwz 28(%4), 28(%3) + lwz 32(%4), 32(%3) + lwz 34(%4), 34(%3) + lwz 38(%4), 38(%3) + + /* we are done here, the assignee should start executing code now. */ + blr diff --git a/Private/HALKit/PowerPC/HalHardware.cxx b/Private/HALKit/POWER/HalHardware.cxx index 5d09805d..693bf70e 100644 --- a/Private/HALKit/PowerPC/HalHardware.cxx +++ b/Private/HALKit/POWER/HalHardware.cxx @@ -4,7 +4,7 @@ ------------------------------------------- */ -#include <HALKit/PowerPC/Processor.hpp> +#include <HALKit/POWER/Processor.hpp> #include <KernelKit/DebugOutput.hpp> namespace NewOS { diff --git a/Private/HALKit/PowerPC/HalHart.cxx b/Private/HALKit/POWER/HalHart.cxx index 102bab7d..75eeb3f7 100644 --- a/Private/HALKit/PowerPC/HalHart.cxx +++ b/Private/HALKit/POWER/HalHart.cxx @@ -4,9 +4,9 @@ ------------------------------------------- */ -#include <HALKit/PowerPC/Processor.hpp> +#include <HALKit/POWER/Processor.hpp> #include <KernelKit/DebugOutput.hpp> -#include <HALKit/PowerPC/Hart.hxx> +#include <HALKit/POWER/Hart.hxx> using namespace NewOS; diff --git a/Private/HALKit/PowerPC/HalSerialPort.cxx b/Private/HALKit/POWER/HalSerialPort.cxx index 36878b61..cf943371 100644 --- a/Private/HALKit/PowerPC/HalSerialPort.cxx +++ b/Private/HALKit/POWER/HalSerialPort.cxx @@ -4,13 +4,13 @@ ------------------------------------------- */ -#include <HALKit/PowerPC/Processor.hpp> +#include <HALKit/POWER/Processor.hpp> #include <KernelKit/DebugOutput.hpp> using namespace NewOS; /// @brief Writes to COM1. -/// @param bytes +/// @param bytes void ke_io_write(const Char* bytes) { if (!bytes) return; @@ -21,4 +21,4 @@ void ke_io_write(const Char* bytes) { // TODO ++index; } -}
\ No newline at end of file +} diff --git a/Private/HALKit/PowerPC/HalStartSequence.s b/Private/HALKit/POWER/HalStartSequence.s index f50a4d4f..f50a4d4f 100644 --- a/Private/HALKit/PowerPC/HalStartSequence.s +++ b/Private/HALKit/POWER/HalStartSequence.s diff --git a/Private/HALKit/PowerPC/HalThread.cxx b/Private/HALKit/POWER/HalThread.cxx index a91e7f28..c79b4fb7 100644 --- a/Private/HALKit/PowerPC/HalThread.cxx +++ b/Private/HALKit/POWER/HalThread.cxx @@ -4,7 +4,7 @@ ------------------------------------------- */ -#include <HALKit/PowerPC/Processor.hpp> +#include <HALKit/POWER/Processor.hpp> #include <KernelKit/DebugOutput.hpp> extern "C" NewOS::HAL::StackFramePtr rt_get_current_context() { return nullptr; } diff --git a/Private/HALKit/PowerPC/HalVirtualMemory.cxx b/Private/HALKit/POWER/HalVirtualMemory.cxx index 301bda0c..43c59384 100644 --- a/Private/HALKit/PowerPC/HalVirtualMemory.cxx +++ b/Private/HALKit/POWER/HalVirtualMemory.cxx @@ -4,10 +4,10 @@ ------------------------------------------- */ -#include <HALKit/PowerPC/ppc-cpu.h> -#include <HALKit/PowerPC/ppc-mmu.h> +#include <HALKit/POWER/ppc-cpu.h> +#include <HALKit/POWER/ppc-mmu.h> -#include <HALKit/PowerPC/Processor.hpp> +#include <HALKit/POWER/Processor.hpp> #include <KernelKit/DebugOutput.hpp> /// NOTE: refer to: https://www.nxp.com/docs/en/white-paper/POWRPCARCPRMRM.pdf, diff --git a/Private/HALKit/PowerPC/Hart.hxx b/Private/HALKit/POWER/Hart.hxx index 56d51243..2a908fcf 100644 --- a/Private/HALKit/PowerPC/Hart.hxx +++ b/Private/HALKit/POWER/Hart.hxx @@ -3,7 +3,7 @@ Copyright Mahrouss Logic File: Hart.hxx - Purpose: PowerPC hardware threads. + Purpose: POWER hardware threads. Revision History: diff --git a/Private/HALKit/PowerPC/MBCI/.gitkeep b/Private/HALKit/POWER/MBCI/.gitkeep index e69de29b..e69de29b 100644 --- a/Private/HALKit/PowerPC/MBCI/.gitkeep +++ b/Private/HALKit/POWER/MBCI/.gitkeep diff --git a/Private/HALKit/PowerPC/MBCI/HalMBCIHost.cxx b/Private/HALKit/POWER/MBCI/HalMBCIHost.cxx index 98371c43..8ad039fe 100644 --- a/Private/HALKit/PowerPC/MBCI/HalMBCIHost.cxx +++ b/Private/HALKit/POWER/MBCI/HalMBCIHost.cxx @@ -4,5 +4,5 @@ ------------------------------------------- */ -#include <HALKit/PowerPC/Processor.hpp> +#include <HALKit/POWER/Processor.hpp> #include <KernelKit/DebugOutput.hpp> diff --git a/Private/HALKit/PowerPC/Processor.hpp b/Private/HALKit/POWER/Processor.hpp index 12a5bd26..a597b202 100644 --- a/Private/HALKit/PowerPC/Processor.hpp +++ b/Private/HALKit/POWER/Processor.hpp @@ -2,7 +2,7 @@ Copyright Mahrouss Logic - Purpose: PowerPC processor header. + Purpose: POWER processor header. ------------------------------------------- */ diff --git a/Private/HALKit/PowerPC/ppc-cpu.h b/Private/HALKit/POWER/ppc-cpu.h index 4bc6e9f0..74003329 100644 --- a/Private/HALKit/PowerPC/ppc-cpu.h +++ b/Private/HALKit/POWER/ppc-cpu.h @@ -17,7 +17,7 @@ struct pt_regs { unsigned long nip; }; -#else +#else #include <asm/ptrace.h> #include <asm/types.h> #endif @@ -880,8 +880,8 @@ struct pt_regs { #define PVR_REV(pvr) (((pvr) >> 0) & 0xFFFF) /* Revison field */ /* - * AMCC has further subdivided the standard PowerPC 16-bit version and - * revision subfields of the PVR for the PowerPC 403s into the following: + * AMCC has further subdivided the standard ppc 16-bit version and + * revision subfields of the PVR for the ppc 403s into the following: */ #define PVR_FAM(pvr) (((pvr) >> 20) & 0xFFF) /* Family field */ @@ -990,7 +990,7 @@ struct pt_regs { /* * For the 8xx processors, all of them report the same PVR family for - * the PowerPC core. The various versions of these processors must be + * the ppc core. The various versions of these processors must be * differentiated by the version number in the Communication Processor * Module (CPM). */ diff --git a/Private/HALKit/PowerPC/ppc-mmu.h b/Private/HALKit/POWER/ppc-mmu.h index 372935aa..5a149243 100644 --- a/Private/HALKit/PowerPC/ppc-mmu.h +++ b/Private/HALKit/POWER/ppc-mmu.h @@ -1,6 +1,3 @@ -/* - * PowerPC memory management structures - */ #ifndef _PPC_MMU_H_ #define _PPC_MMU_H_ @@ -252,7 +249,7 @@ extern void print_bats(void); #define MI_IDXMASK 0x00001f00 /* TLB index to be loaded */ #define MI_RESETVAL 0x00000000 /* Value of register at reset */ -/* These are the Ks and Kp from the PowerPC books. For proper operation, +/* These are the Ks and Kp from the ppc books. For proper operation, * Ks = 0, Kp = 1. */ #define MI_AP 786 @@ -311,7 +308,7 @@ extern void print_bats(void); #define MC_ASIDMASK 0x0000000f /* Bits used for ASID value */ -/* These are the Ks and Kp from the PowerPC books. For proper operation, +/* These are the Ks and Kp from the ppc books. For proper operation, * Ks = 0, Kp = 1. */ #define MD_AP 794 @@ -368,7 +365,7 @@ extern void print_bats(void); #define M_TW 799 /* - * At present, all PowerPC 400-class processors share a similar TLB + * At present, all ppc 400-class processors share a similar TLB * architecture. The instruction and data sides share a unified, * 64-entry, fully-associative TLB which is maintained totally under * software control. In addition, the instruction side has a @@ -797,4 +794,4 @@ void change_tlb(uint32_t vaddr, uint32_t size, uint32_t tlb_word2_i_value); #endif /* __ASSEMBLY__ */ #endif /* CONFIG_440 */ -#endif /* _PPC_MMU_H_ */
\ No newline at end of file +#endif /* _PPC_MMU_H_ */ diff --git a/Private/HALKit/PowerPC/HalCoreContextSwitchPowerPC.s b/Private/HALKit/PowerPC/HalCoreContextSwitchPowerPC.s deleted file mode 100644 index 0bf6418d..00000000 --- a/Private/HALKit/PowerPC/HalCoreContextSwitchPowerPC.s +++ /dev/null @@ -1,30 +0,0 @@ -/* ------------------------------------------- - - Copyright Mahrouss Logic - -------------------------------------------- */ - -.align 4 -.type name, @function -.text -.globl rt_do_context_switch - -/* r3 = assigner stack, r4 = assignee stack */ -rt_do_context_switch: - - lwz 0(%r4), 0(%r3) - lwz 4(%r4), 4(%r3) - lwz 8(%r4), 8(%r3) - lwz 12(%r4), 12(%r3) - lwz 14(%r4), 14(%r3) - lwz 18(%r4), 18(%r3) - lwz 22(%r4), 22(%r3) - lwz 24(%r4), 24(%r3) - lwz 28(%r4), 28(%r3) - lwz 32(%r4), 32(%r3) - lwz 34(%r4), 34(%r3) - lwz 38(%r4), 38(%r3) - - mr %r31, %r4 - - bl diff --git a/Private/KernelKit/DriveManager.hxx b/Private/KernelKit/DriveManager.hxx index e66dedc8..e8028ddd 100644 --- a/Private/KernelKit/DriveManager.hxx +++ b/Private/KernelKit/DriveManager.hxx @@ -106,13 +106,13 @@ class MountpointInterface final { }; /// @brief Unimplemented drive. -/// @param pckt -/// @return +/// @param pckt +/// @return Void ke_drv_unimplemented(DriveTrait::DrivePacket* pckt); /// @brief Gets the drive kind (ATA, SCSI, AHCI...) -/// @param -/// @return +/// @param +/// @return const Char* ke_drive_kind(Void); /// @brief Makes a new drive. diff --git a/Private/KernelKit/PEFCodeManager.hxx b/Private/KernelKit/PEFCodeManager.hxx index d9e857de..1f5269ae 100644 --- a/Private/KernelKit/PEFCodeManager.hxx +++ b/Private/KernelKit/PEFCodeManager.hxx @@ -24,7 +24,7 @@ class PEFLoader : public LoaderInterface { public: explicit PEFLoader(const VoidPtr blob); - explicit PEFLoader(const char *path); + explicit PEFLoader(const Char* path); ~PEFLoader() override; public: diff --git a/Private/KernelKit/SMPManager.hpp b/Private/KernelKit/SMPManager.hpp index 631b29ea..17ea9d38 100644 --- a/Private/KernelKit/SMPManager.hpp +++ b/Private/KernelKit/SMPManager.hpp @@ -31,7 +31,7 @@ enum ThreadKind { /// /// \name HardwareThread -/// @brief CPU Hardware Thread (PowerPC, Intel, or NewCPU) +/// @brief CPU Hardware Thread (POWER, x64, or 64x0) /// class HardwareThread final { diff --git a/Private/KernelKit/XCOFF.hxx b/Private/KernelKit/XCOFF.hxx index 35ca9896..631efdf3 100644 --- a/Private/KernelKit/XCOFF.hxx +++ b/Private/KernelKit/XCOFF.hxx @@ -16,14 +16,14 @@ #include <NewKit/Defines.hpp> -#define kXCOFF64Magic 0x01F7 +#define kXCOFF64Magic 0x01F7 #define kXCOFFRelFlg 0x0001 #define kXCOFFExecutable 0x0002 #define kXCOFFLnno 0x0004 #define kXCOFFLSyms 0x0008 -/// @brief XCoff file header, meant for PowerPC programs. +/// @brief XCoff file header, meant for POWER apps. typedef struct XCoffFileHeader { NewOS::UInt16 fMagic; @@ -35,4 +35,4 @@ typedef struct XCoffFileHeader NewOS::UInt16 fOptHdr; // ?: Number of bytes in optional header } XCoffFileHeader; -#endif // ifndef __XCOFF__
\ No newline at end of file +#endif // ifndef __XCOFF__ diff --git a/Private/NewBoot/Source/makefile b/Private/NewBoot/Source/makefile index 24f46fd6..03bb9248 100644 --- a/Private/NewBoot/Source/makefile +++ b/Private/NewBoot/Source/makefile @@ -1,5 +1,5 @@ ################################################## -# (C) Mahrouss Logic, all rights reserved. +# (C) Mahrouss Logic, all rights reserved. # This is the bootloader makefile. ################################################## diff --git a/Private/Source/RuntimeMain.cxx b/Private/Source/AppMain.cxx index 5bbee3b2..ba5d822f 100644 --- a/Private/Source/RuntimeMain.cxx +++ b/Private/Source/AppMain.cxx @@ -18,15 +18,15 @@ /// @file Main microkernel entrypoint. -EXTERN_C void RuntimeMain(void) { +EXTERN_C NewOS::Void AppMain(NewOS::Void) { ///! Mounts a NewFS block. NewOS::NewFilesystemManager* newFS = new NewOS::NewFilesystemManager(); NewOS::ke_protect_ke_heap(newFS); NewOS::FilesystemManagerInterface::Mount(newFS); - + while (NewOS::ProcessScheduler::Shared().Leak().Run() > 0); ///! we're done, unmount. delete newFS; -}
\ No newline at end of file +} diff --git a/Private/Source/FS/NewFS.cxx b/Private/Source/FS/NewFS.cxx index 1d7d3621..216db7c6 100644 --- a/Private/Source/FS/NewFS.cxx +++ b/Private/Source/FS/NewFS.cxx @@ -161,7 +161,53 @@ bool NewFSParser::Format(_Input _Output DriveTrait* drive) { return false; } - return true; + Char sectorBuf[kNewFSMinimumSectorSz] = {0}; + + drive->fPacket.fPacketContent = sectorBuf; + drive->fPacket.fPacketSize = kNewFSMinimumSectorSz; + drive->fPacket.fLba = kNewFSAddressAsLba; + + drive->fInput(&drive->fPacket); + + /// disk isnt faulty and data has been fetched. + if (drive->fPacket.fPacketGood) { + NewPartitionBlock* partBlock = (NewPartitionBlock*)sectorBuf; + if (partBlock->PartitionName[0] == 0 && + rt_string_cmp(partBlock->Ident, kNewFSIdent, kNewFSIdentLen) == 0) { + /// partition is free and valid. + + rt_copy_memory((VoidPtr)kNewFSIdent, (VoidPtr)partBlock->Ident, + kNewFSIdentLen); + rt_copy_memory((VoidPtr) "New OS\0", (VoidPtr)partBlock->PartitionName, + rt_string_len("New OS\0")); + + SizeT catalogCount = 0; + SizeT sectorCount = 0; + SizeT diskSize = 0; + + partBlock->Kind = kNewFSPartitionTypeStandard; + partBlock->StartCatalog = sizeof(NewPartitionBlock) + kNewFSAddressAsLba; + partBlock->CatalogCount = catalogCount; + partBlock->SectorCount = sectorCount; + partBlock->DiskSize = diskSize; + partBlock->FreeCatalog = partBlock->StartCatalog; + + drive->fPacket.fPacketContent = sectorBuf; + drive->fPacket.fPacketSize = kNewFSMinimumSectorSz; + drive->fPacket.fLba = kNewFSAddressAsLba; + + drive->fOutput(&drive->fPacket); + + return true; + } + + kcout << "New OS: Partition already exists.\r\n"; + + /// return success as well, do not ignore that partition. + return true; + } + + return false; } /// @brief @@ -173,73 +219,80 @@ bool NewFSParser::WriteCatalog(_Input _Output NewCatalog* catalog, return false; } -/// @brief -/// @param catalogName -/// @return +/// @brief +/// @param catalogName +/// @return _Output NewCatalog* NewFSParser::FindCatalog(_Input const char* catalogName) { return nullptr; } -/// @brief -/// @param name -/// @return +/// @brief +/// @param name +/// @return _Output NewCatalog* NewFSParser::GetCatalog(_Input const char* name) { return nullptr; } -/// @brief -/// @param catalog -/// @return +/// @brief +/// @param catalog +/// @return Boolean NewFSParser::CloseCatalog(_Input _Output NewCatalog* catalog) { - return false; + return true; } -/// @brief -/// @param catalog -/// @return +/// @brief Mark catalog as removed. +/// @param catalog The catalog structure. +/// @return Boolean NewFSParser::RemoveCatalog(_Input _Output NewCatalog* catalog) { + catalog->Flags |= kNewFSFlagDeleted; + this->WriteCatalog(catalog, nullptr); + return false; } -/// @brief -/// @param catalog -/// @param dataSz -/// @return +/// ***************************************************************** /// +/// Reading,Seek,Tell are unimplemented on catalogs, refer to forks I/O instead. +/// ***************************************************************** /// + +/// @brief +/// @param catalog +/// @param dataSz +/// @return VoidPtr NewFSParser::ReadCatalog(_Input _Output NewCatalog* catalog, SizeT dataSz) { return nullptr; } -/// @brief -/// @param catalog -/// @param off -/// @return +/// @brief +/// @param catalog +/// @param off +/// @return bool NewFSParser::Seek(_Input _Output NewCatalog* catalog, SizeT off) { return false; } -/// @brief -/// @param catalog -/// @return +/// @brief +/// @param catalog +/// @return SizeT NewFSParser::Tell(_Input _Output NewCatalog* catalog) { return 0; } -/// @brief -/// @param sz -/// @return +/// @brief +/// @param sz +/// @return STATIC Lba ke_find_free_fork(SizeT sz) { return 0; } -/// @brief -/// @param sz -/// @return +/// @brief +/// @param sz +/// @return STATIC Lba ke_find_free_catalog(SizeT sz) { return 0; } -/// @brief -/// @param sz -/// @return +/// @brief +/// @param sz +/// @return STATIC Lba ke_find_free_data(SizeT sz) { return 0; } namespace NewOS::Detail { Boolean fs_init_newfs(Void) noexcept { return false; } } // namespace NewOS::Detail -#endif // ifdef __FSKIT_NEWFS__
\ No newline at end of file +#endif // ifdef __FSKIT_NEWFS__ diff --git a/Private/Source/PEFCodeManager.cxx b/Private/Source/PEFCodeManager.cxx index f8616a8c..2f60f085 100644 --- a/Private/Source/PEFCodeManager.cxx +++ b/Private/Source/PEFCodeManager.cxx @@ -17,6 +17,7 @@ namespace NewOS { namespace Detail { +/// @brief Get the PEF platform signature according to the compiled backebnd UInt32 rt_get_pef_platform(void) noexcept { #ifdef __32x0__ return kPefArch32x0; @@ -33,7 +34,7 @@ UInt32 rt_get_pef_platform(void) noexcept { } // namespace Detail /// @brief PEF loader constructor w/ blob. -/// @param blob +/// @param blob PEFLoader::PEFLoader(const VoidPtr blob) : fCachedBlob(nullptr) { fCachedBlob = blob; fBad = false; @@ -42,11 +43,11 @@ PEFLoader::PEFLoader(const VoidPtr blob) : fCachedBlob(nullptr) { } /// @brief PEF loader constructor. -/// @param path -PEFLoader::PEFLoader(const char *path) : fCachedBlob(nullptr), fBad(false) { - OwnPtr<FileStream<char>> file; +/// @param path the filesystem path. +PEFLoader::PEFLoader(const Char* path) : fCachedBlob(nullptr), fBad(false) { + OwnPtr<FileStream<Char>> file; - file.New(const_cast<Char *>(path), kRestrictRB); + file.New(const_cast<Char*>(path), kRestrictRB); if (StringBuilder::Equals(file->MIME(), this->MIME())) { fPath = StringBuilder::Construct(path).Leak(); @@ -131,7 +132,7 @@ VoidPtr PEFLoader::FindSymbol(const char *name, Int32 kind) { } /// @brief Finds the executable entrypoint. -/// @return +/// @return ErrorOr<VoidPtr> PEFLoader::FindStart() { if (auto sym = this->FindSymbol(kPefStart, kPefCode); sym) return ErrorOr<VoidPtr>(sym); @@ -140,7 +141,7 @@ ErrorOr<VoidPtr> PEFLoader::FindStart() { } /// @brief Tells if the executable is loaded or not. -/// @return +/// @return bool PEFLoader::IsLoaded() noexcept { return !fBad && fCachedBlob; } #define kPefAppnameCommandHdr "PefAppName" diff --git a/Private/makefile b/Private/makefile index ffefecf2..b166990e 100644 --- a/Private/makefile +++ b/Private/makefile @@ -1,5 +1,5 @@ ################################################## -# (C) Mahrouss Logic, all rights reserved. +# (C) Mahrouss Logic, all rights reserved. # This is the microkernel makefile. ################################################## @@ -24,13 +24,12 @@ ifneq ($(DEBUG_SUPPORT), ) DEBUG = -D__DEBUG__ endif -SLEEP = sleep 1 COPY = cp # Add assembler, linker, and object files variables. ASMFLAGS = -f win64 LDFLAGS = -e Main --subsystem=17 -LDOBJ = $(wildcard Objects/*.obj) +LDOBJ = Objects/*.obj # This file is the kernel, responsible of task management, memory, drivers and more. KERNEL = NewKernel.exe @@ -53,7 +52,6 @@ newos-amd64-epm: clean $(ASM) $(ASMFLAGS) HALKit/AMD64/HalSMPCoreManager.asm $(ASM) $(ASMFLAGS) HALKit/AMD64/HalNewBoot.asm $(ASM) $(ASMFLAGS) HALKit/AMD64/HalInstallTIB.asm - $(SLEEP) $(MOVEALL) OBJCOPY=x86_64-w64-mingw32-objcopy |
