| 305 | } |
| 306 | |
| 307 | error_code sys_memory_container_create(cpu_thread &cpu, vm::ptr<u32> cid, |
| 308 | u64 size) { |
| 309 | cpu.state += cpu_flag::wait; |
| 310 | |
| 311 | sys_memory.warning("sys_memory_container_create(cid=*0x%x, size=0x%x)", cid, |
| 312 | size); |
| 313 | |
| 314 | // Round down to 1 MB granularity |
| 315 | size &= ~0xfffff; |
| 316 | |
| 317 | if (!size) { |
| 318 | return CELL_ENOMEM; |
| 319 | } |
| 320 | |
| 321 | auto &dct = g_fxo->get<lv2_memory_container>(); |
| 322 | |
| 323 | std::lock_guard lock(s_memstats_mtx); |
| 324 | |
| 325 | // Try to obtain "physical memory" from the default container |
| 326 | if (!dct.take(size)) { |
| 327 | return CELL_ENOMEM; |
| 328 | } |
| 329 | |
| 330 | // Create the memory container |
| 331 | if (const u32 id = |
| 332 | idm::make<lv2_memory_container>(static_cast<u32>(size), true)) { |
| 333 | cpu.check_state(); |
| 334 | *cid = id; |
| 335 | return CELL_OK; |
| 336 | } |
| 337 | |
| 338 | dct.free(size); |
| 339 | return CELL_EAGAIN; |
| 340 | } |
| 341 | |
| 342 | error_code sys_memory_container_destroy(cpu_thread &cpu, u32 cid) { |
| 343 | cpu.state += cpu_flag::wait; |
nothing calls this directly
no test coverage detected