コード例 #1
0
ファイル: m2skernel.c プロジェクト: Anmol2307/PranaliOS
/* Execute one instruction from each running context. */
void ke_run(void)
{
	struct ctx_t *ctx, *ctx_trav; 
	int k = 0;

	/* Run an instruction from every running process */
	for (k=0, ctx = ke->suspended_list_head; ctx; ctx = ctx->suspended_next, k++);
	//printf ("Instruction number: %lld, suspended processes:%d, queue_size: %d\n", instr_num, k, sched_count);
	for (ctx = ke->running_list_head; ctx; ctx = ctx->running_next) {
		int i;
		for ( i = 0 ; i < ctx->instr_slice && ctx_get_status(ctx, ctx_running); ++i) {
			while (interrupts_exist() && instr_num >= next_interrupt_num())
				handle_interrupt (pop_interrupt());
			
			ctx_execute_inst(ctx);
			instr_num++;
		}
	}
	
	/* Free finished contexts */
	while (ke->finished_list_head)
		ctx_free(ke->finished_list_head);
	
	/* Process list of suspended contexts */
	//ke_process_events();
	while (!(ke->running_list_head) && interrupts_exist()) {
		//printf ("Instruction number updated from %lld to %lld\n", instr_num, next_interrupt_num());
		instr_num = next_interrupt_num();
		handle_interrupt(pop_interrupt());
	}
}
コード例 #2
0
ファイル: exti.c プロジェクト: Liambeguin/openlab
void exti9_5_isr()
{
    // check if EXTI lines 5 to 9 triggered the interrupt
    if (*exti_get_PR() & BV(EXTI_LINE_Px5))
    {
        handle_interrupt(EXTI_LINE_Px5);
    }

    if (*exti_get_PR() & BV(EXTI_LINE_Px6))
    {
        handle_interrupt(EXTI_LINE_Px6);
    }

    if (*exti_get_PR() & BV(EXTI_LINE_Px7))
    {
        handle_interrupt(EXTI_LINE_Px7);
    }

    if (*exti_get_PR() & BV(EXTI_LINE_Px8))
    {
        handle_interrupt(EXTI_LINE_Px8);
    }

    if (*exti_get_PR() & BV(EXTI_LINE_Px9))
    {
        handle_interrupt(EXTI_LINE_Px9);
    }
}
コード例 #3
0
ファイル: evaluator.c プロジェクト: mschaef/vcsh
EVAL_INLINE void _process_interrupts()
{
     if (!interp.intr_pending || interp.intr_masked)
          return;

     if (interp.intr_pending & VMINTR_BREAK)
          handle_interrupt(VMINTR_BREAK, TRAP_USER_BREAK);

     if (interp.intr_pending & VMINTR_TIMER)
          handle_interrupt(VMINTR_TIMER, TRAP_TIMER_EVENT);
}
コード例 #4
0
ファイル: pixma_imageclass.c プロジェクト: Ichoran/lifespan
static int
iclass_scan (pixma_t * s)
{
  int error, n;
  iclass_t *mf = (iclass_t *) s->subdriver;
  uint8_t *buf, ignore;
  unsigned buf_len, ignore2;

  if (mf->state != state_idle)
    return PIXMA_EBUSY;

  /* clear interrupt packets buffer */
  while (handle_interrupt (s, 0) > 0)
    {
    }

  mf->raw_width = ALIGN_SUP (s->param->w, 32);
  PDBG (pixma_dbg (3, "raw_width = %u\n", mf->raw_width));

  n = IMAGE_BLOCK_SIZE / s->param->line_size + 1;
  buf_len = (n + 1) * s->param->line_size + IMAGE_BLOCK_SIZE;
  if (buf_len > mf->buf_len)
    {
      buf = (uint8_t *) realloc (mf->buf, buf_len);
      if (!buf)
	return PIXMA_ENOMEM;
      mf->buf = buf;
      mf->buf_len = buf_len;
    }
  mf->lineptr = mf->buf;
  mf->blkptr = mf->buf + n * s->param->line_size;
  mf->blk_len = 0;

  error = step1 (s);
  if (error >= 0 && (s->param->adf_pageid == 0 || mf->generation == 1))
    { /* single sheet or first sheet from ADF */
      PDBG (pixma_dbg (3, "*iclass_scan***** start scanning *****\n"));
      error = start_session (s);
      if (error >= 0)
        mf->state = state_scanning;
      if (error >= 0)
        error = select_source (s);
    }
  else if (error >= 0)
    { /* next sheet from ADF */
      PDBG (pixma_dbg (3, "*iclass_scan***** scan next sheet from ADF  *****\n"));
      mf->state = state_scanning;
    }
  if (error >= 0)
    error = send_scan_param (s);
  if (error >= 0)
    error = request_image_block (s, 0, &ignore, &ignore2, &ignore, &ignore2);
  if (error < 0)
    {
      iclass_finish_scan (s);
      return error;
    }
  mf->last_block = 0;
  return 0;
}
/* Process any pending interrupt(s) after a group of parallel insns.  */
void
frv_process_interrupts (SIM_CPU *current_cpu)
{
  SI NE_flags[2];
  /* Need to save the pc here because writeback may change it (due to a
     branch).  */
  IADDR pc = CPU_PC_GET (current_cpu);

  /* Check for a reset before anything else.  */
  if (check_reset (current_cpu, pc))
    return;

  /* First queue the writes for any accumulated NE flags.  */
  if (frv_interrupt_state.f_ne_flags[0] != 0
      || frv_interrupt_state.f_ne_flags[1] != 0)
    {
      GET_NE_FLAGS (NE_flags, H_SPR_FNER0);
      NE_flags[0] |= frv_interrupt_state.f_ne_flags[0];
      NE_flags[1] |= frv_interrupt_state.f_ne_flags[1];
      SET_NE_FLAGS (H_SPR_FNER0, NE_flags);
    }

  /* If there is no interrupt pending, then perform parallel writeback.  This
     may cause an interrupt.  */
  if (frv_interrupt_state.queue_index <= 0)
    frvbf_perform_writeback (current_cpu);

  /* If there is an interrupt pending, then process it.  */
  if (frv_interrupt_state.queue_index > 0)
    handle_interrupt (current_cpu, pc);
}
コード例 #6
0
ファイル: eth.c プロジェクト: alexrayne/uos-embedded
/*
 * Poll for interrupts.
 * Must be called by user in case there is a chance to lose an interrupt.
 */
void eth_poll(eth_t *u) {
	uint32_t lock = mutex_trylock(&u->netif.lock);
	if (handle_interrupt(u))
		mutex_signal(&u->netif.lock, 0);
	if (lock)
		mutex_unlock(&u->netif.lock);
}
コード例 #7
0
ファイル: pixma_mp730.c プロジェクト: DspaceSPI/SPIScan
static int
mp730_open (pixma_t * s)
{
  mp730_t *mp;
  uint8_t *buf;

  mp = (mp730_t *) calloc (1, sizeof (*mp));
  if (!mp)
    return PIXMA_ENOMEM;

  buf = (uint8_t *) malloc (CMDBUF_SIZE);
  if (!buf)
    {
      free (mp);
      return PIXMA_ENOMEM;
    }

  s->subdriver = mp;
  mp->state = state_idle;

  mp->cb.buf = buf;
  mp->cb.size = CMDBUF_SIZE;
  mp->cb.res_header_len = 2;
  mp->cb.cmd_header_len = 10;
  mp->cb.cmd_len_field_ofs = 7;

  PDBG (pixma_dbg (3, "Trying to clear the interrupt buffer...\n"));
  if (handle_interrupt (s, 200) == 0)
    {
      PDBG (pixma_dbg (3, "  no packets in buffer\n"));
    }
  return 0;
}
コード例 #8
0
ファイル: pixma_mp730.c プロジェクト: DspaceSPI/SPIScan
static void
mp730_wait_event (pixma_t * s, int timeout)
{
  /* FIXME: timeout is not correct. See usbGetCompleteUrbNoIntr() for
   * instance. */
  while (s->events == 0 && handle_interrupt (s, timeout) > 0)
    {
    }
}
コード例 #9
0
void drv_napi_poll() {
  int work_done;
  work_done = handle_interrupt();
  if ((work_done) < (100)) {
    napi_complete();
    intr_mask = 255;
    write_IntrMask(255);
  }
}
コード例 #10
0
ファイル: B-28-program.c プロジェクト: thorstent/ConRepair
void drv_napi_poll() {
  int work_done;
  work_done = handle_interrupt();
  if (work_done < 100) {
    napi_complete();
    IntrMask = 255;
    intr_mask = 255;
  }
}
コード例 #11
0
ファイル: i2c-keywest.c プロジェクト: sarnobat/knoppix
static void
keywest_timeout(unsigned long data)
{
	struct keywest_iface *iface = (struct keywest_iface *)data;

	DBG("timeout !\n");
	spin_lock_irq(&iface->lock);
	if (handle_interrupt(iface, read_reg(reg_isr)))
		mod_timer(&iface->timeout_timer, jiffies + POLL_TIMEOUT);
	spin_unlock(&iface->lock);
}
コード例 #12
0
ファイル: i2c-keywest.c プロジェクト: sarnobat/knoppix
/* Interrupt handler */
static irqreturn_t
keywest_irq(int irq, void *dev_id, struct pt_regs *regs)
{
	struct keywest_iface *iface = (struct keywest_iface *)dev_id;

	spin_lock(&iface->lock);
	del_timer(&iface->timeout_timer);
	if (handle_interrupt(iface, read_reg(reg_isr)))
		mod_timer(&iface->timeout_timer, jiffies + POLL_TIMEOUT);
	spin_unlock(&iface->lock);
	return IRQ_HANDLED;
}
コード例 #13
0
ファイル: rtl8169.c プロジェクト: thorstent/ConRepair
void drv_napi_poll()
{
    int work_done;

    work_done = handle_interrupt();

    if (work_done < budget) {
        napi_complete();
        intr_mask = 0xff;
        IntrMask = 0xff;
    }
}
コード例 #14
0
void drv_napi_poll() { int thread_id = corral_getThreadID();
  int work_done;
  work_done = handle_interrupt();
  if (poirot_nondet()) {
  	__hv_assume ((work_done) < (100));
    napi_complete();
    write_IntrMask(255);
    intr_mask = 255;
  } else {
  	__hv_assume (!((work_done) < (100)));
  }
}
コード例 #15
0
ファイル: helper.c プロジェクト: AjayMashi/x-tier
void xtensa_cpu_do_interrupt(CPUState *cs)
{
    XtensaCPU *cpu = XTENSA_CPU(cs);
    CPUXtensaState *env = &cpu->env;

    if (env->exception_index == EXC_IRQ) {
        qemu_log_mask(CPU_LOG_INT,
                "%s(EXC_IRQ) level = %d, cintlevel = %d, "
                "pc = %08x, a0 = %08x, ps = %08x, "
                "intset = %08x, intenable = %08x, "
                "ccount = %08x\n",
                __func__, env->pending_irq_level, xtensa_get_cintlevel(env),
                env->pc, env->regs[0], env->sregs[PS],
                env->sregs[INTSET], env->sregs[INTENABLE],
                env->sregs[CCOUNT]);
        handle_interrupt(env);
    }

    switch (env->exception_index) {
    case EXC_WINDOW_OVERFLOW4:
    case EXC_WINDOW_UNDERFLOW4:
    case EXC_WINDOW_OVERFLOW8:
    case EXC_WINDOW_UNDERFLOW8:
    case EXC_WINDOW_OVERFLOW12:
    case EXC_WINDOW_UNDERFLOW12:
    case EXC_KERNEL:
    case EXC_USER:
    case EXC_DOUBLE:
    case EXC_DEBUG:
        qemu_log_mask(CPU_LOG_INT, "%s(%d) "
                "pc = %08x, a0 = %08x, ps = %08x, ccount = %08x\n",
                __func__, env->exception_index,
                env->pc, env->regs[0], env->sregs[PS], env->sregs[CCOUNT]);
        if (env->config->exception_vector[env->exception_index]) {
            env->pc = relocated_vector(env,
                    env->config->exception_vector[env->exception_index]);
            env->exception_taken = 1;
        } else {
            qemu_log("%s(pc = %08x) bad exception_index: %d\n",
                    __func__, env->pc, env->exception_index);
        }
        break;

    case EXC_IRQ:
        break;

    default:
        qemu_log("%s(pc = %08x) unknown exception_index: %d\n",
                __func__, env->pc, env->exception_index);
        break;
    }
    check_interrupts(env);
}
コード例 #16
0
ファイル: exti.c プロジェクト: Liambeguin/openlab
void exti15_10_isr()
{
    // check if EXTI lines 10 to 15 triggered the interrupt
    if (*exti_get_PR() & BV(EXTI_LINE_Px10))
    {
        handle_interrupt(EXTI_LINE_Px10);
    }

    if (*exti_get_PR() & BV(EXTI_LINE_Px11))
    {
        handle_interrupt(EXTI_LINE_Px11);
    }

    if (*exti_get_PR() & BV(EXTI_LINE_Px12))
    {
        handle_interrupt(EXTI_LINE_Px12);
    }

    if (*exti_get_PR() & BV(EXTI_LINE_Px13))
    {
        handle_interrupt(EXTI_LINE_Px13);
    }

    if (*exti_get_PR() & BV(EXTI_LINE_Px14))
    {
        handle_interrupt(EXTI_LINE_Px14);
    }

    if (*exti_get_PR() & BV(EXTI_LINE_Px15))
    {
        handle_interrupt(EXTI_LINE_Px15);
    }
}
コード例 #17
0
ファイル: eth.c プロジェクト: alexrayne/uos-embedded
/*
 * Interrupt task.
 */
static void interrupt_task(void *arg) {
	eth_t *u = arg;

	/* Register the interrupt. */
	mutex_lock_irq(&u->netif.lock, ETH_IRQ, 0, 0);

	for (;;) {
		/* Wait for the interrupt. */
		mutex_wait(&u->netif.lock);
		++u->intr;
		handle_interrupt(u);
	}
}
コード例 #18
0
ファイル: gbemu.c プロジェクト: theotime/gbemu
int main(int argc, char * argv[]) {
    if (argc != 2) {
        usage(argv[0]);
        exit(1);
    }
    
    if (SDL_Init(SDL_INIT_VIDEO) != 0) {
        printf("Echec init : %s\n", SDL_GetError());
        exit(1);
    }

    GBContext   *cpu = cpu_init(argv[1]);
    GPUContext  *gpu = gpu_init(cpu);
    JOYPContext *joyp = joyp_init(cpu);
    
    uint8_t op;
    unsigned int start_time, last_time, elapsed_time;
    while (!cpu->exit) {
        start_time = SDL_GetTicks();

        while (cpu->t_clock < VSYNC_CYCLES) {
            op = read8(cpu, cpu->PC++);
            execute(cpu, op);
            
            //"realtime" operations must be here..
            cpu_ctx_update(cpu);
            gpu_ctx_update(cpu, gpu);
            joyp_ctx_update(cpu, joyp);
            handle_interrupt(cpu);
        }
        cpu->t_clock = 0;

        last_time = SDL_GetTicks();
        elapsed_time = last_time - start_time;
        if(elapsed_time < VSYNC_TIME_MS) {// just a basic frame rate wait loop
            SDL_Delay(VSYNC_TIME_MS - elapsed_time);
        }
        
        gpu_render(cpu, gpu);
//        printf("elapsed: %d\n", elapsed_time);
    }

    
    joyp_destroy(joyp);
    gpu_destroy(gpu);
    cpu_destroy(cpu);
    SDL_Quit();

    return 0;
}
コード例 #19
0
static void
keywest_timeout(unsigned long data)
{
	struct keywest_iface *iface = (struct keywest_iface *)data;
	unsigned long flags;

	pr_debug("timeout !\n");
	spin_lock_irqsave(&iface->lock, flags);
	handle_interrupt(iface, read_reg(reg_isr));
	if (iface->state != state_idle) {
		iface->timeout_timer.expires = jiffies + POLL_TIMEOUT;
		add_timer(&iface->timeout_timer);
	}
	spin_unlock_irqrestore(&iface->lock, flags);
}
コード例 #20
0
/* Interrupt handler */
static irqreturn_t
keywest_irq(int irq, void *dev_id, struct pt_regs *regs)
{
	struct keywest_iface *iface = (struct keywest_iface *)dev_id;
	unsigned long flags;

	spin_lock_irqsave(&iface->lock, flags);
	del_timer(&iface->timeout_timer);
	handle_interrupt(iface, read_reg(reg_isr));
	if (iface->state != state_idle) {
		iface->timeout_timer.expires = jiffies + POLL_TIMEOUT;
		add_timer(&iface->timeout_timer);
	}
	spin_unlock_irqrestore(&iface->lock, flags);
	return IRQ_HANDLED;
}
コード例 #21
0
ファイル: CPUThread.cpp プロジェクト: DreadIsBack/rpcs3
bool cpu_thread::check_status()
{
	std::unique_lock<std::mutex> lock(get_current_thread_mutex(), std::defer_lock);

	while (true)
	{
		CHECK_EMU_STATUS; // check at least once

		if (state & cpu_state::exit)
		{
			return true;
		}

		if (!state.test(cpu_state_pause) && !state.test(cpu_state::interrupt))
		{
			break;
		}

		if (!lock)
		{
			lock.lock();
			continue;
		}

		if (!state.test(cpu_state_pause) && state & cpu_state::interrupt && handle_interrupt())
		{
			continue;
		}

		get_current_thread_cv().wait(lock);
	}

	const auto state_ = state.load();

	if (state_ & make_bitset(cpu_state::ret, cpu_state::stop))
	{
		return true;
	}

	if (state_ & cpu_state::dbg_step)
	{
		state += cpu_state::dbg_pause;
		state -= cpu_state::dbg_step;
	}

	return false;
}
コード例 #22
0
ファイル: handlers.c プロジェクト: mars20/riscv-pk
void handle_trap(trapframe_t* tf)
{
  if ((intptr_t)tf->cause < 0)
    return handle_interrupt(tf);

  typedef void (*trap_handler)(trapframe_t*);

  const static trap_handler trap_handlers[] = {
    [CAUSE_MISALIGNED_FETCH] = handle_misaligned_fetch,
    [CAUSE_FAULT_FETCH] = handle_fault_fetch,
    [CAUSE_ILLEGAL_INSTRUCTION] = handle_illegal_instruction,
    [CAUSE_USER_ECALL] = handle_syscall,
    [CAUSE_BREAKPOINT] = handle_breakpoint,
    [CAUSE_MISALIGNED_STORE] = handle_misaligned_store,
    [CAUSE_FAULT_LOAD] = handle_fault_load,
    [CAUSE_FAULT_STORE] = handle_fault_store,
  };
コード例 #23
0
interruptible_thread(FunctionType f)
{
	std::promise<interrupt_flag*> p;
	internal_thread = std::thread([f, &p] {
		p.set_value(&this_thread_interrupt_flag);
		try
		{
			f();
		}
		catch (thread_interrupted const&)
		{
			handle_interrupt();
		}

	});
	flag = p.get_future().get();
}
コード例 #24
0
ファイル: pixma_mp730.c プロジェクト: DspaceSPI/SPIScan
static int
mp730_scan (pixma_t * s)
{
  int error, n;
  mp730_t *mp = (mp730_t *) s->subdriver;
  uint8_t *buf;

  if (mp->state != state_idle)
    return PIXMA_EBUSY;

  /* clear interrupt packets buffer */
  while (handle_interrupt (s, 0) > 0)
    {
    }

  mp->raw_width = calc_raw_width (s, s->param);
  PDBG (pixma_dbg (3, "raw_width = %u\n", mp->raw_width));

  n = IMAGE_BLOCK_SIZE / s->param->line_size + 1;
  buf = (uint8_t *) malloc ((n + 1) * s->param->line_size + IMAGE_BLOCK_SIZE);
  if (!buf)
    return PIXMA_ENOMEM;
  mp->buf = buf;
  mp->lbuf = buf;
  mp->imgbuf = buf + n * s->param->line_size;
  mp->imgbuf_len = 0;

  error = step1 (s);
  if (error >= 0)
    error = start_session (s);
  if (error >= 0)
    mp->state = state_scanning;
  if (error >= 0)
    error = select_source (s);
  if (error >= 0)
    error = send_scan_param (s);
  if (error < 0)
    {
      mp730_finish_scan (s);
      return error;
    }
  mp->last_block = 0;
  return 0;
}
コード例 #25
0
ファイル: trap.c プロジェクト: duvitech/NyuziProcessor
void handle_trap(struct interrupt_frame *frame)
{
    unsigned int address;
    int trap_cause = __builtin_nyuzi_read_control_reg(CR_TRAP_CAUSE);

    switch (trap_cause & 0xf)
    {
        case TT_PAGE_FAULT:
        case TT_ILLEGAL_STORE:
            address = __builtin_nyuzi_read_control_reg(CR_TRAP_ADDR);
            enable_interrupts();
            if (!handle_page_fault(address, (trap_cause & 0x10) != 0))
            {
                // Jump to user_copy fault handler if set
                if (fault_handler[current_hw_thread()] != 0)
                    frame->pc = fault_handler[current_hw_thread()];
                else
                    bad_fault(frame);
            }

            disable_interrupts();
            break;

        case TT_SYSCALL:
            // Enable interrupts
            address = __builtin_nyuzi_read_control_reg(CR_TRAP_ADDR);
            enable_interrupts();

            frame->gpr[0] = handle_syscall(frame->gpr[0], frame->gpr[1],
                                           frame->gpr[2], frame->gpr[3],
                                           frame->gpr[4], frame->gpr[5]);

            frame->pc += 4;    // Next instruction
            disable_interrupts();
            break;

        case TT_INTERRUPT:
            handle_interrupt(frame);
            break;

        default:
            bad_fault(frame);
    }
}
コード例 #26
0
ファイル: CPUThread.cpp プロジェクト: rodrigonh/rpcs3
bool CPUThread::check_status()
{
	std::unique_lock<std::mutex> lock(mutex, std::defer_lock);

	while (true)
	{
		CHECK_EMU_STATUS; // check at least once

		if (!is_paused() && (m_state & CPU_STATE_INTR) == 0)
		{
			break;
		}

		if (!lock)
		{
			lock.lock();
			continue;
		}

		if (!is_paused() && (m_state & CPU_STATE_INTR) != 0 && handle_interrupt())
		{
			continue;
		}

		cv.wait(lock);
	}

	if (m_state & CPU_STATE_RETURN || is_stopped())
	{
		return true;
	}

	if (m_state & CPU_STATE_STEP)
	{
		// set PAUSE, but allow to execute once
		m_state |= CPU_STATE_PAUSED;
		m_state &= ~CPU_STATE_STEP;
	}

	return false;
}
コード例 #27
0
static int
iclass_open (pixma_t * s)
{
  iclass_t *mf;
  uint8_t *buf;

  mf = (iclass_t *) calloc (1, sizeof (*mf));
  if (!mf)
    return PIXMA_ENOMEM;

  buf = (uint8_t *) malloc (CMDBUF_SIZE);
  if (!buf)
    {
      free (mf);
      return PIXMA_ENOMEM;
    }

  s->subdriver = mf;
  mf->state = state_idle;

  mf->cb.buf = buf;
  mf->cb.size = CMDBUF_SIZE;
  mf->cb.res_header_len = 2;
  mf->cb.cmd_header_len = 10;
  mf->cb.cmd_len_field_ofs = 7;

  /* set generation = 2 for new multifunctionals
   * some new scanners use generation 1 protocol */
  mf->generation = (s->cfg->pid >= MF8030_PID &&
                    s->cfg->pid != MF8200_PID &&
                    s->cfg->pid != MF8500_PID) ? 2 : 1;
  PDBG (pixma_dbg (3, "*iclass_open***** This is a generation %d scanner.  *****\n", mf->generation));

  PDBG (pixma_dbg (3, "Trying to clear the interrupt buffer...\n"));
  if (handle_interrupt (s, 200) == 0)
    {
      PDBG (pixma_dbg (3, "  no packets in buffer\n"));
    }
  return 0;
}
コード例 #28
0
ファイル: pixma_mp750.c プロジェクト: Ichoran/lifespan
static int
mp750_open (pixma_t * s)
{
  mp750_t *mp;
  uint8_t *buf;

  mp = (mp750_t *) calloc (1, sizeof (*mp));
  if (!mp)
    return PIXMA_ENOMEM;

  buf = (uint8_t *) malloc (CMDBUF_SIZE);
  if (!buf)
    {
      free (mp);
      return PIXMA_ENOMEM;
    }

  s->subdriver = mp;
  mp->state = state_idle;

  /* ofs:   0   1    2  3  4  5  6  7  8  9
     cmd: cmd1 cmd2 00 00 00 00 00 00 00 00
     data length-^^^^^    => cmd_len_field_ofs
     |--------- cmd_header_len --------|

     res: res1 res2
     |---------| res_header_len
   */
  mp->cb.buf = buf;
  mp->cb.size = CMDBUF_SIZE;
  mp->cb.res_header_len = 2;
  mp->cb.cmd_header_len = 10;
  mp->cb.cmd_len_field_ofs = 7;

  handle_interrupt (s, 200);
  workaround_first_command (s);
  return 0;
}
コード例 #29
0
ファイル: psl.c プロジェクト: open-cpu/pslse
// Handle events from AFU
static void _handle_afu(struct psl *psl)
{
	struct client *client;
	uint64_t error;
	uint8_t *buffer;
	int reset_done;
	size_t size;

	reset_done = handle_aux2(psl->job, &(psl->parity_enabled),
				 &(psl->latency), &error);
	if (error && !directed_mode_support(psl->mmio)) {
		client = psl->client[0];
		size = 1 + sizeof(uint64_t);
		buffer = (uint8_t *) malloc(size);
		buffer[0] = PSLSE_AFU_ERROR;
		error = htonll(error);
		memcpy((char *)&(buffer[1]), (char *)&error, sizeof(error));
		if (put_bytes
		    (client->fd, size, buffer, psl->dbg_fp, psl->dbg_id,
		     0) < 0) {
			client_drop(client, PSL_IDLE_CYCLES, CLIENT_NONE);
		}
	}
	handle_mmio_ack(psl->mmio, psl->parity_enabled);
	if (psl->cmd != NULL) {
		if (reset_done)
			psl->cmd->credits = psl->cmd->parms->credits;
		handle_response(psl->cmd);
		handle_buffer_write(psl->cmd);
		handle_buffer_read(psl->cmd);
		handle_buffer_data(psl->cmd, psl->parity_enabled);
		handle_mem_write(psl->cmd);
		handle_touch(psl->cmd);
		handle_cmd(psl->cmd, psl->parity_enabled, psl->latency);
		handle_interrupt(psl->cmd);
	}
}
コード例 #30
0
ファイル: slutty.c プロジェクト: ebichu/dd-wrt
unsigned int _pSLsys_getkey (void)
{
   unsigned char c;

   if (TTY_Inited == 0)
     {
	int ic = fgetc (stdin);
	if (ic == EOF) return SLANG_GETKEY_ERROR;
	return (unsigned int) ic;
     }

   while (1)
     {
	int ret;

	if (SLKeyBoard_Quit)
	  return SLang_Abort_Char;

	if (0 == (ret = _pSLsys_input_pending (100)))
	  continue;

	if (ret != -1)
	  break;

	if (errno == EINTR)
	  {
	     if (-1 == handle_interrupt ())
	       return SLANG_GETKEY_ERROR;
	     
	     if (SLKeyBoard_Quit)
	       return SLang_Abort_Char;

	     continue;
	  }

	if (SLKeyBoard_Quit)
	  return SLang_Abort_Char;

	break;			       /* let read handle it */
     }

   while (1)
     {
	int status = read(SLang_TT_Read_FD, (char *) &c, 1);

	if (status > 0)
	  break;

	if (status == 0)
	  {
	     /* We are at the end of a file.  Let application handle it. */
	     return SLANG_GETKEY_ERROR;
	  }

	if (errno == EINTR)
	  {
	     if (-1 == handle_interrupt ())
	       return SLANG_GETKEY_ERROR;

	     if (SLKeyBoard_Quit)
	       return SLang_Abort_Char;

	     continue;
	  }
#ifdef EAGAIN
	if (errno == EAGAIN)
	  {
	     sleep (1);
	     continue;
	  }
#endif
#ifdef EWOULDBLOCK
	if (errno == EWOULDBLOCK)
	  {
	     sleep (1);
	     continue;
	  }
#endif
#ifdef EIO
	if (errno == EIO)
	  {
	     _pSLang_verror (SL_Read_Error, "_pSLsys_getkey: EIO error");
	  }
#endif
	return SLANG_GETKEY_ERROR;
     }

   return((unsigned int) c);
}