summaryrefslogtreecommitdiffhomepage
path: root/Private/NewBoot/BootKit
diff options
context:
space:
mode:
authorAmlal El Mahrouss <amlalelmahrouss@icloud.com>2024-02-01 22:29:30 +0100
committerAmlal El Mahrouss <amlalelmahrouss@icloud.com>2024-02-01 22:29:30 +0100
commit025593a068bc83f64386325b826179cafd95a03f (patch)
treed6724e71e4cb855dc747699cb380c01b3e7a10bf /Private/NewBoot/BootKit
parent9700c31e4958856ea9e4fa755a43d196fcf50614 (diff)
Bootloader: Improve PATA support, but will use UEFI SimpleFile to get
the kernel image. Signed-off-by: Amlal El Mahrouss <amlalelmahrouss@icloud.com>
Diffstat (limited to 'Private/NewBoot/BootKit')
-rw-r--r--Private/NewBoot/BootKit/Arch/ATA.hxx15
-rw-r--r--Private/NewBoot/BootKit/BootKit.hxx39
2 files changed, 47 insertions, 7 deletions
diff --git a/Private/NewBoot/BootKit/Arch/ATA.hxx b/Private/NewBoot/BootKit/Arch/ATA.hxx
index 8327f5c8..6e692c3d 100644
--- a/Private/NewBoot/BootKit/Arch/ATA.hxx
+++ b/Private/NewBoot/BootKit/Arch/ATA.hxx
@@ -95,6 +95,9 @@ using namespace HCore;
#define ATA_PRIMARY 0x00
#define ATA_SECONDARY 0x01
+#define ATA_CYL_LOW 4
+#define ATA_CYL_HIGH 5
+
// IO Direction
#define ATA_READ 0x00
#define ATA_WRITE 0x013
@@ -114,25 +117,25 @@ UInt16 ATAReadLba(UInt32 Lba, UInt8 Bus, Boolean Master);
Void ATAWriteLba(UInt16 Byte, UInt32 Lba, UInt8 Bus, Boolean Master);
Boolean ATAIsDetected(Void);
-class ATAHelper final {
+class BATADevice final {
public:
enum {
kPrimary = ATA_PRIMARY,
kSecondary = ATA_SECONDARY,
};
- explicit ATAHelper() noexcept;
+ explicit BATADevice() noexcept;
- HCORE_COPY_DEFAULT(ATAHelper);
+ HCORE_COPY_DEFAULT(BATADevice);
struct ATATraits final {
SizeT mBase{1024};
- UInt8 mBus{kPrimary};
+ UInt16 mBus{kPrimary};
Boolean mMaster{false};
};
- ATAHelper& Read(WideChar*, const SizeT&);
- ATAHelper& Write(WideChar*, const SizeT&);
+ BATADevice& Read(WideChar*, const SizeT&);
+ BATADevice& Write(WideChar*, const SizeT&);
ATATraits& Traits();
diff --git a/Private/NewBoot/BootKit/BootKit.hxx b/Private/NewBoot/BootKit/BootKit.hxx
index 73bbce37..edd8015b 100644
--- a/Private/NewBoot/BootKit/BootKit.hxx
+++ b/Private/NewBoot/BootKit/BootKit.hxx
@@ -83,7 +83,7 @@ class BFileReader final {
CharacterType mPath[255];
private:
- ATAHelper mHelper;
+ BATADevice mDevice;
};
/***********************************************************************************/
@@ -92,3 +92,40 @@ class BFileReader final {
#include <BootKit/Platform.hxx>
#include <BootKit/Protocol.hxx>
+
+#ifdef __EFI_x86_64__
+
+inline void out8(UInt16 port, UInt8 value) {
+ asm volatile("outb %%al, %1" : : "a"(value), "Nd"(port) : "memory");
+}
+
+inline void out16(UInt16 port, UInt16 value) {
+ asm volatile("outw %%ax, %1" : : "a"(value), "Nd"(port) : "memory");
+}
+
+inline void out32(UInt16 port, UInt32 value) {
+ asm volatile("outl %%eax, %1" : : "a"(value), "Nd"(port) : "memory");
+}
+
+inline UInt8 in8(UInt16 port) {
+ UInt8 value = 0UL;
+ asm volatile("inb %1, %%al" : "=a"(value) : "Nd"(port) : "memory");
+
+ return value;
+}
+
+inline UInt16 in16(UInt16 port) {
+ UInt16 value = 0UL;
+ asm volatile("inw %1, %%ax" : "=a"(value) : "Nd"(port) : "memory");
+
+ return value;
+}
+
+inline UInt32 in32(UInt16 port) {
+ UInt32 value = 0UL;
+ asm volatile("inl %1, %%eax" : "=a"(value) : "Nd"(port) : "memory");
+
+ return value;
+}
+
+#endif // __EFI_x86_64__ \ No newline at end of file