summaryrefslogtreecommitdiffhomepage
path: root/Private/NewBoot/Source
diff options
context:
space:
mode:
authorAmlal El Mahrouss <amlal.elmahrouss@icloud.com>2024-04-28 09:08:00 +0200
committerAmlal El Mahrouss <amlal.elmahrouss@icloud.com>2024-04-28 09:08:00 +0200
commitb608517c047f7e4f7d7d70af7db76b0e9b0873b0 (patch)
tree2ffd9ee4e202692d873f53f41520cde960b1ddef /Private/NewBoot/Source
parentdd6568c64e440fe9d8c75539165377ddbbca3e2c (diff)
MHR-18: Big set of patches regarding the New Filesystem.
Signed-off-by: Amlal El Mahrouss <amlal.elmahrouss@icloud.com>
Diffstat (limited to 'Private/NewBoot/Source')
-rw-r--r--Private/NewBoot/Source/HEL/AMD64/BootATA.cxx20
-rw-r--r--Private/NewBoot/Source/HEL/AMD64/BootMain.cxx2
-rw-r--r--Private/NewBoot/Source/HEL/AMD64/Support.cxx14
-rw-r--r--Private/NewBoot/Source/compile_flags.txt1
-rw-r--r--Private/NewBoot/Source/makefile4
5 files changed, 28 insertions, 13 deletions
diff --git a/Private/NewBoot/Source/HEL/AMD64/BootATA.cxx b/Private/NewBoot/Source/HEL/AMD64/BootATA.cxx
index 5be1e977..d6b5542c 100644
--- a/Private/NewBoot/Source/HEL/AMD64/BootATA.cxx
+++ b/Private/NewBoot/Source/HEL/AMD64/BootATA.cxx
@@ -107,18 +107,22 @@ Void boot_ata_read(UInt64 Lba, UInt16 IO, UInt8 Master, CharacterTypeUTF8* Buf,
boot_ata_select(IO);
Out8(IO + ATA_REG_HDDEVSEL, (Command) | (((Lba) >> 24) & 0x0F));
- Out8(IO + ATA_REG_SEC_COUNT0, 1);
+
+ Out8(IO + ATA_REG_SEC_COUNT0, 2);
Out8(IO + ATA_REG_LBA0, (Lba));
Out8(IO + ATA_REG_LBA1, (Lba) >> 8);
Out8(IO + ATA_REG_LBA2, (Lba) >> 16);
- Out8(IO + ATA_REG_LBA4, (Lba) >> 24);
+ Out8(IO + ATA_REG_LBA3, (Lba) >> 24);
Out8(IO + ATA_REG_COMMAND, ATA_CMD_READ_PIO);
+ boot_ata_wait_io(IO);
+
for (SizeT IndexOff = 0; IndexOff < Size; ++IndexOff) {
boot_ata_wait_io(IO);
Buf[IndexOff] = In16(IO + ATA_REG_DATA);
+ boot_ata_wait_io(IO);
}
}
@@ -130,18 +134,22 @@ Void boot_ata_write(UInt64 Lba, UInt16 IO, UInt8 Master, CharacterTypeUTF8* Buf,
boot_ata_select(IO);
Out8(IO + ATA_REG_HDDEVSEL, (Command) | (((Lba) >> 24) & 0x0F));
- Out8(IO + ATA_REG_SEC_COUNT0, 1);
+
+ Out8(IO + ATA_REG_SEC_COUNT0, 2);
Out8(IO + ATA_REG_LBA0, (Lba));
Out8(IO + ATA_REG_LBA1, (Lba) >> 8);
Out8(IO + ATA_REG_LBA2, (Lba) >> 16);
- Out8(IO + ATA_REG_LBA4, (Lba) >> 24);
+ Out8(IO + ATA_REG_LBA3, (Lba) >> 24);
Out8(IO + ATA_REG_COMMAND, ATA_CMD_WRITE_PIO);
+ boot_ata_wait_io(IO);
+
for (SizeT IndexOff = 0; IndexOff < Size; ++IndexOff) {
boot_ata_wait_io(IO);
Out16(IO + ATA_REG_DATA, Buf[IndexOff]);
+ boot_ata_wait_io(IO);
}
}
@@ -188,7 +196,7 @@ BootDeviceATA& BootDeviceATA::Read(CharacterTypeUTF8* Buf, const SizeT& SectorSz
if (!Buf || SectorSz < 1) return *this;
- auto lba = this->Leak().mBase / BootDeviceATA::kSectorSize;
+ auto lba = this->Leak().mBase / SectorSz;
boot_ata_read(lba, this->Leak().mBus, this->Leak().mMaster,
Buf, SectorSz, this->Leak().mSize);
@@ -211,7 +219,7 @@ BootDeviceATA& BootDeviceATA::Write(CharacterTypeUTF8* Buf, const SizeT& SectorS
if (!Buf || SectorSz < 1) return *this;
- auto lba = this->Leak().mBase / BootDeviceATA::kSectorSize;
+ auto lba = this->Leak().mBase / SectorSz;
boot_ata_write(lba, this->Leak().mBus, this->Leak().mMaster,
Buf, SectorSz, this->Leak().mSize);
diff --git a/Private/NewBoot/Source/HEL/AMD64/BootMain.cxx b/Private/NewBoot/Source/HEL/AMD64/BootMain.cxx
index 36dc47d3..12d34232 100644
--- a/Private/NewBoot/Source/HEL/AMD64/BootMain.cxx
+++ b/Private/NewBoot/Source/HEL/AMD64/BootMain.cxx
@@ -165,7 +165,7 @@ EFI_EXTERN_C EFI_API Int Main(EfiHandlePtr ImageHandle,
/// if not formated yet, then format it with the following folders:
/// /, /Boot, /Applications.
- if (!diskFormatter) {
+ if (!diskFormatter.IsPartitionValid()) {
BDiskFormatFactory<BootDeviceATA>::BFileDescriptor rootDesc{0};
memcpy(rootDesc.fFileName, "/", strlen("/"));
diff --git a/Private/NewBoot/Source/HEL/AMD64/Support.cxx b/Private/NewBoot/Source/HEL/AMD64/Support.cxx
index 686f4811..3a6974bb 100644
--- a/Private/NewBoot/Source/HEL/AMD64/Support.cxx
+++ b/Private/NewBoot/Source/HEL/AMD64/Support.cxx
@@ -16,8 +16,11 @@
/// @param len length of of src.
EXTERN_C VoidPtr memset(void *dst, int byte,
long long unsigned int len) {
- SetMem(dst, byte, len);
- return dst;
+ for (size_t i = 0UL; i < len; ++i) {
+ ((int*)dst)[i] = byte;
+ }
+
+ return dst;
}
/// @brief memcpy definition in C++.
@@ -26,8 +29,11 @@ EXTERN_C VoidPtr memset(void *dst, int byte,
/// @param len length of of src.
EXTERN_C VoidPtr memcpy(void *dst, const void *src,
long long unsigned int len) {
- CopyMem(dst, src, len);
- return dst;
+ for (size_t i = 0UL; i < len; ++i){
+ ((int*)dst)[i] = ((int*)src)[i];
+ }
+
+ return dst;
}
/// @brief strlen definition in C++.
diff --git a/Private/NewBoot/Source/compile_flags.txt b/Private/NewBoot/Source/compile_flags.txt
index e58d7ab9..c74d22b2 100644
--- a/Private/NewBoot/Source/compile_flags.txt
+++ b/Private/NewBoot/Source/compile_flags.txt
@@ -1,3 +1,4 @@
-std=c++20
-I../
-I../../
+-D__NEWOS_AMD64__
diff --git a/Private/NewBoot/Source/makefile b/Private/NewBoot/Source/makefile
index f3a292c5..9f70d903 100644
--- a/Private/NewBoot/Source/makefile
+++ b/Private/NewBoot/Source/makefile
@@ -75,8 +75,8 @@ run-efi-amd64:
.PHONY: epm-img
epm-img:
- qemu-img create -f qcow2 $(IMG) 512M
- qemu-img create -f qcow2 $(IMG_2) 512M
+ qemu-img create -f raw $(IMG) 512M
+ qemu-img create -f raw $(IMG_2) 512M
.PHONY: download-edk
download-edk: