Nugget
Bare-metal libraries and examples for the original PlayStation
Loading...
Searching...
No Matches
cdlsetmode.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;
39 CDROM_REG2 = 0x80;
41
43 uint8_t cause1 = ackCDRomCause();
44 uint8_t ctrl1 = CDROM_REG0 & ~3;
45 uint8_t response1[16];
47 uint8_t ctrl2 = CDROM_REG0 & ~3;
48 CDROM_REG0 = 1;
49 uint8_t cause1b = CDROM_REG3_UC;
50
57 // Typical value seems to be around 2ms, but varies a lot.
60 ramsyscall_printf("Basic setMode: ack in %ius\n", ackTime);
61)
62
63CESTER_TEST(cdlSetModeWithoutArgs, test_instance,
64 int resetDone = resetCDRom();
65 if (!resetDone) {
67 return;
68 }
69
71
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 // Typical value seems to be around 750us.
94 ramsyscall_printf("No args setMode: errored in %ius\n", errorTime);
95)
96
97CESTER_TEST(cdlSetModeWithTooManyArgs, test_instance,
98 int resetDone = resetCDRom();
99 if (!resetDone) {
101 return;
102 }
103
105
106 CDROM_REG0 = 0;
107 CDROM_REG2 = 0x80;
108 CDROM_REG2 = 0x80;
109 CDROM_REG2 = 0x80;
110 CDROM_REG2 = 0x80;
112
114 uint8_t cause1 = ackCDRomCause();
115 uint8_t ctrl1 = CDROM_REG0 & ~3;
116 uint8_t response1[16];
118 uint8_t ctrl2 = CDROM_REG0 & ~3;
119 CDROM_REG0 = 1;
120 uint8_t cause1b = CDROM_REG3_UC;
121
129 // Typical value seems to be around 750us.
132 ramsyscall_printf("Too many args setMode: errored in %ius\n", errorTime);
133)
uint32_t ackTime
Definition cdlgetlocp.c:107
waitCDRomIRQ()
CESTER_TEST(cdlSetMode, test_instance, int resetDone=resetCDRom();if(!resetDone) { cester_assert_true(resetDone);return;} initializeTime();CDROM_REG0=0;CDROM_REG2=0x80;CDROM_REG1=CDL_SETMODE;uint32_t ackTime=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(3, cause1);cester_assert_uint_eq(0xe0, cause1b);cester_assert_uint_eq(2, response1[0]);cester_assert_uint_eq(1, responseSize1);cester_assert_uint_eq(0x38, ctrl1);cester_assert_uint_eq(0x18, ctrl2);cester_assert_uint_ge(ackTime, 500);cester_assert_uint_lt(ackTime, 7000);ramsyscall_printf("Basic setMode: ack in %ius\n", ackTime);) CESTER_TEST(cdlSetModeWithoutArgs
CDROM_REG0
Definition cdlsetmode.c:72
uint8_t responseSize1
Definition cdlsetmode.c:79
int resetDone
Definition cdlsetmode.c:64
uint8_t response1[16]
Definition cdlsetmode.c:78
test_instance
Definition cdlsetmode.c:63
cester_assert_uint_ge(errorTime, 500)
uint8_t ctrl2
Definition cdlsetmode.c:80
uint8_t cause1
Definition cdlsetmode.c:76
uint32_t errorTime
Definition cdlsetmode.c:75
cester_assert_uint_eq(5, cause1)
uint8_t cause1b
Definition cdlsetmode.c:82
uint8_t ctrl1
Definition cdlsetmode.c:77
initializeTime()
CDROM_REG1
Definition cdlsetmode.c:73
cester_assert_uint_lt(errorTime, 7000)
@ CDL_SETMODE
Definition cdrom.h:56
#define CDROM_REG3_UC
Definition cdrom.h:39
#define CDROM_REG2
Definition cdrom.h:33
ramsyscall_printf("=== e01_kseg1_reads_no_fill ===\n")
ackCDRomCause()
cester_assert_true(seekDone)
readResponse(response)
void uint32_t(classId, spec)