コード例 #1
0
ファイル: imgdrv.c プロジェクト: darkseedzero/open-ps2-loader
int _start( int argc, char **argv)
{
	//DelDrv("img");
	AddDrv((iop_device_t*)&my_device);

	return MODULE_RESIDENT_END;
}
コード例 #2
0
ファイル: codyvdfs.c プロジェクト: 86400/scummvm
int _start(void) {
	printf("CoDyVDfs v0.01\n");

	CdInit(1);
	DelDrv(FS_NAME);
	AddDrv(&fsdriver);

	initRpc();
	initFio();
	return(0);
}
コード例 #3
0
ファイル: main.c プロジェクト: scuriumk/ps2sdk
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;
}
コード例 #4
0
ファイル: sbus_tty.c プロジェクト: sp193/ps2sdk
int sbus_tty_init(void)
{
    close(0);
    close(1);
	DelDrv("tty");
	DelDrv("dummytty");

	if(AddDrv(&tty_fsd) != 0) { return(-1); }

    open("tty:", O_RDONLY);
    open("tty:", O_WRONLY);

    Kprintf_set((kprintf_handler_func_t *) &_kPrintf, 0);

    return(0);
}
コード例 #5
0
ファイル: devfs.c プロジェクト: AKuHAK2/ps2sdk
/** DevFS initialise function
    @returns >= 0 on success, -1 on error
*/
int init_devfs(void)

{
   int dummy_loop;
   dummy_func *dummy;

   root_device = NULL;
   dev_count = 0;

   /* Set all io handlers to dummy values */
   dummy = (dummy_func *) &devfs_ops;
   for(dummy_loop = 0; dummy_loop < (sizeof(iop_device_ops_t) / sizeof(dummy)); dummy_loop++)
   {
      dummy[dummy_loop] = devfs_dummy;
   }
   memset(open_dirfiles, 0, sizeof(directory_file_t) * MAX_OPEN_DIRFILES);

   devfs_device.name = "devfs";
   devfs_device.type = IOP_DT_FS | IOP_DT_FSEXT;
   devfs_device.version = 0x100;
   devfs_device.desc = "PS2 Device FS Driver";
   devfs_device.ops = &devfs_ops;
   devfs_ops.init = devfs_init;
   devfs_ops.deinit = devfs_deinit;
   devfs_ops.open = devfs_open;
   devfs_ops.read = devfs_read;
   devfs_ops.close = devfs_close;
   devfs_ops.dopen = devfs_dopen;
   devfs_ops.dclose = devfs_dclose;
   devfs_ops.dread = devfs_dread;
   devfs_ops.ioctl = devfs_ioctl;
   devfs_ops.ioctl2 = devfs_ioctl2;
   devfs_ops.getstat = devfs_getstat;
   DelDrv("devfs");

   return AddDrv(&devfs_device);
}
コード例 #6
0
ファイル: dev9.c プロジェクト: darkseedzero/open-ps2-loader
int dev9_init(void)
{
	USE_DEV9_REGS;
	int idx, res = 1;
	u16 dev9hw;

	M_PRINTF(BANNER, VERSION);

	for (idx = 0; idx < 16; idx++)
		dev9_shutdown_cbs[idx] = NULL;

	dev9hw = DEV9_REG(DEV9_R_REV) & 0xf0;
	if (dev9hw == 0x20) {		/* CXD9566 (PCMCIA) */
		dev9type = 0;
#ifdef PCMCIA
		res = pcmcia_init();
#else
		return 1;
#endif
	} else if (dev9hw == 0x30) {	/* CXD9611 (Expansion Bay) */
		dev9type = 1;
#ifndef PCMCIA
		res = expbay_init();
#else
		return 1;
#endif
	}

	if (res)
		return res;

	DelDrv("dev9x");
	AddDrv((iop_device_t *)&dev9x_dev);

	return 0;
}
コード例 #7
0
ファイル: hdd.c プロジェクト: uyjulian/pfsshell
int _start(int argc, char **argv)
{
    int i, ret;
    char *input;
    int cacheSize = 3;
    apa_ps2time_t tm;
    ata_devinfo_t *hddInfo;

    printStartup();

    if ((input = strrchr(argv[0], '/')))
        input++;
    else
        input = argv[0];

    argc--;
    argv++;
    while (argc) {
        if (argv[0][0] != '-')
            break;
        if (strcmp("-o", argv[0]) == 0) {
            argc--;
            argv++;
            if (!argc)
                return inputError(input);
            i = strtol(argv[0], 0, 10);
            if (i - 1 < 32)
                apaMaxOpen = i;
        } else if (strcmp("-n", argv[0]) == 0) {
            argc--;
            argv++;
            if (!argc)
                return inputError(input);
            i = strtol(*argv, 0, 10);
            if (cacheSize < i)
                cacheSize = i;
        }
        argc--;
        argv++;
    }

    APA_PRINTF(APA_DRV_NAME ": max open = %d, %d buffers\n", apaMaxOpen, cacheSize);
    if (dev9RegisterShutdownCb(0, &hddShutdownCb) != 0) {
        APA_PRINTF(APA_DRV_NAME ": error: dev9 may not be resident.\n");
        return hddInitError();
    }

    if (apaGetTime(&tm) != 0) {
        APA_PRINTF(APA_DRV_NAME ": error: could not get date.\n");
        return hddInitError();
    }

    APA_PRINTF(APA_DRV_NAME ": %02d:%02d:%02d %02d/%02d/%d\n",
               tm.hour, tm.min, tm.sec, tm.month, tm.day, tm.year);
    for (i = 0; i < 2; i++) {
        if (!(hddInfo = ata_get_devinfo(i))) {
            APA_PRINTF(APA_DRV_NAME ": Error: ata initialization failed.\n");
            return hddInitError();
        }
        if (hddInfo->exists != 0 && hddInfo->has_packet == 0) {
            hddDevices[i].status--;
            hddDevices[i].totalLBA = hddInfo->total_sectors;
            hddDevices[i].partitionMaxSize = apaGetPartitionMax(hddInfo->total_sectors);
            if (unlockDrive(i) == 0)
                hddDevices[i].status--;
            APA_PRINTF(APA_DRV_NAME ": disk%d: 0x%08lx sectors, max 0x%08lx\n", i,
                       hddDevices[i].totalLBA, hddDevices[i].partitionMaxSize);
        }
    }
    hddFileSlots = apaAllocMem(apaMaxOpen * sizeof(hdd_file_slot_t));
    ret = (hddFileSlots == NULL) ? -ENOMEM : 0;
    if (ret != 0) {
        APA_PRINTF(APA_DRV_NAME ": error: file descriptor initialization failed.\n");
        return hddInitError();
    }

    memset(hddFileSlots, 0, apaMaxOpen * sizeof(hdd_file_slot_t));

    if (apaCacheInit(cacheSize) != 0) {
        APA_PRINTF(APA_DRV_NAME ": error: cache buffer initialization failed.\n");
        return hddInitError();
    }

    for (i = 0; i < 2; i++) {
        if (hddDevices[i].status < 2) {
            if (apaJournalRestore(i) != 0) {
                APA_PRINTF(APA_DRV_NAME ": error: log check failed.\n");
                return hddInitError();
            }
            if (apaGetFormat(i, &hddDevices[i].format))
                hddDevices[i].status--;
            APA_PRINTF(APA_DRV_NAME ": drive status %d, format version %08x\n",
                       hddDevices[i].status, hddDevices[i].format);
        }
    }
    DelDrv("hdd");
    if (AddDrv(&hddFioDev) == 0) {
#ifdef APA_OSD_VER
        APA_PRINTF(APA_DRV_NAME ": version %04x driver start. This is OSD version!\n", IRX_VER(APA_MODVER_MAJOR, APA_MODVER_MINOR));
#else
        APA_PRINTF(APA_DRV_NAME ": version %04x driver start.\n", IRX_VER(APA_MODVER_MAJOR, APA_MODVER_MINOR));
#endif
        return MODULE_RESIDENT_END;
    } else {
        APA_PRINTF(APA_DRV_NAME ": error: add device failed.\n");
        return hddInitError();
    }
}
コード例 #8
0
ファイル: hdd.c プロジェクト: EvertonSilva/ps2sdk
int _start(int argc, char **argv)
{
	int 	i;
	char	*input;
	int		cacheSize=3;
	ps2time tm;
	t_shddInfo *hddInfo;

	printStartup();
	// decode MBR Magic
	for(i=0;i!=0x20;i++)
		mbrMagic[i]^='x';

	if((input=strrchr(argv[0], '/')))
		input++;
	else
		input=argv[0];

	argc--; argv++;
	while(argc)
	{
		if(argv[0][0] != '-') 
			break;
		if(strcmp("-o", argv[0])==0){
			argc--; argv++;
			if(!argc)
				return inputError(input);
			i=strtol(argv[0], 0, 10);
			if(i-1<32)
				maxOpen=i;
		}
		else if(strcmp("-n", argv[0])==0){
			argc--; argv++;
			if(!argc)
				return inputError(input);
			i=strtol(*argv, 0, 10);
			if(cacheSize<i)
				cacheSize=i;
		}
		argc--; argv++;
	}

	printf("ps2hdd: max open = %ld, %d buffers\n", maxOpen, cacheSize);
	getPs2Time(&tm);
	printf("ps2hdd: %02d:%02d:%02d %02d/%02d/%d\n",
		tm.hour, tm.min, tm.sec, tm.month, tm.day, tm.year);
	for(i=0;i < 2;i++)
	{
		if(!(hddInfo=atadInit((u16)i))){
			printf("ps2hdd: Error: ata initialization failed.\n");
			return 0;
		}
		if(hddInfo->exists!=0 && hddInfo->has_packet==0){
				hddDeviceBuf[i].status--;
				hddDeviceBuf[i].totalLBA=hddInfo->total_sectors;
				hddDeviceBuf[i].partitionMaxSize=apaGetPartitionMax(hddInfo->total_sectors);
				if(unlockDrive(i)==0)
					hddDeviceBuf[i].status--;
				printf("ps2hdd: disk%d: 0x%08lx sectors, max 0x%08lx\n", i,
					hddDeviceBuf[i].totalLBA, hddDeviceBuf[i].partitionMaxSize);
		}
	}
	fileSlots=allocMem(maxOpen*sizeof(hdd_file_slot_t));
	if(fileSlots)
		memset(fileSlots, 0, maxOpen*sizeof(hdd_file_slot_t));

	cacheInit(cacheSize);
	for(i=0;i < 2;i++)
	{
		if(hddDeviceBuf[i].status<2){
			if(journalResetore(i)!=0)
				return 1;
			if(apaGetFormat(i, (int *)&hddDeviceBuf[i].format))
				hddDeviceBuf[i].status--;
			printf("ps2hdd: drive status %ld, format version %08lx\n",
				hddDeviceBuf[i].status, hddDeviceBuf[i].format);
		}
	}
	DelDrv("hdd");
	if(AddDrv(&hddFioDev)==0)
	{
		printf("ps2hdd: driver start.\n");
		return 0;
	}
	return 1;
}
コード例 #9
0
ファイル: fs_driver.c プロジェクト: AKuHAK2/ps2sdk
/* init file system driver */
int InitFS(void)
{
	DelDrv("sd");
	return(AddDrv(&fs_driver) == 0 ? 0 : -1);
}