Ejemplo n.º 1
0
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);
}
Ejemplo n.º 2
0
/* pcn: Present Cylinder Number */
static void ack_irq(uint8_t *pcn)
{
    uint8_t ret;

    g_assert(get_irq(FLOPPY_IRQ));
    floppy_send(CMD_SENSE_INT);
    floppy_recv();

    ret = floppy_recv();
    if (pcn != NULL) {
        *pcn = ret;
    }

    g_assert(!get_irq(FLOPPY_IRQ));
}
Ejemplo n.º 3
0
static int __init my_init(void)
{
	//Obtain major number
	if (alloc_chrdev_region(&dev_first, 0, numr, MYDEV_NAME)) {
		pr_info("Cannot obtain major number\n");
		return -EFAULT;
	}
	pr_info("Success registering %s with MAJOR %d\n", MYDEV_NAME, MAJOR(dev_first)); 

	//Initialize device structure
	ramdisk= kmalloc(SIZE_BYTE, GFP_KERNEL);
	if (!ramdisk) {
		pr_info("Cannot allocate memory");
		unregister_chrdev_region(dev_first, numr);
		return -ENOMEM;
	}

	//Regitering cdev and make a device node
	my_cdev= cdev_alloc();
	cdev_init(my_cdev, &my_fops);
	my_cdev->owner= THIS_MODULE;
	cdev_add(my_cdev, dev_first, numr);
	foo_class= class_create(THIS_MODULE, MYDEV_NAME);
	foo_device= device_create(foo_class, NULL, dev_first, NULL, "%s", MYDEV_NAME);
	pr_info("\nSucceeded in registering device %s\n", MYDEV_NAME);

	//Register IRQ line
	get_irq();

	return 0;
}
static void ftr_gpio_init(struct gpio_runtime *rt)
{
	get_gpio("headphone-mute", NULL,
		 &headphone_mute_gpio,
		 &headphone_mute_gpio_activestate);
	get_gpio("amp-mute", NULL,
		 &amp_mute_gpio,
		 &amp_mute_gpio_activestate);
	get_gpio("lineout-mute", NULL,
		 &lineout_mute_gpio,
		 &lineout_mute_gpio_activestate);
	get_gpio("hw-reset", "audio-hw-reset",
		 &hw_reset_gpio,
		 &hw_reset_gpio_activestate);

	headphone_detect_node = get_gpio("headphone-detect", NULL,
					 &headphone_detect_gpio,
					 &headphone_detect_gpio_activestate);
	/* go Apple, and thanks for giving these different names
	 * across the board... */
	lineout_detect_node = get_gpio("lineout-detect", "line-output-detect",
				       &lineout_detect_gpio,
				       &lineout_detect_gpio_activestate);
	linein_detect_node = get_gpio("linein-detect", "line-input-detect",
				      &linein_detect_gpio,
				      &linein_detect_gpio_activestate);

	gpio_enable_dual_edge(headphone_detect_gpio);
	gpio_enable_dual_edge(lineout_detect_gpio);
	gpio_enable_dual_edge(linein_detect_gpio);

	get_irq(headphone_detect_node, &headphone_detect_irq);
	get_irq(lineout_detect_node, &lineout_detect_irq);
	get_irq(linein_detect_node, &linein_detect_irq);

	ftr_gpio_all_amps_off(rt);
	rt->implementation_private = 0;
	INIT_WORK(&rt->headphone_notify.work, ftr_handle_notify,
		  &rt->headphone_notify);
	INIT_WORK(&rt->line_in_notify.work, ftr_handle_notify,
		  &rt->line_in_notify);
	INIT_WORK(&rt->line_out_notify.work, ftr_handle_notify,
		  &rt->line_out_notify);
	mutex_init(&rt->headphone_notify.mutex);
	mutex_init(&rt->line_in_notify.mutex);
	mutex_init(&rt->line_out_notify.mutex);
}
Ejemplo n.º 5
0
static void bt_cmd(uint8_t *cmd, unsigned int cmd_len,
                    uint8_t *rsp, unsigned int *rsp_len)
{
    unsigned int i, len, j = 0;
    uint8_t seq = 5;

    /* Should be idle */
    g_assert(bt_get_ctrlreg() == 0);

    bt_wait_b_busy();
    IPMI_BT_CTLREG_SET_CLR_WR_PTR();
    bt_write_buf(cmd_len + 1);
    bt_write_buf(cmd[0]);
    bt_write_buf(seq);
    for (i = 1; i < cmd_len; i++) {
        bt_write_buf(cmd[i]);
    }
    IPMI_BT_CTLREG_SET_H2B_ATN();

    emu_msg_handler(); /* We should get a message on the socket here. */

    bt_wait_b2h_atn();
    if (bt_ints_enabled) {
        g_assert((bt_get_irqreg() & 0x02) == 0x02);
        g_assert(get_irq(IPMI_IRQ));
        bt_write_irqreg(0x03);
    } else {
        g_assert(!get_irq(IPMI_IRQ));
    }
    IPMI_BT_CTLREG_SET_H_BUSY();
    IPMI_BT_CTLREG_SET_B2H_ATN();
    IPMI_BT_CTLREG_SET_CLR_RD_PTR();
    len = bt_get_buf();
    g_assert(len >= 4);
    rsp[0] = bt_get_buf();
    assert(bt_get_buf() == seq);
    len--;
    for (j = 1; j < len; j++) {
        rsp[j] = bt_get_buf();
    }
    IPMI_BT_CTLREG_SET_H_BUSY();
    *rsp_len = j;
}
Ejemplo n.º 6
0
static uint8_t send_read_command(uint8_t cmd)
{
    uint8_t drive = 0;
    uint8_t head = 0;
    uint8_t cyl = 0;
    uint8_t sect_addr = 1;
    uint8_t sect_size = 2;
    uint8_t eot = 1;
    uint8_t gap = 0x1b;
    uint8_t gpl = 0xff;

    uint8_t msr = 0;
    uint8_t st0;

    uint8_t ret = 0;

    floppy_send(cmd);
    floppy_send(head << 2 | drive);
    g_assert(!get_irq(FLOPPY_IRQ));
    floppy_send(cyl);
    floppy_send(head);
    floppy_send(sect_addr);
    floppy_send(sect_size);
    floppy_send(eot);
    floppy_send(gap);
    floppy_send(gpl);

    uint8_t i = 0;
    uint8_t n = 2;
    for (; i < n; i++) {
        msr = inb(FLOPPY_BASE + reg_msr);
        if (msr == 0xd0) {
            break;
        }
        sleep(1);
    }

    if (i >= n) {
        return 1;
    }

    st0 = floppy_recv();
    if (st0 != 0x40) {
        ret = 1;
    }

    floppy_recv();
    floppy_recv();
    floppy_recv();
    floppy_recv();
    floppy_recv();
    floppy_recv();

    return ret;
}
Ejemplo n.º 7
0
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);
}
Ejemplo n.º 8
0
void do_IRQ(struct pt_regs *regs)
{
	unsigned int irq;
	struct pt_regs *old_regs = set_irq_regs(regs);

	irq_enter();
	irq = get_irq(regs);
next_irq:
	BUG_ON(irq == -1U);
	generic_handle_irq(irq);

	irq = get_irq(regs);
	if (irq != -1U) {
		pr_debug("next irq: %d\n", irq);
		++concurrent_irq;
		goto next_irq;
	}

	irq_exit();
	set_irq_regs(old_regs);
}
Ejemplo n.º 9
0
sb_status sb16_getenvironment(void)
{
	if(detect_dsp(&sb16)!=SB_TRUE)
	{
		DPRINT1("Detect DSP failed!!!\n");
		return SB_FALSE;
	}
	DPRINT1("DSP base address 0x%x\n",sb16.base);
	get_irq(&sb16);
	DPRINT1("IRQ: %d\n",sb16.irq);
	get_dma(&sb16);
	DPRINT1("DMA8: 0x%x DMA16: 0x%x\n",sb16.dma8,sb16.dma16);
	return SB_TRUE;
}
Ejemplo n.º 10
0
static void test_sense_interrupt(void)
{
    int drive = 0;
    int head = 0;
    int cyl = 0;
    int ret = 0;

    floppy_send(CMD_SENSE_INT);
    ret = floppy_recv();
    g_assert(ret == 0x80);

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

    floppy_send(CMD_SENSE_INT);
    ret = floppy_recv();
    g_assert(ret == 0x20);
    floppy_recv();
}
Ejemplo n.º 11
0
void CLU57813P::request(BYTE value)
{

    switch (value) {

    case 0x01 :
        reg_out = 0x00;
        if (pPC->fp_log) fprintf(pPC->fp_log,"LU57813P - Unknown request 01.\n");
        break;

    case 0x03 :
        // 53 : during initalisation. Read a return value just after.
        // Unknown effect !!!!
        reg_out = 0x00;
        if (pPC->fp_log) fprintf(pPC->fp_log,"LU57813P - Unknown request 53.\n");
        break;


    case 0x05 :
        // 55 : Read the digital value of the CE-1600P battery voltage.
//        This routine is used for monitoring the Ni-Cd battery supply voltage cf the
//        CE-1600P. If the value is Iess than A8H, it is judged as the low battery.
        reg_out = 0xc0;
        if (pPC->fp_log) fprintf(pPC->fp_log,"LU57813P - Read the digital value of the voltage input at the analog input port..\n");
        break;

        case 0x06 :
        // 56 : Read the digital value of the voltage input at the analog input port.
        reg_out = digitalvalue;
        if (pPC->fp_log) fprintf(pPC->fp_log,"LU57813P - Read the digital value of the voltage input at the analog input port..\n");
        break;

        //57 : Read the digital value cf the supply voltage cf the PC-1600 main unit.
//        This routine is used for monitoring the supply voltage of the PC-1600 main unit. If
//        the value is less than AFH, it is judged as the Low battery. The low battery state is
//        released when the value becomes greater than BEH.
    case 0x07 : reg_out = 0xC0;
        if (pPC->fp_log) fprintf(pPC->fp_log,"LU57813P - Read the digital value cf the supply voltage cf the PC-1600 main unit.\n");
        break;

        // 5A : first call from the main CPU. Unknown action
    case 0x0a : reg_out = 0xa0;
        if (pPC->fp_log) fprintf(pPC->fp_log,"LU57813P - Unknown action, perhaps voltage monitor.\n");
        break;

    case 0x0c :
        // 5C : (Bit 5 AND the byte in A register indicates the state of the CI signal: If the CI
        //          signal is high, then bit 5 = 0. If it is Iow, then bit 5 = 1.)
        //      (Bit 2 AND the byte in A register indicates the state of the PASSWORD signal: If the PASSWORD IS SET
        //          signal is high, then bit 2 = 0. If it is Iow, then bit 2 = 1.)

        reg_out = 0x20 | (password[0]==0?0x00 : 0x04);
        if (pPC->fp_log) fprintf(pPC->fp_log,"LU57813P - indicates the state of the signal\n");
        if (pPC->pCPU->fp_log) fprintf(pPC->pCPU->fp_log,"\n Check LU57813P\n");
        break;

        // 5D : Read the current interrupt cause for SC-7852.
    case 0x0d: reg_out = get_irq();
//        if (pPC->fp_log) fprintf(pPC->fp_log,"LU57813P - Read the current interrupt cause for SC-7852.\n");
        break;

        // 5E : Read the current setting of the interrupt mask for SC-7852.
    case 0x0e : reg_out = irq_mask;
        if (pPC->fp_log) fprintf(pPC->fp_log,"LU57813P - Read the current setting of the interrupt mask for SC-7852.\n");
        break;

        // 5F : Set the interrupt mask for SC-7852. from sp[0] and sp[1]
    case 0x0f :
        irq_mask = (imem[0]<<4) + imem[1];

        // 0x20 : ALARM$
        // 0x40 : TIME_CHECK
        // 0x80 : WAKE$(0)

        if (pPC->fp_log) fprintf(pPC->fp_log,"LU57813P - Set the interrupt mask for SC-7852. from sp[0] and sp[1]\n");
        break;

    default: // UNKNOWN COMMAND
        if (pPC->fp_log) fprintf(pPC->fp_log,"LU57813P - Unknown request %02X.\n",value);
    }
    output_pending = true;
}
Ejemplo n.º 12
0
int io_gen_ioctl(struct inode *inode, struct file *filp, unsigned int cmd, unsigned long arg)
#endif
{
	io_gen_io_packet iopack;
	io_gen_resource resource_requested;
	io_gen_irq_struct irq_request;
	int status;

	switch (cmd)
	{
		case io_gen_request_io:
			if (access_ok(VERIFY_WRITE, arg, sizeof(io_gen_resource)))
			{
				status = copy_from_user(&resource_requested, (io_gen_resource *)arg, sizeof(io_gen_resource));

				if (status != 0) return status;

				return make_region_request(resource_requested, filp);
			}
			else
			{
#ifdef IO_GEN_DEBUG_ON
				printk(KERN_INFO "iogen: could not copy from user\n");
#endif
				return -EFAULT;
			}
				
		case io_gen_write_ioctl:
			if (access_ok(VERIFY_WRITE, arg, sizeof(io_gen_io_packet)))
			{
				//grab the data and write it to the offset....
				status = copy_from_user(&iopack, (io_gen_io_packet *)arg, sizeof(io_gen_io_packet));
				
				if (status != 0) return status;

#ifdef IO_GEN_DEBUG_ON
				printk(KERN_INFO "iogen: attempting to write to address %x\n", iopack.offset);
#endif

				//since the request region doesn't seem to be enforced we are going
				//to disallow writes and reads below 100 hex

				if (iopack.offset <= 0x100)
				{
					 return -EFAULT;
				}

				switch (iopack.size)
				{
					case 0:
						outb((unsigned char) iopack.data, iopack.offset);
						break;

					case 1:
						outw((unsigned short) iopack.data,iopack.offset);
						break;
					case 2:
						outl((unsigned long) iopack.data, iopack.offset);
						break;
				};
				return 0;
			}
			else //couldn't acces the data. oh nos!
			{
#ifdef IO_GEN_DEBUG_ON
				printk(KERN_INFO "iogen: could not get access io_gen_write_ioctl\n");
#endif
				return -EFAULT;
			}
		break;
		case io_gen_read_ioctl:
			if (access_ok(VERIFY_WRITE, arg, sizeof(io_gen_io_packet)))
			{
				status = copy_from_user(&iopack, (io_gen_io_packet *)arg, sizeof(io_gen_io_packet));

				if (status != 0) return status;
#ifdef IO_GEN_DEBUG_ON
				printk(KERN_INFO "iogen: attempting to read from address %x\n", iopack.offset);
#endif

				if (iopack.offset <= 0x100)
				{
					return -EFAULT;
				}

				switch(iopack.size)
				{
					case 0:
						iopack.data = inb(iopack.offset);
						break;

					case 1:
						iopack.data = inw(iopack.offset);
						break;

					case 2:
						iopack.data = inl(iopack.offset);
						break;
				};

				return copy_to_user((io_gen_io_packet *)arg, &iopack, sizeof(io_gen_io_packet));

			}
			else
			{
#ifdef IO_GEN_DEBUG_ON
				printk(KERN_INFO "iogen: could not get access: io_gen_read_ioctl\n");
#endif
				return -EFAULT;
			}
		case io_gen_wait_for_irq_ioctl:
			if (waiting_for_irq != 0)
			{
#ifdef IO_GEN_DEBUG_ON
				printk(KERN_INFO "iogen: io_gen_wait_for_irq_ioctl called while already waiting\n");
#endif
				return -EBUSY;
			}
			else
			{

				if ((irq_num == -1) || (offset_to_clear == -1) || (write_to_clear == -1))
				{
#ifdef IO_GEN_DEBUG_ON
					printk(KERN_INFO "iogen: attempt to wait for IRQ without allocation\n");
#endif
					//we aren't ready because the irq has not been properly requested/allocated yet
					return -EFAULT;
				}

				waiting_for_irq = 1;
#ifdef IO_GEN_DEBUG_ON
				printk(KERN_INFO "iogen: io_gen_wait_for_irq_ioctl: entering sleep\n");
#endif
				interruptible_sleep_on(&io_gen_wait);
#ifdef IO_GEN_DEBUG_ON
				printk(KERN_INFO "iogen: io_gen_wait_for_irq_ioctl: done sleeping\n");
#endif

				if (irq_cancelled == 1)
				{
					irq_cancelled = 0;
					return -ECANCELED;
				}
				else
				{
					return 0;
				}
			}
			break;
		case io_gen_irq_setup:
			if (irq_num != -1) //we already have an irq
			{
				return -EBUSY;
			}
			if (access_ok(VERIFY_WRITE, arg, sizeof(io_gen_irq_struct)))
			{
				status = copy_from_user(&irq_request, (io_gen_irq_struct *)arg, sizeof(io_gen_irq_struct));

				return get_irq(irq_request.write_to_clear, 
									irq_request.offset_to_clear, 
									irq_request.irq_num, 
									irq_request.val_to_clear);

			}
			else
			{
				return -EFAULT;
			}
			break;
		case io_gen_cancel_wait_for_irq_ioctl:
#ifdef IO_GEN_DEBUG_ON
			printk(KERN_INFO "iogen: cancelling irq wait\n");
#endif
				waiting_for_irq = 0; 
				irq_cancelled = 1;
				wake_up_interruptible(&io_gen_wait);
//				while (irq_cancelled == 1); //wait for the other ioctl to finish then return.
				return 0;
				break;
		default:
			return -EINVAL; //probably need a better return val
	};
}
static void IntIpcCcpuStartHandler(u32 irq)
{
    printk("IntIpcCcpuStartHandler irq = %d\n", get_irq());
    ccpu_start();
    pm_vote(PM_PWR_VOTE_CCORE, 1);
}
Ejemplo n.º 14
0
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);
}
Ejemplo n.º 15
0
static uint8_t send_read_no_dma_command(int nb_sect, uint8_t expected_st0)
{
    uint8_t drive = 0;
    uint8_t head = 0;
    uint8_t cyl = 0;
    uint8_t sect_addr = 1;
    uint8_t sect_size = 2;
    uint8_t eot = nb_sect;
    uint8_t gap = 0x1b;
    uint8_t gpl = 0xff;

    uint8_t msr = 0;
    uint8_t st0;

    uint8_t ret = 0;

    floppy_send(CMD_READ);
    floppy_send(head << 2 | drive);
    g_assert(!get_irq(FLOPPY_IRQ));
    floppy_send(cyl);
    floppy_send(head);
    floppy_send(sect_addr);
    floppy_send(sect_size);
    floppy_send(eot);
    floppy_send(gap);
    floppy_send(gpl);

    uint16_t i = 0;
    uint8_t n = 2;
    for (; i < n; i++) {
        msr = inb(FLOPPY_BASE + reg_msr);
        if (msr == (BUSY | NONDMA | DIO | RQM)) {
            break;
        }
        sleep(1);
    }

    if (i >= n) {
        return 1;
    }

    /* Non-DMA mode */
    for (i = 0; i < 512 * 2 * nb_sect; i++) {
        msr = inb(FLOPPY_BASE + reg_msr);
        assert_bit_set(msr, BUSY | RQM | DIO);
        inb(FLOPPY_BASE + reg_fifo);
    }

    st0 = floppy_recv();
    if (st0 != expected_st0) {
        ret = 1;
    }

    floppy_recv();
    floppy_recv();
    floppy_recv();
    floppy_recv();
    floppy_recv();
    floppy_recv();

    return ret;
}