您好,欢迎光临本网站![请登录][注册会员]  
文件名称: ATA_EFI_Command.pdf
  所属分类: C
  开发工具:
  文件大小: 215kb
  下载次数: 0
  上传时间: 2019-05-24
  提 供 者: su_****
 详细说明:EFI BIOS平台,关于 ATA硬盘指令的开发规范/ Assemble packet. If it is non blocking mode, the Ata driver should keep each subtask and clean them when the event is signaled. if (TaskPacket ! NULL)( Packet taskPacket Packet->Asb=AllocateAlignedBuffer (AtaDevice, sizeof (EFI ATA STATUS BLOCK)) if(Packel->Asb==NULL)[ return EFI OUT OF RESOURCES; Copy Mem (Packet->Asb, AtaDevice-)Asb, sizeof (EFI ATA STATUS BLOCK)) Packet->Acb= AllocateCopy Pool (sizeof (EFI ATA COMMAND BLOCK),&AtaDevice->Acb) e⊥se Packet = &AtaDevice->Packet Packet-asb= ataDevice->asb Packet>Ach &atadeviceacb AtaPassThru= AtaDevice-AtaBusDriverdata->AtaPassThru Status= AtaPassThru->PassThru AtaPass thru ALaDevice->P( AtaDevice->PortMultiplierport Packet Event // Ensure Ata pass through caller and callee have the same // interpretation of AtA pass through protocol. aSSert (Status ! EFI INVALID PARAMETER) ASSERT (Status ! EFI BAD BUFFER SIZE) return status /末 Wrapper for EFI AtA PASS THRU PROTOCOL. ResetDevice( This function wraps the ResetDevice( invocation for Ata pass through function for an ata device param AtaDevice The ata child device involved for the operation return The return status from EFI ATA PASS THRU PROTOCOL. Pass Thru EFI STATUS ResetataDevice IN ATA DEVICE 米 Atadeyice EFI ATA PASS THRU PROTOCOL 冰 AtaPass thru AtaPassthru atadevice-ataBusdriverdata->ataPassthru // Report Salus Code to indicale reset happens REPORT STATUS CODE WITH DEVICE PATH EFI PROGRESS CODE (EFI IO BUS ATA ATAPI EFI IOB PC RESET AlaDevice->AlaBusDriverDala-> ParentDevicePalh return AtaPassThru->Reset Device AtaPass thru AtaDevice->port AtaDevice->PortMultiplierPort /* Prints ata model name to ata device structure This function converts ata device model name from ata identify data to a string in ata device structure. it needs to change the character order in the original model name string param AlaDevice The Ata child device involved for the operalion VOID PrintAtaModeIName IN OUT ATA DEVICE *Aladevice Ind CHAR8 *Source CHAR16 *Destination Source- AtaDevice->Identify Data->Modelname Destination atadevice-mode iname Swap the byte order in the original module name for (Index=0: Index< MAX MODEL NAME LEN; Tndex + 2) DestinationlIndexl Sourcelindex +11 Destination[Index 1= Source lIndel AtaDevice-)ModelNameI MAX MODEL NAME LEN=L'\0 Gets ata device capacity according to ata 6. This function returns the capacity of the ata device if it follows aTa 6 to support 48 bit addressing. param AtaDevice The ata child device involved for the operation return The capacity of the ata device or o if the device does not support 48-bit addressing defined in ATA 6 EFI LBA GetAtapi6capacity IN ATA DEVICE 冰 AtaDevice EFI Capacity; EFI Tmplba UINTN Index A"A⊥ DENTIEFY DATA kIdentifyData I dentifyData AtaDevice->IdentifyData: if((IdenlifyDala->command set supported 83& BIT10) // The device doesn't support 48 bit addressing return o //48 bit address feature set is supported, get maximum capacity for (Index =0; Index 4: Index++) / Lower byte goes first: word[100] is the lowest word, word[103 is highest TmpLba Identify Data->maximum Iba for 48bit addressing [Index] Capacity= LShirL64(TmpLb, 16 Index return Capacity; 半米 Identifies ata device via the identify data This function identifies the ata device and initializes the media informa lion ir Block Io protocol interface param AtaDevice The ata child device involved for the operation retval EFI UNSUPPorTed The device is not a valid ata device (hard disk) retval EFI SUCCeSS The device is successfully identified and Media information s correctly initialized. EFI STATUS IdenlifyalaDevice IN OUT ATA DEVICE 冰 AtaDevice A⊥A⊥ DENTITY DATA iDentify Data EFI BLOCK IO MEDIA *kblockMedia EFI LBA Capacity UINT16 Phy LogicSectorSupport UINT16 Identify Dala= AlaDevice->Idenlify Dal if((identify Data->config Bit15)!=0) // This is not an hard disk return Efi UnSuPported DEBUG ((EFI D INFO,AtaBus- Identify Device: Port %x PortMultiplierport %x\n", AtaDevice- >Port, AtaDevice->PortMultiplierport)) Check whether the WORD 88 (supported ultradma by drive) is valid it'((IdentifyData- >field validity BIT2)!=0)( UdmaMode- Idenlify Dala>ultra dma mode; if ((Udma Mode &(BITO BIT1 BIT2 BIT3 BIT4 BIT5 BIT6))!=0)[ / If Bito BIT6 is selected, then [DMA is supported AtaDevice-ldmavalid TRUe Capacity- GetAtapi6Capacity (AtaDevice) f(Capacity > MAX 28BIT ADDRESSING CAPACITY)[ / Capacity exceeds 120GB. 48-bit addressing is really needed ataDevice->Lba48Bit TRUE e se / This is a hard disk (=120GB capacity, treat it as normal hard disk Capacity =((UInt32)Identify Data->user addressable sectors hi<< 16) Identify Data- seT addressable sectors lo AtaDevice-Lba48Bit false / Block Media Information BlockMedia &ataDevice-blockmedia BlockMedia->Lds(Block- Capacity- 1 BlockMedia->IoAlign= AtaDevice->AtaBusDriverData->AtaPass Thru->Mode->IoAlign / Check whether Long Physical Sector Feature is supported PhylogicSector Support Identify Data-phy logic sector support if((Phy Logic SectorSupport &(BIT14 BIT15))=BIT14)i / Check whether one physical block contains multiple physical blocks if ((Phy Logic SectorSupport BiT13)!=0)i BlockMedid->LogicalBlocksPerPhysicalBlock-(UINT32)(1<<(Phy Logic SeclorSupport 0x000f)) / Check lowest alignment of logical blocks within physical block if ((Identify Dala->alignment logic in phy blocks &(BIT14 BIT15))==BIT14)( BlockMedia->LowestAlignedLba=(EFI LBA)((BlockMedia->LogicalBlocksPerPhysicalBlock ((UINT32) Identify Data->alignment logic in phy blocks 0x3fff))% BlockMedia->LogicalblocksPerPhysicalBlock / Check logical block size if ((Phy Logic Sector Support BIT12)!=0) BlockMedia->BlockSize =(UINT32)(((Identify Data->logic sector size hi<< 16) IdentifyData->logic sector size lo) *k sizeof (UINT16) AtaDevice-blocklo revision Efi blocK io Protocol revision2 Gel Ata odel name fromm idenlify dala slructure PrintAtaModelName (AtaDevice) return EF succeSs /* Discovers whether it is a valid ata device This function issues ATa CMD IDENTIFY drivE command to the ata device to identify it If the command is executed successfully, il hen identifies it and initializes the media information in block io protocol interface. param AtaDevice The ata child device involved for the operation retval efI success The device is successfully identified and media information is correctly initialized return others Some error occurs when discovering the ata device. EFI STATUS DiscoverAlaDevice IN OUT ATA DEVICE katadevice EFI STATUS Status, EFI ATA COMMAND BLOCK 本Acb; EFI ATA PASS THRU COMMAND PACKET *Packet UINTN Retry // Prepare for ATA cOmmand block Acb- ZeroMem (&AtaDevice->Acb, sizeof (EFI ATA COMMAND BLOCK)) Acb->atacommand AtA cMd IdentifY drive Acb-)AtaDeviceHead=(UINT8)(BIT7 BIT6 BIT5 (AtaDevice->Port Multiplierport < 4)) // Prepare for ata pass through packet Packet= ZeroMem (&AtaDevice->Packet, sizeof (EFI ATA PASS THRL: COMMAND PACKET)) Packet->InDataBuffer AtaDevice->Identify Data Packel->InTransferLengih-sizeof (ATA IDENTIFY DATA Packet->Protocol= Efl ATA PASS THRU PROTOCOL PIo data in Packet->Length =EFT ATA PASS THRU LENGTH BYTES EFT ATA PASS THRU LENGTH SECTOR COUNT Packet->Timeout ATA TIMEOUT Retry MAX RETRY TIMES do Status- AtaDevicePassThru (AtaDevice, NULL, NULL) if (!EFI ERROR (Status))[ / The Command is issued success fully Status IdentifyAtaDevice (AtaDevice) return status g while (Retry-->0 return status /* Transfer data from ata device This function performs one ata pass through transaction to transfer data from/ to ata device. It chooses the appropriate ata command and protocol to invoke Pass thru interface of AtA pass through. paran LIn, ut AtaDevice The ata child device involved for the operation paramin, out TaskPacket Pointer lo a Pass thru Command packet. Optional if it is NUll, blocking mode, and use the packet in AtaDevice. If it is not NULL, non blocking mode, his packet [in, out] Buffer The pointer to the current transaction buffer p paraI Lin Starlab The slarting logical block address to be accessed param「in Transfcrlength The block number or sector count of the transfer. paracin Rewrite Indicates whether it is a write operation p Caramon Event If Event is null, then blocking i/ o is performed If Event is not NULL and non-blocking 1/0 is supported, then non-blocking I/0 is performed and Event will be signaled when the write request is completed retval efI Success The data transfer is complete successfull return others Some error occurs when transferring data EFI STATUS TransferAtaDevice IN OUT ATA DEVICE 冰 AtaDeyice, IN OUT EFI ATA PASS THRU COMMAND PACKET TaskPackeL. OPTIONAL UT VOID 冰 Buffer, IN EFI LBA Startlba IN UINT32 Transferlength IN BOOLEAN IsWrite IN EFI EVENT EvenL optional EFL ATA COMMAND BLOCK acb EFI ATA PASS THRU COMMAND PACKET * *Packet // Ensure AtaDevice->UdmaValid, AtaDevice->Lba48Bit and IsWrite are valid boolean values ASSERT ((UINTN) AtaDevice->UdmaValid< 2) assert((UINTN) AtaDevice->Lba48Bit< 2) aSSErt ((UINTN) IsWriLe< 2) / Prepare for ATA command block. Acb= ZeroMem (&AtaDevice->Acb, sizeof (EFl ATA COMMAND BLOCK)) Acb->ALaCommand= mnA La Commands [AlaDevice->dma Valid [AlaDevice->Lba48BilILIsWritel Acb->AtaSector Number =(UINT8) StartLba Acb->AtaCylinderLOW- ( UINT8)RShiftU64(StartLba, 8) Acb->AtaCylinderHigh =(UINT8) RShiftU64 (StartLba, 16) Acb-)AtaDevicellead=(UINT8)(BIT7 BIT6 BIT5 (AtaDevice->Port Multiplierport << 4)) Acb->AlaSectorCounl-(UINT8) Trans ferLenglh if (AtaDevice->Lba48Bit)I Acb->AtaSectorNumberExp =(UINT8) RShiftu61(StartLba, 21) Acb->AtaCylinderLowExp=(UINT8)RShiftU64(StartLba, 32 Acb->AtaCylinderHighExp=(UINT8) RShiftu64 (StartLba, 40) Acb->AtaSectorCountExp =(UINT8)(TransferLength >)8) j else i Acb->AtaDeviceHead=(UINT8)(Acb->AtaDeviceHead RShiftU61(StartLba, 21)) // Prepare for ATa pass through packet if (TaskPacket ! NULI Packet= ZeroMem (TaskPacket, sizeof (EFI ATA PASS THRU COMMAND PACKET)) eI se Packet= ZeroMeml (&ALaDevice->Packet, sizeof (EFI ATa PASS THRU COMMAND PACKET) if(IsWrite) Packet->OutDataBuffer Buffer Packet-OutTransferlength Transferlength Packet-InDataBuller= Buffer Packet->InTransferlength= Transferlength Packet >Protocol mAtaPass'ThruCmdProtocolslAtaDevice-)UdmaValidllsWritel Packet->length EFI ATA PASS THRU LENGTH SECTOR COUNT //////∥/ / ATA PIO Transfer Mod. Transfer Rate ATA DMA Transfer Mode Transfer rate PIo Mode o 3.3Mbytes/sec Single-word DMA Mode 0 2. 1Mby tes/sec PIO Mode 1 5.2Mbytes/ sec Single-word DMA Mode 11. 2Mbytes/sec PIO MOde 2 8. 3Mbytes/sec Single-word DMA Mode 2 8. 4Mbytes/sec //∥ PIO Mode 3 11. 1Mby les/sec Multi-word DMA Mode 0 4. 2Mby les/ sec PIO Mode 4 16. 6Mbytes/sec Multi-word DMA Mode 113. 3Mbytes/sec As albus is used Lo manage ata devices, we have to use the lowest transfer rale lo // calculate the possible maximum timeout value for each read/ write operation. / The timout value is rounded up to nearest integar and here an additional 30s is added / to follow Ata spec in which it mentioned that the device may take up to 30s to respond // commands in the Standby/Idle mode if (AtaDevice->tdmaValid) / Calculate the maximum timeout value for DMa read/write operation. Packet-Timeout EFI TIMER PERIOD SECONDS (DivU64x32 (Mult[64x32 (TransferLength ALaDevice->BlockMedia BlockSize), 2100000)+31) i else / Calculate the maximum timeout value for Pio read/ write operation Packel->Timeout- EFI TIMER PERIOD SECONDS (DivU64x32(MullL64x32(Trans ferLenglh AtaDevice->BlockMedia BlockSize), 3300000)+31) return AtaDevicePass'Thru (AtaDevice, TaskPacket, Event) 半米 Free subtask param[in, out Task Pointer to task to be freed 半* VOID EFLAPI FreeAtaSubrask IN OUT ATA BUS ASYN SUB TASK Task if (Task->Packet. Ash ! NULL) FreeAlignedBuffer (Task->Packet. Asb, sizeof (EFI ATA STATUS BLOCK)) if (Task->Packet Acb ! NULL) i FreePool (Tdsk->Packet Acb) FreePool (Task) 半米 Terminate any in-flight non-blocking I/0 requests by signaling an EFI ABORTED n the Transactionstatus member of the efi block t02 TOKen for the non-blocking 170. After that it is safe to free any Token or Buffer data structures that were allocated to initiate the non-blockingI/o requests that were in-flight for this device paramlin AtaDevice The ata child device invol ved for the operation 水木 VOID EFLAPI AtaTerminateNonBlockingTask IN ATA DEVICE 冰 AtaDevice BOOLEAN SubTaskempty EFI TPL oldTpl ATA BUS ASYN TASK 半 Atatask *Entry LIST ENTRY 冰LisL o1dTp1- gBS->RaiseTPL (TPL NOTIFY / Abort all executing tasks from now ataDevice->abort TRUe List &atadeviceatatasklist for(Entry= GetFirstNode (List);!IsNull (List, Entry); )i AtaTask ATA ASYN TASK FROM ENTRY (Entry) AlaTask- Toker-trausactionslalus EFI ABOrteD gBS->SignalEvent (AtaTask->Token->Event) Entry=RemoveEntryList.(Entry) FreePool (AtaTask) gBS->RestoretPl(oldTpl do OldTpl =gBS-RaiseTPL (TPL NOTIFY) // Wait for executing subtasks done SubTaskempty isl istempty (&ataDevice->AtaSubTasklist) gBS->RestoretPL(oldTp1) g while ( SubTaskEmpty) / Aborting operation has been done. From now on, don't need to abort normal operation OldTpl= gbS-RaiselPL (TPL NOTIFY) aLadeyice-aborL= false gBS-RestoreTPL(O1dTp1) * Call back funtion when the event is signaled
(系统自动生成,下载前可以参看下载内容)

下载文件列表

相关说明

  • 本站资源为会员上传分享交流与学习,如有侵犯您的权益,请联系我们删除.
  • 本站是交换下载平台,提供交流渠道,下载内容来自于网络,除下载问题外,其它问题请自行百度
  • 本站已设置防盗链,请勿用迅雷、QQ旋风等多线程下载软件下载资源,下载后用WinRAR最新版进行解压.
  • 如果您发现内容无法下载,请稍后再次尝试;或者到消费记录里找到下载记录反馈给我们.
  • 下载后发现下载的内容跟说明不相乎,请到消费记录里找到下载记录反馈给我们,经确认后退回积分.
  • 如下载前有疑问,可以通过点击"提供者"的名字,查看对方的联系方式,联系对方咨询.
 相关搜索: ATA_EFI_Command.pdf
 输入关键字,在本站1000多万海量源码库中尽情搜索: