aboutsummaryrefslogtreecommitdiff
path: root/backends/platform/ps2/cd.c
blob: cd44b3d0341ccf4d6ffc642790b567e88b7e5177 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
/*********************************************************************
 * Copyright (C) 2003 Tord Lindstrom (pukko@home.se)
 * This file is subject to the terms and conditions of the PS2Link License.
 * See the file LICENSE in the main directory of this distribution for more
 * details.
 */

#include <tamtypes.h>
#include <kernel.h>
#include <sifrpc.h>

#define CDVD_INIT_BIND_RPC 0x80000592

static SifRpcClientData_t cdvdCd __attribute__((aligned(64)));
static char sendBuffer[256] __attribute__((aligned(16)));

int cdvdInitialised = 0;


void cdvdExit(void)
{
    cdvdInitialised = 0;
}


int cdvdInit(int mode)
{
	int i=0,len=0,ret=0;
    u8  *pkt;

    cdvdCd.server = NULL;

    do {
        if ((ret = SifBindRpc(&cdvdCd, CDVD_INIT_BIND_RPC, 0)) < 0) {
            return -1;
        }
        if (!cdvdCd.server) {
            nopdelay();
        }
    }
	while(!cdvdCd.server);

    pkt = sendBuffer;
    PUSHDATA( int, pkt, mode, i);
    pkt += i; len += i;

	if ((ret = SifCallRpc(&cdvdCd, 0, 0, sendBuffer, len, NULL, 0, 0, 0)) < 0)
        return -1;

    cdvdInitialised = 1;

    return 0;
}