ide.h 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. /* Copyright (C) 2021 Rain */
  2. /* This file is part of XNIX. */
  3. /*
  4. XNIX is free software: you can redistribute it and/or modify
  5. it under the terms of the GNU General Public License as published by
  6. the Free Software Foundation, either version 3 of the License, or
  7. (at your option) and later version.
  8. */
  9. /*
  10. XNIX is distributed in the hope that it will be useful,
  11. but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. GNU General Public License for more details.
  14. */
  15. /*
  16. You should have received a copy of the GNU General Public License
  17. along with XNIX. If not, see <https://www.gnu.org/licenses/>.
  18. */
  19. #include <kernel/init.h>
  20. #include <kernel/errno.h>
  21. #include <kernel/types.h>
  22. #include <modules/ata.h>
  23. #define ide_info(fmt, ...) printk(yellow, "ide: " fmt, ##__VA_ARGS__);
  24. /* 0: PIO mode */
  25. #define PROGIF_HD0MODE 0x01
  26. /* 1: can change the pio mode to pci mode */
  27. #define PROGIF_HD0CHANGABLE 0x02
  28. #define PROGIF_HD1MODE 0x04
  29. #define PROGIF_HD1CHANGABLE 0x08
  30. #define PROGIF_DMA 0x80
  31. #define PORT_DATA 0
  32. #define PORT_ERR 1
  33. #define PORT_NSECTORS 2
  34. #define PORT_ADDR0 3
  35. #define PORT_ADDR1 4
  36. #define PORT_ADDR2 5
  37. #define PORT_DEV 6
  38. #define PORT_STAT 7
  39. void do_ide_intr(void);
  40. void do_ide_id(void);
  41. void do_ide_read(void);
  42. int ide_cmdout(int, int, char *, int, __uint64_t);
  43. #define wait_disk_not_busy(port) while (inb(port + PORT_STAT) & ATASTAT_BUSY);
  44. #define wait_disk_ready(port) while (!(inb(port + PORT_STAT) & ATASTAT_READY));