| 163 | } |
| 164 | |
| 165 | extern s32 sysutil_send_system_cmd(u64 status, u64 param) |
| 166 | { |
| 167 | s32 count = 0; |
| 168 | |
| 169 | if (auto cbm = g_fxo->try_get<sysutil_cb_manager>()) |
| 170 | { |
| 171 | if (status == CELL_SYSUTIL_DRAWING_BEGIN) |
| 172 | { |
| 173 | if (cbm->draw_cb_started.exchange(true)) |
| 174 | { |
| 175 | cellSysutil.error( |
| 176 | "Tried to enqueue a second or more DRAWING_BEGIN callback!"); |
| 177 | return CELL_SYSUTIL_ERROR_BUSY; |
| 178 | } |
| 179 | } |
| 180 | else if (status == CELL_SYSUTIL_DRAWING_END) |
| 181 | { |
| 182 | if (!cbm->draw_cb_started.exchange(false)) |
| 183 | { |
| 184 | cellSysutil.error("Tried to enqueue a DRAWING_END callback without a " |
| 185 | "BEGIN callback!"); |
| 186 | return -1; |
| 187 | } |
| 188 | } |
| 189 | else if (status == CELL_SYSUTIL_REQUEST_EXITGAME) |
| 190 | { |
| 191 | abort_lv2_watchdog(); |
| 192 | } |
| 193 | |
| 194 | for (sysutil_cb_manager::registered_cb cb : cbm->callbacks) |
| 195 | { |
| 196 | if (cb.callback) |
| 197 | { |
| 198 | cbm->registered.push( |
| 199 | sysutil_cb_manager::dispatcher_cb{[=](ppu_thread& ppu) -> s32 |
| 200 | { |
| 201 | // TODO: check it and find the source of the return value (void |
| 202 | // isn't equal to CELL_OK) |
| 203 | cb.callback(ppu, status, param, cb.user_data); |
| 204 | return CELL_OK; |
| 205 | }}); |
| 206 | |
| 207 | count++; |
| 208 | } |
| 209 | } |
| 210 | } |
| 211 | |
| 212 | return count; |
| 213 | } |
| 214 | |
| 215 | extern u64 get_sysutil_cb_manager_read_count() |
| 216 | { |
no test coverage detected