feat: disk read/write support for both ATA and ATAPI device
[lunaix-os.git] / lunaix-os / includes / hal / ahci / sata.h
index 135f3ebb58ca2819638bbed3d14d3741b846f5d7..f898d322add8afb22ac9065552bce929f9891905 100644 (file)
@@ -6,7 +6,15 @@
 #define SATA_REG_FIS_D2H 0x34
 #define SATA_REG_FIS_H2D 0x27
 #define SATA_REG_FIS_COMMAND 0x80
-#define SATA_LBA_COMPONENT(lba, offset) ((((lba_lo) >> (offset)) & 0xff))
+#define SATA_LBA_COMPONENT(lba, offset) ((((lba) >> (offset)) & 0xff))
+
+#define ATA_IDENTIFY_DEVICE 0xec
+#define ATA_IDENTIFY_PAKCET_DEVICE 0xa1
+#define ATA_PACKET 0xa0
+#define ATA_READ_DMA_EXT 0xc8
+#define ATA_READ_DMA 0x25
+#define ATA_WRITE_DMA_EXT 0xca
+#define ATA_WRITE_DMA 0x35
 
 struct sata_fis_head
 {
@@ -40,8 +48,19 @@ struct sata_data_fis
 void
 sata_create_fis(struct sata_reg_fis* cmd_fis,
                 uint8_t command,
-                uint32_t lba_lo,
-                uint32_t lba_hi,
+                uint64_t lba,
                 uint16_t sector_count);
 
+int
+sata_read_buffer(struct hba_port* port,
+                 uint64_t lba,
+                 void* buffer,
+                 uint32_t size);
+
+int
+sata_write_buffer(struct hba_port* port,
+                  uint64_t lba,
+                  void* buffer,
+                  uint32_t size);
+
 #endif /* __LUNAIX_SATA_H */