summaryrefslogtreecommitdiffhomepage
path: root/Private
diff options
context:
space:
mode:
Diffstat (limited to 'Private')
-rw-r--r--Private/DriverKit/KernelCall.c (renamed from Private/DriverKit/KernelStd.c)0
-rw-r--r--Private/DriverKit/KernelDev.h4
-rw-r--r--Private/DriverKit/KernelDispatchCall.S2
-rw-r--r--Private/FSKit/NewFS.hxx8
-rw-r--r--Private/NewBoot/BootKit/BootKit.hxx108
-rw-r--r--Private/NewBoot/BootKit/HW/ATA.hxx4
-rw-r--r--Private/NewBoot/BootKit/Vendor/Qr.hxx3
-rw-r--r--Private/NewBoot/Source/HEL/AMD64/BootATA.cxx11
-rw-r--r--Private/NewBoot/Source/HEL/AMD64/Support.cxx14
-rw-r--r--Private/NewBoot/Source/HEL/POWER/BootEPM.cxx118
-rw-r--r--Private/NewBoot/Source/HEL/POWER/CoreBootStartup.S (renamed from Private/NewBoot/Source/HEL/POWER/BootCoreBoot.S)2
-rw-r--r--Private/NewBoot/Source/makefile5
12 files changed, 135 insertions, 144 deletions
diff --git a/Private/DriverKit/KernelStd.c b/Private/DriverKit/KernelCall.c
index 494ac0bc..494ac0bc 100644
--- a/Private/DriverKit/KernelStd.c
+++ b/Private/DriverKit/KernelCall.c
diff --git a/Private/DriverKit/KernelDev.h b/Private/DriverKit/KernelDev.h
index daa60a7c..8b6888f0 100644
--- a/Private/DriverKit/KernelDev.h
+++ b/Private/DriverKit/KernelDev.h
@@ -10,7 +10,11 @@
#include <DriverKit/KernelStd.h>
+struct _kernelDevice;
+
+/// @brief Kernel Device driver.
typedef struct _kernelDevice {
+ char name[255]; // the device name. Could be /./DEVICE_NAME/
int32_t(*read)(); // read from device.
int32_t(*write)(); // write to device.
struct _kernelDevice* (*open)(const char* path); // open device.
diff --git a/Private/DriverKit/KernelDispatchCall.S b/Private/DriverKit/KernelDispatchCall.S
index 4eec8ae0..64b6663e 100644
--- a/Private/DriverKit/KernelDispatchCall.S
+++ b/Private/DriverKit/KernelDispatchCall.S
@@ -14,7 +14,7 @@ __kernelDispatchCall:
#elif defined(__powerpc64__)
__kernelDispatchCall:
- mflr 3
+ /* There is no specific interrupt request id for a system call in POWER. */
sc
blr
diff --git a/Private/FSKit/NewFS.hxx b/Private/FSKit/NewFS.hxx
index 339b9832..cc43f51b 100644
--- a/Private/FSKit/NewFS.hxx
+++ b/Private/FSKit/NewFS.hxx
@@ -82,7 +82,7 @@ default.
#define kNewFSLbaType (NewOS::Lba)
/// Start After the PM headers, pad 1024 bytes.
-#define kNewFSAddressAsLba (1024U)
+#define kNewFSAddressAsLba (1024)
#define kResourceTypeDialog 10
#define kResourceTypeString 11
@@ -95,6 +95,8 @@ default.
#define kNewFSFlagUnallocated 0x00
#define kNewFSFlagCreated 0x0F
+#define kNewFSMimeNameLen (216)
+
typedef NewOS::Char NewCharType;
enum {
@@ -106,10 +108,10 @@ enum {
kNewFSDriveCount = 5,
};
-/// @brief Ccatalog type.
+/// @brief Catalog type.
struct PACKED NewCatalog final {
NewCharType Name[kNewFSNodeNameLen];
- NewCharType Mime[kNewFSNodeNameLen];
+ NewCharType Mime[kNewFSMimeNameLen];
NewOS::Int32 Flags;
NewOS::Int32 Kind;
diff --git a/Private/NewBoot/BootKit/BootKit.hxx b/Private/NewBoot/BootKit/BootKit.hxx
index 5c3a531d..15700f54 100644
--- a/Private/NewBoot/BootKit/BootKit.hxx
+++ b/Private/NewBoot/BootKit/BootKit.hxx
@@ -11,6 +11,22 @@
#pragma once
+#include <BootKit/HW/ATA.hxx>
+#include <CompilerKit/Version.hxx>
+
+/// include NewFS header and Support header as well.
+
+#include <FSKit/NewFS.hxx>
+#include <cstring>
+#include <BootKit/Vendor/Support.hxx>
+
+/***********************************************************************************/
+/// Include other APIs.
+/***********************************************************************************/
+
+#include <NewKit/Defines.hpp>
+#include "Builtins/ATA/ATA.hxx"
+
/***********************************************************************************/
/// Framebuffer helpers.
/***********************************************************************************/
@@ -22,15 +38,6 @@ class BFileReader;
class BFileRunner;
class BVersionString;
-#include <BootKit/HW/ATA.hxx>
-#include <CompilerKit/Version.hxx>
-
-/***********************************************************************************/
-/// Include other APIs.
-/***********************************************************************************/
-
-#include <NewKit/Defines.hpp>
-
///! @note This address is reserved to NewKernel.
#define kBootVirtualAddress (0xfffffff80000000)
@@ -39,12 +46,6 @@ using namespace NewOS;
typedef Char *PEFImagePtr;
typedef Char *PEImagePtr;
-enum {
- kSegmentCode = 2,
- kSegmentData = 4,
- kSegmentBss = 6,
-};
-
typedef WideChar CharacterTypeUTF16;
typedef Char CharacterTypeUTF8;
@@ -169,3 +170,80 @@ static inline const UInt32 kRgbGreen = 0x0000FF00;
static inline const UInt32 kRgbBlue = 0x00FF0000;
static inline const UInt32 kRgbBlack = 0x00000000;
static inline const UInt32 kRgbWhite = 0x00FFFFFF;
+
+/// @brief BootKit Disk Formatter.
+template <typename BootDev>
+class BDiskFormatFactory final {
+public:
+ /// @brief File entry for **BDiskFormatFactory**.
+ struct BFileDescriptor final {
+ Char fFilename[255];
+ Char fForkName[255];
+
+ VoidPtr fBlob;
+ SizeT fBlobSz;
+
+ struct BFileDescriptor* fPrev;
+ struct BFileDescriptor* fNext;
+ };
+
+public:
+ explicit BDiskFormatFactory() = default;
+ explicit BDiskFormatFactory(BootDev dev) : fDiskDev(dev) {}
+ ~BDiskFormatFactory() = default;
+
+ NEWOS_COPY_DELETE(BDiskFormatFactory);
+
+ /// @brief Format disk.
+ /// @param Partition Name
+ /// @param Blobs.
+ /// @param Number of blobs.
+ /// @retval True disk has been formatted.
+ /// @retval False failed to format.
+ Boolean Format(const char* partName, BFileDescriptor* fileBlobs, SizeT blobCount);
+
+private:
+ /// @brief Write all of the requested catalogs into the filesystem.
+ Boolean _AppendCatalogList(BFileDescriptor* fileBlobs, SizeT blobCount) {
+ return true;
+ }
+
+private:
+ BootDev fDiskDev;
+
+};
+
+/// @brief Format disk.
+/// @param Partition Name
+/// @param Blobs.
+/// @param Number of blobs.
+/// @retval True disk has been formatted.
+/// @retval False failed to format.
+template <typename BootDev>
+inline Boolean BDiskFormatFactory<BootDev>::Format(const char* partName,
+ BDiskFormatFactory::BFileDescriptor* fileBlobs, SizeT blobCount) {
+ // if (!fileBlobs || !blobCount) return false;
+
+ static_assert(kNewFSMinimumSectorSz == kATASectorSize, "Sector size doesn't match!");
+
+ Char buf[kNewFSMinimumSectorSz] = { 0 };
+ NewPartitionBlock* partBlock = reinterpret_cast<NewPartitionBlock*>(buf);
+
+ memcpy(partBlock->PartitionName, partName, strlen(partName));
+
+ /// @note A catalog roughly equal to a sector.
+
+ partBlock->CatalogCount = blobCount;
+ partBlock->Kind = kNewFSHardDrive;
+ partBlock->SectorCount = kNewFSMinimumSectorSz;
+ partBlock->FreeCatalog = fDiskDev.GetSectorsCount() - partBlock->CatalogCount;
+ partBlock->SectorCount = fDiskDev.GetSectorsCount();
+ partBlock->FreeSectors = fDiskDev.GetSectorsCount() - partBlock->CatalogCount;
+ partBlock->StartCatalog = kNewFSAddressAsLba + sizeof(NewPartitionBlock);
+
+ fDiskDev.Leak().mBase = (kNewFSAddressAsLba / kNewFSMinimumSectorSz);
+ fDiskDev.Leak().mSize = kNewFSMinimumSectorSz;
+ fDiskDev.Write(buf, kNewFSMinimumSectorSz);
+
+ return this->_AppendCatalogList(fileBlobs, blobCount);
+}
diff --git a/Private/NewBoot/BootKit/HW/ATA.hxx b/Private/NewBoot/BootKit/HW/ATA.hxx
index 9127e598..c557aeb8 100644
--- a/Private/NewBoot/BootKit/HW/ATA.hxx
+++ b/Private/NewBoot/BootKit/HW/ATA.hxx
@@ -34,6 +34,8 @@ class BootDeviceATA final : public Device {
public:
operator bool();
+ SizeT GetSectorsCount() noexcept;
+
BootDeviceATA& Read(Char* Buf, const SizeT& SecCount) override;
BootDeviceATA& Write(Char* Buf, const SizeT& SecCount) override;
@@ -41,4 +43,4 @@ class BootDeviceATA final : public Device {
private:
ATATrait mTrait;
-}; \ No newline at end of file
+};
diff --git a/Private/NewBoot/BootKit/Vendor/Qr.hxx b/Private/NewBoot/BootKit/Vendor/Qr.hxx
index ca5eb566..27db8060 100644
--- a/Private/NewBoot/BootKit/Vendor/Qr.hxx
+++ b/Private/NewBoot/BootKit/Vendor/Qr.hxx
@@ -12,6 +12,7 @@
#include <BootKit/Vendor/Support.hxx>
#include <Builtins/Toolbox/Toolbox.hxx>
#include <cstdint>
+#include <CompilerKit/Detail.hxx>
namespace qr {
inline uint8_t min_poly =
@@ -811,6 +812,8 @@ public:
explicit QrDelegate() = default;
~QrDelegate() = default;
+ NEWOS_COPY_DEFAULT(QrDelegate);
+
/// @brief Draw method delegate.
template <int V>
bool draw(Qr<V>& subject, int x, int y) noexcept {
diff --git a/Private/NewBoot/Source/HEL/AMD64/BootATA.cxx b/Private/NewBoot/Source/HEL/AMD64/BootATA.cxx
index d3573064..10d4272d 100644
--- a/Private/NewBoot/Source/HEL/AMD64/BootATA.cxx
+++ b/Private/NewBoot/Source/HEL/AMD64/BootATA.cxx
@@ -25,7 +25,7 @@
static Boolean kATADetected = false;
static Int32 kATADeviceType = kATADeviceCount;
-static CharacterTypeUTF8 kATAData[kATADataLen] = {0};
+static UInt16 kATAData[kATADataLen] = {0};
Boolean boot_ata_detected(Void);
@@ -82,8 +82,6 @@ ATAInit_Retry:
Out8(IO + ATA_REG_COMMAND, ATA_CMD_IDENTIFY);
- BSetMem(kATAData, 0, kATADataLen);
-
/// fetch serial info
/// model, speed, number of sectors...
@@ -269,3 +267,10 @@ BootDeviceATA& BootDeviceATA::Write(CharacterTypeUTF8* Buf, const SizeT& SectorS
* @return BootDeviceATA::ATATrait& the drive config.
*/
BootDeviceATA::ATATrait& BootDeviceATA::Leak() { return mTrait; }
+
+/***
+ @brief Getter, gets the number of sectors inside the drive.
+*/
+SizeT BootDeviceATA::GetSectorsCount() noexcept {
+ return kATAData[60] + kATAData[61];
+}
diff --git a/Private/NewBoot/Source/HEL/AMD64/Support.cxx b/Private/NewBoot/Source/HEL/AMD64/Support.cxx
index c6b62630..0508d491 100644
--- a/Private/NewBoot/Source/HEL/AMD64/Support.cxx
+++ b/Private/NewBoot/Source/HEL/AMD64/Support.cxx
@@ -28,5 +28,19 @@ EXTERN_C VoidPtr memcpy(void *dst, const void *src,
return dst;
}
+/// @brief strlen definition in C++.
+EXTERN_C size_t strlen(const char *whatToCheck) {
+ if (!whatToCheck || *whatToCheck == 0) return 0;
+
+ SizeT len = 0;
+
+ while (whatToCheck[len] != 0) {
+ ++len;
+ }
+
+ return len;
+}
+
+
/// @brief somthing specific to the microsoft ABI, regarding checking the stack.
EXTERN_C void ___chkstk_ms(void) {}
diff --git a/Private/NewBoot/Source/HEL/POWER/BootEPM.cxx b/Private/NewBoot/Source/HEL/POWER/BootEPM.cxx
deleted file mode 100644
index 72276ef9..00000000
--- a/Private/NewBoot/Source/HEL/POWER/BootEPM.cxx
+++ /dev/null
@@ -1,118 +0,0 @@
-/* -------------------------------------------
-
- Copyright Mahrouss Logic
-
-------------------------------------------- */
-
-#include <BootKit/BootKit.hxx>
-#include <FSKit/NewFS.hxx>
-
-#define kEPMSectorSize (1024U)
-#define kEPMSwapSize MIB(16)
-
-// {310E1FC7-2060-425D-BE7B-75A37CC679BC}
-STATIC const BlockGUID kEPMGuid = {
- 0x310e1fc7,
- 0x2060,
- 0x425d,
- {0xbe, 0x7b, 0x75, 0xa3, 0x7c, 0xc6, 0x79, 0xbc}};
-
-/// @brief Write epm partition to disk.
-/// @param namePart partition name
-/// @param namePartLength length of name
-/// @param bootDev disk interface.
-/// @return
-EXTERN_C Boolean boot_write_epm_partition(const Char* namePart, SizeT namePartLength,
- BootDevice* bootDev) {
- if (namePartLength > kEPMNameLength || !namePart) return No;
- if (!bootDev) return No;
-
- bootDev->Leak().mBase = kEPMStartPartitionBlk;
- bootDev->Leak().mSize = kEPMSectorSize;
-
- Char buf[kEPMSectorSize] = {0};
-
- bootDev->Read(buf, 1);
-
- BTextWriter writer;
-
- writer.Write(L"NewBoot: Checking for an EPM partition...\r\n");
-
- for (SizeT index = 0; index < kEPMMagicLength; ++index) {
- if (buf[index] != kEPMMagic[index]) {
- writer.Write(L"NewBoot: Writing an EPM partition...\r\n");
-
- BootBlockType* bootBlock = (BootBlockType*)buf;
-
- bootBlock->Version = kEPMRevision;
- bootBlock->NumBlocks = 2;
-
- for (SizeT i = 0; i < kEPMNameLength; ++i) {
- bootBlock->Magic[i] = kEPMMagic[i];
- }
-
- for (SizeT i = 0; i < namePartLength; ++i) {
- bootBlock->Name[i] = namePart[i];
- }
-
- bootBlock->LbaStart =
- sizeof(BootBlockType) + (sizeof(PartitionBlockType) * kEPMMaxBlks);
-
- bootBlock->SectorSz = kEPMSectorSize;
-
- bootBlock->Uuid = kEPMGuid;
-
- PartitionBlock* partBlock = (PartitionBlock*)(buf + sizeof(BootBlock));
-
- char* fsName = "NewFS";
- int fsNameLength = 6;
-
- for (SizeT i = 0; i < fsNameLength; ++i) {
- partBlock->Fs[i] = fsName[i];
- }
-
- partBlock->Version = kEPMNewOS;
-
- char* partName = "System HD";
- int partNameLength = 10;
-
- for (SizeT i = 0; i < partNameLength; ++i) {
- partBlock->Name[i] = partName[i];
- }
-
- partBlock->SectorSz = kEPMSectorSize;
- partBlock->LbaStart = kEPMStartPartitionBlk + kEPMSwapSize;
- partBlock->Version = kNewFSVersionInteger;
- partBlock->Kind = kNewFSPartitionTypeStandard;
- partBlock->LbaEnd = 0UL; ///! grows on the disk.
-
- PartitionBlock* swapBlock = (PartitionBlock*)(buf + sizeof(BootBlock) + sizeof(PartitionBlock));
-
- for (SizeT i = 0; i < fsNameLength; ++i) {
- swapBlock->Fs[i] = fsName[i];
- }
-
- swapBlock->Version = kEPMNewOS;
-
- partName = "Swap HD";
- partNameLength = 8;
-
- for (SizeT i = 0; i < partNameLength; ++i) {
- swapBlock->Name[i] = partName[i];
- }
-
- swapBlock->SectorSz = kEPMSectorSize;
- swapBlock->LbaStart = kEPMStartPartitionBlk;
- swapBlock->Version = kNewFSVersionInteger;
- swapBlock->Kind = kNewFSPartitionTypePage;
- swapBlock->LbaEnd = kEPMSwapSize; /// 4 MIB swap partition.
-
- bootDev->Write(buf, 1);
-
- return No;
- }
- }
-
- writer.Write(L"NewBoot: Partition found, everything's OK.\r\n");
- return Yes;
-}
diff --git a/Private/NewBoot/Source/HEL/POWER/BootCoreBoot.S b/Private/NewBoot/Source/HEL/POWER/CoreBootStartup.S
index c611467d..41fc6ae2 100644
--- a/Private/NewBoot/Source/HEL/POWER/BootCoreBoot.S
+++ b/Private/NewBoot/Source/HEL/POWER/CoreBootStartup.S
@@ -10,7 +10,7 @@
/* NewBoot boot header begin */
boot_hdr_mag:
- .ascii "LX"
+ .ascii "CB"
boot_hdr_name:
// it has to match ten bytes.
.asciz "NewBoot\0\0\0"
diff --git a/Private/NewBoot/Source/makefile b/Private/NewBoot/Source/makefile
index 11c1da75..7ed42abd 100644
--- a/Private/NewBoot/Source/makefile
+++ b/Private/NewBoot/Source/makefile
@@ -51,6 +51,7 @@ all: compile-amd64
$(DD) if=$(KERNEL_OBJ) of=$(BOOT_LOADER) bs=1 seek=0 conv=notrunc
$(COPY) $(BOOT_LOADER) CDROM/EFI/BOOT/BOOTX64.EFI
$(COPY) $(BOOT_LOADER) CDROM/EFI/BOOT/NEWBOOT.EFI
+ $(COPY) ../../$(KERNEL) CDROM/$(KERNEL)
$(COPY) $(BOOT_LOADER) ../../Root/Boot/$(BOOT_LOADER)
ifneq ($(DEBUG_SUPPORT), )
@@ -68,8 +69,8 @@ run-efi-amd64:
.PHONY: epm-img
epm-img:
- qemu-img create -f raw $(IMG) 256M
- qemu-img create -f raw $(IMG_2) 512M
+ qemu-img create -f qcow2 $(IMG) 256M
+ qemu-img create -f qcow2 $(IMG_2) 512M
.PHONY: download-edk
download-edk: