Du kan inte välja fler än 25 ämnen Ämnen måste starta med en bokstav eller siffra, kan innehålla bindestreck ('-') och vara max 35 tecken långa.

floppy.c 1.6 KiB

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