[Kernel] Implement per-process TLS allocation

Previous global TLS bitmap was shared across all processes. Now
per-process TLS bitmaps stored X_KPROCESS structures which should
better match Xbox360 architecture.
This commit is contained in:
Herman S.
2025-10-20 11:16:09 +09:00
parent 2590f03bc1
commit c17a3b19fb
3 changed files with 133 additions and 30 deletions

View File

@@ -469,8 +469,8 @@ void KeQuerySystemTime_entry(lpqword_t time_ptr, const ppc_context_t& ctx) {
DECLARE_XBOXKRNL_EXPORT1(KeQuerySystemTime, kThreading, kImplemented);
// https://msdn.microsoft.com/en-us/library/ms686801
dword_result_t KeTlsAlloc_entry() {
uint32_t slot = kernel_state()->AllocateTLS();
dword_result_t KeTlsAlloc_entry(const ppc_context_t& context) {
uint32_t slot = kernel_state()->AllocateTLS(context);
XThread::GetCurrentThread()->SetTLSValue(slot, 0);
return slot;
@@ -478,12 +478,13 @@ dword_result_t KeTlsAlloc_entry() {
DECLARE_XBOXKRNL_EXPORT1(KeTlsAlloc, kThreading, kImplemented);
// https://msdn.microsoft.com/en-us/library/ms686804
dword_result_t KeTlsFree_entry(dword_t tls_index) {
dword_result_t KeTlsFree_entry(dword_t tls_index,
const ppc_context_t& context) {
if (tls_index == X_TLS_OUT_OF_INDEXES) {
return 0;
}
kernel_state()->FreeTLS(tls_index);
kernel_state()->FreeTLS(context, tls_index);
return 1;
}
DECLARE_XBOXKRNL_EXPORT1(KeTlsFree, kThreading, kImplemented);