summaryrefslogtreecommitdiff
path: root/kernel/include
diff options
context:
space:
mode:
authorFreya Murphy <freya@freyacat.org>2025-04-20 21:54:39 -0400
committerFreya Murphy <freya@freyacat.org>2025-04-20 23:44:40 -0400
commitff505969479f0cda3b605150c8d41327712178f7 (patch)
treef90baa7b6e907fa227c03f2c80e006e6a7fd3a73 /kernel/include
parentdont use in[s] instructions or rep in c (diff)
downloadcomus-ff505969479f0cda3b605150c8d41327712178f7.tar.gz
comus-ff505969479f0cda3b605150c8d41327712178f7.tar.bz2
comus-ff505969479f0cda3b605150c8d41327712178f7.zip
make stuff public
Diffstat (limited to 'kernel/include')
-rw-r--r--kernel/include/comus/drivers/ata.h46
1 files changed, 42 insertions, 4 deletions
diff --git a/kernel/include/comus/drivers/ata.h b/kernel/include/comus/drivers/ata.h
index 06d3e78..5f97df3 100644
--- a/kernel/include/comus/drivers/ata.h
+++ b/kernel/include/comus/drivers/ata.h
@@ -1,6 +1,3 @@
-#ifndef ATA_H_
-#define ATA_H_
-
/*
* @file ata.h
*
@@ -10,7 +7,32 @@
* ATA driver
*/
-#include <stdbool.h>
+#ifndef ATA_H_
+#define ATA_H_
+
+#include <stdint.h>
+
+struct ide_channel {
+ uint16_t io_base;
+ uint16_t control_base;
+ uint16_t bus_master_ide_base;
+ uint8_t no_interrupt;
+};
+
+struct ide_device {
+ uint8_t is_reserved; // 0 (Empty) or 1 (This Drive really exists).
+ uint8_t channel_idx; // 0 (Primary Channel) or 1 (Secondary Channel).
+ uint8_t drive_idx; // 0 (Master Drive) or 1 (Slave Drive).
+ uint16_t type; // 0: ATA, 1:ATAPI.
+ uint16_t drive_signature;
+ uint16_t features;
+ uint32_t supported_command_sets;
+ uint32_t size_in_sectors;
+ uint8_t model_str[41];
+};
+
+extern struct ide_channel ide_channels[2];
+extern struct ide_device ide_devices[4];
/**
* @returns 0 on success, 1 on failure
@@ -18,6 +40,22 @@
int ata_init(void);
/**
+ * reads a number of sectors from the provided IDE/ATA device
+ *
+ * @returns 0 on success or an error code on failure
+ */
+int ide_device_read_sectors(struct ide_device *dev, uint8_t numsects,
+ uint32_t lba, uint16_t buf[numsects * 256]);
+
+/**
+ * writes a number of sectors to the provided IDE/ATA device
+ *
+ * @returns 0 on success or an error code on failure
+ */
+int ide_device_write_sectors(struct ide_device *dev, uint8_t numsects,
+ uint32_t lba, uint16_t buf[numsects * 256]);
+
+/**
* report all ata devices to console
*/
void ata_report(void);