mirror of
https://github.com/joel16/PSP-Everest.git
synced 2024-11-26 21:10:39 +00:00
kernel: Get model via kernel plugin instead of using kubridge for one function
This commit is contained in:
parent
e51997b035
commit
8cd3b1509e
2
.gitignore
vendored
2
.gitignore
vendored
@ -38,7 +38,7 @@
|
||||
*.PBP
|
||||
app/*.prx
|
||||
app/*.SFO
|
||||
app/data/everest_kernel.prx
|
||||
app/data/kernel.prx
|
||||
app/data/kumdman.prx
|
||||
|
||||
# Debug files
|
||||
|
2
Makefile
2
Makefile
@ -1,4 +1,4 @@
|
||||
SUBDIRS = plugin/everest_kernel plugin/kumdman app
|
||||
SUBDIRS = plugin/kernel plugin/kumdman app
|
||||
|
||||
all:
|
||||
@for dir in $(SUBDIRS); do $(MAKE) -C $$dir; done
|
||||
|
@ -1,182 +0,0 @@
|
||||
#ifndef __KULIBRARY__
|
||||
#define __KULIBRARY__
|
||||
|
||||
#if defined (__cplusplus)
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include <pspsdk.h>
|
||||
#include <pspkernel.h>
|
||||
#include <pspsysmem_kernel.h>
|
||||
#include <pspctrl.h>
|
||||
|
||||
/**
|
||||
* Functions to let user mode access certain functions only available in
|
||||
* kernel mode
|
||||
*/
|
||||
|
||||
/**
|
||||
* Load a module using ModuleMgrForKernel.
|
||||
*
|
||||
* @param path - The path to the module to load.
|
||||
* @param flags - Unused, always 0 .
|
||||
* @param option - Pointer to a mod_param_t structure. Can be NULL.
|
||||
*
|
||||
* @returns The UID of the loaded module on success, otherwise one of ::PspKernelErrorCodes.
|
||||
*/
|
||||
SceUID kuKernelLoadModule(const char *path, int flags, SceKernelLMOption *option);
|
||||
|
||||
|
||||
/**
|
||||
* Load a module with a specific apitype
|
||||
*
|
||||
* @param ap<EFBFBD>type - The apitype
|
||||
* @param path - The path to the module to load.
|
||||
* @param flags - Unused, always 0 .
|
||||
* @param option - Pointer to a mod_param_t structure. Can be NULL.
|
||||
*
|
||||
* @returns The UID of the loaded module on success, otherwise one of ::PspKernelErrorCodes.
|
||||
*/
|
||||
SceUID kuKernelLoadModuleWithApitype2(int apitype, const char *path, int flags, SceKernelLMOption *option);
|
||||
|
||||
/**
|
||||
* Gets the api type
|
||||
*
|
||||
* @returns the api type in which the system has booted
|
||||
*/
|
||||
int kuKernelInitApitype();
|
||||
|
||||
/**
|
||||
* Gets the filename of the executable to be launched after all modules of the api.
|
||||
*
|
||||
* @param initfilename - String where copy the initfilename
|
||||
* @returns 0 on success
|
||||
*/
|
||||
int kuKernelInitFileName(char *initfilename);
|
||||
|
||||
/**
|
||||
*
|
||||
* Gets the device in which the application was launched.
|
||||
*
|
||||
* @returns the device code, one of PSPBootFrom values.
|
||||
*/
|
||||
int kuKernelBootFrom();
|
||||
|
||||
/**
|
||||
* Get the key configuration in which the system has booted.
|
||||
*
|
||||
* @returns the key configuration code, one of PSPKeyConfig values
|
||||
*/
|
||||
int kuKernelInitKeyConfig();
|
||||
|
||||
/**
|
||||
* Get the user level of the current thread
|
||||
*
|
||||
* @return The user level, < 0 on error
|
||||
*/
|
||||
int kuKernelGetUserLevel(void);
|
||||
|
||||
/**
|
||||
* Set the protection of a block of ddr memory
|
||||
*
|
||||
* @param addr - Address to set protection on
|
||||
* @param size - Size of block
|
||||
* @param prot - Protection bitmask
|
||||
*
|
||||
* @return < 0 on error
|
||||
*/
|
||||
int kuKernelSetDdrMemoryProtection(void *addr, int size, int prot);
|
||||
|
||||
/**
|
||||
* Gets the model of the PSP from user mode.
|
||||
* This function is available since 3.60 M33.
|
||||
* In previous version, use the kernel function sceKernelGetModel
|
||||
*
|
||||
* @return one of PspModel values
|
||||
*/
|
||||
int kuKernelGetModel(void);
|
||||
|
||||
/**
|
||||
* Find module by name
|
||||
*
|
||||
* @param modname - Name of Module
|
||||
* @param mod - module structure for output (actually treated as SceModule2)
|
||||
*
|
||||
* @return < 0 on error
|
||||
*/
|
||||
int kuKernelFindModuleByName(char *modname, SceModule *mod);
|
||||
|
||||
/**
|
||||
* Invalidate the entire instruction cache
|
||||
*/
|
||||
void kuKernelIcacheInvalidateAll(void);
|
||||
|
||||
/**
|
||||
* Read 4 bytes from memory (with kernel memory access)
|
||||
*
|
||||
* @param addr - Address to read, must have 4 bytes alignment
|
||||
*/
|
||||
u32 kuKernelPeekw(void *addr);
|
||||
|
||||
/**
|
||||
* Write 4 bytes to memory (with kernel memory access)
|
||||
*
|
||||
* @param addr - Address to write, must have 4 bytes alignment
|
||||
*/
|
||||
void kuKernelPokew(void *addr, u32 value);
|
||||
|
||||
/**
|
||||
* memcpy (with kernel memory access)
|
||||
*
|
||||
* @param dest - Destination address
|
||||
* @param src - Source address
|
||||
* @param num - copy bytes count
|
||||
*
|
||||
* @return Destination address
|
||||
*/
|
||||
void *kuKernelMemcpy(void *dest, const void *src, size_t num);
|
||||
|
||||
struct KernelCallArg {
|
||||
u32 arg1;
|
||||
u32 arg2;
|
||||
u32 arg3;
|
||||
u32 arg4;
|
||||
u32 arg5;
|
||||
u32 arg6;
|
||||
u32 arg7;
|
||||
u32 arg8;
|
||||
u32 arg9;
|
||||
u32 arg10;
|
||||
u32 arg11;
|
||||
u32 arg12;
|
||||
u32 ret1;
|
||||
u32 ret2;
|
||||
};
|
||||
|
||||
/**
|
||||
* Call a kernel function with kernel privilege
|
||||
*
|
||||
* @param func_addr - kernel function address
|
||||
* @param args - kernel arguments and return values
|
||||
*
|
||||
* return < 0 on error
|
||||
*/
|
||||
int kuKernelCall(void *func_addr, struct KernelCallArg *args);
|
||||
|
||||
/**
|
||||
* Call a kernel function with kernel privilege and extended stack
|
||||
*
|
||||
* @param func_addr - kernel function address
|
||||
* @param args - kernel arguments and return values
|
||||
*
|
||||
* return < 0 on error
|
||||
*/
|
||||
int kuKernelCallExtendStack(void *func_addr, struct KernelCallArg *args, int stack_size);
|
||||
|
||||
void kuKernelGetUmdFile(char *umdfile, int size);
|
||||
|
||||
#if defined (__cplusplus)
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
@ -1,6 +1,10 @@
|
||||
#ifndef __VLF_H__
|
||||
#define __VLF_H__
|
||||
|
||||
#if defined (__cplusplus)
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
typedef struct _VlfText *VlfText;
|
||||
typedef struct _VlfPicture *VlfPicture;
|
||||
typedef struct _VlfShadowedPicture *VlfShadowedPicture;
|
||||
@ -773,7 +777,7 @@ VlfPicture vlfGuiAddPictureFile(char *file, int x, int y);
|
||||
*
|
||||
* @returns - a new VlfPivture on success, NULL on error
|
||||
*/
|
||||
VlfPicture vlfGuiAddPictureResource(char *rco, char *name, int x, int y);
|
||||
VlfPicture vlfGuiAddPictureResource(const char *rco, const char *name, int x, int y);
|
||||
|
||||
/**
|
||||
* Removes a picture
|
||||
@ -1795,7 +1799,7 @@ void vlfGuiCancelBottomDialog();
|
||||
*
|
||||
* @returns - < 0 on error
|
||||
*/
|
||||
int vlfGuiCentralMenu(int noptions, char **items, int defaultsel, int (* handler)(int sel), int dispx, int dispy);
|
||||
int vlfGuiCentralMenu(int noptions, const char **items, int defaultsel, int (* handler)(int sel), int dispx, int dispy);
|
||||
|
||||
/**
|
||||
* Cancels (remove) the central menu
|
||||
@ -2029,7 +2033,8 @@ int vlfGuiSetEventDelayEx(int (* func)(void *), void * param, u32 delay);
|
||||
*/
|
||||
int vlfGuiDelayAllEvents(u32 delay);
|
||||
|
||||
|
||||
|
||||
#if defined (__cplusplus)
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
Binary file not shown.
@ -1,5 +1,5 @@
|
||||
TARGET = everest_kernel
|
||||
OBJS = everest_kernel.o imports.o exports.o
|
||||
TARGET = kernel
|
||||
OBJS = kernel.o imports.o exports.o
|
||||
|
||||
PRX_EXPORTS = exports.exp
|
||||
|
||||
@ -21,5 +21,5 @@ include $(PSPSDK)/lib/build_prx.mak
|
||||
|
||||
all:
|
||||
psp-build-exports -s $(PRX_EXPORTS)
|
||||
mkdir "../../app/data/"; mv everest_kernel.prx "../../app/data/"
|
||||
mkdir "../../app/drivers/"; mv everest_kernel.S "../../app/drivers/"
|
||||
mkdir "../../app/data/"; mv kernel.prx "../../app/data/"
|
||||
mkdir "../../app/drivers/"; mv kernel.S "../../app/drivers/"
|
@ -4,7 +4,7 @@ PSP_BEGIN_EXPORTS
|
||||
PSP_EXPORT_VAR_HASH(module_info)
|
||||
PSP_EXPORT_END
|
||||
|
||||
PSP_EXPORT_START(everest_kernel, 0, 0x4001)
|
||||
PSP_EXPORT_START(kernel, 0, 0x4001)
|
||||
PSP_EXPORT_FUNC_HASH(pspGetBaryonVersion)
|
||||
PSP_EXPORT_FUNC_HASH(pspGetPommelVersion)
|
||||
PSP_EXPORT_FUNC_HASH(pspGetTachyonVersion)
|
||||
@ -25,5 +25,6 @@ PSP_BEGIN_EXPORTS
|
||||
PSP_EXPORT_FUNC_HASH(pspChkregGetPsCode)
|
||||
PSP_EXPORT_FUNC_HASH(pspSysconBatteryGetElec)
|
||||
PSP_EXPORT_FUNC_HASH(pspSysconBatteryGetTotalElec)
|
||||
PSP_EXPORT_FUNC_HASH(pspGetModel)
|
||||
PSP_EXPORT_END
|
||||
PSP_END_EXPORTS
|
@ -5,3 +5,7 @@
|
||||
STUB_START "SystemCtrlForKernel",0x00090000,0x00010005
|
||||
STUB_FUNC 0x159AF5CC,sctrlHENFindFunction
|
||||
STUB_END
|
||||
|
||||
STUB_START "sceChkreg_driver",0x00090000,0x00010005
|
||||
STUB_FUNC 0x59F8491D,sceChkreg_driver_59F8491D
|
||||
STUB_END
|
@ -9,63 +9,13 @@
|
||||
#include <pspsysmem.h>
|
||||
|
||||
#include "systemctrl.h"
|
||||
#include "everest_kernel.h"
|
||||
#include "kernel.h"
|
||||
|
||||
PSP_MODULE_INFO("everest_kernel", 0x1006, 7, 4);
|
||||
PSP_MODULE_INFO("kernel", 0x1006, 1, 1);
|
||||
PSP_MAIN_THREAD_ATTR(0);
|
||||
|
||||
#define MAKE_CALL(f) (0x0C000000 | (((u32)(f) >> 2) & 0x03ffffff))
|
||||
|
||||
/**
|
||||
* This structure represents a unique per-console identifier. It contains console specific information and can be used,
|
||||
* for example, for DRM purposes and simple PSP hardware model checks.
|
||||
*
|
||||
* @remark On the PSP, Sony uses the term "PSID" (not to mixup with the term "OpenPSID" which represents a different set of
|
||||
* unique identifier bits). On later consoles, like the PS Vita and PS4, Sony uses the term "ConsoleId" for this set of
|
||||
* identifier bits. To be consistent within the PS family, we are going with the term "ConsoleId" here, even though APIs like
|
||||
* sceOpenPSIDGetPSID() (which returns the ConsoleId) will remain as originally named by Sony.
|
||||
*/
|
||||
typedef struct {
|
||||
/* Unknown. On retail set to 0. */
|
||||
u16 unk0; // 0
|
||||
/* Company code. Set to 1. */
|
||||
u16 companyCode; // 2
|
||||
/* Product code. */
|
||||
u16 productCode; // 4
|
||||
/* Product sub code. */
|
||||
u16 productSubCode; // 6
|
||||
/* Upper two bit of PsFlags. */
|
||||
u8 psFlagsMajor : 2; // 8
|
||||
/* Factory code. */
|
||||
u8 factoryCode : 6; // 8
|
||||
u8 uniqueIdMajor : 2; // 9
|
||||
/* Lower six bit of the PsFlags. Contain the QA flag, if set. */
|
||||
u8 psFlagsMinor : 6; // 9
|
||||
u8 uniqueIdMinor[6]; // 10
|
||||
} SceConsoleId; // size = 16
|
||||
|
||||
/*
|
||||
* This structure contains the ConsoleId (termed "PSID" on the PSP) and an ECDSA signature used to verify the correctness of the
|
||||
* ConsoleId.
|
||||
* The ConsoleId is used, for example, in PSN DRM, DNAS and system configuration (with its derived PSCode).
|
||||
*/
|
||||
typedef struct {
|
||||
/* Unique per-console identifier. */
|
||||
SceConsoleId consoleId; // 0
|
||||
/* Contains the public key of the certificate. No padding. */
|
||||
u8 plantextPublicKey[0x28]; // 16
|
||||
/* The 'r' part of the ECDSA signature pair (r, s). */
|
||||
u8 r[0x14]; // 56
|
||||
/* The 's' part of the ECDSA signature pair (r, s). */
|
||||
u8 s[0x14]; // 76
|
||||
/* The ECDSA public key (can be used to verify ECDSA signature rs). */
|
||||
u8 publicKey[0x28]; // 96
|
||||
/* Contains the encrypted private key of the certificate (with padding). */
|
||||
u8 encPrivateKey[0x20]; // 136
|
||||
/* Hash of previous data. */
|
||||
u8 hash[0x10]; // 168
|
||||
} SceIdStorageConsoleIdCertificate; // size = 184
|
||||
|
||||
s32 sceSysconGetBaryonVersion(s32 *baryon);
|
||||
s32 sceSysconGetPommelVersion(s32 *pommel);
|
||||
s32 sceSyscon_driver_FB148FB6(s32 *polestar); // sceSysconGetPolestarVersion
|
||||
@ -77,8 +27,7 @@ u32 sceSysconCmdExec(void *param, int unk);
|
||||
int sceSysconBatteryGetElec(int *elec);
|
||||
int sceSyscon_driver_4C539345(int *elec); // sceSysconBatteryGetTotalElec
|
||||
static int (*sceUtilsBufferCopyWithRange)(u8 *outbuff, int outsize, u8 *inbuff, int insize, int cmd);
|
||||
|
||||
static SceIdStorageConsoleIdCertificate g_ConsoleIdCertificate;
|
||||
s32 sceChkreg_driver_59F8491D(ScePsCode *pPsCode);
|
||||
|
||||
static int _sceUtilsBufferCopyWithRange(u8 *outbuff, int outsize, u8 *inbuff, int insize, int cmd) {
|
||||
return (*sceUtilsBufferCopyWithRange)(outbuff, outsize, inbuff, insize, cmd);
|
||||
@ -310,21 +259,23 @@ static u32 pspReadEEPROM(u8 addr) {
|
||||
return (param[0x21] << 8) | param[0x20];
|
||||
}
|
||||
|
||||
static int pspErrCheck(u32 chdata) {
|
||||
if ((chdata & 0x80250000) == 0x80250000) {
|
||||
return -1;
|
||||
}
|
||||
else if (chdata & 0xFFFF0000) {
|
||||
return(chdata & 0xFFFF0000) >> 16;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int pspReadSerial(u16 *pdata) {
|
||||
int err = 0;
|
||||
u32 data;
|
||||
|
||||
u32 k1 = pspSdkSetK1(0);
|
||||
|
||||
int pspErrCheck(u32 chdata) {
|
||||
if ((chdata & 0x80250000) == 0x80250000)
|
||||
return -1;
|
||||
else if (chdata & 0xFFFF0000)
|
||||
return(chdata & 0xFFFF0000) >> 16;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
data = pspReadEEPROM(0x07);
|
||||
err = pspErrCheck(data);
|
||||
|
||||
@ -344,40 +295,10 @@ int pspReadSerial(u16 *pdata) {
|
||||
return err;
|
||||
}
|
||||
|
||||
// Re-implementation of Subroutine sub_000001C4 - Address 0x000001C4 (openpsid.prx)
|
||||
static int sceOpenPSIDLookupAndVerifyConsoleIdCertificate(void) {
|
||||
int ret = 0;
|
||||
const int KIRK_CERT_LEN = 0xB8;
|
||||
|
||||
/* Obtain a ConsoleId certificate. TODO: Use include/idstorage.h for these values once chkreg gets merged */
|
||||
ret = pspIdStorageLookup(0x100, 0x38, &g_ConsoleIdCertificate, KIRK_CERT_LEN);
|
||||
if (ret < 0) {
|
||||
ret = pspIdStorageLookup(0x120, 0x38, &g_ConsoleIdCertificate, KIRK_CERT_LEN);
|
||||
if (ret < 0)
|
||||
return 0xC0520002;
|
||||
}
|
||||
|
||||
int k1 = pspSdkSetK1(0);
|
||||
ret = _sceUtilsBufferCopyWithRange(NULL, 0, (u8 *)&g_ConsoleIdCertificate, KIRK_CERT_LEN, 0x12);
|
||||
pspSdkSetK1(k1);
|
||||
|
||||
if (ret != 0)
|
||||
return 0xC0520001;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
// Reimplementation of Subroutine sceChkreg_driver_59F8491D (without sema) - Address 0x00000438
|
||||
int pspChkregGetPsCode(ScePsCode *pPsCode) {
|
||||
int ret = 0;
|
||||
|
||||
if (((ret = sceOpenPSIDLookupAndVerifyConsoleIdCertificate()) == 0)) {
|
||||
pPsCode->companyCode = g_ConsoleIdCertificate.consoleId.companyCode >> 0x8;
|
||||
pPsCode->productCode = g_ConsoleIdCertificate.consoleId.productCode >> 0x8;
|
||||
pPsCode->productSubCode = g_ConsoleIdCertificate.consoleId.productSubCode >> 0x8;
|
||||
pPsCode->factoryCode = g_ConsoleIdCertificate.consoleId.factoryCode;
|
||||
}
|
||||
|
||||
int k1 = pspSdkSetK1(0);
|
||||
int ret = sceChkreg_driver_59F8491D(pPsCode);
|
||||
pspSdkSetK1(k1);
|
||||
return ret;
|
||||
}
|
||||
|
||||
@ -395,6 +316,13 @@ int pspSysconBatteryGetTotalElec(int *elec) {
|
||||
return ret;
|
||||
}
|
||||
|
||||
int pspGetModel(void) {
|
||||
int k1 = pspSdkSetK1(0);
|
||||
int ret = sceKernelGetModel();
|
||||
pspSdkSetK1(k1);
|
||||
return ret;
|
||||
}
|
||||
|
||||
int module_start(SceSize args __attribute__((unused)), void *argp __attribute__((unused))) {
|
||||
pspPatchMemlmd(sceKernelFindModuleByName("sceMesgLed"));
|
||||
pspSyncCache();
|
Loading…
Reference in New Issue
Block a user