Windows NT 4.0 source code leak
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.

86 lines
1.9 KiB

4 years ago
  1. #ifdef i386
  2. //--------------------------------------------------------------------
  3. //
  4. // PARALLEL.C
  5. //
  6. // Parallel port access file.
  7. //
  8. // Revisions:
  9. // 09-01-92 KJB First.
  10. // 03-11-93 JAP Changed retcode equates to reflect new names.
  11. // 03-25-93 JAP Fixed up typedef and prototype inconsistencies
  12. //--------------------------------------------------------------------
  13. #include CARDTXXX_H
  14. //
  15. // ParallelWaitBusy
  16. //
  17. // This routine waits until the busy line is 1.
  18. //
  19. USHORT ParallelWaitBusy (PBASE_REGISTER baseIoAddress, ULONG usec, PUCHAR data)
  20. {
  21. ULONG i;
  22. // see if the flag comes back quickly
  23. for (i = 0; i < TIMEOUT_QUICK; i++) {
  24. ParallelPortGet (baseIoAddress, PARALLEL_STATUS, data);
  25. if (*data & P_BUSY) {
  26. return 0;
  27. }
  28. }
  29. // ok, it did not come back quickly, we will yield to other processes
  30. for (i = 0; i < usec; i++) {
  31. ParallelPortGet (baseIoAddress, PARALLEL_STATUS, data);
  32. if (*data & P_BUSY) {
  33. return 0;
  34. }
  35. ScsiPortStallExecution (1);
  36. }
  37. // return with an error, non-zero indicates timeout
  38. return RET_STATUS_TIMEOUT;
  39. }
  40. //
  41. // ParallelWaitNoBusy
  42. //
  43. // This routine waits until the busy line is 0.
  44. //
  45. USHORT ParallelWaitNoBusy (PBASE_REGISTER baseIoAddress, ULONG usec, PUCHAR data)
  46. {
  47. ULONG i;
  48. // see if the flag comes back quickly
  49. for (i = 0; i < TIMEOUT_QUICK; i++) {
  50. ParallelPortGet (baseIoAddress, PARALLEL_STATUS, data);
  51. if (!(*data & P_BUSY)) {
  52. return 0;
  53. }
  54. }
  55. // ok, it did not come back quickly, we will yield to other processes
  56. for (i = 0; i < usec; i++) {
  57. ParallelPortGet (baseIoAddress, PARALLEL_STATUS, data);
  58. if (!(*data & P_BUSY)) {
  59. return 0;
  60. }
  61. ScsiPortStallExecution (1);
  62. }
  63. // return with an error, non-zero indicates timeout
  64. return RET_STATUS_TIMEOUT;
  65. }
  66. #endif