devops_64.c 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. /*
  2. * devops.c: Device operations using the PROM.
  3. *
  4. * Copyright (C) 1995 David S. Miller (davem@caip.rutgers.edu)
  5. * Copyright (C) 1996,1997 Jakub Jelinek (jj@sunsite.mff.cuni.cz)
  6. */
  7. #include <linux/types.h>
  8. #include <linux/kernel.h>
  9. #include <linux/sched.h>
  10. #include <asm/openprom.h>
  11. #include <asm/oplib.h>
  12. /* Open the device described by the string 'dstr'. Returns the handle
  13. * to that device used for subsequent operations on that device.
  14. * Returns 0 on failure.
  15. */
  16. int
  17. prom_devopen(const char *dstr)
  18. {
  19. unsigned long args[5];
  20. args[0] = (unsigned long) "open";
  21. args[1] = 1;
  22. args[2] = 1;
  23. args[3] = (unsigned long) dstr;
  24. args[4] = (unsigned long) -1;
  25. p1275_cmd_direct(args);
  26. return (int) args[4];
  27. }
  28. /* Close the device described by device handle 'dhandle'. */
  29. int
  30. prom_devclose(int dhandle)
  31. {
  32. unsigned long args[4];
  33. args[0] = (unsigned long) "close";
  34. args[1] = 1;
  35. args[2] = 0;
  36. args[3] = (unsigned int) dhandle;
  37. p1275_cmd_direct(args);
  38. return 0;
  39. }
  40. /* Seek to specified location described by 'seekhi' and 'seeklo'
  41. * for device 'dhandle'.
  42. */
  43. void
  44. prom_seek(int dhandle, unsigned int seekhi, unsigned int seeklo)
  45. {
  46. unsigned long args[7];
  47. args[0] = (unsigned long) "seek";
  48. args[1] = 3;
  49. args[2] = 1;
  50. args[3] = (unsigned int) dhandle;
  51. args[4] = seekhi;
  52. args[5] = seeklo;
  53. args[6] = (unsigned long) -1;
  54. p1275_cmd_direct(args);
  55. }