-
Notifications
You must be signed in to change notification settings - Fork 11
/
psp-dev-version.c
93 lines (77 loc) · 2.51 KB
/
psp-dev-version.c
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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
/** @file
* PSP Emulator - Some sort of version(?) register mapped into MMIO space.
*/
/*
* Copyright (C) 2020 Alexander Eichner <[email protected]>
*
* 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 <psp-devs.h>
/**
* Version device instance data.
*/
typedef struct PSPDEVVERS
{
/** Pointer to the owning device instance. */
PPSPDEV pDev;
/** version register handle. */
PSPIOMREGIONHANDLE hMmioVersion;
/** The version register value written. */
uint32_t u32RegVersion;
} PSPDEVVERS;
/** Pointer to the device instance data. */
typedef PSPDEVVERS *PPSPDEVVERS;
static void pspDevVersMmioRead(PSPADDR offMmio, size_t cbRead, void *pvVal, void *pvUser)
{
PPSPDEVVERS pThis = (PPSPDEVVERS)pvUser;
*(uint32_t *)pvVal = pThis->u32RegVersion;
}
static void pspDevVersMmioWrite(PSPADDR offMmio, size_t cbWrite, const void *pvVal, void *pvUser)
{
/*
* This is written once by the on chip bootloader right at the beginning and
* read later on to determine the L1 PSP directory to select.
*/
PPSPDEVVERS pThis = (PPSPDEVVERS)pvUser;
pThis->u32RegVersion = *(uint32_t *)pvVal;
}
static int pspDevMmioVersInit(PPSPDEV pDev)
{
PPSPDEVVERS pThis = (PPSPDEVVERS)&pDev->abInstance[0];
pThis->pDev = pDev;
return PSPEmuIoMgrMmioRegister(pDev->hIoMgr, pDev->pCfg->pPspProfile->PspAddrMmioVersion, 4,
pspDevVersMmioRead, pspDevVersMmioWrite, pThis,
"RegVersion", &pThis->hMmioVersion);
}
static void pspDevMmioVersDestruct(PPSPDEV pDev)
{
/* Nothing to do so far. */
}
/**
* Device registration structure.
*/
const PSPDEVREG g_DevRegMmioVersion =
{
/** pszName */
"version",
/** pszDesc */
"Version register device",
/** cbInstance */
sizeof(PSPDEVVERS),
/** pfnInit */
pspDevMmioVersInit,
/** pfnDestruct */
pspDevMmioVersDestruct,
/** pfnReset */
NULL
};