From 2ee7030776461ee835dbbd44149f90ae79e7d4c5 Mon Sep 17 00:00:00 2001 From: red031000 Date: Sun, 3 May 2020 01:42:55 +0100 Subject: temp OS_entropy --- arm9/lib/src/OS_entropy.c | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 arm9/lib/src/OS_entropy.c (limited to 'arm9/lib/src/OS_entropy.c') diff --git a/arm9/lib/src/OS_entropy.c b/arm9/lib/src/OS_entropy.c new file mode 100644 index 00000000..bfc95882 --- /dev/null +++ b/arm9/lib/src/OS_entropy.c @@ -0,0 +1,28 @@ +// +// Created by red031000 on 2020-05-03. +// + +#include "function_target.h" +#include "consts.h" +#include "OS_entropy.h" + +u32 * const HW_REG_006 = (u32 *) 0x04000006; +u32 * const HW_REG_130 = (u32 *) 0x04000130; +u32 * const HW_REG_600 = (u32 *) 0x04000600; + +u32 * const OSi_TickCounter = (u32 *) 0x021D37B4; + +ARM_FUNC void OS_GetLowEntropyData(u32 * arr) +{ + OSSystemWork* work = OS_GetSystemWork(); + u16 x = *((u16 *)HW_REG_006); + u8 * nvramUserInfo = work->nvramUserInfo; + u8 r5 = nvramUserInfo[0x74]; + arr[0] = (OS_GetTickLo()<<0x10) | x ; + arr[1] = (OSi_TickCounter[0]<<0x10) ^ r5[2]; + u32 what = OSi_TickCounter[0]; + what = OSi_TickCounter[1]; + arr[2] = *((u32 *)r4) ^ what ^ *(u32 *)((u8 *)work+0x3c); + arr[2] ^= *HW_REG_600; + // ... +} \ No newline at end of file -- cgit v1.2.3 From 4f6c75ac8381a7a3c2902c97870066ee90f1d320 Mon Sep 17 00:00:00 2001 From: red031000 Date: Sun, 3 May 2020 19:22:26 +0100 Subject: match OS_GetLowEntropyData --- arm9/lib/src/OS_entropy.c | 30 ++++++++++++------------------ 1 file changed, 12 insertions(+), 18 deletions(-) (limited to 'arm9/lib/src/OS_entropy.c') diff --git a/arm9/lib/src/OS_entropy.c b/arm9/lib/src/OS_entropy.c index bfc95882..b33781cc 100644 --- a/arm9/lib/src/OS_entropy.c +++ b/arm9/lib/src/OS_entropy.c @@ -6,23 +6,17 @@ #include "consts.h" #include "OS_entropy.h" -u32 * const HW_REG_006 = (u32 *) 0x04000006; -u32 * const HW_REG_130 = (u32 *) 0x04000130; -u32 * const HW_REG_600 = (u32 *) 0x04000600; - -u32 * const OSi_TickCounter = (u32 *) 0x021D37B4; - ARM_FUNC void OS_GetLowEntropyData(u32 * arr) { - OSSystemWork* work = OS_GetSystemWork(); - u16 x = *((u16 *)HW_REG_006); - u8 * nvramUserInfo = work->nvramUserInfo; - u8 r5 = nvramUserInfo[0x74]; - arr[0] = (OS_GetTickLo()<<0x10) | x ; - arr[1] = (OSi_TickCounter[0]<<0x10) ^ r5[2]; - u32 what = OSi_TickCounter[0]; - what = OSi_TickCounter[1]; - arr[2] = *((u32 *)r4) ^ what ^ *(u32 *)((u8 *)work+0x3c); - arr[2] ^= *HW_REG_600; - // ... -} \ No newline at end of file + const OSSystemWork* work = OS_GetSystemWork(); + const u8 * macAddress = (u8 *)((u32)(work->nvramUserInfo) + ((sizeof(NVRAMConfig) + 3) & ~3)); + arr[0] = (u32)((GX_GetVCount() << 16) | OS_GetTickLo()); + arr[1] = (u32)(*(u16 *)(macAddress + 4) << 16) ^ (u32)(OSi_TickCounter); + arr[2] = (u32)(OSi_TickCounter >> 32) ^ *(u32 *)macAddress ^ work->vblankCount; + arr[2] ^= reg_G3X_GXSTAT; + arr[3] = *(u32 *)(&work->real_time_clock[0]); + arr[4] = *(u32 *)(&work->real_time_clock[4]); + arr[5] = (((u32)work->mic_sampling_data) << 16) ^ work->mic_last_address; + arr[6] = (u32) ((*(u16 *)(&work->touch_panel[0]) << 16) | *(u16 *)(&work->touch_panel[2])); + arr[7] = (u32)((work->wm_rssi_pool << 16) | (reg_PAD_KEYINPUT | *(vu16 *)HW_BUTTON_XY_BUF)); +} -- cgit v1.2.3