Leaked source code of windows server 2003
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.

153 lines
4.7 KiB

  1. // $Header: G:/SwDev/WDM/Video/bt848/rcs/Command.h 1.4 1998/04/29 22:43:31 tomz Exp $
  2. #ifndef __COMMAND_H
  3. #define __COMMAND_H
  4. #ifndef __MEM_H
  5. #include <memory.h>
  6. #endif
  7. #include "mytypes.h"
  8. #define PROGRAM_TERMINATOR 0xa5a5a5a5
  9. /* Type: Instruction
  10. * Purpose: enumerates all RISC commands
  11. */
  12. typedef enum
  13. {
  14. WRIT = 0x01, SKIP = 0x02, WRITEC = 0x05,
  15. JUMP = 0x07, SYNC = 0x08, WRITE123 = 0x09,
  16. SKIP123 = 0x0A, WRITE1S23 = 0x0B, Reserved = 0xFF
  17. } Instruction;
  18. /* Type: SyncCode
  19. * Purpose: enumerates all sync codes coming out of decoder
  20. */
  21. typedef enum
  22. {
  23. SC_FM1 = 0x6, SC_FM3 = 0xE, SC_VRE = 0x4,
  24. SC_VRO = 0xC, SC_RESYNC = 1, SC_Reserved = 0xFF
  25. } SyncCode;
  26. /* Class: Command
  27. * Purpose: This class represents a RISC instruction in a more convenient form
  28. * Attributes:
  29. * Operations:
  30. */
  31. class Command
  32. {
  33. public:
  34. typedef union tag {
  35. struct {
  36. unsigned int ByteCount : 12;
  37. unsigned int BE_Res : 4;
  38. unsigned int StatusSet : 4;
  39. unsigned int StatusReset : 4;
  40. unsigned int IRQ : 1;
  41. unsigned int Reserved : 1;
  42. unsigned int EOL : 1;
  43. unsigned int SOL : 1;
  44. unsigned int OpCode : 4;
  45. } Gen;
  46. struct {
  47. unsigned int Status : 4;
  48. unsigned int Res1 : 11;
  49. unsigned int Resync : 1;
  50. unsigned int StatusSet : 4;
  51. unsigned int StatusReset : 4;
  52. unsigned int IRQ : 1;
  53. unsigned int Res2 : 1;
  54. unsigned int EOL : 1;
  55. unsigned int SOL : 1;
  56. unsigned int OpCode : 4;
  57. } Sync;
  58. struct {
  59. unsigned int ByteCountCb : 12;
  60. unsigned int skip : 4;
  61. unsigned int ByteCountCr : 12;
  62. } CRByteCounts;
  63. DWORD Initer; // used to zero out all the fields
  64. } FIRSTDWORD, *LPFIRSTDWORD;
  65. private:
  66. Instruction ThisInstr_;
  67. static BYTE InstrSize_ [];
  68. static BYTE InstrNumber_ [];
  69. PDWORD pdwInstrAddr_;
  70. public:
  71. Instruction GetInstr() { return ThisInstr_; }
  72. PDWORD GetInstrAddr() { return pdwInstrAddr_; }
  73. BYTE GetInstrSize() { return InstrSize_ [InstrNumber_ [ThisInstr_] ]; }
  74. BYTE GetInstrSize( Instruction inst )
  75. { return InstrSize_ [InstrNumber_ [inst] ]; }
  76. LPVOID Create( LPVOID lpDst, Instruction Instr, WORD wByteCnt [],
  77. DWORD dwAddress [], bool SafetyDevice = true,
  78. bool SOL = true, bool EOL = true, bool Intr = false );
  79. // start/end of line control
  80. void SetSOL( PVOID lpFD ) { ((LPFIRSTDWORD)lpFD)->Gen.SOL = 1; }
  81. void ResetSOL( PVOID lpFD ) { ((LPFIRSTDWORD)lpFD)->Gen.SOL = 0; }
  82. void SetEOL( PVOID lpFD ) { ((LPFIRSTDWORD)lpFD)->Gen.EOL = 1; }
  83. void ResetEOL( PVOID lpFD ) { ((LPFIRSTDWORD)lpFD)->Gen.EOL = 0; }
  84. void SetIRQ( PVOID lpFD ) { ((LPFIRSTDWORD)lpFD)->Gen.IRQ = 1; }
  85. void ResetIRQ( PVOID lpFD ) { ((LPFIRSTDWORD)lpFD)->Gen.IRQ = 0; }
  86. void SetStatus( PVOID lpFD, int s )
  87. {
  88. ((LPFIRSTDWORD)lpFD)->Gen.StatusSet = s;
  89. ((LPFIRSTDWORD)lpFD)->Gen.StatusReset = 0;
  90. }
  91. void ResetStatus( PVOID lpFD, int s )
  92. {
  93. ((LPFIRSTDWORD)lpFD)->Gen.StatusReset = s;
  94. ((LPFIRSTDWORD)lpFD)->Gen.StatusSet = 0;
  95. }
  96. void SetToCount( PVOID lpFD )
  97. {
  98. ((LPFIRSTDWORD)lpFD)->Gen.StatusReset = 0xF;
  99. ((LPFIRSTDWORD)lpFD)->Gen.StatusSet = 0xF;
  100. }
  101. // eol/sol query
  102. bool IsEOL( PVOID lpFD ) { return bool( ((LPFIRSTDWORD)lpFD)->Gen.EOL ); }
  103. bool IsSOL( PVOID lpFD ) { return bool( ((LPFIRSTDWORD)lpFD)->Gen.SOL ); }
  104. bool IsIRQ( PVOID lpFD ) { return bool( ((LPFIRSTDWORD)lpFD)->Gen.IRQ ); }
  105. WORD GetStatus( PVOID lpFD )
  106. {
  107. return WORD( ( ((LPFIRSTDWORD)lpFD)->Gen.StatusSet << 4 ) |
  108. ((LPFIRSTDWORD)lpFD)->Gen.StatusReset );
  109. }
  110. WORD GetSyncStatus( PVOID lpFD )
  111. { return (WORD)((LPFIRSTDWORD)lpFD)->Sync.Status; }
  112. void SetSync( PVOID lpFD, SyncCode eACode, bool Resync = false ) {
  113. ((LPFIRSTDWORD)lpFD)->Sync.Status = eACode;
  114. ((LPFIRSTDWORD)lpFD)->Sync.Resync = Resync;
  115. }
  116. void SetResync( PVOID lpFD, bool val )
  117. { ((LPFIRSTDWORD)lpFD)->Sync.Resync = val; }
  118. bool GetResync( PVOID lpFD )
  119. { return bool( ((LPFIRSTDWORD)lpFD)->Sync.Resync ); }
  120. Command(){}// { Init(); }
  121. Command( Instruction instr ) : ThisInstr_( instr ) {}
  122. };
  123. #endif __COMMAND_H