ahci.h 1.1 KB

12345678910111213141516171819202122232425262728293031
  1. /* AHCI (SATA) driver: polled, no IRQs, no NCQ.
  2. * Finds the first AHCI controller (PCI class 01:06:01), brings its ports up
  3. * and exposes the attached ATA disks. Read/write use DMA (READ/WRITE DMA EXT,
  4. * LBA48) through a bounce buffer. */
  5. #ifndef AHCI_H
  6. #define AHCI_H
  7. #define AHCI_MAX_DISKS 8
  8. struct ahci_disk {
  9. unsigned int port; /* controller port number */
  10. unsigned int sectors; /* total sectors (clamped to 32 bits) */
  11. char model[41];
  12. };
  13. /* Initialise the first AHCI controller. Idempotent; returns 0 if a controller
  14. * was found and brought up, -1 otherwise. */
  15. int ahci_init(void);
  16. /* 1 if an AHCI controller was found and initialised. */
  17. int ahci_controller_present(void);
  18. /* Collect present ATA disks. Returns the number written (<= max). */
  19. unsigned int ahci_scan(struct ahci_disk *out, unsigned int max);
  20. /* Read/write `count` sectors at LBA `lba` on the given controller port.
  21. * Return 0 on success, -1 on error. */
  22. int ahci_read_sectors(unsigned int port, unsigned int lba, void *buf, unsigned int count);
  23. int ahci_write_sectors(unsigned int port, unsigned int lba, const void *buf, unsigned int count);
  24. #endif