static int udbg_getc_pollLP(void)
{
	/* The interface is tricky because it may return up to 16 chars.
	 * We save them statically for future calls to udbg_getc().
	 */
	char ch, *buf = (char *)inbuf;
	int i;
	long rc;
	if (inbuflen == 0) {
		/* get some more chars. */
		inbuflen = 0;
		rc = plpar_get_term_char(vtermno, &inbuflen, buf);
		if (rc != H_Success)
			inbuflen = 0;	/* otherwise inbuflen is garbage */
	}
	if (inbuflen <= 0 || inbuflen > 16) {
		/* Catch error case as well as other oddities (corruption) */
		inbuflen = 0;
		return -1;
	}
	ch = buf[0];
	for (i = 1; i < inbuflen; i++)	/* shuffle them down. */
		buf[i-1] = buf[i];
	inbuflen--;
	return ch;
}
示例#2
0
文件: hvconsole.c 项目: 274914765/C
/**
 * hvc_get_chars - retrieve characters from firmware for denoted vterm adatper
 * @vtermno: The vtermno or unit_address of the adapter from which to fetch the
 *    data.
 * @buf: The character buffer into which to put the character data fetched from
 *    firmware.
 * @count: not used?
 */
int hvc_get_chars(uint32_t vtermno, char *buf, int count)
{
    unsigned long got;

    if (plpar_get_term_char(vtermno, &got, buf) == H_SUCCESS)
        return got;

    return 0;
}