Uthernet 2: add some logging to debug TCP mode (used by ii-vision).
This commit is contained in:
parent
80222caa0d
commit
7f3ecac9b1
2 changed files with 45 additions and 4 deletions
|
@ -45,6 +45,8 @@
|
|||
#define SN_MR_PPPOE 0x05
|
||||
|
||||
#define SN_CR_OPEN 0x01
|
||||
#define SN_CR_LISTENT 0x02
|
||||
#define SN_CR_CONNECT 0x04
|
||||
#define SN_CR_CLOSE 0x10
|
||||
#define SN_CR_SEND 0x20
|
||||
#define SN_CR_RECV 0x40
|
||||
|
@ -52,8 +54,12 @@
|
|||
#define SN_MR 0x00
|
||||
#define SN_CR 0x01
|
||||
#define SN_SR 0x03
|
||||
#define SN_PORT0 0x04
|
||||
#define SN_PORT1 0x05
|
||||
#define SN_DIPR0 0x0C
|
||||
#define SN_DIPR3 0x0F
|
||||
#define SN_DPORT0 0x10
|
||||
#define SN_DPORT1 0x11
|
||||
#define SN_PROTO 0x14
|
||||
#define SN_TOS 0x15
|
||||
#define SN_TTL 0x16
|
||||
|
@ -68,5 +74,9 @@
|
|||
#define SN_RX_RD0 0x28
|
||||
#define SN_RX_RD1 0x29
|
||||
|
||||
#define SN_SR_CLOSED 0x00
|
||||
#define SN_SR_SOCK_INIT 0x13
|
||||
#define SN_SR_ESTABLISHED 0x17
|
||||
#define SN_SR_SOCK_UDP 0x22
|
||||
#define SN_SR_SOCK_IPRAW 0x32
|
||||
#define SN_SR_SOCK_MACRAW 0x42
|
||||
|
|
|
@ -106,6 +106,12 @@ namespace
|
|||
case SN_MR_CLOSED:
|
||||
LogFileOutput("U2: Mode[%d]: CLOSED\n", i);
|
||||
break;
|
||||
case SN_MR_TCP:
|
||||
LogFileOutput("U2: Mode[%d]: TCP\n", i);
|
||||
break;
|
||||
case SN_MR_UDP:
|
||||
LogFileOutput("U2: Mode[%d]: UDP\n", i);
|
||||
break;
|
||||
case SN_MR_IPRAW:
|
||||
LogFileOutput("U2: Mode[%d]: IPRAW\n", i);
|
||||
break;
|
||||
|
@ -114,7 +120,7 @@ namespace
|
|||
break;
|
||||
#ifdef U2_LOG_UNKNOWN
|
||||
default:
|
||||
LogFileOutput("U2: Unknown protocol: %02x\n", value);
|
||||
LogFileOutput("U2: Unknown protocol: %02x\n", protocol);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
@ -377,6 +383,12 @@ namespace
|
|||
case SN_MR_MACRAW:
|
||||
sr = SN_SR_SOCK_MACRAW;
|
||||
break;
|
||||
case SN_MR_TCP:
|
||||
sr = SN_SR_SOCK_INIT;
|
||||
break;
|
||||
case SN_MR_UDP:
|
||||
sr = SN_SR_SOCK_UDP;
|
||||
break;
|
||||
#ifdef U2_LOG_UNKNOWN
|
||||
default:
|
||||
LogFileOutput("U2: OPEN[%d]: unknown mode: %02x\n", i, mr);
|
||||
|
@ -389,10 +401,19 @@ namespace
|
|||
void closeSocket(const size_t i)
|
||||
{
|
||||
const Socket & socket = sockets[i];
|
||||
memory[socket.registers + SN_SR] = SN_MR_CLOSED;
|
||||
memory[socket.registers + SN_SR] = SN_SR_CLOSED;
|
||||
LogFileOutput("U2: CLOSE[%d]\n", i);
|
||||
}
|
||||
|
||||
void connectSocket(const size_t i)
|
||||
{
|
||||
const Socket & socket = sockets[i];
|
||||
memory[socket.registers + SN_SR] = SN_SR_ESTABLISHED;
|
||||
const uint8_t * dest = memory.data() + socket.registers + SN_DIPR0;
|
||||
const uint16_t port = readNetworkWord(memory.data() + socket.registers + SN_DPORT0);
|
||||
LogFileOutput("U2: TCP[%d]: CONNECT to %d.%d.%d.%d:%d\n", i, dest[0], dest[1], dest[2], dest[3], port);
|
||||
}
|
||||
|
||||
void setCommandRegister(const size_t i, const uint8_t value)
|
||||
{
|
||||
switch (value)
|
||||
|
@ -400,6 +421,9 @@ namespace
|
|||
case SN_CR_OPEN:
|
||||
openSocket(i);
|
||||
break;
|
||||
case SN_CR_CONNECT:
|
||||
connectSocket(i);
|
||||
break;
|
||||
case SN_CR_CLOSE:
|
||||
closeSocket(i);
|
||||
break;
|
||||
|
@ -425,6 +449,7 @@ namespace
|
|||
{
|
||||
case SN_MR:
|
||||
case SN_CR:
|
||||
case SN_SR:
|
||||
value = memory[address];
|
||||
break;
|
||||
case SN_TX_FSR0:
|
||||
|
@ -538,6 +563,12 @@ namespace
|
|||
case SN_CR:
|
||||
setCommandRegister(i, value);
|
||||
break;
|
||||
case SN_PORT0:
|
||||
case SN_PORT1:
|
||||
case SN_DPORT0:
|
||||
case SN_DPORT1:
|
||||
memory[address] = value;
|
||||
break;
|
||||
case SN_DIPR0 ... SN_DIPR3:
|
||||
memory[address] = value;
|
||||
break;
|
||||
|
@ -711,7 +742,7 @@ namespace
|
|||
#ifdef U2_LOG_VERBOSE
|
||||
const char * mode = write ? "WRITE " : "READ ";
|
||||
const char c = std::isprint(res) ? res : '.';
|
||||
LogFileOutput("U2: %04x: %s %04x %02x = %02x, %c\n", programcounter, mode, address, value, res, c);
|
||||
LogFileOutput("U2: %04x: %s %04x %02x = %02x, %c [%d = %d]\n", programcounter, mode, address, value, res, c, value, res);
|
||||
#endif
|
||||
|
||||
return res;
|
||||
|
@ -732,7 +763,7 @@ void registerUthernet2()
|
|||
void processEventsUthernet2(uint32_t timeout)
|
||||
{
|
||||
#ifdef U2_USE_SLIRP
|
||||
if (slirp)
|
||||
if (slirp)
|
||||
{
|
||||
slirp->process(timeout);
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue