ata.h 1.2 KB

123456789101112131415161718192021222324
  1. /* ATA PIO driver (polling, no IRQ). Primary 0x1F0 / secondary 0x170. */
  2. #ifndef ATA_H
  3. #define ATA_H
  4. /* Probe an ATA device (bus 0=primary,1=secondary; unit 0=master,1=slave).
  5. * Returns 0 and fills total_sectors/model if an ATA disk is present, else -1. */
  6. int ata_probe(int bus, int unit, unsigned int *total_sectors, char model[41]);
  7. /* Configure the channel port bases. Scans for a PCI IDE interface
  8. * (class 01:01): in native mode (prog-if bit 0/2) the command/control blocks
  9. * live in BAR0..BAR3, otherwise the fixed legacy ports are used. Idempotent;
  10. * call before ata_probe(). */
  11. void ata_init_ports(void);
  12. /* Parse an IDENTIFY DEVICE response (256 words): fills total_sectors (clamped
  13. * to 32 bits) and a trimmed 40-char model string. Returns 0 for an ATA disk,
  14. * -1 for a non-disk (e.g. ATAPI). Shared by the PATA and AHCI drivers. */
  15. int ata_identify_parse(const unsigned short *id, unsigned int *total_sectors, char model[41]);
  16. /* Read/write sectors via ATA PIO. Return 0 on success, -1 on error. */
  17. int ata_read_sectors(int bus, int unit, unsigned int lba, void *buf, unsigned int count);
  18. int ata_write_sectors(int bus, int unit, unsigned int lba, const void *buf, unsigned int count);
  19. #endif