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

Go to the source code of this file.

Classes

union  nCmdSendParams_t
struct  _cdvd_read_data_1400
struct  _cdvd_read_data_1300

Macros

#define CD_SERVER_NCMD   0x80000595

Enumerations

enum  CdvdStCmd_t {
  CDVD_ST_CMD_START = 1 , CDVD_ST_CMD_READ , CDVD_ST_CMD_STOP , CDVD_ST_CMD_SEEK ,
  CDVD_ST_CMD_INIT , CDVD_ST_CMD_STAT , CDVD_ST_CMD_PAUSE , CDVD_ST_CMD_RESUME ,
  CDVD_ST_CMD_SEEKF
}
enum  CD_NCMD_CMDS {
  CD_NCMD_READ = 0x01 , CD_NCMD_CDDAREAD , CD_NCMD_DVDREAD , CD_NCMD_GETTOC ,
  CD_NCMD_SEEK , CD_NCMD_STANDBY , CD_NCMD_STOP , CD_NCMD_PAUSE ,
  CD_NCMD_STREAM , CD_NCMD_CDDASTREAM , CD_NCMD_READ_KEY , CD_NCMD_NCMD ,
  CD_NCMD_READIOPMEM , CD_NCMD_DISKREADY , CD_NCMD_READCHAIN
}

Functions

int sceCdStream (u32 lbn, u32 nsectors, void *buf, CdvdStCmd_t cmd, sceCdRMode *rm)
int sceCdCddaStream (u32 lbn, u32 nsectors, void *buf, CdvdStCmd_t cmd, sceCdRMode *rm)
int _CdCheckNCmd (int cmd)
SifRpcClientData_t clientNCmd __attribute__ ((aligned(64)))
u32 cdda_st_buf[64/sizeof(u32)] ALIGNED (64)
int sceCdNCmdDiskReady (void)
void _CdAlignReadBuffer (void *data)
int sceCdRead (u32 lbn, u32 sectors, void *buf, sceCdRMode *mode)
int sceCdReadDVDV (u32 lbn, u32 nsectors, void *buf, sceCdRMode *rm)
int sceCdReadCDDA (u32 lbn, u32 nsectors, void *buf, sceCdRMode *rm)
int sceCdGetToc (u8 *toc)
int sceCdSeek (u32 lbn)
int sceCdStandby (void)
int sceCdStop (void)
int sceCdPause (void)
int sceCdApplyNCmd (u8 cmdNum, const void *inBuff, u16 inBuffSize)
int sceCdReadIOPMem (u32 lbn, u32 sectors, void *buf, sceCdRMode *mode)
int sceCdReadChain (sceCdRChain *readChain, sceCdRMode *mode)
u32 sceCdGetReadPos (void)
int sceCdStStart (u32 lbn, sceCdRMode *mode)
int sceCdStRead (u32 sectorType, u32 *buffer, u32 mode, u32 *error)
int sceCdStStop (void)
int sceCdStSeek (u32 lbn)
int sceCdStInit (u32 buffSize, u32 numBuffers, void *buf)
int sceCdStStat (void)
int sceCdStPause (void)
int sceCdStResume (void)
int sceCdSync (int mode)
int sceCdReadKey (unsigned char arg1, unsigned char arg2, unsigned int command, unsigned char *key)

Variables

int nCmdSemaId
int nCmdNum = 0
int streamStatus = 0
sceCdRMode dummyMode
int initVersionCdvdfsv
SifRpcClientData_t clientNCmd
u32 readStreamData [5]
u32 readData [6]
sceCdRChain readChainData [66]
u32 getTocSendBuff [3]
u32 _rd_intr_data [64]
u32 curReadPos
u8 tocBuff [2064]
u8 nCmdRecvBuff [48]
nCmdSendParams_t nCmdSendBuff
u32 seekSector
u32 cdda_st_buf [64/sizeof(u32)]

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 ncmd.c.

Macro Definition Documentation

◆ CD_SERVER_NCMD

#define CD_SERVER_NCMD   0x80000595

non-blocking commands (Non-synchronous)

Definition at line 33 of file ncmd.c.

Enumeration Type Documentation

◆ CD_NCMD_CMDS

Enumerator
CD_NCMD_READCHAIN 

XCDVDFSV only

Definition at line 51 of file ncmd.c.

◆ CdvdStCmd_t

Stream commands.

Definition at line 36 of file ncmd.c.

Function Documentation

◆ __attribute__()

SifRpcClientData_t clientNCmd __attribute__ ( (aligned(64)) )

for n-cmds

get toc

toc buffer (for sceCdGetToc())

◆ _CdAlignReadBuffer()

void _CdAlignReadBuffer ( void * data)
extern

this gets called when the sceCdRead function finishes to copy the data read in to unaligned buffers

Definition at line 148 of file ncmd.c.

◆ _CdCheckNCmd()

int _CdCheckNCmd ( int cmd)

check whether ready to send an n-command

Parameters
cmdcurrent command
Returns
1 if read to send; 0 if busy/error

Definition at line 746 of file ncmd.c.

◆ sceCdApplyNCmd()

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

send an n-command by function number

Parameters
cmdNumcommand number
inBuffinput buffer (can be null)
inBuffSizesize of input buffer (0 - 16 bytes)
Returns
1 on success, 0 on failure.

Definition at line 427 of file ncmd.c.

◆ sceCdCddaStream()

int sceCdCddaStream ( u32 lbn,
u32 nsectors,
void * buf,
CdvdStCmd_t cmd,
sceCdRMode * rm )

Definition at line 690 of file ncmd.c.

◆ sceCdGetReadPos()

u32 sceCdGetReadPos ( void )

get the current read position (when reading using sceCdRead)

Definition at line 567 of file ncmd.c.

◆ sceCdGetToc()

int sceCdGetToc ( u8 * toc)

get toc from inserted disc

Parameters
tocbuffer to hold toc (1024 bytes)
Returns
1 on success, 0 on failure.

Definition at line 302 of file ncmd.c.

◆ sceCdNCmdDiskReady()

int sceCdNCmdDiskReady ( void )

wait for disc to finish all n-commands (shouldnt really need to call this yourself)

Returns
SCECdNotReady (6) if busy; SCECdComplete (2) if ready; 0 if error

Definition at line 480 of file ncmd.c.

◆ sceCdPause()

int sceCdPause ( void )

pauses ps2 sceCd drive non-blocking, requires sceCdSync() call

Returns
1 on success, 0 on failure.

Definition at line 406 of file ncmd.c.

◆ sceCdRead()

int sceCdRead ( u32 lbn,
u32 sectors,
void * buffer,
sceCdRMode * mode )

read data from disc non-blocking, requires sceCdSync() call

Parameters
lbnsector location to start reading from
sectorsnumber of sectors to read
bufferbuffer to read to
modemode to read as
Returns
1 on success, 0 on failure.

Definition at line 179 of file ncmd.c.

◆ sceCdReadCDDA()

int sceCdReadCDDA ( u32 lbn,
u32 nsectors,
void * buf,
sceCdRMode * rm )

Definition at line 258 of file ncmd.c.

◆ sceCdReadChain()

int sceCdReadChain ( sceCdRChain * tag,
sceCdRMode * mode )

do a 'chain' of reads with one command last chain value must be all 0xFFFFFFFF (max of 64 reads can be set at once) non-blocking, requires sceCdSync() call

SUPPORTED IN XCDVDMAN/XCDVDFSV ONLY

Parameters
tagpointer to an array of read chain data
moderead mode
Returns
1 on success, 0 on failure.

Definition at line 494 of file ncmd.c.

◆ sceCdReadDVDV()

int sceCdReadDVDV ( u32 lbn,
u32 nsectors,
void * buf,
sceCdRMode * rm )

Definition at line 228 of file ncmd.c.

◆ sceCdReadIOPMem()

int sceCdReadIOPMem ( u32 lbn,
u32 sectors,
void * buf,
sceCdRMode * mode )

read data to iop memory

Parameters
lbnsector location to read from
sectorsnumber of sectors to read
bufbuffer to read to (in iop memory)
moderead mode
Returns
1 if successful, 0 if error

Definition at line 449 of file ncmd.c.

◆ sceCdReadKey()

int sceCdReadKey ( unsigned char arg1,
unsigned char arg2,
unsigned int command,
unsigned char * key )

Reads the requested key from the CD/DVD.

Parameters
arg1Unknown
arg2Unknown
commandCommand
keyBuffer to store the key in.
Returns
1 on success, 0 on failure.

Definition at line 817 of file ncmd.c.

◆ sceCdSeek()

int sceCdSeek ( u32 lbn)

seek to given sector on disc non-blocking, requires sceCdSync() call

Parameters
lbnsector to seek to on disc
Returns
1 on success, 0 on failure.

Definition at line 341 of file ncmd.c.

◆ sceCdStandby()

int sceCdStandby ( void )

puts ps2 sceCd drive into standby mode non-blocking, requires sceCdSync() call

Returns
1 on success, 0 on failure.

Definition at line 364 of file ncmd.c.

◆ sceCdStInit()

int sceCdStInit ( u32 bufmax,
u32 bankmax,
void * buffer )

init streaming

Parameters
bufmaxstream buffer size
bankmaxnumber of ring buffers
bufferbuffer address on iop
Returns
1 on success, 0 on failure.

Definition at line 636 of file ncmd.c.

◆ sceCdStop()

int sceCdStop ( void )

stops ps2 sceCd drive from spinning non-blocking, requires sceCdSync() call

Returns
1 on success, 0 on failure.

Definition at line 385 of file ncmd.c.

◆ sceCdStPause()

int sceCdStPause ( void )

pause streaming

Returns
1 on success, 0 on failure.

Definition at line 648 of file ncmd.c.

◆ sceCdStRead()

int sceCdStRead ( u32 sectors,
u32 * buffer,
u32 mode,
u32 * error )

read stream data

Parameters
sectorsnumber of sectors to read
bufferread buffer address
modedata stream mode (STMNBLK or STMBLK)
errorerror value holder
Returns
number of sectors read if successful, 0 otherwise

Definition at line 583 of file ncmd.c.

◆ sceCdStream()

int sceCdStream ( u32 lbn,
u32 nsectors,
void * buf,
CdvdStCmd_t cmd,
sceCdRMode * rm )

perform the stream operation

Definition at line 661 of file ncmd.c.

◆ sceCdStResume()

int sceCdStResume ( void )

continue streaming

Returns
1 on success, 0 on failure.

Definition at line 654 of file ncmd.c.

◆ sceCdStSeek()

int sceCdStSeek ( u32 lbn)

seek to a new stream position

Parameters
lbnsector location to start streaming from
Returns
1 on success, 0 on failure.

Definition at line 631 of file ncmd.c.

◆ sceCdStStart()

int sceCdStStart ( u32 lbn,
sceCdRMode * mode )

start streaming data

Parameters
lbnsector location to start streaming from
modemode to read in
Returns
1 on success, 0 on failure.

Definition at line 577 of file ncmd.c.

◆ sceCdStStat()

int sceCdStStat ( void )

get stream read status

Returns
number of sectors read if successful, 0 otherwise

Definition at line 642 of file ncmd.c.

◆ sceCdStStop()

int sceCdStStop ( void )

stop streaming

Returns
1 on success, 0 on failure.

Definition at line 625 of file ncmd.c.

◆ sceCdSync()

int sceCdSync ( int mode)

waits/checks for completion of n-commands

Parameters
mode0 = wait for completion of command (blocking), 1 = check current status and return immediately
Returns
0 = completed, 1 = not completed

Definition at line 722 of file ncmd.c.

Variable Documentation

◆ dummyMode

sceCdRMode dummyMode

Definition at line 99 of file ncmd.c.

◆ getTocSendBuff

u32 getTocSendBuff ( )
extern

get toc

◆ initVersionCdvdfsv

int initVersionCdvdfsv
extern

Definition at line 66 of file libcdvd.c.

◆ nCmdNum

int nCmdNum = 0

Definition at line 85 of file ncmd.c.

◆ nCmdSemaId

int nCmdSemaId

n-cmd semaphore id

Definition at line 83 of file ncmd.c.

◆ streamStatus

int streamStatus = 0

Definition at line 98 of file ncmd.c.

◆ tocBuff

u8 tocBuff ( )
extern

toc buffer (for sceCdGetToc())