OSTime 100%

This commit is contained in:
shibbo 2023-02-18 17:55:42 -05:00
parent f4b934ad47
commit 060c8631d4
9 changed files with 179 additions and 28 deletions

View File

@ -209,12 +209,12 @@ OSSetThreadPriority,OSThread.o,os.a,false
OSGetThreadPriority,OSThread.o,os.a,false
SleepAlarmHandler,OSThread.o,os.a,false
OSSleepTicks,OSThread.o,os.a,false
OSGetTime,OSTime.o,os.a,false
OSGetTick,OSTime.o,os.a,false
__OSGetSystemTime,OSTime.o,os.a,false
__OSTimeToSystemTime,OSTime.o,os.a,false
GetDates,OSTime.o,os.a,false
OSTicksToCalendarTime,OSTime.o,os.a,false
OSGetTime,OSTime.o,os.a,true
OSGetTick,OSTime.o,os.a,true
__OSGetSystemTime,OSTime.o,os.a,true
__OSTimeToSystemTime,OSTime.o,os.a,true
GetDates,OSTime.o,os.a,true
OSTicksToCalendarTime,OSTime.o,os.a,true
OSUTF8to32,OSUtf.o,os.a,false
OSUTF16to32,OSUtf.o,os.a,false
OSUTF32toANSI,OSUtf.o,os.a,false

1 Symbol Name Object File Library Archive Matching
209 OSGetThreadPriority OSThread.o os.a false
210 SleepAlarmHandler OSThread.o os.a false
211 OSSleepTicks OSThread.o os.a false
212 OSGetTime OSTime.o os.a false true
213 OSGetTick OSTime.o os.a false true
214 __OSGetSystemTime OSTime.o os.a false true
215 __OSTimeToSystemTime OSTime.o os.a false true
216 GetDates OSTime.o os.a false true
217 OSTicksToCalendarTime OSTime.o os.a false true
218 OSUTF8to32 OSUtf.o os.a false
219 OSUTF16to32 OSUtf.o os.a false
220 OSUTF32toANSI OSUtf.o os.a false

View File

@ -1,6 +1,6 @@
{
"schemaVersion": 1,
"label": "SDK",
"message": "1.5983841607859761%",
"message": "1.791636535920006%",
"color": "blue"
}

View File

@ -5,7 +5,7 @@
| [arc](https://github.com/shibbo/Petari/tree/master/libs/RVL_SDK/docs/lib/arc.md) | 0.0% |
| [ax](https://github.com/shibbo/Petari/tree/master/libs/RVL_SDK/docs/lib/ax.md) | 0.0% |
| [axfx](https://github.com/shibbo/Petari/tree/master/libs/RVL_SDK/docs/lib/axfx.md) | 0.0% |
| [base](https://github.com/shibbo/Petari/tree/master/libs/RVL_SDK/docs/lib/base.md) | 0.0% |
| [base](https://github.com/shibbo/Petari/tree/master/libs/RVL_SDK/docs/lib/base.md) | 44.565217391304344% |
| [bte](https://github.com/shibbo/Petari/tree/master/libs/RVL_SDK/docs/lib/bte.md) | 0.0% |
| [db](https://github.com/shibbo/Petari/tree/master/libs/RVL_SDK/docs/lib/db.md) | 100.0% |
| [dsp](https://github.com/shibbo/Petari/tree/master/libs/RVL_SDK/docs/lib/dsp.md) | 100.0% |
@ -13,7 +13,7 @@
| [esp](https://github.com/shibbo/Petari/tree/master/libs/RVL_SDK/docs/lib/esp.md) | 17.078651685393258% |
| [euart](https://github.com/shibbo/Petari/tree/master/libs/RVL_SDK/docs/lib/euart.md) | 0.0% |
| [exi](https://github.com/shibbo/Petari/tree/master/libs/RVL_SDK/docs/lib/exi.md) | 3.303143313798615% |
| [fs](https://github.com/shibbo/Petari/tree/master/libs/RVL_SDK/docs/lib/fs.md) | 0.0% |
| [fs](https://github.com/shibbo/Petari/tree/master/libs/RVL_SDK/docs/lib/fs.md) | 0.5486968449931412% |
| [gd](https://github.com/shibbo/Petari/tree/master/libs/RVL_SDK/docs/lib/gd.md) | 0.0% |
| [gx](https://github.com/shibbo/Petari/tree/master/libs/RVL_SDK/docs/lib/gx.md) | 3.3725976441413517% |
| [ipc](https://github.com/shibbo/Petari/tree/master/libs/RVL_SDK/docs/lib/ipc.md) | 13.484205563413484% |
@ -21,7 +21,7 @@
| [mtx](https://github.com/shibbo/Petari/tree/master/libs/RVL_SDK/docs/lib/mtx.md) | 0.0% |
| [nand](https://github.com/shibbo/Petari/tree/master/libs/RVL_SDK/docs/lib/nand.md) | 0.0% |
| [net](https://github.com/shibbo/Petari/tree/master/libs/RVL_SDK/docs/lib/net.md) | 0.0% |
| [os](https://github.com/shibbo/Petari/tree/master/libs/RVL_SDK/docs/lib/os.md) | 6.461731493099123% |
| [os](https://github.com/shibbo/Petari/tree/master/libs/RVL_SDK/docs/lib/os.md) | 8.281053952321205% |
| [pad](https://github.com/shibbo/Petari/tree/master/libs/RVL_SDK/docs/lib/pad.md) | 0.0% |
| [rso](https://github.com/shibbo/Petari/tree/master/libs/RVL_SDK/docs/lib/rso.md) | 0.0% |
| [sc](https://github.com/shibbo/Petari/tree/master/libs/RVL_SDK/docs/lib/sc.md) | 0.0% |

View File

@ -8,7 +8,7 @@
| Object | Percentage (of Bytes) | Functions Done / Total Functions | Percentage (Functions) | Status
| ------------- | ------------- | ------------- | ------------- | -------------
| PPCArch.o | 0.0% | 0 / 24 | 0.0% | :x:
| PPCArch.o | 44.565217391304344% | 7 / 24 | 29.166666666666668% | :eight_pointed_black_star:
# PPCArch.o
@ -31,12 +31,12 @@
| PPCMtpmc4 | :x: |
| PPCMffpscr | :x: |
| PPCMtfpscr | :x: |
| PPCMfhid2 | :x: |
| PPCMthid2 | :x: |
| PPCMfwpar | :x: |
| PPCMtwpar | :x: |
| PPCDisableSpeculation | :x: |
| PPCSetFpNonIEEEMode | :x: |
| PPCMthid4 | :x: |
| PPCMfhid2 | :white_check_mark: |
| PPCMthid2 | :white_check_mark: |
| PPCMfwpar | :white_check_mark: |
| PPCMtwpar | :white_check_mark: |
| PPCDisableSpeculation | :white_check_mark: |
| PPCSetFpNonIEEEMode | :white_check_mark: |
| PPCMthid4 | :white_check_mark: |

View File

@ -8,7 +8,7 @@
| Object | Percentage (of Bytes) | Functions Done / Total Functions | Percentage (Functions) | Status
| ------------- | ------------- | ------------- | ------------- | -------------
| fs.o | 0.0% | 0 / 28 | 0.0% | :x:
| fs.o | 0.5486968449931412% | 1 / 28 | 3.571428571428571% | :eight_pointed_black_star:
# fs.o
@ -35,7 +35,7 @@
| ISFS_GetFileStatsAsync | :x: |
| ISFS_Seek | :x: |
| ISFS_SeekAsync | :x: |
| ISFS_Read | :x: |
| ISFS_Read | :white_check_mark: |
| ISFS_ReadAsync | :x: |
| ISFS_Write | :x: |
| ISFS_WriteAsync | :x: |

View File

@ -29,7 +29,7 @@
| OSRtc.o | 0.0% | 0 / 9 | 0.0% | :x:
| OSSync.o | 0.0% | 0 / 2 | 0.0% | :x:
| OSThread.o | 2.0053475935828877% | 2 / 28 | 7.142857142857142% | :eight_pointed_black_star:
| OSTime.o | 0.0% | 0 / 6 | 0.0% | :x:
| OSTime.o | 100.0% | 6 / 6 | 100.0% | :white_check_mark:
| OSUtf.o | 0.0% | 0 / 4 | 0.0% | :x:
| OSIpc.o | 100.0% | 3 / 3 | 100.0% | :white_check_mark:
| OSStateTM.o | 11.627906976744185% | 3 / 12 | 25.0% | :eight_pointed_black_star:
@ -360,12 +360,12 @@
# OSTime.o
| Symbol | Decompiled? |
| ------------- | ------------- |
| OSGetTime | :x: |
| OSGetTick | :x: |
| __OSGetSystemTime | :x: |
| __OSTimeToSystemTime | :x: |
| GetDates | :x: |
| OSTicksToCalendarTime | :x: |
| OSGetTime | :white_check_mark: |
| OSGetTick | :white_check_mark: |
| __OSGetSystemTime | :white_check_mark: |
| __OSTimeToSystemTime | :white_check_mark: |
| GetDates | :white_check_mark: |
| OSTicksToCalendarTime | :white_check_mark: |
# OSUtf.o

View File

@ -24,7 +24,12 @@ u32 __OSBusClock : (0x8000 << 16 | 0x00F8);
#define OS_TIMER_CLOCK (OS_BUS_CLOCK/4)
#endif
#define OSNanosecondsToTicks( nsec ) (((nsec) * (OS_TIMER_CLOCK / 125000)) / 8000)
#define OSNanosecondsToTicks(nsec) (((nsec) * (OS_TIMER_CLOCK / 125000)) / 8000)
#define OSTicksToSeconds(ticks) ((ticks) / OS_TIMER_CLOCK)
#define OSTicksToMilliseconds(ticks) ((ticks) / (OS_TIMER_CLOCK / 1000))
#define OSTicksToMicroseconds(ticks) (((ticks) * 8) / (OS_TIMER_CLOCK / 125000))
#define OSSecondsToTicks(sec) ((sec) * OS_TIMER_CLOCK)
void* OSPhysicalToUncached(u32);
u32 OSCachedToPhysical(const void* caddr);

View File

@ -0,0 +1,36 @@
#ifndef OSTIME_H
#define OSTIME_H
#include <revolution.h>
#ifdef __cplusplus
extern "C" {
#endif
typedef u32 OSTick;
typedef s64 OSTime;
typedef struct OSCalendarTime {
int sec;
int min;
int hour;
int mday;
int mon;
int year;
int wday;
int yday;
int msec;
int usec;
} OSCalendarTime;
OSTime OSGetTime(void);
OSTick OSGetTick(void);
OSTime __OSGetSystemTime(void);
OSTime __OSTimeToSystemTime(OSTime);
void OSTicksToCalendarTime(OSTime, OSCalendarTime *);
#ifdef __cplusplus
}
#endif
#endif // OSTIME_H

View File

@ -0,0 +1,110 @@
#include <revolution/os/OSTime.h>
static int YearDays[] = { 0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334 };
static int LeapYearDays[] = { 0, 31, 60, 91, 121, 152, 182, 213, 244, 274, 305, 335 };
asm OSTime OSGetTime(void) {
nofralloc
loop:
mftbu r3
mftb r4
mftbu r5
cmpw r3, r5
bne loop
blr
}
asm OSTick OSGetTick(void) {
nofralloc
mftb r3
blr
}
OSTime __OSGetSystemTime(void) {
BOOL en;
OSTime* time = (OSTime*)(0x800030D8);
OSTime res;
en = OSDisableInterrupts();
res = *time + OSGetTime();
OSRestoreInterrupts(en);
return res;
}
OSTime __OSTimeToSystemTime(OSTime time) {
BOOL en;
OSTime* os_time = (OSTime*)(0x800030D8);
OSTime res;
en = OSDisableInterrupts();
res = *os_time + time;
OSRestoreInterrupts(en);
return res;
}
static BOOL IsLeapYear(int year) {
return (year % 4 == 0 && year % 100 != 0) || year % 400 == 0;
}
static int GetLeapDays(int year) {
if (year < 1) {
return 0;
}
return (year + 3) / 4 - (year - 1) / 100 + (year - 1) / 400;
}
static void GetDates(s32 days, OSCalendarTime *pTime);
void OSTicksToCalendarTime(OSTime ticks, OSCalendarTime *pTime) {
int numDays;
int numSecs;
OSTime ticksAfter;
ticksAfter = ticks % OSSecondsToTicks(1);
if (ticksAfter < 0) {
ticksAfter += OSSecondsToTicks(1);
}
pTime->usec = (int)(OSTicksToMicroseconds(ticksAfter) % 1000);
pTime->msec = (int)(OSTicksToMilliseconds(ticksAfter) % 1000);
ticks -= ticksAfter;
numDays = (int)(OSTicksToSeconds(ticks) / 86400 + 0xB2575);
numSecs = (int)(OSTicksToSeconds(ticks) % 86400);
if (numSecs < 0) {
numDays -= 1;
numSecs += 86400;
}
GetDates(numDays, pTime);
pTime->hour = numSecs / 60 / 60;
pTime->min = (numSecs / 60) % 60;
pTime->sec = numSecs % 60;
}
static void GetDates(s32 days, OSCalendarTime *pTime) {
int year;
int dayCount;
int month;
int* monthArr;
pTime->wday = (days + 6) % 7;
for (year = days / 365; days < (dayCount = GetLeapDays(year) + 365 * year); --year);
days -= dayCount;
pTime->year = year;
pTime->yday = days;
monthArr = IsLeapYear(year) ? LeapYearDays : YearDays;
for (month = 12; days < monthArr[--month];);
pTime->mon = month;
pTime->mday = days - monthArr[month] + 1;
}