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.
 
 
 
 
 
 

72 lines
1.7 KiB

  1. /*
  2. * libcaca
  3. * libcaca Colour ASCII-Art library
  4. * Copyright (c) 2006 Sam Hocevar <sam@hocevar.net>
  5. * 2009 Jean-Yves Lamoureux <jylam@lnxscene.org>
  6. * All Rights Reserved
  7. *
  8. * $Id: kernel.h 4154 2009-12-20 13:33:11Z jylam $
  9. *
  10. * This library is free software. It comes without any warranty, to
  11. * the extent permitted by applicable law. You can redistribute it
  12. * and/or modify it under the terms of the Do What The Fuck You Want
  13. * To Public License, Version 2, as published by Sam Hocevar. See
  14. * http://sam.zoy.org/wtfpl/COPYING for more details.
  15. */
  16. #include "kernel.h"
  17. #include "klibc.h"
  18. #include "floppy.h"
  19. int floppy_get_info(struct floppy_info *floppy_info)
  20. {
  21. outb(0x70, 0x10);
  22. unsigned char c = inb(0x71);
  23. int a = c >> 4;
  24. int b = c & 0xF;
  25. char *drive_type[6] = {
  26. "none",
  27. "360kb 5.25in",
  28. "1.2mb 5.25in",
  29. "720kb 3.5in",
  30. "1.44mb 3.5in",
  31. "2.88mb 3.5in"
  32. };
  33. memcpy(floppy_info->drive[0].type, drive_type[a],
  34. strlen(drive_type[a]) + 1);
  35. memcpy(floppy_info->drive[1].type, drive_type[b],
  36. strlen(drive_type[b]) + 1);
  37. floppy_info->count = 0;
  38. if (a != 0)
  39. floppy_info->count++;
  40. if (b != 0)
  41. floppy_info->count++;
  42. return 0;
  43. }
  44. void floppy_print_info(struct floppy_info *floppy_info)
  45. {
  46. printf("%d floppy drive(s)\n", floppy_info->count);
  47. if (floppy_info->count)
  48. {
  49. printf("Floppy %d type %s\n", 0, floppy_info->drive[0].type);
  50. if (floppy_info->count == 2)
  51. {
  52. printf("Floppy %d type %s\n", 1, floppy_info->drive[1].type);
  53. }
  54. }
  55. }
  56. int floppy_get_status(void)
  57. {
  58. unsigned char c = inb(0x1F7);
  59. return c;
  60. }