Esempio n. 1
0
int _start(int argc, char** argv)
{
  if(InitFAT() != 0)
  {
	printf("Error initializing FAT driver!\n");
	return MODULE_NO_RESIDENT_END;
  }

  init_ieee1394DiskDriver();

  DelDrv(dev_name);
  AddDrv(&device_driver);

#if 0
   iop_sys_clock_t lTime;
   u32 lSecStart, lUSecStart;
   u32 lSecEnd,   lUSecEnd, nbytes;
   int fd, size, bytesToRead, block_size;

   printf("trying to open file...");
   while((fd=open("sd0:PS2ESDL/SLPM_55052_00.pdi", O_RDONLY))<0){DelayThread(2000);};
   nbytes=size=lseek(fd, 0, SEEK_END)/4;
   block_size=2048*512;
   lseek(fd, 0, SEEK_SET);

   printf("Read test start\n" );

   GetSystemTime ( &lTime );
   SysClock2USec ( &lTime, &lSecStart, &lUSecStart );

	void *buffer;
	if((buffer=malloc(block_size))==NULL) printf("Unable to allocate memory. :(\n");
	printf("Read test: %p.\n", buffer);
	while(size>0){
		bytesToRead=(size>(block_size))?(block_size):size;
		read(fd, buffer, bytesToRead);
		size-=bytesToRead;
	}
	free(buffer);
	printf("Completed.\n");

   GetSystemTime ( &lTime );
   SysClock2USec ( &lTime, &lSecEnd, &lUSecEnd );
   close(fd);

   printf("Done: %lu %lu/%lu %lu\n", lSecStart, lUSecStart, lSecEnd, lUSecEnd );
   printf("KB: %ld, time: %ld, Approximate KB/s: %ld.\n", (nbytes/1024), (lSecEnd -lSecStart), (nbytes/1024)/(lSecEnd -lSecStart));
#endif

  return MODULE_RESIDENT_END;
}
Esempio n. 2
0
u32_t sys_now(void)
{
	iop_sys_clock_t	timenow;
	u32 seconds, usecs;

	GetSystemTime(&timenow);
	SysClock2USec(&timenow, &seconds, &usecs);

	return(seconds*1000 + usecs / 1000);
}
Esempio n. 3
0
static u32_t
ComputeTimeDiff(iop_sys_clock_t* pStart,iop_sys_clock_t* pEnd)
{
	iop_sys_clock_t	Diff;
	u32 iSec, iUSec, iDiff;

	Diff.lo=pEnd->lo-pStart->lo;
	Diff.hi=pEnd->hi-pStart->hi;

	SysClock2USec(&Diff, (u32 *)&iSec, (u32 *)&iUSec);
	iDiff=(iSec*1000)+(iUSec/1000);

	return((iDiff!=0)?iDiff:1);
}
Esempio n. 4
0
inline int initConfigureSBP2Device(struct SBP2Device *dev){
	unsigned char retries;

	retries=10;
	do{
		if(ieee1394_SendManagementORB(SBP2_LOGIN_REQUEST, dev)<0){
			XPRINTF("Error logging into the SBP-2 device.\n");
			retries--;
		}
		else break;
	}while(retries>0);
	if(retries==0){
		XPRINTF("Failed to log into the SBP-2 device.\n");
		return -1;
	}

	if(ieee1394_InitializeFetchAgent(dev)<0){
		XPRINTF("Error initializing the SBP-2 device's Fetch Agent.\n");
		return -2;
	}

	if(ConfigureSBP2Device(dev)<0) return -3;

	XPRINTF("Completed device initialization.\n");

	/****** !!!FOR TESTING ONLY!!! ******/
#if 0
	iop_sys_clock_t lTime;
	u32 lSecStart, lUSecStart;
	u32 lSecEnd,   lUSecEnd, nbytes, i, rounds;
	void *buffer;
	int result;

	nbytes=1048576;
	rounds=64;
	if((buffer=malloc(nbytes))==NULL) printf("Unable to allocate memory. :(\n");
	printf("Read test: %p.\n", buffer);
	printf("Start reading data...\n" );

	GetSystemTime ( &lTime );
	SysClock2USec ( &lTime, &lSecStart, &lUSecStart );

	for(i=0; i<rounds; i++){
		if((result=scsiReadSector(dev, 16, buffer, nbytes/512))!=0){
		    printf("Sector read error %d.\n", result);
		    break;
		}
	}
	free(buffer);

	GetSystemTime ( &lTime );
	SysClock2USec ( &lTime, &lSecEnd, &lUSecEnd );

	printf("Completed.\n");

	printf ( "Done: %lu %lu/%lu %lu\n", lSecStart, lUSecStart, lSecEnd, lUSecEnd );
	printf("KB: %lu, time: %lu, Approximate KB/s: %lu", (nbytes*rounds/1024), (lSecEnd -lSecStart), (nbytes*rounds/1024)/(lSecEnd -lSecStart));
	/****** !!!FOR TESTING ONLY!!! ******/
#endif

	return 0;
}