You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

57 lines
1.1 KiB

  1. #include "kernel.h"
  2. #include "klibc.h"
  3. #include "floppy.h"
  4. int floppy_get_info(struct floppy_info *floppy_info)
  5. {
  6. outb(0x70, 0x10);
  7. unsigned char c = inb(0x71);
  8. int a = c >> 4;
  9. int b = c & 0xF;
  10. char *drive_type[6] = {
  11. "none",
  12. "360kb 5.25in",
  13. "1.2mb 5.25in",
  14. "720kb 3.5in",
  15. "1.44mb 3.5in",
  16. "2.88mb 3.5in"
  17. };
  18. memcpy(floppy_info->drive[0].type, drive_type[a],
  19. strlen(drive_type[a]) + 1);
  20. memcpy(floppy_info->drive[1].type, drive_type[b],
  21. strlen(drive_type[b]) + 1);
  22. floppy_info->count = 0;
  23. if (a != 0)
  24. floppy_info->count++;
  25. if (b != 0)
  26. floppy_info->count++;
  27. return 0;
  28. }
  29. void floppy_print_info(struct floppy_info *floppy_info)
  30. {
  31. printf("%d floppy drive(s)\n", floppy_info->count);
  32. if (floppy_info->count)
  33. {
  34. printf("Floppy %d type %s\n", 0, floppy_info->drive[0].type);
  35. if (floppy_info->count == 2)
  36. {
  37. printf("Floppy %d type %s\n", 1, floppy_info->drive[1].type);
  38. }
  39. }
  40. }
  41. int floppy_get_status(void)
  42. {
  43. unsigned char c = inb(0x1F7);
  44. return c;
  45. }