Commit
- Loading branch information
There are no files selected for viewing
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
|
@@ -108,6 +108,7 @@ int amd_am79c973::Reset() | ||
|
|
||
|
|
||
void printf(char*); | void printf(char*); | ||
void printfHex(uint8_t); | |||
|
|
||
uint32_t amd_am79c973::HandleInterrupt(common::uint32_t esp) | uint32_t amd_am79c973::HandleInterrupt(common::uint32_t esp) | ||
{ | { | ||
|
@@ -120,15 +121,66 @@ uint32_t amd_am79c973::HandleInterrupt(common::uint32_t esp) | ||
if((temp & 0x2000) == 0x2000) printf("AMD am79c973 COLLISION ERROR\n"); | if((temp & 0x2000) == 0x2000) printf("AMD am79c973 COLLISION ERROR\n"); | ||
if((temp & 0x1000) == 0x1000) printf("AMD am79c973 MISSED FRAME\n"); | if((temp & 0x1000) == 0x1000) printf("AMD am79c973 MISSED FRAME\n"); | ||
if((temp & 0x0800) == 0x0800) printf("AMD am79c973 MEMORY ERROR\n"); | if((temp & 0x0800) == 0x0800) printf("AMD am79c973 MEMORY ERROR\n"); | ||
if((temp & 0x0400) == 0x0400) printf("AMD am79c973 DATA RECEVED\n"); | if((temp & 0x0400) == 0x0400) Receive(); | ||
if((temp & 0x0200) == 0x0200) printf("AMD am79c973 DATA SENT\n"); | if((temp & 0x0200) == 0x0200) printf("AMD am79c973 DATA SENT\n"); | ||
|
|
||
// acknoledge | // acknoledge | ||
registerAddressPort.Write(0); | registerAddressPort.Write(0); | ||
registerDataPort.Write(temp); | registerDataPort.Write(temp); | ||
|
|
||
if((temp & 0x0200) == 0x0200) printf("AMD am79c973 INIT DONE\n"); | if((temp & 0x0100) == 0x0100) printf("AMD am79c973 INIT DONE\n"); | ||
|
|
||
return esp; | return esp; | ||
} | } | ||
|
|
||
|
|||
This comment has been minimized.
Sorry, something went wrong. |
|||
void amd_am79c973::Send(uint8_t* buffer, int size) | |||
{ | |||
int sendDescriptor = currentSendBuffer; | |||
currentSendBuffer = (currentSendBuffer + 1) % 8; | |||
|
|||
if(size > 1518) | |||
size = 1518; | |||
|
|||
for(uint8_t *src = buffer + size -1, | |||
*dst = (uint8_t*)(sendBufferDescr[sendDescriptor].address + size -1); | |||
src >= buffer; src--, dst--) | |||
*dst = *src; | |||
|
|||
sendBufferDescr[sendDescriptor].avail = 0; | |||
sendBufferDescr[sendDescriptor].flags2 = 0; | |||
sendBufferDescr[sendDescriptor].flags = 0x8300F000 | |||
| ((uint16_t)((-size) & 0xFFF)); | |||
This comment has been minimized.
Sorry, something went wrong.
amr98khaled
|
|||
registerAddressPort.Write(0); | |||
registerDataPort.Write(0x48); | |||
} | |||
|
|||
void amd_am79c973::Receive() | |||
{ | |||
printf("AMD am79c973 DATA RECEIVED\n"); | |||
|
|||
This comment has been minimized.
Sorry, something went wrong. |
|||
for(; (recvBufferDescr[currentRecvBuffer].flags & 0x80000000) == 0; | |||
currentRecvBuffer = (currentRecvBuffer + 1) % 8) | |||
{ | |||
if(!(recvBufferDescr[currentRecvBuffer].flags & 0x40000000) | |||
This comment has been minimized.
Sorry, something went wrong. |
|||
&& (recvBufferDescr[currentRecvBuffer].flags & 0x03000000) == 0x03000000) | |||
This comment has been minimized.
Sorry, something went wrong.
amr98khaled
|
|||
|
|||
{ | |||
uint32_t size = recvBufferDescr[currentRecvBuffer].flags & 0xFFF; | |||
if(size > 64) // remove checksum | |||
This comment has been minimized.
Sorry, something went wrong. |
|||
size -= 4; | |||
|
|||
uint8_t* buffer = (uint8_t*)(recvBufferDescr[currentRecvBuffer].address); | |||
|
|||
for(int i = 0; i < size; i++) | |||
{ | |||
printfHex(buffer[i]); | |||
printf(" "); | |||
} | |||
} | |||
|
|||
recvBufferDescr[currentRecvBuffer].flags2 = 0; | |||
recvBufferDescr[currentRecvBuffer].flags = 0x8000F7FF; | |||
} | |||
} | |||
|
Sending a package :
"Flags2" shows whether an error occurred while sending and should therefore be set to 0 by the driver. The OWN bit must now be set in the “flags” field (0x80000000) in order to “transfer” the descriptor to the card. Furthermore, STP (Start of Packet, 0x02000000) and ENP (End of Packet, 0x01000000) should be set - this indicates that the data is not split up, but that it is a single Ethernet packet. Furthermore, bits 12-15 must be set (0x0000F000, are probably reserved) and bits 0-11 are negative Size of the package.