diff options
| author | Anghelo Carvajal <angheloalf95@gmail.com> | 2023-03-28 23:42:56 -0300 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-03-29 03:42:56 +0100 |
| commit | d66a21685f45d130f980e8a5ec7b08cfe189e40b (patch) | |
| tree | f11b3b09dc5772e419fe08d3d0ead4e778def57f /lib/ultralib/src/debug | |
| parent | 6a5e64cc4c26398cc607bb02cdc12a056ddf42d1 (diff) | |
Initial repo setup (#1)
* git subrepo clone git@github.com:ethteck/splat.git tools/splat
subrepo:
subdir: "tools/splat"
merged: "4fec014"
upstream:
origin: "git@github.com:ethteck/splat.git"
branch: "master"
commit: "4fec014"
git-subrepo:
version: "0.4.3"
origin: "https://github.com/ingydotnet/git-subrepo.git"
commit: "2f68596"
* gitignore
* decompress_baserom.py
* Initial yaml
* run flib
* more yaml stuff
* Builds an uncompressed ROM
* setup ido download
* git subrepo clone git@github.com:simonlindholm/asm-differ.git tools/asm-differ
subrepo:
subdir: "tools/asm-differ"
merged: "ae40866"
upstream:
origin: "git@github.com:simonlindholm/asm-differ.git"
branch: "main"
commit: "ae40866"
git-subrepo:
version: "0.4.3"
origin: "https://github.com/ingydotnet/git-subrepo.git"
commit: "2f68596"
* git subrepo clone git@github.com:simonlindholm/asm-processor.git tools/asm-processor
subrepo:
subdir: "tools/asm-processor"
merged: "bbd86ea"
upstream:
origin: "git@github.com:simonlindholm/asm-processor.git"
branch: "main"
commit: "bbd86ea"
git-subrepo:
version: "0.4.3"
origin: "https://github.com/ingydotnet/git-subrepo.git"
commit: "2f68596"
* git subrepo clone (merge) git@github.com:EllipticEllipsis/fado.git tools/fado
subrepo:
subdir: "tools/fado"
merged: "8d896ee"
upstream:
origin: "git@github.com:EllipticEllipsis/fado.git"
branch: "master"
commit: "8d896ee"
git-subrepo:
version: "0.4.3"
origin: "https://github.com/ingydotnet/git-subrepo.git"
commit: "2f68596"
* setup ido in makefile
* data and rodata
* add automatic file splits
* bootstrap most symbol_addrs
* git subrepo clone --branch=irix git@github.com:hensldm/ultralib.git lib/ultralib
subrepo:
subdir: "lib/ultralib"
merged: "0d1e095"
upstream:
origin: "git@github.com:hensldm/ultralib.git"
branch: "irix"
commit: "0d1e095"
git-subrepo:
version: "0.4.3"
origin: "https://github.com/ingydotnet/git-subrepo.git"
commit: "2f68596"
* setup ido building
* various tooling
* git subrepo pull tools/asm-differ
subrepo:
subdir: "tools/asm-differ"
merged: "857b398"
upstream:
origin: "git@github.com:simonlindholm/asm-differ.git"
branch: "main"
commit: "857b398"
git-subrepo:
version: "0.4.3"
origin: "https://github.com/ingydotnet/git-subrepo.git"
commit: "2f68596"
* Change defines to match IDO
* review
* newlin
* update gitignore
* Windows error
* D_01000000
* yeet settings.json
* yeet
* git subrepo clone git@github.com:decompals/ultralib.git lib/ultralib
subrepo:
subdir: "lib/ultralib"
merged: "d03b2a3"
upstream:
origin: "git@github.com:decompals/ultralib.git"
branch: "main"
commit: "d03b2a3"
git-subrepo:
version: "0.4.3"
origin: "https://github.com/ingydotnet/git-subrepo.git"
commit: "2f68596"
* clangformat and clangtidy
* Setup a bunch of headers
* bootstrap boot and code functions and variables headers
* global.h
* update format.py includes
* -D_MIPS_SZLONG=32
* format.py: --verbose
* Update tools/decompress_baserom.py
Co-authored-by: Derek Hensley <hensley.derek58@gmail.com>
* Add libc to global.h
* review
* yeet saved_regs
* yeet headers
* yeet _MSC_VER
* more header cleanup
* add readme licensing note
---------
Co-authored-by: Derek Hensley <hensley.derek58@gmail.com>
Diffstat (limited to 'lib/ultralib/src/debug')
| -rw-r--r-- | lib/ultralib/src/debug/osint_debug.h | 11 | ||||
| -rw-r--r-- | lib/ultralib/src/debug/threadprofile.c | 22 | ||||
| -rw-r--r-- | lib/ultralib/src/debug/threadprofileclear.c | 11 | ||||
| -rw-r--r-- | lib/ultralib/src/debug/threadprofileinit.c | 16 | ||||
| -rw-r--r-- | lib/ultralib/src/debug/threadprofilereadcount.c | 31 | ||||
| -rw-r--r-- | lib/ultralib/src/debug/threadprofilereadtime.c | 43 | ||||
| -rw-r--r-- | lib/ultralib/src/debug/threadprofilestart.c | 20 | ||||
| -rw-r--r-- | lib/ultralib/src/debug/threadprofilestop.c | 34 |
8 files changed, 188 insertions, 0 deletions
diff --git a/lib/ultralib/src/debug/osint_debug.h b/lib/ultralib/src/debug/osint_debug.h new file mode 100644 index 0000000..b493035 --- /dev/null +++ b/lib/ultralib/src/debug/osint_debug.h @@ -0,0 +1,11 @@ +#include "PR/os_internal.h" + +extern s32 __osThprofFlag; +extern void (*__osThprofFunc)(OSThread*); +extern u32 __osThprofLastTimer; +extern u32 __osThprofCount; +extern __OSThreadprofile_s thprof[THPROF_IDMAX]; +extern u64 __osThprofHeap[THPROF_STACKSIZE]; +extern void* __osThprofStack; + +void osThreadProfileCallback(OSThread*); diff --git a/lib/ultralib/src/debug/threadprofile.c b/lib/ultralib/src/debug/threadprofile.c new file mode 100644 index 0000000..e383773 --- /dev/null +++ b/lib/ultralib/src/debug/threadprofile.c @@ -0,0 +1,22 @@ +#include "osint_debug.h" + +#include "macros.h" + +s32 __osThprofFlag = 0; +void (*__osThprofFunc)(OSThread*) = NULL; + +u32 __osThprofLastTimer; +u32 __osThprofCount; +__OSThreadprofile_s thprof[THPROF_IDMAX] ALIGNED(0x10); +u64 __osThprofHeap[THPROF_STACKSIZE] ALIGNED(0x10); +void* __osThprofStack; + +void osThreadProfileCallback(OSThread* osthread) { + register u32 now_time = osGetCount(); + __OSThreadprofile_s* thprof = osthread->thprof; + + thprof->time += now_time - __osThprofLastTimer; + thprof->count++; + __osThprofCount++; + __osThprofLastTimer = now_time; +} diff --git a/lib/ultralib/src/debug/threadprofileclear.c b/lib/ultralib/src/debug/threadprofileclear.c new file mode 100644 index 0000000..42788f8 --- /dev/null +++ b/lib/ultralib/src/debug/threadprofileclear.c @@ -0,0 +1,11 @@ +#include "osint_debug.h" + +void osThreadProfileClear(OSId id) { + register OSIntMask saveMask = __osDisableInt(); + + thprof[id].flag = 0; + thprof[id].count = 0; + thprof[id].time = 0; + + __osRestoreInt(saveMask); +} diff --git a/lib/ultralib/src/debug/threadprofileinit.c b/lib/ultralib/src/debug/threadprofileinit.c new file mode 100644 index 0000000..7fef229 --- /dev/null +++ b/lib/ultralib/src/debug/threadprofileinit.c @@ -0,0 +1,16 @@ +#include "osint_debug.h" + +void osThreadProfileInit(void) { + register u32 saveMask = __osDisableInt(); + OSId i; + + __osThprofFunc = NULL; + __osThprofFlag = 1; + __osThprofCount = 0; + __osThprofStack = &__osThprofHeap[(THPROF_STACKSIZE - 8) / sizeof(*__osThprofHeap)]; + __osRestoreInt(saveMask); + + for (i = 0; i < THPROF_IDMAX; i++) { + osThreadProfileClear(i); + } +} diff --git a/lib/ultralib/src/debug/threadprofilereadcount.c b/lib/ultralib/src/debug/threadprofilereadcount.c new file mode 100644 index 0000000..c12d313 --- /dev/null +++ b/lib/ultralib/src/debug/threadprofilereadcount.c @@ -0,0 +1,31 @@ +#include "osint_debug.h" + +u32 osThreadProfileReadCount(OSId id) { + if (!__osThprofFlag) { + __osError(139, 0); + return 0; + } + + if (id >= THPROF_IDMAX) { + __osError(143, 1, id); + return 0; + } + return thprof[id].count; +} + +u32 osThreadProfileReadCountTh(OSThread* thread) { + OSId id; + + if (!__osThprofFlag) { + __osError(141, 0); + return 0; + } + + id = osGetThreadId(thread); + + if (id >= THPROF_IDMAX) { + __osError(145, 1, id); + return 0; + } + return thprof[id].count; +} diff --git a/lib/ultralib/src/debug/threadprofilereadtime.c b/lib/ultralib/src/debug/threadprofilereadtime.c new file mode 100644 index 0000000..c5c4cca --- /dev/null +++ b/lib/ultralib/src/debug/threadprofilereadtime.c @@ -0,0 +1,43 @@ +#include "osint_debug.h" + +OSTime osThreadProfileReadTime(OSId id) { + OSTime adjust = 0; + u32 now_time = osGetCount(); + + if (!__osThprofFlag) { + __osError(140, 0); + return 0; + } + if (id >= THPROF_IDMAX) { + __osError(144, 1, id); + return 0; + } + + if (id == osGetThreadId(NULL) && __osThprofFunc != NULL) { + adjust = now_time - __osThprofLastTimer; + } + return thprof[id].time + adjust; +} + +OSTime osThreadProfileReadTimeTh(OSThread* thread) { + OSId id; + OSTime adjust = 0; + u32 now_time = osGetCount(); + + if (!__osThprofFlag) { + __osError(142, 0); + return 0; + } + + id = osGetThreadId(thread); + + if (id >= THPROF_IDMAX) { + __osError(146, 1, id); + return 0; + } + + if (id == osGetThreadId(NULL) && __osThprofFunc != NULL) { + adjust = now_time - __osThprofLastTimer; + } + return thprof[id].time + adjust; +} diff --git a/lib/ultralib/src/debug/threadprofilestart.c b/lib/ultralib/src/debug/threadprofilestart.c new file mode 100644 index 0000000..0891ad7 --- /dev/null +++ b/lib/ultralib/src/debug/threadprofilestart.c @@ -0,0 +1,20 @@ +#include "osint_debug.h" + +void osThreadProfileStart(void) { + register u32 saveMask; + + if (!__osThprofFlag) { + __osError(136, 0); + return; + } + if (__osThprofFunc != NULL) { + __osError(137, 0); + return; + } + + saveMask = __osDisableInt(); + + __osThprofLastTimer = osGetCount(); + __osThprofFunc = osThreadProfileCallback; + __osRestoreInt(saveMask); +} diff --git a/lib/ultralib/src/debug/threadprofilestop.c b/lib/ultralib/src/debug/threadprofilestop.c new file mode 100644 index 0000000..666d7cd --- /dev/null +++ b/lib/ultralib/src/debug/threadprofilestop.c @@ -0,0 +1,34 @@ +#include "osint_debug.h" + +void osThreadProfileStop(void) { + register u32 saveMask; + int i; + OSId id; + u32 now_time = osGetCount(); + + saveMask = __osDisableInt(); + + if (__osThprofFlag == 0) { + __osRestoreInt(saveMask); + __osError(138, 0); + return; + } + + if (__osThprofFunc != NULL) { + id = osGetThreadId(0); + + if (id < THPROF_IDMAX) { + thprof[id].time += now_time - __osThprofLastTimer; + } else { + __osRestoreInt(saveMask); + __osError(147, 1, id); + saveMask = __osDisableInt(); + } + } + __osThprofFunc = NULL; + + for (i = 0; i < THPROF_IDMAX; i++) { + thprof[i].flag = 0; + } + __osRestoreInt(saveMask); +} |
