# OpalSecurity

## Function Table

| Address | Name | Description |
|---------|------|-------------|
|  | **OpalReadCmosDebugLevel** |  |
|  | **OpalGetHobList** |  |
|  | **OpalSecurityDriverInit** |  |
|  | **OpalSecurityBindingStart** |  |
|  | **OpalSecurityBindingStop** |  |
|  | **OpalSecurityAllocBuffer** |  |
|  | **OpalSecurityReceiveResponse** |  |
|  | **OpalSecuritySendCommand** |  |
|  | **TcgStorageIoRecv** |  |
|  | **TcgStorageIoSend** |  |
|  | **OpalDebugAssertPrint** |  |
|  | **OpalAssertHandler** |  |
|  | **OpalCompareGuid** |  |
|  | **OpalReadUnaligned64** |  |
| External | **global variables set by the UEFI Boot Services Table Library** |  |
| extern | **EFI_HANDLE        gImageHandle;** |  |
| STATIC | **EFI_BOOT_SERVICES    *mBootServices             = NULL;** |  |
| Forward | **declarations** |  |
| STATIC | **UINTN** |  |
| Module | **Entry Point** |  |
| Cache | **UEFI service table pointers locally** |  |
| if | **(mSystemTable == NULL) {** |  |
| Allocate | **a protocol instance structure** |  |
| Status | **= mBootServices->AllocatePool (** |  |
| Populate | **the protocol dispatch table with binding Start/Stop** |  |
| Install | **the Opal Security Protocol onto the image handle** |  |
| Set | **the MemoryOverwriteRequestControl variable per UEFI spec** |  |
| Driver | **Binding Start** |  |
| Zero | **the buffer used for TCG command data** |  |
| OpalMemset | **(Buffer, 0, sizeof (Buffer));** |  |
| Check | **if the controller supports TCG Storage IO (type == 1)** |  |
| if | **(StorageIoType == 1)** |  |
| Copy | **the device context from the controller handle** |  |
| CopyMem | **(Buffer, (VOID *)((UINTN)ControllerHandle + 35), 4 * sizeof (UINT128));** |  |
| Verify | **TCG SSC feature bit in Level 0 discovery data (bit 94)** |  |
| if | **((Buffer[94] & 1) == 0) {** |  |
| Check | **if the protocol already exists on this controller** |  |
| Allocate | **the child protocol instance (32 bytes)** |  |
| Initialize | **child protocol with TCG send/recv handlers** |  |
| Install | **the child protocol** |  |
| If | **Opal Security is enabled, perform initial security exchange** |  |
| if | **((mOpalSecurityEnabled & 1) != 0 &&** |  |
| Driver | **Binding Stop** |  |
| Buffer | **Allocation for TCG Security Protocol** |  |
| Issue | **IF-RECV (Level 0 Discovery) to read TCG capabilities** |  |
| Process | **TCG Security Response (IF-RECV data parsing)** |  |
| Read | **descriptor count from Level 0 Discovery response** |  |
| NumDescriptors | **= _byteswap_ushort (*(UINT16 *)(DiscoveryBuffer + 6));** |  |
| Parse | **TCG Level 0 Discovery descriptors** |  |
| for | **(Index = 0; Index < NumDescriptors; Index++)** |  |
| TCG | **Storage SSC feature found** | send IF-SEND command |
| TmpBuffer | **= 0;** |  |
| Opal | **SSC v2 (Pyrite) feature** | issue IF-RECV |
| Status | **= OpalSecuritySendCommand (Protocol);** |  |
| TCG | **Storage IF-SEND Command** |  |
| CommandIteration | **= 256;** |  |
| Verify | **the COM ID iteration matches** |  |
| while | **(CommandIteration != _byteswap_ushort (*(UINT16 *)(CmdResponseBuffer + 2)))** |  |
| Final | **IF-RECV with Level 1 discovery ProtocolId** |  |
| SmallBuffer | **= NULL;** |  |
| TCG | **IF-RECV (receive security data without transfer length)** |  |
| Build | **TCG IF-RECV packet** |  |
| TCG | **IF-SEND (send security data with transfer length)** |  |
| Debug | **Support Functions** |  |
| HOB | **List Retrieval** |  |
| Utility | **Functions** |  |

---
*Generated by HR650X BIOS Decompilation Project*