mirror of
https://github.com/ps5-linux/ps5-linux-loader.git
synced 2026-05-12 09:41:59 +00:00
devkit ram support
This commit is contained in:
@@ -42,6 +42,7 @@ struct linux_info {
|
||||
size_t initrd_size;
|
||||
size_t vram_size;
|
||||
char cmdline[2048];
|
||||
int kit_type;
|
||||
uintptr_t linux_info; // PA of linux_info
|
||||
};
|
||||
|
||||
@@ -156,4 +157,17 @@ void enter_rest_mode(void);
|
||||
#define DEBUG_PRINT(fmt, ...)
|
||||
#endif
|
||||
|
||||
|
||||
bool if_exists(const char* path);
|
||||
bool sceKernelIsTestKit(void);
|
||||
bool sceKernelIsDevKit(void);
|
||||
|
||||
enum kit_type {
|
||||
KIT_RETAIL,
|
||||
KIT_TESTKIT,
|
||||
KIT_DEVKIT
|
||||
};
|
||||
|
||||
enum kit_type get_kit_type(void);
|
||||
|
||||
#endif
|
||||
|
||||
@@ -12,6 +12,7 @@ struct linux_info {
|
||||
size_t initrd_size;
|
||||
size_t vram_size;
|
||||
char cmdline[2048];
|
||||
int kit_type;
|
||||
};
|
||||
|
||||
static struct linux_info info;
|
||||
@@ -88,8 +89,16 @@ static void e820_memory_setup(struct boot_params *bp) {
|
||||
append_e820_table(bp, 0x0f0000000, 0x0f8000000, E820_TYPE_RESERVED);
|
||||
append_e820_table(bp, 0x100000000, VRAM_BASE, E820_TYPE_RAM);
|
||||
append_e820_table(bp, VRAM_BASE, 0x470000000, E820_TYPE_RESERVED); // VRAM
|
||||
append_e820_table(bp, 0x470000000, 0x47f300000, E820_TYPE_RAM);
|
||||
append_e820_table(bp, 0x47f300000, 0x480000000, E820_TYPE_RESERVED);
|
||||
|
||||
// DevKits have 32GB
|
||||
if (info.kit_type != KIT_DEVKIT) {
|
||||
append_e820_table(bp, 0x470000000, 0x47f300000, E820_TYPE_RAM);
|
||||
append_e820_table(bp, 0x47f300000, 0x480000000, E820_TYPE_RESERVED);
|
||||
}
|
||||
else {
|
||||
append_e820_table(bp, 0x470000000, 0x87f300000, E820_TYPE_RAM);
|
||||
append_e820_table(bp, 0x87f300000, 0x880000000, E820_TYPE_RESERVED);
|
||||
}
|
||||
}
|
||||
|
||||
void boot_linux(void) {
|
||||
@@ -124,7 +133,7 @@ void boot_linux(void) {
|
||||
|
||||
memcpy((void *)kernel_pa, (void *)(info.bzimage + setup_size), kernel_size);
|
||||
|
||||
// printf("This is kernel_pa: "); print_val64(kernel_pa); printf("\n");
|
||||
|
||||
void (*startup_64)(uint64_t physaddr, struct boot_params *bp) =
|
||||
(void *)(kernel_pa + 0x200);
|
||||
startup_64(kernel_pa, bp);
|
||||
|
||||
@@ -44,3 +44,9 @@
|
||||
|
||||
void entry(void);
|
||||
void boot_linux(void);
|
||||
|
||||
enum kit_type {
|
||||
KIT_RETAIL,
|
||||
KIT_TESTKIT,
|
||||
KIT_DEVKIT
|
||||
};
|
||||
@@ -46,6 +46,7 @@ struct linux_info {
|
||||
size_t initrd_size;
|
||||
size_t vram_size;
|
||||
char cmdline[2048];
|
||||
int kit_type;
|
||||
};
|
||||
|
||||
static struct linux_info info;
|
||||
|
||||
@@ -220,6 +220,7 @@ int fetch_linux(struct linux_info *info) {
|
||||
info->initrd_size = initrd_size;
|
||||
info->vram_size = vram_size;
|
||||
strcpy(info->cmdline, cmdline);
|
||||
info->kit_type = (int) get_kit_type();
|
||||
|
||||
uint64_t page = alloc_page();
|
||||
kwrite(pa_to_dmap(page), info, sizeof(struct linux_info));
|
||||
|
||||
@@ -5,8 +5,8 @@ offset_list off_0300 = {
|
||||
.HV_VCPU_ARRAY_OFF = 0x5D0,
|
||||
.HV_VCPU_STRIDE = 0x320,
|
||||
.HV_VCPU_VMCB_PTR = 0x08,
|
||||
.KERNEL_CODE_CAVE = 0x0043000,
|
||||
.KERNEL_DATA_CAVE = 0x0043000 + 0xBBE300,
|
||||
.KERNEL_CODE_CAVE = 0x500,
|
||||
.KERNEL_DATA_CAVE = 0xC01300,
|
||||
.IOMMU_SOFTC = 0x33175E0,
|
||||
.VMSPACE_VM_VMID = 0x1E4,
|
||||
.VMSPACE_VM_PMAP = 0x1D0,
|
||||
@@ -37,8 +37,8 @@ offset_list off_0310 = {
|
||||
.HV_VCPU_ARRAY_OFF = 0x5D0,
|
||||
.HV_VCPU_STRIDE = 0x320,
|
||||
.HV_VCPU_VMCB_PTR = 0x08,
|
||||
.KERNEL_CODE_CAVE = 0x0043000,
|
||||
.KERNEL_DATA_CAVE = 0x0043000 + 0xBBE300,
|
||||
.KERNEL_CODE_CAVE = 0x500,
|
||||
.KERNEL_DATA_CAVE = 0xC01300,
|
||||
.IOMMU_SOFTC = 0x33175E0,
|
||||
.VMSPACE_VM_VMID = 0x1E4,
|
||||
.VMSPACE_VM_PMAP = 0x1D0,
|
||||
@@ -69,8 +69,8 @@ offset_list off_0320 = {
|
||||
.HV_VCPU_ARRAY_OFF = 0x5D0,
|
||||
.HV_VCPU_STRIDE = 0x320,
|
||||
.HV_VCPU_VMCB_PTR = 0x08,
|
||||
.KERNEL_CODE_CAVE = 0x0043000,
|
||||
.KERNEL_DATA_CAVE = 0x0043000 + 0xBBE300,
|
||||
.KERNEL_CODE_CAVE = 0x500,
|
||||
.KERNEL_DATA_CAVE = 0xC01300,
|
||||
.IOMMU_SOFTC = 0x33175E0,
|
||||
.VMSPACE_VM_VMID = 0x1E4,
|
||||
.VMSPACE_VM_PMAP = 0x1D0,
|
||||
@@ -101,8 +101,8 @@ offset_list off_0321 = {
|
||||
.HV_VCPU_ARRAY_OFF = 0x5D0,
|
||||
.HV_VCPU_STRIDE = 0x320,
|
||||
.HV_VCPU_VMCB_PTR = 0x08,
|
||||
.KERNEL_CODE_CAVE = 0x0043000,
|
||||
.KERNEL_DATA_CAVE = 0x0043000 + 0xBBE300,
|
||||
.KERNEL_CODE_CAVE = 0x500,
|
||||
.KERNEL_DATA_CAVE = 0xC01300,
|
||||
.IOMMU_SOFTC = 0x33175E0,
|
||||
.VMSPACE_VM_VMID = 0x1E4,
|
||||
.VMSPACE_VM_PMAP = 0x1D0,
|
||||
@@ -133,8 +133,8 @@ offset_list off_0400 = {
|
||||
.HV_VCPU_ARRAY_OFF = 0x5D0,
|
||||
.HV_VCPU_STRIDE = 0x320,
|
||||
.HV_VCPU_VMCB_PTR = 0x08,
|
||||
.KERNEL_CODE_CAVE = 0x0043000,
|
||||
.KERNEL_DATA_CAVE = 0x0043000 + 0xBBE300,
|
||||
.KERNEL_CODE_CAVE = 0x500,
|
||||
.KERNEL_DATA_CAVE = 0xC01300,
|
||||
.IOMMU_SOFTC = 0x33C7680,
|
||||
.VMSPACE_VM_VMID = 0x1E4,
|
||||
.VMSPACE_VM_PMAP = 0x1D0,
|
||||
@@ -165,8 +165,8 @@ offset_list off_0402 = {
|
||||
.HV_VCPU_ARRAY_OFF = 0x5D0,
|
||||
.HV_VCPU_STRIDE = 0x320,
|
||||
.HV_VCPU_VMCB_PTR = 0x08,
|
||||
.KERNEL_CODE_CAVE = 0x0043000,
|
||||
.KERNEL_DATA_CAVE = 0x0043000 + 0xBBE300,
|
||||
.KERNEL_CODE_CAVE = 0x500,
|
||||
.KERNEL_DATA_CAVE = 0xC01300,
|
||||
.IOMMU_SOFTC = 0x33C7680,
|
||||
.VMSPACE_VM_VMID = 0x1E4,
|
||||
.VMSPACE_VM_PMAP = 0x1D0,
|
||||
@@ -198,7 +198,7 @@ offset_list off_0403 = {
|
||||
.HV_VCPU_STRIDE = 0x320,
|
||||
.HV_VCPU_VMCB_PTR = 0x08,
|
||||
.KERNEL_CODE_CAVE = 0x500,
|
||||
.KERNEL_DATA_CAVE = 0x0043000 + 0xBBE300,
|
||||
.KERNEL_DATA_CAVE = 0xC01300,
|
||||
.IOMMU_SOFTC = 0x33C7680,
|
||||
.VMSPACE_VM_VMID = 0x1E4,
|
||||
.VMSPACE_VM_PMAP = 0x1D0,
|
||||
@@ -229,8 +229,8 @@ offset_list off_0450 = {
|
||||
.HV_VCPU_ARRAY_OFF = 0x5D0,
|
||||
.HV_VCPU_STRIDE = 0x320,
|
||||
.HV_VCPU_VMCB_PTR = 0x08,
|
||||
.KERNEL_CODE_CAVE = 0x0043000,
|
||||
.KERNEL_DATA_CAVE = 0x0043000 + 0xBBE300,
|
||||
.KERNEL_CODE_CAVE = 0x500,
|
||||
.KERNEL_DATA_CAVE = 0xC01300,
|
||||
.IOMMU_SOFTC = 0x33C7680,
|
||||
.VMSPACE_VM_VMID = 0x1E4,
|
||||
.VMSPACE_VM_PMAP = 0x1D0,
|
||||
@@ -261,8 +261,8 @@ offset_list off_0451 = {
|
||||
.HV_VCPU_ARRAY_OFF = 0x5D0,
|
||||
.HV_VCPU_STRIDE = 0x320,
|
||||
.HV_VCPU_VMCB_PTR = 0x08,
|
||||
.KERNEL_CODE_CAVE = 0x0043000,
|
||||
.KERNEL_DATA_CAVE = 0x0043000 + 0xBBE300,
|
||||
.KERNEL_CODE_CAVE = 0x500,
|
||||
.KERNEL_DATA_CAVE = 0xC01300,
|
||||
.IOMMU_SOFTC = 0x33C7680,
|
||||
.VMSPACE_VM_VMID = 0x1E4,
|
||||
.VMSPACE_VM_PMAP = 0x1D0,
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
#include <sys/param.h>
|
||||
#include <sys/proc.h>
|
||||
#include <unistd.h>
|
||||
#include <sys/stat.h>
|
||||
|
||||
/* Global Variables */
|
||||
offset_list env_offset;
|
||||
@@ -247,4 +248,32 @@ void enter_rest_mode(void) {
|
||||
sceKernelNotifySystemSuspendStart();
|
||||
sceKernelSetEventFlag(event, 0x400);
|
||||
sceKernelCloseEventFlag(&event);
|
||||
}
|
||||
|
||||
|
||||
// Kit type by EchoStretch
|
||||
bool if_exists(const char* path) {
|
||||
struct stat st;
|
||||
return stat(path, &st) == 0;
|
||||
}
|
||||
|
||||
bool sceKernelIsTestKit(void) {
|
||||
return if_exists("/system/priv/lib/libSceDeci5Ttyp.sprx");
|
||||
}
|
||||
|
||||
bool sceKernelIsDevKit(void) {
|
||||
return if_exists("/system/priv/lib/libSceDeci5Dtracep.sprx");
|
||||
}
|
||||
|
||||
enum kit_type get_kit_type(void) {
|
||||
if (sceKernelIsDevKit()) {
|
||||
notify("DevKit detected\n");
|
||||
return KIT_DEVKIT;
|
||||
}
|
||||
if (sceKernelIsTestKit()) {
|
||||
notify("TestKit detected\n");
|
||||
return KIT_TESTKIT;
|
||||
}
|
||||
notify("Retail console detected\n");
|
||||
return KIT_RETAIL;
|
||||
}
|
||||
Reference in New Issue
Block a user