- dbg_putchar() and dbg_getchar() don't call any common sub routines

git-svn-id: http://moon:8086/svn/mips@81 a8ebac50-d88d-4704-bea3-6648445a41b3
This commit is contained in:
2017-01-14 20:31:34 +00:00
parent b11c98a70f
commit 28c8957b96
3 changed files with 62 additions and 31 deletions
+29 -18
View File
@@ -26,6 +26,8 @@ con_if_t con_if =
con_if_entry, ARRAYSIZE(con_if_entry)
};
uart_if_t const *dbg_uart = NULL;
void dbg_uart_setup();
void board_init(void)
@@ -54,44 +56,53 @@ extern void dbg_handler(struct xcptcontext * xcp);
void dbg_uart_isr(struct xcptcontext *xcp);
void dbg_uart_setup()
{
uart_if_t *pUart = (uart_if_t*)con_getInstanceByName("UART-1");
const int UART_INT = SYS_INT_UART1;
dbg_uart = (uart_if_t*)con_getInterfaceByName("UART-1")->pInst;
*pUart->pCTRL = SYS_UART_BIT_RX_INTEN;
interrupt_register(SYS_INT_UART1, dbg_uart_isr);
interrupt_enable(SYS_INT_UART1);
*dbg_uart->pCTRL = SYS_UART_BIT_RX_INTEN;
interrupt_register(UART_INT, dbg_uart_isr);
interrupt_enable(UART_INT);
}
void dbg_uart_isr(struct xcptcontext *xcp)
{
uart_if_t *pUart = (uart_if_t*)con_getInstanceByName("UART-1");
if(SYS_UART_BIT_RX_AVAIL & *pUart->pCTRL)
if(SYS_UART_BIT_RX_AVAIL & *dbg_uart->pCTRL)
{
char c = *pUart->pDATA;
char c = *dbg_uart->pDATA;
if (c == 3)
{
// Disable UART interrupt
// to prevent consuming uart data in ISR during single step
// Interrupts mask bits are recovered on return from exception
//interrupt_disable(SYS_INT_UART1);
//uint32_t im = 1 << SYS_INT_UART1;
//xcp->sr &= ~(SR_MASK_IM & (im << 8));
//*pUart->pCTRL &= ~SYS_UART_BIT_RX_INTEN;
dbg_handler(xcp);
}
}
}
inline void _dbg_writechar(uart_if_t const *pUart, char c)
{
while((SYS_UART_BIT_TX_HALFFULL & *pUart->pCTRL) != 0);
*pUart->pDATA = (uint32_t)c;
}
inline char _dbg_readchar(uart_if_t const *pUart)
{
// busy read
while(!(SYS_UART_BIT_RX_AVAIL & *pUart->pCTRL));
return (*pUart->pDATA & 0xFF);
}
void dbg_putchar(char c)
{
if (c == 0x0A)
{
writechar(4, 0x0D);
_dbg_writechar(dbg_uart, 0x0D);
}
writechar(4, c);
_dbg_writechar(dbg_uart, c);
}
char dbg_getchar()
{
return (char)readchar(4);
return (char)_dbg_readchar(dbg_uart);
}
+30 -13
View File
@@ -26,6 +26,21 @@ con_if_entry_t const* con_getInterface(int file)
return result;
}
con_if_entry_t const* con_getInterfaceByName(char const *pName)
{
void const *result = NULL;
int i;
for (i=0; i < con_if.length; i++)
{
if (!strcmp(pName, con_if.con_if_entry[i].pName))
{
result = &con_if.con_if_entry[i];
break;
}
}
return result;
}
void const* con_getInstanceByName(char const *pName)
{
void const *result = NULL;
@@ -77,12 +92,9 @@ void con_flush(int fd)
} while(c > 0);
}
// ---------------------------------------------------------------------------------
int readchar(int fd)
int con_readchar(con_if_entry_t const *pIF)
{
int c;
con_if_entry_t const *pIF = con_getInterface(fd);
assert(pIF);
// busy read
@@ -95,26 +107,31 @@ int readchar(int fd)
return c;
}
void writechar(int fd, char c)
void con_writechar(con_if_entry_t const *pIF, char c)
{
con_if_entry_t const *pIF = con_getInterface(fd);
assert(pIF);
pIF->writechar(pIF->pInst, c);
}
// ---------------------------------------------------------------------------------
int readchar(int fd)
{
return con_readchar(con_getInterface(fd));
}
void writechar(int fd, char c)
{
con_writechar(con_getInterface(fd), c);
}
void _putchar(int fd, char c)
{
con_if_entry_t const *pIF = con_getInterface(fd);
assert(pIF);
if (c == 0x0A)
{
pIF->writechar(pIF->pInst, 0x0D);
writechar(fd, 0x0D);
}
pIF->writechar(pIF->pInst, c);
writechar(fd, c);
}
+3
View File
@@ -50,7 +50,10 @@ int con_open(char const *pName);
int con_close(int fd);
void con_flush(int file);
con_if_entry_t const* con_getInterface(int file);
con_if_entry_t const* con_getInterfaceByName(char const *pName);
void const* con_getInstanceByName(char const *pName);
int con_readchar(con_if_entry_t const *pIF);
void con_writechar(con_if_entry_t const *pIF, char c);
int readchar(int file);
void writechar(int file, char c);