-
Notifications
You must be signed in to change notification settings - Fork 13
Expand file tree
/
Copy pathpsp-dev.c
More file actions
63 lines (52 loc) · 1.6 KB
/
psp-dev.c
File metadata and controls
63 lines (52 loc) · 1.6 KB
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
54
55
56
57
58
59
60
61
62
/** @file
* PSP Emulator - Device interface.
*/
/*
* Copyright (C) 2020 Alexander Eichner <alexander.eichner@campus.tu-berlin.de>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, version 3.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include <stdlib.h>
#include <common/types.h>
#include <common/cdefs.h>
#include <common/status.h>
#include <psp-dev.h>
int PSPEmuDevCreate(PSPIOM hIoMgr, PCPSPDEVREG pDevReg, PCPSPDEVIF pDevIf, PCPSPEMUCFG pCfg, PPSPDEV *ppDev)
{
int rc = 0;
PPSPDEV pDev = (PPSPDEV)calloc(1, sizeof(*pDev) + pDevReg->cbInstance);
if (pDev)
{
pDev->pReg = pDevReg;
pDev->pDevIf = pDevIf;
pDev->hIoMgr = hIoMgr;
pDev->pCfg = pCfg;
/* Initialize the device instance and add to the list of known devices. */
rc = pDev->pReg->pfnInit(pDev);
if (!rc)
{
*ppDev = pDev;
return STS_INF_SUCCESS;
}
free(pDev);
}
else
rc = STS_ERR_NO_MEMORY;
return rc;
}
int PSPEmuDevDestroy(PPSPDEV pDev)
{
pDev->pReg->pfnDestruct(pDev);
free(pDev);
return STS_INF_SUCCESS;
}