mirror of
https://github.com/skyline-emu/skyline.git
synced 2024-12-23 18:51:56 +01:00
Min. API version to 26 (8.0) and use ASharedMemory
Move Minimum API version to Android 8.0 and switch from /dev/ashmem to ASharedMemory APIs.
This commit is contained in:
parent
423540328a
commit
0d141b71e9
@ -5,7 +5,7 @@ android {
|
|||||||
buildToolsVersion '29.0.2'
|
buildToolsVersion '29.0.2'
|
||||||
defaultConfig {
|
defaultConfig {
|
||||||
applicationId "skyline.emu"
|
applicationId "skyline.emu"
|
||||||
minSdkVersion 24
|
minSdkVersion 26
|
||||||
targetSdkVersion 29
|
targetSdkVersion 29
|
||||||
versionCode 3
|
versionCode 3
|
||||||
versionName "0.3"
|
versionName "0.3"
|
||||||
|
@ -1,22 +1,17 @@
|
|||||||
#include "KSharedMemory.h"
|
#include "KSharedMemory.h"
|
||||||
#include <nce.h>
|
#include <nce.h>
|
||||||
#include <fcntl.h>
|
#include <android/sharedmem.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
|
||||||
constexpr const char *ASHMEM_NAME_DEF = "dev/ashmem";
|
|
||||||
constexpr int ASHMEM_SET_SIZE = 0x40087703;
|
|
||||||
|
|
||||||
namespace skyline::kernel::type {
|
namespace skyline::kernel::type {
|
||||||
u64 MapSharedFunc(u64 address, size_t size, u64 perms, u64 fd) {
|
u64 MapSharedFunc(u64 address, size_t size, u64 perms, u64 fd) {
|
||||||
return reinterpret_cast<u64>(mmap(reinterpret_cast<void *>(address), size, static_cast<int>(perms), MAP_SHARED | ((address) ? MAP_FIXED : 0), static_cast<int>(fd), 0)); // NOLINT(hicpp-signed-bitwise)
|
return reinterpret_cast<u64>(mmap(reinterpret_cast<void *>(address), size, static_cast<int>(perms), MAP_SHARED | ((address) ? MAP_FIXED : 0), static_cast<int>(fd), 0)); // NOLINT(hicpp-signed-bitwise)
|
||||||
}
|
}
|
||||||
|
|
||||||
KSharedMemory::KSharedMemory(const DeviceState &state, pid_t pid, u64 kaddress, size_t ksize, const memory::Permission localPermission, const memory::Permission remotePermission, memory::Type type) : kaddress(kaddress), ksize(ksize), localPermission(localPermission), remotePermission(remotePermission), type(type), owner(pid), KObject(state, KType::KSharedMemory) {
|
KSharedMemory::KSharedMemory(const DeviceState &state, pid_t pid, u64 kaddress, size_t ksize, const memory::Permission localPermission, const memory::Permission remotePermission, memory::Type type) : kaddress(kaddress), ksize(ksize), localPermission(localPermission), remotePermission(remotePermission), type(type), owner(pid), KObject(state, KType::KSharedMemory) {
|
||||||
fd = open(ASHMEM_NAME_DEF, O_RDWR | O_CLOEXEC); // NOLINT(hicpp-signed-bitwise)
|
fd = ASharedMemory_create("", ksize);
|
||||||
if (fd < 0)
|
if (fd < 0)
|
||||||
throw exception("An error occurred while opening {}: {}", ASHMEM_NAME_DEF, fd);
|
throw exception("An error occurred while creating shared memory: {}", fd);
|
||||||
if (ioctl(fd, ASHMEM_SET_SIZE, ksize) < 0) // NOLINT(hicpp-signed-bitwise)
|
|
||||||
throw exception("An error occurred while setting shared memory size: {}", ksize);
|
|
||||||
kaddress = MapSharedFunc(kaddress, ksize, static_cast<u64>(pid ? remotePermission.Get() : localPermission.Get()), static_cast<u64>(fd));
|
kaddress = MapSharedFunc(kaddress, ksize, static_cast<u64>(pid ? remotePermission.Get() : localPermission.Get()), static_cast<u64>(fd));
|
||||||
if (kaddress == reinterpret_cast<u64>(MAP_FAILED)) // NOLINT(hicpp-signed-bitwise)
|
if (kaddress == reinterpret_cast<u64>(MAP_FAILED)) // NOLINT(hicpp-signed-bitwise)
|
||||||
throw exception("An occurred while mapping shared region: {}", strerror(errno));
|
throw exception("An occurred while mapping shared region: {}", strerror(errno));
|
||||||
|
Loading…
Reference in New Issue
Block a user