mirror of
https://github.com/decompals/wibo.git
synced 2025-12-12 14:46:09 +00:00
Split into HostContextGuard/GuestContextGuard
This commit is contained in:
16
src/main.cpp
16
src/main.cpp
@@ -346,14 +346,7 @@ int main(int argc, char **argv) {
|
||||
fprintf(stderr, "Failed to install TIB for main thread\n");
|
||||
return 1;
|
||||
}
|
||||
|
||||
uint16_t hostFsSelector = 0;
|
||||
uint16_t hostGsSelector = 0;
|
||||
asm volatile("mov %%fs, %0" : "=r"(hostFsSelector));
|
||||
asm volatile("mov %%gs, %0" : "=r"(hostGsSelector));
|
||||
tib.hostFsSelector = hostFsSelector;
|
||||
tib.hostGsSelector = hostGsSelector;
|
||||
tib.hostSegmentsValid = 1;
|
||||
wibo::setThreadTibForHost(&tib);
|
||||
|
||||
// Determine the guest program name
|
||||
auto guestArgs = wibo::splitCommandLine(cmdLine.c_str());
|
||||
@@ -490,10 +483,9 @@ int main(int argc, char **argv) {
|
||||
}
|
||||
|
||||
// Invoke the damn thing
|
||||
asm("movw %0, %%fs; call *%1" : : "r"(wibo::tibSelector), "r"(entryPoint));
|
||||
if (tib.hostSegmentsValid) {
|
||||
asm volatile("movw %0, %%fs" : : "r"(tib.hostFsSelector) : "memory");
|
||||
asm volatile("movw %0, %%gs" : : "r"(tib.hostGsSelector) : "memory");
|
||||
{
|
||||
GUEST_CONTEXT_GUARD(&tib);
|
||||
asm volatile("call *%0" : : "r"(entryPoint) : "memory");
|
||||
}
|
||||
DEBUG_LOG("We came back\n");
|
||||
wibo::shutdownModuleRegistry();
|
||||
|
||||
Reference in New Issue
Block a user