mirror of
https://github.com/shadergz/cosmic-station.git
synced 2024-11-27 00:00:21 +00:00
Kernel
: backend handler has now been implemented; tests are required
This commit is contained in:
parent
ceef1f9554
commit
d71401a47b
1
.idea/inspectionProfiles/Project_Default.xml
generated
1
.idea/inspectionProfiles/Project_Default.xml
generated
@ -3,6 +3,7 @@
|
||||
<option name="myName" value="Project Default" />
|
||||
<inspection_tool class="ClangTidy" enabled="true" level="INFORMATION" enabled_by_default="true" />
|
||||
<inspection_tool class="ConstantFunctionResult" enabled="false" level="WARNING" enabled_by_default="false" />
|
||||
<inspection_tool class="JniParameters" enabled="false" level="WARNING" enabled_by_default="false" />
|
||||
<inspection_tool class="OCUnusedGlobalDeclaration" enabled="false" level="WARNING" enabled_by_default="false" />
|
||||
<inspection_tool class="UnusedParameter" enabled="false" level="WARNING" enabled_by_default="false" />
|
||||
<inspection_tool class="UnusedSymbol" enabled="false" level="WARNING" enabled_by_default="false" />
|
||||
|
@ -39,12 +39,26 @@ Java_emu_zenith_helper_KernelsHelper_kernelAdd(JNIEnv *env, jobject thiz, jobjec
|
||||
|
||||
extern "C"
|
||||
JNIEXPORT jboolean JNICALL
|
||||
Java_emu_zenith_helper_KernelsHelper_kernelSet(JNIEnv *env, jobject thiz, jobjectArray kCRCwFd) {
|
||||
Java_emu_zenith_helper_KernelsHelper_kernelRemove(JNIEnv *env, jobject thiz, jlongArray kFDwCRC) {
|
||||
if (env->GetArrayLength(kFDwCRC) != 2) {
|
||||
throw zenith::fatalError("Not supported element array size {} passed to KernelSet",
|
||||
env->GetArrayLength(kFDwCRC));
|
||||
}
|
||||
auto group{zenith::zenithApp->getKernelsGroup()};
|
||||
|
||||
return false;
|
||||
jlong* mangled{env->GetLongArrayElements(kFDwCRC, nullptr)};
|
||||
zenith::u32 downVote[2];
|
||||
downVote[0] = static_cast<zenith::u32>(mangled[0]);
|
||||
downVote[1] = static_cast<zenith::u32>(mangled[1]);
|
||||
|
||||
bool hasRemoved{group->rmFromStore(downVote)};
|
||||
env->ReleaseLongArrayElements(kFDwCRC, mangled, 0);
|
||||
|
||||
return hasRemoved;
|
||||
}
|
||||
extern "C"
|
||||
JNIEXPORT jboolean JNICALL
|
||||
Java_emu_zenith_helper_KernelsHelper_kernelRemove(JNIEnv *env, jobject thiz, jobjectArray kCRCwFd) {
|
||||
return false;
|
||||
Java_emu_zenith_helper_KernelsHelper_kernelSet(JNIEnv *env, jobject thiz, jlong kCRC) {
|
||||
auto group{zenith::zenithApp->getKernelsGroup()};
|
||||
return group->choiceByCRC(static_cast<zenith::u32>(kCRC));
|
||||
}
|
||||
|
@ -28,7 +28,7 @@ namespace zenith::eeiv {
|
||||
for (auto segmentPage{kUnmapStart}; segmentPage != kUnmapEnd; segmentPage += 4096) {
|
||||
auto kVTable{segmentPage / 4096};
|
||||
if (kVTable >= 1024 * 1024) {
|
||||
throw fatal_error("Kernel TLB table {} is outside the specified range", kVTable);
|
||||
throw fatalError("Kernel TLB table {} is outside the specified range", kVTable);
|
||||
}
|
||||
|
||||
kernelVTLB[kVTable] = choiceMemSrc(segmentPage & (0x20000000 - 1));
|
||||
@ -60,7 +60,7 @@ namespace zenith::eeiv {
|
||||
|
||||
void TLBCache::tlbChModified(u32 page, bool value) {
|
||||
if (page >= 1024 * 1024)
|
||||
throw fatal_error("Page {} is outside the range, TLB is missing for this page", page);
|
||||
throw fatalError("Page {} is outside the range, TLB is missing for this page", page);
|
||||
tlbInfo[page].modified = value;
|
||||
}
|
||||
}
|
||||
|
@ -29,7 +29,7 @@ namespace zenith::java {
|
||||
JavaClass(JNIEnv* env, const char* className)
|
||||
: classEnv(env),
|
||||
model(env->FindClass(className)) {}
|
||||
virtual ~JavaClass() = 0;
|
||||
virtual ~JavaClass() = default;
|
||||
|
||||
virtual jobject createInstance() = 0;
|
||||
virtual void fillInstance(jobject kotlin) = 0;
|
||||
|
@ -13,6 +13,24 @@ namespace zenith::kernel {
|
||||
return alreadyAdded;
|
||||
}
|
||||
|
||||
bool KernelsGroup::rmFromStore(u32 rmBy[2]) {
|
||||
bool hasRemoved{};
|
||||
std::remove_if(kernels.begin(), kernels.end(), [rmBy, &hasRemoved](const auto& kernel) {
|
||||
hasRemoved = kernel.kID == rmBy[0] && kernel.kDataCRC == rmBy[1];
|
||||
return hasRemoved;
|
||||
});
|
||||
return hasRemoved;
|
||||
}
|
||||
|
||||
bool KernelsGroup::choiceByCRC(u32 kernelCRC) {
|
||||
bool picked{};
|
||||
std::for_each(kernels.begin(), kernels.end(), [kernelCRC, &picked](const auto& kValue) {
|
||||
if (kValue.kDataCRC == kernelCRC)
|
||||
picked = true;
|
||||
});
|
||||
return picked;
|
||||
}
|
||||
|
||||
jobject KernelModel::createInstance() {
|
||||
auto modelInit{classEnv->GetMethodID(model, "<init>", "()V")};
|
||||
auto kotlinKernel{classEnv->NewObject(model, modelInit)};
|
||||
|
@ -32,6 +32,8 @@ namespace zenith::kernel {
|
||||
rIsCrucial = true;
|
||||
kernels.push_back(kernel);
|
||||
}
|
||||
bool rmFromStore(u32 rmBy[2]);
|
||||
bool choiceByCRC(u32 kernelCRC);
|
||||
private:
|
||||
bool rIsCrucial{};
|
||||
std::list<KernelModel> kernels;
|
||||
|
@ -17,10 +17,10 @@ namespace zenith {
|
||||
|
||||
using u64 = std::uint64_t;
|
||||
|
||||
class fatal_error : public std::runtime_error {
|
||||
class fatalError : public std::runtime_error {
|
||||
public:
|
||||
template <typename T, typename... Args>
|
||||
fatal_error(const T& format, Args&&... args)
|
||||
fatalError(const T& format, Args&&... args)
|
||||
: std::runtime_error(fmt::format(fmt::runtime(format), args...)) {}
|
||||
};
|
||||
|
||||
@ -40,7 +40,7 @@ namespace zenith {
|
||||
|
||||
void operator=(int fileNativeFd) {
|
||||
if (fileNativeFd == invalidFileDescriptor) {
|
||||
throw fatal_error("Corrupted file descriptor being passed without checking");
|
||||
throw fatalError("Corrupted file descriptor being passed without checking");
|
||||
}
|
||||
basicFd = fileNativeFd;
|
||||
|
||||
|
@ -53,20 +53,20 @@ class KernelsHelper(val context: Context) {
|
||||
}
|
||||
|
||||
fun setActive(kModel: KernelModel) {
|
||||
val info = arrayOf(kModel.id, kModel.dataCRC)
|
||||
val kernelCRC = kModel.dataCRC
|
||||
assert(kernelList.contains(kModel))
|
||||
if (kModel.selected) {
|
||||
Log.d("Zenith", "Kernel ID, CRC $info is already selected; this may be an issue")
|
||||
Log.d("Zenith", "Kernel ID, CRC $kernelCRC is already selected; this may be an issue")
|
||||
return
|
||||
}
|
||||
if (!kernelSet(info))
|
||||
throw Exception("Can't set the kernel with ID, CRC ($info) as active")
|
||||
if (!kernelSet(kernelCRC))
|
||||
throw Exception("Can't set the kernel with CRC ($kernelCRC) as active")
|
||||
kernelList.find { it == kModel }?.apply {
|
||||
selected = true
|
||||
}
|
||||
}
|
||||
|
||||
private external fun kernelAdd(descriptor: FileDescriptor): KernelModel
|
||||
private external fun kernelSet(kCRCwFd: Array<UInt>): Boolean
|
||||
private external fun kernelRemove(kCRCwFd: Array<UInt>): Boolean
|
||||
private external fun kernelSet(kCRC: UInt): Boolean
|
||||
private external fun kernelRemove(kFDwCRC: Array<UInt>): Boolean
|
||||
}
|
Loading…
Reference in New Issue
Block a user