Beispiel #1
0
void EnCharQ(char ch, char_q_t *p) // append ch to p->q[tail] if queue has space
{
    if(CharFullQ(p))
    {
        cons_printf("Char queue is full, can't enqueue!\n");
        return;
    }
    p->q[p->tail] = ch;
    p->tail++;
    if(p->tail == CHAR_Q_SIZE) p->tail = 0; // wrap
    p->count++;
}
void CharEnQ(char id, char_q_t *p) // append id to p->q[tail] if queue has space
{
   if(CharFullQ(p))
   {
      cons_printf("Queue is full, can't enqueue!\n");
      return;
   }
   p->q[p->tail] = id;
   p->tail++;
   if(p->tail == CHAR_Q_SIZE) p->tail = 0;   // wrap around
   p->count++;
}
Beispiel #3
0
void CharEnQ(char element, char_q_t *p)
{
	if (CharFullQ(p)) {
		cons_printf("Queue is full, can't enqueue!\n");
		return;
	}
	p->q[p->tail] = element;

	p->tail += 1;

	if (p->tail >= Q_SIZE) {
		p->tail = 0;
	}

	p->count += 1;
}
Beispiel #4
0
// read incoming char from UART and store into input queue, if there's no
// room, place a bell character to echo queue to send a alarm sound to the
// terminal instead
void IRQ34ISRInChar(int term_num)
{
    char ch,status;
    status = inportb(terminals[term_num].io_base + LSR);
// what's keyed-in, mask with 127, to get 7-bit ASCII char
    ch = inportb(terminals[term_num].io_base + DATA);// & 0x7F;
// Error inside UART. We've cleared the condition by reading it.
// However, the character is messed up, replace it.
    printf("\n0x%x-->%c",ch,ch);
    if(!QBIT_ANY_ON(status, LSR_FE | LSR_OE)) {  		//8-N-1
        //if(!QBIT_ANY_ON(status, LSR_FE | LSR_PE | LSR_OE)) {	//7-E-1
        if(CharFullQ(&terminals[term_num].in_q)) // in queue full (typed too fast?)
        {
        }
        else // add char to in queue, signal data now avail
        {
            EnCharQ(ch, &terminals[term_num].in_q); // put ch into in queue
            SemPostISR(terminals[term_num].in_sid); // post data-avail semaphore
        }
    }
}