summaryrefslogtreecommitdiffhomepage
path: root/src/boot
diff options
context:
space:
mode:
authorAmlal El Mahrouss <amlal@nekernel.org>2025-11-29 15:01:34 -0500
committerAmlal El Mahrouss <amlal@nekernel.org>2025-11-29 15:01:34 -0500
commitceabd82ac8e796249feacf39c836034ed5e11c6d (patch)
treee446d471a0eaf4ed7ac67e878ce4fb02334a2acb /src/boot
parent0376382a848ef5ebbb0e02428c9d1df8a099d8b4 (diff)
chore: source code review and fixes.
Signed-off-by: Amlal El Mahrouss <amlal@nekernel.org>
Diffstat (limited to 'src/boot')
-rw-r--r--src/boot/BootKit/BootKit.h20
-rw-r--r--src/boot/BootKit/HW/ATA.h6
-rw-r--r--src/boot/BootKit/HW/SATA.h2
-rw-r--r--src/boot/BootKit/Qr.h6
-rw-r--r--src/boot/modules/BootNet/BootNet.cc4
-rw-r--r--src/boot/src/BootThread.cc6
-rw-r--r--src/boot/src/HEL/AMD64/BootATA.cc19
-rw-r--r--src/boot/src/HEL/AMD64/BootEFI.cc2
-rw-r--r--src/boot/src/HEL/AMD64/BootSATA.cc2
-rw-r--r--src/boot/src/HEL/ARM64/BootEFI.cc2
-rw-r--r--src/boot/src/HEL/ARM64/BootPlatform.cc3
-rw-r--r--src/boot/src/New+Delete.cc7
12 files changed, 37 insertions, 42 deletions
diff --git a/src/boot/BootKit/BootKit.h b/src/boot/BootKit/BootKit.h
index e1a2b628..55392ef6 100644
--- a/src/boot/BootKit/BootKit.h
+++ b/src/boot/BootKit/BootKit.h
@@ -40,7 +40,7 @@
/***********************************************************************************/
namespace Boot {
-void ThrowError(const WideChar* errorCode, const WideChar* reason) noexcept;
+void ThrowError(const WideChar* errorCode, const WideChar* reason);
class BootTextWriter;
class BootFileReader;
@@ -205,7 +205,7 @@ class BDiskFormatFactory final {
Boolean Format(const Char* part_name);
/// @brief check if partition is good.
- Bool IsPartitionValid() noexcept {
+ Bool IsPartitionValid() {
#if defined(BOOTZ_EPM_SUPPORT)
fDiskDev.Leak().mBase = (kEPMBootBlockLba);
fDiskDev.Leak().mSize = sizeof(EPM_PART_BLOCK);
@@ -293,16 +293,16 @@ inline Boolean BDiskFormatFactory<BootDev>::Format(const Char* part_name) {
CopyMem(gpt_part->Signature, reinterpret_cast<VoidPtr>(const_cast<Char*>(kMagicGPT)),
StrLen(kMagicGPT));
- gpt_part->Revision = 0x00010000;
+ gpt_part->Revision = 0x00010000;
gpt_part->HeaderSize = sizeof(GPT_PARTITION_TABLE);
gpt_part->CRC32 = 0x00000000;
- gpt_part->Reserved1 = 0x00000000;
- gpt_part->LBAHeader = 0x00000000;
- gpt_part->LBAAltHeader = 0x00000000;
+ gpt_part->Reserved1 = 0x00000000;
+ gpt_part->LBAHeader = 0x00000000;
+ gpt_part->LBAAltHeader = 0x00000000;
gpt_part->FirstGPTEntry = 0x00000000;
- gpt_part->LastGPTEntry = 0x00000000;
+ gpt_part->LastGPTEntry = 0x00000000;
gpt_part->Guid.Data1 = 0x00000000;
gpt_part->Guid.Data2 = 0x0000;
@@ -312,10 +312,10 @@ inline Boolean BDiskFormatFactory<BootDev>::Format(const Char* part_name) {
gpt_part->Revision = 0x00010000;
- gpt_part->StartingLBA = 0x00000000;
+ gpt_part->StartingLBA = 0x00000000;
gpt_part->NumPartitionEntries = 0x00000000;
- gpt_part->SizeOfEntries = 0x00000000;
- gpt_part->CRC32PartEntry = 0x00000000;
+ gpt_part->SizeOfEntries = 0x00000000;
+ gpt_part->CRC32PartEntry = 0x00000000;
SetMem(gpt_part->Reserved2, 0, kSectorAlignGPT_PartTbl);
diff --git a/src/boot/BootKit/HW/ATA.h b/src/boot/BootKit/HW/ATA.h
index 25629869..7ebf296d 100644
--- a/src/boot/BootKit/HW/ATA.h
+++ b/src/boot/BootKit/HW/ATA.h
@@ -18,7 +18,7 @@ class BootDeviceATA final : public Device {
kSecondary = ATA_SECONDARY_IO,
};
- explicit BootDeviceATA() noexcept;
+ explicit BootDeviceATA();
~BootDeviceATA() = default;
enum { kSectorSize = kATASectorSize };
@@ -34,8 +34,8 @@ class BootDeviceATA final : public Device {
public:
operator bool();
- SizeT GetSectorsCount() noexcept;
- SizeT GetDiskSize() noexcept;
+ SizeT GetSectorsCount();
+ SizeT GetDiskSize();
BootDeviceATA& Read(Char* Buf, SizeT SecCount) override;
BootDeviceATA& Write(Char* Buf, SizeT SecCount) override;
diff --git a/src/boot/BootKit/HW/SATA.h b/src/boot/BootKit/HW/SATA.h
index 07ce7611..68ed30c8 100644
--- a/src/boot/BootKit/HW/SATA.h
+++ b/src/boot/BootKit/HW/SATA.h
@@ -14,7 +14,7 @@
class BootDeviceSATA final {
public:
- explicit BootDeviceSATA() noexcept;
+ explicit BootDeviceSATA();
~BootDeviceSATA() = default;
NE_COPY_DEFAULT(BootDeviceSATA)
diff --git a/src/boot/BootKit/Qr.h b/src/boot/BootKit/Qr.h
index f537aa5e..f5ac5f2e 100644
--- a/src/boot/BootKit/Qr.h
+++ b/src/boot/BootKit/Qr.h
@@ -235,7 +235,7 @@ template <int V>
struct Qr {
private:
friend class QrDelegate;
- bool draw(int x, int y) noexcept;
+ bool draw(int x, int y);
public:
constexpr auto side_size() const { return SIDE; }
@@ -303,7 +303,7 @@ bool Qr<V>::module(int x, int y) {
/// @brief draw a new QR code.
template <int V>
-bool Qr<V>::draw(int whereX, int whereY) noexcept {
+bool Qr<V>::draw(int whereX, int whereY) {
if (!this->status) return false; // it may be invalid.
cg_init();
@@ -784,7 +784,7 @@ class QrDelegate final {
/// @brief Draw method delegate.
template <Int32 V>
- bool draw(Qr<V>& subject, Int32 x, Int32 y) noexcept {
+ bool draw(Qr<V>& subject, Int32 x, Int32 y) {
return subject.draw(x, y);
}
};
diff --git a/src/boot/modules/BootNet/BootNet.cc b/src/boot/modules/BootNet/BootNet.cc
index 20d1a6c9..21981ad3 100644
--- a/src/boot/modules/BootNet/BootNet.cc
+++ b/src/boot/modules/BootNet/BootNet.cc
@@ -12,8 +12,8 @@
#include <FirmwareKit/EFI/API.h>
#include <modules/BootNet/BootNet.h>
-STATIC EFI_GUID kEfiSimpleProtoGUID = EFI_SIMPLE_NETWORK_PROTOCOL_GUID;
-STATIC EFI_SIMPLE_NETWORK_PROTOCOL* kEfiProtocol = nullptr;
+STATIC EFI_GUID kEfiSimpleProtoGUID = EFI_SIMPLE_NETWORK_PROTOCOL_GUID;
+STATIC EFI_SIMPLE_NETWORK_PROTOCOL* kEfiProtocol = nullptr;
STATIC Void bootnet_read_ip_packet(BOOTNET_INTERNET_HEADER inet,
BOOTNET_INTERNET_HEADER** inet_out);
diff --git a/src/boot/src/BootThread.cc b/src/boot/src/BootThread.cc
index 55aebd49..336c5f9e 100644
--- a/src/boot/src/BootThread.cc
+++ b/src/boot/src/BootThread.cc
@@ -82,8 +82,8 @@ BootThread::BootThread(VoidPtr blob) : fStartAddress(nullptr), fBlob(blob) {
LDR_SECTION_HEADER_PTR sectPtr =
(LDR_SECTION_HEADER_PTR) (((Char*) opt_header_ptr) + header_ptr->SizeOfOptionalHeader);
- constexpr auto sectionForCode = ".text";
- constexpr auto sectionForBootZ = ".ldr";
+ constexpr auto sectionForCode = ".text";
+ constexpr auto sectionForBootZ = ".ldr";
constexpr auto sectionForBootZAlt = ".botz";
for (SizeT sectIndex = 0; sectIndex < numSecs; ++sectIndex) {
@@ -113,7 +113,7 @@ BootThread::BootThread(VoidPtr blob) : fStartAddress(nullptr), fBlob(blob) {
#endif
} else if (StrCmp(sectionForBootZ, sect->Name) == 0 ||
- StrCmp(sectionForBootZAlt, sect->Name) == 0) {
+ StrCmp(sectionForBootZAlt, sect->Name) == 0) {
struct HANDOVER_INFORMATION_STUB {
UInt64 HandoverMagic;
UInt32 HandoverType;
diff --git a/src/boot/src/HEL/AMD64/BootATA.cc b/src/boot/src/HEL/AMD64/BootATA.cc
index 02051471..0276ca4c 100644
--- a/src/boot/src/HEL/AMD64/BootATA.cc
+++ b/src/boot/src/HEL/AMD64/BootATA.cc
@@ -88,8 +88,7 @@ ATAInit_Retry:
/// fetch serial info
/// model, speed, number of sectors...
- while (!(rt_in8(IO + ATA_REG_STATUS) & ATA_SR_DRQ))
- ;
+ while (!(rt_in8(IO + ATA_REG_STATUS) & ATA_SR_DRQ));
for (SizeT indexData = 0ul; indexData < kATADataLen; ++indexData) {
kATAData[indexData] = rt_in16(IO + ATA_REG_DATA);
@@ -115,15 +114,14 @@ Void boot_ata_read(UInt64 Lba, UInt16 IO, UInt8 Master, CharacterTypeASCII* Buf,
rt_out8(IO + ATA_REG_SEC_COUNT0, ((Size + SectorSz) / SectorSz));
- rt_out8(IO + ATA_REG_LBA0, (Lba) &0xFF);
+ rt_out8(IO + ATA_REG_LBA0, (Lba) & 0xFF);
rt_out8(IO + ATA_REG_LBA1, (Lba) >> 8);
rt_out8(IO + ATA_REG_LBA2, (Lba) >> 16);
rt_out8(IO + ATA_REG_LBA3, (Lba) >> 24);
rt_out8(IO + ATA_REG_COMMAND, ATA_CMD_READ_PIO);
- while (!(rt_in8(IO + ATA_REG_STATUS) & ATA_SR_DRQ))
- ;
+ while (!(rt_in8(IO + ATA_REG_STATUS) & ATA_SR_DRQ));
for (SizeT IndexOff = 0; IndexOff < Size; IndexOff += 2) {
boot_ata_wait_io(IO);
@@ -149,15 +147,14 @@ Void boot_ata_write(UInt64 Lba, UInt16 IO, UInt8 Master, CharacterTypeASCII* Buf
rt_out8(IO + ATA_REG_SEC_COUNT0, ((Size + (SectorSz)) / SectorSz));
- rt_out8(IO + ATA_REG_LBA0, (Lba) &0xFF);
+ rt_out8(IO + ATA_REG_LBA0, (Lba) & 0xFF);
rt_out8(IO + ATA_REG_LBA1, (Lba) >> 8);
rt_out8(IO + ATA_REG_LBA2, (Lba) >> 16);
rt_out8(IO + ATA_REG_LBA3, (Lba) >> 24);
rt_out8(IO + ATA_REG_COMMAND, ATA_CMD_WRITE_PIO);
- while (!(rt_in8(IO + ATA_REG_STATUS) & ATA_SR_DRQ))
- ;
+ while (!(rt_in8(IO + ATA_REG_STATUS) & ATA_SR_DRQ));
for (SizeT IndexOff = 0; IndexOff < Size; IndexOff += 2) {
boot_ata_wait_io(IO);
@@ -191,7 +188,7 @@ Boolean boot_ata_detected(Void) {
* @brief ATA Device constructor.
* @param void none.
*/
-BootDeviceATA::BootDeviceATA() noexcept {
+BootDeviceATA::BootDeviceATA() {
if (boot_ata_init(ATA_PRIMARY_IO, true, this->Leak().mBus, this->Leak().mMaster) ||
boot_ata_init(ATA_SECONDARY_IO, true, this->Leak().mBus, this->Leak().mMaster)) {
kATADetected = true;
@@ -260,10 +257,10 @@ BootDeviceATA::ATATrait& BootDeviceATA::Leak() {
/***
@brief Getter, gets the number of sectors inside the drive.
*/
-SizeT BootDeviceATA::GetSectorsCount() noexcept {
+SizeT BootDeviceATA::GetSectorsCount() {
return (kATAData[61] << 16) | kATAData[60];
}
-SizeT BootDeviceATA::GetDiskSize() noexcept {
+SizeT BootDeviceATA::GetDiskSize() {
return this->GetSectorsCount() * BootDeviceATA::kSectorSize;
}
diff --git a/src/boot/src/HEL/AMD64/BootEFI.cc b/src/boot/src/HEL/AMD64/BootEFI.cc
index 331ded5f..7558ec62 100644
--- a/src/boot/src/HEL/AMD64/BootEFI.cc
+++ b/src/boot/src/HEL/AMD64/BootEFI.cc
@@ -32,7 +32,7 @@ EXTERN_C Kernel::VoidPtr boot_read_cr3(); // @brief Page directory inside cr3 r
/**
@brief Finds and stores the GOP object.
*/
-STATIC Bool boot_init_fb() noexcept {
+STATIC Bool boot_init_fb() {
kGopGuid = EFI_GUID(EFI_GRAPHICS_OUTPUT_PROTOCOL_GUID);
kGop = nullptr;
diff --git a/src/boot/src/HEL/AMD64/BootSATA.cc b/src/boot/src/HEL/AMD64/BootSATA.cc
index 1364c58b..b184e02e 100644
--- a/src/boot/src/HEL/AMD64/BootSATA.cc
+++ b/src/boot/src/HEL/AMD64/BootSATA.cc
@@ -38,7 +38,7 @@ using namespace Boot;
* @brief ATA Device constructor.
* @param void none.
*/
-BootDeviceSATA::BootDeviceSATA() noexcept {
+BootDeviceSATA::BootDeviceSATA() {
UInt16 pi = 0u;
drv_std_init(pi);
}
diff --git a/src/boot/src/HEL/ARM64/BootEFI.cc b/src/boot/src/HEL/ARM64/BootEFI.cc
index ac5eb030..7f4b152c 100644
--- a/src/boot/src/HEL/ARM64/BootEFI.cc
+++ b/src/boot/src/HEL/ARM64/BootEFI.cc
@@ -38,7 +38,7 @@ EXTERN EfiBootServices* BS;
/**
@brief Finds and stores the GOP object.
*/
-STATIC Bool boot_init_fb() noexcept {
+STATIC Bool boot_init_fb() {
kGopGuid = EFI_GUID(EFI_GRAPHICS_OUTPUT_PROTOCOL_GUID);
kGop = nullptr;
diff --git a/src/boot/src/HEL/ARM64/BootPlatform.cc b/src/boot/src/HEL/ARM64/BootPlatform.cc
index 2ad9b776..9da3a2a6 100644
--- a/src/boot/src/HEL/ARM64/BootPlatform.cc
+++ b/src/boot/src/HEL/ARM64/BootPlatform.cc
@@ -13,8 +13,7 @@
using namespace Boot;
EXTERN_C void rt_halt() {
- while (Yes)
- ;
+ while (Yes);
}
EXTERN_C void rt_cli() {}
diff --git a/src/boot/src/New+Delete.cc b/src/boot/src/New+Delete.cc
index a66d8464..dcbd31de 100644
--- a/src/boot/src/New+Delete.cc
+++ b/src/boot/src/New+Delete.cc
@@ -17,8 +17,7 @@
void* operator new(size_t sz) {
void* buf = nullptr;
- while (BS->AllocatePool(EfiMemoryType::EfiLoaderData, sz, &buf) != kEfiOk)
- ;
+ while (BS->AllocatePool(EfiMemoryType::EfiLoaderData, sz, &buf) != kEfiOk);
return buf;
}
@@ -35,7 +34,7 @@ void* operator new[](size_t sz) {
/// @brief Deletes the object.
/// @param buf the object.
-void operator delete(void* buf) noexcept {
+void operator delete(void* buf) {
if (!buf) return;
BS->FreePool(buf);
@@ -43,7 +42,7 @@ void operator delete(void* buf) noexcept {
/// @brief Deletes the object.
/// @param buf the object.
-void operator delete[](void* buf) noexcept {
+void operator delete[](void* buf) {
if (!buf) return;
BS->FreePool(buf);