Nugget
Bare-metal libraries and examples for the original PlayStation
Loading...
Searching...
No Matches
cdltest.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
38 CDROM_REG0 = 0;
40
42 uint8_t cause1 = ackCDRomCause();
43 uint8_t ctrl1 = CDROM_REG0 & ~3;
44 uint8_t response1[16];
46 uint8_t ctrl2 = CDROM_REG0 & ~3;
47 CDROM_REG0 = 1;
48 uint8_t cause1b = CDROM_REG3_UC;
49
59 ramsyscall_printf("Basic cdlTest with no args, errored in %ius\n", errorTime);
60)
61
63 int resetDone = resetCDRom();
64 if (!resetDone) {
66 return;
67 }
68
70
72 CDROM_REG2 = 0x20;
74
76 uint8_t cause1 = ackCDRomCause();
77 uint8_t ctrl1 = CDROM_REG0 & ~3;
78 uint8_t response1[16];
80 uint8_t ctrl2 = CDROM_REG0 & ~3;
81 CDROM_REG0 = 1;
83
91 ramsyscall_printf("Basic cdlTest with arg = 0x20, ack in %ius, response = %02x %02x %02x %02x\n", ackTime, response1[0], response1[1], response1[2], response1[3]);
92)
93
94CESTER_TEST(cdlTest20ExtraArgs, test_instance,
95 int resetDone = resetCDRom();
96 if (!resetDone) {
98 return;
99 }
100
102
103 CDROM_REG0 = 0;
104 CDROM_REG2 = 0x20;
105 CDROM_REG2 = 0x00;
107
109 uint8_t cause1 = ackCDRomCause();
110 uint8_t ctrl1 = CDROM_REG0 & ~3;
111 uint8_t response1[16];
113 uint8_t ctrl2 = CDROM_REG0 & ~3;
114 CDROM_REG0 = 1;
115 uint8_t cause1b = CDROM_REG3_UC;
116
126 ramsyscall_printf("Basic cdlTest with arg = 0x20, 0x00, errored in %ius\n", errorTime);
127)
128
129CESTER_TEST(cdlTestff, test_instance,
130 int resetDone = resetCDRom();
131 if (!resetDone) {
133 return;
134 }
135
137
138 CDROM_REG0 = 0;
139 CDROM_REG2 = 0xff;
141
143 uint8_t cause1 = ackCDRomCause();
144 uint8_t ctrl1 = CDROM_REG0 & ~3;
145 uint8_t response1[16];
147 uint8_t ctrl2 = CDROM_REG0 & ~3;
148 CDROM_REG0 = 1;
149 uint8_t cause1b = CDROM_REG3_UC;
150
160 ramsyscall_printf("Basic cdlTest with arg = 0xff, errored in %ius\n", ackTime);
161)
uint32_t errorTime
Definition cdlgetlocl.c:81
waitCDRomIRQ()
cester_assert_uint_eq(3, cause1)
CDROM_REG0
Definition cdltest.c:71
uint32_t ackTime
Definition cdltest.c:75
uint8_t responseSize1
Definition cdltest.c:79
int resetDone
Definition cdltest.c:63
uint8_t response1[16]
Definition cdltest.c:78
CESTER_TEST(cdlTestNoArg, test_instance, int resetDone=resetCDRom();if(!resetDone) { cester_assert_true(resetDone);return;} initializeTime();CDROM_REG0=0;CDROM_REG1=CDL_TEST;uint32_t errorTime=waitCDRomIRQ();uint8_t cause1=ackCDRomCause();uint8_t ctrl1=CDROM_REG0 &~3;uint8_t response1[16];uint8_t responseSize1=readResponse(response1);uint8_t ctrl2=CDROM_REG0 &~3;CDROM_REG0=1;uint8_t cause1b=CDROM_REG3_UC;cester_assert_uint_eq(5, cause1);cester_assert_uint_eq(0xe0, cause1b);cester_assert_uint_eq(3, response1[0]);cester_assert_uint_eq(0x20, response1[1]);cester_assert_uint_eq(2, responseSize1);cester_assert_uint_eq(0x38, ctrl1);cester_assert_uint_eq(0x18, ctrl2);cester_assert_uint_ge(errorTime, 500);cester_assert_uint_lt(errorTime, 7000);ramsyscall_printf("Basic cdlTest with no args, errored in %ius\n", errorTime);) CESTER_TEST(cdlTest20
test_instance
Definition cdltest.c:62
uint8_t ctrl2
Definition cdltest.c:80
uint8_t cause1
Definition cdltest.c:76
cester_assert_uint_ge(ackTime, 500)
cester_assert_uint_lt(ackTime, 7000)
uint8_t cause1b
Definition cdltest.c:82
uint8_t ctrl1
Definition cdltest.c:77
CDROM_REG2
Definition cdltest.c:72
initializeTime()
CDROM_REG1
Definition cdltest.c:73
@ CDL_TEST
Definition cdrom.h:67
#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)