PCI.h
上传用户:xjjlds
上传日期:2015-12-05
资源大小:22823k
文件大小:10k
源码类别:

多媒体编程

开发平台:

Visual C++

  1. /*
  2.      File:       PCI.h
  3.  
  4.      Contains:   PCI Bus Interfaces.
  5.  
  6.      Version:    Technology: PowerSurge 1.0.2
  7.                  Release:    QuickTime 6.0.2
  8.  
  9.      Copyright:  (c) 1993-2001 by Apple Computer, Inc., all rights reserved.
  10.  
  11.      Bugs?:      For bug reports, consult the following page on
  12.                  the World Wide Web:
  13.  
  14.                      http://developer.apple.com/bugreporter/
  15.  
  16. */
  17. #ifndef __PCI__
  18. #define __PCI__
  19. #ifndef __MACTYPES__
  20. #include "MacTypes.h"
  21. #endif
  22. #ifndef __NAMEREGISTRY__
  23. #include "NameRegistry.h"
  24. #endif
  25. #if PRAGMA_ONCE
  26. #pragma once
  27. #endif
  28. #ifdef __cplusplus
  29. extern "C" {
  30. #endif
  31. #if PRAGMA_IMPORT
  32. #pragma import on
  33. #endif
  34. #if PRAGMA_STRUCT_ALIGN
  35.     #pragma options align=mac68k
  36. #elif PRAGMA_STRUCT_PACKPUSH
  37.     #pragma pack(push, 2)
  38. #elif PRAGMA_STRUCT_PACK
  39.     #pragma pack(2)
  40. #endif
  41. /* Definitions for the PCI Config Registers*/
  42. enum {
  43.     kPCIConfigVendorID          = 0x00,
  44.     kPCIConfigDeviceID          = 0x02,
  45.     kPCIConfigCommand           = 0x04,
  46.     kPCIConfigStatus            = 0x06,
  47.     kPCIConfigRevisionID        = 0x08,
  48.     kPCIConfigClassCode         = 0x09,
  49.     kPCIConfigCacheLineSize     = 0x0C,
  50.     kPCIConfigLatencyTimer      = 0x0D,
  51.     kPCIConfigHeaderType        = 0x0E,
  52.     kPCIConfigBIST              = 0x0F,
  53.     kPCIConfigBaseAddress0      = 0x10,
  54.     kPCIConfigBaseAddress1      = 0x14,
  55.     kPCIConfigBaseAddress2      = 0x18,
  56.     kPCIConfigBaseAddress3      = 0x1C,
  57.     kPCIConfigBaseAddress4      = 0x20,
  58.     kPCIConfigBaseAddress5      = 0x24,
  59.     kPCIConfigCardBusCISPtr     = 0x28,
  60.     kPCIConfigSubSystemVendorID = 0x2C,
  61.     kPCIConfigSubSystemID       = 0x2E,
  62.     kPCIConfigExpansionROMBase  = 0x30,
  63.     kPCIConfigCapabilitiesPtr   = 0x34,
  64.     kPCIConfigInterruptLine     = 0x3C,
  65.     kPCIConfigInterruptPin      = 0x3D,
  66.     kPCIConfigMinimumGrant      = 0x3E,
  67.     kPCIConfigMaximumLatency    = 0x3F
  68. };
  69. /* Definitions for the Capabilities PCI Config Register*/
  70. enum {
  71.     kPCICapabilityIDOffset      = 0x00,
  72.     kPCINextCapabilityOffset    = 0x01,
  73.     kPCIPowerManagementCapability = 0x01,
  74.     kPCIAGPCapability           = 0x02
  75. };
  76. /* Types and structures for accessing the PCI Assigned-Address property.*/
  77. #define kPCIAssignedAddressProperty "assigned-addresses"
  78. enum {
  79.     kPCIRelocatableSpace        = 0x80,
  80.     kPCIPrefetchableSpace       = 0x40,
  81.     kPCIAliasedSpace            = 0x20,
  82.     kPCIAddressTypeCodeMask     = 0x03,
  83.     kPCIConfigSpace             = 0,
  84.     kPCIIOSpace                 = 1,
  85.     kPCI32BitMemorySpace        = 2,
  86.     kPCI64BitMemorySpace        = 3
  87. };
  88. typedef UInt8                           PCIAddressSpaceFlags;
  89. enum {
  90.     kPCIDeviceNumberMask        = 0x1F,
  91.     kPCIFunctionNumberMask      = 0x07
  92. };
  93. typedef UInt8                           PCIDeviceFunction;
  94. typedef UInt8                           PCIBusNumber;
  95. typedef UInt8                           PCIRegisterNumber;
  96. struct PCIAssignedAddress {
  97.     PCIAddressSpaceFlags            addressSpaceFlags;
  98.     PCIBusNumber                    busNumber;
  99.     PCIDeviceFunction               deviceFunctionNumber;
  100.     PCIRegisterNumber               registerNumber;
  101.     UnsignedWide                    address;
  102.     UnsignedWide                    size;
  103. };
  104. typedef struct PCIAssignedAddress       PCIAssignedAddress;
  105. typedef PCIAssignedAddress *            PCIAssignedAddressPtr;
  106. #define GetPCIIsRelocatable( AssignedAddressPtr )       ((AssignedAddressPtr)->addressSpaceFlags & kPCIRelocatableSpace)
  107. #define GetPCIIsPrefetchable( AssignedAddressPtr )      ((AssignedAddressPtr)->addressSpaceFlags & kPCIPrefetchableSpace)
  108. #define GetPCIIsAliased( AssignedAddressPtr )           ((AssignedAddressPtr)->addressSpaceFlags & kPCIAliasedSpace)
  109. #define GetPCIAddressSpaceType( AssignedAddressPtr )    ((AssignedAddressPtr)->addressSpaceFlags & kPCIAddressTypeCodeMask)
  110. #define GetPCIBusNumber( AssignedAddressPtr )           ((AssignedAddressPtr)->busNumber)
  111. #define GetPCIDeviceNumber( AssignedAddressPtr )        (((AssignedAddressPtr)->deviceFunctionNumber >> 3) & kPCIDeviceNumberMask)
  112. #define GetPCIFunctionNumber( AssignedAddressPtr )      ((AssignedAddressPtr)->deviceFunctionNumber & kPCIFunctionNumberMask)
  113. #define GetPCIRegisterNumber( AssignedAddressPtr )      ((AssignedAddressPtr)->registerNumber)
  114. #if CALL_NOT_IN_CARBON
  115.                                                                                             #if TARGET_OS_MAC && TARGET_CPU_68K && !TARGET_RT_MAC_CFM
  116.                                                                                             #pragma parameter __D0 EndianSwap16Bit(__D0)
  117.                                                                                             #endif
  118. EXTERN_API( UInt16 )
  119. EndianSwap16Bit                 (UInt16                 data16)                             ONEWORDINLINE(0xE158);
  120.                                                                                             #if TARGET_OS_MAC && TARGET_CPU_68K && !TARGET_RT_MAC_CFM
  121.                                                                                             #pragma parameter __D0 EndianSwap32Bit(__D0)
  122.                                                                                             #endif
  123. EXTERN_API( UInt32 )
  124. EndianSwap32Bit                 (UInt32                 data32)                             THREEWORDINLINE(0xE158, 0x4840, 0xE158);
  125. #endif  /* CALL_NOT_IN_CARBON */
  126. #if CALL_NOT_IN_CARBON
  127. EXTERN_API( OSErr )
  128. ExpMgrConfigReadByte            (RegEntryIDPtr          node,
  129.                                  LogicalAddress         configAddr,
  130.                                  UInt8 *                valuePtr)                           THREEWORDINLINE(0x303C, 0x0620, 0xAAF3);
  131. EXTERN_API( OSErr )
  132. ExpMgrConfigReadWord            (RegEntryIDPtr          node,
  133.                                  LogicalAddress         configAddr,
  134.                                  UInt16 *               valuePtr)                           THREEWORDINLINE(0x303C, 0x0621, 0xAAF3);
  135. EXTERN_API( OSErr )
  136. ExpMgrConfigReadLong            (RegEntryIDPtr          node,
  137.                                  LogicalAddress         configAddr,
  138.                                  UInt32 *               valuePtr)                           THREEWORDINLINE(0x303C, 0x0622, 0xAAF3);
  139. EXTERN_API( OSErr )
  140. ExpMgrConfigWriteByte           (RegEntryIDPtr          node,
  141.                                  LogicalAddress         configAddr,
  142.                                  UInt8                  value)                              THREEWORDINLINE(0x303C, 0x0523, 0xAAF3);
  143. EXTERN_API( OSErr )
  144. ExpMgrConfigWriteWord           (RegEntryIDPtr          node,
  145.                                  LogicalAddress         configAddr,
  146.                                  UInt16                 value)                              THREEWORDINLINE(0x303C, 0x0524, 0xAAF3);
  147. EXTERN_API( OSErr )
  148. ExpMgrConfigWriteLong           (RegEntryIDPtr          node,
  149.                                  LogicalAddress         configAddr,
  150.                                  UInt32                 value)                              THREEWORDINLINE(0x303C, 0x0625, 0xAAF3);
  151. EXTERN_API( OSErr )
  152. ExpMgrIOReadByte                (RegEntryIDPtr          node,
  153.                                  LogicalAddress         ioAddr,
  154.                                  UInt8 *                valuePtr)                           THREEWORDINLINE(0x303C, 0x0626, 0xAAF3);
  155. EXTERN_API( OSErr )
  156. ExpMgrIOReadWord                (RegEntryIDPtr          node,
  157.                                  LogicalAddress         ioAddr,
  158.                                  UInt16 *               valuePtr)                           THREEWORDINLINE(0x303C, 0x0627, 0xAAF3);
  159. EXTERN_API( OSErr )
  160. ExpMgrIOReadLong                (RegEntryIDPtr          node,
  161.                                  LogicalAddress         ioAddr,
  162.                                  UInt32 *               valuePtr)                           THREEWORDINLINE(0x303C, 0x0628, 0xAAF3);
  163. EXTERN_API( OSErr )
  164. ExpMgrIOWriteByte               (RegEntryIDPtr          node,
  165.                                  LogicalAddress         ioAddr,
  166.                                  UInt8                  value)                              THREEWORDINLINE(0x303C, 0x0529, 0xAAF3);
  167. EXTERN_API( OSErr )
  168. ExpMgrIOWriteWord               (RegEntryIDPtr          node,
  169.                                  LogicalAddress         ioAddr,
  170.                                  UInt16                 value)                              THREEWORDINLINE(0x303C, 0x052A, 0xAAF3);
  171. EXTERN_API( OSErr )
  172. ExpMgrIOWriteLong               (RegEntryIDPtr          node,
  173.                                  LogicalAddress         ioAddr,
  174.                                  UInt32                 value)                              THREEWORDINLINE(0x303C, 0x062B, 0xAAF3);
  175. EXTERN_API( OSErr )
  176. ExpMgrInterruptAcknowledgeReadByte (RegEntryIDPtr       entry,
  177.                                  UInt8 *                valuePtr)                           THREEWORDINLINE(0x303C, 0x0411, 0xAAF3);
  178. EXTERN_API( OSErr )
  179. ExpMgrInterruptAcknowledgeReadWord (RegEntryIDPtr       entry,
  180.                                  UInt16 *               valuePtr)                           THREEWORDINLINE(0x303C, 0x0412, 0xAAF3);
  181. EXTERN_API( OSErr )
  182. ExpMgrInterruptAcknowledgeReadLong (RegEntryIDPtr       entry,
  183.                                  UInt32 *               valuePtr)                           THREEWORDINLINE(0x303C, 0x0413, 0xAAF3);
  184. EXTERN_API( OSErr )
  185. ExpMgrSpecialCycleWriteLong     (RegEntryIDPtr          entry,
  186.                                  UInt32                 value)                              THREEWORDINLINE(0x303C, 0x0419, 0xAAF3);
  187. EXTERN_API( OSErr )
  188. ExpMgrSpecialCycleBroadcastLong (UInt32                 value)                              THREEWORDINLINE(0x303C, 0x021A, 0xAAF3);
  189. #endif  /* CALL_NOT_IN_CARBON */
  190. #if PRAGMA_STRUCT_ALIGN
  191.     #pragma options align=reset
  192. #elif PRAGMA_STRUCT_PACKPUSH
  193.     #pragma pack(pop)
  194. #elif PRAGMA_STRUCT_PACK
  195.     #pragma pack()
  196. #endif
  197. #ifdef PRAGMA_IMPORT_OFF
  198. #pragma import off
  199. #elif PRAGMA_IMPORT
  200. #pragma import reset
  201. #endif
  202. #ifdef __cplusplus
  203. }
  204. #endif
  205. #endif /* __PCI__ */