SachinVin / citra_android

An Android frontend for the Citra Emulator
GNU General Public License v3.0
573 stars 90 forks source link

ARMVM Project May Help The Project #216

Open armvm opened 5 years ago

armvm commented 5 years ago

https://github.com/armvm/ARMVM ARMVM, Running ARM Code directly On Android, Can Catch and callback System call and other Exception. It may help you The bridge of HLE<->CPU is class VmCallback, please see main.cpp It Has two thread: main thread and sandbox thread. 3ds code run on sandbox thread, and sandbox thread can CATCH HLE call and callback to main thread. but i want to know how to compile citra on android, it faild. please give me "simple project" for citra android

SachinVin commented 5 years ago

Maybe pitch it on the citra discord and we could see what they think about it, I'm not entirely sure about the requirements for the HLE<->CPU bridge.

Jack-Rickwood commented 5 years ago

For that matter, @sachinvin, how hard would it be to implement kvm support... obviosly it would be usable on a very limited number of devices, but i might just give it a shot

armvm commented 5 years ago

It has two thread:sandbox thread and main thread. sandbox thread run 3ds code, WHEN RAISE SVC CALL(HLE), it will switch to main thread and save registers. then call hle. sandbox would wait for main thread. YOU CAN IMPLEMENT CLASS VmCallback, Method void HandleSystemCall(uint32_t swi) , the bridge of HLE<->CPU i want to know how to compile citra on android

SachinVin commented 5 years ago

@armvm How would you handle MMIO?

git clone https://github.com/SachinVin/citra_android.git
git clone --recursive  https://github.com/SachinVin/citra.git

Then you build it with android studio

armvm commented 5 years ago

@SachinVin for example

include "core/hle/kernel/svc.h"

class TestCallback : public ARMVM::VmCallback { TestCallback(Core::System& system) :svc(system) {

}

virtual void HandleException(uint32_t sig) override
{

}

virtual void HandleIllegalInstruction(uint32_t instruction) override
{

}

virtual void HandleSystemCall(uint32_t svc) override
{
    svc.CallSVC(svc); //include MMIO and other system call;
}

virtual void HandleSegmentFault(uint32_t instruction) override
{

}

virtual ~TestCallback() override
{

}

Kernel::SVC svc;
std::unique_ptr<ARMVM::VmLauncher> launcher;

};

... std::unique_ptr callback = std::unique_ptr(coreSystem); callback->launcher = ARMVM::VmLauncher::Create(); auto context = callback->launcher->NewContext(); context->SetCpuRegister(13, reinterpret_cast(stack) + sizeof(stack)); context->SetCpuRegister(15, reinterpret_cast(entry)); callback->launcher->LoadContext(context); callback->launcher->Run(callback); callback->launcher->SaveContext(context); ...

Because MMIO is system call, for example "WriteProcessMemory" is svc 0x6B, so when call "WriteProcessMemory", armvm will will save register and swich main thread and call vmcallback->HandleSystemCall(0x6B), then emulator can handle it and modify register and memory. after return HandleSystemCall, it will switch to sandbox and load register.

I'm fans of citra_android project, and I want to contribute to the project!

SachinVin commented 5 years ago

MMIO is not a system call, a program could write to an address that isnt a memory location but a device, If you dont handle these non existent memory location you're going to segfault. Also there needs to be a cycle counter for timings.

armvm commented 5 years ago

@SachinVin ARMVM can catch segfault exception and not crash, so you can handle the exception at main thread(emulator)

armvm commented 5 years ago

VmCallback::HandleException(uint32_t sig); when sig = 11, it is segfault. you can get instruction by PC register and handle it

SachinVin commented 5 years ago

Well, i guess you can go ahead and give it a shot.

wahidkamenrider commented 5 years ago

Nice emulator for android i have playing runefactory 4 on android playble fps 30-60 on snapdragon 710(game fav. On 3ds)

Thanks for SachinVin

wahidkamenrider commented 5 years ago

Wait new build for mapping gamepad controler thanks....^_^

SachinVin commented 5 years ago

Dont wait, I dont plan on updating anytime soon.

wahidkamenrider commented 5 years ago

Okay ^_^