mirror of
https://github.com/Atmosphere-NX/Atmosphere.git
synced 2024-11-22 20:06:40 +00:00
Stratosphere: Add Launch Queue to Loader
Modified from RE done by @ogniK5377
This commit is contained in:
parent
864979179a
commit
c8d1342ddf
2 changed files with 65 additions and 0 deletions
46
stratosphere/loader/source/ldr_launch_queue.cpp
Normal file
46
stratosphere/loader/source/ldr_launch_queue.cpp
Normal file
|
@ -0,0 +1,46 @@
|
||||||
|
#include "ldr_launch_queue.hpp"
|
||||||
|
|
||||||
|
#include <switch.h>
|
||||||
|
|
||||||
|
static launch_item_t g_launch_queue[LAUNCH_QUEUE_SIZE];
|
||||||
|
|
||||||
|
int launch_queue_get_index(u64 TID) {
|
||||||
|
for(unsigned int i = 0; i < LAUNCH_QUEUE_SIZE; i++) {
|
||||||
|
if(g_launch_queue[i].tid == TID) {
|
||||||
|
return i;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return LAUNCH_QUEUE_FULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
int launch_queue_get_free_index(u64 TID) {
|
||||||
|
for(unsigned int i = 0; i < LAUNCH_QUEUE_SIZE; i++) {
|
||||||
|
if(g_launch_queue[i].tid == TID || g_launch_queue[i].tid == 0x0) {
|
||||||
|
return i;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return LAUNCH_QUEUE_FULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
Result launch_queue_add(launch_item_t *item) {
|
||||||
|
if(item->arg_size > LAUNCH_QUEUE_ARG_SIZE_MAX) {
|
||||||
|
return 0x209;
|
||||||
|
}
|
||||||
|
|
||||||
|
int idx = launch_queue_get_free_index(item->tid);
|
||||||
|
if(idx == LAUNCH_QUEUE_FULL)
|
||||||
|
return 0x409;
|
||||||
|
|
||||||
|
g_launch_queue[idx] = *item;
|
||||||
|
return 0x0;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool launch_queue_contains(uint64_t TID) {
|
||||||
|
return launch_queue_get_index(TID) != LAUNCH_QUEUE_FULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
void launch_queue_clear() {
|
||||||
|
for (unsigned int i = 0; i < LAUNCH_QUEUE_SIZE; i++) {
|
||||||
|
g_launch_queue[i].tid = 0;
|
||||||
|
}
|
||||||
|
}
|
19
stratosphere/loader/source/ldr_launch_queue.hpp
Normal file
19
stratosphere/loader/source/ldr_launch_queue.hpp
Normal file
|
@ -0,0 +1,19 @@
|
||||||
|
#pragma once
|
||||||
|
#include <switch.h>
|
||||||
|
|
||||||
|
#define LAUNCH_QUEUE_SIZE (10)
|
||||||
|
#define LAUNCH_QUEUE_FULL (-1)
|
||||||
|
|
||||||
|
#define LAUNCH_QUEUE_ARG_SIZE_MAX (0x8000)
|
||||||
|
|
||||||
|
typedef struct launch_item_t {
|
||||||
|
u64 tid;
|
||||||
|
u64 arg_size;
|
||||||
|
char args[LAUNCH_QUEUE_ARG_SIZE_MAX];
|
||||||
|
} launch_item_t;
|
||||||
|
|
||||||
|
Result launch_queue_add(launch_item_t item);
|
||||||
|
int launch_queue_get_index(u64 TID);
|
||||||
|
int launch_queue_get_free_index(u64 TID = 0);
|
||||||
|
bool launch_queue_contains(u64 TID);
|
||||||
|
void launch_queue_clear();
|
Loading…
Reference in a new issue