# PcRtc

## Function Table

| Address | Name | Description |
|---------|------|-------------|
|  | **ModuleEntryPoint** |  |
|  | **PcRtcEntryInit** |  |
|  | **PcRtcVirtualAddressChangeEvent** |  |
|  | **PcRtcGetTime** |  |
|  | **PcRtcSetTime** |  |
|  | **PcRtcGetWakeupTime** |  |
|  | **PcRtcSetWakeupTime** |  |
|  | **PcRtcRead** |  |
|  | **PcRtcWrite** |  |
|  | **PcRtcWaitForUpdate** |  |
|  | **PcRtcGetTimeInternal** |  |
|  | **PcRtcSetTimeInternal** |  |
|  | **PcRtcValidateTime** |  |
|  | **PcRtcValidateDay** |  |
|  | **PcRtcTimeFieldsValid** |  |
|  | **PcRtcBcdToBinary** |  |
|  | **PcRtcBinaryToBcd** |  |
|  | **PcRtcLockRtc** |  |
|  | **PcRtcUnlockRtc** |  |
| Global | **Variables (stored in .data at VA 0x5000-0x51C0)** |  |
| DebugLib | **Protocol GUID (36232936-0E76-31C8-A13A-3AF2FC1C3932)** |  |
| HOB | **List GUID (7739F24C-93D7-11D4-9A3A-0090273FC14D)** |  |
| RTC | **Architecture Protocol GUID (27CFAC87-46CC-11D4-9A38-0090273FC14D)** |  |
| Unknown | **Protocol GUID 1 (11B34006-D85B-4D0A-A290-D5A571310EF7)** |  |
| Unknown | **Protocol GUID 2 (27ABF055-B1B8-4C26-8048-748F37BAA2DF)** |  |
| Unknown | **Protocol GUID 3 (13FA7698-C831-49C7-87EA-8F43FCC25196)** |  |
| DXE | **Services Table GUID (05AD34BA-6F02-4214-952E-4DA0398E2BB9)** |  |
| Unknown | **Protocol GUID 4 (378D7B65-8DA9-4773-B6E4-A47826A833E1)** |  |
| Module | **Entry Point (0x1114)** |  |
| Initialize | **the RTC driver:** |  |
| Status | **= PcRtcEntryInit ();** |  |
| If | **initialization failed, trigger assertion.** |  |
| ASSERT_EFI_ERROR | **(Status);** |  |
| PcRtcEntryInit | **- Main Driver Initialization** |  |
| Step | **1: Get HOB list from SystemTable ConfigurationTable.** |  |
| HobList | **= GetHobList ();** |  |
| Step | **2: Verify RTC hardware.** |  |
| Read | **Register A and D to check RTC state.** |  |
| Step | **3: Read and validate current RTC time.** |  |
| If | **invalid (e.g., CMOS battery dead), initialize to default.** |  |
| Status | **= PcRtcGetTime (&CurrentTime, NULL);** |  |
| Debug | **message: "PcRtc: Write 0x%x to CMOS location 0x%x"** |  |
| DEBUG | **((EFI_D_INFO, "PcRtc: RTC time invalid, initializing to default\n"));** |  |
| Step | **4: Register SetVirtualAddressMap event.** |  |
| Required | **for runtime drivers** | converts pointers on OS virtual |
| address | **mapping.** |  |
| VirtualAddressChangeEvent | **= NULL;** |  |
| Step | **5: Install runtime RTC services into gRT.** |  |
| return | **EFI_SUCCESS;** |  |
| PcRtcVirtualAddressChangeEvent | **- Runtime Pointer Conversion** |  |
| Convert | **runtime pointers.** |  |
| EfiConvertPointer | **(0, &gRT);** |  |
| PcRtcGetTime | **- Read Current Time from RTC** |  |
| Acquire | **RTC lock - raise TPL to TPL_HIGH_LEVEL for atomic access.** |  |
| This | **prevents interrupt handlers from reading the RTC during our** |  |
| PcRtcLockRtc | **(&OldTpl);** |  |
| Read | **time from CMOS registers (waits for UIP, then reads all regs).** |  |
| Status | **= PcRtcGetTimeInternal (Time);** |  |
| Release | **RTC lock - restore previous TPL.** |  |
| PcRtcUnlockRtc | **(OldTpl);** |  |
| Optionally | **fill time capabilities.** |  |
| if | **(Capabilities != NULL) {** |  |
| 1 | **Hz (1 second granularity)** |  |
| Unknown | **Capabilities->SetsToZero = FALSE;** |  |
| PcRtcSetTime | **- Write Time to RTC** |  |
| PcRtcGetWakeupTime | **- Read RTC Alarm** |  |
| Read | **alarm registers from CMOS.** |  |
| PcRtcSetWakeupTime | **- Set RTC Alarm** |  |
| Disable | **alarm interrupt during update.** |  |
| RegisterB | **= PcRtcRead (RTC_REG_STATUS_B);** |  |
| Write | **"don't care" to all alarm registers to disable.** |  |
| PcRtcWrite | **(RTC_REG_SECONDS_ALARM, RTC_ALARM_DONT_CARE_MIN);** |  |
| Clear | **any pending alarm IRQ by reading Register C.** |  |
| PcRtcRead | **(RTC_REG_STATUS_C);** |  |
| PcRtcRead | **/ PcRtcWrite - CMOS Port Access Utilities** |  |
| PcRtcWaitForUpdate | **- Wait for RTC Update Cycle** |  |
| Poll | **UIP bit until clear.** |  |
| Typical | **wait is <10 microseconds.** |  |
| while | **((PcRtcRead (RTC_REG_STATUS_A) & RTC_REG_A_UIP) != 0) {** |  |
| PcRtcGetTimeInternal | **/ PcRtcSetTimeInternal - Locked CMOS Access** |  |
| Convert | **BCD to binary if needed.** |  |
| if | **((RegisterB & RTC_REG_B_DM) == 0) {** |  |
| Convert | **12h to 24h if needed.** |  |
| if | **((RegisterB & RTC_REG_B_24H) == 0) {** |  |
| PM | **in 12h mode.** |  |
| Combine | **year and century.** |  |
| Century | **= PcRtcRead (RTC_REG_CENTURY_DEFAULT);** |  |
| Set | **SET bit to freeze RTC registers during write.** |  |
| PcRtcWrite | **(RTC_REG_STATUS_B, RegisterB | RTC_REG_B_SET);** |  |
| BCD | **mode: convert binary to BCD before writing.** |  |
| PcRtcWrite | **(RTC_REG_SECONDS,      PcRtcBinaryToBcd (Time->Second));** |  |
| Binary | **mode: write values directly.** |  |
| PcRtcWrite | **(RTC_REG_SECONDS,      (UINT8)Time->Second);** |  |
| Set | **24h mode and clear SET bit in Register B.** |  |
| RegisterB | **|= RTC_REG_B_24H;** |  |
| PcRtcValidateTime | **/ PcRtcValidateDay / PcRtcTimeFieldsValid** |  |
| Gregorian | **leap year test.** |  |
| if | **((Year % 400 == 0) || (Year % 4 == 0 && Year % 100 != 0)) {** |  |
| PcRtcBcdToBinary | **/ PcRtcBinaryToBcd - BCD Conversion** |  |
| PcRtcLockRtc | **/ PcRtcUnlockRtc - Access Serialization** |  |

---
*Generated by HR650X BIOS Decompilation Project*