home *** CD-ROM | disk | FTP | other *** search
/ Chip 2004 February / Chip_2004-02_cd1.bin / zkuste / konfig / download / msic / Help / Int / MiTeC_NTDDK.int < prev    next >
Text File  |  2003-08-26  |  10KB  |  382 lines

  1. {*******************************************************}
  2. {                                                       }
  3. {               MiTeC NT DDK Header                     }
  4. {           version 1.0 for Delphi 5,6,7                }
  5. {                                                       }
  6. {           Copyright ⌐ 2003 Michal Mutl                }
  7. {                                                       }
  8. {*******************************************************}
  9.  
  10. unit MiTeC_NTDDK;
  11.  
  12. interface
  13.  
  14. uses Windows, SysUtils;
  15.  
  16.  
  17. type UCHAR = Byte;
  18. type USHORT = Word;
  19. type ULONG = LongInt;
  20.  
  21. type
  22.   CM_RESOURCE_TYPE = integer;
  23.  
  24.  
  25. const
  26.   CmResourceTypeNull                   = 0; { ResType_All or ResType_None (0x0000)}
  27.   CmResourceTypePort                   = 1; { ResType_IO (0x0002)}
  28.   CmResourceTypeInterrupt              = 2; { ResType_IRQ (0x0004)}
  29.   CmResourceTypeMemory                 = 3; { ResType_Mem (0x0001)}
  30.   CmResourceTypeDma                    = 4; { ResType_DMA (0x0003)}
  31.   CmResourceTypeDeviceSpecific         = 5; { ResType_ClassSpecific (0xFFFF)}
  32.   CmResourceTypeBusNumber              = 6; { ResType_BusNumber (0x0006)}
  33.   CmResourceTypeMaximum                = 7;
  34.   CmResourceTypeAssignedResource       = 8; { BUGBUG--remove}
  35.   CmResourceTypeSubAllocateFrom        = 9; { BUGBUG--remove}
  36.   CmResourceTypeNonArbitrated          = 128; { Not arbitrated if 0x80 bit set}
  37.   CmResourceTypeConfigData             = 128; { ResType_Reserved (0x8000) }
  38.   CmResourceTypeDevicePrivate          = 129; { ResType_DevicePrivate (0x8001) }
  39.   CmResourceTypePcCardConfig           = 130; { ResType_PcCardConfig (0x8002) }
  40.  
  41. { Defines the ShareDisposition in the RESOURCE_DESCRIPTOR }
  42. type
  43.   CM_SHARE_DISPOSITION = (
  44.  
  45.         CmResourceShareUndetermined,
  46.  
  47.         CmResourceShareDeviceExclusive,{ Reserved }
  48.         CmResourceShareDriverExclusive);
  49.  
  50.  
  51. { Define the bit masks for Flags common for all CM_RESOURCE_TYPE }
  52.  
  53. const
  54.   CM_RESOURCE_COMMON_COMPUTE_LENGTH_FROM_DEPENDENTS = $8000;
  55.  
  56.   CM_RESOURCE_COMMON_NOT_REASSIGNED    = $4000;
  57.  
  58.   CM_RESOURCE_COMMON_SUBSTRACTIVE      = $2000;
  59.  
  60.  
  61. { Define the bit masks for Flags when type is CmResourceTypeInterrupt }
  62.   CM_RESOURCE_INTERRUPT_LEVEL_SENSITIVE = 0;
  63.   CM_RESOURCE_INTERRUPT_LATCHED        = 1;
  64.  
  65.  
  66. { Define the bit masks for Flags when type is CmResourceTypeMemory }
  67.  
  68.   CM_RESOURCE_MEMORY_READ_WRITE        = $0000;
  69.   CM_RESOURCE_MEMORY_READ_ONLY         = $0001;
  70.  
  71.   CM_RESOURCE_MEMORY_WRITE_ONLY        = $0002;
  72.  
  73.   CM_RESOURCE_MEMORY_PREFETCHABLE      = $0004;
  74.  
  75.  
  76.   CM_RESOURCE_MEMORY_COMBINEDWRITE     = $0008;
  77.  
  78.   CM_RESOURCE_MEMORY_24                = $0010;
  79.  
  80.  
  81. { Define the bit masks for Flags when type is CmResourceTypePort }
  82.   CM_RESOURCE_PORT_MEMORY              = $0000;
  83.   CM_RESOURCE_PORT_IO                  = $0001;
  84.  
  85.  
  86.   CM_RESOURCE_PORT_FORWARD_FIRST_256_OF_EACH_1024 = $0002; { BUGBUG--remove }
  87.  
  88.   CM_RESOURCE_PORT_10_BIT_DECODE       = $0004;
  89.   CM_RESOURCE_PORT_12_BIT_DECODE       = $0008;
  90.  
  91.   CM_RESOURCE_PORT_16_BIT_DECODE       = $0010;
  92.  
  93.   CM_RESOURCE_PORT_POSITIVE_DECODE     = $0020;
  94.  
  95.  
  96. { Define the bit masks for Flags when type is CmResourceTypeDma }
  97.  
  98.   CM_RESOURCE_DMA_8                    = $0000;
  99.   CM_RESOURCE_DMA_16                   = $0001;
  100.  
  101.   CM_RESOURCE_DMA_32                   = $0002;
  102.  
  103.  
  104.  
  105. { Define the bit masks for Flags when type is CmResourceTypeBusNumber }
  106.   CM_RESOURCE_BUSNUMBER_SUBALLOCATE_FIRST_VALUE = $0001; { BUGBUG--remove }
  107.  
  108. { Define the bit masks for Flags when type is CmResourceTypeSubAllocateFrom }
  109.   CM_RESOURCE_SUBALLOCATEFROM_FIXED_TRANSLATION = $0001; { BUGBUG--remove }
  110.  
  111.   CM_RESOURCE_SUBALLOCATEFROM_WIRED_TRANSLATION = $0002; { BUGBUG--remove }
  112.  
  113. type
  114.   PHYSICAL_ADDRESS = LARGE_INTEGER;
  115.  
  116.   { Range of resources, inclusive.  These are physical, bus relative. }
  117.   { It is known that Port and Memory below have the exact same layout }
  118.   { as Generic. }
  119.   PRDD_Generic = ^RDD_Generic;
  120.   RDD_Generic = record
  121.     Start: PHYSICAL_ADDRESS;
  122.     Length: Cardinal;
  123.   end;
  124.  
  125.   { Range of port numbers, inclusive. These are physical, bus }
  126.   { relative. The value should be the same as the one passed to }
  127.   { HalTranslateBusAddress(). }
  128.   PRDD_Port = ^RDD_Port;
  129.   RDD_Port = record
  130.     Start: PHYSICAL_ADDRESS;
  131.     Length: Cardinal;
  132.   end;
  133.  
  134.   { IRQL and vector. Should be same values as were passed to }
  135.   { HalGetInterruptVector(). }
  136.   PRDD_Interrupt = ^RDD_Interrupt;
  137.   RDD_Interrupt =  record
  138.     Level: cardinal;
  139.  
  140.     Vector: cardinal;
  141.  
  142.     Affinity: cardinal;
  143.  
  144.   end;
  145.  
  146.   { Range of memory addresses, inclusive. These are physical, bus }
  147.   { relative. The value should be the same as the one passed to }
  148.   { HalTranslateBusAddress(). }
  149.   PRDD_Memory = ^RDD_Memory;
  150.   RDD_Memory = record
  151.     Start: PHYSICAL_ADDRESS;
  152.     Length: Cardinal;
  153.   end;
  154.  
  155.   { Physical DMA channel. }
  156.   PRDD_DMA = ^RDD_DMA;
  157.   RDD_DMA = record
  158.     Channel: cardinal;
  159.  
  160.     Port: cardinal;
  161.  
  162.     Reserved1: cardinal;
  163.  
  164.   end;
  165.  
  166.   { Device driver private data, usually used to help it figure }
  167.   { what the resource assignments decisions that were made. }
  168.   PRDD_DevicePrivate = ^RDD_DevicePrivate;
  169.   RDD_DevicePrivate = record
  170.     Data: array [0..2] of cardinal;
  171.  
  172.   end;
  173.  
  174.   { Bus Number information. }
  175.   PRDD_BusNumber = ^RDD_BusNumber;
  176.   RDD_BusNumber = record
  177.     Start: cardinal;
  178.  
  179.     Length: cardinal;
  180.  
  181.     Reserved: cardinal;
  182.  
  183.   end;
  184.  
  185.   { Device Specific information defined by the driver. }
  186.   { The DataSize field indicates the size of the data in bytes. The }
  187.   { data is located immediately after the DeviceSpecificData field in }
  188.   { the structure. }
  189.   PRDD_DeviceSpecificData = ^RDD_DeviceSpecificData;
  190.   RDD_DeviceSpecificData = record
  191.     DataSize: cardinal;
  192.  
  193.     Reserved1: cardinal;
  194.  
  195.     Reserved2: cardinal;
  196.  
  197.   end;
  198.  
  199.   _CM_PARTIAL_RESOURCE_DESCRIPTOR = record
  200.      Typ: Byte;
  201.  
  202.      ShareDisposition: CM_SHARE_DISPOSITION;
  203.  
  204.      Flags: smallint;
  205.  
  206.      case integer of
  207.  
  208.       0: (Generic: RDD_Generic);
  209.       1: (Port: RDD_Port);
  210.       2: (Interrupt: RDD_Interrupt);
  211.  
  212.       3: (Memory: RDD_Memory);
  213.       4: (Dma: RDD_DMA);
  214.  
  215.       5: (DevicePrivate: RDD_DevicePrivate);
  216.       6: (BusNumber: RDD_BusNumber);
  217.       7: (DeviceSpecificData: RDD_DeviceSpecificData);
  218.  
  219.   end;
  220.   CM_PARTIAL_RESOURCE_DESCRIPTOR = _CM_PARTIAL_RESOURCE_DESCRIPTOR;
  221.  
  222.   PCM_PARTIAL_RESOURCE_DESCRIPTOR = _CM_PARTIAL_RESOURCE_DESCRIPTOR;
  223.  
  224.   _CM_PARTIAL_RESOURCE_LIST = record
  225.     Version: USHORT;
  226.     Revision: USHORT;
  227.     Count: ULONG;
  228.     PartialDescriptors: CM_PARTIAL_RESOURCE_DESCRIPTOR;
  229.   end;
  230.   CM_PARTIAL_RESOURCE_LIST = _CM_PARTIAL_RESOURCE_LIST;
  231.   PCM_PARTIAL_RESOURCE_LIST = ^_CM_PARTIAL_RESOURCE_LIST;
  232.  
  233. { Define the I/O bus interface types. }
  234.   INTERFACE_TYPE = (
  235.               InterfaceTypeUndefined,           //-1
  236.  
  237.               Internal,
  238.  
  239.               Isa,
  240.  
  241.               Eisa,
  242.  
  243.               MicroChannel,
  244.  
  245.               TurboChannel,
  246.  
  247.               PCIBus,
  248.  
  249.               VMEBus,
  250.  
  251.               NuBus,
  252.  
  253.               PCMCIABus,
  254.  
  255.               CBus,
  256.  
  257.               MPIBus,
  258.  
  259.               MPSABus,
  260.  
  261.               ProcessorInternal,
  262.  
  263.               InternalPowerBus,
  264.  
  265.               PNPISABus,
  266.  
  267.               PNPBus);
  268.  
  269. { Define the DMA transfer widths. }
  270.   DMA_WIDTH = (
  271.               Width8Bits,
  272.  
  273.               Width16Bits,
  274.  
  275.               Width32Bits);
  276.  
  277.  
  278. { Define DMA transfer speeds. }
  279.  
  280.      DMA_SPEED = (
  281.               Compatible,
  282.  
  283.               TypeA,
  284.  
  285.               TypeB,
  286.  
  287.               TypeC);
  288.  
  289.  
  290. { Define types of bus information. }
  291.  
  292.      BUS_DATA_TYPE = (
  293.               ConfigurationSpaceUndefined,  //-1
  294.  
  295.               Cmos,
  296.  
  297.               EisaConfiguration,
  298.  
  299.               Pos1,
  300.  
  301.               CbusConfiguration,
  302.  
  303.               PCIConfiguration,
  304.  
  305.               VMEConfiguration,
  306.  
  307.               NuBusConfiguration,
  308.  
  309.               PCMCIAConfiguration,
  310.  
  311.               MPIConfiguration,
  312.  
  313.               MPSAConfiguration,
  314.  
  315.               PNPISAConfiguration);
  316.  
  317.  
  318.   _CM_FULL_RESOURCE_DESCRIPTOR = record
  319.     InterfaceType: INTERFACE_TYPE;
  320.     BusNumber: ULONG;
  321.     PartialResourceList: CM_PARTIAL_RESOURCE_LIST;
  322.   end;
  323.   CM_FULL_RESOURCE_DESCRIPTOR = _CM_FULL_RESOURCE_DESCRIPTOR;
  324.   PCM_FULL_RESOURCE_DESCRIPTOR = ^_CM_FULL_RESOURCE_DESCRIPTOR;
  325.  
  326.   _CM_RESOURCE_LIST = record
  327.     Count: ULONG;
  328.     List: CM_FULL_RESOURCE_DESCRIPTOR;
  329.   end;
  330.   CM_RESOURCE_LIST = _CM_RESOURCE_LIST;
  331.   PCM_RESOURCE_LIST = ^_CM_RESOURCE_LIST;
  332.  
  333. { my implementation of structures above to read from registry }
  334.  
  335. type
  336.   PResourceListHeader = ^TResourceListHeader;
  337.   TResourceListHeader = record
  338.     Count: DWORD;
  339.   end;
  340.  
  341.   PFullResourceDescriptorHeader = ^TFullResourceDescriptorHeader;
  342.   TFullResourceDescriptorHeader = record
  343.     InterfaceType: INTERFACE_TYPE;
  344.     BusNumber: DWORD;
  345.   end;
  346.  
  347.   PPartialResourceListHeader = ^TPartialResourceListHeader;
  348.   TPartialResourceListHeader = record
  349.     Version: WORD;
  350.     Revision: WORD;
  351.     Count: DWORD;
  352.   end;
  353.  
  354.   PPartialResourceDescriptorHeader = ^TPartialResourceDescriptorHeader;
  355.   TPartialResourceDescriptorHeader = record
  356.     Typ: Byte;
  357.     ShareDisposition: CM_SHARE_DISPOSITION;
  358.     Flags: WORD;
  359.   end;
  360.  
  361.   TDeviceResources = record
  362.     InterfaceType: INTERFACE_TYPE;
  363.     BusNumber: DWORD;
  364.     Version: WORD;
  365.     Revision: WORD;
  366.     Resources: array of CM_PARTIAL_RESOURCE_DESCRIPTOR;
  367.   end;
  368.  
  369. procedure ReadDeviceResourcesFromRegistry(AKey: HKEY; Avalue: string; var DeviceResources: TDeviceResources);
  370. procedure BufferToResourceList(Buffer: PChar; var DeviceResources: TDeviceResources);
  371.  
  372.  
  373. function DeviceResourceTypeStr(AType: DWORD): string;
  374. function DeviceIntfTypeStr(AIntf: INTERFACE_TYPE): string;
  375. function ResourceShareStr(AType: CM_SHARE_DISPOSITION): string;
  376. function InterruptTypeStr(AType: DWORD): string;
  377. function MemoryAccessStr(AType: DWORD): string;
  378. function PortTypeStr(AType: DWORD): string;
  379.  
  380. implementation
  381.  
  382.