/**
 * pdc_iodc_getc - Read a character (non-blocking) from the PDC console.
 *
 * Read a character (non-blocking) from the PDC console, returns -1 if
 * key is not present.
 */
int pdc_iodc_getc(void)
{
    int ch;
    int status;
    unsigned long flags;

    /* Bail if no console input device. */
    if (!PAGE0->mem_kbd.iodc_io)
        return 0;

    /* wait for a keyboard (rs232)-input */
    spin_lock_irqsave(&pdc_lock, flags);
    real32_call(PAGE0->mem_kbd.iodc_io,
                (unsigned long)PAGE0->mem_kbd.hpa, ENTRY_IO_CIN,
                PAGE0->mem_kbd.spa, __pa(PAGE0->mem_kbd.dp.layers),
                __pa(iodc_retbuf), 0, __pa(iodc_dbuf), 1, 0);

    ch = *iodc_dbuf;
    status = *iodc_retbuf;
    spin_unlock_irqrestore(&pdc_lock, flags);

    if (status == 0)
        return -1;

    return ch;
}
/**
 * pdc_iodc_print - Console print using IODC.
 * @str: the string to output.
 * @count: length of str
 *
 * Note that only these special chars are architected for console IODC io:
 * BEL, BS, CR, and LF. Others are passed through.
 * Since the HP console requires CR+LF to perform a 'newline', we translate
 * "\n" to "\r\n".
 */
int pdc_iodc_print(const unsigned char *str, unsigned count)
{
	unsigned int i;
	unsigned long flags;

	for (i = 0; i < count;) {
		switch(str[i]) {
		case '\n':
			iodc_dbuf[i+0] = '\r';
			iodc_dbuf[i+1] = '\n';
			i += 2;
			goto print;
		default:
			iodc_dbuf[i] = str[i];
			i++;
			break;
		}
	}

print:
        spin_lock_irqsave(&pdc_lock, flags);
        real32_call(PAGE0->mem_cons.iodc_io,
                    (unsigned long)PAGE0->mem_cons.hpa, ENTRY_IO_COUT,
                    PAGE0->mem_cons.spa, __pa(PAGE0->mem_cons.dp.layers),
                    __pa(iodc_retbuf), 0, __pa(iodc_dbuf), i, 0);
        spin_unlock_irqrestore(&pdc_lock, flags);

	return i;
}
Example #3
0
void pdc_putc(unsigned char c)
{
	unsigned int n;
	unsigned long flags;

	switch (c) {
	case '\n':
		iodc_dbuf[0] = '\r'; 
		iodc_dbuf[1] = '\n';
               	n = 2;
               	posx = 0;
		break;
	case '\t':
		pdc_putc(' ');
		while (posx & 7) 	/* expand TAB */
			pdc_putc(' ');
		return;		/* return since IODC can't handle this */
	case '\b':
		posx-=2;		/* BS */
	default:
		iodc_dbuf[0] = c;
		n = 1;
		posx++;
		break;
	}
	{
		real32_call(PAGE0->mem_cons.iodc_io,
			(unsigned long)PAGE0->mem_cons.hpa, ENTRY_IO_COUT,
			PAGE0->mem_cons.spa, __pa(PAGE0->mem_cons.dp.layers),
			__pa(iodc_retbuf), 0, __pa(iodc_dbuf), n, 0);
	}
}
Example #4
0
int pdc_sti_call(unsigned long func, unsigned long flags,
                 unsigned long inptr, unsigned long outputr,
                 unsigned long glob_cfg)
{
        int retval;

        spin_lock_irq(&pdc_lock);  
        retval = real32_call(func, flags, inptr, outputr, glob_cfg);
        spin_unlock_irq(&pdc_lock);

        return retval;
}
int pdc_sti_call(unsigned long func, unsigned long flags,
                 unsigned long inptr, unsigned long outputr,
                 unsigned long glob_cfg)
{
    int retval;
    unsigned long irqflags;

    spin_lock_irqsave(&pdc_lock, irqflags);
    retval = real32_call(func, flags, inptr, outputr, glob_cfg);
    spin_unlock_irqrestore(&pdc_lock, irqflags);

    return retval;
}
/**
 * pdc_iodc_print - Console print using IODC.
 * @str: the string to output.
 * @count: length of str
 *
 * Note that only these special chars are architected for console IODC io:
 * BEL, BS, CR, and LF. Others are passed through.
 * Since the HP console requires CR+LF to perform a 'newline', we translate
 * "\n" to "\r\n".
 */
int pdc_iodc_print(const unsigned char *str, unsigned count)
{
    static int posx;        /* for simple TAB-Simulation... */
    unsigned int i;
    unsigned long flags;

    for (i = 0; i < count && i < 79;) {
        switch(str[i]) {
        case '\n':
            iodc_dbuf[i+0] = '\r';
            iodc_dbuf[i+1] = '\n';
            i += 2;
            posx = 0;
            goto print;
        case '\t':
            while (posx & 7) {
                iodc_dbuf[i] = ' ';
                i++, posx++;
            }
            break;
        case '\b':	/* BS */
            posx -= 2;
        default:
            iodc_dbuf[i] = str[i];
            i++, posx++;
            break;
        }
    }

    /* if we're at the end of line, and not already inserting a newline,
     * insert one anyway. iodc console doesn't claim to support >79 char
     * lines. don't account for this in the return value.
     */
    if (i == 79 && iodc_dbuf[i-1] != '\n') {
        iodc_dbuf[i+0] = '\r';
        iodc_dbuf[i+1] = '\n';
    }

print:
    spin_lock_irqsave(&pdc_lock, flags);
    real32_call(PAGE0->mem_cons.iodc_io,
                (unsigned long)PAGE0->mem_cons.hpa, ENTRY_IO_COUT,
                PAGE0->mem_cons.spa, __pa(PAGE0->mem_cons.dp.layers),
                __pa(iodc_retbuf), 0, __pa(iodc_dbuf), i, 0);
    spin_unlock_irqrestore(&pdc_lock, flags);

    return i;
}
Example #7
0
/**
 * pdc_iodc_outc - Console character print using IODC (without conversions).
 * @c: the character to output.
 *
 * Write the character directly to the IODC console.
 */
void pdc_iodc_outc(unsigned char c)
{
	unsigned int n, flags;

	/* fill buffer with one caracter and print it */
        static int __attribute__((aligned(8)))   iodc_retbuf[32];
        static char __attribute__((aligned(64))) iodc_dbuf[4096];

	n = 1;
	iodc_dbuf[0] = c;

	spin_lock_irqsave(&pdc_lock, flags);
	real32_call(PAGE0->mem_cons.iodc_io,
		    (unsigned long)PAGE0->mem_cons.hpa, ENTRY_IO_COUT,
		    PAGE0->mem_cons.spa, __pa(PAGE0->mem_cons.dp.layers),
		    __pa(iodc_retbuf), 0, __pa(iodc_dbuf), n, 0);
	spin_unlock_irqrestore(&pdc_lock, flags);
}
Example #8
0
/**
 * pdc_iodc_putc - Console character print using IODC.
 * @c: the character to output.
 *
 * Note that only these special chars are architected for console IODC io:
 * BEL, BS, CR, and LF. Others are passed through.
 * Since the HP console requires CR+LF to perform a 'newline', we translate
 * "\n" to "\r\n".
 */
void pdc_iodc_putc(unsigned char c)
{
        /* XXX Should we spinlock posx usage */
        static int posx;        /* for simple TAB-Simulation... */
        static int __attribute__((aligned(8)))   iodc_retbuf[32];
        static char __attribute__((aligned(64))) iodc_dbuf[4096];
        unsigned int n;
	unsigned int flags;

        switch (c) {
        case '\n':
                iodc_dbuf[0] = '\r';
                iodc_dbuf[1] = '\n';
                n = 2;
                posx = 0;
                break;
        case '\t':
                pdc_iodc_putc(' ');
                while (posx & 7)        /* expand TAB */
                        pdc_iodc_putc(' ');
                return;         /* return since IODC can't handle this */
        case '\b':
                posx-=2;                /* BS */
        default:
                iodc_dbuf[0] = c;
                n = 1;
                posx++;
                break;
        }

        spin_lock_irqsave(&pdc_lock, flags);
        real32_call(PAGE0->mem_cons.iodc_io,
                    (unsigned long)PAGE0->mem_cons.hpa, ENTRY_IO_COUT,
                    PAGE0->mem_cons.spa, __pa(PAGE0->mem_cons.dp.layers),
                    __pa(iodc_retbuf), 0, __pa(iodc_dbuf), n, 0);
        spin_unlock_irqrestore(&pdc_lock, flags);
}
Example #9
0
int pdc_console_wait_key(struct console *co)
{
	int ch = 'X';
	int status;

	/* Bail if no console input device. */
	if (!PAGE0->mem_kbd.iodc_io)
		return 0;
	
	/* wait for a keyboard (rs232)-input */
	do {
		unsigned long flags;

		save_flags(flags);
		cli();
		status = real32_call(PAGE0->mem_kbd.iodc_io,
			(unsigned long)PAGE0->mem_kbd.hpa, ENTRY_IO_CIN,
			PAGE0->mem_kbd.spa, __pa(PAGE0->mem_kbd.dp.layers),
			__pa(iodc_retbuf), 0, __pa(iodc_dbuf), 1, 0);
		restore_flags(flags);
		ch = *iodc_dbuf;	/* save the character directly to ch */
	} while (*iodc_retbuf == 0);	/* wait for a key */
	return ch;
}