# SataController

## Function Table

| Address | Name | Description |
|---------|------|-------------|
|  | **SataGetDeviceCount** |  |
|  | **SataGetDevice** |  |
|  | **SataIdentifyDevice** |  |
|  | **SataModifyDevice** |  |
|  | **SataSubmitAsyncCommand** |  |
|  | **SataStopDevice** |  |
|  | **SataCalculateBestPioMode** |  |
|  | **PchGetPchSeries** |  |
|  | **S3BootScriptLibInit** |  |
|  | **S3BootScriptEventNotify** |  |
|  | **S3BootScriptFinalize** |  |
|  | **S3ReadyToLockNotify** |  |
|  | **S3BootScriptCloseEvent** |  |
|  | **S3BootScriptCloseNotify** |  |
|  | **SaveBootScriptDataToLockBox** |  |
|  | **SmmLockBoxSave** |  |
|  | **SmmLockBoxSetAttributes** |  |
|  | **SmmLockBoxRestore** |  |
|  | **S3BootScriptLibDeinit** |  |
|  | **SataComponentNameGetDriverName** |  |
|  | **SataComponentNameGetControllerName** |  |
|  | **LookupStringTable** |  |
| EFI_IDE_CONTROLLER_INIT_PROTOCOL | **implementation** |  |
| Allocate | **result buffer for caller** |  |
| ResultBuffer | **= AllocatePool (sizeof (EFI_IDE_CHANNEL_INFO));** |  |
| Query | **best PIO mode** |  |
| MaxMode | **= 0;** |  |
| Mode | **valid** |  |
| Mode | **invalid** |  |
| Check | **DMA capability** |  |
| if | **(SataPrivateData->DeviceIdentifyData[Channel][106] & 4) {** |  |
| Device | **supports DMA - calculate best DMA mode** |  |
| UINT16 | **DmaMode = 0;** |  |
| No | **DMA** |  |
| PIO | **Mode Calculation** |  |
| Field | **103: IORDY support and mode info** |  |
| Field103 | **= IdentifyData->Field103;** |  |
| No | **IORDY - use PIO mode 0-2 only** |  |
| BestPio | **= Field103;** |  |
| IORDY | **supported - determine PIO mode 0-4** |  |
| Determine | **PIO mode from timing** |  |
| if | **(PioModeBits <= 0x78) {** |  |
| PCH | **Series Detection** |  |
| Check | **if device ID falls in SPT range (0x9D00-0x9D3F with mask 0xFF70)** |  |
| if | **(((LpcDeviceId + 24128) & 0xFF70) != 0) {** |  |
| Check | **CNP range** |  |
| if | **((UINT16)(LpcDeviceId + 25280) <= 8) {** |  |
| Cannon | **Point** |  |
| S3 | **Boot Script Library** |  |
| Allocate | **EfiReservedMemory for boot script context** |  |
| Status | **= GetPcdDbProtocol ();** |  |
| Locate | **SMM protocol** |  |
| Status | **= gBS->LocateProtocol (&gEfiSmmBase2ProtocolGuid, NULL, &gSmst);** |  |
| Register | **S3 boot script close notification** |  |
| Status | **= gBS->CreateEvent (** |  |
| Status | **= gBS->RegisterProtocolNotify (** |  |
| S3 | **Boot Script Event Notify Callbacks** |  |
| Inside | **SMM - check if already saved** |  |
| if | **(gBootScriptContext != NULL && !gBootScriptContext->FlagSaved) {** |  |
| S3 | **Boot Script Data save to LockBox** |  |
| Step | **1: Save boot script context to lockbox** |  |
| Status | **= SmmLockBoxSave (&gBootScriptFinalGuid** |  |
| Step | **2: Get memory map** |  |
| Step | **3: Allocate memory ranges structure** |  |
| PagesAddr | **= (EFI_PHYSICAL_ADDRESS)(UINTN)-1;** |  |
| Count | **ranges that are not MMIO** |  |
| for | **(Index = 0; Index < MemoryMapSize / MapDescriptorSize; Index++) {** |  |
| Allocate | **memory ranges buffer** |  |
| BufferSize | **= MemoryRanges->NumberOfMemoryRanges * sizeof (MEMORY_RANGE_ENTRY);** |  |
| Step | **4: Fill memory ranges** |  |
| Step | **5: Save memory ranges to lockbox** |  |
| Status | **= SmmLockBoxSave (&gBootScriptFinalGuid, MemoryRanges** |  |
| SMM | **LockBox Wrappers** |  |
| ReturnStatus | ***(UINT32 *)(CommBuffer + 24) = 1;            // Function: Save** |  |
| HeaderSize | **CopyMem (CommBuffer + 40, Guid, 16);** |  |
| Close | **DxeSmmReadyToLock event** |  |
| if | **(gDxeSmmReadyToLockEvent != NULL) {** |  |
| Unregister | **notifies** |  |
| if | **(gSmst != NULL) {** |  |
| Free | **boot script buffer** |  |
| if | **(gBootScriptAllocated && gBootScriptContext != NULL) {** |  |
| Free | **SMM allocated buffer** |  |
| if | **(gSmstAllocated && gSmst != NULL) {** |  |
| Component | **Name Protocol** |  |
| Verify | **the controller is managed by this driver** |  |
| EFI_STATUS | **Status;** |  |
| Not | **PCI IO - return unsupported** |  |
| if | **(Status != EFI_UNSUPPORTED) {** |  |
| String | **Table Lookup** |  |
| RFC | **4646 language tags: compare 3-byte prefix** |  |
| if | **(ReadUint24 ((UINT32 *)Lang) == ReadUint24 ((UINT32 *)SupportedLanguages)) {** |  |
| ISO | **639-2: split by ';', compare each** |  |
| Skip | **to next language token** |  |
| Lang | **+= TokenLen;** |  |
| Compare | **entry token with language** |  |
| CHAR8 | ***StrTok = *Entry;** |  |
| Skip | **semicolons** |  |

---
*Generated by HR650X BIOS Decompilation Project*