sdk-core v2026.11.05
PS2 SDK - core tier (build-critical EE/IOP modules)
Loading...
Searching...
No Matches
scmd.c File Reference
#include <stdio.h>
#include <kernel.h>
#include <sifrpc.h>
#include <libcdvd.h>
#include <libcdvd-rpc.h>
#include <string.h>
#include <time.h>
#include <osd_config.h>
#include <sys/_tz_structs.h>
#include <iopcontrol.h>
#include "internal.h"

Go to the source code of this file.

Classes

union  sCmdSendParams_t

Macros

#define CD_SERVER_SCMD   0x80000593

Enumerations

enum  CD_SCMD_CMDS {
  CD_SCMD_READCLOCK = 0x01 , CD_SCMD_WRITECLOCK , CD_SCMD_GETDISKTYPE , CD_SCMD_GETERROR ,
  CD_SCMD_TRAYREQ , CD_SCMD_READ_ILINK_ID , CD_SCMD_WRITE_ILINK_ID , CD_SCMD_READ_NVM ,
  CD_SCMD_WRITE_NVM , CD_SCMD_DEC_SET , CD_SCMD_SCMD , CD_SCMD_STATUS ,
  CD_SCMD_SET_HD_MODE , CD_SCMD_OPEN_CONFIG , CD_SCMD_CLOSE_CONFIG , CD_SCMD_READ_CONFIG ,
  CD_SCMD_WRITE_CONFIG , CD_SCMD_READ_CONSOLE_ID , CD_SCMD_WRITE_CONSOLE_ID , CD_SCMD_READ_MECHACON_VERSION ,
  CD_SCMD_CTRL_AD_OUT , CD_SCMD_BREAK , CD_SCMD_READ_SUBQ , CD_SCMD_FORBID_DVDP ,
  CD_SCMD_AUTO_ADJUST_CTRL , CD_SCMD_READ_MODEL_NAME , CD_SCMD_WRITE_MODEL_NAME , CD_SCMD_FORBID_READ ,
  CD_SCMD_SPIN_CTRL , CD_SCMD_BOOT_CERTIFY , CD_SCMD_CANCELPOWEROFF , CD_SCMD_BLUELEDCTRL ,
  CD_SCMD_POWEROFF , CD_SCMD_MMODE , CD_SCMD_SETTHREADPRI
}

Functions

SifRpcClientData_t clientSCmd __attribute__ ((aligned(64)))
void convertfrombcd (sceCdCLOCK *time)
int _CdCheckSCmd (int cmd)
int sceCdReadClock (sceCdCLOCK *clock)
time_t ps2time (time_t *t)
int sceCdWriteClock (sceCdCLOCK *clock)
int sceCdGetDiskType (void)
int sceCdGetError (void)
int sceCdTrayReq (int param, u32 *traychk)
int sceCdApplySCmd (u8 cmdNum, const void *inBuff, u16 inBuffSize, void *outBuff)
int sceCdStatus (void)
int sceCdBreak (void)
int sceCdCancelPOffRdy (u32 *result)
int sceCdBlueLedCtrl (u8 control, u32 *result)
int sceCdPowerOff (u32 *result)
int sceCdMmode (int media)
int sceCdChangeThreadPriority (int priority)
int sceCdForbidRead (u32 *status)
int sceCdSpinCtrlEE (u32 speed)
int sceCdBootCertify (const u8 *romname)
int sceCdReadSUBQ (void *buffer, u32 *status)
int sceCdForbidDVDP (u32 *result)
int sceCdAutoAdjustCtrl (int mode, u32 *result)
int sceCdDecSet (unsigned char arg1, unsigned char arg2, unsigned char shift)
int sceCdSetHDMode (u32 mode)
int sceCdOpenConfig (int block, int mode, int NumBlocks, u32 *status)
int sceCdCloseConfig (u32 *result)
int sceCdReadConfig (void *buffer, u32 *result)
int sceCdWriteConfig (const void *buffer, u32 *result)
int sceCdReadNVM (u32 address, u16 *data, u8 *result)
int sceCdWriteNVM (u32 address, u16 data, u8 *result)
int sceCdRI (unsigned char *buffer, u32 *result)
int sceCdWI (const unsigned char *buffer, u32 *status)
int sceCdReadConsoleID (unsigned char *buffer, u32 *result)
int sceCdWriteConsoleID (const unsigned char *buffer, u32 *result)
int sceCdMV (unsigned char *buffer, u32 *result)
int sceCdCtrlADout (int arg1, u32 *result)
int sceCdRM (char *buffer, u32 *result)
int sceCdWM (const char *buffer, u32 *result)
int sceCdNoticeGameStart (u8 arg1, u32 *result)
int _CdSyncS (int mode)

Variables

int sCmdSemaId
int sCmdNum = 0
int CdConfigRdWrNumBlocks
int initVersionCdvdman
SifRpcClientData_t clientSCmd
u8 sCmdRecvBuff []
sCmdSendParams_t sCmdSendBuff

Detailed Description

Function definitions for libsceCdvd (EE side calls to the iop module sceCdvdfsv).

NOTE: These functions will work with the CDVDMAN/CDVDFSV or XCDVDMAN/XCDVDFSV modules stored in rom0.

NOTE: not all functions work with each set of modules!

Definition in file scmd.c.

Macro Definition Documentation

◆ CD_SERVER_SCMD

#define CD_SERVER_SCMD   0x80000593

blocking commands (Synchronous)

Definition at line 36 of file scmd.c.

Enumeration Type Documentation

◆ CD_SCMD_CMDS

enum CD_SCMD_CMDS

Definition at line 38 of file scmd.c.

Function Documentation

◆ _CdCheckSCmd()

int _CdCheckSCmd ( int cmd)

Definition at line 422 of file scmd.c.

◆ _CdSyncS()

int _CdSyncS ( int mode)

Definition at line 894 of file scmd.c.

◆ convertfrombcd()

void convertfrombcd ( sceCdCLOCK * time)
extern

Definition at line 73 of file osd_config.c.

◆ ps2time()

time_t ps2time ( time_t * t)

Definition at line 144 of file scmd.c.

◆ sceCdApplySCmd()

int sceCdApplySCmd ( u8 cmdNum,
const void * inBuff,
u16 inBuffSize,
void * outBuff )

send an s-command by function number

Parameters
commandnumber
inputbuffer (can be null)
sizeof input buffer (0 - 16 bytes)
outputbuffer (16 bytes, can be null)
Returns
1 if successful, 0 if error

Definition at line 267 of file scmd.c.

◆ sceCdAutoAdjustCtrl()

int sceCdAutoAdjustCtrl ( int mode,
u32 * result )

Controls automatic adjustment of the CD/DVD drive. This also causes the auto-tilt motor (on units that have one) to be activated.

Parameters
modeMode
resultResult code.
Returns
1 on success, 0 on failure.

Definition at line 541 of file scmd.c.

◆ sceCdBlueLedCtrl()

int sceCdBlueLedCtrl ( u8 control,
u32 * result )

Definition at line 345 of file scmd.c.

◆ sceCdBootCertify()

int sceCdBootCertify ( const u8 * romname)

Performs bootup certification. SUPPORTED IN XCDVDMAN/XCDVDFSV ONLY

Parameters
romnameROM version - The ROM "name" of the console in this format: romname[0] - ROM major version number (In decimal). romname[1] - ROM minor version number (In decimal). romname[2] - ROM region. romname[3] - Console type (E.g. C, D or T).
Returns
1 on success, 0 on failure.

Definition at line 486 of file scmd.c.

◆ sceCdBreak()

int sceCdBreak ( void )

'breaks' the currently executing command

Returns
1 on success, 0 on failure.

Definition at line 309 of file scmd.c.

◆ sceCdCancelPOffRdy()

int sceCdCancelPOffRdy ( u32 * result)

cancel power off Minimum Mechacon firmware version: 20400 SUPPORTED IN XCDVDMAN/XCDVDFSV ONLY

Parameters
resultresult
Returns
1 on success, 0 on failure.

Definition at line 326 of file scmd.c.

◆ sceCdChangeThreadPriority()

int sceCdChangeThreadPriority ( int priority)

Definition at line 403 of file scmd.c.

◆ sceCdCloseConfig()

int sceCdCloseConfig ( u32 * result)

Closes the configuration block that is currently opened.

Parameters
resultResult code.
Returns
1 on success, 0 on failure.

Definition at line 620 of file scmd.c.

◆ sceCdCtrlADout()

int sceCdCtrlADout ( int mode,
u32 * status )

Controls Audio Digital output.

Parameters
modeSet to a non-zero value to enable digital output.
statusResult code.
Returns
1 on success, 0 on failure.

Definition at line 818 of file scmd.c.

◆ sceCdDecSet()

int sceCdDecSet ( unsigned char enable_xor,
unsigned char enable_shift,
unsigned char shiftval )

Controls on-the-fly (hardware) data decryption. Setting all options to 0 will disable decryption. This is used for decrypting encrypted sectors like the PlayStation 2 logo.

Parameters
enable_xorSet to a non-zero value to enable xor by index 4 of the key argument in sceCdReadKey
enable_shiftSet to a non-zero value to enable rotate shift right by the amount specified by the "shiftval" argument
shiftvalShift amount enable_shift is enabled
Returns
1 on success, 0 on failure.

Definition at line 560 of file scmd.c.

◆ sceCdForbidDVDP()

int sceCdForbidDVDP ( u32 * result)

Disables (Forbids) the DVD READ N-command, so that DVD video disc sectors cannot be read. Support for the DVD READ N-command is re-enabled when a DVD player is loaded.

Parameters
resultResult code.
Returns
1 on success, 0 on failure.

Definition at line 523 of file scmd.c.

◆ sceCdForbidRead()

int sceCdForbidRead ( u32 * result)

Disables (Forbids) the READ N-command, so that disc sectors cannot be read. Support for the READ N-command is re-enabled when the disc is replaced. SUPPORTED IN XCDVDMAN/XCDVDFSV ONLY

Parameters
resultResult code.
Returns
1 on success, 0 on failure.

Definition at line 454 of file scmd.c.

◆ sceCdGetDiskType()

int sceCdGetDiskType ( void )

gets the type of the currently inserted disc

Returns
disk type (SCECdvdMediaTypes)

Definition at line 209 of file scmd.c.

◆ sceCdGetError()

int sceCdGetError ( void )

gets the last error that occurred

Returns
error type (SCECdvdErrorCode)

Definition at line 227 of file scmd.c.

◆ sceCdMmode()

int sceCdMmode ( int media)

set media mode

SUPPORTED IN XCDVDMAN/XCDVDFSV ONLY

Parameters
mediamedia mode (SCECdvdMModeMediaTypes)
Returns
1 on success, 0 on failure.

Definition at line 384 of file scmd.c.

◆ sceCdMV()

int sceCdMV ( u8 * buffer,
u32 * status )

Reads MECHACON version data (RR MM mm TT): RR = Magicgate region, MM = major, mm = minor, TT = system type (00 = PS2, 01 = PSX) Magicgate region codes are: 00 = Japan, 01 = USA, 02 = Europe, 03 = Oceania, 04 = Asia, 05 = Russia, 06 = China, and 07 = Mexico.

NOTE: The old CDVDMAN module only returns MM mm TT instead. The region byte is made up of the lower 7 bits of the status/result code.

Parameters
bufferPointer to the buffer to store the version data in.
statusResult code.
Returns
1 on success, 0 on failure.

Definition at line 798 of file scmd.c.

◆ sceCdNoticeGameStart()

int sceCdNoticeGameStart ( u8 arg1,
u32 * result )

Notice game start. Minimum Mechacon firmware version: 50400 SUPPORTED BY ONLY DESR/PSX DVR CDVDMAN MODULES

Returns
1 on success, 0 on failure

Definition at line 875 of file scmd.c.

◆ sceCdOpenConfig()

int sceCdOpenConfig ( int block,
int mode,
int NumBlocks,
u32 * status )

Opens a specified configuration block, within NVRAM. Each block is 15 bytes long.

Parameters
blockBlock number.
modeMode (0 = read, 1 = write).
NumBlocksNumber of blocks.
statusResult code.
Returns
1 on success, 0 on failure.

Definition at line 597 of file scmd.c.

◆ sceCdPowerOff()

int sceCdPowerOff ( u32 * result)

power off

SUPPORTED IN XCDVDMAN/XCDVDFSV ONLY

Parameters
resultresult
Returns
1 on success, 0 on failure.

Definition at line 365 of file scmd.c.

◆ sceCdReadClock()

int sceCdReadClock ( sceCdCLOCK * clock)

Reads the PlayStation clock. (time value is in BCD)

NOTE: For the old CDVDMAN module, the month field will not have its most significant bit automatically filed off.

Parameters
clocktime/date struct
Returns
1 on success, 0 on failure.

Definition at line 116 of file scmd.c.

◆ sceCdReadConfig()

int sceCdReadConfig ( void * buffer,
u32 * result )

Reads the configuration block(s) that was/were previously opened. Each block is 15 bytes long.

Parameters
bufferPointer to the buffer to store the configuration data in.
resultResult code.
Returns
1 on success, 0 on failure.

Definition at line 638 of file scmd.c.

◆ sceCdReadConsoleID()

int sceCdReadConsoleID ( u8 * buffer,
u32 * result )

Reads the ID of the console. This is not the same as the i.Link ID.

Parameters
bufferPointer to the buffer that will contain the data read.
resultResult code.
Returns
1 on success, 0 on failure.

Definition at line 760 of file scmd.c.

◆ sceCdReadNVM()

int sceCdReadNVM ( u32 address,
u16 * data,
u8 * result )

Reads a single word from the NVRAM storage.

Parameters
addressAddress in 2-byte words, of the word that will be read.
dataPointer to the buffer that will contain the data read.
resultResult code.
Returns
1 on success, 0 on failure.

Definition at line 677 of file scmd.c.

◆ sceCdReadSUBQ()

int sceCdReadSUBQ ( void * buffer,
u32 * status )

Reads SUBQ data from the disc.

Parameters
bufferPointer to the buffer for storing the SUBQ data in.
statusResult code.
Returns
1 on success, 0 on failure.

Definition at line 504 of file scmd.c.

◆ sceCdRI()

int sceCdRI ( u8 * buffer,
u32 * result )

Reads the i.Link ID of the console. All consoles have an i.Link ID, including those that do not have a physical i.Link port.

Parameters
bufferPointer to the buffer that will contain the data read.
resultResult code.
Returns
1 on success, 0 on failure.

Definition at line 722 of file scmd.c.

◆ sceCdRM()

int sceCdRM ( char * buffer,
u32 * status )

Reads the console's model "name": e.g. "SCPH-39000". SUPPORTED IN XCDVDMAN/XCDVDFSV ONLY

Parameters
bufferPointer to the buffer for storing the model name in.
statusResult code.
Returns
1 on success, 0 on failure.

Definition at line 837 of file scmd.c.

◆ sceCdSetHDMode()

int sceCdSetHDMode ( u32 mode)

Blocks disc tray eject functionality and turns off the blue eject LED when enabled.

Parameters
modeSet to a non-zero value to enable the tray eject functionality
Returns
1 on success, 0 on failure.

Definition at line 581 of file scmd.c.

◆ sceCdSpinCtrlEE()

int sceCdSpinCtrlEE ( u32 speed)

Controls spindle speed? Not sure what it really does. SUPPORTED IN XCDVDMAN/XCDVDFSV ONLY

Parameters
speedSpeed mode.
Returns
1 on success, 0 on failure.

Definition at line 470 of file scmd.c.

◆ sceCdStatus()

int sceCdStatus ( void )

gets the state of the drive

Returns
status (SCECdvdDriveStates)

Definition at line 289 of file scmd.c.

◆ sceCdTrayReq()

int sceCdTrayReq ( int param,
u32 * traychk )

open/close/check disk tray

Parameters
paramparam (SCECdvdTrayReqMode)
traychkaddress for returning tray state change
Returns
1 on success, 0 on failure.

Definition at line 245 of file scmd.c.

◆ sceCdWI()

int sceCdWI ( const u8 * buffer,
u32 * result )

Writes a new i.Link ID for the console. Starting from Mechacon firmware version 50000, a unlock combination (0x03 0x46 and 0x03 0x47) needs to be executed first.

Parameters
bufferPointer to the buffer that contains the new i.Link ID.
resultResult code.
Returns
1 on success, 0 on failure.

Definition at line 741 of file scmd.c.

◆ sceCdWM()

int sceCdWM ( const char * buffer,
u32 * status )

Sets the console's model name. Starting from Mechacon firmware version 50000, a unlock combination (0x03 0x46 and 0x03 0x47) needs to be executed first. SUPPORTED IN XCDVDMAN/XCDVDFSV ONLY

Parameters
bufferPointer to a buffer containing the new model name.
statusResult code.
Returns
1 on success, 0 on failure.

Definition at line 856 of file scmd.c.

◆ sceCdWriteClock()

int sceCdWriteClock ( sceCdCLOCK * clock)

Sets the PlayStation 2 clock. (time value is in BCD)

NOTE: The normalized value will be written back to the buffer specified.

Parameters
clocktime/date struct to set clocks time with
Returns
1 on success, 0 on failure.

Definition at line 188 of file scmd.c.

◆ sceCdWriteConfig()

int sceCdWriteConfig ( const void * buffer,
u32 * result )

Writes to the configuration block(s) that was/were previously opened. Each block is 15 bytes long.

Parameters
bufferPointer to the buffer that contains the new configuration data.
resultResult code.
Returns
1 on success, 0 on failure.

Definition at line 657 of file scmd.c.

◆ sceCdWriteConsoleID()

int sceCdWriteConsoleID ( const u8 * buffer,
u32 * status )

Writes a new ID for the console. This is not the same as the i.Link ID. Starting from Mechacon firmware version 50000, a unlock combination (0x03 0x46 and 0x03 0x47) needs to be executed first.

Parameters
bufferPointer to the buffer that contains the new i.Link ID.
statusResult code.
Returns
1 on success, 0 on failure.

Definition at line 779 of file scmd.c.

◆ sceCdWriteNVM()

int sceCdWriteNVM ( u32 address,
u16 data,
u8 * result )

Writes a single word to the NVRAM storage. Starting from Mechacon firmware version 50000, attempting to write to address values over 150 will error.

Parameters
addressAddress in 2-byte words, of the word that will be written to.
dataPointer to the buffer that contains the new data.
resultResult code.
Returns
1 on success, 0 on failure.

Definition at line 700 of file scmd.c.

Variable Documentation

◆ CdConfigRdWrNumBlocks

int CdConfigRdWrNumBlocks

Definition at line 99 of file scmd.c.

◆ initVersionCdvdman

int initVersionCdvdman
extern

Definition at line 67 of file libcdvd.c.

◆ sCmdNum

int sCmdNum = 0

Definition at line 97 of file scmd.c.

◆ sCmdSemaId

int sCmdSemaId

Definition at line 92 of file scmd.c.