![Texas Instruments AM1808 Скачать руководство пользователя страница 1364](http://html.mh-extra.com/html/texas-instruments/am1808/am1808_technical-reference-manual_10945581364.webp)
Use Cases
1364
SPRUH82C – April 2013 – Revised September 2016
Copyright © 2013–2016, Texas Instruments Incorporated
Serial ATA (SATA) Controller
sataRegs->P0CMD &= ~(1 << AHCI_PxCMD_FRE_SHIFT);
waitForXms(WAIT_500_MILLISECONDS);
}// Wait unti FR is Cleared.
while (sataRegs->P0CMD & AHCI_PxCMD_FR)
waitForXms(WAIT_500_MILLISECONDS);
// If P0CMD.FRE is still set, HBA probably has hunged. No need to continue.
//
Need to perform HBA Reset.
if (sataRegs->P0CMD & AHCI_PxCMD_FRE)
return(1);
return(0);
}
void associateSysMem2Hba(Uint16 cmdSlot) {
associtateCmdSlotWithCmdTable(cmdSlot);
// Assign Sys Mem allocated for Cmd Table to Cmd
List Slot
//associtatePrdsWithCmdTable(cmdSlot);
// Assign PRD info to Cmd Table
associtatePrdsWithCmdTable(cmdSlot, sata_input_filePageSize);
}
void associtateCmdSlotWithCmdTable(Uint16 cmdSlot) {
CmdLists[cmdSlot].DW2.CmdTableAddLow=((unsigned int)&CmdTable[cmdSlot] & 0xFFFFFF80);
CmdLists[cmdSlot].DW3.CmdTableAddHigh=0x0;
}
void associtatePrdsWithCmdTable(Uint16 cmdSlot, Uint16 fSize) {
Uint16 fileSIZE, prdLength;
for (fileSIZE=0; fileSIZE<fSize; f+) {
for (prdLength=0; prdLength<sata_input_prdLength; pr+) {
// Command Header 0 PRD Descriptors 0 & 1 are Initialized.
CmdTable[cmdSlot].prdTable[(sata_input_prdLength*fiprdLength].DW0.DbaLow=(unsigned
int)&prdTableDataBuff[cmdSlot][prdLength];
CmdTable[cmdSlot].prdTable[(sata_input_prdLength*fiprdLength].DW1.DbaHigh=0x0;
CmdTable[cmdSlot].prdTable[(sata_input_prdLength*fiprdLength].DW3.DataBC=sata_input_prd_da
taBuffLen-1;
}
}
}
void setSataSpeed(unsigned char iSpeed) {
sataRegs->P0SCTL |= (iSpeed << AHCI_PxSCTL_PxSSTS_SPD_SHIFT);
waitForXms(5); // This might not be necessary: wait a bit
}
char setupCfisEntriesForDataRdWr(CmdListHeader *CmdListNum, dataXferDir readOrWrite, xferProtocol
xferType) {
// *************************************************************************************
//$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ **** Initializing the Command Header *******
// Other part of the Command List Structure, with the exception of Word 0 for the
//
Command Slots[0] and [1] are already initialized when invoking sata_init_and_spin_up()
//
function via associateMem2HBA() function.
// Configure Word 0 of Command List
CmdListNum->DW0.CmdLen=5;
// This is the length of H2D FIS. This might need changing
//
based on the Command issued to Device. Need to Check.
CmdListNum->DW0.Atapi=0;
// Command is destined to HDD Like Device.
CmdListNum->DW0.Prefetch=1; // Doesn't hurt prefetching so do it.
// WARNING: Do Not Prefetch if using:
//
=> Command Queuing
//
=> Port Multiplier
CmdListNum->DW0.Reset=0;
// This is normally set to Zero unless a Soft Reset is required.
CmdListNum-