Files
palera1n/src/pongo_helper.c
T

61 lines
1.9 KiB
C
Raw Normal View History

2023-01-25 21:22:42 +08:00
#include <errno.h>
#include <fcntl.h> // open
#include <pthread.h>
#include <stdbool.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h> // exit, strtoull
#include <string.h> // strlen, strerror, memcpy, memmove
#include <unistd.h> // close
#include <sys/mman.h> // mmap, munmap
#include <sys/stat.h> // fstst
2023-01-28 20:54:06 +08:00
#include <common.h>
2023-01-25 21:22:42 +08:00
int found_pongo = 0;
void* pongo_helper(void* ptr) {
pongo_thr_running = 1;
pthread_cleanup_push(thr_cleanup, &pongo_thr_running);
wait_for_pongo();
while (spin) {
sleep(1);
}
pthread_cleanup_pop(1);
return NULL;
}
void *pongo_usb_callback(void *arg) {
if (found_pongo)
return NULL;
found_pongo = 1;
2023-01-29 01:02:47 +08:00
strncat(xargs_cmd, " rootdev=md0", 0x270 - strlen(xargs_cmd) - 1);
2023-01-27 21:24:46 +08:00
if (checkrain_option_enabled(palerain_flags, palerain_option_setup_rootful)) {
2023-01-29 01:02:47 +08:00
strncat(xargs_cmd, " wdt=-1", 0x270 - strlen(xargs_cmd) - 1);
2023-01-27 21:24:46 +08:00
}
2023-01-25 21:22:42 +08:00
LOG(LOG_INFO, "Found PongoOS USB Device");
usb_device_handle_t handle = *(usb_device_handle_t *)arg;
issue_pongo_command(handle, NULL);
issue_pongo_command(handle, "fuse lock");
issue_pongo_command(handle, "sep auto");
upload_pongo_file(handle, **kpf_to_upload, checkra1n_kpf_pongo_len);
issue_pongo_command(handle, "modload");
issue_pongo_command(handle, kpf_flags_cmd);
issue_pongo_command(handle, checkrain_flags_cmd);
issue_pongo_command(handle, palerain_flags_cmd);
if (enable_rootful)
{
issue_pongo_command(handle, rootfs_cmd);
issue_pongo_command(handle, dtpatch_cmd);
}
upload_pongo_file(handle, **ramdisk_to_upload, ramdisk_dmg_len);
issue_pongo_command(handle, "ramdisk");
upload_pongo_file(handle, **overlay_to_upload, binpack_dmg_len);
issue_pongo_command(handle, "overlay");
issue_pongo_command(handle, xargs_cmd);
issue_pongo_command(handle, "kpf");
issue_pongo_command(handle, "bootux");
LOG(LOG_INFO, "Booting Kernel...");
spin = false;
return NULL;
}