Nugget
Bare-metal libraries and examples for the original PlayStation
Loading...
Searching...
No Matches
cdlgetlocl.c
Go to the documentation of this file.
1/*
2
3MIT License
4
5Copyright (c) 2022 PCSX-Redux authors
6
7Permission is hereby granted, free of charge, to any person obtaining a copy
8of this software and associated documentation files (the "Software"), to deal
9in the Software without restriction, including without limitation the rights
10to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11copies of the Software, and to permit persons to whom the Software is
12furnished to do so, subject to the following conditions:
13
14The above copyright notice and this permission notice shall be included in all
15copies or substantial portions of the Software.
16
17THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
23SOFTWARE.
24
25*/
26
27// clang-format off
28
30 int resetDone = resetCDRom();
31 if (!resetDone) {
33 return;
34 }
35
37 CDROM_REG0 = 0;
40 uint8_t cause1 = ackCDRomCause();
41 uint8_t ctrl1 = CDROM_REG0 & ~3;
42 uint8_t response[16];
44 uint8_t ctrl2 = CDROM_REG0 & ~3;
45 CDROM_REG0 = 1;
46 uint8_t cause1b = CDROM_REG3_UC;
47
52 // Nothing of value is actually being read right after initialization,
53 // so there's no proper data in this response. There's somewhat of a
54 // bug in the controller, where doing a GetLocL right after a reset
55 // will actually work, whereas it shouldn't, as GetLocL is only supposed
56 // to work during a data transfer.
58 // Typical value seems to be around 1ms, but has
59 // been seen to spike high from time to time.
62 ramsyscall_printf("Basic getlocL, ack in %ius\n", ackTime);
63)
64
65CESTER_TEST(cdlGetLocLafterSeekP, test_instances,
66 int resetDone = resetCDRom();
67 if (!resetDone) {
69 return;
70 }
71
72 int seekDone = seekPTo(0x50, 0, 0);
73 if (!seekDone) {
75 return;
76 }
77
82 uint8_t cause1 = ackCDRomCause();
83 uint8_t ctrl1 = CDROM_REG0 & ~3;
84 uint8_t response[16];
86 uint8_t ctrl2 = CDROM_REG0 & ~3;
87 CDROM_REG0 = 1;
89
94 // Since we've done a seekP, without a read, we will actually
95 // error out here, unlike the previous test.
99 // Typical value seems to be around 750us, but has
100 // been seen to spike high from time to time.
103 ramsyscall_printf("Basic getlocL after seekP, errored in %ius\n", errorTime);
104)
105
106
107CESTER_TEST(cdlGetLocLafterSeekL, test_instances,
108 int resetDone = resetCDRom();
109 if (!resetDone) {
111 return;
112 }
113
114 int seekDone = seekPTo(0x50, 0, 0);
115 if (!seekDone) {
117 return;
118 }
119
121 CDROM_REG0 = 0;
124 uint8_t cause1 = ackCDRomCause();
125 uint8_t ctrl1 = CDROM_REG0 & ~3;
126 uint8_t response[16];
128 uint8_t ctrl2 = CDROM_REG0 & ~3;
129 CDROM_REG0 = 1;
130 uint8_t cause1b = CDROM_REG3_UC;
131
136 // Just like with the seekP, we will error out here, as
137 // there was no valid read performed.
141 // Typical value seems to be around 750us, but has
142 // been seen to spike high from time to time.
145 ramsyscall_printf("Basic getlocL after seekL, ack in %ius\n", ackTime);
146)
uint8_t response[16]
Definition cdlgetlocl.c:84
CDROM_REG0
Definition cdlgetlocl.c:79
uint8_t responseSize
Definition cdlgetlocl.c:85
CESTER_TEST(cdlGetLocL, test_instances, int resetDone=resetCDRom();if(!resetDone) { cester_assert_true(resetDone);return;} initializeTime();CDROM_REG0=0;CDROM_REG1=CDL_GETLOCL;uint32_t ackTime=waitCDRomIRQ();uint8_t cause1=ackCDRomCause();uint8_t ctrl1=CDROM_REG0 &~3;uint8_t response[16];uint8_t responseSize=readResponse(response);uint8_t ctrl2=CDROM_REG0 &~3;CDROM_REG0=1;uint8_t cause1b=CDROM_REG3_UC;cester_assert_uint_eq(3, cause1);cester_assert_uint_eq(0xe0, cause1b);cester_assert_uint_eq(0x38, ctrl1);cester_assert_uint_eq(0x18, ctrl2);cester_assert_uint_eq(8, responseSize);cester_assert_uint_ge(ackTime, 500);cester_assert_uint_lt(ackTime, 7000);ramsyscall_printf("Basic getlocL, ack in %ius\n", ackTime);) CESTER_TEST(cdlGetLocLafterSeekP
int resetDone
Definition cdlgetlocl.c:66
test_instances
Definition cdlgetlocl.c:65
cester_assert_uint_ge(errorTime, 500)
uint8_t ctrl2
Definition cdlgetlocl.c:86
uint8_t cause1
Definition cdlgetlocl.c:82
uint32_t errorTime
Definition cdlgetlocl.c:81
cester_assert_uint_eq(5, cause1)
uint8_t cause1b
Definition cdlgetlocl.c:88
uint8_t ctrl1
Definition cdlgetlocl.c:83
initializeTime()
CDROM_REG1
Definition cdlgetlocl.c:80
cester_assert_uint_lt(errorTime, 7000)
int seekDone
Definition cdlgetlocl.c:72
uint32_t ackTime
Definition cdlgetlocp.c:107
waitCDRomIRQ()
@ CDL_GETLOCL
Definition cdrom.h:58
#define CDROM_REG3_UC
Definition cdrom.h:39
ramsyscall_printf("=== e01_kseg1_reads_no_fill ===\n")
ackCDRomCause()
cester_assert_true(seekDone)
readResponse(response)
void uint32_t(classId, spec)