コード例 #1
0
ファイル: fdc-test.c プロジェクト: CarterTsai/qemu_stm32
static void test_relative_seek(void)
{
    uint8_t drive = 0;
    uint8_t head = 0;
    uint8_t cyl = 1;
    uint8_t pcn;

    /* Send seek to track 0 */
    send_seek(0);

    /* Send relative seek to increase track by 1 */
    floppy_send(CMD_RELATIVE_SEEK_IN);
    floppy_send(head << 2 | drive);
    g_assert(!get_irq(FLOPPY_IRQ));
    floppy_send(cyl);

    ack_irq(&pcn);
    g_assert(pcn == 1);

    /* Send relative seek to decrease track by 1 */
    floppy_send(CMD_RELATIVE_SEEK_OUT);
    floppy_send(head << 2 | drive);
    g_assert(!get_irq(FLOPPY_IRQ));
    floppy_send(cyl);

    ack_irq(&pcn);
    g_assert(pcn == 0);
}
コード例 #2
0
ファイル: irq.c プロジェクト: andreiw/mkunity
static inline void device_interrupt(int irq, int ack, struct pt_regs * regs)
{
	struct irqaction * action;

	if ((unsigned) irq > NR_IRQS) {
		printk("device_interrupt: unexpected interrupt %d\n", irq);
		return;
	}

	kstat.interrupts[irq]++;
	action = irq_action[irq];
	/*
	 * For normal interrupts, we mask it out, and then ACK it.
	 * This way another (more timing-critical) interrupt can
	 * come through while we're doing this one.
	 *
	 * Note! A irq without a handler gets masked and acked, but
	 * never unmasked. The autoirq stuff depends on this (it looks
	 * at the masks before and after doing the probing).
	 */
	mask_irq(ack);
	ack_irq(ack);
	if (!action)
		return;
	if (action->flags & SA_SAMPLE_RANDOM)
		add_interrupt_randomness(irq);
	do {
		action->handler(irq, action->dev_id, regs);
		action = action->next;
	} while (action);
	unmask_irq(ack);
}
コード例 #3
0
ファイル: fdc-test.c プロジェクト: CarterTsai/qemu_stm32
static void send_seek(int cyl)
{
    int drive = 0;
    int head = 0;

    floppy_send(CMD_SEEK);
    floppy_send(head << 2 | drive);
    g_assert(!get_irq(FLOPPY_IRQ));
    floppy_send(cyl);
    ack_irq(NULL);
}
コード例 #4
0
ファイル: console.c プロジェクト: jkaivo/Composite
int
keyboard_handler(struct pt_regs *regs)
{
	u16_t scancode;
	int preempt = 1;

	ack_irq(IRQ_KEYBOARD);

	while(inb(KEY_PENDING) & 2) {
		/* wait for keypress to be ready */
	}
	scancode = inb(KEY_DEVICE);
	printk("Keyboard press: %d\n", scancode);
	return preempt;
}
コード例 #5
0
ファイル: pic.c プロジェクト: sjkingo/luminary
void irq_handler(struct trap_frame frame)
{
    switch (frame.trapno) {
        case IRQ_TIMER:
            timer_tick();
            goto out;

        default:
            printk("Unhandled IRQ%d\n", frame.trapno);
            goto out;
    }

out:
    ack_irq(frame.trapno);
}
コード例 #6
0
ファイル: irq.c プロジェクト: AdamRLukaitis/spoon
int irq_handler( int irq )
{
	acquire_spinlock( &irq_lock );
	mask_irq( irq );

	dmesg("%!IRQ %i occurred on %i\n", irq, CPUID );
	
		if ( handlers[irq] != NULL )
		{
			queue( handlers[irq] );
		}
	

	ack_irq( irq );
	release_spinlock( &irq_lock );
	return 0;
}
コード例 #7
0
ファイル: interrupt.c プロジェクト: LDVSOFT/os-course
void isr_common_handler(struct thread_regs *ctx)
{
	const int intno = ctx->intno;

	if (intno < IDT_EXCEPTIONS) {
		default_exception_handler(ctx);
		return;
	}

	const int irqno = intno - IDT_EXCEPTIONS;
	const irq_t irq = handler[irqno];

	mask_irq(irqno);
	ack_irq(irqno);
	if (irq)
		irq(irqno);
	unmask_irq(irqno);
}
コード例 #8
0
ファイル: mmc_hotplug.c プロジェクト: HackLinux/jz4725
static void MMCGpioTask(void *arg)
{
	u8 err;
	cardstate = CARD_OUT;
	cardexsit = 1 ;
	while(1)
	{
//		__intc_mask_irq(48 + MMC_CD_PIN);
		printf("Looks like MMC gpio change! \n");
		if ( cardstate == CARD_OUT )     //card have inserted!
		{
			OSTimeDlyHMSM(0,0,2,0);
			if ( __gpio_get_pin(MMC_CD_PIN) == 0 ) //card readlly insert!
			{
				printf("Card readlly insert! \n");
				cardstate = CARD_IN;
				info_card_in();
				MMC_Initialize();
				__gpio_as_irq_rise_edge(MMC_CD_PIN);
			}
			else
				__gpio_as_irq_fall_edge(MMC_CD_PIN);
		}
		else                            //card have not inserted!
		{
			OSTimeDlyHMSM(0,0,2,0);
			if ( __gpio_get_pin(MMC_CD_PIN) == 1 ) //card readlly out!
			{
				printf("Card readlly out! \n");
				cardstate = CARD_OUT;
				info_card_out();
				__gpio_as_irq_fall_edge(MMC_CD_PIN);
			}
			else
				__gpio_as_irq_rise_edge(MMC_CD_PIN);

		}
		__gpio_ack_irq(MMC_CD_PIN);
		ack_irq(48 + MMC_CD_PIN);
		__gpio_unmask_irq(MMC_CD_PIN);
		OSSemPend(MMCGPIOEvent, 0, &err);
	}
}
コード例 #9
0
ファイル: fdc-test.c プロジェクト: CarterTsai/qemu_stm32
static void test_read_id(void)
{
    uint8_t drive = 0;
    uint8_t head = 0;
    uint8_t cyl;
    uint8_t st0;

    /* Seek to track 0 and check with READ ID */
    send_seek(0);

    floppy_send(CMD_READ_ID);
    g_assert(!get_irq(FLOPPY_IRQ));
    floppy_send(head << 2 | drive);

    while (!get_irq(FLOPPY_IRQ)) {
        /* qemu involves a timer with READ ID... */
        clock_step(1000000000LL / 50);
    }

    st0 = floppy_recv();
    floppy_recv();
    floppy_recv();
    cyl = floppy_recv();
    head = floppy_recv();
    floppy_recv();
    floppy_recv();

    g_assert_cmpint(cyl, ==, 0);
    g_assert_cmpint(head, ==, 0);
    g_assert_cmpint(st0, ==, head << 2);

    /* Seek to track 8 on head 1 and check with READ ID */
    head = 1;
    cyl = 8;

    floppy_send(CMD_SEEK);
    floppy_send(head << 2 | drive);
    g_assert(!get_irq(FLOPPY_IRQ));
    floppy_send(cyl);
    g_assert(get_irq(FLOPPY_IRQ));
    ack_irq(NULL);

    floppy_send(CMD_READ_ID);
    g_assert(!get_irq(FLOPPY_IRQ));
    floppy_send(head << 2 | drive);

    while (!get_irq(FLOPPY_IRQ)) {
        /* qemu involves a timer with READ ID... */
        clock_step(1000000000LL / 50);
    }

    st0 = floppy_recv();
    floppy_recv();
    floppy_recv();
    cyl = floppy_recv();
    head = floppy_recv();
    floppy_recv();
    floppy_recv();

    g_assert_cmpint(cyl, ==, 8);
    g_assert_cmpint(head, ==, 1);
    g_assert_cmpint(st0, ==, head << 2);
}