Nugget
Bare-metal libraries and examples for the original PlayStation
Loading...
Searching...
No Matches
cdlgettd.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 = 0;
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
61 ramsyscall_printf("Basic getTD 0: ack in %ius\n", ackTime);
62)
63
65 int resetDone = resetCDRom();
66 if (!resetDone) {
68 return;
69 }
70
72
76
78 uint8_t cause1 = ackCDRomCause();
79 uint8_t ctrl1 = CDROM_REG0 & ~3;
80 uint8_t response1[16];
82 uint8_t ctrl2 = CDROM_REG0 & ~3;
83 CDROM_REG0 = 1;
85
96 ramsyscall_printf("Basic getTD 1: ack in %ius\n", ackTime);
97)
98
99
101 int resetDone = resetCDRom();
102 if (!resetDone) {
104 return;
105 }
106
108
109 CDROM_REG0 = 0;
110 CDROM_REG2 = 2;
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
132 ramsyscall_printf("Basic getTD 2: ack in %ius\n", ackTime);
133)
134
135
136CESTER_TEST(cdlGetTD3, test_instance,
137 int resetDone = resetCDRom();
138 if (!resetDone) {
140 return;
141 }
142
144
145 CDROM_REG0 = 0;
146 CDROM_REG2 = 3;
148
150 uint8_t cause1 = ackCDRomCause();
151 uint8_t ctrl1 = CDROM_REG0 & ~3;
152 uint8_t response1[16];
154 uint8_t ctrl2 = CDROM_REG0 & ~3;
155 CDROM_REG0 = 1;
156 uint8_t cause1b = CDROM_REG3_UC;
157
168 ramsyscall_printf("Basic getTD 3: ack in %ius\n", ackTime);
169)
170
172 int resetDone = resetCDRom();
173 if (!resetDone) {
175 return;
176 }
177
179
180 CDROM_REG0 = 0;
181 CDROM_REG2 = 4;
183
185 uint8_t cause1 = ackCDRomCause();
186 uint8_t ctrl1 = CDROM_REG0 & ~3;
187 uint8_t response1[16];
189 uint8_t ctrl2 = CDROM_REG0 & ~3;
190 CDROM_REG0 = 1;
191 uint8_t cause1b = CDROM_REG3_UC;
192
203 ramsyscall_printf("Basic getTD 4: ack in %ius\n", ackTime);
204)
205
206CESTER_TEST(cdlGetTD5, test_instance,
207 int resetDone = resetCDRom();
208 if (!resetDone) {
210 return;
211 }
212
214
215 CDROM_REG0 = 0;
216 CDROM_REG2 = 5;
218
220 uint8_t cause1 = ackCDRomCause();
221 uint8_t ctrl1 = CDROM_REG0 & ~3;
222 uint8_t response1[16];
224 uint8_t ctrl2 = CDROM_REG0 & ~3;
225 CDROM_REG0 = 1;
226 uint8_t cause1b = CDROM_REG3_UC;
227
238 ramsyscall_printf("Basic getTD 5: ack in %ius\n", ackTime);
239)
240
242 int resetDone = resetCDRom();
243 if (!resetDone) {
245 return;
246 }
247
249
250 CDROM_REG0 = 0;
251 CDROM_REG2 = 6;
253
255 uint8_t cause1 = ackCDRomCause();
256 uint8_t ctrl1 = CDROM_REG0 & ~3;
257 uint8_t response1[16];
259 uint8_t ctrl2 = CDROM_REG0 & ~3;
260 CDROM_REG0 = 1;
261 uint8_t cause1b = CDROM_REG3_UC;
262
273 ramsyscall_printf("Basic getTD 6: ack in %ius\n", ackTime);
274)
275
276CESTER_TEST(cdlGetTD12, test_instance,
277 int resetDone = resetCDRom();
278 if (!resetDone) {
280 return;
281 }
282
284
285 CDROM_REG0 = 0;
286 CDROM_REG2 = 0x12;
288
290 uint8_t cause1 = ackCDRomCause();
291 uint8_t ctrl1 = CDROM_REG0 & ~3;
292 uint8_t response1[16];
294 uint8_t ctrl2 = CDROM_REG0 & ~3;
295 CDROM_REG0 = 1;
296 uint8_t cause1b = CDROM_REG3_UC;
297
308 ramsyscall_printf("Basic getTD 12: ack in %ius\n", ackTime);
309)
310
312 int resetDone = resetCDRom();
313 if (!resetDone) {
315 return;
316 }
317
319
320 CDROM_REG0 = 0;
321 CDROM_REG2 = 0x25;
323
325 uint8_t cause1 = ackCDRomCause();
326 uint8_t ctrl1 = CDROM_REG0 & ~3;
327 uint8_t response1[16];
329 uint8_t ctrl2 = CDROM_REG0 & ~3;
330 CDROM_REG0 = 1;
331 uint8_t cause1b = CDROM_REG3_UC;
332
343 ramsyscall_printf("Basic getTD 25: ack in %ius\n", ackTime);
344)
345
346CESTER_TEST(cdlGetTD26, test_instance,
347 int resetDone = resetCDRom();
348 if (!resetDone) {
350 return;
351 }
352
354
355 CDROM_REG0 = 0;
356 CDROM_REG2 = 0x26;
358
360 uint8_t cause1 = ackCDRomCause();
361 uint8_t ctrl1 = CDROM_REG0 & ~3;
362 uint8_t response1[16];
364 uint8_t ctrl2 = CDROM_REG0 & ~3;
365 CDROM_REG0 = 1;
366 uint8_t cause1b = CDROM_REG3_UC;
367
377 ramsyscall_printf("Basic getTD 26: errored in %ius\n", errorTime);
378)
379
381 int resetDone = resetCDRom();
382 if (!resetDone) {
384 return;
385 }
386
388
389 CDROM_REG0 = 0;
390 CDROM_REG2 = 0x99;
392
394 uint8_t cause1 = ackCDRomCause();
395 uint8_t ctrl1 = CDROM_REG0 & ~3;
396 uint8_t response1[16];
398 uint8_t ctrl2 = CDROM_REG0 & ~3;
399 CDROM_REG0 = 1;
400 uint8_t cause1b = CDROM_REG3_UC;
401
411 ramsyscall_printf("Basic getTD 99: errored in %ius\n", errorTime);
412)
413
414CESTER_TEST(cdlGetTDaa, test_instance,
415 int resetDone = resetCDRom();
416 if (!resetDone) {
418 return;
419 }
420
422
423 CDROM_REG0 = 0;
424 CDROM_REG2 = 0xaa;
426
428 uint8_t cause1 = ackCDRomCause();
429 uint8_t ctrl1 = CDROM_REG0 & ~3;
430 uint8_t response1[16];
432 uint8_t ctrl2 = CDROM_REG0 & ~3;
433 CDROM_REG0 = 1;
434 uint8_t cause1b = CDROM_REG3_UC;
435
445 ramsyscall_printf("Basic getTD aa: errored in %ius\n", errorTime);
446)
447
449 int resetDone = resetCDRom();
450 if (!resetDone) {
452 return;
453 }
454
456
457 CDROM_REG0 = 0;
458 CDROM_REG2 = 0x0a;
460
462 uint8_t cause1 = ackCDRomCause();
463 uint8_t ctrl1 = CDROM_REG0 & ~3;
464 uint8_t response1[16];
466 uint8_t ctrl2 = CDROM_REG0 & ~3;
467 CDROM_REG0 = 1;
468 uint8_t cause1b = CDROM_REG3_UC;
469
479 ramsyscall_printf("Basic getTD 0a: errored in %ius\n", errorTime);
480)
481
482CESTER_TEST(cdlGetTD1a, test_instance,
483 int resetDone = resetCDRom();
484 if (!resetDone) {
486 return;
487 }
488
490
491 CDROM_REG0 = 0;
492 CDROM_REG2 = 0x1a;
494
496 uint8_t cause1 = ackCDRomCause();
497 uint8_t ctrl1 = CDROM_REG0 & ~3;
498 uint8_t response1[16];
500 uint8_t ctrl2 = CDROM_REG0 & ~3;
501 CDROM_REG0 = 1;
502 uint8_t cause1b = CDROM_REG3_UC;
503
513 ramsyscall_printf("Basic getTD 1a: errored in %ius\n", errorTime);
514)
515
517 int resetDone = resetCDRom();
518 if (!resetDone) {
520 return;
521 }
522
524
525 CDROM_REG0 = 0;
527
529 uint8_t cause1 = ackCDRomCause();
530 uint8_t ctrl1 = CDROM_REG0 & ~3;
531 uint8_t response1[16];
533 uint8_t ctrl2 = CDROM_REG0 & ~3;
534 CDROM_REG0 = 1;
535 uint8_t cause1b = CDROM_REG3_UC;
536
546 ramsyscall_printf("No args getTD: errored in %ius\n", errorTime);
547)
548
549CESTER_TEST(cdlGetTDTooManyArgs, test_instance,
550 int resetDone = resetCDRom();
551 if (!resetDone) {
553 return;
554 }
555
557
558 CDROM_REG0 = 0;
559 CDROM_REG2 = 0;
560 CDROM_REG2 = 0;
562
564 uint8_t cause1 = ackCDRomCause();
565 uint8_t ctrl1 = CDROM_REG0 & ~3;
566 uint8_t response1[16];
568 uint8_t ctrl2 = CDROM_REG0 & ~3;
569 CDROM_REG0 = 1;
570 uint8_t cause1b = CDROM_REG3_UC;
571
581 ramsyscall_printf("Too many args getTD: errored in %ius\n", errorTime);
582)
583
cester_assert_uint_eq(3, cause1)
uint8_t response1[16]
Definition cdlgettd.c:80
CDROM_REG0
Definition cdlgettd.c:73
uint32_t ackTime
Definition cdlgettd.c:77
uint8_t responseSize1
Definition cdlgettd.c:81
int resetDone
Definition cdlgettd.c:65
CESTER_TEST(cdlGetTD0, test_instance, int resetDone=resetCDRom();if(!resetDone) { cester_assert_true(resetDone);return;} initializeTime();CDROM_REG0=0;CDROM_REG2=0;CDROM_REG1=CDL_GETTD;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(0x71, response1[1]);cester_assert_uint_eq(0x28, response1[2]);cester_assert_uint_eq(3, 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 getTD 0: ack in %ius\n", ackTime);) CESTER_TEST(cdlGetTD1
test_instance
Definition cdlgettd.c:64
uint8_t ctrl2
Definition cdlgettd.c:82
uint8_t cause1
Definition cdlgettd.c:78
cester_assert_uint_ge(ackTime, 500)
uint32_t errorTime
Definition cdlgettd.c:359
cester_assert_uint_lt(ackTime, 7000)
uint8_t cause1b
Definition cdlgettd.c:84
uint8_t ctrl1
Definition cdlgettd.c:79
CDROM_REG2
Definition cdlgettd.c:74
initializeTime()
CDROM_REG1
Definition cdlgettd.c:75
waitCDRomIRQ()
@ CDL_GETTD
Definition cdrom.h:62
#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)