Ejemplo n.º 1
0
IPCCommandResult SDIOSlot0::IOCtl(const IOCtlRequest& request)
{
  Memory::Memset(request.buffer_out, 0, request.buffer_out_size);

  switch (request.request)
  {
  case IOCTL_WRITEHCR:
    return WriteHCRegister(request);
  case IOCTL_READHCR:
    return ReadHCRegister(request);
  case IOCTL_RESETCARD:
    return ResetCard(request);
  case IOCTL_SETCLK:
    return SetClk(request);
  case IOCTL_SENDCMD:
    return SendCommand(request);
  case IOCTL_GETSTATUS:
    return GetStatus(request);
  case IOCTL_GETOCR:
    return GetOCRegister(request);
  default:
    ERROR_LOG(IOS_SD, "Unknown SD IOCtl command (0x%08x)", request.request);
    break;
  }

  return GetDefaultReply(IPC_SUCCESS);
}
Ejemplo n.º 2
0
/**
 * CT-BCS Request ICC command
 *
 * @param ctx Reader context
 * @param lc Length of command
 * @param cmd Command
 * @param lr Length of response
 * @param rsp Response buffer
 * @return \ref OK, \ref ERR_CT, \ref ERR_MEMORY
 */
int RequestICC(struct scr *ctx, unsigned int lc, unsigned char *cmd,
			   unsigned int *lr, unsigned char *rsp)
{
	int status, timeout;

	if ((lc > 4) && (cmd[4] == 1)) {
		timeout = cmd[5];
	} else {
		timeout = 0;
	}

	status = PC_to_RDR_GetSlotStatus(ctx);

	if (status < 0) {
		rsp[0] = HIGH(NOT_SUCCESSFUL);
		rsp[1] = LOW(NOT_SUCCESSFUL);
		*lr = 2;
		return ERR_CT;
	}

	timeout *= 4;

	do {

		status = PC_to_RDR_GetSlotStatus(ctx);

		if (status < 0) {
			rsp[0] = HIGH(NOT_SUCCESSFUL);
			rsp[1] = LOW(NOT_SUCCESSFUL);
			*lr = 2;
			return ERR_CT;
		}

		if ((status == ICC_PRESENT_AND_INACTIVE) || !timeout) {
			break;
		}

		usleep(250000);
		timeout--;
	} while (timeout);

	if (!timeout && (status == NO_ICC_PRESENT)) {
		rsp[0] = HIGH(W_NO_CARD_PRESENTED);
		rsp[1] = LOW(W_NO_CARD_PRESENTED);
		*lr = 2;
		return OK;
	}

	if ((status = ResetCard(ctx, lc, cmd, lr, rsp)) < 0) {
		return status;
	}

	return OK;
}
Ejemplo n.º 3
0
static void UltraPlayStart(void)
{
    int t;



    for (t = 0; t < GUS_CHANNELS; t++) {
	voices[t].flags = 0;
	voices[t].handle = 0;
	voices[t].size = 0;
	voices[t].start = 0;
	voices[t].reppos = 0;
	voices[t].repend = 0;
	voices[t].changes = 0;
	voices[t].kick = 0;
	voices[t].freq = 10000;
	voices[t].vol = 64;
	voices[t].pan = 8192;
    }

    nr_voices = md_numchn;


    if (ResetCard() == FALSE) {
	exit(-1);
    }
    LoadSamples();

    gus_queue_write_set_size(1024);
    gus_queue_read_set_size(128);

    if (gus_timer_start() < 0) {
    }
    gus_timer_tempo(50);
    ULTRA_BPM = 0;

    for (t = 0; t < nr_voices; t++) {
	gus_do_voice_pan(t, 8192);
	gus_do_voice_volume(t, 50 << 7);
    }

    if (gus_do_flush() != 0) {
    }
}
Ejemplo n.º 4
0
/**
 * Pass a command to the reader driver and receive the response
 *
 * @param ctn Card terminal number
 * @param dad Destination address
 * @param sad Source address
 * @param lc Length of command data
 * @param cmd Command data
 * @param lr Size of response data buffer
 * @param rsp Response data
 * @return Status code \ref OK, \ref ERR_INVALID, \ref ERR_CT, \ref ERR_TRANS, \ref ERR_MEMORY, \ref ERR_HOST, \ref ERR_HTSI
 */
signed char CT_data(unsigned short ctn, unsigned char *dad, unsigned char *sad,
					unsigned short lc, unsigned char *cmd, unsigned short *lr,
					unsigned char *rsp)
{

	int rc;
	unsigned int ilr;
	scr_t *ctx;

	rc = LookupReader(ctn);

	if (rc < 0) {
		return ERR_CT;
	}

	ctx = readerTable[rc];

	if (!ctx) {
		return ERR_CT;
	}

	ilr = (int)*lr; /* Overcome problem with lr size     */

	rc = 0;

	if (mutex_lock(&ctx->mutex) != 0) {
		return ERR_MUTEX;
	}

	if (*dad == 1) {
		*sad = 1; /* Source Reader    */
		*dad = 2; /* Destination Host */

		/*******************/
		/* CT-BCS Commands */
		/*******************/

		if (cmd[0] == 0x20) {
			switch (cmd[1]) {
			case 0x12: /* Request ICC                       */
				rc = RequestICC(ctx, lc, cmd, &ilr, rsp);
				break;

			case 0x11: /* Resets the card/terminal and return ATR */
				rc = ResetCard(ctx, lc, cmd, &ilr, rsp);
				break;

			case 0x13: /* Get Status - Gets reader status   */
				rc = GetStatus(ctx, cmd, &ilr, rsp);
				break;

			case 0x15: /* Eject ICC - Deactivate reader    */
				rc = EjectICC(ctx, lc, cmd, &ilr, rsp);
				break;

			default: /* Wrong instruction for CTAPI */
				rsp[0] = HIGH(WRONG_INSTRUCTION);
				rsp[1] = LOW(WRONG_INSTRUCTION);
				ilr = 2;
				break;
			}
		} else { /* Wrong class for CTAPI */
			rsp[0] = HIGH(CLASS_NOT_SUPPORTED);
			rsp[1] = LOW(CLASS_NOT_SUPPORTED);
			ilr = 2;
		}

	} else if (*dad == 0) { /* This command goes to the card     */

		/*  Don't get confused here this is for the return saying

			the source was the card and the destination the host */

		*sad = 0; /* Source Smartcard */
		*dad = 2; /* Destination Host */

		if (ctx->CTModFunc) {
			rc = (*ctx->CTModFunc)(ctx, lc, cmd, &ilr, rsp);

			if (rc < 0) {
				rc = ERR_TRANS;
			}
		} else {
			*sad = 1; /* Shows that response comes from CTAPI */
			*dad = 2;
			rc = 0;
			rsp[0] = HIGH(COMMUNICATION_NOT_POSSIBLE);
			rsp[1] = LOW(COMMUNICATION_NOT_POSSIBLE);
			ilr = 2;
		}

	} else {
		rc = ERR_INVALID; /* Invalid SAD/DAD Address */
		ilr = 0;
	}

	*lr = ilr;

	if (mutex_unlock(&ctx->mutex) != 0) {
		return ERR_MUTEX;
	}

	return rc;
}