NSMBW-Decomp
A decompilation of New Super Mario Bros. Wii
Loading...
Searching...
No Matches
gki_int.h
1/******************************************************************************
2 *
3 * NOTICE OF CHANGES
4 * 2024/03/25:
5 * - Move from ulinux/ to platform/
6 * - Modify tGKI_OS structure to match RVL target
7 * - Add #define for MAX_INT_STATE
8 *
9 * Compile with REVOLUTION defined to include these changes.
10 *
11 ******************************************************************************/
12
13
14
15/******************************************************************************
16 *
17 * Copyright (C) 1999-2012 Broadcom Corporation
18 *
19 * Licensed under the Apache License, Version 2.0 (the "License");
20 * you may not use this file except in compliance with the License.
21 * You may obtain a copy of the License at:
22 *
23 * http://www.apache.org/licenses/LICENSE-2.0
24 *
25 * Unless required by applicable law or agreed to in writing, software
26 * distributed under the License is distributed on an "AS IS" BASIS,
27 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
28 * See the License for the specific language governing permissions and
29 * limitations under the License.
30 *
31 ******************************************************************************/
32#ifndef GKI_INT_H
33#define GKI_INT_H
34#include "gki_common.h"
35
36/**********************************************************************
37** OS specific definitions
38*/
39
40#ifdef REVOLUTION
41#define MAX_INT_STATE 16
42#endif
43
44/* The base priority used for pthread based GKI task. below value is to keep it retro compatible.
45 * It is recommended to use (GKI_MAX_TASKS+3), this will assign real time priorities GKI_MAX_TASKS-
46 * task_id -2 to the thread */
47#ifndef GKI_LINUX_BASE_PRIORITY
48#define GKI_LINUX_BASE_PRIORITY 30
49#endif
50
51/* The base policy used for pthread based GKI task. the sched defines are defined here to avoid undefined values due
52 * to missing header file, see pthread functions! Overall it is recommend however to use SCHED_NOMRAL */
53#define GKI_SCHED_NORMAL 0
54#define GKI_SCHED_FIFO 1
55#define GKI_SCHED_RR 2
56#ifndef GKI_LINUX_BASE_POLICY
57#define GKI_LINUX_BASE_POLICY GKI_SCHED_NORMAL
58#endif
59
60/* GKI timer bases should use GKI_SCHED_FIFO to ensure the least jitter possible */
61#ifndef GKI_LINUX_TIMER_POLICY
62#define GKI_LINUX_TIMER_POLICY GKI_SCHED_FIFO
63#endif
64
65/* the GKI_timer_update() thread should have the highest real time priority to ensue correct
66 * timer expiry.
67 */
68#ifndef GKI_LINUX_TIMER_TICK_PRIORITY
69#define GKI_LINUX_TIMER_TICK_PRIORITY GKI_LINUX_BASE_PRIORITY+2
70#endif
71
72/* the AV timer should preferably run above the gki timer tick to ensure precise AV timing
73 * If you observe AV jitter under have load you may increase this one */
74#ifndef GKI_LINUX_AV_TIMER_PRIORITY
75#define GKI_LINUX_AV_TIMER_PRIORITY GKI_LINUX_BASE_PRIORITY+3
76#endif
77
78/* defines by how much the nice value of the PROCESS should be changed. Values allowed:
79 * -19 to +19. a negative value give higher priority to btld compared to the default nice value
80 * of 20. in case of SCHED_NORMAL, a level of -5 should give a good btld/bt performance.
81 * In case of real time scheduling, leave default value.
82 */
83#ifndef GKI_LINUX_DEFAULT_NICE_INC
84#define GKI_LINUX_DEFAULT_NICE_INC -7
85#endif
86
87typedef struct
88{
89#ifdef REVOLUTION
90 UINT8 int_index;
91 BOOL int_state[MAX_INT_STATE];
92 char _pad[0x10];
93#else
94 pthread_mutex_t GKI_mutex;
95 pthread_t thread_id[GKI_MAX_TASKS];
96 pthread_mutex_t thread_evt_mutex[GKI_MAX_TASKS];
97 pthread_cond_t thread_evt_cond[GKI_MAX_TASKS];
98 pthread_mutex_t thread_timeout_mutex[GKI_MAX_TASKS];
99 pthread_cond_t thread_timeout_cond[GKI_MAX_TASKS];
100 int no_timer_suspend; /* 1: no suspend, 0 stop calling GKI_timer_update() */
101 pthread_mutex_t gki_timer_mutex;
102 pthread_cond_t gki_timer_cond;
103#if (GKI_DEBUG == TRUE)
104 pthread_mutex_t GKI_trace_mutex;
105#endif
106#endif
107} tGKI_OS;
108
109/* condition to exit or continue GKI_run() timer loop */
110#define GKI_TIMER_TICK_RUN_COND 1
111#define GKI_TIMER_TICK_STOP_COND 0
112
113extern void gki_system_tick_start_stop_cback(BOOLEAN start);
114
115/* Contains common control block as well as OS specific variables */
116typedef struct
117{
118 tGKI_OS os;
119 tGKI_COM_CB com;
120} tGKI_CB;
121
122
123#ifdef __cplusplus
124extern "C" {
125#endif
126
127#if GKI_DYNAMIC_MEMORY == FALSE
128GKI_API extern tGKI_CB gki_cb;
129#else
130GKI_API extern tGKI_CB *gki_cb_ptr;
131#define gki_cb (*gki_cb_ptr)
132#endif
133
134#ifdef __cplusplus
135}
136#endif
137
138#endif
139