From ff505969479f0cda3b605150c8d41327712178f7 Mon Sep 17 00:00:00 2001 From: Freya Murphy Date: Sun, 20 Apr 2025 21:54:39 -0400 Subject: make stuff public --- kernel/include/comus/drivers/ata.h | 46 ++++++++++++++++++++++++++++++++++---- 1 file changed, 42 insertions(+), 4 deletions(-) (limited to 'kernel/include') 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,13 +7,54 @@ * ATA driver */ -#include +#ifndef ATA_H_ +#define ATA_H_ + +#include + +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 */ 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 */ -- cgit v1.2.3-freya