Nugget
Bare-metal libraries and examples for the original PlayStation
Loading...
Searching...
No Matches
Functions | Variables
readnosetloc.c File Reference
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

 CESTER_BODY (typedef struct { uint32_t time;uint8_t cause;uint8_t status;uint8_t header[4];} NoSetLocEvent;static unsigned noSetLocCollect(NoSetLocEvent *events, unsigned count, unsigned max, unsigned wantData) { unsigned dataReady=0;while((count< max) &&(dataReady< wantData)) { uint32_t timeout=3000000;if(!waitCDRomIRQWithTimeout(&timeout)) break;NoSetLocEvent *e=&events[count++];e->time=timeout;e->cause=ackCDRomCause();uint8_t response[16];readResponse(response);e->status=response[0];e->header[0]=e->header[1]=e->header[2]=e->header[3]=0;if(e->cause==1) { CDROM_REG0=0;CDROM_REG3=0x80;while((CDROM_REG0 &0x40)==0);for(unsigned i=0;i< 4;i++) e->header[i]=CDROM_REG2;CDROM_REG3=0;dataReady++;} } return count;} static int noSetLocPauseAndDrain() { CDROM_REG0=0;CDROM_REG1=CDL_PAUSE;while(1) { uint32_t timeout=3000000;if(!waitCDRomIRQWithTimeout(&timeout)) return 0;uint8_t cause=ackCDRomCause();discardResponse();if(cause==2) return 1;} } static void printNoSetLocEvents(const char *name, const NoSetLocEvent *events, unsigned count, unsigned split) { ramsyscall_printf("%s, %u events:", name, count);for(unsigned i=0;i< count;i++) { const NoSetLocEvent *e=&events[i];if(i==split) ramsyscall_printf(" |");ramsyscall_printf(" [%ius int%u stat %02x", e->time, e->cause, e->status);if(e->cause==1) { ramsyscall_printf(" hdr %02x:%02x:%02x m%u", e->header[0], e->header[1], e->header[2], e->header[3]);} ramsyscall_printf("]");} ramsyscall_printf("\n");} static uint32_t noSetLocHeaderLBA(const NoSetLocEvent *e) { return MSF2LBA(btoi(e->header[0]), btoi(e->header[1]), btoi(e->header[2]));} static uint32_t noSetLocLastLBA(const NoSetLocEvent *events, unsigned from, unsigned to) { uint32_t lba=0;for(unsigned i=from;i< to;i++) { if(events[i].cause==1) lba=noSetLocHeaderLBA(&events[i]);} return lba;} static uint32_t noSetLocFirstLBA(const NoSetLocEvent *events, unsigned from, unsigned to) { for(unsigned i=from;i< to;i++) { if(events[i].cause==1) return noSetLocHeaderLBA(&events[i]);} return 0;})
 
 initializeTime ()
 
 printNoSetLocEvents ("ReadS at 00:02:16, six sectors, ReadS again with no Setloc", events, count, split)
 
 ramsyscall_printf ("last LBA before %u, first LBA after %u, Setloc LBA %u\n", before, after, MSF2LBA(0, 2, 16))
 
 cester_assert_uint_ne (0, before)
 
 cester_assert_uint_ne (0, after)
 
 cester_assert_true (drained)
 
 cester_assert_uint_eq (before+1, after)
 

Variables

 CDROM_REG0 = 0
 
 CDROM_REG1 = CDL_READS
 
unsigned count = noSetLocCollect(events, 0, 24, 6)
 
unsigned split = count
 
int drained = noSetLocPauseAndDrain()
 
uint32_t before = noSetLocLastLBA(events, 0, split)
 
uint32_t after = noSetLocFirstLBA(events, split, count)
 

Function Documentation

◆ cester_assert_true()

cester_assert_true ( drained  )

◆ cester_assert_uint_eq()

cester_assert_uint_eq ( before+  1,
after   
)

◆ cester_assert_uint_ne() [1/2]

cester_assert_uint_ne ( 0  ,
after   
)

◆ cester_assert_uint_ne() [2/2]

cester_assert_uint_ne ( 0  ,
before   
)

◆ CESTER_BODY()

CESTER_BODY ( typedef struct { uint32_t time;uint8_t cause;uint8_t status;uint8_t header[4];} NoSetLocEvent;static unsigned noSetLocCollect(NoSetLocEvent *events, unsigned count, unsigned max, unsigned wantData) { unsigned dataReady=0;while((count< max) &&(dataReady< wantData)) { uint32_t timeout=3000000;if(!waitCDRomIRQWithTimeout(&timeout)) break;NoSetLocEvent *e=&events[count++];e->time=timeout;e->cause=ackCDRomCause();uint8_t response[16];readResponse(response);e->status=response[0];e->header[0]=e->header[1]=e->header[2]=e->header[3]=0;if(e->cause==1) { CDROM_REG0=0;CDROM_REG3=0x80;while((CDROM_REG0 &0x40)==0);for(unsigned i=0;i< 4;i++) e->header[i]=CDROM_REG2;CDROM_REG3=0;dataReady++;} } return count;} static int noSetLocPauseAndDrain() { CDROM_REG0=0;CDROM_REG1=CDL_PAUSE;while(1) { uint32_t timeout=3000000;if(!waitCDRomIRQWithTimeout(&timeout)) return 0;uint8_t cause=ackCDRomCause();discardResponse();if(cause==2) return 1;} } static void printNoSetLocEvents(const char *name, const NoSetLocEvent *events, unsigned count, unsigned split) { ramsyscall_printf("%s, %u events:", name, count);for(unsigned i=0;i< count;i++) { const NoSetLocEvent *e=&events[i];if(i==split) ramsyscall_printf(" |");ramsyscall_printf(" [%ius int%u stat %02x", e->time, e->cause, e->status);if(e->cause==1) { ramsyscall_printf(" hdr %02x:%02x:%02x m%u", e->header[0], e->header[1], e->header[2], e->header[3]);} ramsyscall_printf("]");} ramsyscall_printf("\n");} static uint32_t noSetLocHeaderLBA(const NoSetLocEvent *e) { return MSF2LBA(btoi(e->header[0]), btoi(e->header[1]), btoi(e->header[2]));} static uint32_t noSetLocLastLBA(const NoSetLocEvent *events, unsigned from, unsigned to) { uint32_t lba=0;for(unsigned i=from;i< to;i++) { if(events[i].cause==1) lba=noSetLocHeaderLBA(&events[i]);} return lba;} static uint32_t noSetLocFirstLBA(const NoSetLocEvent *events, unsigned from, unsigned to) { for(unsigned i=from;i< to;i++) { if(events[i].cause==1) return noSetLocHeaderLBA(&events[i]);} return 0;}   )

◆ initializeTime()

initializeTime ( )

◆ printNoSetLocEvents()

printNoSetLocEvents ( "ReadS at 00:02:16  ,
six  sectors,
ReadS again with no Setloc"  ,
events  ,
count  ,
split   
)

◆ ramsyscall_printf()

ramsyscall_printf ( "last LBA before %  u,
first LBA after %  u,
Setloc LBA %u\n"  ,
before  ,
after  ,
MSF2LBA(0, 2, 16)   
)

Variable Documentation

◆ after

uint32_t after = noSetLocFirstLBA(events, split, count)

◆ before

uint32_t before = noSetLocLastLBA(events, 0, split)

◆ CDROM_REG0

CDROM_REG0 = 0

◆ CDROM_REG1

CDROM_REG1 = CDL_READS

◆ count

count = noSetLocCollect(events, 0, 24, 6)

◆ drained

int drained = noSetLocPauseAndDrain()

◆ split

unsigned split = count