readdisk.inc 1.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. ; Copyright (C) 2021 Rain
  2. ; This file is part of Cunix.
  3. ; Cunix is free software: you can redistribute it and/or modify
  4. ; it under the terms of the GNU General Public Licene and published by
  5. ; the Free Software Foundation, either version 3 of the License, or
  6. ; (at your option) any later version.
  7. ; Cunix is distributed in the hope that it will be useful,
  8. ; but WITHOUT ANY WARRANTY; without even the implied warranty of
  9. ; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  10. ; GNU General Public License for more details.
  11. ; You should have recceived a copy of the GNU General Public License
  12. ; along with Cunix. If not, see <https://www.gnu.org/licenses/>.
  13. %define DISK_CHS
  14. BI_BOOTDEV equ 0x7e00
  15. read_sector:
  16. %ifdef DISK_CHS
  17. read_sector_chs:
  18. mov ax, 0x0201
  19. xor ch, ch
  20. xor dh, dh
  21. mov dl, [BI_BOOTDEV]
  22. int 0x13
  23. ret
  24. %else
  25. read_sector_lba:
  26. push dword 0x00000000
  27. push dword ecx
  28. push word es
  29. push word bx
  30. push word 0x0001
  31. push word 0x0010
  32. mov ah, 0x42
  33. mov dl, [BI_BOOTDEV]
  34. int 0x13
  35. add sp, 0x10
  36. ret
  37. %endif