コード例 #1
0
ファイル: yam.c プロジェクト: 383530895/linux
static enum uart yam_check_uart(unsigned int iobase)
{
	unsigned char b1, b2, b3;
	enum uart u;
	enum uart uart_tab[] =
	{c_uart_16450, c_uart_unknown, c_uart_16550, c_uart_16550A};

	b1 = inb(MCR(iobase));
	outb(b1 | 0x10, MCR(iobase));	/* loopback mode */
	b2 = inb(MSR(iobase));
	outb(0x1a, MCR(iobase));
	b3 = inb(MSR(iobase)) & 0xf0;
	outb(b1, MCR(iobase));		/* restore old values */
	outb(b2, MSR(iobase));
	if (b3 != 0x90)
		return c_uart_unknown;
	inb(RBR(iobase));
	inb(RBR(iobase));
	outb(0x01, FCR(iobase));	/* enable FIFOs */
	u = uart_tab[(inb(IIR(iobase)) >> 6) & 3];
	if (u == c_uart_16450) {
		outb(0x5a, SCR(iobase));
		b1 = inb(SCR(iobase));
		outb(0xa5, SCR(iobase));
		b2 = inb(SCR(iobase));
		if ((b1 != 0x5a) || (b2 != 0xa5))
			u = c_uart_8250;
	}
	return u;
}
コード例 #2
0
ファイル: disk.c プロジェクト: 99years/plan9
void plotdisc(double xc, double yc, double r){
	Point p;
	int rad;
	p.x=SCX(xc);
	p.y=SCY(yc);
	if (r < 0) 
		rad=SCR(-r);
	else
		rad=SCR(r);
	fillellipse(screen, p, rad, rad, getcolor(e1->foregr), ZP);
}
コード例 #3
0
static int
com_detect(int unit, int addr)
{
    int     oldctl, oldmsb;
    char    *type = "8250";
    int     i;

    oldctl = inb(LINE_CTL(addr));	 /* Save old value of LINE_CTL */
    oldmsb = inb(BAUD_MSB(addr));	 /* Save old value of BAUD_MSB */
    outb(LINE_CTL(addr), 0);	 /* Select INTR_ENAB */
    outb(BAUD_MSB(addr), 0);
    if (inb(BAUD_MSB(addr)) != 0)
    {
        outb(LINE_CTL(addr), oldctl);
        outb(BAUD_MSB(addr), oldmsb);
        return 0;
    }
    outb(LINE_CTL(addr), iDLAB);	 /* Select BAUD_MSB */
    outb(BAUD_MSB(addr), 255);
    if (inb(BAUD_MSB(addr)) != 255)
    {
        outb(LINE_CTL(addr), oldctl);
        outb(BAUD_MSB(addr), oldmsb);
        return 0;
    }
    outb(LINE_CTL(addr), 0);	 /* Select INTR_ENAB */
    if (inb(BAUD_MSB(addr)) != 0)	 /* Check that it has kept it's value*/
    {
        outb(LINE_CTL(addr), oldctl);
        outb(BAUD_MSB(addr), oldmsb);
        return 0;
    }

    /* Com port found, now check what chip it has */

    for(i = 0; i < 256; i++)	 /* Is there Scratch register */
    {
        outb(SCR(addr), i);
        if (inb(SCR(addr)) != i)
            break;
    }
    if (i == 256)
    {				 /* Yes == 450 or 460 */
        outb(SCR(addr), 0);
        type = "82450 or 16450";
        outb(FIFO_CTL(addr), iFIFOENA | iFIFO14CH);	 /* Enable fifo */
        if ((inb(FIFO_CTL(addr)) & iFIFO14CH) != 0)
        {				 /* Was it successfull */
            /* if both bits are not set then broken xx550 */
            if ((inb(FIFO_CTL(addr)) & iFIFO14CH) == iFIFO14CH)
            {
                type = "82550 or 16550";
                //comfifo[unit] = 1;
            }
            else
            {
                type = "82550 or 16550 with non-working FIFO";
            }
            outb(INTR_ID(addr), 0x00); /* Disable fifos */
        }
    }
    SHOW_INFO( 0, "com%d: %s chip", unit, type);
    return 1;

}