ide.h 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  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. #ifndef _MOD_IDE_H
  20. #define _MOD_IDE_H
  21. #include <kernel/types.h>
  22. #include <kernel/errno.h>
  23. errno_t ide_init(void);
  24. extern void do_ide_intr(void);
  25. void unexcepted_ide_intr(void);
  26. void ide_stat(void);
  27. #define IDE_CMD_ID 0xec
  28. #define IDE_CMD_RD 0x20
  29. #define IDE_CMD_RD48 0x24
  30. #define IDE_CMD_WR 0x30
  31. #define IDE_CMD_WR48 0x34
  32. #define DISK0_DATA 0x1f0
  33. #define DISK0_ERR 0x1f1
  34. #define DISK0_SECTORS 0x1f2
  35. #define DISK0_ADDR_LOW 0x1f3
  36. #define DISK0_ADDR_MID 0x1f4
  37. #define DISK0_ADDR_HIGH 0x1f5
  38. #define DISK0_MODE 0x1f6
  39. #define DISK0_CMD 0x1f7
  40. #define DISK0_CTL_STAT 0x3f6
  41. #define DISK1_DATA 0x170
  42. #define DISK1_ERR 0x171
  43. #define DISK1_SECTORS 0x172
  44. #define DISK1_ADDR_LOW 0x173
  45. #define DISK1_ADDR_MID 0x174
  46. #define DISK1_ADDR_HIGH 0x175
  47. #define DISK1_MODE 0x176
  48. #define DISK1_CMD 0x177
  49. #define DISK1_CTL_STAT 0x376
  50. #define STAT_BUSY 0x80
  51. #define STAT_READY 0x40
  52. #define STAT_REQ 0x08
  53. #define STAT_ERR 0x01
  54. /* enable the irq...but 0 is enable, 1 is disable */
  55. #define CTL_IRQ 0x02
  56. #define CTL_RESET 0x04
  57. /* irq 14 and 15 */
  58. #define DISK0_INT_NR 0x2e
  59. #define DISK1_INT_NR 0x2f
  60. #define DISK0_IRQ_NR 14
  61. #define DISK1_IRQ_NR 15
  62. #define MODE_DISK1 0x10
  63. #define MODE_LBA 0x40
  64. #endif