DAC960.h
上传用户:jlfgdled
上传日期:2013-04-10
资源大小:33168k
文件大小:144k
源码类别:

Linux/Unix编程

开发平台:

Unix_Linux

  1. typedef enum DAC960_MessageLevel
  2. {
  3.   DAC960_AnnounceLevel = 0,
  4.   DAC960_InfoLevel = 1,
  5.   DAC960_NoticeLevel = 2,
  6.   DAC960_WarningLevel = 3,
  7.   DAC960_ErrorLevel = 4,
  8.   DAC960_ProgressLevel = 5,
  9.   DAC960_CriticalLevel = 6,
  10.   DAC960_UserCriticalLevel = 7
  11. }
  12. DAC960_MessageLevel_T;
  13. static char
  14.   *DAC960_MessageLevelMap[] =
  15.     { KERN_NOTICE, KERN_NOTICE, KERN_NOTICE, KERN_WARNING,
  16.       KERN_ERR, KERN_CRIT, KERN_CRIT, KERN_CRIT };
  17. /*
  18.   Define Driver Message macros.
  19. */
  20. #define DAC960_Announce(Format, Arguments...) 
  21.   DAC960_Message(DAC960_AnnounceLevel, Format, ##Arguments)
  22. #define DAC960_Info(Format, Arguments...) 
  23.   DAC960_Message(DAC960_InfoLevel, Format, ##Arguments)
  24. #define DAC960_Notice(Format, Arguments...) 
  25.   DAC960_Message(DAC960_NoticeLevel, Format, ##Arguments)
  26. #define DAC960_Warning(Format, Arguments...) 
  27.   DAC960_Message(DAC960_WarningLevel, Format, ##Arguments)
  28. #define DAC960_Error(Format, Arguments...) 
  29.   DAC960_Message(DAC960_ErrorLevel, Format, ##Arguments)
  30. #define DAC960_Progress(Format, Arguments...) 
  31.   DAC960_Message(DAC960_ProgressLevel, Format, ##Arguments)
  32. #define DAC960_Critical(Format, Arguments...) 
  33.   DAC960_Message(DAC960_CriticalLevel, Format, ##Arguments)
  34. #define DAC960_UserCritical(Format, Arguments...) 
  35.   DAC960_Message(DAC960_UserCriticalLevel, Format, ##Arguments)
  36. /*
  37.   Define types for some of the structures that interface with the rest
  38.   of the Linux Kernel and I/O Subsystem.
  39. */
  40. typedef struct buffer_head BufferHeader_T;
  41. typedef struct file File_T;
  42. typedef struct block_device_operations BlockDeviceOperations_T;
  43. typedef struct completion Completion_T;
  44. typedef struct gendisk GenericDiskInfo_T;
  45. typedef struct hd_geometry DiskGeometry_T;
  46. typedef struct hd_struct DiskPartition_T;
  47. typedef struct inode Inode_T;
  48. typedef struct inode_operations InodeOperations_T;
  49. typedef kdev_t KernelDevice_T;
  50. typedef struct list_head ListHead_T;
  51. typedef struct notifier_block NotifierBlock_T;
  52. typedef struct pci_dev PCI_Device_T;
  53. typedef struct proc_dir_entry PROC_DirectoryEntry_T;
  54. typedef unsigned long ProcessorFlags_T;
  55. typedef struct pt_regs Registers_T;
  56. typedef struct request IO_Request_T;
  57. typedef request_queue_t RequestQueue_T;
  58. typedef struct super_block SuperBlock_T;
  59. typedef struct timer_list Timer_T;
  60. typedef wait_queue_head_t WaitQueue_T;
  61. /*
  62.   Define the DAC960 V1 Firmware Controller Status Mailbox structure.
  63. */
  64. typedef union DAC960_V1_StatusMailbox
  65. {
  66.   unsigned int Word; /* Word 0 */
  67.   struct {
  68.     DAC960_V1_CommandIdentifier_T CommandIdentifier; /* Byte 0 */
  69.     unsigned char :7; /* Byte 1 Bits 0-6 */
  70.     boolean Valid:1; /* Byte 1 Bit 7 */
  71.     DAC960_V1_CommandStatus_T CommandStatus; /* Bytes 2-3 */
  72.   } Fields;
  73. }
  74. DAC960_V1_StatusMailbox_T;
  75. /*
  76.   Define the DAC960 V2 Firmware Controller Status Mailbox structure.
  77. */
  78. typedef union DAC960_V2_StatusMailbox
  79. {
  80.   unsigned int Words[2]; /* Words 0-1 */
  81.   struct {
  82.     DAC960_V2_CommandIdentifier_T CommandIdentifier; /* Bytes 0-1 */
  83.     DAC960_V2_CommandStatus_T CommandStatus; /* Byte 2 */
  84.     unsigned char RequestSenseLength; /* Byte 3 */
  85.     int DataTransferResidue; /* Bytes 4-7 */
  86.   } Fields;
  87. }
  88. DAC960_V2_StatusMailbox_T;
  89. /*
  90.   Define the DAC960 Driver Command Types.
  91. */
  92. typedef enum
  93. {
  94.   DAC960_ReadCommand = 1,
  95.   DAC960_WriteCommand = 2,
  96.   DAC960_ReadRetryCommand = 3,
  97.   DAC960_WriteRetryCommand = 4,
  98.   DAC960_MonitoringCommand = 5,
  99.   DAC960_ImmediateCommand = 6,
  100.   DAC960_QueuedCommand = 7
  101. }
  102. DAC960_CommandType_T;
  103. /*
  104.   Define the DAC960 Driver Command structure.
  105. */
  106. typedef struct DAC960_Command
  107. {
  108.   int CommandIdentifier;
  109.   DAC960_CommandType_T CommandType;
  110.   struct DAC960_Controller *Controller;
  111.   struct DAC960_Command *Next;
  112.   Completion_T *Completion;
  113.   unsigned int LogicalDriveNumber;
  114.   unsigned int BlockNumber;
  115.   unsigned int BlockCount;
  116.   unsigned int SegmentCount;
  117.   BufferHeader_T *BufferHeader;
  118.   void *RequestBuffer;
  119.   union {
  120.     struct {
  121.       DAC960_V1_CommandMailbox_T CommandMailbox;
  122.       DAC960_V1_KernelCommand_T *KernelCommand;
  123.       DAC960_V1_CommandStatus_T CommandStatus;
  124.       DAC960_V1_ScatterGatherSegment_T
  125. ScatterGatherList[DAC960_V1_ScatterGatherLimit]
  126. __attribute__ ((aligned (sizeof(DAC960_V1_ScatterGatherSegment_T))));
  127.       unsigned int EndMarker[0];
  128.     } V1;
  129.     struct {
  130.       DAC960_V2_CommandMailbox_T CommandMailbox;
  131.       DAC960_V2_KernelCommand_T *KernelCommand;
  132.       DAC960_V2_CommandStatus_T CommandStatus;
  133.       unsigned char RequestSenseLength;
  134.       int DataTransferResidue;
  135.       DAC960_V2_ScatterGatherSegment_T
  136. ScatterGatherList[DAC960_V2_ScatterGatherLimit]
  137. __attribute__ ((aligned (sizeof(DAC960_V2_ScatterGatherSegment_T))));
  138.       DAC960_SCSI_RequestSense_T RequestSense
  139. __attribute__ ((aligned (sizeof(int))));
  140.       unsigned int EndMarker[0];
  141.     } V2;
  142.   } FW;
  143. }
  144. DAC960_Command_T;
  145. /*
  146.   Define the DAC960 Driver Controller structure.
  147. */
  148. typedef struct DAC960_Controller
  149. {
  150.   void *BaseAddress;
  151.   void *MemoryMappedAddress;
  152.   DAC960_FirmwareType_T FirmwareType;
  153.   DAC960_HardwareType_T HardwareType;
  154.   DAC960_IO_Address_T IO_Address;
  155.   DAC960_PCI_Address_T PCI_Address;
  156.   unsigned char ControllerNumber;
  157.   unsigned char ControllerName[4];
  158.   unsigned char ModelName[20];
  159.   unsigned char FullModelName[28];
  160.   unsigned char FirmwareVersion[12];
  161.   unsigned char Bus;
  162.   unsigned char Device;
  163.   unsigned char Function;
  164.   unsigned char IRQ_Channel;
  165.   unsigned char Channels;
  166.   unsigned char Targets;
  167.   unsigned char MemorySize;
  168.   unsigned char LogicalDriveCount;
  169.   unsigned short CommandAllocationGroupSize;
  170.   unsigned short ControllerQueueDepth;
  171.   unsigned short DriverQueueDepth;
  172.   unsigned short MaxBlocksPerCommand;
  173.   unsigned short ControllerScatterGatherLimit;
  174.   unsigned short DriverScatterGatherLimit;
  175.   unsigned int ControllerUsageCount;
  176.   unsigned int CombinedStatusBufferLength;
  177.   unsigned int InitialStatusLength;
  178.   unsigned int CurrentStatusLength;
  179.   unsigned int ProgressBufferLength;
  180.   unsigned int UserStatusLength;
  181.   unsigned long MemoryMailboxPagesAddress;
  182.   unsigned long MemoryMailboxPagesOrder;
  183.   unsigned long MonitoringTimerCount;
  184.   unsigned long PrimaryMonitoringTime;
  185.   unsigned long SecondaryMonitoringTime;
  186.   unsigned long LastProgressReportTime;
  187.   unsigned long LastCurrentStatusTime;
  188.   boolean ControllerDetectionSuccessful;
  189.   boolean ControllerInitialized;
  190.   boolean MonitoringCommandDeferred;
  191.   boolean EphemeralProgressMessage;
  192.   boolean DriveSpinUpMessageDisplayed;
  193.   boolean MonitoringAlertMode;
  194.   boolean SuppressEnclosureMessages;
  195.   Timer_T MonitoringTimer;
  196.   GenericDiskInfo_T GenericDiskInfo;
  197.   DAC960_Command_T *FreeCommands;
  198.   unsigned char *CombinedStatusBuffer;
  199.   unsigned char *CurrentStatusBuffer;
  200.   RequestQueue_T *RequestQueue;
  201.   WaitQueue_T CommandWaitQueue;
  202.   WaitQueue_T HealthStatusWaitQueue;
  203.   DAC960_Command_T InitialCommand;
  204.   DAC960_Command_T *Commands[DAC960_MaxDriverQueueDepth];
  205.   PROC_DirectoryEntry_T *ControllerProcEntry;
  206.   unsigned int LogicalDriveUsageCount[DAC960_MaxLogicalDrives];
  207.   boolean LogicalDriveInitiallyAccessible[DAC960_MaxLogicalDrives];
  208.   void (*QueueCommand)(DAC960_Command_T *Command);
  209.   boolean (*ReadControllerConfiguration)(struct DAC960_Controller *);
  210.   boolean (*ReadDeviceConfiguration)(struct DAC960_Controller *);
  211.   boolean (*ReportDeviceConfiguration)(struct DAC960_Controller *);
  212.   void (*QueueReadWriteCommand)(DAC960_Command_T *Command);
  213.   union {
  214.     struct {
  215.       unsigned char GeometryTranslationHeads;
  216.       unsigned char GeometryTranslationSectors;
  217.       unsigned char PendingRebuildFlag;
  218.       unsigned short StripeSize;
  219.       unsigned short SegmentSize;
  220.       unsigned short NewEventLogSequenceNumber;
  221.       unsigned short OldEventLogSequenceNumber;
  222.       unsigned short DeviceStateChannel;
  223.       unsigned short DeviceStateTargetID;
  224.       boolean DualModeMemoryMailboxInterface;
  225.       boolean BackgroundInitializationStatusSupported;
  226.       boolean SAFTE_EnclosureManagementEnabled;
  227.       boolean NeedLogicalDriveInformation;
  228.       boolean NeedErrorTableInformation;
  229.       boolean NeedDeviceStateInformation;
  230.       boolean NeedDeviceInquiryInformation;
  231.       boolean NeedDeviceSerialNumberInformation;
  232.       boolean NeedRebuildProgress;
  233.       boolean NeedConsistencyCheckProgress;
  234.       boolean NeedBackgroundInitializationStatus;
  235.       boolean StartDeviceStateScan;
  236.       boolean RebuildProgressFirst;
  237.       boolean RebuildFlagPending;
  238.       boolean RebuildStatusPending;
  239.       DAC960_V1_CommandMailbox_T *FirstCommandMailbox;
  240.       DAC960_V1_CommandMailbox_T *LastCommandMailbox;
  241.       DAC960_V1_CommandMailbox_T *NextCommandMailbox;
  242.       DAC960_V1_CommandMailbox_T *PreviousCommandMailbox1;
  243.       DAC960_V1_CommandMailbox_T *PreviousCommandMailbox2;
  244.       DAC960_V1_StatusMailbox_T *FirstStatusMailbox;
  245.       DAC960_V1_StatusMailbox_T *LastStatusMailbox;
  246.       DAC960_V1_StatusMailbox_T *NextStatusMailbox;
  247.       DAC960_V1_DCDB_T MonitoringDCDB;
  248.       DAC960_V1_Enquiry_T Enquiry;
  249.       DAC960_V1_Enquiry_T NewEnquiry;
  250.       DAC960_V1_ErrorTable_T ErrorTable;
  251.       DAC960_V1_ErrorTable_T NewErrorTable;
  252.       DAC960_V1_EventLogEntry_T EventLogEntry;
  253.       DAC960_V1_RebuildProgress_T RebuildProgress;
  254.       DAC960_V1_CommandStatus_T LastRebuildStatus;
  255.       DAC960_V1_CommandStatus_T PendingRebuildStatus;
  256.       DAC960_V1_LogicalDriveInformationArray_T LogicalDriveInformation;
  257.       DAC960_V1_LogicalDriveInformationArray_T NewLogicalDriveInformation;
  258.       DAC960_V1_BackgroundInitializationStatus_T
  259.         BackgroundInitializationStatus;
  260.       DAC960_V1_BackgroundInitializationStatus_T
  261.         LastBackgroundInitializationStatus;
  262.       DAC960_V1_DeviceState_T
  263. DeviceState[DAC960_V1_MaxChannels][DAC960_V1_MaxTargets];
  264.       DAC960_V1_DeviceState_T NewDeviceState;
  265.       DAC960_SCSI_Inquiry_T
  266. InquiryStandardData[DAC960_V1_MaxChannels][DAC960_V1_MaxTargets];
  267.       DAC960_SCSI_Inquiry_UnitSerialNumber_T
  268. InquiryUnitSerialNumber[DAC960_V1_MaxChannels][DAC960_V1_MaxTargets];
  269.       int DeviceResetCount[DAC960_V1_MaxChannels][DAC960_V1_MaxTargets];
  270.       boolean DirectCommandActive[DAC960_V1_MaxChannels][DAC960_V1_MaxTargets];
  271.     } V1;
  272.     struct {
  273.       unsigned int StatusChangeCounter;
  274.       unsigned int NextEventSequenceNumber;
  275.       unsigned int PhysicalDeviceIndex;
  276.       boolean NeedLogicalDeviceInformation;
  277.       boolean NeedPhysicalDeviceInformation;
  278.       boolean NeedDeviceSerialNumberInformation;
  279.       boolean StartLogicalDeviceInformationScan;
  280.       boolean StartPhysicalDeviceInformationScan;
  281.       DAC960_V2_CommandMailbox_T *FirstCommandMailbox;
  282.       DAC960_V2_CommandMailbox_T *LastCommandMailbox;
  283.       DAC960_V2_CommandMailbox_T *NextCommandMailbox;
  284.       DAC960_V2_CommandMailbox_T *PreviousCommandMailbox1;
  285.       DAC960_V2_CommandMailbox_T *PreviousCommandMailbox2;
  286.       DAC960_V2_StatusMailbox_T *FirstStatusMailbox;
  287.       DAC960_V2_StatusMailbox_T *LastStatusMailbox;
  288.       DAC960_V2_StatusMailbox_T *NextStatusMailbox;
  289.       DAC960_V2_HealthStatusBuffer_T *HealthStatusBuffer;
  290.       DAC960_V2_ControllerInfo_T ControllerInformation;
  291.       DAC960_V2_ControllerInfo_T NewControllerInformation;
  292.       DAC960_V2_LogicalDeviceInfo_T
  293. *LogicalDeviceInformation[DAC960_MaxLogicalDrives];
  294.       DAC960_V2_LogicalDeviceInfo_T NewLogicalDeviceInformation;
  295.       DAC960_V2_PhysicalDeviceInfo_T
  296. *PhysicalDeviceInformation[DAC960_V2_MaxPhysicalDevices];
  297.       DAC960_V2_PhysicalDeviceInfo_T NewPhysicalDeviceInformation;
  298.       DAC960_SCSI_Inquiry_UnitSerialNumber_T
  299. *InquiryUnitSerialNumber[DAC960_V2_MaxPhysicalDevices];
  300.       DAC960_V2_PhysicalDevice_T
  301. LogicalDriveToVirtualDevice[DAC960_MaxLogicalDrives];
  302.       DAC960_V2_Event_T Event;
  303.       boolean LogicalDriveFoundDuringScan[DAC960_MaxLogicalDrives];
  304.     } V2;
  305.   } FW;
  306.   DiskPartition_T DiskPartitions[DAC960_MinorCount];
  307.   int PartitionSizes[DAC960_MinorCount];
  308.   int BlockSizes[DAC960_MinorCount];
  309.   int MaxSectorsPerRequest[DAC960_MinorCount];
  310.   unsigned char ProgressBuffer[DAC960_ProgressBufferSize];
  311.   unsigned char UserStatusBuffer[DAC960_UserMessageSize];
  312. }
  313. DAC960_Controller_T;
  314. /*
  315.   Simplify access to Firmware Version Dependent Data Structure Components
  316.   and Functions.
  317. */
  318. #define V1 FW.V1
  319. #define V2 FW.V2
  320. #define DAC960_QueueCommand(Command) 
  321.   (Controller->QueueCommand)(Command)
  322. #define DAC960_ReadControllerConfiguration(Controller) 
  323.   (Controller->ReadControllerConfiguration)(Controller)
  324. #define DAC960_ReadDeviceConfiguration(Controller) 
  325.   (Controller->ReadDeviceConfiguration)(Controller)
  326. #define DAC960_ReportDeviceConfiguration(Controller) 
  327.   (Controller->ReportDeviceConfiguration)(Controller)
  328. #define DAC960_QueueReadWriteCommand(Command) 
  329.   (Controller->QueueReadWriteCommand)(Command)
  330. /*
  331.   DAC960_AcquireControllerLock acquires exclusive access to Controller.
  332. */
  333. static inline
  334. void DAC960_AcquireControllerLock(DAC960_Controller_T *Controller,
  335.   ProcessorFlags_T *ProcessorFlags)
  336. {
  337.   spin_lock_irqsave(&io_request_lock, *ProcessorFlags);
  338. }
  339. /*
  340.   DAC960_ReleaseControllerLock releases exclusive access to Controller.
  341. */
  342. static inline
  343. void DAC960_ReleaseControllerLock(DAC960_Controller_T *Controller,
  344.   ProcessorFlags_T *ProcessorFlags)
  345. {
  346.   spin_unlock_irqrestore(&io_request_lock, *ProcessorFlags);
  347. }
  348. /*
  349.   DAC960_AcquireControllerLockRF acquires exclusive access to Controller,
  350.   but is only called from the request function with the io_request_lock held.
  351. */
  352. static inline
  353. void DAC960_AcquireControllerLockRF(DAC960_Controller_T *Controller,
  354.     ProcessorFlags_T *ProcessorFlags)
  355. {
  356. }
  357. /*
  358.   DAC960_ReleaseControllerLockRF releases exclusive access to Controller,
  359.   but is only called from the request function with the io_request_lock held.
  360. */
  361. static inline
  362. void DAC960_ReleaseControllerLockRF(DAC960_Controller_T *Controller,
  363.     ProcessorFlags_T *ProcessorFlags)
  364. {
  365. }
  366. /*
  367.   DAC960_AcquireControllerLockIH acquires exclusive access to Controller,
  368.   but is only called from the interrupt handler.
  369. */
  370. static inline
  371. void DAC960_AcquireControllerLockIH(DAC960_Controller_T *Controller,
  372.     ProcessorFlags_T *ProcessorFlags)
  373. {
  374.   spin_lock_irqsave(&io_request_lock, *ProcessorFlags);
  375. }
  376. /*
  377.   DAC960_ReleaseControllerLockIH releases exclusive access to Controller,
  378.   but is only called from the interrupt handler.
  379. */
  380. static inline
  381. void DAC960_ReleaseControllerLockIH(DAC960_Controller_T *Controller,
  382.     ProcessorFlags_T *ProcessorFlags)
  383. {
  384.   spin_unlock_irqrestore(&io_request_lock, *ProcessorFlags);
  385. }
  386. /*
  387.   Virtual_to_Bus32 maps from Kernel Virtual Addresses to 32 Bit PCI Bus
  388.   Addresses.
  389. */
  390. static inline DAC960_BusAddress32_T Virtual_to_Bus32(void *VirtualAddress)
  391. {
  392.   return (DAC960_BusAddress32_T) virt_to_bus(VirtualAddress);
  393. }
  394. /*
  395.   Bus32_to_Virtual maps from 32 Bit PCI Bus Addresses to Kernel Virtual
  396.   Addresses.
  397. */
  398. static inline void *Bus32_to_Virtual(DAC960_BusAddress32_T BusAddress)
  399. {
  400.   return (void *) bus_to_virt(BusAddress);
  401. }
  402. /*
  403.   Virtual_to_Bus64 maps from Kernel Virtual Addresses to 64 Bit PCI Bus
  404.   Addresses.
  405. */
  406. static inline DAC960_BusAddress64_T Virtual_to_Bus64(void *VirtualAddress)
  407. {
  408.   return (DAC960_BusAddress64_T) virt_to_bus(VirtualAddress);
  409. }
  410. /*
  411.   Define the DAC960 BA Series Controller Interface Register Offsets.
  412. */
  413. #define DAC960_BA_RegisterWindowSize 0x80
  414. typedef enum
  415. {
  416.   DAC960_BA_InboundDoorBellRegisterOffset = 0x60,
  417.   DAC960_BA_OutboundDoorBellRegisterOffset = 0x61,
  418.   DAC960_BA_InterruptStatusRegisterOffset = 0x30,
  419.   DAC960_BA_InterruptMaskRegisterOffset = 0x34,
  420.   DAC960_BA_CommandMailboxBusAddressOffset = 0x50,
  421.   DAC960_BA_CommandStatusOffset = 0x58,
  422.   DAC960_BA_ErrorStatusRegisterOffset = 0x63
  423. }
  424. DAC960_BA_RegisterOffsets_T;
  425. /*
  426.   Define the structure of the DAC960 BA Series Inbound Door Bell Register.
  427. */
  428. typedef union DAC960_BA_InboundDoorBellRegister
  429. {
  430.   unsigned char All;
  431.   struct {
  432.     boolean HardwareMailboxNewCommand:1; /* Bit 0 */
  433.     boolean AcknowledgeHardwareMailboxStatus:1; /* Bit 1 */
  434.     boolean GenerateInterrupt:1; /* Bit 2 */
  435.     boolean ControllerReset:1; /* Bit 3 */
  436.     boolean MemoryMailboxNewCommand:1; /* Bit 4 */
  437.     unsigned char :3; /* Bits 5-7 */
  438.   } Write;
  439.   struct {
  440.     boolean HardwareMailboxEmpty:1; /* Bit 0 */
  441.     boolean InitializationNotInProgress:1; /* Bit 1 */
  442.     unsigned char :6; /* Bits 2-7 */
  443.   } Read;
  444. }
  445. DAC960_BA_InboundDoorBellRegister_T;
  446. /*
  447.   Define the structure of the DAC960 BA Series Outbound Door Bell Register.
  448. */
  449. typedef union DAC960_BA_OutboundDoorBellRegister
  450. {
  451.   unsigned char All;
  452.   struct {
  453.     boolean AcknowledgeHardwareMailboxInterrupt:1; /* Bit 0 */
  454.     boolean AcknowledgeMemoryMailboxInterrupt:1; /* Bit 1 */
  455.     unsigned char :6; /* Bits 2-7 */
  456.   } Write;
  457.   struct {
  458.     boolean HardwareMailboxStatusAvailable:1; /* Bit 0 */
  459.     boolean MemoryMailboxStatusAvailable:1; /* Bit 1 */
  460.     unsigned char :6; /* Bits 2-7 */
  461.   } Read;
  462. }
  463. DAC960_BA_OutboundDoorBellRegister_T;
  464. /*
  465.   Define the structure of the DAC960 BA Series Interrupt Mask Register.
  466. */
  467. typedef union DAC960_BA_InterruptMaskRegister
  468. {
  469.   unsigned char All;
  470.   struct {
  471.     unsigned int :2; /* Bits 0-1 */
  472.     boolean DisableInterrupts:1; /* Bit 2 */
  473.     boolean DisableInterruptsI2O:1; /* Bit 3 */
  474.     unsigned int :4; /* Bits 4-7 */
  475.   } Bits;
  476. }
  477. DAC960_BA_InterruptMaskRegister_T;
  478. /*
  479.   Define the structure of the DAC960 BA Series Error Status Register.
  480. */
  481. typedef union DAC960_BA_ErrorStatusRegister
  482. {
  483.   unsigned char All;
  484.   struct {
  485.     unsigned int :2; /* Bits 0-1 */
  486.     boolean ErrorStatusPending:1; /* Bit 2 */
  487.     unsigned int :5; /* Bits 3-7 */
  488.   } Bits;
  489. }
  490. DAC960_BA_ErrorStatusRegister_T;
  491. /*
  492.   Define inline functions to provide an abstraction for reading and writing the
  493.   DAC960 BA Series Controller Interface Registers.
  494. */
  495. static inline
  496. void DAC960_BA_HardwareMailboxNewCommand(void *ControllerBaseAddress)
  497. {
  498.   DAC960_BA_InboundDoorBellRegister_T InboundDoorBellRegister;
  499.   InboundDoorBellRegister.All = 0;
  500.   InboundDoorBellRegister.Write.HardwareMailboxNewCommand = true;
  501.   writeb(InboundDoorBellRegister.All,
  502.  ControllerBaseAddress + DAC960_BA_InboundDoorBellRegisterOffset);
  503. }
  504. static inline
  505. void DAC960_BA_AcknowledgeHardwareMailboxStatus(void *ControllerBaseAddress)
  506. {
  507.   DAC960_BA_InboundDoorBellRegister_T InboundDoorBellRegister;
  508.   InboundDoorBellRegister.All = 0;
  509.   InboundDoorBellRegister.Write.AcknowledgeHardwareMailboxStatus = true;
  510.   writeb(InboundDoorBellRegister.All,
  511.  ControllerBaseAddress + DAC960_BA_InboundDoorBellRegisterOffset);
  512. }
  513. static inline
  514. void DAC960_BA_GenerateInterrupt(void *ControllerBaseAddress)
  515. {
  516.   DAC960_BA_InboundDoorBellRegister_T InboundDoorBellRegister;
  517.   InboundDoorBellRegister.All = 0;
  518.   InboundDoorBellRegister.Write.GenerateInterrupt = true;
  519.   writeb(InboundDoorBellRegister.All,
  520.  ControllerBaseAddress + DAC960_BA_InboundDoorBellRegisterOffset);
  521. }
  522. static inline
  523. void DAC960_BA_ControllerReset(void *ControllerBaseAddress)
  524. {
  525.   DAC960_BA_InboundDoorBellRegister_T InboundDoorBellRegister;
  526.   InboundDoorBellRegister.All = 0;
  527.   InboundDoorBellRegister.Write.ControllerReset = true;
  528.   writeb(InboundDoorBellRegister.All,
  529.  ControllerBaseAddress + DAC960_BA_InboundDoorBellRegisterOffset);
  530. }
  531. static inline
  532. void DAC960_BA_MemoryMailboxNewCommand(void *ControllerBaseAddress)
  533. {
  534.   DAC960_BA_InboundDoorBellRegister_T InboundDoorBellRegister;
  535.   InboundDoorBellRegister.All = 0;
  536.   InboundDoorBellRegister.Write.MemoryMailboxNewCommand = true;
  537.   writeb(InboundDoorBellRegister.All,
  538.  ControllerBaseAddress + DAC960_BA_InboundDoorBellRegisterOffset);
  539. }
  540. static inline
  541. boolean DAC960_BA_HardwareMailboxFullP(void *ControllerBaseAddress)
  542. {
  543.   DAC960_BA_InboundDoorBellRegister_T InboundDoorBellRegister;
  544.   InboundDoorBellRegister.All =
  545.     readb(ControllerBaseAddress + DAC960_BA_InboundDoorBellRegisterOffset);
  546.   return !InboundDoorBellRegister.Read.HardwareMailboxEmpty;
  547. }
  548. static inline
  549. boolean DAC960_BA_InitializationInProgressP(void *ControllerBaseAddress)
  550. {
  551.   DAC960_BA_InboundDoorBellRegister_T InboundDoorBellRegister;
  552.   InboundDoorBellRegister.All =
  553.     readb(ControllerBaseAddress + DAC960_BA_InboundDoorBellRegisterOffset);
  554.   return !InboundDoorBellRegister.Read.InitializationNotInProgress;
  555. }
  556. static inline
  557. void DAC960_BA_AcknowledgeHardwareMailboxInterrupt(void *ControllerBaseAddress)
  558. {
  559.   DAC960_BA_OutboundDoorBellRegister_T OutboundDoorBellRegister;
  560.   OutboundDoorBellRegister.All = 0;
  561.   OutboundDoorBellRegister.Write.AcknowledgeHardwareMailboxInterrupt = true;
  562.   writeb(OutboundDoorBellRegister.All,
  563.  ControllerBaseAddress + DAC960_BA_OutboundDoorBellRegisterOffset);
  564. }
  565. static inline
  566. void DAC960_BA_AcknowledgeMemoryMailboxInterrupt(void *ControllerBaseAddress)
  567. {
  568.   DAC960_BA_OutboundDoorBellRegister_T OutboundDoorBellRegister;
  569.   OutboundDoorBellRegister.All = 0;
  570.   OutboundDoorBellRegister.Write.AcknowledgeMemoryMailboxInterrupt = true;
  571.   writeb(OutboundDoorBellRegister.All,
  572.  ControllerBaseAddress + DAC960_BA_OutboundDoorBellRegisterOffset);
  573. }
  574. static inline
  575. void DAC960_BA_AcknowledgeInterrupt(void *ControllerBaseAddress)
  576. {
  577.   DAC960_BA_OutboundDoorBellRegister_T OutboundDoorBellRegister;
  578.   OutboundDoorBellRegister.All = 0;
  579.   OutboundDoorBellRegister.Write.AcknowledgeHardwareMailboxInterrupt = true;
  580.   OutboundDoorBellRegister.Write.AcknowledgeMemoryMailboxInterrupt = true;
  581.   writeb(OutboundDoorBellRegister.All,
  582.  ControllerBaseAddress + DAC960_BA_OutboundDoorBellRegisterOffset);
  583. }
  584. static inline
  585. boolean DAC960_BA_HardwareMailboxStatusAvailableP(void *ControllerBaseAddress)
  586. {
  587.   DAC960_BA_OutboundDoorBellRegister_T OutboundDoorBellRegister;
  588.   OutboundDoorBellRegister.All =
  589.     readb(ControllerBaseAddress + DAC960_BA_OutboundDoorBellRegisterOffset);
  590.   return OutboundDoorBellRegister.Read.HardwareMailboxStatusAvailable;
  591. }
  592. static inline
  593. boolean DAC960_BA_MemoryMailboxStatusAvailableP(void *ControllerBaseAddress)
  594. {
  595.   DAC960_BA_OutboundDoorBellRegister_T OutboundDoorBellRegister;
  596.   OutboundDoorBellRegister.All =
  597.     readb(ControllerBaseAddress + DAC960_BA_OutboundDoorBellRegisterOffset);
  598.   return OutboundDoorBellRegister.Read.MemoryMailboxStatusAvailable;
  599. }
  600. static inline
  601. void DAC960_BA_EnableInterrupts(void *ControllerBaseAddress)
  602. {
  603.   DAC960_BA_InterruptMaskRegister_T InterruptMaskRegister;
  604.   InterruptMaskRegister.All = 0xFF;
  605.   InterruptMaskRegister.Bits.DisableInterrupts = false;
  606.   InterruptMaskRegister.Bits.DisableInterruptsI2O = true;
  607.   writeb(InterruptMaskRegister.All,
  608.  ControllerBaseAddress + DAC960_BA_InterruptMaskRegisterOffset);
  609. }
  610. static inline
  611. void DAC960_BA_DisableInterrupts(void *ControllerBaseAddress)
  612. {
  613.   DAC960_BA_InterruptMaskRegister_T InterruptMaskRegister;
  614.   InterruptMaskRegister.All = 0xFF;
  615.   InterruptMaskRegister.Bits.DisableInterrupts = true;
  616.   InterruptMaskRegister.Bits.DisableInterruptsI2O = true;
  617.   writeb(InterruptMaskRegister.All,
  618.  ControllerBaseAddress + DAC960_BA_InterruptMaskRegisterOffset);
  619. }
  620. static inline
  621. boolean DAC960_BA_InterruptsEnabledP(void *ControllerBaseAddress)
  622. {
  623.   DAC960_BA_InterruptMaskRegister_T InterruptMaskRegister;
  624.   InterruptMaskRegister.All =
  625.     readb(ControllerBaseAddress + DAC960_BA_InterruptMaskRegisterOffset);
  626.   return !InterruptMaskRegister.Bits.DisableInterrupts;
  627. }
  628. static inline
  629. void DAC960_BA_WriteCommandMailbox(DAC960_V2_CommandMailbox_T
  630.      *MemoryCommandMailbox,
  631.    DAC960_V2_CommandMailbox_T
  632.      *CommandMailbox)
  633. {
  634.   memcpy(&MemoryCommandMailbox->Words[1], &CommandMailbox->Words[1],
  635.  sizeof(DAC960_V2_CommandMailbox_T) - sizeof(unsigned int));
  636.   wmb();
  637.   MemoryCommandMailbox->Words[0] = CommandMailbox->Words[0];
  638.   mb();
  639. }
  640. static inline
  641. void DAC960_BA_WriteHardwareMailbox(void *ControllerBaseAddress,
  642.     DAC960_V2_CommandMailbox_T *CommandMailbox)
  643. {
  644. #ifdef __ia64__
  645.   writeq(Virtual_to_Bus64(CommandMailbox),
  646.  ControllerBaseAddress + DAC960_BA_CommandMailboxBusAddressOffset);
  647. #else
  648.   writel(Virtual_to_Bus32(CommandMailbox),
  649.  ControllerBaseAddress + DAC960_BA_CommandMailboxBusAddressOffset);
  650. #endif
  651. }
  652. static inline DAC960_V2_CommandIdentifier_T
  653. DAC960_BA_ReadCommandIdentifier(void *ControllerBaseAddress)
  654. {
  655.   return readw(ControllerBaseAddress + DAC960_BA_CommandStatusOffset);
  656. }
  657. static inline DAC960_V2_CommandStatus_T
  658. DAC960_BA_ReadCommandStatus(void *ControllerBaseAddress)
  659. {
  660.   return readw(ControllerBaseAddress + DAC960_BA_CommandStatusOffset + 2);
  661. }
  662. static inline boolean
  663. DAC960_BA_ReadErrorStatus(void *ControllerBaseAddress,
  664.   unsigned char *ErrorStatus,
  665.   unsigned char *Parameter0,
  666.   unsigned char *Parameter1)
  667. {
  668.   DAC960_BA_ErrorStatusRegister_T ErrorStatusRegister;
  669.   ErrorStatusRegister.All =
  670.     readb(ControllerBaseAddress + DAC960_BA_ErrorStatusRegisterOffset);
  671.   if (!ErrorStatusRegister.Bits.ErrorStatusPending) return false;
  672.   ErrorStatusRegister.Bits.ErrorStatusPending = false;
  673.   *ErrorStatus = ErrorStatusRegister.All;
  674.   *Parameter0 =
  675.     readb(ControllerBaseAddress + DAC960_BA_CommandMailboxBusAddressOffset + 0);
  676.   *Parameter1 =
  677.     readb(ControllerBaseAddress + DAC960_BA_CommandMailboxBusAddressOffset + 1);
  678.   writeb(0xFF, ControllerBaseAddress + DAC960_BA_ErrorStatusRegisterOffset);
  679.   return true;
  680. }
  681. /*
  682.   Define the DAC960 LP Series Controller Interface Register Offsets.
  683. */
  684. #define DAC960_LP_RegisterWindowSize 0x80
  685. typedef enum
  686. {
  687.   DAC960_LP_InboundDoorBellRegisterOffset = 0x20,
  688.   DAC960_LP_OutboundDoorBellRegisterOffset = 0x2C,
  689.   DAC960_LP_InterruptStatusRegisterOffset = 0x30,
  690.   DAC960_LP_InterruptMaskRegisterOffset = 0x34,
  691.   DAC960_LP_CommandMailboxBusAddressOffset = 0x10,
  692.   DAC960_LP_CommandStatusOffset = 0x18,
  693.   DAC960_LP_ErrorStatusRegisterOffset = 0x2E
  694. }
  695. DAC960_LP_RegisterOffsets_T;
  696. /*
  697.   Define the structure of the DAC960 LP Series Inbound Door Bell Register.
  698. */
  699. typedef union DAC960_LP_InboundDoorBellRegister
  700. {
  701.   unsigned char All;
  702.   struct {
  703.     boolean HardwareMailboxNewCommand:1; /* Bit 0 */
  704.     boolean AcknowledgeHardwareMailboxStatus:1; /* Bit 1 */
  705.     boolean GenerateInterrupt:1; /* Bit 2 */
  706.     boolean ControllerReset:1; /* Bit 3 */
  707.     boolean MemoryMailboxNewCommand:1; /* Bit 4 */
  708.     unsigned char :3; /* Bits 5-7 */
  709.   } Write;
  710.   struct {
  711.     boolean HardwareMailboxFull:1; /* Bit 0 */
  712.     boolean InitializationInProgress:1; /* Bit 1 */
  713.     unsigned char :6; /* Bits 2-7 */
  714.   } Read;
  715. }
  716. DAC960_LP_InboundDoorBellRegister_T;
  717. /*
  718.   Define the structure of the DAC960 LP Series Outbound Door Bell Register.
  719. */
  720. typedef union DAC960_LP_OutboundDoorBellRegister
  721. {
  722.   unsigned char All;
  723.   struct {
  724.     boolean AcknowledgeHardwareMailboxInterrupt:1; /* Bit 0 */
  725.     boolean AcknowledgeMemoryMailboxInterrupt:1; /* Bit 1 */
  726.     unsigned char :6; /* Bits 2-7 */
  727.   } Write;
  728.   struct {
  729.     boolean HardwareMailboxStatusAvailable:1; /* Bit 0 */
  730.     boolean MemoryMailboxStatusAvailable:1; /* Bit 1 */
  731.     unsigned char :6; /* Bits 2-7 */
  732.   } Read;
  733. }
  734. DAC960_LP_OutboundDoorBellRegister_T;
  735. /*
  736.   Define the structure of the DAC960 LP Series Interrupt Mask Register.
  737. */
  738. typedef union DAC960_LP_InterruptMaskRegister
  739. {
  740.   unsigned char All;
  741.   struct {
  742.     unsigned int :2; /* Bits 0-1 */
  743.     boolean DisableInterrupts:1; /* Bit 2 */
  744.     unsigned int :5; /* Bits 3-7 */
  745.   } Bits;
  746. }
  747. DAC960_LP_InterruptMaskRegister_T;
  748. /*
  749.   Define the structure of the DAC960 LP Series Error Status Register.
  750. */
  751. typedef union DAC960_LP_ErrorStatusRegister
  752. {
  753.   unsigned char All;
  754.   struct {
  755.     unsigned int :2; /* Bits 0-1 */
  756.     boolean ErrorStatusPending:1; /* Bit 2 */
  757.     unsigned int :5; /* Bits 3-7 */
  758.   } Bits;
  759. }
  760. DAC960_LP_ErrorStatusRegister_T;
  761. /*
  762.   Define inline functions to provide an abstraction for reading and writing the
  763.   DAC960 LP Series Controller Interface Registers.
  764. */
  765. static inline
  766. void DAC960_LP_HardwareMailboxNewCommand(void *ControllerBaseAddress)
  767. {
  768.   DAC960_LP_InboundDoorBellRegister_T InboundDoorBellRegister;
  769.   InboundDoorBellRegister.All = 0;
  770.   InboundDoorBellRegister.Write.HardwareMailboxNewCommand = true;
  771.   writeb(InboundDoorBellRegister.All,
  772.  ControllerBaseAddress + DAC960_LP_InboundDoorBellRegisterOffset);
  773. }
  774. static inline
  775. void DAC960_LP_AcknowledgeHardwareMailboxStatus(void *ControllerBaseAddress)
  776. {
  777.   DAC960_LP_InboundDoorBellRegister_T InboundDoorBellRegister;
  778.   InboundDoorBellRegister.All = 0;
  779.   InboundDoorBellRegister.Write.AcknowledgeHardwareMailboxStatus = true;
  780.   writeb(InboundDoorBellRegister.All,
  781.  ControllerBaseAddress + DAC960_LP_InboundDoorBellRegisterOffset);
  782. }
  783. static inline
  784. void DAC960_LP_GenerateInterrupt(void *ControllerBaseAddress)
  785. {
  786.   DAC960_LP_InboundDoorBellRegister_T InboundDoorBellRegister;
  787.   InboundDoorBellRegister.All = 0;
  788.   InboundDoorBellRegister.Write.GenerateInterrupt = true;
  789.   writeb(InboundDoorBellRegister.All,
  790.  ControllerBaseAddress + DAC960_LP_InboundDoorBellRegisterOffset);
  791. }
  792. static inline
  793. void DAC960_LP_ControllerReset(void *ControllerBaseAddress)
  794. {
  795.   DAC960_LP_InboundDoorBellRegister_T InboundDoorBellRegister;
  796.   InboundDoorBellRegister.All = 0;
  797.   InboundDoorBellRegister.Write.ControllerReset = true;
  798.   writeb(InboundDoorBellRegister.All,
  799.  ControllerBaseAddress + DAC960_LP_InboundDoorBellRegisterOffset);
  800. }
  801. static inline
  802. void DAC960_LP_MemoryMailboxNewCommand(void *ControllerBaseAddress)
  803. {
  804.   DAC960_LP_InboundDoorBellRegister_T InboundDoorBellRegister;
  805.   InboundDoorBellRegister.All = 0;
  806.   InboundDoorBellRegister.Write.MemoryMailboxNewCommand = true;
  807.   writeb(InboundDoorBellRegister.All,
  808.  ControllerBaseAddress + DAC960_LP_InboundDoorBellRegisterOffset);
  809. }
  810. static inline
  811. boolean DAC960_LP_HardwareMailboxFullP(void *ControllerBaseAddress)
  812. {
  813.   DAC960_LP_InboundDoorBellRegister_T InboundDoorBellRegister;
  814.   InboundDoorBellRegister.All =
  815.     readb(ControllerBaseAddress + DAC960_LP_InboundDoorBellRegisterOffset);
  816.   return InboundDoorBellRegister.Read.HardwareMailboxFull;
  817. }
  818. static inline
  819. boolean DAC960_LP_InitializationInProgressP(void *ControllerBaseAddress)
  820. {
  821.   DAC960_LP_InboundDoorBellRegister_T InboundDoorBellRegister;
  822.   InboundDoorBellRegister.All =
  823.     readb(ControllerBaseAddress + DAC960_LP_InboundDoorBellRegisterOffset);
  824.   return InboundDoorBellRegister.Read.InitializationInProgress;
  825. }
  826. static inline
  827. void DAC960_LP_AcknowledgeHardwareMailboxInterrupt(void *ControllerBaseAddress)
  828. {
  829.   DAC960_LP_OutboundDoorBellRegister_T OutboundDoorBellRegister;
  830.   OutboundDoorBellRegister.All = 0;
  831.   OutboundDoorBellRegister.Write.AcknowledgeHardwareMailboxInterrupt = true;
  832.   writeb(OutboundDoorBellRegister.All,
  833.  ControllerBaseAddress + DAC960_LP_OutboundDoorBellRegisterOffset);
  834. }
  835. static inline
  836. void DAC960_LP_AcknowledgeMemoryMailboxInterrupt(void *ControllerBaseAddress)
  837. {
  838.   DAC960_LP_OutboundDoorBellRegister_T OutboundDoorBellRegister;
  839.   OutboundDoorBellRegister.All = 0;
  840.   OutboundDoorBellRegister.Write.AcknowledgeMemoryMailboxInterrupt = true;
  841.   writeb(OutboundDoorBellRegister.All,
  842.  ControllerBaseAddress + DAC960_LP_OutboundDoorBellRegisterOffset);
  843. }
  844. static inline
  845. void DAC960_LP_AcknowledgeInterrupt(void *ControllerBaseAddress)
  846. {
  847.   DAC960_LP_OutboundDoorBellRegister_T OutboundDoorBellRegister;
  848.   OutboundDoorBellRegister.All = 0;
  849.   OutboundDoorBellRegister.Write.AcknowledgeHardwareMailboxInterrupt = true;
  850.   OutboundDoorBellRegister.Write.AcknowledgeMemoryMailboxInterrupt = true;
  851.   writeb(OutboundDoorBellRegister.All,
  852.  ControllerBaseAddress + DAC960_LP_OutboundDoorBellRegisterOffset);
  853. }
  854. static inline
  855. boolean DAC960_LP_HardwareMailboxStatusAvailableP(void *ControllerBaseAddress)
  856. {
  857.   DAC960_LP_OutboundDoorBellRegister_T OutboundDoorBellRegister;
  858.   OutboundDoorBellRegister.All =
  859.     readb(ControllerBaseAddress + DAC960_LP_OutboundDoorBellRegisterOffset);
  860.   return OutboundDoorBellRegister.Read.HardwareMailboxStatusAvailable;
  861. }
  862. static inline
  863. boolean DAC960_LP_MemoryMailboxStatusAvailableP(void *ControllerBaseAddress)
  864. {
  865.   DAC960_LP_OutboundDoorBellRegister_T OutboundDoorBellRegister;
  866.   OutboundDoorBellRegister.All =
  867.     readb(ControllerBaseAddress + DAC960_LP_OutboundDoorBellRegisterOffset);
  868.   return OutboundDoorBellRegister.Read.MemoryMailboxStatusAvailable;
  869. }
  870. static inline
  871. void DAC960_LP_EnableInterrupts(void *ControllerBaseAddress)
  872. {
  873.   DAC960_LP_InterruptMaskRegister_T InterruptMaskRegister;
  874.   InterruptMaskRegister.All = 0xFF;
  875.   InterruptMaskRegister.Bits.DisableInterrupts = false;
  876.   writeb(InterruptMaskRegister.All,
  877.  ControllerBaseAddress + DAC960_LP_InterruptMaskRegisterOffset);
  878. }
  879. static inline
  880. void DAC960_LP_DisableInterrupts(void *ControllerBaseAddress)
  881. {
  882.   DAC960_LP_InterruptMaskRegister_T InterruptMaskRegister;
  883.   InterruptMaskRegister.All = 0xFF;
  884.   InterruptMaskRegister.Bits.DisableInterrupts = true;
  885.   writeb(InterruptMaskRegister.All,
  886.  ControllerBaseAddress + DAC960_LP_InterruptMaskRegisterOffset);
  887. }
  888. static inline
  889. boolean DAC960_LP_InterruptsEnabledP(void *ControllerBaseAddress)
  890. {
  891.   DAC960_LP_InterruptMaskRegister_T InterruptMaskRegister;
  892.   InterruptMaskRegister.All =
  893.     readb(ControllerBaseAddress + DAC960_LP_InterruptMaskRegisterOffset);
  894.   return !InterruptMaskRegister.Bits.DisableInterrupts;
  895. }
  896. static inline
  897. void DAC960_LP_WriteCommandMailbox(DAC960_V2_CommandMailbox_T
  898.      *MemoryCommandMailbox,
  899.    DAC960_V2_CommandMailbox_T
  900.      *CommandMailbox)
  901. {
  902.   memcpy(&MemoryCommandMailbox->Words[1], &CommandMailbox->Words[1],
  903.  sizeof(DAC960_V2_CommandMailbox_T) - sizeof(unsigned int));
  904.   wmb();
  905.   MemoryCommandMailbox->Words[0] = CommandMailbox->Words[0];
  906.   mb();
  907. }
  908. static inline
  909. void DAC960_LP_WriteHardwareMailbox(void *ControllerBaseAddress,
  910.     DAC960_V2_CommandMailbox_T *CommandMailbox)
  911. {
  912. #ifdef __ia64__
  913.   writeq(Virtual_to_Bus64(CommandMailbox),
  914.  ControllerBaseAddress + DAC960_LP_CommandMailboxBusAddressOffset);
  915. #else
  916.   writel(Virtual_to_Bus32(CommandMailbox),
  917.  ControllerBaseAddress + DAC960_LP_CommandMailboxBusAddressOffset);
  918. #endif
  919. }
  920. static inline DAC960_V2_CommandIdentifier_T
  921. DAC960_LP_ReadCommandIdentifier(void *ControllerBaseAddress)
  922. {
  923.   return readw(ControllerBaseAddress + DAC960_LP_CommandStatusOffset);
  924. }
  925. static inline DAC960_V2_CommandStatus_T
  926. DAC960_LP_ReadCommandStatus(void *ControllerBaseAddress)
  927. {
  928.   return readw(ControllerBaseAddress + DAC960_LP_CommandStatusOffset + 2);
  929. }
  930. static inline boolean
  931. DAC960_LP_ReadErrorStatus(void *ControllerBaseAddress,
  932.   unsigned char *ErrorStatus,
  933.   unsigned char *Parameter0,
  934.   unsigned char *Parameter1)
  935. {
  936.   DAC960_LP_ErrorStatusRegister_T ErrorStatusRegister;
  937.   ErrorStatusRegister.All =
  938.     readb(ControllerBaseAddress + DAC960_LP_ErrorStatusRegisterOffset);
  939.   if (!ErrorStatusRegister.Bits.ErrorStatusPending) return false;
  940.   ErrorStatusRegister.Bits.ErrorStatusPending = false;
  941.   *ErrorStatus = ErrorStatusRegister.All;
  942.   *Parameter0 =
  943.     readb(ControllerBaseAddress + DAC960_LP_CommandMailboxBusAddressOffset + 0);
  944.   *Parameter1 =
  945.     readb(ControllerBaseAddress + DAC960_LP_CommandMailboxBusAddressOffset + 1);
  946.   writeb(0xFF, ControllerBaseAddress + DAC960_LP_ErrorStatusRegisterOffset);
  947.   return true;
  948. }
  949. /*
  950.   Define the DAC960 LA Series Controller Interface Register Offsets.
  951. */
  952. #define DAC960_LA_RegisterWindowSize 0x80
  953. typedef enum
  954. {
  955.   DAC960_LA_InboundDoorBellRegisterOffset = 0x60,
  956.   DAC960_LA_OutboundDoorBellRegisterOffset = 0x61,
  957.   DAC960_LA_InterruptMaskRegisterOffset = 0x34,
  958.   DAC960_LA_CommandOpcodeRegisterOffset = 0x50,
  959.   DAC960_LA_CommandIdentifierRegisterOffset = 0x51,
  960.   DAC960_LA_MailboxRegister2Offset = 0x52,
  961.   DAC960_LA_MailboxRegister3Offset = 0x53,
  962.   DAC960_LA_MailboxRegister4Offset = 0x54,
  963.   DAC960_LA_MailboxRegister5Offset = 0x55,
  964.   DAC960_LA_MailboxRegister6Offset = 0x56,
  965.   DAC960_LA_MailboxRegister7Offset = 0x57,
  966.   DAC960_LA_MailboxRegister8Offset = 0x58,
  967.   DAC960_LA_MailboxRegister9Offset = 0x59,
  968.   DAC960_LA_MailboxRegister10Offset = 0x5A,
  969.   DAC960_LA_MailboxRegister11Offset = 0x5B,
  970.   DAC960_LA_MailboxRegister12Offset = 0x5C,
  971.   DAC960_LA_StatusCommandIdentifierRegOffset = 0x5D,
  972.   DAC960_LA_StatusRegisterOffset = 0x5E,
  973.   DAC960_LA_ErrorStatusRegisterOffset = 0x63
  974. }
  975. DAC960_LA_RegisterOffsets_T;
  976. /*
  977.   Define the structure of the DAC960 LA Series Inbound Door Bell Register.
  978. */
  979. typedef union DAC960_LA_InboundDoorBellRegister
  980. {
  981.   unsigned char All;
  982.   struct {
  983.     boolean HardwareMailboxNewCommand:1; /* Bit 0 */
  984.     boolean AcknowledgeHardwareMailboxStatus:1; /* Bit 1 */
  985.     boolean GenerateInterrupt:1; /* Bit 2 */
  986.     boolean ControllerReset:1; /* Bit 3 */
  987.     boolean MemoryMailboxNewCommand:1; /* Bit 4 */
  988.     unsigned char :3; /* Bits 5-7 */
  989.   } Write;
  990.   struct {
  991.     boolean HardwareMailboxEmpty:1; /* Bit 0 */
  992.     boolean InitializationNotInProgress:1; /* Bit 1 */
  993.     unsigned char :6; /* Bits 2-7 */
  994.   } Read;
  995. }
  996. DAC960_LA_InboundDoorBellRegister_T;
  997. /*
  998.   Define the structure of the DAC960 LA Series Outbound Door Bell Register.
  999. */
  1000. typedef union DAC960_LA_OutboundDoorBellRegister
  1001. {
  1002.   unsigned char All;
  1003.   struct {
  1004.     boolean AcknowledgeHardwareMailboxInterrupt:1; /* Bit 0 */
  1005.     boolean AcknowledgeMemoryMailboxInterrupt:1; /* Bit 1 */
  1006.     unsigned char :6; /* Bits 2-7 */
  1007.   } Write;
  1008.   struct {
  1009.     boolean HardwareMailboxStatusAvailable:1; /* Bit 0 */
  1010.     boolean MemoryMailboxStatusAvailable:1; /* Bit 1 */
  1011.     unsigned char :6; /* Bits 2-7 */
  1012.   } Read;
  1013. }
  1014. DAC960_LA_OutboundDoorBellRegister_T;
  1015. /*
  1016.   Define the structure of the DAC960 LA Series Interrupt Mask Register.
  1017. */
  1018. typedef union DAC960_LA_InterruptMaskRegister
  1019. {
  1020.   unsigned char All;
  1021.   struct {
  1022.     unsigned char :2; /* Bits 0-1 */
  1023.     boolean DisableInterrupts:1; /* Bit 2 */
  1024.     unsigned char :5; /* Bits 3-7 */
  1025.   } Bits;
  1026. }
  1027. DAC960_LA_InterruptMaskRegister_T;
  1028. /*
  1029.   Define the structure of the DAC960 LA Series Error Status Register.
  1030. */
  1031. typedef union DAC960_LA_ErrorStatusRegister
  1032. {
  1033.   unsigned char All;
  1034.   struct {
  1035.     unsigned int :2; /* Bits 0-1 */
  1036.     boolean ErrorStatusPending:1; /* Bit 2 */
  1037.     unsigned int :5; /* Bits 3-7 */
  1038.   } Bits;
  1039. }
  1040. DAC960_LA_ErrorStatusRegister_T;
  1041. /*
  1042.   Define inline functions to provide an abstraction for reading and writing the
  1043.   DAC960 LA Series Controller Interface Registers.
  1044. */
  1045. static inline
  1046. void DAC960_LA_HardwareMailboxNewCommand(void *ControllerBaseAddress)
  1047. {
  1048.   DAC960_LA_InboundDoorBellRegister_T InboundDoorBellRegister;
  1049.   InboundDoorBellRegister.All = 0;
  1050.   InboundDoorBellRegister.Write.HardwareMailboxNewCommand = true;
  1051.   writeb(InboundDoorBellRegister.All,
  1052.  ControllerBaseAddress + DAC960_LA_InboundDoorBellRegisterOffset);
  1053. }
  1054. static inline
  1055. void DAC960_LA_AcknowledgeHardwareMailboxStatus(void *ControllerBaseAddress)
  1056. {
  1057.   DAC960_LA_InboundDoorBellRegister_T InboundDoorBellRegister;
  1058.   InboundDoorBellRegister.All = 0;
  1059.   InboundDoorBellRegister.Write.AcknowledgeHardwareMailboxStatus = true;
  1060.   writeb(InboundDoorBellRegister.All,
  1061.  ControllerBaseAddress + DAC960_LA_InboundDoorBellRegisterOffset);
  1062. }
  1063. static inline
  1064. void DAC960_LA_GenerateInterrupt(void *ControllerBaseAddress)
  1065. {
  1066.   DAC960_LA_InboundDoorBellRegister_T InboundDoorBellRegister;
  1067.   InboundDoorBellRegister.All = 0;
  1068.   InboundDoorBellRegister.Write.GenerateInterrupt = true;
  1069.   writeb(InboundDoorBellRegister.All,
  1070.  ControllerBaseAddress + DAC960_LA_InboundDoorBellRegisterOffset);
  1071. }
  1072. static inline
  1073. void DAC960_LA_ControllerReset(void *ControllerBaseAddress)
  1074. {
  1075.   DAC960_LA_InboundDoorBellRegister_T InboundDoorBellRegister;
  1076.   InboundDoorBellRegister.All = 0;
  1077.   InboundDoorBellRegister.Write.ControllerReset = true;
  1078.   writeb(InboundDoorBellRegister.All,
  1079.  ControllerBaseAddress + DAC960_LA_InboundDoorBellRegisterOffset);
  1080. }
  1081. static inline
  1082. void DAC960_LA_MemoryMailboxNewCommand(void *ControllerBaseAddress)
  1083. {
  1084.   DAC960_LA_InboundDoorBellRegister_T InboundDoorBellRegister;
  1085.   InboundDoorBellRegister.All = 0;
  1086.   InboundDoorBellRegister.Write.MemoryMailboxNewCommand = true;
  1087.   writeb(InboundDoorBellRegister.All,
  1088.  ControllerBaseAddress + DAC960_LA_InboundDoorBellRegisterOffset);
  1089. }
  1090. static inline
  1091. boolean DAC960_LA_HardwareMailboxFullP(void *ControllerBaseAddress)
  1092. {
  1093.   DAC960_LA_InboundDoorBellRegister_T InboundDoorBellRegister;
  1094.   InboundDoorBellRegister.All =
  1095.     readb(ControllerBaseAddress + DAC960_LA_InboundDoorBellRegisterOffset);
  1096.   return !InboundDoorBellRegister.Read.HardwareMailboxEmpty;
  1097. }
  1098. static inline
  1099. boolean DAC960_LA_InitializationInProgressP(void *ControllerBaseAddress)
  1100. {
  1101.   DAC960_LA_InboundDoorBellRegister_T InboundDoorBellRegister;
  1102.   InboundDoorBellRegister.All =
  1103.     readb(ControllerBaseAddress + DAC960_LA_InboundDoorBellRegisterOffset);
  1104.   return !InboundDoorBellRegister.Read.InitializationNotInProgress;
  1105. }
  1106. static inline
  1107. void DAC960_LA_AcknowledgeHardwareMailboxInterrupt(void *ControllerBaseAddress)
  1108. {
  1109.   DAC960_LA_OutboundDoorBellRegister_T OutboundDoorBellRegister;
  1110.   OutboundDoorBellRegister.All = 0;
  1111.   OutboundDoorBellRegister.Write.AcknowledgeHardwareMailboxInterrupt = true;
  1112.   writeb(OutboundDoorBellRegister.All,
  1113.  ControllerBaseAddress + DAC960_LA_OutboundDoorBellRegisterOffset);
  1114. }
  1115. static inline
  1116. void DAC960_LA_AcknowledgeMemoryMailboxInterrupt(void *ControllerBaseAddress)
  1117. {
  1118.   DAC960_LA_OutboundDoorBellRegister_T OutboundDoorBellRegister;
  1119.   OutboundDoorBellRegister.All = 0;
  1120.   OutboundDoorBellRegister.Write.AcknowledgeMemoryMailboxInterrupt = true;
  1121.   writeb(OutboundDoorBellRegister.All,
  1122.  ControllerBaseAddress + DAC960_LA_OutboundDoorBellRegisterOffset);
  1123. }
  1124. static inline
  1125. void DAC960_LA_AcknowledgeInterrupt(void *ControllerBaseAddress)
  1126. {
  1127.   DAC960_LA_OutboundDoorBellRegister_T OutboundDoorBellRegister;
  1128.   OutboundDoorBellRegister.All = 0;
  1129.   OutboundDoorBellRegister.Write.AcknowledgeHardwareMailboxInterrupt = true;
  1130.   OutboundDoorBellRegister.Write.AcknowledgeMemoryMailboxInterrupt = true;
  1131.   writeb(OutboundDoorBellRegister.All,
  1132.  ControllerBaseAddress + DAC960_LA_OutboundDoorBellRegisterOffset);
  1133. }
  1134. static inline
  1135. boolean DAC960_LA_HardwareMailboxStatusAvailableP(void *ControllerBaseAddress)
  1136. {
  1137.   DAC960_LA_OutboundDoorBellRegister_T OutboundDoorBellRegister;
  1138.   OutboundDoorBellRegister.All =
  1139.     readb(ControllerBaseAddress + DAC960_LA_OutboundDoorBellRegisterOffset);
  1140.   return OutboundDoorBellRegister.Read.HardwareMailboxStatusAvailable;
  1141. }
  1142. static inline
  1143. boolean DAC960_LA_MemoryMailboxStatusAvailableP(void *ControllerBaseAddress)
  1144. {
  1145.   DAC960_LA_OutboundDoorBellRegister_T OutboundDoorBellRegister;
  1146.   OutboundDoorBellRegister.All =
  1147.     readb(ControllerBaseAddress + DAC960_LA_OutboundDoorBellRegisterOffset);
  1148.   return OutboundDoorBellRegister.Read.MemoryMailboxStatusAvailable;
  1149. }
  1150. static inline
  1151. void DAC960_LA_EnableInterrupts(void *ControllerBaseAddress)
  1152. {
  1153.   DAC960_LA_InterruptMaskRegister_T InterruptMaskRegister;
  1154.   InterruptMaskRegister.All = 0xFF;
  1155.   InterruptMaskRegister.Bits.DisableInterrupts = false;
  1156.   writeb(InterruptMaskRegister.All,
  1157.  ControllerBaseAddress + DAC960_LA_InterruptMaskRegisterOffset);
  1158. }
  1159. static inline
  1160. void DAC960_LA_DisableInterrupts(void *ControllerBaseAddress)
  1161. {
  1162.   DAC960_LA_InterruptMaskRegister_T InterruptMaskRegister;
  1163.   InterruptMaskRegister.All = 0xFF;
  1164.   InterruptMaskRegister.Bits.DisableInterrupts = true;
  1165.   writeb(InterruptMaskRegister.All,
  1166.  ControllerBaseAddress + DAC960_LA_InterruptMaskRegisterOffset);
  1167. }
  1168. static inline
  1169. boolean DAC960_LA_InterruptsEnabledP(void *ControllerBaseAddress)
  1170. {
  1171.   DAC960_LA_InterruptMaskRegister_T InterruptMaskRegister;
  1172.   InterruptMaskRegister.All =
  1173.     readb(ControllerBaseAddress + DAC960_LA_InterruptMaskRegisterOffset);
  1174.   return !InterruptMaskRegister.Bits.DisableInterrupts;
  1175. }
  1176. static inline
  1177. void DAC960_LA_WriteCommandMailbox(DAC960_V1_CommandMailbox_T
  1178.      *MemoryCommandMailbox,
  1179.    DAC960_V1_CommandMailbox_T
  1180.      *CommandMailbox)
  1181. {
  1182.   MemoryCommandMailbox->Words[1] = CommandMailbox->Words[1];
  1183.   MemoryCommandMailbox->Words[2] = CommandMailbox->Words[2];
  1184.   MemoryCommandMailbox->Words[3] = CommandMailbox->Words[3];
  1185.   wmb();
  1186.   MemoryCommandMailbox->Words[0] = CommandMailbox->Words[0];
  1187.   mb();
  1188. }
  1189. static inline
  1190. void DAC960_LA_WriteHardwareMailbox(void *ControllerBaseAddress,
  1191.     DAC960_V1_CommandMailbox_T *CommandMailbox)
  1192. {
  1193.   writel(CommandMailbox->Words[0],
  1194.  ControllerBaseAddress + DAC960_LA_CommandOpcodeRegisterOffset);
  1195.   writel(CommandMailbox->Words[1],
  1196.  ControllerBaseAddress + DAC960_LA_MailboxRegister4Offset);
  1197.   writel(CommandMailbox->Words[2],
  1198.  ControllerBaseAddress + DAC960_LA_MailboxRegister8Offset);
  1199.   writeb(CommandMailbox->Bytes[12],
  1200.  ControllerBaseAddress + DAC960_LA_MailboxRegister12Offset);
  1201. }
  1202. static inline DAC960_V1_CommandIdentifier_T
  1203. DAC960_LA_ReadStatusCommandIdentifier(void *ControllerBaseAddress)
  1204. {
  1205.   return readb(ControllerBaseAddress
  1206.        + DAC960_LA_StatusCommandIdentifierRegOffset);
  1207. }
  1208. static inline DAC960_V1_CommandStatus_T
  1209. DAC960_LA_ReadStatusRegister(void *ControllerBaseAddress)
  1210. {
  1211.   return readw(ControllerBaseAddress + DAC960_LA_StatusRegisterOffset);
  1212. }
  1213. static inline boolean
  1214. DAC960_LA_ReadErrorStatus(void *ControllerBaseAddress,
  1215.   unsigned char *ErrorStatus,
  1216.   unsigned char *Parameter0,
  1217.   unsigned char *Parameter1)
  1218. {
  1219.   DAC960_LA_ErrorStatusRegister_T ErrorStatusRegister;
  1220.   ErrorStatusRegister.All =
  1221.     readb(ControllerBaseAddress + DAC960_LA_ErrorStatusRegisterOffset);
  1222.   if (!ErrorStatusRegister.Bits.ErrorStatusPending) return false;
  1223.   ErrorStatusRegister.Bits.ErrorStatusPending = false;
  1224.   *ErrorStatus = ErrorStatusRegister.All;
  1225.   *Parameter0 =
  1226.     readb(ControllerBaseAddress + DAC960_LA_CommandOpcodeRegisterOffset);
  1227.   *Parameter1 =
  1228.     readb(ControllerBaseAddress + DAC960_LA_CommandIdentifierRegisterOffset);
  1229.   writeb(0xFF, ControllerBaseAddress + DAC960_LA_ErrorStatusRegisterOffset);
  1230.   return true;
  1231. }
  1232. static inline
  1233. void DAC960_LA_SaveMemoryMailboxInfo(DAC960_Controller_T *Controller)
  1234. {
  1235. #ifdef __i386__
  1236.   void *ControllerBaseAddress = Controller->BaseAddress;
  1237.   writel(0x743C485E,
  1238.  ControllerBaseAddress + DAC960_LA_CommandOpcodeRegisterOffset);
  1239.   writel((unsigned long) Controller->V1.FirstCommandMailbox,
  1240.  ControllerBaseAddress + DAC960_LA_MailboxRegister4Offset);
  1241.   writew(Controller->V1.NextCommandMailbox - Controller->V1.FirstCommandMailbox,
  1242.  ControllerBaseAddress + DAC960_LA_MailboxRegister8Offset);
  1243.   writew(Controller->V1.NextStatusMailbox - Controller->V1.FirstStatusMailbox,
  1244.  ControllerBaseAddress + DAC960_LA_MailboxRegister10Offset);
  1245. #endif
  1246. }
  1247. static inline
  1248. void DAC960_LA_RestoreMemoryMailboxInfo(DAC960_Controller_T *Controller,
  1249. void **MemoryMailboxAddress,
  1250. short *NextCommandMailboxIndex,
  1251. short *NextStatusMailboxIndex)
  1252. {
  1253. #ifdef __i386__
  1254.   void *ControllerBaseAddress = Controller->BaseAddress;
  1255.   if (readl(ControllerBaseAddress
  1256.     + DAC960_LA_CommandOpcodeRegisterOffset) != 0x743C485E)
  1257.     return;
  1258.   *MemoryMailboxAddress =
  1259.     (void *) readl(ControllerBaseAddress + DAC960_LA_MailboxRegister4Offset);
  1260.   *NextCommandMailboxIndex =
  1261.     readw(ControllerBaseAddress + DAC960_LA_MailboxRegister8Offset);
  1262.   *NextStatusMailboxIndex =
  1263.     readw(ControllerBaseAddress + DAC960_LA_MailboxRegister10Offset);
  1264. #endif
  1265. }
  1266. /*
  1267.   Define the DAC960 PG Series Controller Interface Register Offsets.
  1268. */
  1269. #define DAC960_PG_RegisterWindowSize 0x2000
  1270. typedef enum
  1271. {
  1272.   DAC960_PG_InboundDoorBellRegisterOffset = 0x0020,
  1273.   DAC960_PG_OutboundDoorBellRegisterOffset = 0x002C,
  1274.   DAC960_PG_InterruptMaskRegisterOffset = 0x0034,
  1275.   DAC960_PG_CommandOpcodeRegisterOffset = 0x1000,
  1276.   DAC960_PG_CommandIdentifierRegisterOffset = 0x1001,
  1277.   DAC960_PG_MailboxRegister2Offset = 0x1002,
  1278.   DAC960_PG_MailboxRegister3Offset = 0x1003,
  1279.   DAC960_PG_MailboxRegister4Offset = 0x1004,
  1280.   DAC960_PG_MailboxRegister5Offset = 0x1005,
  1281.   DAC960_PG_MailboxRegister6Offset = 0x1006,
  1282.   DAC960_PG_MailboxRegister7Offset = 0x1007,
  1283.   DAC960_PG_MailboxRegister8Offset = 0x1008,
  1284.   DAC960_PG_MailboxRegister9Offset = 0x1009,
  1285.   DAC960_PG_MailboxRegister10Offset = 0x100A,
  1286.   DAC960_PG_MailboxRegister11Offset = 0x100B,
  1287.   DAC960_PG_MailboxRegister12Offset = 0x100C,
  1288.   DAC960_PG_StatusCommandIdentifierRegOffset = 0x1018,
  1289.   DAC960_PG_StatusRegisterOffset = 0x101A,
  1290.   DAC960_PG_ErrorStatusRegisterOffset = 0x103F
  1291. }
  1292. DAC960_PG_RegisterOffsets_T;
  1293. /*
  1294.   Define the structure of the DAC960 PG Series Inbound Door Bell Register.
  1295. */
  1296. typedef union DAC960_PG_InboundDoorBellRegister
  1297. {
  1298.   unsigned int All;
  1299.   struct {
  1300.     boolean HardwareMailboxNewCommand:1; /* Bit 0 */
  1301.     boolean AcknowledgeHardwareMailboxStatus:1; /* Bit 1 */
  1302.     boolean GenerateInterrupt:1; /* Bit 2 */
  1303.     boolean ControllerReset:1; /* Bit 3 */
  1304.     boolean MemoryMailboxNewCommand:1; /* Bit 4 */
  1305.     unsigned int :27; /* Bits 5-31 */
  1306.   } Write;
  1307.   struct {
  1308.     boolean HardwareMailboxFull:1; /* Bit 0 */
  1309.     boolean InitializationInProgress:1; /* Bit 1 */
  1310.     unsigned int :30; /* Bits 2-31 */
  1311.   } Read;
  1312. }
  1313. DAC960_PG_InboundDoorBellRegister_T;
  1314. /*
  1315.   Define the structure of the DAC960 PG Series Outbound Door Bell Register.
  1316. */
  1317. typedef union DAC960_PG_OutboundDoorBellRegister
  1318. {
  1319.   unsigned int All;
  1320.   struct {
  1321.     boolean AcknowledgeHardwareMailboxInterrupt:1; /* Bit 0 */
  1322.     boolean AcknowledgeMemoryMailboxInterrupt:1; /* Bit 1 */
  1323.     unsigned int :30; /* Bits 2-31 */
  1324.   } Write;
  1325.   struct {
  1326.     boolean HardwareMailboxStatusAvailable:1; /* Bit 0 */
  1327.     boolean MemoryMailboxStatusAvailable:1; /* Bit 1 */
  1328.     unsigned int :30; /* Bits 2-31 */
  1329.   } Read;
  1330. }
  1331. DAC960_PG_OutboundDoorBellRegister_T;
  1332. /*
  1333.   Define the structure of the DAC960 PG Series Interrupt Mask Register.
  1334. */
  1335. typedef union DAC960_PG_InterruptMaskRegister
  1336. {
  1337.   unsigned int All;
  1338.   struct {
  1339.     unsigned int MessageUnitInterruptMask1:2; /* Bits 0-1 */
  1340.     boolean DisableInterrupts:1; /* Bit 2 */
  1341.     unsigned int MessageUnitInterruptMask2:5; /* Bits 3-7 */
  1342.     unsigned int Reserved0:24; /* Bits 8-31 */
  1343.   } Bits;
  1344. }
  1345. DAC960_PG_InterruptMaskRegister_T;
  1346. /*
  1347.   Define the structure of the DAC960 PG Series Error Status Register.
  1348. */
  1349. typedef union DAC960_PG_ErrorStatusRegister
  1350. {
  1351.   unsigned char All;
  1352.   struct {
  1353.     unsigned int :2; /* Bits 0-1 */
  1354.     boolean ErrorStatusPending:1; /* Bit 2 */
  1355.     unsigned int :5; /* Bits 3-7 */
  1356.   } Bits;
  1357. }
  1358. DAC960_PG_ErrorStatusRegister_T;
  1359. /*
  1360.   Define inline functions to provide an abstraction for reading and writing the
  1361.   DAC960 PG Series Controller Interface Registers.
  1362. */
  1363. static inline
  1364. void DAC960_PG_HardwareMailboxNewCommand(void *ControllerBaseAddress)
  1365. {
  1366.   DAC960_PG_InboundDoorBellRegister_T InboundDoorBellRegister;
  1367.   InboundDoorBellRegister.All = 0;
  1368.   InboundDoorBellRegister.Write.HardwareMailboxNewCommand = true;
  1369.   writel(InboundDoorBellRegister.All,
  1370.  ControllerBaseAddress + DAC960_PG_InboundDoorBellRegisterOffset);
  1371. }
  1372. static inline
  1373. void DAC960_PG_AcknowledgeHardwareMailboxStatus(void *ControllerBaseAddress)
  1374. {
  1375.   DAC960_PG_InboundDoorBellRegister_T InboundDoorBellRegister;
  1376.   InboundDoorBellRegister.All = 0;
  1377.   InboundDoorBellRegister.Write.AcknowledgeHardwareMailboxStatus = true;
  1378.   writel(InboundDoorBellRegister.All,
  1379.  ControllerBaseAddress + DAC960_PG_InboundDoorBellRegisterOffset);
  1380. }
  1381. static inline
  1382. void DAC960_PG_GenerateInterrupt(void *ControllerBaseAddress)
  1383. {
  1384.   DAC960_PG_InboundDoorBellRegister_T InboundDoorBellRegister;
  1385.   InboundDoorBellRegister.All = 0;
  1386.   InboundDoorBellRegister.Write.GenerateInterrupt = true;
  1387.   writel(InboundDoorBellRegister.All,
  1388.  ControllerBaseAddress + DAC960_PG_InboundDoorBellRegisterOffset);
  1389. }
  1390. static inline
  1391. void DAC960_PG_ControllerReset(void *ControllerBaseAddress)
  1392. {
  1393.   DAC960_PG_InboundDoorBellRegister_T InboundDoorBellRegister;
  1394.   InboundDoorBellRegister.All = 0;
  1395.   InboundDoorBellRegister.Write.ControllerReset = true;
  1396.   writel(InboundDoorBellRegister.All,
  1397.  ControllerBaseAddress + DAC960_PG_InboundDoorBellRegisterOffset);
  1398. }
  1399. static inline
  1400. void DAC960_PG_MemoryMailboxNewCommand(void *ControllerBaseAddress)
  1401. {
  1402.   DAC960_PG_InboundDoorBellRegister_T InboundDoorBellRegister;
  1403.   InboundDoorBellRegister.All = 0;
  1404.   InboundDoorBellRegister.Write.MemoryMailboxNewCommand = true;
  1405.   writel(InboundDoorBellRegister.All,
  1406.  ControllerBaseAddress + DAC960_PG_InboundDoorBellRegisterOffset);
  1407. }
  1408. static inline
  1409. boolean DAC960_PG_HardwareMailboxFullP(void *ControllerBaseAddress)
  1410. {
  1411.   DAC960_PG_InboundDoorBellRegister_T InboundDoorBellRegister;
  1412.   InboundDoorBellRegister.All =
  1413.     readl(ControllerBaseAddress + DAC960_PG_InboundDoorBellRegisterOffset);
  1414.   return InboundDoorBellRegister.Read.HardwareMailboxFull;
  1415. }
  1416. static inline
  1417. boolean DAC960_PG_InitializationInProgressP(void *ControllerBaseAddress)
  1418. {
  1419.   DAC960_PG_InboundDoorBellRegister_T InboundDoorBellRegister;
  1420.   InboundDoorBellRegister.All =
  1421.     readl(ControllerBaseAddress + DAC960_PG_InboundDoorBellRegisterOffset);
  1422.   return InboundDoorBellRegister.Read.InitializationInProgress;
  1423. }
  1424. static inline
  1425. void DAC960_PG_AcknowledgeHardwareMailboxInterrupt(void *ControllerBaseAddress)
  1426. {
  1427.   DAC960_PG_OutboundDoorBellRegister_T OutboundDoorBellRegister;
  1428.   OutboundDoorBellRegister.All = 0;
  1429.   OutboundDoorBellRegister.Write.AcknowledgeHardwareMailboxInterrupt = true;
  1430.   writel(OutboundDoorBellRegister.All,
  1431.  ControllerBaseAddress + DAC960_PG_OutboundDoorBellRegisterOffset);
  1432. }
  1433. static inline
  1434. void DAC960_PG_AcknowledgeMemoryMailboxInterrupt(void *ControllerBaseAddress)
  1435. {
  1436.   DAC960_PG_OutboundDoorBellRegister_T OutboundDoorBellRegister;
  1437.   OutboundDoorBellRegister.All = 0;
  1438.   OutboundDoorBellRegister.Write.AcknowledgeMemoryMailboxInterrupt = true;
  1439.   writel(OutboundDoorBellRegister.All,
  1440.  ControllerBaseAddress + DAC960_PG_OutboundDoorBellRegisterOffset);
  1441. }
  1442. static inline
  1443. void DAC960_PG_AcknowledgeInterrupt(void *ControllerBaseAddress)
  1444. {
  1445.   DAC960_PG_OutboundDoorBellRegister_T OutboundDoorBellRegister;
  1446.   OutboundDoorBellRegister.All = 0;
  1447.   OutboundDoorBellRegister.Write.AcknowledgeHardwareMailboxInterrupt = true;
  1448.   OutboundDoorBellRegister.Write.AcknowledgeMemoryMailboxInterrupt = true;
  1449.   writel(OutboundDoorBellRegister.All,
  1450.  ControllerBaseAddress + DAC960_PG_OutboundDoorBellRegisterOffset);
  1451. }
  1452. static inline
  1453. boolean DAC960_PG_HardwareMailboxStatusAvailableP(void *ControllerBaseAddress)
  1454. {
  1455.   DAC960_PG_OutboundDoorBellRegister_T OutboundDoorBellRegister;
  1456.   OutboundDoorBellRegister.All =
  1457.     readl(ControllerBaseAddress + DAC960_PG_OutboundDoorBellRegisterOffset);
  1458.   return OutboundDoorBellRegister.Read.HardwareMailboxStatusAvailable;
  1459. }
  1460. static inline
  1461. boolean DAC960_PG_MemoryMailboxStatusAvailableP(void *ControllerBaseAddress)
  1462. {
  1463.   DAC960_PG_OutboundDoorBellRegister_T OutboundDoorBellRegister;
  1464.   OutboundDoorBellRegister.All =
  1465.     readl(ControllerBaseAddress + DAC960_PG_OutboundDoorBellRegisterOffset);
  1466.   return OutboundDoorBellRegister.Read.MemoryMailboxStatusAvailable;
  1467. }
  1468. static inline
  1469. void DAC960_PG_EnableInterrupts(void *ControllerBaseAddress)
  1470. {
  1471.   DAC960_PG_InterruptMaskRegister_T InterruptMaskRegister;
  1472.   InterruptMaskRegister.All = 0;
  1473.   InterruptMaskRegister.Bits.MessageUnitInterruptMask1 = 0x3;
  1474.   InterruptMaskRegister.Bits.DisableInterrupts = false;
  1475.   InterruptMaskRegister.Bits.MessageUnitInterruptMask2 = 0x1F;
  1476.   writel(InterruptMaskRegister.All,
  1477.  ControllerBaseAddress + DAC960_PG_InterruptMaskRegisterOffset);
  1478. }
  1479. static inline
  1480. void DAC960_PG_DisableInterrupts(void *ControllerBaseAddress)
  1481. {
  1482.   DAC960_PG_InterruptMaskRegister_T InterruptMaskRegister;
  1483.   InterruptMaskRegister.All = 0;
  1484.   InterruptMaskRegister.Bits.MessageUnitInterruptMask1 = 0x3;
  1485.   InterruptMaskRegister.Bits.DisableInterrupts = true;
  1486.   InterruptMaskRegister.Bits.MessageUnitInterruptMask2 = 0x1F;
  1487.   writel(InterruptMaskRegister.All,
  1488.  ControllerBaseAddress + DAC960_PG_InterruptMaskRegisterOffset);
  1489. }
  1490. static inline
  1491. boolean DAC960_PG_InterruptsEnabledP(void *ControllerBaseAddress)
  1492. {
  1493.   DAC960_PG_InterruptMaskRegister_T InterruptMaskRegister;
  1494.   InterruptMaskRegister.All =
  1495.     readl(ControllerBaseAddress + DAC960_PG_InterruptMaskRegisterOffset);
  1496.   return !InterruptMaskRegister.Bits.DisableInterrupts;
  1497. }
  1498. static inline
  1499. void DAC960_PG_WriteCommandMailbox(DAC960_V1_CommandMailbox_T
  1500.      *MemoryCommandMailbox,
  1501.    DAC960_V1_CommandMailbox_T
  1502.      *CommandMailbox)
  1503. {
  1504.   MemoryCommandMailbox->Words[1] = CommandMailbox->Words[1];
  1505.   MemoryCommandMailbox->Words[2] = CommandMailbox->Words[2];
  1506.   MemoryCommandMailbox->Words[3] = CommandMailbox->Words[3];
  1507.   wmb();
  1508.   MemoryCommandMailbox->Words[0] = CommandMailbox->Words[0];
  1509.   mb();
  1510. }
  1511. static inline
  1512. void DAC960_PG_WriteHardwareMailbox(void *ControllerBaseAddress,
  1513.     DAC960_V1_CommandMailbox_T *CommandMailbox)
  1514. {
  1515.   writel(CommandMailbox->Words[0],
  1516.  ControllerBaseAddress + DAC960_PG_CommandOpcodeRegisterOffset);
  1517.   writel(CommandMailbox->Words[1],
  1518.  ControllerBaseAddress + DAC960_PG_MailboxRegister4Offset);
  1519.   writel(CommandMailbox->Words[2],
  1520.  ControllerBaseAddress + DAC960_PG_MailboxRegister8Offset);
  1521.   writeb(CommandMailbox->Bytes[12],
  1522.  ControllerBaseAddress + DAC960_PG_MailboxRegister12Offset);
  1523. }
  1524. static inline DAC960_V1_CommandIdentifier_T
  1525. DAC960_PG_ReadStatusCommandIdentifier(void *ControllerBaseAddress)
  1526. {
  1527.   return readb(ControllerBaseAddress
  1528.        + DAC960_PG_StatusCommandIdentifierRegOffset);
  1529. }
  1530. static inline DAC960_V1_CommandStatus_T
  1531. DAC960_PG_ReadStatusRegister(void *ControllerBaseAddress)
  1532. {
  1533.   return readw(ControllerBaseAddress + DAC960_PG_StatusRegisterOffset);
  1534. }
  1535. static inline boolean
  1536. DAC960_PG_ReadErrorStatus(void *ControllerBaseAddress,
  1537.   unsigned char *ErrorStatus,
  1538.   unsigned char *Parameter0,
  1539.   unsigned char *Parameter1)
  1540. {
  1541.   DAC960_PG_ErrorStatusRegister_T ErrorStatusRegister;
  1542.   ErrorStatusRegister.All =
  1543.     readb(ControllerBaseAddress + DAC960_PG_ErrorStatusRegisterOffset);
  1544.   if (!ErrorStatusRegister.Bits.ErrorStatusPending) return false;
  1545.   ErrorStatusRegister.Bits.ErrorStatusPending = false;
  1546.   *ErrorStatus = ErrorStatusRegister.All;
  1547.   *Parameter0 =
  1548.     readb(ControllerBaseAddress + DAC960_PG_CommandOpcodeRegisterOffset);
  1549.   *Parameter1 =
  1550.     readb(ControllerBaseAddress + DAC960_PG_CommandIdentifierRegisterOffset);
  1551.   writeb(0, ControllerBaseAddress + DAC960_PG_ErrorStatusRegisterOffset);
  1552.   return true;
  1553. }
  1554. static inline
  1555. void DAC960_PG_SaveMemoryMailboxInfo(DAC960_Controller_T *Controller)
  1556. {
  1557. #ifdef __i386__
  1558.   void *ControllerBaseAddress = Controller->BaseAddress;
  1559.   writel(0x743C485E,
  1560.  ControllerBaseAddress + DAC960_PG_CommandOpcodeRegisterOffset);
  1561.   writel((unsigned long) Controller->V1.FirstCommandMailbox,
  1562.  ControllerBaseAddress + DAC960_PG_MailboxRegister4Offset);
  1563.   writew(Controller->V1.NextCommandMailbox - Controller->V1.FirstCommandMailbox,
  1564.  ControllerBaseAddress + DAC960_PG_MailboxRegister8Offset);
  1565.   writew(Controller->V1.NextStatusMailbox - Controller->V1.FirstStatusMailbox,
  1566.  ControllerBaseAddress + DAC960_PG_MailboxRegister10Offset);
  1567. #endif
  1568. }
  1569. static inline
  1570. void DAC960_PG_RestoreMemoryMailboxInfo(DAC960_Controller_T *Controller,
  1571. void **MemoryMailboxAddress,
  1572. short *NextCommandMailboxIndex,
  1573. short *NextStatusMailboxIndex)
  1574. {
  1575. #ifdef __i386__
  1576.   void *ControllerBaseAddress = Controller->BaseAddress;
  1577.   if (readl(ControllerBaseAddress
  1578.     + DAC960_PG_CommandOpcodeRegisterOffset) != 0x743C485E)
  1579.     return;
  1580.   *MemoryMailboxAddress =
  1581.     (void *) readl(ControllerBaseAddress + DAC960_PG_MailboxRegister4Offset);
  1582.   *NextCommandMailboxIndex =
  1583.     readw(ControllerBaseAddress + DAC960_PG_MailboxRegister8Offset);
  1584.   *NextStatusMailboxIndex =
  1585.     readw(ControllerBaseAddress + DAC960_PG_MailboxRegister10Offset);
  1586. #endif
  1587. }
  1588. /*
  1589.   Define the DAC960 PD Series Controller Interface Register Offsets.
  1590. */
  1591. #define DAC960_PD_RegisterWindowSize 0x80
  1592. typedef enum
  1593. {
  1594.   DAC960_PD_CommandOpcodeRegisterOffset = 0x00,
  1595.   DAC960_PD_CommandIdentifierRegisterOffset = 0x01,
  1596.   DAC960_PD_MailboxRegister2Offset = 0x02,
  1597.   DAC960_PD_MailboxRegister3Offset = 0x03,
  1598.   DAC960_PD_MailboxRegister4Offset = 0x04,
  1599.   DAC960_PD_MailboxRegister5Offset = 0x05,
  1600.   DAC960_PD_MailboxRegister6Offset = 0x06,
  1601.   DAC960_PD_MailboxRegister7Offset = 0x07,
  1602.   DAC960_PD_MailboxRegister8Offset = 0x08,
  1603.   DAC960_PD_MailboxRegister9Offset = 0x09,
  1604.   DAC960_PD_MailboxRegister10Offset = 0x0A,
  1605.   DAC960_PD_MailboxRegister11Offset = 0x0B,
  1606.   DAC960_PD_MailboxRegister12Offset = 0x0C,
  1607.   DAC960_PD_StatusCommandIdentifierRegOffset = 0x0D,
  1608.   DAC960_PD_StatusRegisterOffset = 0x0E,
  1609.   DAC960_PD_ErrorStatusRegisterOffset = 0x3F,
  1610.   DAC960_PD_InboundDoorBellRegisterOffset = 0x40,
  1611.   DAC960_PD_OutboundDoorBellRegisterOffset = 0x41,
  1612.   DAC960_PD_InterruptEnableRegisterOffset = 0x43
  1613. }
  1614. DAC960_PD_RegisterOffsets_T;
  1615. /*
  1616.   Define the structure of the DAC960 PD Series Inbound Door Bell Register.
  1617. */
  1618. typedef union DAC960_PD_InboundDoorBellRegister
  1619. {
  1620.   unsigned char All;
  1621.   struct {
  1622.     boolean NewCommand:1; /* Bit 0 */
  1623.     boolean AcknowledgeStatus:1; /* Bit 1 */
  1624.     boolean GenerateInterrupt:1; /* Bit 2 */
  1625.     boolean ControllerReset:1; /* Bit 3 */
  1626.     unsigned char :4; /* Bits 4-7 */
  1627.   } Write;
  1628.   struct {
  1629.     boolean MailboxFull:1; /* Bit 0 */
  1630.     boolean InitializationInProgress:1; /* Bit 1 */
  1631.     unsigned char :6; /* Bits 2-7 */
  1632.   } Read;
  1633. }
  1634. DAC960_PD_InboundDoorBellRegister_T;
  1635. /*
  1636.   Define the structure of the DAC960 PD Series Outbound Door Bell Register.
  1637. */
  1638. typedef union DAC960_PD_OutboundDoorBellRegister
  1639. {
  1640.   unsigned char All;
  1641.   struct {
  1642.     boolean AcknowledgeInterrupt:1; /* Bit 0 */
  1643.     unsigned char :7; /* Bits 1-7 */
  1644.   } Write;
  1645.   struct {
  1646.     boolean StatusAvailable:1; /* Bit 0 */
  1647.     unsigned char :7; /* Bits 1-7 */
  1648.   } Read;
  1649. }
  1650. DAC960_PD_OutboundDoorBellRegister_T;
  1651. /*
  1652.   Define the structure of the DAC960 PD Series Interrupt Enable Register.
  1653. */
  1654. typedef union DAC960_PD_InterruptEnableRegister
  1655. {
  1656.   unsigned char All;
  1657.   struct {
  1658.     boolean EnableInterrupts:1; /* Bit 0 */
  1659.     unsigned char :7; /* Bits 1-7 */
  1660.   } Bits;
  1661. }
  1662. DAC960_PD_InterruptEnableRegister_T;
  1663. /*
  1664.   Define the structure of the DAC960 PD Series Error Status Register.
  1665. */
  1666. typedef union DAC960_PD_ErrorStatusRegister
  1667. {
  1668.   unsigned char All;
  1669.   struct {
  1670.     unsigned int :2; /* Bits 0-1 */
  1671.     boolean ErrorStatusPending:1; /* Bit 2 */
  1672.     unsigned int :5; /* Bits 3-7 */
  1673.   } Bits;
  1674. }
  1675. DAC960_PD_ErrorStatusRegister_T;
  1676. /*
  1677.   Define inline functions to provide an abstraction for reading and writing the
  1678.   DAC960 PD Series Controller Interface Registers.
  1679. */
  1680. static inline
  1681. void DAC960_PD_NewCommand(void *ControllerBaseAddress)
  1682. {
  1683.   DAC960_PD_InboundDoorBellRegister_T InboundDoorBellRegister;
  1684.   InboundDoorBellRegister.All = 0;
  1685.   InboundDoorBellRegister.Write.NewCommand = true;
  1686.   writeb(InboundDoorBellRegister.All,
  1687.  ControllerBaseAddress + DAC960_PD_InboundDoorBellRegisterOffset);
  1688. }
  1689. static inline
  1690. void DAC960_PD_AcknowledgeStatus(void *ControllerBaseAddress)
  1691. {
  1692.   DAC960_PD_InboundDoorBellRegister_T InboundDoorBellRegister;
  1693.   InboundDoorBellRegister.All = 0;
  1694.   InboundDoorBellRegister.Write.AcknowledgeStatus = true;
  1695.   writeb(InboundDoorBellRegister.All,
  1696.  ControllerBaseAddress + DAC960_PD_InboundDoorBellRegisterOffset);
  1697. }
  1698. static inline
  1699. void DAC960_PD_GenerateInterrupt(void *ControllerBaseAddress)
  1700. {
  1701.   DAC960_PD_InboundDoorBellRegister_T InboundDoorBellRegister;
  1702.   InboundDoorBellRegister.All = 0;
  1703.   InboundDoorBellRegister.Write.GenerateInterrupt = true;
  1704.   writeb(InboundDoorBellRegister.All,
  1705.  ControllerBaseAddress + DAC960_PD_InboundDoorBellRegisterOffset);
  1706. }
  1707. static inline
  1708. void DAC960_PD_ControllerReset(void *ControllerBaseAddress)
  1709. {
  1710.   DAC960_PD_InboundDoorBellRegister_T InboundDoorBellRegister;
  1711.   InboundDoorBellRegister.All = 0;
  1712.   InboundDoorBellRegister.Write.ControllerReset = true;
  1713.   writeb(InboundDoorBellRegister.All,
  1714.  ControllerBaseAddress + DAC960_PD_InboundDoorBellRegisterOffset);
  1715. }
  1716. static inline
  1717. boolean DAC960_PD_MailboxFullP(void *ControllerBaseAddress)
  1718. {
  1719.   DAC960_PD_InboundDoorBellRegister_T InboundDoorBellRegister;
  1720.   InboundDoorBellRegister.All =
  1721.     readb(ControllerBaseAddress + DAC960_PD_InboundDoorBellRegisterOffset);
  1722.   return InboundDoorBellRegister.Read.MailboxFull;
  1723. }
  1724. static inline
  1725. boolean DAC960_PD_InitializationInProgressP(void *ControllerBaseAddress)
  1726. {
  1727.   DAC960_PD_InboundDoorBellRegister_T InboundDoorBellRegister;
  1728.   InboundDoorBellRegister.All =
  1729.     readb(ControllerBaseAddress + DAC960_PD_InboundDoorBellRegisterOffset);
  1730.   return InboundDoorBellRegister.Read.InitializationInProgress;
  1731. }
  1732. static inline
  1733. void DAC960_PD_AcknowledgeInterrupt(void *ControllerBaseAddress)
  1734. {
  1735.   DAC960_PD_OutboundDoorBellRegister_T OutboundDoorBellRegister;
  1736.   OutboundDoorBellRegister.All = 0;
  1737.   OutboundDoorBellRegister.Write.AcknowledgeInterrupt = true;
  1738.   writeb(OutboundDoorBellRegister.All,
  1739.  ControllerBaseAddress + DAC960_PD_OutboundDoorBellRegisterOffset);
  1740. }
  1741. static inline
  1742. boolean DAC960_PD_StatusAvailableP(void *ControllerBaseAddress)
  1743. {
  1744.   DAC960_PD_OutboundDoorBellRegister_T OutboundDoorBellRegister;
  1745.   OutboundDoorBellRegister.All =
  1746.     readb(ControllerBaseAddress + DAC960_PD_OutboundDoorBellRegisterOffset);
  1747.   return OutboundDoorBellRegister.Read.StatusAvailable;
  1748. }
  1749. static inline
  1750. void DAC960_PD_EnableInterrupts(void *ControllerBaseAddress)
  1751. {
  1752.   DAC960_PD_InterruptEnableRegister_T InterruptEnableRegister;
  1753.   InterruptEnableRegister.All = 0;
  1754.   InterruptEnableRegister.Bits.EnableInterrupts = true;
  1755.   writeb(InterruptEnableRegister.All,
  1756.  ControllerBaseAddress + DAC960_PD_InterruptEnableRegisterOffset);
  1757. }
  1758. static inline
  1759. void DAC960_PD_DisableInterrupts(void *ControllerBaseAddress)
  1760. {
  1761.   DAC960_PD_InterruptEnableRegister_T InterruptEnableRegister;
  1762.   InterruptEnableRegister.All = 0;
  1763.   InterruptEnableRegister.Bits.EnableInterrupts = false;
  1764.   writeb(InterruptEnableRegister.All,
  1765.  ControllerBaseAddress + DAC960_PD_InterruptEnableRegisterOffset);
  1766. }
  1767. static inline
  1768. boolean DAC960_PD_InterruptsEnabledP(void *ControllerBaseAddress)
  1769. {
  1770.   DAC960_PD_InterruptEnableRegister_T InterruptEnableRegister;
  1771.   InterruptEnableRegister.All =
  1772.     readb(ControllerBaseAddress + DAC960_PD_InterruptEnableRegisterOffset);
  1773.   return InterruptEnableRegister.Bits.EnableInterrupts;
  1774. }
  1775. static inline
  1776. void DAC960_PD_WriteCommandMailbox(void *ControllerBaseAddress,
  1777.    DAC960_V1_CommandMailbox_T *CommandMailbox)
  1778. {
  1779.   writel(CommandMailbox->Words[0],
  1780.  ControllerBaseAddress + DAC960_PD_CommandOpcodeRegisterOffset);
  1781.   writel(CommandMailbox->Words[1],
  1782.  ControllerBaseAddress + DAC960_PD_MailboxRegister4Offset);
  1783.   writel(CommandMailbox->Words[2],
  1784.  ControllerBaseAddress + DAC960_PD_MailboxRegister8Offset);
  1785.   writeb(CommandMailbox->Bytes[12],
  1786.  ControllerBaseAddress + DAC960_PD_MailboxRegister12Offset);
  1787. }
  1788. static inline DAC960_V1_CommandIdentifier_T
  1789. DAC960_PD_ReadStatusCommandIdentifier(void *ControllerBaseAddress)
  1790. {
  1791.   return readb(ControllerBaseAddress
  1792.        + DAC960_PD_StatusCommandIdentifierRegOffset);
  1793. }
  1794. static inline DAC960_V1_CommandStatus_T
  1795. DAC960_PD_ReadStatusRegister(void *ControllerBaseAddress)
  1796. {
  1797.   return readw(ControllerBaseAddress + DAC960_PD_StatusRegisterOffset);
  1798. }
  1799. static inline boolean
  1800. DAC960_PD_ReadErrorStatus(void *ControllerBaseAddress,
  1801.   unsigned char *ErrorStatus,
  1802.   unsigned char *Parameter0,
  1803.   unsigned char *Parameter1)
  1804. {
  1805.   DAC960_PD_ErrorStatusRegister_T ErrorStatusRegister;
  1806.   ErrorStatusRegister.All =
  1807.     readb(ControllerBaseAddress + DAC960_PD_ErrorStatusRegisterOffset);
  1808.   if (!ErrorStatusRegister.Bits.ErrorStatusPending) return false;
  1809.   ErrorStatusRegister.Bits.ErrorStatusPending = false;
  1810.   *ErrorStatus = ErrorStatusRegister.All;
  1811.   *Parameter0 =
  1812.     readb(ControllerBaseAddress + DAC960_PD_CommandOpcodeRegisterOffset);
  1813.   *Parameter1 =
  1814.     readb(ControllerBaseAddress + DAC960_PD_CommandIdentifierRegisterOffset);
  1815.   writeb(0, ControllerBaseAddress + DAC960_PD_ErrorStatusRegisterOffset);
  1816.   return true;
  1817. }
  1818. static inline void DAC960_P_To_PD_TranslateEnquiry(void *Enquiry)
  1819. {
  1820.   memcpy(Enquiry + 132, Enquiry + 36, 64);
  1821.   memset(Enquiry + 36, 0, 96);
  1822. }
  1823. static inline void DAC960_P_To_PD_TranslateDeviceState(void *DeviceState)
  1824. {
  1825.   memcpy(DeviceState + 2, DeviceState + 3, 1);
  1826.   memcpy(DeviceState + 4, DeviceState + 5, 2);
  1827.   memcpy(DeviceState + 6, DeviceState + 8, 4);
  1828. }
  1829. static inline
  1830. void DAC960_PD_To_P_TranslateReadWriteCommand(DAC960_V1_CommandMailbox_T
  1831.       *CommandMailbox)
  1832. {
  1833.   int LogicalDriveNumber = CommandMailbox->Type5.LD.LogicalDriveNumber;
  1834.   CommandMailbox->Bytes[3] &= 0x7;
  1835.   CommandMailbox->Bytes[3] |= CommandMailbox->Bytes[7] << 6;
  1836.   CommandMailbox->Bytes[7] = LogicalDriveNumber;
  1837. }
  1838. static inline
  1839. void DAC960_P_To_PD_TranslateReadWriteCommand(DAC960_V1_CommandMailbox_T
  1840.       *CommandMailbox)
  1841. {
  1842.   int LogicalDriveNumber = CommandMailbox->Bytes[7];
  1843.   CommandMailbox->Bytes[7] = CommandMailbox->Bytes[3] >> 6;
  1844.   CommandMailbox->Bytes[3] &= 0x7;
  1845.   CommandMailbox->Bytes[3] |= LogicalDriveNumber << 3;
  1846. }
  1847. /*
  1848.   Define prototypes for the forward referenced DAC960 Driver Internal Functions.
  1849. */
  1850. static void DAC960_FinalizeController(DAC960_Controller_T *);
  1851. static int DAC960_Notifier(NotifierBlock_T *, unsigned long, void *);
  1852. static void DAC960_V1_QueueReadWriteCommand(DAC960_Command_T *);
  1853. static void DAC960_V2_QueueReadWriteCommand(DAC960_Command_T *);
  1854. static void DAC960_RequestFunction(RequestQueue_T *);
  1855. static void DAC960_BA_InterruptHandler(int, void *, Registers_T *);
  1856. static void DAC960_LP_InterruptHandler(int, void *, Registers_T *);
  1857. static void DAC960_LA_InterruptHandler(int, void *, Registers_T *);
  1858. static void DAC960_PG_InterruptHandler(int, void *, Registers_T *);
  1859. static void DAC960_PD_InterruptHandler(int, void *, Registers_T *);
  1860. static void DAC960_P_InterruptHandler(int, void *, Registers_T *);
  1861. static void DAC960_V1_QueueMonitoringCommand(DAC960_Command_T *);
  1862. static void DAC960_V2_QueueMonitoringCommand(DAC960_Command_T *);
  1863. static void DAC960_MonitoringTimerFunction(unsigned long);
  1864. static int DAC960_Open(Inode_T *, File_T *);
  1865. static int DAC960_Release(Inode_T *, File_T *);
  1866. static int DAC960_IOCTL(Inode_T *, File_T *, unsigned int, unsigned long);
  1867. static int DAC960_UserIOCTL(Inode_T *, File_T *, unsigned int, unsigned long);
  1868. static void DAC960_Message(DAC960_MessageLevel_T, unsigned char *,
  1869.    DAC960_Controller_T *, ...);
  1870. static void DAC960_CreateProcEntries(void);
  1871. static void DAC960_DestroyProcEntries(void);
  1872. /*
  1873.   Export the Kernel Mode IOCTL interface.
  1874. */
  1875. EXPORT_SYMBOL(DAC960_KernelIOCTL);
  1876. #endif /* DAC960_DriverVersion */