summaryrefslogtreecommitdiff
path: root/arm9/lib/NitroSDK/src/OS_entropy.c
diff options
context:
space:
mode:
authorred031000 <rubenru09@aol.com>2021-07-23 01:11:15 +0100
committerred031000 <rubenru09@aol.com>2021-07-23 01:12:27 +0100
commit5bf13c7f48fe91c7902ce50250bc1a5a2398a2ae (patch)
tree2e91e60bdb7a9174b16d8ca1b532809d4ae2e5b6 /arm9/lib/NitroSDK/src/OS_entropy.c
parentc2d91a2d997afd01fa4f40e1e16d5ee85557c9a8 (diff)
separate out libs to libc, libnns and NitroSDK
Diffstat (limited to 'arm9/lib/NitroSDK/src/OS_entropy.c')
-rw-r--r--arm9/lib/NitroSDK/src/OS_entropy.c25
1 files changed, 25 insertions, 0 deletions
diff --git a/arm9/lib/NitroSDK/src/OS_entropy.c b/arm9/lib/NitroSDK/src/OS_entropy.c
new file mode 100644
index 00000000..5d466f82
--- /dev/null
+++ b/arm9/lib/NitroSDK/src/OS_entropy.c
@@ -0,0 +1,25 @@
+//
+// Created by red031000 on 2020-05-03.
+//
+
+#include "OS_entropy.h"
+
+#include "global.h"
+#include "registers.h"
+#include "systemWork.h"
+#include "userInfo.h"
+
+ARM_FUNC void OS_GetLowEntropyData(u32 * arr)
+{
+ 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));
+}