summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--.vscode/c_cpp_properties.json6
-rw-r--r--Private/Builtins/AHCI/Defines.hxx8
-rw-r--r--Private/Builtins/ATA/Defines.hxx12
-rw-r--r--Private/Builtins/RJ45/.gitkeep (renamed from Private/Builtins/Ethernet/.gitkeep)0
-rw-r--r--Private/Builtins/RJ45/compile_flags.txt (renamed from Private/Builtins/Ethernet/compile_flags.txt)0
-rw-r--r--Private/Builtins/SCSI/.gitkeep (renamed from Private/Builtins/SAS/.gitkeep)0
-rw-r--r--Private/Builtins/SCSI/SCSI.hxx (renamed from Private/Builtins/SAS/SCSI.hxx)0
-rw-r--r--Private/HALKit/AMD64/PCI/Iterator.cxx6
-rw-r--r--Private/HALKit/AMD64/Storage/AHCI.cxx43
-rw-r--r--Private/HALKit/AMD64/Storage/ATA-DMA.cxx4
-rw-r--r--Private/HALKit/AMD64/Storage/ATA-PIO.cxx22
-rw-r--r--Private/KernelKit/PCI/Device.hpp4
-rw-r--r--Private/KernelKit/PCI/Iterator.hpp8
-rw-r--r--Private/NewBoot/Source/HEL/AMD64/BootMain.cxx20
-rw-r--r--Private/NewBoot/Source/HEL/AMD64/BootPlatform.cxx2
-rw-r--r--Private/NewBoot/Source/makefile4
-rw-r--r--Private/Source/DriveManager.cxx4
-rw-r--r--Private/StorageKit/SCSI.hxx2
18 files changed, 93 insertions, 52 deletions
diff --git a/.vscode/c_cpp_properties.json b/.vscode/c_cpp_properties.json
index 6899e66e..cb5e3f38 100644
--- a/.vscode/c_cpp_properties.json
+++ b/.vscode/c_cpp_properties.json
@@ -14,7 +14,8 @@
"Z_PREFIX",
"__HAVE_MAHROUSS_APIS__",
"__FSKIT_NEWFS__",
- "__EFI_x86_64__"
+ "__EFI_x86_64__",
+ "__AHCI__"
],
"cStandard": "c17",
"cppStandard": "c++20",
@@ -45,7 +46,8 @@
"Z_PREFIX",
"__HAVE_MAHROUSS_APIS__",
"__FSKIT_NEWFS__",
- "__EFI_x86_64__"
+ "__EFI_x86_64__",
+ "__AHCI__"
],
"cStandard": "c17",
"cppStandard": "c++20",
diff --git a/Private/Builtins/AHCI/Defines.hxx b/Private/Builtins/AHCI/Defines.hxx
index 23c86049..44a19f38 100644
--- a/Private/Builtins/AHCI/Defines.hxx
+++ b/Private/Builtins/AHCI/Defines.hxx
@@ -320,14 +320,14 @@ typedef struct HbaCmdTbl final {
/// @brief Initializes an AHCI disk.
/// @param PortsImplemented the amount of port that have been detected.
/// @return
-NewOS::Boolean drv_ahci_init(NewOS::UInt16& PortsImplemented);
+NewOS::Boolean drv_std_init(NewOS::UInt16& PortsImplemented);
-NewOS::Boolean drv_ahci_detected(NewOS::Void);
+NewOS::Boolean drv_std_detected(NewOS::Void);
-NewOS::Void drv_ahci_read(NewOS::UInt64 Lba, NewOS::UInt16 IO, NewOS::UInt8 Master, NewOS::Char* Buf,
+NewOS::Void drv_std_read(NewOS::UInt64 Lba, NewOS::UInt16 IO, NewOS::UInt8 Master, NewOS::Char* Buf,
NewOS::SizeT SectorSz, NewOS::SizeT Size);
-NewOS::Void drv_ahci_write(NewOS::UInt64 Lba, NewOS::UInt16 IO, NewOS::UInt8 Master, NewOS::Char* Buf,
+NewOS::Void drv_std_write(NewOS::UInt64 Lba, NewOS::UInt16 IO, NewOS::UInt8 Master, NewOS::Char* Buf,
NewOS::SizeT SectorSz, NewOS::SizeT Size);
#endif // ifdef __KERNEL__
diff --git a/Private/Builtins/ATA/Defines.hxx b/Private/Builtins/ATA/Defines.hxx
index a8cabe77..c8a87384 100644
--- a/Private/Builtins/ATA/Defines.hxx
+++ b/Private/Builtins/ATA/Defines.hxx
@@ -130,19 +130,19 @@ enum {
#ifdef __KERNEL__
-NewOS::Boolean drv_ata_init(NewOS::UInt16 Bus, NewOS::UInt8 Drive, NewOS::UInt16& OutBus,
+NewOS::Boolean drv_std_init(NewOS::UInt16 Bus, NewOS::UInt8 Drive, NewOS::UInt16& OutBus,
NewOS::UInt8& OutMaster);
-NewOS::Boolean drv_ata_detected(NewOS::Void);
+NewOS::Boolean drv_std_detected(NewOS::Void);
-NewOS::Void drv_ata_select(NewOS::UInt16 Bus);
+NewOS::Void drv_std_select(NewOS::UInt16 Bus);
-NewOS::Boolean drv_ata_wait_io(NewOS::UInt16 IO);
+NewOS::Boolean drv_std_wait_io(NewOS::UInt16 IO);
-NewOS::Void drv_ata_read(NewOS::UInt64 Lba, NewOS::UInt16 IO, NewOS::UInt8 Master, NewOS::Char* Buf,
+NewOS::Void drv_std_read(NewOS::UInt64 Lba, NewOS::UInt16 IO, NewOS::UInt8 Master, NewOS::Char* Buf,
NewOS::SizeT SectorSz, NewOS::SizeT Size);
-NewOS::Void drv_ata_write(NewOS::UInt64 Lba, NewOS::UInt16 IO, NewOS::UInt8 Master, NewOS::Char* Buf,
+NewOS::Void drv_std_write(NewOS::UInt64 Lba, NewOS::UInt16 IO, NewOS::UInt8 Master, NewOS::Char* Buf,
NewOS::SizeT SectorSz, NewOS::SizeT Size);
#endif // ifdef __KERNEL__
diff --git a/Private/Builtins/Ethernet/.gitkeep b/Private/Builtins/RJ45/.gitkeep
index e69de29b..e69de29b 100644
--- a/Private/Builtins/Ethernet/.gitkeep
+++ b/Private/Builtins/RJ45/.gitkeep
diff --git a/Private/Builtins/Ethernet/compile_flags.txt b/Private/Builtins/RJ45/compile_flags.txt
index 545816fc..545816fc 100644
--- a/Private/Builtins/Ethernet/compile_flags.txt
+++ b/Private/Builtins/RJ45/compile_flags.txt
diff --git a/Private/Builtins/SAS/.gitkeep b/Private/Builtins/SCSI/.gitkeep
index e69de29b..e69de29b 100644
--- a/Private/Builtins/SAS/.gitkeep
+++ b/Private/Builtins/SCSI/.gitkeep
diff --git a/Private/Builtins/SAS/SCSI.hxx b/Private/Builtins/SCSI/SCSI.hxx
index d7fb18d4..d7fb18d4 100644
--- a/Private/Builtins/SAS/SCSI.hxx
+++ b/Private/Builtins/SCSI/SCSI.hxx
diff --git a/Private/HALKit/AMD64/PCI/Iterator.cxx b/Private/HALKit/AMD64/PCI/Iterator.cxx
index eb3f7b13..151d8780 100644
--- a/Private/HALKit/AMD64/PCI/Iterator.cxx
+++ b/Private/HALKit/AMD64/PCI/Iterator.cxx
@@ -12,9 +12,9 @@
namespace NewOS::PCI {
Iterator::Iterator(const Types::PciDeviceKind &type) {
// probe devices.
- for (int bus = 0; bus < ME_BUS_COUNT; ++bus) {
- for (int device = 0; device < ME_DEVICE_COUNT; ++device) {
- for (int function = 0; function < ME_FUNCTION_COUNT; ++function) {
+ for (int bus = 0; bus < NEWOS_BUS_COUNT; ++bus) {
+ for (int device = 0; device < NEWOS_DEVICE_COUNT; ++device) {
+ for (int function = 0; function < NEWOS_FUNCTION_COUNT; ++function) {
Device dev(bus, device, function, 0);
if (dev.Class() == (UChar)type) {
diff --git a/Private/HALKit/AMD64/Storage/AHCI.cxx b/Private/HALKit/AMD64/Storage/AHCI.cxx
index 25318212..35308582 100644
--- a/Private/HALKit/AMD64/Storage/AHCI.cxx
+++ b/Private/HALKit/AMD64/Storage/AHCI.cxx
@@ -15,4 +15,45 @@
*
*/
-#include <Builtins/AHCI/Defines.hxx> \ No newline at end of file
+#include <Builtins/AHCI/Defines.hxx>
+#include <KernelKit/PCI/Iterator.hpp>
+
+#ifdef __AHCI__
+enum { kSATAProgIfAHCI = 0x01, kSATASubClass = 0x06 };
+
+static NewOS::PCI::Device kAhciDevice;
+
+/// @brief Initializes an AHCI disk.
+/// @param PortsImplemented the amount of port that have been detected.
+/// @return
+NewOS::Boolean drv_std_init(NewOS::UInt16& PortsImplemented) {
+ using namespace NewOS;
+
+ PCI::Iterator iterator(Types::PciDeviceKind::MassStorageController);
+ for (SizeT devIndex = 0; devIndex < NEWOS_BUS_COUNT; ++devIndex) {
+ if (iterator[devIndex].Leak().Subclass() == kSATASubClass &&
+ iterator[devIndex].Leak().ProgIf() == kSATAProgIfAHCI) {
+ iterator[devIndex].Leak().EnableMmio();
+ kAhciDevice = iterator[devIndex].Leak();
+
+ kcout << "NewKernel: Found AHCI controller.\r\n";
+
+ return true;
+ }
+ }
+
+ return false;
+}
+
+NewOS::Boolean drv_std_detected(NewOS::Void) {
+ return kAhciDevice.DeviceId() != 0xFFFF;
+}
+
+NewOS::Void drv_std_read(NewOS::UInt64 Lba, NewOS::UInt16 IO,
+ NewOS::UInt8 Master, NewOS::Char* Buf,
+ NewOS::SizeT SectorSz, NewOS::SizeT Size) {}
+
+NewOS::Void drv_std_write(NewOS::UInt64 Lba, NewOS::UInt16 IO,
+ NewOS::UInt8 Master, NewOS::Char* Buf,
+ NewOS::SizeT SectorSz, NewOS::SizeT Size) {}
+#endif // __AHCI__ \ No newline at end of file
diff --git a/Private/HALKit/AMD64/Storage/ATA-DMA.cxx b/Private/HALKit/AMD64/Storage/ATA-DMA.cxx
index 4189e467..d3e90f67 100644
--- a/Private/HALKit/AMD64/Storage/ATA-DMA.cxx
+++ b/Private/HALKit/AMD64/Storage/ATA-DMA.cxx
@@ -27,11 +27,11 @@ EXTERN_C Int32 kPRDTTransferStatus;
#ifdef __ATA_DMA__
#ifdef __ATA_PIO__
-# error You can't have both PIO and DMA enabled!
+# error You cant have both PIO and DMA enabled!
#endif /* ifdef __ATA_PIO__ */
#ifdef __AHCI__
-# error You can't have both ATA and AHCI enabled!
+# error You cant have both ATA and AHCI enabled!
#endif /* ifdef __AHCI__ */
#endif /* ifdef __ATA_DMA__ */
diff --git a/Private/HALKit/AMD64/Storage/ATA-PIO.cxx b/Private/HALKit/AMD64/Storage/ATA-PIO.cxx
index 2344cd86..0ff3591e 100644
--- a/Private/HALKit/AMD64/Storage/ATA-PIO.cxx
+++ b/Private/HALKit/AMD64/Storage/ATA-PIO.cxx
@@ -31,7 +31,7 @@ static Boolean kATADetected = false;
static Int32 kATADeviceType = kATADeviceCount;
static Char kATAData[kATADataLen] = {0};
-Boolean drv_ata_wait_io(UInt16 IO) {
+Boolean drv_std_wait_io(UInt16 IO) {
for (int i = 0; i < 4; i++) In8(IO + ATA_REG_STATUS);
ATAWaitForIO_Retry:
@@ -49,20 +49,20 @@ ATAWaitForIO_Retry2:
return true;
}
-Void drv_ata_select(UInt16 Bus) {
+Void drv_std_select(UInt16 Bus) {
if (Bus == ATA_PRIMARY_IO)
Out8(Bus + ATA_REG_HDDEVSEL, ATA_PRIMARY_SEL);
else
Out8(Bus + ATA_REG_HDDEVSEL, ATA_SECONDARY_SEL);
}
-Boolean drv_ata_init(UInt16 Bus, UInt8 Drive, UInt16& OutBus,
+Boolean drv_std_init(UInt16 Bus, UInt8 Drive, UInt16& OutBus,
UInt8& OutMaster) {
- if (drv_ata_detected()) return false;
+ if (drv_std_detected()) return false;
UInt16 IO = Bus;
- drv_ata_select(IO);
+ drv_std_select(IO);
// Bus init, NEIN bit.
Out8(IO + ATA_REG_NEIN, 1);
@@ -86,7 +86,7 @@ ATAInit_Retry:
/// fetch serial info
/// model, speed, number of sectors...
- drv_ata_wait_io(IO);
+ drv_std_wait_io(IO);
for (SizeT indexData = 0ul; indexData < kATADataLen; ++indexData) {
kATAData[indexData] = In16(IO + ATA_REG_DATA);
@@ -130,7 +130,7 @@ ATAInit_Retry:
return true;
}
-Void drv_ata_read(UInt64 Lba, UInt16 IO, UInt8 Master, Char* Buf,
+Void drv_std_read(UInt64 Lba, UInt16 IO, UInt8 Master, Char* Buf,
SizeT SectorSz, SizeT Size) {
UInt8 Command = (!Master ? 0xE0 : 0xF0);
@@ -144,7 +144,7 @@ Void drv_ata_read(UInt64 Lba, UInt16 IO, UInt8 Master, Char* Buf,
Out8(IO + ATA_REG_COMMAND, ATA_CMD_READ_PIO);
- drv_ata_wait_io(IO);
+ drv_std_wait_io(IO);
for (SizeT IndexOff = 0; IndexOff < Size; ++IndexOff) {
WideChar chr = In16(IO + ATA_REG_DATA);
@@ -153,7 +153,7 @@ Void drv_ata_read(UInt64 Lba, UInt16 IO, UInt8 Master, Char* Buf,
}
}
-Void drv_ata_write(UInt64 Lba, UInt16 IO, UInt8 Master, Char* Buf,
+Void drv_std_write(UInt64 Lba, UInt16 IO, UInt8 Master, Char* Buf,
SizeT SectorSz, SizeT Size) {
UInt8 Command = (!Master ? 0xE0 : 0xF0);
@@ -167,7 +167,7 @@ Void drv_ata_write(UInt64 Lba, UInt16 IO, UInt8 Master, Char* Buf,
Out8(IO + ATA_REG_COMMAND, ATA_CMD_WRITE_PIO);
- drv_ata_wait_io(IO);
+ drv_std_wait_io(IO);
for (SizeT IndexOff = 0; IndexOff < Size; ++IndexOff) {
Out16(IO + ATA_REG_DATA, Buf[IndexOff]);
@@ -176,6 +176,6 @@ Void drv_ata_write(UInt64 Lba, UInt16 IO, UInt8 Master, Char* Buf,
}
/// @check is ATA detected?
-Boolean drv_ata_detected(Void) { return kATADetected; }
+Boolean drv_std_detected(Void) { return kATADetected; }
#endif /* ifdef __ATA_PIO__ */ \ No newline at end of file
diff --git a/Private/KernelKit/PCI/Device.hpp b/Private/KernelKit/PCI/Device.hpp
index c73ca068..9bb22cb2 100644
--- a/Private/KernelKit/PCI/Device.hpp
+++ b/Private/KernelKit/PCI/Device.hpp
@@ -77,5 +77,5 @@ namespace NewOS::PCI
} // namespace NewOS::PCI
-extern "C" void LumiaPCISetCfgTarget(NewOS::UInt bar);
-extern "C" NewOS::UInt LumiaPCIReadRaw(NewOS::UInt bar);
+EXTERN_C void NewOSPCISetCfgTarget(NewOS::UInt bar);
+EXTERN_C NewOS::UInt NewOSPCIReadRaw(NewOS::UInt bar);
diff --git a/Private/KernelKit/PCI/Iterator.hpp b/Private/KernelKit/PCI/Iterator.hpp
index f1069fda..7f17263d 100644
--- a/Private/KernelKit/PCI/Iterator.hpp
+++ b/Private/KernelKit/PCI/Iterator.hpp
@@ -7,9 +7,9 @@
#include <NewKit/Defines.hpp>
#include <NewKit/Ref.hpp>
-#define ME_BUS_COUNT (256)
-#define ME_DEVICE_COUNT (33)
-#define ME_FUNCTION_COUNT (8)
+#define NEWOS_BUS_COUNT (256)
+#define NEWOS_DEVICE_COUNT (33)
+#define NEWOS_FUNCTION_COUNT (8)
namespace NewOS::PCI {
class Iterator final {
@@ -29,7 +29,7 @@ namespace NewOS::PCI {
Ref<PCI::Device> operator[](const Size &sz);
private:
- Array<PCI::Device, ME_BUS_COUNT> m_Devices;
+ Array<PCI::Device, NEWOS_BUS_COUNT> m_Devices;
};
} // namespace NewOS::PCI
diff --git a/Private/NewBoot/Source/HEL/AMD64/BootMain.cxx b/Private/NewBoot/Source/HEL/AMD64/BootMain.cxx
index dd973d0c..8b10503a 100644
--- a/Private/NewBoot/Source/HEL/AMD64/BootMain.cxx
+++ b/Private/NewBoot/Source/HEL/AMD64/BootMain.cxx
@@ -34,7 +34,7 @@ EFI_EXTERN_C EFI_API Int EfiMain(EfiHandlePtr ImageHandle,
writer.Write(L"Mahrouss-Logic (R) NewOS: ").Write(BVersionString::Shared());
- writer.Write(L"\r\nNewBoot.exe: Firmware Vendor: ")
+ writer.Write(L"\r\nNewOS: Firmware Vendor: ")
.Write(SystemTable->FirmwareVendor)
.Write(L"\r\n");
@@ -43,15 +43,12 @@ EFI_EXTERN_C EFI_API Int EfiMain(EfiHandlePtr ImageHandle,
/// if ATA drive is initialized and EFI vendor supports an EPM scheme.
/// @EDK tells our OS that it supports EPM scheme as well.
- if (ataDev) {
+ if (ataDev && SystemTable->FirmwareVendor[0] == '@') {
Char namePart[kEPMNameLength] = {"NewBoot"};
/// tries to read an EPM block, or writes one if it fails.
isEpmFound = boot_write_epm_partition(namePart, kEPMNameLength, &ataDev);
} else {
- writer.Write(
- L"NewOS: This computer can't work with NewOS, please use Mahrouss-"
- L"Logic products instead\r\nNewBoot.exe: Our website: "
- L"www.el-mahrouss-logic.com\r\n");
+ writer.Write(L"NewOS: This computer can't work with NewOS.\r\n");
return kEfiFail;
}
@@ -71,9 +68,7 @@ EFI_EXTERN_C EFI_API Int EfiMain(EfiHandlePtr ImageHandle,
if (BS->AllocatePool(EfiLoaderData, sizeof(UInt32), (VoidPtr*)&SizePtr) !=
kEfiOk) {
- EFI::RaiseHardError(
- L"__bad_alloc",
- L"NewBoot ran out of memory!");
+ EFI::RaiseHardError(L"__bad_alloc", L"NewBoot ran out of memory!");
}
/****
@@ -86,9 +81,7 @@ EFI_EXTERN_C EFI_API Int EfiMain(EfiHandlePtr ImageHandle,
if (BS->AllocatePool(EfiLoaderData, sizeof(EfiMemoryDescriptor),
(VoidPtr*)&Descriptor) != kEfiOk) {
- EFI::RaiseHardError(
- L"__bad_alloc",
- L"NewBoot ran out of memory!");
+ EFI::RaiseHardError(L"__bad_alloc", L"NewBoot ran out of memory!");
}
/****
@@ -98,7 +91,8 @@ EFI_EXTERN_C EFI_API Int EfiMain(EfiHandlePtr ImageHandle,
*/
while (BS->GetMemoryMap(SizePtr, Descriptor, &MapKey, &SzDesc, &RevDesc) !=
- kEfiOk);
+ kEfiOk)
+ ;
HEL::HandoverInformationHeader* handoverHdrPtr = nullptr;
diff --git a/Private/NewBoot/Source/HEL/AMD64/BootPlatform.cxx b/Private/NewBoot/Source/HEL/AMD64/BootPlatform.cxx
index b27654cb..00f7bdd8 100644
--- a/Private/NewBoot/Source/HEL/AMD64/BootPlatform.cxx
+++ b/Private/NewBoot/Source/HEL/AMD64/BootPlatform.cxx
@@ -14,4 +14,4 @@ EXTERN_C void rt_sti() { asm volatile("sti"); }
EXTERN_C void rt_cld() { asm volatile("cld"); }
-EXTERN_C void rt_std() { asm volatile("std"); } \ No newline at end of file
+EXTERN_C void rt_std() { asm volatile("std"); }
diff --git a/Private/NewBoot/Source/makefile b/Private/NewBoot/Source/makefile
index 7fc566b6..595010d3 100644
--- a/Private/NewBoot/Source/makefile
+++ b/Private/NewBoot/Source/makefile
@@ -17,11 +17,14 @@ EMU=qemu-system-x86_64w.exe
endif
IMG=epm.img
+IMG_2=epm-slave.img
EMU_FLAGS=-net none -smp 4 -m 4G -M q35 -bios OVMF.fd -device piix3-ide,id=ide -drive id=disk,file=$(IMG),format=raw,if=none -device ide-hd,drive=disk,bus=ide.0 -drive file=fat:rw:CDROM,index=2,format=raw -d int
LD_FLAGS=-e efi_main --subsystem=10
+
OBJ=$(wildcard *.o) $(wildcard HEL/AMD64/*.obj)
+
REM=rm
REM_FLAG=-f
@@ -55,6 +58,7 @@ run-efi-amd64:
.PHONY: epm-img
epm-img:
qemu-img create -f raw $(IMG) 256M
+ qemu-img create -f raw $(IMG_2) 256M
.PHONY: download-edk
download-edk:
diff --git a/Private/Source/DriveManager.cxx b/Private/Source/DriveManager.cxx
index f9a07c66..d04faa68 100644
--- a/Private/Source/DriveManager.cxx
+++ b/Private/Source/DriveManager.cxx
@@ -25,7 +25,7 @@ Void ke_drv_input(DriveTrait::DrivePacket* pckt) {
pckt->fPacketGood = false;
- drv_ata_read(pckt->fLba, kATAIO, kATAMaster, (Char*)pckt->fPacketContent, 1, pckt->fPacketSize);
+ drv_std_read(pckt->fLba, kATAIO, kATAMaster, (Char*)pckt->fPacketContent, 1, pckt->fPacketSize);
pckt->fPacketGood = true;
}
@@ -40,7 +40,7 @@ Void ke_drv_output(DriveTrait::DrivePacket* pckt) {
pckt->fPacketGood = false;
- drv_ata_write(pckt->fLba, kATAIO, kATAMaster, (Char*)pckt->fPacketContent, 1, pckt->fPacketSize);
+ drv_std_write(pckt->fLba, kATAIO, kATAMaster, (Char*)pckt->fPacketContent, 1, pckt->fPacketSize);
pckt->fPacketGood = true;
}
diff --git a/Private/StorageKit/SCSI.hxx b/Private/StorageKit/SCSI.hxx
index eb207c9d..54d58cf0 100644
--- a/Private/StorageKit/SCSI.hxx
+++ b/Private/StorageKit/SCSI.hxx
@@ -6,6 +6,6 @@
#pragma once
-#include <Builtins/SAS/SCSI.hxx>
+#include <Builtins/SCSI/SCSI.hxx>
extern const scsi_packet_type kCDRomPacketTemplate;