MCPcopy Create free account
hub / github.com/RPCSX/rpcsx / ppu_alloc_tls

Function ppu_alloc_tls

ps3fw/sys_ppu_thread_.cpp:25–49  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

23static std::unique_ptr<atomic_t<bool>[]> s_tls_map; // I'd like to make it std::vector but it won't work
24
25static u32 ppu_alloc_tls()
26{
27 u32 addr = 0;
28
29 for (u32 i = 0; i < s_tls_max; i++)
30 {
31 if (!s_tls_map[i] && s_tls_map[i].exchange(true) == false)
32 {
33 // Default (small) TLS allocation
34 addr = s_tls_area + i * s_tls_size;
35 break;
36 }
37 }
38
39 if (!addr)
40 {
41 // Alternative (big) TLS allocation
42 addr = vm::alloc(s_tls_size, vm::main);
43 }
44
45 std::memset(vm::base(addr), 0, 0x30); // Clear system area (TODO)
46 std::memcpy(vm::base(addr + 0x30), vm::base(s_tls_addr), s_tls_file); // Copy TLS image
47 std::memset(vm::base(addr + 0x30 + s_tls_file), 0, s_tls_zero); // Clear the rest
48 return addr;
49}
50
51static void ppu_free_tls(u32 addr)
52{

Callers 2

sys_initialize_tlsFunction · 0.85
sys_ppu_thread_createFunction · 0.85

Calls 3

allocFunction · 0.85
baseFunction · 0.85
exchangeMethod · 0.45

Tested by

no test coverage detected