diff options
Diffstat (limited to 'Private/NewBoot/BootKit')
| -rw-r--r-- | Private/NewBoot/BootKit/Arch/ATA.hxx | 15 | ||||
| -rw-r--r-- | Private/NewBoot/BootKit/BootKit.hxx | 39 |
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 |
