From daca502ce032a103d766485308cdf819cd2bb043 Mon Sep 17 00:00:00 2001 From: Julien CLEMENT Date: Sun, 11 Dec 2022 02:22:22 +0100 Subject: [PATCH] Adding base consts and macros for atapi driver Signed-off-by: Julien CLEMENT --- src/drivers/atapi/mod.rs | 47 ++++++++++++++++++++++++++++++++++++++++ src/drivers/mod.rs | 1 + 2 files changed, 48 insertions(+) diff --git a/src/drivers/atapi/mod.rs b/src/drivers/atapi/mod.rs index 849e611..17f6b91 100644 --- a/src/drivers/atapi/mod.rs +++ b/src/drivers/atapi/mod.rs @@ -3,3 +3,50 @@ const CD_SECTOR_SIZE: usize = 2048; const ATA_BUS_PRIMARY: u16= 0x1f0; const ATA_BUS_SECONDARY: u16 = 0x170; + +const ATA_DRIVE_MASTER: u16 = 0xa0; +const ATA_DRIVE_SLAVE: u16 = 0xb0; + +macro_rules! ATA_DATA { + ($reg:expr) => (reg); +} + +macro_rules! ATA_ERROR { + ($reg:expr) => (reg + 1); // read +} + +macro_rules! ATA_FEATURES { + ($reg:expr) => (reg + 1); // write +} + +macro_rules! ATA_SECTOR_COUNT { + ($reg:expr) => (reg + 2); +} + +macro_rules! ATA_ADDRESS1 { + ($reg:expr) => (reg + 3); +} + +macro_rules! ATA_ADDRESS2 { + ($reg:expr) => (reg + 4); +} + +macro_rules! ATA_ADDRESS3 { + ($reg:expr) => (reg + 5); +} + +macro_rules! ATA_DRIVE_SELECT { + ($reg:expr) => (reg + 6); +} + +macro_rules! ATA_STATUS { + ($reg:expr) => (reg + 7); // read +} + +macro_rules! ATA_COMMAND { + ($reg:expr) => (reg + 7); // write +} + +macro_rules! ATA_DCR { + ($reg:expr) => (reg + 0x206); +} \ No newline at end of file diff --git a/src/drivers/mod.rs b/src/drivers/mod.rs index fffbe08..238be6f 100644 --- a/src/drivers/mod.rs +++ b/src/drivers/mod.rs @@ -1,2 +1,3 @@ pub mod serial; pub mod vga; +pub mod atapi;