mirror of
https://github.com/Atmosphere-NX/Atmosphere
synced 2024-12-22 20:31:14 +00:00
fusee: support passing target firmware to kernel loader.
This commit is contained in:
parent
a25be61e94
commit
9b677c81a5
3 changed files with 9 additions and 3 deletions
|
@ -855,7 +855,7 @@ const kernel_info_t *get_kernel_info(void *kernel, size_t size) {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
void package2_patch_kernel(void *_kernel, size_t *kernel_size, bool is_sd_kernel, void **out_ini1) {
|
void package2_patch_kernel(void *_kernel, size_t *kernel_size, bool is_sd_kernel, void **out_ini1, uint32_t target_firmware) {
|
||||||
const kernel_info_t *kernel_info = get_kernel_info(_kernel, *kernel_size);
|
const kernel_info_t *kernel_info = get_kernel_info(_kernel, *kernel_size);
|
||||||
*out_ini1 = NULL;
|
*out_ini1 = NULL;
|
||||||
|
|
||||||
|
@ -876,6 +876,12 @@ void package2_patch_kernel(void *_kernel, size_t *kernel_size, bool is_sd_kernel
|
||||||
const uint32_t kernel_ldr_offset = *((volatile uint64_t *)((uintptr_t)_kernel + kernel_info->embedded_ini_ptr + 8));
|
const uint32_t kernel_ldr_offset = *((volatile uint64_t *)((uintptr_t)_kernel + kernel_info->embedded_ini_ptr + 8));
|
||||||
memcpy((void *)((uintptr_t)_kernel + kernel_ldr_offset), kernel_ldr_bin, kernel_ldr_bin_size);
|
memcpy((void *)((uintptr_t)_kernel + kernel_ldr_offset), kernel_ldr_bin, kernel_ldr_bin_size);
|
||||||
|
|
||||||
|
/* Set target firmware for our kernel loader. */
|
||||||
|
uint32_t *kldr_u32 = (uint32_t *)((uintptr_t)_kernel + kernel_ldr_offset);
|
||||||
|
if (kldr_u32[1] == 0x30444C4D) {
|
||||||
|
kldr_u32[2] = target_firmware;
|
||||||
|
}
|
||||||
|
|
||||||
/* Update size. */
|
/* Update size. */
|
||||||
*kernel_size = kernel_ldr_offset + kernel_ldr_bin_size;
|
*kernel_size = kernel_ldr_offset + kernel_ldr_bin_size;
|
||||||
|
|
||||||
|
|
|
@ -19,6 +19,6 @@
|
||||||
|
|
||||||
#include "utils.h"
|
#include "utils.h"
|
||||||
|
|
||||||
void package2_patch_kernel(void *kernel, size_t *kernel_size, bool is_sd_kernel, void **out_ini1);
|
void package2_patch_kernel(void *kernel, size_t *kernel_size, bool is_sd_kernel, void **out_ini1, uint32_t target_firmware);
|
||||||
|
|
||||||
#endif
|
#endif
|
|
@ -87,7 +87,7 @@ void package2_rebuild_and_copy(package2_header_t *package2, uint32_t target_firm
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Perform any patches we want to the NX kernel. */
|
/* Perform any patches we want to the NX kernel. */
|
||||||
package2_patch_kernel(kernel, &kernel_size, is_sd_kernel, (void *)&orig_ini1);
|
package2_patch_kernel(kernel, &kernel_size, is_sd_kernel, (void *)&orig_ini1, target_firmware);
|
||||||
|
|
||||||
/* Ensure we know where embedded INI is if present, and we don't if not. */
|
/* Ensure we know where embedded INI is if present, and we don't if not. */
|
||||||
if ((target_firmware < ATMOSPHERE_TARGET_FIRMWARE_800 && orig_ini1 != NULL) ||
|
if ((target_firmware < ATMOSPHERE_TARGET_FIRMWARE_800 && orig_ini1 != NULL) ||
|
||||||
|
|
Loading…
Reference in a new issue