Core: Fixes regressions and addresses various bugs

This commit is contained in:
Gabriel Correia 2024-06-04 22:23:35 -03:00
parent 4778e03229
commit 9667a2aa4f
5 changed files with 55 additions and 35 deletions

View File

@ -69,22 +69,23 @@ namespace cosmic::mio {
}
storage.append(devOutFile);
boost::filesystem::fstream wrIo;
wrIo.open(storage, std::ios::trunc | std::ios::binary);
boost::filesystem::fstream writeFile;
const auto ioPerm{std::ios::out | std::ios::trunc | std::ios::binary};
writeFile.open(storage, ioPerm);
DumpFileImage image{
const DumpFileImage image{
.version = 1,
.size = devBlock.getBlockSize()
};
if (wrIo) {
wrIo << image.version;
wrIo << image.size;
if (writeFile) {
writeFile << image.version;
writeFile << image.size;
auto size{static_cast<std::streamsize>(devBlock.getBlockSize())};
wrIo.write(reinterpret_cast<const char*>(*devBlock), size);
writeFile.write(reinterpret_cast<const char*>(*devBlock), size);
}
wrIo.close();
writeFile.close();
}
constexpr u64 soundMemory = 1024 * 1024 * 2;

View File

@ -13,7 +13,7 @@ namespace cosmic::os {
{SchedulerAffinity, "dsdb_sched_affinity"},
{EeMode, "dsdb_ee_mode"}
};
OsMachState::OsMachState(JavaVM* vm) :
OsMachState::OsMachState() :
// Our application's root directory, we can save everything from here
appStorage(dsKeys.at(AppStorage)),
@ -28,12 +28,7 @@ namespace cosmic::os {
schedAffinity(dsKeys.at(SchedulerAffinity)),
// Includes the EE execution mode
eeMode(dsKeys.at(EeMode)), androidRuntime(vm) {
void* env{};
if (androidRuntime)
androidRuntime->GetEnv(&env, JNI_VERSION_1_6);
cosmicEnv.feedVm(BitCast<JNIEnv*>(env));
eeMode(dsKeys.at(EeMode)) {
}
void OsMachState::syncAllSettings() {

View File

@ -9,8 +9,10 @@
#include <os/env.h>
#include <common/types.h>
namespace cosmic {
extern thread_local os::CosmicEnv cosmicEnv;
}
namespace cosmic::os {
extern thread_local CosmicEnv cosmicEnv;
enum StateId {
AppStorage,
GpuCustomDriver,
@ -60,7 +62,7 @@ namespace cosmic::os {
class OsMachState {
public:
OsMachState(JavaVM* vm);
OsMachState();
void syncAllSettings();
OsVariable<java::JniString> appStorage,

View File

@ -23,9 +23,14 @@ static struct sigaction trap{
// JNI_OnLoad function is called when the JVM has loaded our native code in the heap, this process
// is started by Java Runtime using System.loadLibrary("cosmic")
extern "C" jint JNI_OnLoad(JavaVM* vm, void* reserved) {
void* env{};
if (vm)
vm->GetEnv(&env, JNI_VERSION_1_6);
cosmic::cosmicEnv.feedVm(cosmic::BitCast<JNIEnv*>(env));
// Kickstart the user readable log system also called as, GlobalLogger
cosmic::user = std::make_shared<cosmic::GlobalLogger>();
cosmic::states = std::make_unique<cosmic::os::OsMachState>(vm);
cosmic::states = std::make_unique<cosmic::os::OsMachState>();
sigaction(SIGABRT, &trap, &signals[0]);
sigaction(SIGTRAP, &trap, &signals[1]);

View File

@ -4,15 +4,20 @@ import android.content.res.Resources.NotFoundException
import emu.cosmic.CosmicApplication
class CosmicSettings private constructor(context: Context) {
var appStorage by DelegateDataStore<String>(SettingContainer(context, SettingsKeys.AppStorage))
var appStorage by DelegateDataStore<String>(
SettingContainer(context, SettingsKeys.AppStorage))
var gpuTurboMode by DelegateDataStore<Boolean>(SettingContainer(context, SettingsKeys.GpuTurboMode))
var gpuTurboMode by DelegateDataStore<Boolean>(
SettingContainer(context, SettingsKeys.GpuTurboMode))
var customDriver by DelegateDataStore<String>(SettingContainer(context, SettingsKeys.CustomDriver))
var customDriver by DelegateDataStore<String>(
SettingContainer(context, SettingsKeys.CustomDriver))
var eeMode by DelegateDataStore<Int>(SettingContainer(context, SettingsKeys.EEMode))
var eeMode by DelegateDataStore<Int>(
SettingContainer(context, SettingsKeys.EEMode))
var biosPath by DelegateDataStore<String>(SettingContainer(context, SettingsKeys.BiosPath))
var biosPath by DelegateDataStore<String>(
SettingContainer(context, SettingsKeys.BiosPath))
// Creating a static object to store all our configurations
// This object will reside in the global heap memory (Accessible to JNI)
@ -20,21 +25,33 @@ class CosmicSettings private constructor(context: Context) {
val globalSettings by lazy { CosmicSettings(CosmicApplication.context) }
var updateSettings: Boolean = false
private val dsCachedSet = LinkedHashMap<String, Any>()
private var dsCachedSet: HashMap<String, Any>? = null
private fun updateAllValues() {
if (!updateSettings)
return
dsCachedSet?.clear()
val dsCached = mapOf(
"dsdb_app_storage" to globalSettings.appStorage,
"dsdb_gpu_turbo_mode" to globalSettings.gpuTurboMode,
"dsdb_gpu_custom_driver" to globalSettings.customDriver,
"dsdb_ee_mode" to globalSettings.eeMode,
"dsdb_bios_path" to globalSettings.biosPath
)
dsCachedSet = HashMap(dsCached)
updateSettings = false
}
@JvmStatic
fun getDataStoreValue(config: String) : Any {
dsCachedSet.clear()
dsCachedSet["dsdb_app_storage"] = globalSettings.appStorage
dsCachedSet["dsdb_gpu_turbo_mode"] = globalSettings.gpuTurboMode
dsCachedSet["dsdb_gpu_custom_driver"] = globalSettings.customDriver
dsCachedSet["dsdb_ee_mode"] = globalSettings.eeMode
dsCachedSet["dsdb_bios_path"] = globalSettings.biosPath
if (!dsCachedSet.containsValue(config)) {
throw NotFoundException(config)
if (!updateSettings)
updateSettings = dsCachedSet == null
updateAllValues()
dsCachedSet?.let {
if (!it.containsKey(config))
throw NotFoundException(config)
return it[config]!!
}
return dsCachedSet.getValue(config)
return {}
}
}
}