diff options
author | Alexis211 <alexis211@gmail.com> | 2009-11-29 16:22:01 +0100 |
---|---|---|
committer | Alexis211 <alexis211@gmail.com> | 2009-11-29 16:22:01 +0100 |
commit | 41874c455c755f00ca73c2e2ee5ab8c4b0dbe61e (patch) | |
tree | 95986807bde312286c28297059873a6c66b72566 /Source/Kernel/Devices/ATA/ATAController.class.h | |
parent | a913d4c2cb4daf10c0eac4d548fccb26b2a9f099 (diff) | |
download | Melon-41874c455c755f00ca73c2e2ee5ab8c4b0dbe61e.tar.gz Melon-41874c455c755f00ca73c2e2ee5ab8c4b0dbe61e.zip |
Reading from HDD is now possible !
Diffstat (limited to 'Source/Kernel/Devices/ATA/ATAController.class.h')
-rw-r--r-- | Source/Kernel/Devices/ATA/ATAController.class.h | 47 |
1 files changed, 47 insertions, 0 deletions
diff --git a/Source/Kernel/Devices/ATA/ATAController.class.h b/Source/Kernel/Devices/ATA/ATAController.class.h new file mode 100644 index 0000000..a12b835 --- /dev/null +++ b/Source/Kernel/Devices/ATA/ATAController.class.h @@ -0,0 +1,47 @@ +#ifndef DEF_ATACONTROLLER_CLASS_H +#define DEF_ATACONTROLLER_CLASS_H + +#include <Devices/Device.proto.h> + +#define ATA_BUS1_BASE 0x1F0 +#define ATA_BUS2_BASE 0x170 + +#define ATA_PORT_DATA 0 +#define ATA_PORT_FEATURES_ERROR 1 +#define ATA_PORT_SECT_COUNT 2 +#define ATA_PORT_PARTIAL1 3 +#define ATA_PORT_PARTIAL2 4 +#define ATA_PORT_PARTIAL3 5 +#define ATA_PORT_DRIVE_SELECT 6 +#define ATA_PORT_COMMAND 7 + +#define ATA_CMD_IDENTIFY 0xEC +#define ATA_CMD_READ 0x20 +#define ATA_CMD_WRITE 0x30 + +class ATADrive; + +class ATAController : public Device { + friend class ATADrive; + private: + ATAController(u32int base, u8int number); + + u32int m_base; + u8int m_number; + + ATADrive* m_drives[2]; + + void writeWord(u16int port, u16int word) { Sys::outw(m_base + port, word); } + void writeByte(u16int port, u8int byte) { Sys::outb(m_base + port, byte); } + u8int readByte(u16int port) { return Sys::inb(m_base + port); } + u16int readWord(u16int port) { return Sys::inw(m_base + port); } + + void identify(bool slave); //Identifies a drive and adds it to m_drives + + public: + static void detect(); + String getClass(); + String getName(); +}; + +#endif |