Skip to content
Snippets Groups Projects
Commit 78a5323e authored by rswindell's avatar rswindell
Browse files

A better fix for the RyBBS and KnK input problem (now that I understand the

problem better):
* Re-assert the "RX data" interrupt after the rx data register is read and
  there is remaining data.
This also allows us to only signal the interrupt event for *enabled*
interrupts (which certainly seems logical).
parent 3e39348b
No related branches found
No related tags found
No related merge requests found
......@@ -164,13 +164,18 @@ CRITICAL_SECTION interrupt_mutex;
void set_interrupt_pending(BYTE intr, BOOL assert)
{
EnterCriticalSection(&interrupt_mutex);
lprintf(LOG_DEBUG,"%sasserting interrupt %02X", assert ? "" : "de-", intr);
lprintf(LOG_DEBUG,"%sasserting interrupt %02X (pending: %02X, IER: %02X)"
,assert ? "" : "de-", intr
,pending_interrupts
,uart_ier_reg);
if(assert) {
if(uart_ier_reg&intr) /* is interrupt enabled? */
pending_interrupts |= intr; /* flag as pending */
SetEvent(interrupt_event);
if(uart_ier_reg&intr) { /* is interrupt enabled? */
pending_interrupts |= intr; /* flag as pending */
SetEvent(interrupt_event);
}
} else /* de-assert */
pending_interrupts &= ~intr; /* remove as pending */
LeaveCriticalSection(&interrupt_mutex);
}
......@@ -266,6 +271,19 @@ void reset_yield()
/* UART Virtualization */
/***********************/
static char *chr(uchar ch)
{
static char str[25];
if(ch>=' ' && ch<='~')
sprintf(str,"'%c' (%02Xh)",ch,ch);
else if(ch<' ')
sprintf(str,"^%c (%02Xh)",'@'+ch,ch);
else
sprintf(str,"%u (%02Xh)",ch,ch);
return(str);
}
VOID uart_wrport(WORD port, BYTE data)
{
int reg = port - uart_io_base;
......@@ -279,7 +297,7 @@ VOID uart_wrport(WORD port, BYTE data)
uart_divisor_latch_lsb = data;
lprintf(LOG_DEBUG,"set divisor latch low byte: %02X", data);
} else {
lprintf(LOG_DEBUG,"WRITE DATA: %02X", data);
lprintf(LOG_DEBUG,"WRITE DATA: %s", chr(data));
if(!WriteFile(wrslot,&data,sizeof(BYTE),&retval,NULL)) {
lprintf(LOG_ERR,"!VDD_WRITE: WriteFile Error %d (size=%d)"
,GetLastError(),retval);
......@@ -331,7 +349,7 @@ VOID uart_rdport(WORD port, PBYTE data)
}
if((avail=RingBufFull(&rdbuf))!=0) {
vdd_read(data,sizeof(BYTE));
lprintf(LOG_DEBUG,"READ DATA: 0x%02X", *data);
lprintf(LOG_DEBUG,"READ DATA: %s", chr(*data));
avail--;
reset_yield();
} else
......@@ -343,7 +361,8 @@ VOID uart_rdport(WORD port, PBYTE data)
/* Clear data ready interrupt identification in IIR */
deassert_interrupt(UART_IER_RX_DATA);
}
} else /* re-assert RX data (increment the semaphore) */
assert_interrupt(UART_IER_RX_DATA);
break;
case UART_IER:
if(uart_lcr_reg&UART_LCR_DLAB) {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment