⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 dac960.c

📁 讲述linux的初始化过程
💻 C
📖 第 1 页 / 共 5 页
字号:
	return DAC960_Failure(Controller, "GET DEVICE STATE");  /*    Initialize the Controller Model Name and Full Model Name fields.  */  switch (Enquiry2.HardwareID.SubModel)    {    case DAC960_V1_P_PD_PU:      if (Enquiry2.SCSICapability.BusSpeed == DAC960_V1_Ultra)	strcpy(Controller->ModelName, "DAC960PU");      else strcpy(Controller->ModelName, "DAC960PD");      break;    case DAC960_V1_PL:      strcpy(Controller->ModelName, "DAC960PL");      break;    case DAC960_V1_PG:      strcpy(Controller->ModelName, "DAC960PG");      break;    case DAC960_V1_PJ:      strcpy(Controller->ModelName, "DAC960PJ");      break;    case DAC960_V1_PR:      strcpy(Controller->ModelName, "DAC960PR");      break;    case DAC960_V1_PT:      strcpy(Controller->ModelName, "DAC960PT");      break;    case DAC960_V1_PTL0:      strcpy(Controller->ModelName, "DAC960PTL0");      break;    case DAC960_V1_PRL:      strcpy(Controller->ModelName, "DAC960PRL");      break;    case DAC960_V1_PTL1:      strcpy(Controller->ModelName, "DAC960PTL1");      break;    case DAC960_V1_1164P:      strcpy(Controller->ModelName, "DAC1164P");      break;    default:      return DAC960_Failure(Controller, "MODEL VERIFICATION");    }  strcpy(Controller->FullModelName, "Mylex ");  strcat(Controller->FullModelName, Controller->ModelName);  /*    Initialize the Controller Firmware Version field and verify that it    is a supported firmware version.  The supported firmware versions are:    DAC1164P		    5.06 and above    DAC960PTL/PRL/PJ/PG	    4.06 and above    DAC960PU/PD/PL	    3.51 and above  */  sprintf(Controller->FirmwareVersion, "%d.%02d-%c-%02d",	  Enquiry2.FirmwareID.MajorVersion, Enquiry2.FirmwareID.MinorVersion,	  Enquiry2.FirmwareID.FirmwareType, Enquiry2.FirmwareID.TurnID);  if (!((Controller->FirmwareVersion[0] == '5' &&	 strcmp(Controller->FirmwareVersion, "5.06") >= 0) ||	(Controller->FirmwareVersion[0] == '4' &&	 strcmp(Controller->FirmwareVersion, "4.06") >= 0) ||	(Controller->FirmwareVersion[0] == '3' &&	 strcmp(Controller->FirmwareVersion, "3.51") >= 0)))    {      DAC960_Failure(Controller, "FIRMWARE VERSION VERIFICATION");      DAC960_Error("Firmware Version = '%s'\n", Controller,		   Controller->FirmwareVersion);      return false;    }  /*    Initialize the Controller Channels, Targets, Memory Size, and SAF-TE    Enclosure Management Enabled fields.  */  Controller->Channels = Enquiry2.ActualChannels;  Controller->Targets = Enquiry2.MaxTargets;  Controller->MemorySize = Enquiry2.MemorySize >> 20;  Controller->V1.SAFTE_EnclosureManagementEnabled =    (Enquiry2.FaultManagementType == DAC960_V1_SAFTE);  /*    Initialize the Controller Queue Depth, Driver Queue Depth, Logical Drive    Count, Maximum Blocks per Command, Controller Scatter/Gather Limit, and    Driver Scatter/Gather Limit.  The Driver Queue Depth must be at most one    less than the Controller Queue Depth to allow for an automatic drive    rebuild operation.  */  Controller->ControllerQueueDepth = Controller->V1.Enquiry.MaxCommands;  Controller->DriverQueueDepth = Controller->ControllerQueueDepth - 1;  if (Controller->DriverQueueDepth > DAC960_MaxDriverQueueDepth)    Controller->DriverQueueDepth = DAC960_MaxDriverQueueDepth;  Controller->LogicalDriveCount =    Controller->V1.Enquiry.NumberOfLogicalDrives;  Controller->MaxBlocksPerCommand = Enquiry2.MaxBlocksPerCommand;  Controller->ControllerScatterGatherLimit = Enquiry2.MaxScatterGatherEntries;  Controller->DriverScatterGatherLimit =    Controller->ControllerScatterGatherLimit;  if (Controller->DriverScatterGatherLimit > DAC960_V1_ScatterGatherLimit)    Controller->DriverScatterGatherLimit = DAC960_V1_ScatterGatherLimit;  /*    Initialize the Stripe Size, Segment Size, and Geometry Translation.  */  Controller->V1.StripeSize = Config2.BlocksPerStripe * Config2.BlockFactor			      >> (10 - DAC960_BlockSizeBits);  Controller->V1.SegmentSize = Config2.BlocksPerCacheLine * Config2.BlockFactor			       >> (10 - DAC960_BlockSizeBits);  switch (Config2.DriveGeometry)    {    case DAC960_V1_Geometry_128_32:      Controller->V1.GeometryTranslationHeads = 128;      Controller->V1.GeometryTranslationSectors = 32;      break;    case DAC960_V1_Geometry_255_63:      Controller->V1.GeometryTranslationHeads = 255;      Controller->V1.GeometryTranslationSectors = 63;      break;    default:      return DAC960_Failure(Controller, "CONFIG2 DRIVE GEOMETRY");    }  /*    Initialize the Logical Drive Initially Accessible flag.  */  for (LogicalDriveNumber = 0;       LogicalDriveNumber < Controller->LogicalDriveCount;       LogicalDriveNumber++)    if (Controller->V1.LogicalDriveInformation		       [LogicalDriveNumber].LogicalDriveState !=	DAC960_V1_LogicalDrive_Offline)      Controller->LogicalDriveInitiallyAccessible[LogicalDriveNumber] = true;  Controller->V1.LastRebuildStatus = DAC960_V1_NoRebuildOrCheckInProgress;  return true;}/*  DAC960_V2_ReadControllerConfiguration reads the Configuration Information  from DAC960 V2 Firmware Controllers and initializes the Controller structure.*/static boolean DAC960_V2_ReadControllerConfiguration(DAC960_Controller_T						     *Controller){  DAC960_V2_ControllerInfo_T *ControllerInfo =    &Controller->V2.ControllerInformation;  unsigned short LogicalDeviceNumber = 0;  int ModelNameLength;  if (!DAC960_V2_ControllerInfo(Controller, DAC960_V2_GetControllerInfo,				ControllerInfo,				sizeof(DAC960_V2_ControllerInfo_T)))    return DAC960_Failure(Controller, "GET CONTROLLER INFO");  if (!DAC960_V2_GeneralInfo(Controller, DAC960_V2_GetHealthStatus,			     Controller->V2.HealthStatusBuffer,			     sizeof(DAC960_V2_HealthStatusBuffer_T)))    return DAC960_Failure(Controller, "GET HEALTH STATUS");  /*    Initialize the Controller Model Name and Full Model Name fields.  */  ModelNameLength = sizeof(ControllerInfo->ControllerName);  if (ModelNameLength > sizeof(Controller->ModelName)-1)    ModelNameLength = sizeof(Controller->ModelName)-1;  memcpy(Controller->ModelName, ControllerInfo->ControllerName,	 ModelNameLength);  ModelNameLength--;  while (Controller->ModelName[ModelNameLength] == ' ' ||	 Controller->ModelName[ModelNameLength] == '\0')    ModelNameLength--;  Controller->ModelName[++ModelNameLength] = '\0';  strcpy(Controller->FullModelName, "Mylex ");  strcat(Controller->FullModelName, Controller->ModelName);  /*    Initialize the Controller Firmware Version field.  */  sprintf(Controller->FirmwareVersion, "%d.%02d-%02d",	  ControllerInfo->FirmwareMajorVersion,	  ControllerInfo->FirmwareMinorVersion,	  ControllerInfo->FirmwareTurnNumber);  if (ControllerInfo->FirmwareMajorVersion == 6 &&      ControllerInfo->FirmwareMinorVersion == 0 &&      ControllerInfo->FirmwareTurnNumber < 1)    {      DAC960_Info("FIRMWARE VERSION %s DOES NOT PROVIDE THE CONTROLLER\n",		  Controller, Controller->FirmwareVersion);      DAC960_Info("STATUS MONITORING FUNCTIONALITY NEEDED BY THIS DRIVER.\n",		  Controller);      DAC960_Info("PLEASE UPGRADE TO VERSION 6.00-01 OR ABOVE.\n",		  Controller);    }  /*    Initialize the Controller Channels, Targets, and Memory Size.  */  Controller->Channels = ControllerInfo->NumberOfPhysicalChannelsPresent;  Controller->Targets =    ControllerInfo->MaximumTargetsPerChannel		    [ControllerInfo->NumberOfPhysicalChannelsPresent-1];  Controller->MemorySize = ControllerInfo->MemorySizeMB;  /*    Initialize the Controller Queue Depth, Driver Queue Depth, Logical Drive    Count, Maximum Blocks per Command, Controller Scatter/Gather Limit, and    Driver Scatter/Gather Limit.  The Driver Queue Depth must be at most one    less than the Controller Queue Depth to allow for an automatic drive    rebuild operation.  */  Controller->ControllerQueueDepth = ControllerInfo->MaximumParallelCommands;  Controller->DriverQueueDepth = Controller->ControllerQueueDepth - 1;  if (Controller->DriverQueueDepth > DAC960_MaxDriverQueueDepth)    Controller->DriverQueueDepth = DAC960_MaxDriverQueueDepth;  Controller->LogicalDriveCount = ControllerInfo->LogicalDevicesPresent;  Controller->MaxBlocksPerCommand =    ControllerInfo->MaximumDataTransferSizeInBlocks;  Controller->ControllerScatterGatherLimit =    ControllerInfo->MaximumScatterGatherEntries;  Controller->DriverScatterGatherLimit =    Controller->ControllerScatterGatherLimit;  if (Controller->DriverScatterGatherLimit > DAC960_V2_ScatterGatherLimit)    Controller->DriverScatterGatherLimit = DAC960_V2_ScatterGatherLimit;  /*    Initialize the Logical Device Information.  */  while (true)    {      DAC960_V2_LogicalDeviceInfo_T *NewLogicalDeviceInfo =	&Controller->V2.NewLogicalDeviceInformation;      DAC960_V2_LogicalDeviceInfo_T *LogicalDeviceInfo;      DAC960_V2_PhysicalDevice_T PhysicalDevice;      if (!DAC960_V2_LogicalDeviceInfo(Controller,				       DAC960_V2_GetLogicalDeviceInfoValid,				       LogicalDeviceNumber,				       NewLogicalDeviceInfo,				       sizeof(DAC960_V2_LogicalDeviceInfo_T)))	break;      LogicalDeviceNumber = NewLogicalDeviceInfo->LogicalDeviceNumber;      if (LogicalDeviceNumber > DAC960_MaxLogicalDrives)	panic("DAC960: Logical Drive Number %d not supported\n",		       LogicalDeviceNumber);      if (NewLogicalDeviceInfo->DeviceBlockSizeInBytes != DAC960_BlockSize)	panic("DAC960: Logical Drive Block Size %d not supported\n",	      NewLogicalDeviceInfo->DeviceBlockSizeInBytes);      PhysicalDevice.Controller = 0;      PhysicalDevice.Channel = NewLogicalDeviceInfo->Channel;      PhysicalDevice.TargetID = NewLogicalDeviceInfo->TargetID;      PhysicalDevice.LogicalUnit = NewLogicalDeviceInfo->LogicalUnit;      Controller->V2.LogicalDriveToVirtualDevice[LogicalDeviceNumber] =	PhysicalDevice;      if (NewLogicalDeviceInfo->LogicalDeviceState !=	  DAC960_V2_LogicalDevice_Offline)	Controller->LogicalDriveInitiallyAccessible[LogicalDeviceNumber] = true;      LogicalDeviceInfo = (DAC960_V2_LogicalDeviceInfo_T *)	kmalloc(sizeof(DAC960_V2_LogicalDeviceInfo_T), GFP_ATOMIC);      if (LogicalDeviceInfo == NULL)	return DAC960_Failure(Controller, "LOGICAL DEVICE ALLOCATION");      Controller->V2.LogicalDeviceInformation[LogicalDeviceNumber] =	LogicalDeviceInfo;      memcpy(LogicalDeviceInfo, NewLogicalDeviceInfo,	     sizeof(DAC960_V2_LogicalDeviceInfo_T));      LogicalDeviceNumber++;    }  return true;}/*  DAC960_ReportControllerConfiguration reports the Configuration Information  for Controller.*/static boolean DAC960_ReportControllerConfiguration(DAC960_Controller_T						    *Controller){  DAC960_Info("Configuring Mylex %s PCI RAID Controller\n",	      Controller, Controller->ModelName);  DAC960_Info("  Firmware Version: %s, Channels: %d, Memory Size: %dMB\n",	      Controller, Controller->FirmwareVersion,	      Controller->Channels, Controller->MemorySize);  DAC960_Info("  PCI Bus: %d, Device: %d, Function: %d, I/O Address: ",	      Controller, Controller->Bus,	      Controller->Device, Controller->Function);  if (Controller->IO_Address == 0)    DAC960_Info("Unassigned\n", Controller);  else DAC960_Info("0x%X\n", Controller, Controller->IO_Address);  DAC960_Info("  PCI Address: 0x%X mapped at 0x%lX, IRQ Channel: %d\n",	      Controller, Controller->PCI_Address,	      (unsigned long) Controller->BaseAddress,	      Controller->IRQ_Channel);  DAC960_Info("  Controller Queue Depth: %d, "	      "Maximum Blocks per Command: %d\n",	      Controller, Controller->ControllerQueueDepth,	      Controller->MaxBlocksPerCommand);  DAC960_Info("  Driver Queue Depth: %d, "	      "Scatter/Gather Limit: %d of %d Segments\n",	      Controller, Controller->DriverQueueDepth,	      Controller->DriverScatterGatherLimit,	      Controller->ControllerScatterGatherLimit);  if (Controller->FirmwareType == DAC960_V1_Controller)    {      DAC960_Info("  Stripe Size: %dKB, Segment Size: %dKB, "		  "BIOS Geometry: %d/%d\n", Controller,		  Controller->V1.StripeSize,		  Controller->V1.SegmentSize,		  Controller->V1.GeometryTranslationHeads,		  Controller->V1.GeometryTranslationSectors);      if (Controller->V1.SAFTE_EnclosureManagementEnabled)	DAC960_Info("  SAF-TE Enclosure Management Enabled\n", Controller);    }  return true;}/*  DAC960_V1_ReadDeviceConfiguration reads the Device Configuration Information  for DAC960 V1 Firmware Controllers by requesting the SCSI Inquiry and SCSI  Inquiry Unit Serial Number information for each device connected to  Controller.*/static boolean DAC960_V1_ReadDeviceConfiguration(DAC960_Controller_T						 *Controller){  DAC960_V1_DCDB_T DCDBs[DAC960_V1_MaxChannels], *DCDB;  Semaphore_T Semaphores[DAC960_V1_MaxChannels], *Semaphore;  unsigned long ProcessorFlags;  int Channel, TargetID;  for (TargetID = 0; TargetID < Controller->Targets; TargetID++)    {      for (Channel = 0; Channel < Controller->Channels; Channel++)	{	  DAC960_Command_T *Command = Controller->Commands[Channel];	  DAC960_SCSI_Inquiry_T *InquiryStandardData =	    &Controller->V1.InquiryStandardData[Channel][TargetID];	  InquiryStandardData->PeripheralDeviceType = 0x1F;	  Semaphore = &Semaphores[Channel];	  init_MUTEX_LOCKED(Semaphore);	  DCDB = &DCDBs[Channel];	  DAC960_V1_ClearCommand(Command);	  Command->CommandType = DAC960_ImmediateCommand;	  Command->Semaphore = Semaphore;	  Command->V1.CommandMailbox.Type3.CommandOpcode = DAC960_V1_DCDB;	  Command->V1.CommandMailbox.Type3.BusAddress = Virtual_to_Bus(DCDB);	  DCDB->Channel = Channel;	  DCDB->TargetID = TargetID;	  DCDB->Direction = DAC960_V1_DCDB_DataTransferDeviceToSystem;

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -