Nugget
Bare-metal libraries and examples for the original PlayStation
Loading...
Searching...
No Matches
cdlnop.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;
39
41 uint8_t cause1 = ackCDRomCause();
42 uint8_t ctrl1 = CDROM_REG0 & ~3;
43 uint8_t response1[16];
45 uint8_t ctrl2 = CDROM_REG0 & ~3;
46 CDROM_REG0 = 1;
47 uint8_t cause1b = CDROM_REG3_UC;
48
57 ramsyscall_printf("Basic cdlNop, ack in %ius\n", ackTime);
58)
59
60CESTER_TEST(cdlNopTooManyArgs, test_instance,
61 int resetDone = resetCDRom();
62 if (!resetDone) {
64 return;
65 }
66
68
71 CDROM_REG2 = 0;
72 CDROM_REG2 = 0;
73 CDROM_REG2 = 0;
75
77 uint8_t cause1 = ackCDRomCause();
78 uint8_t ctrl1 = CDROM_REG0 & ~3;
79 uint8_t response1[16];
81 uint8_t ctrl2 = CDROM_REG0 & ~3;
82 CDROM_REG0 = 1;
84
94 ramsyscall_printf("Basic cdlNop with too many args, errored in %ius\n", errorTime);
95)
96
97CESTER_TEST(cdlNopBusyTime, test_instance,
98 int resetDone = resetCDRom();
99 if (!resetDone) {
101 return;
102 }
103
105 CDROM_REG0 = 0;
107 while (CDROM_REG0 & 0x80);
108 uint32_t busyTime = updateTime();
109
111 uint8_t cause1 = ackCDRomCause();
112 uint8_t ctrl1 = CDROM_REG0 & ~3;
113 uint8_t response1[16];
115 uint8_t ctrl2 = CDROM_REG0 & ~3;
116 CDROM_REG0 = 1;
117 uint8_t cause1b = CDROM_REG3_UC;
118
127 ramsyscall_printf("Basic cdlNop, ack in %ius, busy flag was set for %ius, actual processing time %ius\n", ackTime, busyTime, ackTime - busyTime);
128)
129
uint32_t ackTime
Definition cdlgetlocp.c:107
waitCDRomIRQ()
CDROM_REG0
Definition cdlnop.c:69
CESTER_TEST(cdlNop, test_instance, int resetDone=resetCDRom();if(!resetDone) { cester_assert_true(resetDone);return;} initializeTime();CDROM_REG0=0;CDROM_REG1=CDL_NOP;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 cdlNop, ack in %ius\n", ackTime);) CESTER_TEST(cdlNopTooManyArgs
uint8_t responseSize1
Definition cdlnop.c:80
int resetDone
Definition cdlnop.c:61
uint8_t response1[16]
Definition cdlnop.c:79
test_instance
Definition cdlnop.c:60
cester_assert_uint_ge(errorTime, 500)
uint8_t ctrl2
Definition cdlnop.c:81
uint8_t cause1
Definition cdlnop.c:77
uint32_t errorTime
Definition cdlnop.c:76
cester_assert_uint_eq(5, cause1)
uint8_t cause1b
Definition cdlnop.c:83
uint8_t ctrl1
Definition cdlnop.c:78
CDROM_REG2
Definition cdlnop.c:70
initializeTime()
CDROM_REG1
Definition cdlnop.c:74
cester_assert_uint_lt(errorTime, 7000)
@ CDL_NOP
Definition cdrom.h:43
#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)