示例#1
0
文件: hdd.c 项目: uyjulian/pfsshell
static void hddShutdownCb(void)
{
    int i;

    for (i = 0; i < 2; i++) {
        if (hddDevices[i].status == 0)
            ata_device_smart_save_attr(i);
    }
}
示例#2
0
文件: hdd_fio.c 项目: AKuHAK2/ps2sdk
int hddDevctl(iop_file_t *f, const char *devname, int cmd, void *arg,
			  unsigned int arglen, void *bufp, unsigned int buflen)
{
	int	rv=0;

	WaitSema(fioSema);
	switch(cmd)
	{
	// Command set 1 ('H')
	case HDIOC_DEV9OFF:
		ata_device_smart_save_attr(f->unit);
		dev9Shutdown();
		break;

	case HDIOC_IDLE:
		rv=ata_device_idle(f->unit, *(char *)arg);
		break;

	case HDIOC_MAXSECTOR:
		rv=hddDevices[f->unit].partitionMaxSize;
		break;

	case HDIOC_TOTALSECTOR:
		rv=hddDevices[f->unit].totalLBA;
		break;

	case HDIOC_FLUSH:
		if(ata_device_flush_cache(f->unit))
			rv=-EIO;
		break;

	case HDIOC_SWAPTMP:
		rv=devctlSwapTemp(f->unit, (char *)arg);
		break;

	case HDIOC_SMARTSTAT:
		rv=ata_device_smart_get_status(f->unit);
		break;

	case HDIOC_STATUS:
		rv=hddDevices[f->unit].status;
		break;

	case HDIOC_FORMATVER:
		rv=hddDevices[f->unit].format;
		break;

	case HDIOC_FREESECTOR:
		rv=apaGetFreeSectors(f->unit, bufp, hddDevices);
		break;

	case HDIOC_IDLEIMM:
		rv=ata_device_idle_immediate(f->unit);
		break;

	// Command set 2 ('h')
	case HDIOC_GETTIME:
		rv=apaGetTime((apa_ps2time_t *)bufp);
		break;

	case HDIOC_SETOSDMBR:
		rv=devctlSetOsdMBR(f->unit, (hddSetOsdMBR_t *)arg);
		break;

	case HDIOC_GETSECTORERROR:
		rv=apaGetPartErrorSector(f->unit, APA_SECTOR_SECTOR_ERROR, 0);
		break;

	case HDIOC_GETERRORPARTNAME:
		rv=apaGetPartErrorName(f->unit, (char *)bufp);
		break;

	case HDIOC_READSECTOR:
		rv=ata_device_sector_io(f->unit, (void *)bufp, ((hddAtaTransfer_t *)arg)->lba,
			((hddAtaTransfer_t *)arg)->size, ATA_DIR_READ);
		break;

	case HDIOC_WRITESECTOR:
		rv=ata_device_sector_io(f->unit, ((hddAtaTransfer_t *)arg)->data,
			((hddAtaTransfer_t *)arg)->lba, ((hddAtaTransfer_t *)arg)->size,
				ATA_DIR_WRITE);
		break;

	case HDIOC_SCEIDENTIFY:
		rv=ata_device_sce_identify_drive(f->unit, (u16 *)bufp);
		break;

	default:
		rv=-EINVAL;
		break;
	}
	SignalSema(fioSema);

	return rv;
}