URL
https://opencores.org/ocsvn/or1k/or1k/trunk
Subversion Repositories or1k
Compare Revisions
- This comparison shows the changes necessary to convert path
/
- from Rev 1499 to Rev 1500
- ↔ Reverse comparison
Rev 1499 → Rev 1500
/trunk/or1ksim/peripheral/16450.c
386,6 → 386,70
return value; |
} |
|
/*--------------------------------------------------------[ VAPI handling ]---*/ |
/* Decodes the read vapi command */ |
static void uart_vapi_cmd(struct dev_16450 *uart) |
{ |
int received = 0; |
|
while (!received) { |
if (uart->vapi_buf_head_ptr != uart->vapi_buf_tail_ptr) { |
unsigned long data = uart->vapi_buf[uart->vapi_buf_tail_ptr]; |
TRACE("\tHandling: %08lx (%i,%i)\n", data, uart->vapi_buf_head_ptr, |
uart->vapi_buf_tail_ptr); |
uart->vapi_buf_tail_ptr = (uart->vapi_buf_tail_ptr + 1) % UART_VAPI_BUF_LEN; |
switch (data >> 24) { |
case 0x00: |
uart->vapi.lcr = (data >> 8) & 0xff; |
/* Put data into rx fifo */ |
uart->iregs.rxser = data & 0xff; |
uart->vapi.char_clks = char_clks (uart->vapi.dll, uart->vapi.dlh, uart->vapi.lcr); |
if((uart->vapi.lcr & ~UART_LCR_SBC) != (uart->regs.lcr & ~UART_LCR_SBC) |
|| uart->vapi.char_clks != uart->char_clks |
|| uart->vapi.skew < -MAX_SKEW || uart->vapi.skew > MAX_SKEW) { |
if((uart->vapi.lcr & ~UART_LCR_SBC) != (uart->regs.lcr & ~UART_LCR_SBC)) |
WARN("unmatched VAPI (%02"PRIx8") and uart (%02"PRIx8") modes.\n", |
uart->vapi.lcr & ~UART_LCR_SBC, uart->regs.lcr & ~UART_LCR_SBC); |
if(uart->vapi.char_clks != uart->char_clks) { |
WARN("unmatched VAPI (%li) and uart (%li) char clocks.\n", |
uart->vapi.char_clks, uart->char_clks); |
WARN("VAPI: lcr: %02"PRIx8", dll: %02"PRIx8", dlh: %02"PRIx8"\n", |
uart->vapi.lcr, uart->vapi.dll, uart->vapi.dlh); |
WARN("UART: lcr: %02"PRIx8", dll: %02"PRIx8", dlh: %02"PRIx8"\n", |
uart->regs.lcr, uart->regs.dll, uart->vapi.dlh); |
} |
if(uart->vapi.skew < -MAX_SKEW || uart->vapi.skew > MAX_SKEW) |
WARN("VAPI skew is beyond max: %i\n", uart->vapi.skew); |
/* Set error bits */ |
uart->iregs.rxser |= (UART_LSR_FRAME | UART_LSR_RXERR) << 8; |
if(uart->regs.lcr & UART_LCR_PARITY) |
uart->iregs.rxser |= UART_LSR_PARITY << 8; |
} |
uart->istat.rxser_full = 1; |
received = 1; |
break; |
case 0x01: |
uart->vapi.dll = (data >> 0) & 0xff; |
uart->vapi.dlh = (data >> 8) & 0xff; |
break; |
case 0x02: |
uart->vapi.lcr = (data >> 8) & 0xff; |
break; |
case 0x03: |
uart->vapi.skew = (signed short)(data & 0xffff); |
break; |
case 0x04: |
uart->vapi.next_break_cnt = data & 0xffff; |
uart->vapi.next_break = (data >> 16) & 1; |
break; |
default: |
WARN("WARNING: Invalid vapi command %02lx\n", data >> 24); |
break; |
} |
} else break; |
} |
} |
|
/* Function that handles incoming VAPI data. */ |
void uart_vapi_read (unsigned long id, unsigned long data, void *dat) |
{ |
498,53 → 562,9
} |
} |
} else { /* VAPI */ |
int received = 0; |
/* do not handle commands while receiving */ |
if (uart->istat.rxser_full) return; |
while (!received) { |
if (uart->vapi_buf_head_ptr != uart->vapi_buf_tail_ptr) { |
unsigned long data = uart->vapi_buf[uart->vapi_buf_tail_ptr]; |
TRACE("\tHandling: %08lx (%i,%i)\n", data, uart->vapi_buf_head_ptr, |
uart->vapi_buf_tail_ptr); |
uart->vapi_buf_tail_ptr = (uart->vapi_buf_tail_ptr + 1) % UART_VAPI_BUF_LEN; |
switch (data >> 24) { |
case 0x00: |
uart->vapi.lcr = (data >> 8) & 0xff; |
/* Put data into rx fifo */ |
uart->iregs.rxser = data & 0xff; |
uart->vapi.char_clks = char_clks (uart->vapi.dll, uart->vapi.dlh, uart->vapi.lcr); |
if ((uart->vapi.lcr & ~UART_LCR_SBC) != (uart->regs.lcr & ~UART_LCR_SBC) |
|| uart->vapi.char_clks != uart->char_clks |
|| uart->vapi.skew < -MAX_SKEW || uart->vapi.skew > MAX_SKEW) { |
WARN("WARNING: unmatched VAPI (%02x) and uart (%02x) modes.\n", |
uart->vapi.lcr & ~UART_LCR_SBC, uart->regs.lcr & ~UART_LCR_SBC); |
/* Set error bits */ |
uart->iregs.rxser |= (UART_LSR_FRAME | UART_LSR_RXERR) << 8; |
if (uart->regs.lcr & UART_LCR_PARITY) uart->iregs.rxser |= UART_LSR_PARITY << 8; |
} |
uart->istat.rxser_full = 1; |
received = 1; |
break; |
case 0x01: |
uart->vapi.dll = (data >> 0) & 0xff; |
uart->vapi.dlh = (data >> 8) & 0xff; |
break; |
case 0x02: |
uart->vapi.lcr = (data >> 8) & 0xff; |
break; |
case 0x03: |
uart->vapi.skew = (signed short)(data & 0xffff); |
break; |
case 0x04: |
uart->vapi.next_break_cnt = data & 0xffff; |
uart->vapi.next_break = (data >> 16) & 1; |
break; |
default: |
WARN ("WARNING: Invalid vapi command %02lx\n", data >> 24); |
break; |
} |
} else break; |
} |
uart_vapi_cmd(uart); |
} |
} |
|