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.

87 lines
2.1 KiB

4 years ago
  1. //-------------------------------------------------------------------------
  2. //
  3. // File: PORTIO.C
  4. //
  5. // Contains generic port access routines for I/O cards.
  6. //
  7. // Revisions:
  8. // 02-24-93 KJB First.
  9. // 03-22-93 KJB Reorged for stub function library.
  10. // 03-25-93 JAP Fixed up typedef and prototype inconsistencies
  11. // 04-05-93 KJB Added functions for word io. Changed PUCHAR to
  12. // PBASE_REGISTER.
  13. //
  14. //-------------------------------------------------------------------------
  15. #include CARDTXXX_H
  16. //
  17. // PortIOSet
  18. //
  19. // This routine sets a mask on a certain port. It or's the mask with
  20. // the value currently at the port. Works only for ports where all bits
  21. // are readable and writable.
  22. //
  23. VOID PortIOSet(PBASE_REGISTER baseIoAddress, UCHAR mask)
  24. {
  25. UCHAR tmp;
  26. PortIOGet(baseIoAddress,&tmp);
  27. tmp = tmp | mask;
  28. PortIOPut(baseIoAddress,tmp);
  29. }
  30. VOID PortIOSetWord(PBASE_REGISTER baseIoAddress, USHORT mask)
  31. {
  32. USHORT tmp;
  33. PortIOGetWord(baseIoAddress,&tmp);
  34. tmp = tmp | mask;
  35. PortIOPutWord(baseIoAddress,tmp);
  36. }
  37. //
  38. // PortIOClear
  39. //
  40. // This routine clears a mask on a certain port. It and's the inverse with
  41. // the value currently at the port. Works only for ports where all bits
  42. // are readable and writable.
  43. //
  44. VOID PortIOClear(PBASE_REGISTER baseIoAddress, UCHAR mask)
  45. {
  46. UCHAR tmp;
  47. PortIOGet(baseIoAddress,&tmp);
  48. tmp = tmp & (0xff ^ mask);
  49. PortIOPut(baseIoAddress,tmp);
  50. }
  51. VOID PortIOClearWord(PBASE_REGISTER baseIoAddress, USHORT mask)
  52. {
  53. USHORT tmp;
  54. PortIOGetWord(baseIoAddress,&tmp);
  55. tmp = tmp & (0xff ^ mask);
  56. PortIOPutWord(baseIoAddress,tmp);
  57. }
  58. //
  59. // PortIOTest
  60. //
  61. // This routine clears a mask on a certain port. It and's the mask with
  62. // the value currently at the port. This result is returned.
  63. //
  64. BOOLEAN PortIOTest(PBASE_REGISTER baseIoAddress, UCHAR mask)
  65. {
  66. UCHAR tmp;
  67. PortIOGet(baseIoAddress,&tmp);
  68. return (tmp & mask);
  69. }
  70. BOOLEAN PortIOTestWord(PBASE_REGISTER baseIoAddress, USHORT theval)
  71. {
  72. USHORT tmpw;
  73. PortIOGetWord(baseIoAddress, &tmpw);
  74. return tmpw & theval;
  75. }