summaryrefslogtreecommitdiff
path: root/include/nitro
diff options
context:
space:
mode:
authorEgor Ananyin <ananinegor@gmail.com>2020-06-20 09:18:43 +0300
committerEgor Ananyin <ananinegor@gmail.com>2020-06-20 09:18:43 +0300
commitabd2d1e16494867989e710e5235c6425fa4e8c34 (patch)
tree7eff3e1db566801104a8fc2672bbe57e06f7009e /include/nitro
parent70556fc300ba85dad248d20b3c79c415e2ef88e5 (diff)
parent12c17948602bf14535c91c530f214b99863e038e (diff)
conflicts
Diffstat (limited to 'include/nitro')
-rw-r--r--include/nitro/MI_dma_shared.h (renamed from include/nitro/dma.h)16
-rw-r--r--include/nitro/OS_alarm_shared.h35
-rw-r--r--include/nitro/OS_interrupt_shared.h9
-rw-r--r--include/nitro/OS_mutex_shared.h20
-rw-r--r--include/nitro/OS_spinLock_shared.h24
-rw-r--r--include/nitro/OS_systemWork_shared.h66
-rw-r--r--include/nitro/OS_thread_shared.h43
-rw-r--r--include/nitro/OS_tick_shared.h24
-rw-r--r--include/nitro/consts_shared.h9
-rw-r--r--include/nitro/mmap_shared.h5
-rw-r--r--include/nitro/registers_shared.h17
11 files changed, 258 insertions, 10 deletions
diff --git a/include/nitro/dma.h b/include/nitro/MI_dma_shared.h
index 32944cb3..e839417a 100644
--- a/include/nitro/dma.h
+++ b/include/nitro/MI_dma_shared.h
@@ -1,5 +1,17 @@
-#ifndef GUARD_DMA_H
-#define GUARD_DMA_H
+/*
+ * NOTE:
+ * This file is shared between ARM9 and ARM7
+ * DO NOT PUT PROC SPECIFIC CODE IN HERE
+ * Thank You!
+ */
+
+/*
+ * DO NOT INCLUDE THIS FILE DIRECTLY
+ * Include MI_dma.h from the specific proc's lib
+ */
+
+#ifndef GUARD_DMA_SHARED_H
+#define GUARD_DMA_SHARED_H
#define REG_ADDR_DMA0SAD 0x040000b0
diff --git a/include/nitro/OS_alarm_shared.h b/include/nitro/OS_alarm_shared.h
new file mode 100644
index 00000000..fe549351
--- /dev/null
+++ b/include/nitro/OS_alarm_shared.h
@@ -0,0 +1,35 @@
+/*
+ * NOTE:
+ * This file is shared between ARM9 and ARM7
+ * DO NOT PUT PROC SPECIFIC CODE IN HERE
+ * Thank You!
+ */
+
+/*
+ * DO NOT INCLUDE THIS FILE DIRECTLY
+ * Include OS_alarm.h from the specific proc's lib
+ */
+
+#ifndef POKEDIAMOND_OS_ALARM_SHARED_H
+#define POKEDIAMOND_OS_ALARM_SHARED_H
+
+#include "nitro/types.h"
+#include "nitro/OS_tick_shared.h"
+
+typedef void (*OSAlarmHandler) (void *);
+
+struct OSiAlarm
+{
+ OSAlarmHandler handler;
+ void *arg;
+
+ u32 tag;
+ OSTick fire;
+ OSAlarm *prev;
+ OSAlarm *next;
+
+ OSTick period;
+ OSTick start;
+};
+
+#endif //POKEDIAMOND_OS_ALARM_SHARED_H
diff --git a/include/nitro/OS_interrupt_shared.h b/include/nitro/OS_interrupt_shared.h
index 97bed8b1..9b5974e5 100644
--- a/include/nitro/OS_interrupt_shared.h
+++ b/include/nitro/OS_interrupt_shared.h
@@ -17,4 +17,13 @@
typedef u32 OSIrqMask;
+typedef void (*OSIrqFunction) (void);
+
+typedef struct
+{
+ void (*func) (void *);
+ u32 enable;
+ void* arg;
+} OSIrqCallbackInfo;
+
#endif //POKEDIAMOND_OS_INTERRUPT_SHARED_H
diff --git a/include/nitro/OS_mutex_shared.h b/include/nitro/OS_mutex_shared.h
index bd181f55..e3c93e47 100644
--- a/include/nitro/OS_mutex_shared.h
+++ b/include/nitro/OS_mutex_shared.h
@@ -1,8 +1,20 @@
-#ifndef GUARD_OS_SHARED_MUTEX_H
-#define GUARD_OS_SHARED_MUTEX_H
+/*
+ * NOTE:
+ * This file is shared between ARM9 and ARM7
+ * DO NOT PUT PROC SPECIFIC CODE IN HERE
+ * Thank You!
+ */
+
+/*
+ * DO NOT INCLUDE THIS FILE DIRECTLY
+ * Include OS_mutex.h from the specific proc's lib
+ */
+
+#ifndef POKEDIAMOND_OS_MUTEX_SHARED_H
+#define POKEDIAMOND_OS_MUTEX_SHARED_H
-#include "nitro/types.h"
#include "nitro/OS_thread_shared.h"
+#include "nitro/types.h"
struct OSMutex {
OSThreadQueue queue;
@@ -11,4 +23,4 @@ struct OSMutex {
OSMutexLink link;
};
-#endif
+#endif //POKEDIAMOND_OS_MUTEX_SHARED_H
diff --git a/include/nitro/OS_spinLock_shared.h b/include/nitro/OS_spinLock_shared.h
new file mode 100644
index 00000000..31f0be32
--- /dev/null
+++ b/include/nitro/OS_spinLock_shared.h
@@ -0,0 +1,24 @@
+/*
+ * NOTE:
+ * This file is shared between ARM9 and ARM7
+ * DO NOT PUT PROC SPECIFIC CODE IN HERE
+ * Thank You!
+ */
+
+/*
+ * DO NOT INCLUDE THIS FILE DIRECTLY
+ * Include OS_spinLock.h from the specific proc's lib
+ */
+
+#ifndef POKEDIAMOND_OS_SPINLOCK_SHARED_H
+#define POKEDIAMOND_OS_SPINLOCK_SHARED_H
+
+#include "nitro/types.h"
+
+typedef volatile struct OSLockWord {
+ u32 lockFlag;
+ u16 ownerID;
+ u16 extension;
+} OSLockWord;
+
+#endif //POKEDIAMOND_OS_SPINLOCK_SHARED_H
diff --git a/include/nitro/OS_systemWork_shared.h b/include/nitro/OS_systemWork_shared.h
new file mode 100644
index 00000000..54321015
--- /dev/null
+++ b/include/nitro/OS_systemWork_shared.h
@@ -0,0 +1,66 @@
+/*
+ * NOTE:
+ * This file is shared between ARM9 and ARM7
+ * DO NOT PUT PROC SPECIFIC CODE IN HERE
+ * Thank You!
+ */
+
+/*
+ * DO NOT INCLUDE THIS FILE DIRECTLY
+ * Include consts.h from the specific proc's lib
+ */
+
+#ifndef POKEDIAMOND_OS_SYSTEMWORK_SHARED_H
+#define POKEDIAMOND_OS_SYSTEMWORK_SHARED_H
+
+#include "nitro/types.h"
+#include "nitro/mmap_shared.h"
+#include "nitro/OS_thread_shared.h"
+#include "nitro/OS_spinLock_shared.h"
+
+typedef struct {
+ u8 bootCheckInfo[0x20]; // 000-01f: 32byte boot check info
+ u32 resetParameter; // 020-023: 4byte reset parameter
+ u8 padding5[0x8]; // 024-02c: (8byte)
+ u32 romBaseOffset; // 02c-02f: 4byte ROM offset of own program
+ u8 cartridgeModuleInfo[12]; // 030-03b: 12byte cartridge module info
+ u32 vblankCount; // 03c-03f: 4byte V-Blank Count
+ u8 wmBootBuf[0x40]; // 040-07f: 64byte WM multiboot buffer
+ u8 nvramUserInfo[0x100]; // 080-17f: 256bytes NVRAM user info
+ u8 isd_reserved1[0x20]; // 180-19f: 32bytes ISDebugger reserved
+ u8 arenaInfo[0x48]; // 1a0-1e7: 72byte Arena information
+ u8 real_time_clock[8]; // 1e8-1ef: 8bytes RTC
+ u32 dmaClearBuf[4]; // 1f0-1ff: 16bytes DMA clear information buffer (for ARM9-TEG)
+ u8 rom_header[0x160]; // 200-35f: 352bytes ROM registration area info storage buffer
+ u8 isd_reserved2[32]; // 360-37f: 32bytes ISDebugger reserved
+ u32 pxiSignalParam[2]; // 380-387: 8bytes Param for PXI Signal
+ u32 pxiHandleChecker[2]; // 388-38f: 8bytes Flag for PXI Command Handler Installed
+ u32 mic_last_address; // 390-393: 4bytes MIC latest sampling result storage address
+ u16 mic_sampling_data; // 394-395: 2bytes MIC sampling result
+ u16 wm_callback_control; // 396-397: 2bytes Parameter for WM callback synchronization
+ u16 wm_rssi_pool; // 398-399: 2bytes Random number source depends on WM received signal intensity
+ u8 padding3[2]; // 39a-39b: (2bytes)
+ u32 component_param; // 39c-39f: 4bytes Parameter for Component synchronization
+ OSThreadInfo *threadinfo_mainp; // 3a0-3a3: 4bytes Verify that the pointer to ARM9 thread information is initial value 0
+ OSThreadInfo *threadinfo_subp; // 3a4-3a7: 4bytes Verify that the pointer to ARM7 thread information is initial value 0
+ u16 button_XY; // 3a8-3a9: 2bytes XY button information storage location
+ u8 touch_panel[4]; // 3aa-3ad: 4bytes Touch Screen information storage location
+ u16 autoloadSync; // 3ae-3af: 2bytes autoload sync between processors
+ u32 lockIDFlag_mainp[2]; // 3b0-3b7: 8bytes lockID management flag (ARM9)
+ u32 lockIDFlag_subp[2]; // 3b8-3bf: 8bytes lockID management flag (ARM7)
+ struct OSLockWord lock_VRAM_C; // 3c0-3c7: 8bytes C - lock buffer
+ struct OSLockWord lock_VRAM_D; // 3c8-3cf: 8bytes VRAM-D - lock buffer
+ struct OSLockWord lock_WRAM_BLOCK0; // 3d0-3d7: 8bytes Block0 - lock buffer
+ struct OSLockWord lock_WRAM_BLOCK1; // 3d8-3df: 8bytes CPU internal work RAM - Block1 - lock buffer
+ struct OSLockWord lock_CARD; // 3e0-3e7: 8bytes Game Card - lock buffer
+ struct OSLockWord lock_CARTRIDGE; // 3e8-3ef: 8bytes DS Pak - lock buffer
+ struct OSLockWord lock_INIT; // 3f0-3f7: 8bytes Initialization lock buffer
+ u16 mmem_checker_mainp; // 3f8-3f9: 2bytes MainMomory Size Checker for Main processor
+ u16 mmem_checker_subp; // 3fa-3fb: 2bytes MainMomory Size Checker for Sub processor
+ u8 padding4[2]; // 3fc-3fd: (2bytes)
+ u16 command_area; // 3fe-3ff: 2bytes Command Area
+} OSSystemWork; //0x027FFC00
+
+#define OS_GetSystemWork() ((OSSystemWork *)HW_MAIN_MEM_SYSTEM)
+
+#endif //POKEDIAMOND_OS_SYSTEMWORK_SHARED_H
diff --git a/include/nitro/OS_thread_shared.h b/include/nitro/OS_thread_shared.h
index 5855ee21..a0cce54d 100644
--- a/include/nitro/OS_thread_shared.h
+++ b/include/nitro/OS_thread_shared.h
@@ -1,8 +1,19 @@
-#ifndef GUARD_OS_THREAD_SHARED_H
-#define GUARD_OS_THREAD_SHARED_H
+/*
+ * NOTE:
+ * This file is shared between ARM9 and ARM7
+ * DO NOT PUT PROC SPECIFIC CODE IN HERE
+ * Thank You!
+ */
+
+/*
+ * DO NOT INCLUDE THIS FILE DIRECTLY
+ * Include OS_thread.h from the specific proc's lib
+ */
+
+#ifndef POKEDIAMOND_OS_THREAD_SHARED_H
+#define POKEDIAMOND_OS_THREAD_SHARED_H
#include "nitro/types.h"
-#include "nitro/OS_context_shared.h"
typedef struct OSiAlarm OSAlarm;
@@ -85,9 +96,33 @@ struct _OSThread
u32 systemErrno;
};
+extern OSThreadInfo OSi_ThreadInfo;
+
+static inline OSThreadInfo *OS_GetThreadInfo(void)
+{
+ return &OSi_ThreadInfo;
+}
+
+static inline BOOL OS_IsThreadRunnable(const OSThread *thread)
+{
+ return thread->state == OS_THREAD_STATE_READY;
+}
+
static inline void OS_InitThreadQueue(OSThreadQueue * queue)
{
queue->head = queue->tail = NULL;
}
-#endif
+static inline OSThread *OS_GetCurrentThread(void)
+{
+ return OS_GetThreadInfo()->current;
+}
+
+static inline void OS_SetCurrentThread(OSThread *thread)
+{
+ OS_GetThreadInfo()->current = thread;
+}
+
+#define OSi_GetCurrentThread() (*OSi_CurrentThreadPtr)
+
+#endif //POKEDIAMOND_OS_THREAD_SHARED_H
diff --git a/include/nitro/OS_tick_shared.h b/include/nitro/OS_tick_shared.h
new file mode 100644
index 00000000..e6d6d3b3
--- /dev/null
+++ b/include/nitro/OS_tick_shared.h
@@ -0,0 +1,24 @@
+/*
+ * NOTE:
+ * This file is shared between ARM9 and ARM7
+ * DO NOT PUT PROC SPECIFIC CODE IN HERE
+ * Thank You!
+ */
+
+/*
+ * DO NOT INCLUDE THIS FILE DIRECTLY
+ * Include OS_tick.h from the specific proc's lib
+ */
+
+#ifndef POKEDIAMOND_OS_TICK_SHARED_H
+#define POKEDIAMOND_OS_TICK_SHARED_H
+
+#include "nitro/types.h"
+
+typedef u64 OSTick;
+
+#define OS_SYSTEM_CLOCK HW_SYSTEM_CLOCK
+
+#define OS_MilliSecondsToTicks(msec) ((OSTick)(((OS_SYSTEM_CLOCK/1000) * (u64)(msec)) / 64))
+
+#endif //POKEDIAMOND_OS_TICK_SHARED_H
diff --git a/include/nitro/consts_shared.h b/include/nitro/consts_shared.h
index 151212d1..26cc2fca 100644
--- a/include/nitro/consts_shared.h
+++ b/include/nitro/consts_shared.h
@@ -15,6 +15,7 @@
#include "nitro/types.h"
#include "nitro/mmap_shared.h"
+#include "nitro/registers_shared.h"
//Shared Consts
@@ -29,6 +30,14 @@
#define OSi_InRange(targ, a, b) ((u32)(a) <= (u32)(targ) && (u32)(targ) < (u32)(b))
#define OSi_OFFSET(n, a) (((u32) (n)) & ((a) - 1))
+#define OS_THREAD_SPECIFIC_MAX 0x03
+
+#define OS_THREAD_LAUNCHER_PRIORITY 0x10
+#define OS_THREAD_PRIORITY_MIN 0x00
+#define OS_THREAD_PRIORITY_MAX 0x1F
+
+#define HW_SYSTEM_CLOCK 33514000
+
#define OSi_GetArenaInfo() (*(OSArenaInfo*)HW_ARENA_INFO_BUF)
#endif //POKEDIAMOND_CONSTS_SHARED_H
diff --git a/include/nitro/mmap_shared.h b/include/nitro/mmap_shared.h
index 587887bb..60c0c1cb 100644
--- a/include/nitro/mmap_shared.h
+++ b/include/nitro/mmap_shared.h
@@ -18,8 +18,13 @@
#define HW_MAIN_MEM_MAIN_SIZE 0x003E0000
#define HW_MAIN_MEM_SHARED_SIZE 0x00001000
+#define HW_WRAM 0x037F8000
+
+#define HW_MAIN_MEM_SYSTEM (HW_MAIN_MEM + 0x007ffc00)
#define HW_WM_BOOT_BUF (HW_MAIN_MEM + 0x007ffc40)
#define HW_ARENA_INFO_BUF (HW_MAIN_MEM + 0x007ffda0)
+#define HW_CTRDG_LOCK_BUF (HW_MAIN_MEM + 0x007fffe8)
+#define HW_INIT_LOCK_BUF (HW_MAIN_MEM + 0x007ffff0)
#define HW_MAIN_MEM_MAIN_END (HW_MAIN_MEM + HW_MAIN_MEM_MAIN_SIZE)
#endif //POKEDIAMOND_MMAP_SHARED_H
diff --git a/include/nitro/registers_shared.h b/include/nitro/registers_shared.h
new file mode 100644
index 00000000..60152ab0
--- /dev/null
+++ b/include/nitro/registers_shared.h
@@ -0,0 +1,17 @@
+/*
+ * NOTE:
+ * This file is shared between ARM9 and ARM7
+ * DO NOT PUT PROC SPECIFIC CODE IN HERE
+ * Thank You!
+ */
+
+#ifndef POKEDIAMOND_REGISTERS_SHARED_H
+#define POKEDIAMOND_REGISTERS_SHARED_H
+
+#include "nitro/types.h"
+
+#define reg_OS_IME (*(REGType16v *)0x4000208)
+#define reg_OS_IE (*(REGType32v *)0x4000210)
+#define reg_OS_IF (*(REGType32v *)0x4000214)
+
+#endif //POKEDIAMOND_REGISTERS_SHARED_H