📄 realtimeclock.cod
字号:
; 454 : //
; 455 : bResult = FALSE;
000d4 03a00000 moveq r0, #0
; 456 : }
; 457 : return( bResult );
; 458 : }
000d8 e28dd008 add sp, sp, #8
000dc e8bd41f0 ldmia sp!, {r4 - r8, lr}
000e0 e12fff1e bx lr
000e4 |$L14451|
000e4 00000000 DCD |KFileTimeToSystemTime|
000e8 00000000 DCD |gliLastCurTicks|
000ec 00000000 DCD |CurTicks|
000f0 00000000 DCD |gfInitRTC|
000f4 |$M14447|
ENDP ; |OEMGetRealTime|
EXPORT |OEMSetRealTime|
00000 AREA |.text| { |OEMSetRealTime| }, CODE, ARM, SELECTION=1 ; comdat noduplicate
00000 AREA |.pdata$$OEMSetRealTime|, PDATA, SELECTION=5, ASSOC=|.text| { |OEMSetRealTime| } ; comdat associative
|$T14462| DCD |$L14461|
DCD 0x40002b02
; Function compile flags: /Ogsy
00000 AREA |.text| { |OEMSetRealTime| }, CODE, ARM, SELECTION=1 ; comdat noduplicate
00000 |OEMSetRealTime| PROC
; 461 : {
00000 |$L14461|
00000 e92d4070 stmdb sp!, {r4 - r6, lr}
00004 e24dd028 sub sp, sp, #0x28
00008 |$M14459|
00008 e1a04000 mov r4, r0
; 462 : //
; 463 : // NOTE: this function is passed a LOCAL time rather than a UTC time!
; 464 : //
; 465 : BOOL bResult;
; 466 : SYSTEMTIME curTime;
; 467 :
; 468 : if (gfInitRTC)
0000c e59f3094 ldr r3, [pc, #0x94]
00010 e5933000 ldr r3, [r3]
00014 e3530000 cmp r3, #0
; 469 : {
; 470 : // Setup the software RTC...
; 471 : initRTC();
00018 1b000000 blne initRTC
; 472 : }
; 473 :
; 474 : KFileTimeToSystemTime( &gftLastFileTime, &curTime );
0001c e59f6080 ldr r6, [pc, #0x80]
00020 e59f5078 ldr r5, [pc, #0x78]
00024 e28d1008 add r1, sp, #8
00028 e5963000 ldr r3, [r6]
0002c e2850008 add r0, r5, #8
00030 e1a0e00f mov lr, pc
00034 e12fff13 bx r3
; 475 :
; 476 : // if the last file time is updated, then update
; 477 : // the last current tick value...
; 478 : if( KSystemTimeToFileTime( lpst, &gftLastFileTime ) )
00038 e59f305c ldr r3, [pc, #0x5C]
0003c e2851008 add r1, r5, #8
00040 e1a00004 mov r0, r4
00044 e5933000 ldr r3, [r3]
00048 e1a0e00f mov lr, pc
0004c e12fff13 bx r3
00050 e3500000 cmp r0, #0
00054 0a00000b beq |$L14455|
; 479 : {
; 480 : SYSTEMTIME newTime;
; 481 :
; 482 : // remember when we last updated the time...
; 483 : gliLastCurTicks.QuadPart = CurTicks.QuadPart;
00058 e59f2038 ldr r2, [pc, #0x38]
; 484 :
; 485 : KFileTimeToSystemTime( &gftLastFileTime, &newTime );
0005c e5964000 ldr r4, [r6]
00060 e28d1018 add r1, sp, #0x18
00064 e5923000 ldr r3, [r2]
00068 e5922004 ldr r2, [r2, #4]
0006c e2850008 add r0, r5, #8
00070 e5853000 str r3, [r5]
00074 e5852004 str r2, [r5, #4]
00078 e1a0e00f mov lr, pc
0007c e12fff14 bx r4
; 486 :
; 487 : DEBUGMSG(DEBUG_SET, (_T("OEMSetRealTime: gliLastCurTicks: %d\r\n"),
; 488 : gliLastCurTicks.QuadPart ));
; 489 : DEBUGMSG(DEBUG_SET, (_T("OEMSetRealTime: cur: ST(%02d/%02d/%04d %02d:%02d:%02d)\r\n"),
; 490 : curTime.wMonth, curTime.wDay, curTime.wYear,
; 491 : curTime.wHour, curTime.wMinute, curTime.wSecond ));
; 492 : DEBUGMSG(DEBUG_SET, (_T("OEMSetRealTime: In: ST(%02d/%02d/%04d %02d:%02d:%02d)\r\n"),
; 493 : lpst->wMonth, lpst->wDay, lpst->wYear,
; 494 : lpst->wHour, lpst->wMinute, lpst->wSecond ));
; 495 : DEBUGMSG(DEBUG_SET, (_T("OEMSetRealTime: ft: ST(%02d/%02d/%04d %02d:%02d:%02d)\r\n"),
; 496 : newTime.wMonth, newTime.wDay, newTime.wYear,
; 497 : newTime.wHour, newTime.wMinute, newTime.wSecond ));
; 498 :
; 499 : bResult = TRUE;
00080 e3a00001 mov r0, #1
00084 ea000000 b |$L14361|
00088 |$L14455|
00088 e59d0000 ldr r0, [sp]
0008c |$L14361|
; 500 : }
; 501 : return( bResult );
; 502 : }
0008c e28dd028 add sp, sp, #0x28
00090 e8bd4070 ldmia sp!, {r4 - r6, lr}
00094 e12fff1e bx lr
00098 |$L14464|
00098 00000000 DCD |CurTicks|
0009c 00000000 DCD |KSystemTimeToFileTime|
000a0 00000000 DCD |gliLastCurTicks|
000a4 00000000 DCD |KFileTimeToSystemTime|
000a8 00000000 DCD |gfInitRTC|
000ac |$M14460|
ENDP ; |OEMSetRealTime|
EXPORT |OEMSetAlarmTime|
IMPORT |OEMInterruptEnable|
IMPORT |gfRTCAlarm|
IMPORT |gliRTCAlarmTicks|
00000 AREA |.text| { |OEMSetAlarmTime| }, CODE, ARM, SELECTION=1 ; comdat noduplicate
00000 AREA |.pdata$$OEMSetAlarmTime|, PDATA, SELECTION=5, ASSOC=|.text| { |OEMSetAlarmTime| } ; comdat associative
|$T14479| DCD |$L14478|
DCD 0x40002902
; Function compile flags: /Ogsy
00000 AREA |.text| { |OEMSetAlarmTime| }, CODE, ARM, SELECTION=1 ; comdat noduplicate
00000 |OEMSetAlarmTime| PROC
; 505 : {
00000 |$L14478|
00000 e92d4030 stmdb sp!, {r4, r5, lr}
00004 e24dd018 sub sp, sp, #0x18
00008 |$M14476|
00008 e1a04000 mov r4, r0
; 506 : BOOL bResult = TRUE;
; 507 : SYSTEMTIME stCurTime;
; 508 : FILETIME ftAlarmTime;
; 509 : ULARGE_INTEGER uliCurFTime;
; 510 : ULARGE_INTEGER uliAlarmFTime;
; 511 :
; 512 : // The following call will make sure that
; 513 : // the RTC is properly initialized...
; 514 : // This will return the LOCAL time.
; 515 : // A side-effect that is used here is that
; 516 : // gftLastFileTime is set to the current time...
; 517 : // gliLastCurTicks is also modified...
; 518 : OEMGetRealTime( &stCurTime );
0000c e28d0008 add r0, sp, #8
00010 eb000000 bl OEMGetRealTime
; 519 :
; 520 : DEBUGMSG(DEBUG_ALARM, (_T("OEMSetAlarmTime: CurTime: ST(%02d/%02d/%04d %02d:%02d:%02d)\r\n"),
; 521 : stCurTime.wMonth, stCurTime.wDay, stCurTime.wYear,
; 522 : stCurTime.wHour, stCurTime.wMinute, stCurTime.wSecond ));
; 523 : DEBUGMSG(DEBUG_ALARM, (_T("OEMSetAlarmTime: Alarm: ST(%02d/%02d/%04d %02d:%02d:%02d)\r\n"),
; 524 : lpst->wMonth, lpst->wDay, lpst->wYear,
; 525 : lpst->wHour, lpst->wMinute, lpst->wSecond ));
; 526 : DEBUGMSG(DEBUG_ALARM, (_T("OEMSetAlarmTime: gliLastCurTicks(0x%08X:0x%08X)\r\n"),
; 527 : gliLastCurTicks.HighPart, gliLastCurTicks.LowPart ));
; 528 :
; 529 : uliCurFTime.LowPart = gftLastFileTime.dwLowDateTime;
; 530 : uliCurFTime.HighPart = gftLastFileTime.dwHighDateTime;
; 531 :
; 532 : // Convert the SYSTEMTIME alarmTime to FILETIME
; 533 : KSystemTimeToFileTime( lpst, &ftAlarmTime );
00014 e59f3084 ldr r3, [pc, #0x84]
00018 e59f207c ldr r2, [pc, #0x7C]
0001c e1a00004 mov r0, r4
00020 e5933000 ldr r3, [r3]
00024 e5925000 ldr r5, [r2]
00028 e5924004 ldr r4, [r2, #4]
0002c e28d1000 add r1, sp, #0
00030 e1a0e00f mov lr, pc
00034 e12fff13 bx r3
; 534 : // now to ULARGE_INTEGER
; 535 : uliAlarmFTime.LowPart = ftAlarmTime.dwLowDateTime;
; 536 : uliAlarmFTime.HighPart = ftAlarmTime.dwHighDateTime;
00038 e59d0004 ldr r0, [sp, #4]
0003c e59d1000 ldr r1, [sp]
; 537 :
; 538 : DEBUGMSG(DEBUG_ALARM, (_T("OEMSetAlarmTime: uliCurFTime(0x%08X:0x%08X) uliAlarmFTime(0x%08X:0x%08X)\r\n"),
; 539 : uliCurFTime.HighPart, uliCurFTime.LowPart,
; 540 : uliAlarmFTime.HighPart, uliAlarmFTime.LowPart ));
; 541 :
; 542 : // Compare the current time with the alarm time
; 543 : // to make sure that the alarm is in the future.
; 544 : if (uliAlarmFTime.QuadPart > uliCurFTime.QuadPart)
00040 e1500004 cmp r0, r4
00044 3a00000e bcc |$L14379|
00048 8a000001 bhi |$L14467|
0004c e1510005 cmp r1, r5
00050 9a00000b bls |$L14379|
00054 |$L14467|
; 545 : {
; 546 : #if (1 == DEBUG_ALARM)
; 547 : unsigned __int64 ui64RealTime;
; 548 :
; 549 : // The alarm time is in the future, so
; 550 : // we now need to figure out the TICK count
; 551 : // to look for.
; 552 : // Find the difference in NANO chunks...
; 553 : uliAlarmFTime.QuadPart -= uliCurFTime.QuadPart;
; 554 : // now we need to convert NANO chunks to TICKS
; 555 : ui64RealTime = (unsigned __int64) uliAlarmFTime.HighPart << 32;
; 556 : ui64RealTime += uliAlarmFTime.LowPart;
; 557 : NANO_CHUNKS_TO_TICKS( ui64RealTime );
; 558 :
; 559 : // Add the current ticks back to get desired the alarm ticks...
; 560 : ui64RealTime += (unsigned __int64) gliLastCurTicks.QuadPart;
; 561 :
; 562 : // Save it back into uliAlarmFTime (now in TICKS)
; 563 : uliAlarmFTime.HighPart = (DWORD) (ui64RealTime >> 32);
; 564 : uliAlarmFTime.LowPart = (DWORD) ui64RealTime;
; 565 :
; 566 : DEBUGMSG(TRUE, (_T("OEMSetAlarmTime: uliAlarmFTime(0x%08X:0x%08X)\r\n"),
; 567 : uliAlarmFTime.HighPart, uliAlarmFTime.LowPart ));
; 568 : #endif // ( DEBUG_ALARM )
; 569 :
; 570 : gliRTCAlarmTicks.QuadPart = uliAlarmFTime.QuadPart;
00054 e59f303c ldr r3, [pc, #0x3C]
; 571 :
; 572 : #if (1 == DEBUG_ALARM )
; 573 : // Test the alarm date & time to see if it is close to what
; 574 : // was wanted...
; 575 : {
; 576 : LARGE_INTEGER tmpCurTicks = gliRTCAlarmTicks;
; 577 : LARGE_INTEGER liTimeDelta;
; 578 : FILETIME ftDelta;
; 579 : FILETIME ftCurFTime;
; 580 : SYSTEMTIME stTime;
; 581 : unsigned __int64 ui64Delta;
; 582 :
; 583 : // Calculate the current diference
; 584 : //
; 585 : liTimeDelta.QuadPart =
; 586 : tmpCurTicks.QuadPart - gliLastCurTicks.QuadPart;
; 587 :
; 588 : ui64Delta = (unsigned __int64) liTimeDelta.QuadPart;
; 589 : TICKS_TO_NANO_CHUNKS( ui64Delta ); // convert to nano chunks
; 590 :
; 591 : // setup to add in the nano chunk time difference
; 592 : ftDelta.dwLowDateTime = (DWORD) ui64Delta;
; 593 : ftDelta.dwHighDateTime = (DWORD) (ui64Delta >> 32);
; 594 :
; 595 : // Add the delta to the last known time...
; 596 : //
; 597 : add64_64_64( &gftLastFileTime , &ftDelta, &ftCurFTime );
; 598 :
; 599 : // convert the answer to a system time format
; 600 : //
; 601 : KFileTimeToSystemTime( &ftCurFTime, &stTime );
; 602 :
; 603 : DEBUGMSG( DEBUG_ALARM, (_T("OEMSetAlarmTime: Converted alarmTime: ST(%02d/%02d/%04d %02d:%02d:%02d)\r\n"),
; 604 : stTime.wMonth, stTime.wDay, stTime.wYear,
; 605 : stTime.wHour, stTime.wMinute, stTime.wSecond ) );
; 606 : // Write out to the debug serial port that we
; 607 : // are enabling the alarm...
; 608 : //OEMWriteDebugByte('S');
; 609 : }
; 610 : #endif // ( DEBUG_ALARM )
; 611 :
; 612 : gfRTCAlarm = TRUE;
00058 e59f2034 ldr r2, [pc, #0x34]
0005c e3a0e001 mov lr, #1
00060 e5831000 str r1, [r3]
00064 e5830004 str r0, [r3, #4]
00068 e582e000 str lr, [r2]
; 613 :
; 614 : // clear interrupts, write the comparator, and enable interrupts
; 615 : OEMInterruptEnable( SYSINTR_RTC_ALARM, NULL, 0 );
0006c e3a02000 mov r2, #0
00070 e3a01000 mov r1, #0
00074 e3a0000d mov r0, #0xD
00078 eb000000 bl OEMInterruptEnable
; 616 : bResult = TRUE;
0007c e3a00001 mov r0, #1
; 617 : }
; 618 : else
00080 ea000000 b |$L14381|
00084 |$L14379|
; 619 : {
; 620 : DEBUGMSG( TRUE,
; 621 : (_T("OEMSetAlarmTime: alarm occurs before current time!\r\n") ) );
; 622 : bResult = FALSE;
00084 e3a00000 mov r0, #0
00088 |$L14381|
; 623 : }
; 624 : return( bResult );
; 625 : }
00088 e28dd018 add sp, sp, #0x18
0008c e8bd4030 ldmia sp!, {r4, r5, lr}
00090 e12fff1e bx lr
00094 |$L14481|
00094 00000000 DCD |gfRTCAlarm|
00098 00000000 DCD |gliRTCAlarmTicks|
0009c 00000000 DCD |gftLastFileTime|
000a0 00000000 DCD |KSystemTimeToFileTime|
000a4 |$M14477|
ENDP ; |OEMSetAlarmTime|
END
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -