diff options
| -rw-r--r-- | CODEOWNERS | 2 | ||||
| -rw-r--r-- | README.md | 9 | ||||
| -rw-r--r-- | dev/boot/amd64-desktop.make | 2 | ||||
| -rw-r--r-- | dev/boot/src/BootThread.cc | 18 | ||||
| -rw-r--r-- | dev/kernel/HALKit/AMD64/HalPagingMgrAMD64.cc | 2 | ||||
| -rw-r--r-- | dev/kernel/HALKit/AMD64/Storage/AHCI+Generic.cc | 12 | ||||
| -rw-r--r-- | dev/kernel/HALKit/AMD64/Storage/DMA+Generic.cc | 10 | ||||
| -rw-r--r-- | dev/kernel/HALKit/AMD64/Storage/PIO+Generic.cc | 24 | ||||
| -rw-r--r-- | meta/png/nekernel.png | bin | 0 -> 184830 bytes | |||
| -rw-r--r-- | public/frameworks/KernelTest.fwrk/headers/KernelTest.h | 3 | ||||
| -rwxr-xr-x | setup_x64.sh (renamed from setup_amd64.sh) | 0 |
11 files changed, 45 insertions, 37 deletions
@@ -1,4 +1,4 @@ -# boot, libsci, and kernel are owned by amlal@nekernel.org.
+# boot, user, and kernel are owned by amlal@nekernel.org.
/dev/kernel/ @amlel-el-mahrouss
/dev/boot/ @amlel-el-mahrouss
/dev/user/ @amlel-el-mahrouss
@@ -1,6 +1,9 @@ <!-- Read Me of NeKernel --> -# NeKernel +<div align="center"> + <img src="meta/png/nekernel.png" alt="Logo" width="128"/> + <h1>NeKernel</h1> +</div>   @@ -13,7 +16,9 @@ A kernel for engineers who want a custom solution for their stack, written mostl ## User Friendly Diagram: - +<div align="center"> + <img src="docs/svg/OS_DESIGN.png" alt="Diagram"/> +</div> ## Notice for Doxygen: diff --git a/dev/boot/amd64-desktop.make b/dev/boot/amd64-desktop.make index b0f81a39..6e796752 100644 --- a/dev/boot/amd64-desktop.make +++ b/dev/boot/amd64-desktop.make @@ -119,7 +119,7 @@ run-efi-amd64-ahci: .PHONY: run-efi-amd64-ata-pio run-efi-amd64-ata-pio: - $(EMU) $(EMU_FLAGS) -device piix3-ide,id=ide -drive id=disk,file=$(IMG),format=raw,if=none -device ide-hd,drive=disk,bus=ide.0 -s -S + $(EMU) $(EMU_FLAGS) -device piix3-ide,id=ide -drive id=disk,file=$(IMG),format=raw,if=none -device ide-hd,drive=disk,bus=ide.0 -s -S -d int .PHONY: run-efi-amd64-ata-dma run-efi-amd64-ata-dma: diff --git a/dev/boot/src/BootThread.cc b/dev/boot/src/BootThread.cc index aac3c931..ee70812f 100644 --- a/dev/boot/src/BootThread.cc +++ b/dev/boot/src/BootThread.cc @@ -73,23 +73,18 @@ namespace Boot writer.Write("BootZ: Minor Subsystem Ver: ").Write(opt_header_ptr->MinorSubsystemVersion).Write("\r"); writer.Write("BootZ: Magic: ").Write(header_ptr->Signature).Write("\r"); - constexpr auto cPageSize = 512; - EfiPhysicalAddress loadStartAddress = opt_header_ptr->ImageBase; loadStartAddress += opt_header_ptr->BaseOfData; writer.Write("BootZ: Image base: ").Write(loadStartAddress).Write("\r"); - auto numPages = opt_header_ptr->SizeOfImage / cPageSize; - BS->AllocatePages(AllocateAddress, EfiLoaderData, numPages, &loadStartAddress); - fStack = new UInt8[mib_cast(16)]; LDR_SECTION_HEADER_PTR sectPtr = (LDR_SECTION_HEADER_PTR)(((Char*)opt_header_ptr) + header_ptr->SizeOfOptionalHeader); - constexpr auto sectionForCode = ".text"; - constexpr auto sectionForNewLdr = ".ldr"; - constexpr auto sectionForBSS = ".bss"; + constexpr auto sectionForCode = ".text"; + constexpr auto sectionForBootZ = ".ldr"; + constexpr auto sectionForBSS = ".bss"; for (SizeT sectIndex = 0; sectIndex < numSecs; ++sectIndex) { @@ -114,7 +109,7 @@ namespace Boot fStartAddress = (VoidPtr)((UIntPtr)loadStartAddress + opt_header_ptr->AddressOfEntryPoint); writer.Write("BootZ: Executable entry address: ").Write((UIntPtr)fStartAddress).Write("\r"); } - else if (StrCmp(sectionForNewLdr, sect->Name) == 0) + else if (StrCmp(sectionForBootZ, sect->Name) == 0) { struct HANDOVER_INFORMATION_STUB { @@ -159,8 +154,9 @@ namespace Boot // ========================================= // fStartAddress = nullptr; + writer.Write("BootZ: PEF executable detected, won't load it.\r"); - writer.Write("BootZ: note: PEF executables aren't loadable by default.\r"); + writer.Write("BootZ: note: PEF executables aren't supported for now.\r"); } else { @@ -187,7 +183,7 @@ namespace Boot if (own_stack) { - UInt8* aligned_stack = &fStack[mib_cast(16)]; + UInt8* aligned_stack = &fStack[mib_cast(16) - 1]; aligned_stack = (UInt8*)((UIntPtr)aligned_stack & ~0xF); rt_jump_to_address(fStartAddress, fHandover, aligned_stack); diff --git a/dev/kernel/HALKit/AMD64/HalPagingMgrAMD64.cc b/dev/kernel/HALKit/AMD64/HalPagingMgrAMD64.cc index 63796393..6a9a89b7 100644 --- a/dev/kernel/HALKit/AMD64/HalPagingMgrAMD64.cc +++ b/dev/kernel/HALKit/AMD64/HalPagingMgrAMD64.cc @@ -91,7 +91,7 @@ namespace Kernel::HAL // Lastly, grab the pte entry. NE_PDE* pde_struct = reinterpret_cast<NE_PDE*>(pt_base); - return pde_struct->fEntries[pt_index]->PhysicalAddress; + return pde_struct->fEntries[pt_entry]->PhysicalAddress; } /***********************************************************************************/ diff --git a/dev/kernel/HALKit/AMD64/Storage/AHCI+Generic.cc b/dev/kernel/HALKit/AMD64/Storage/AHCI+Generic.cc index 21d95b5d..f74db6c0 100644 --- a/dev/kernel/HALKit/AMD64/Storage/AHCI+Generic.cc +++ b/dev/kernel/HALKit/AMD64/Storage/AHCI+Generic.cc @@ -15,6 +15,7 @@ * */ +#include "NewKit/Defines.h" #include <KernelKit/DeviceMgr.h> #include <KernelKit/DriveMgr.h> #include <KernelKit/ProcessScheduler.h> @@ -71,13 +72,13 @@ STATIC Void drv_compute_disk_ahci() noexcept kSATASectorCount = 0UL; /// Normally 512 bytes, but add an additional 512 bytes to make 1 KIB. - const UInt16 kSzIdent = kib_cast(1); + const UInt16 kSzIdent = 256; /// Push it to the stack - UInt8* identify_data ATTRIBUTE(aligned(4096)) = new UInt8[kSzIdent]; + UInt16* identify_data ATTRIBUTE(aligned(4096)) = new UInt16[kSzIdent]; /// Send AHCI command for identification. - drv_std_input_output_ahci<NO, YES, YES>(0, identify_data, kAHCISectorSize, kSzIdent); + drv_std_input_output_ahci<NO, YES, YES>(0, (UInt8*)identify_data, kAHCISectorSize, kSzIdent); /// Extract 48-bit LBA. @@ -90,6 +91,9 @@ STATIC Void drv_compute_disk_ahci() noexcept kSATASectorCount = (identify_data[61] << 16) | identify_data[60]; else kSATASectorCount = lba48_sectors; + + delete[] identify_data; + identify_data = nullptr; } /// @brief Finds a command slot for a HBA port. @@ -140,8 +144,10 @@ STATIC Void drv_std_input_output_ahci(UInt64 lba, UInt8* buffer, SizeT sector_sz /// Offset to specific command slot. command_header += slot; + /// check for command header. MUST_PASS(command_header); + /// 4kb per PRD. constexpr const UInt32 kMaxPRDSize = kib_cast(4); command_header->Cfl = sizeof(FisRegH2D) / sizeof(UInt32); diff --git a/dev/kernel/HALKit/AMD64/Storage/DMA+Generic.cc b/dev/kernel/HALKit/AMD64/Storage/DMA+Generic.cc index 5aabf144..f04d25eb 100644 --- a/dev/kernel/HALKit/AMD64/Storage/DMA+Generic.cc +++ b/dev/kernel/HALKit/AMD64/Storage/DMA+Generic.cc @@ -28,11 +28,11 @@ using namespace Kernel::HAL; /// BUGS: 0 -STATIC Boolean kATADetected = false; -STATIC Int32 kATADeviceType = kATADeviceCount; -STATIC Char kATAData[kATADataLen] = {0}; +STATIC Boolean kATADetected = false; +STATIC Int32 kATADeviceType = kATADeviceCount; +STATIC UInt16 kATAIdentifyData[kATADataLen] = {0}; STATIC Kernel::PCI::Device kATADevice; -STATIC Char kCurrentDiskModel[50] = {"GENERIC DMA"}; +STATIC Char kATADiskModel[50] = {"GENERIC DMA"}; Boolean drv_std_wait_io(UInt16 IO) { @@ -198,7 +198,7 @@ Boolean drv_std_detected(Void) /***********************************************************************************/ Kernel::SizeT drv_get_sector_count() { - return (kATAData[61] << 16) | kATAData[60]; + return (kATAIdentifyData[61] << 16) | kATAIdentifyData[60]; } /***********************************************************************************/ diff --git a/dev/kernel/HALKit/AMD64/Storage/PIO+Generic.cc b/dev/kernel/HALKit/AMD64/Storage/PIO+Generic.cc index aa3b50c4..fc608e94 100644 --- a/dev/kernel/HALKit/AMD64/Storage/PIO+Generic.cc +++ b/dev/kernel/HALKit/AMD64/Storage/PIO+Generic.cc @@ -25,12 +25,12 @@ using namespace Kernel::HAL; /// BUGS: 0 -#define kATADataLen 512 +#define kATADataLen 256 -STATIC Boolean kATADetected = false; -STATIC Int32 kATADeviceType = kATADeviceCount; -STATIC Char kATAData[kATADataLen] = {0}; -STATIC Char kCurrentDiskModel[50] = {"GENERIC PIO"}; +STATIC Boolean kATADetected = false; +STATIC Int32 kATADeviceType = kATADeviceCount; +STATIC UInt16 kATAIdentifyData[kATADataLen] = {0}; +STATIC Char kATADiskModel[50] = {"GENERIC PIO"}; static Boolean drv_pio_std_wait_io(UInt16 IO) { @@ -96,20 +96,18 @@ ATAInit_Retry: for (SizeT i = 0ul; i < kATADataLen; ++i) { - kATAData[i] = HAL::rt_in16(OutBus + ATA_REG_DATA); + kATAIdentifyData[i] = HAL::rt_in16(OutBus + ATA_REG_DATA); } for (Int32 i = 0; i < 20; i++) { - kCurrentDiskModel[i * 2] = kATAData[27 + i] >> 8; - kCurrentDiskModel[i * 2 + 1] = kATAData[27 + i + 1] & 0xFF; + kATADiskModel[i * 2] = (kATAIdentifyData[27 + i] >> 8) & 0xFF; + kATADiskModel[i * 2 + 1] = kATAIdentifyData[27 + i] & 0xFF; } - kCurrentDiskModel[40] = '\0'; + kATADiskModel[40] = '\0'; - kout << "Detect: /dev/ata0" << kendl; - - kout << "Drive Model: " << kCurrentDiskModel << kendl; + kout << "Drive Model: " << kATADiskModel << kendl; return true; } @@ -179,7 +177,7 @@ Boolean drv_pio_std_detected(Void) */ SizeT drv_pio_get_sector_count() { - return (kATAData[61] << 16) | kATAData[60]; + return (kATAIdentifyData[61] << 16) | kATAIdentifyData[60]; } /// @brief Get the drive size. diff --git a/meta/png/nekernel.png b/meta/png/nekernel.png Binary files differnew file mode 100644 index 00000000..43f77ea8 --- /dev/null +++ b/meta/png/nekernel.png diff --git a/public/frameworks/KernelTest.fwrk/headers/KernelTest.h b/public/frameworks/KernelTest.fwrk/headers/KernelTest.h index 966672bb..e3200032 100644 --- a/public/frameworks/KernelTest.fwrk/headers/KernelTest.h +++ b/public/frameworks/KernelTest.fwrk/headers/KernelTest.h @@ -8,6 +8,9 @@ #include <NewKit/KernelPanic.h> +/// @brief Kernel Test Framework. +/// @file KernelTest.h + #define KT_TEST_VERSION_BCD (0x0001) #define KT_TEST_VERSION "0.0.1" diff --git a/setup_amd64.sh b/setup_x64.sh index b211b4bc..b211b4bc 100755 --- a/setup_amd64.sh +++ b/setup_x64.sh |
