Example #1
0
int hddIoctl2(iop_file_t *f, int req, void *argp, unsigned int arglen,
			  void *bufp, unsigned int buflen)
{
	u32 rv=0, err_lba;
	hdd_file_slot_t *fileSlot=f->privdata;

	WaitSema(fioSema);
	switch(req)
	{
	// cmd set 1
	case HIOCADDSUB:
		rv=ioctl2AddSub(fileSlot, (char *)argp);
		break;

	case HIOCDELSUB:
		rv=ioctl2DeleteLastSub(fileSlot);
		break;

	case HIOCNSUB:
		rv=fileSlot->nsub;
		break;

	case HIOCFLUSH:
		ata_device_flush_cache(f->unit);
		break;

	// cmd set 2
	case HIOCTRANSFER:
		rv=ioctl2Transfer(f->unit, fileSlot, argp);
		break;

	case HIOCGETSIZE:
		rv=fileSlot->parts[*(u32 *)argp].length;
		break;

	case HIOCSETPARTERROR:
		apaSetPartErrorSector(f->unit, fileSlot->parts[0].start); rv=0;
		break;

	case HIOCGETPARTERROR:
		if((rv=apaGetPartErrorSector(f->unit, APA_SECTOR_PART_ERROR, &err_lba)) > 0) {
			if(err_lba==fileSlot->parts[0].start) {
				rv=0; apaSetPartErrorSector(f->unit, 0);// clear last error :)
			}
		}
		break;

	default:
		rv=-EINVAL;
		break;
	}
	SignalSema(fioSema);
	return rv;
}
Example #2
0
int hddIoctl2(iop_file_t *f, int req, void *argp, unsigned int arglen,
			  void *bufp, unsigned int buflen)
{
	u32 rv=0;
	hdd_file_slot_t *fileSlot=f->privdata;

	WaitSema(fioSema);
	switch(req)
	{
	// cmd set 1
	case APA_IOCTL2_ADD_SUB:
		rv=ioctl2AddSub(fileSlot, (char *)argp);
		break;

	case APA_IOCTL2_DELETE_LAST_SUB:
		rv=ioctl2DeleteLastSub(fileSlot);
		break;

	case APA_IOCTL2_NUMBER_OF_SUBS:
		rv=fileSlot->nsub;
		break;

	case APA_IOCTL2_FLUSH_CACHE:
		atadFlushCache(f->unit);
		break;

	// cmd set 2
	case APA_IOCTL2_TRANSFER_DATA:
		rv=ioctl2Transfer(f->unit, fileSlot, argp);
		break;

	case APA_IOCTL2_GETSIZE:
		//	rv=fileSlot->subs[*(u32 *)argp].length;
		rv=((apa_subs *)(&fileSlot->start))[*(u32 *)argp].length;	// !HACK!
		break;

	case APA_IOCTL2_GETHEADER:
		if(atadDmaTransfer(f->unit, bufp, fileSlot->start, sizeof(apa_header)/512, ATAD_MODE_READ))
			rv=-EIO;
		rv=sizeof(apa_header);
		break;

	case APA_IOCTL2_SET_PART_ERROR:
		setPartErrorSector(f->unit, fileSlot->start); rv=0;
		break;

	case APA_IOCTL2_GET_PART_ERROR:
		if((rv=getPartErrorSector(f->unit, APA_SECTOR_PART_ERROR, bufp)) > 0) {
			if(*(u32 *)bufp==fileSlot->start) {
				rv=0; setPartErrorSector(f->unit, 0);// clear last error :)
			}
		}
		break;

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