Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 22 additions & 14 deletions src/ctrl/pspctrl.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,13 @@ extern "C" {
* @see ::SceCtrlData
* @see ::SceCtrlLatch
*/
enum PspCtrlButtons
{
enum PspCtrlButtons {
/** Select button. */
PSP_CTRL_SELECT = 0x000001,
/** L3 button. */
PSP_CTRL_L3 = 0x000002,
/** R3 button. */
PSP_CTRL_R3 = 0x000004,
/** Start button. */
PSP_CTRL_START = 0x000008,
/** Up D-Pad button. */
Expand All @@ -58,6 +61,14 @@ enum PspCtrlButtons
PSP_CTRL_LTRIGGER = 0x000100,
/** Right trigger. */
PSP_CTRL_RTRIGGER = 0x000200,
/** L2 button. */
PSP_CTRL_L2 = 0x000100,
/** R2 button. */
PSP_CTRL_R2 = 0x000200,
/** L1 button. */
PSP_CTRL_L1 = 0x000400,
/** R1 button. */
PSP_CTRL_R1 = 0x000800,
/** Triangle button. */
PSP_CTRL_TRIANGLE = 0x001000,
/** Circle button. */
Expand All @@ -66,28 +77,25 @@ enum PspCtrlButtons
PSP_CTRL_CROSS = 0x004000,
/** Square button. */
PSP_CTRL_SQUARE = 0x008000,
/**
* Kernel mode: Home button state.
* User mode: Exit dialog visible.
*/
/** Home button. In user mode this bit is set if the exit dialog is visible. */
PSP_CTRL_HOME = 0x010000,
/** Hold button. */
PSP_CTRL_HOLD = 0x020000,
/** Music note button - kernel mode only.*/
/** Music Note button. */
PSP_CTRL_NOTE = 0x800000,
/** Screen button - kernel mode only.*/
/** Screen button. */
PSP_CTRL_SCREEN = 0x400000,
/** Volume up button - kernel mode only.*/
/** Volume up button. */
PSP_CTRL_VOLUP = 0x100000,
/** Volume down button - kernel mode only.*/
/** Volume down button. */
PSP_CTRL_VOLDOWN = 0x200000,
/** Wlan switch up - kernel mode only.*/
/** Wlan switch up. */
PSP_CTRL_WLAN_UP = 0x040000,
/** Remote hold position - kernel mode only.*/
/** Remote hold position. */
PSP_CTRL_REMOTE = 0x080000,
/** Disc present - kernel mode only.*/
/** Disc present. */
PSP_CTRL_DISC = 0x1000000,
/** Memory stick present - kernel mode only.*/
/** Memory stick present. */
PSP_CTRL_MS = 0x2000000,
};

Expand Down
24 changes: 12 additions & 12 deletions src/kernel/InitForKernel.S
Original file line number Diff line number Diff line change
Expand Up @@ -6,35 +6,35 @@
IMPORT_START "InitForKernel",0x00090000
#endif
#ifdef F_InitForKernel_0001
IMPORT_FUNC "InitForKernel",0x1D3256BA,sceKernelRegisterChunk
IMPORT_FUNC "InitForKernel",0x1D3256BA,sceKernelRegisterChunk
#endif
#ifdef F_InitForKernel_0002
IMPORT_FUNC "InitForKernel",0x27932388,sceKernelBootFrom
IMPORT_FUNC "InitForKernel",0x27932388,sceKernelBootFrom
#endif
#ifdef F_InitForKernel_0003
IMPORT_FUNC "InitForKernel",0x2C6E9FE9,sceKernelGetChunk
IMPORT_FUNC "InitForKernel",0x2C6E9FE9,sceKernelGetChunk
#endif
#ifdef F_InitForKernel_0004
IMPORT_FUNC "InitForKernel",0x33D30F49,InitForKernel_33D30F49
IMPORT_FUNC "InitForKernel",0x33D30F49,InitForKernel_33D30F49
#endif
#ifdef F_InitForKernel_0005
IMPORT_FUNC "InitForKernel",0x7233B5BC,InitForKernel_7233B5BC
IMPORT_FUNC_WITH_ALIAS "InitForKernel",0x7233B5BC,sceKernelApplicationType,sceKernelInitKeyConfig
#endif
#ifdef F_InitForKernel_0006
IMPORT_FUNC "InitForKernel",0x7A2333AD,sceKernelInitApitype
IMPORT_FUNC "InitForKernel",0x7A2333AD,sceKernelInitApitype
#endif
#ifdef F_InitForKernel_0007
IMPORT_FUNC "InitForKernel",0x9F9AE99C,InitForKernel_9F9AE99C
IMPORT_FUNC "InitForKernel",0x9F9AE99C,InitForKernel_9F9AE99C
#endif
#ifdef F_InitForKernel_0008
IMPORT_FUNC "InitForKernel",0xA6E71B93,sceKernelInitFileName
IMPORT_FUNC "InitForKernel",0xA6E71B93,sceKernelInitFileName
#endif
#ifdef F_InitForKernel_0009
IMPORT_FUNC "InitForKernel",0xC4F1BA33,InitForKernel_C4F1BA33
IMPORT_FUNC "InitForKernel",0xC4F1BA33,InitForKernel_C4F1BA33
#endif
#ifdef F_InitForKernel_0010
IMPORT_FUNC "InitForKernel",0xCE88E870,sceKernelReleaseChunk
IMPORT_FUNC "InitForKernel",0xCE88E870,sceKernelReleaseChunk
#endif
#ifdef F_InitForKernel_0011
IMPORT_FUNC "InitForKernel",0xFD0F25AD,InitForKernel_FD0F25AD
#endif
IMPORT_FUNC "InitForKernel",0xFD0F25AD,InitForKernel_FD0F25AD
#endif
3 changes: 2 additions & 1 deletion src/kernel/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,8 @@ libpspkernelinclude_HEADERS = \
pspexception.h \
pspsysclib.h \
pspimpose_driver.h \
pspinit.h \
pspinit.h \
pspamctrl.h \
pspaudiorouting.h

lib_LIBRARIES = libpspkernel.a
Expand Down
77 changes: 77 additions & 0 deletions src/kernel/pspamctrl.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
/*
* PSP Software Development Kit - http://www.pspdev.org
* -----------------------------------------------------------------------
* Licensed under the BSD license, see LICENSE in PSPSDK root for details.
*
* pspamctrl.h - Prototypes for the sceAmctrl_driver library.
*
* Copyright (c) 2024 GrayJack <gr41.j4ck@gmail.com>
*
* TODO: Contribute this header to PSPSDK
*/

#ifndef _PSP_AM_CTRL_H
#define _PSP_AM_CTRL_H

#include <psptypes.h>

#ifdef __cplusplus
extern "C" {
#endif // __cplusplus


typedef struct SceMacKey {
int type;
u8 key[16];
u8 pad[16];
int pad_size;
} SceMacKey;

typedef struct SceCipherKey {
u32 type;
u32 seed;
u8 key[16];
} SceCipherKey;

enum SceMacKeyType {
MAC_KEY_TYPE_UNK0 = 0,
MAC_KEY_TYPE_UNK1 = 1,
/** Use fuse ID */
MAC_KEY_TYPE_FUSE_ID = 2,
/** Use fixed key. MAC will need to encrypt again. */
MAC_KEY_TYPE_FIXED = 3,
MAC_KEY_TYPE_UNK6 = 6,
};

enum SceCipherKeyType {
/** Use fixed key */
CIPHER_KEY_TYPE_FIXED = 1,
/** Use fuse ID */
CIPHER_KEY_TYPE_FUSE_ID = 2,
};

enum SceCipherKeyMode {
CIPHER_KEY_MODE_ENCRYPT = 1,
CIPHER_KEY_MODE_DECRYPT = 2,
};

#ifdef __KERNEL__

int sceDrmBBMacInit(SceMacKey *mac_key, int type);
int sceDrmBBMacUpdate(SceMacKey *mac_key, u8 *buf, int size);
int sceAmctrl_driver_9227EA79(SceMacKey *mac_key, u8 *buf, int size);
int sceDrmBBMacFinal(SceMacKey *mac_key, u8 *buf, u8 *version_key);
int sceDrmBBMacFinal2(SceMacKey *mac_key, u8 *buf, u8 *version_key);

int sceDrmBBCipherInit(SceCipherKey *cipher_key, int type, int mode, u8 *header_key, u8 *version_key, int seed);
int sceDrmBBCipherUpdate(SceCipherKey *cipher_key, u8 *buf, int size);
int sceAmctrl_driver_E04ADD4C(SceCipherKey *cipher_key, u8 *buf, int size);
int sceDrmBBCipherFinal(SceCipherKey *cipher_key);

#endif // __KERNEL__

#ifdef __cplusplus
}
#endif // __cplusplus

#endif // AM_CTRL_H
Loading