Line 40... |
Line 40... |
|
|
void interrupt_handler()
|
void interrupt_handler()
|
{
|
{
|
unsigned i,len;
|
unsigned i,len;
|
|
|
printf ("Int\n");
|
PRINTF ("Int\n");
|
switch (*eth_int_source & 0x7f) {
|
switch (*eth_int_source & 0x7f) {
|
case 0x2 :
|
case 0x2 :
|
printf ("Transmit Error.\n");
|
PRINTF ("Transmit Error.\n");
|
*eth_int_source = 0x2;
|
*eth_int_source = 0x2;
|
break;
|
break;
|
case 0x8 :
|
case 0x8 :
|
printf ("Receive Error\n");
|
PRINTF ("Receive Error\n");
|
*eth_int_source = 0x8;
|
*eth_int_source = 0x8;
|
break;
|
break;
|
case 0x4 :
|
case 0x4 :
|
printf ("Receive Frame\n");
|
PRINTF ("Receive Frame\n");
|
*eth_int_source = 0x4;
|
*eth_int_source = 0x4;
|
|
|
CLEAR_FLAG(*eth_moder, ETH_MODER, RXEN);
|
CLEAR_FLAG(*eth_moder, ETH_MODER, RXEN);
|
|
|
len = GET_FIELD(eth_bd_base[*eth_tx_bd_num + 2], ETH_RX_BD, LENGTH);
|
len = GET_FIELD(eth_bd_base[*eth_tx_bd_num + 2], ETH_RX_BD, LENGTH);
|
for (i=0; i<len; i++)
|
for (i=0; i<len; i++)
|
if (r_packet[i] != (unsigned char)i)
|
if (r_packet[i] != (unsigned char)i)
|
{
|
{
|
printf("Failed at byte %d. expect %d, received %d\n", i, i, r_packet[i]);
|
PRINTF("Failed at byte %d. expect %d, received %d\n", i, i, r_packet[i]);
|
exit(1);
|
exit(1);
|
}
|
}
|
break;
|
break;
|
case 0x10:
|
case 0x10:
|
printf ("Busy\n");
|
PRINTF ("Busy\n");
|
*eth_int_source = 0x10;
|
*eth_int_source = 0x10;
|
break;
|
break;
|
case 0x1 :
|
case 0x1 :
|
printf ("Transmit Frame.\n");
|
PRINTF ("Transmit Frame.\n");
|
*eth_int_source = 0x1;
|
*eth_int_source = 0x1;
|
CLEAR_FLAG(*eth_moder, ETH_MODER, TXEN);
|
CLEAR_FLAG(*eth_moder, ETH_MODER, TXEN);
|
|
|
break;
|
break;
|
default:
|
default:
|
printf ("Invalid int @ %0x\n", (unsigned int)*eth_int_source & 0x7f);
|
PRINTF ("Invalid int @ %0x\n", (unsigned int)*eth_int_source & 0x7f);
|
*eth_int_source = 0x7f;
|
*eth_int_source = 0x7f;
|
exit (1);
|
exit (1);
|
}
|
}
|
|
|
mtspr(SPR_PICSR, 0);
|
mtspr(SPR_PICSR, 0);
|
Line 118... |
Line 118... |
{
|
{
|
unsigned i;
|
unsigned i;
|
|
|
int_happend = 0;
|
int_happend = 0;
|
/* Initialize packet */
|
/* Initialize packet */
|
printf("Init\n");
|
PRINTF("Init\n");
|
for ( i = 0; i < sizeof(s_packet); ++ i )
|
for ( i = 0; i < sizeof(s_packet); ++ i )
|
s_packet[i] = (unsigned char)i;
|
s_packet[i] = (unsigned char)i;
|
|
|
/* Set Ethernet BD */
|
/* Set Ethernet BD */
|
printf("Set BD\n");
|
PRINTF("Set BD\n");
|
SET_FIELD(eth_bd_base[tx_bindex], ETH_TX_BD, LENGTH, sizeof(s_packet));
|
SET_FIELD(eth_bd_base[tx_bindex], ETH_TX_BD, LENGTH, sizeof(s_packet));
|
eth_bd_base[tx_bindex + 1] = (unsigned long)s_packet;
|
eth_bd_base[tx_bindex + 1] = (unsigned long)s_packet;
|
|
|
/* Start Ethernet */
|
/* Start Ethernet */
|
printf("Set Flags\n");
|
PRINTF("Set Flags\n");
|
SET_FLAG(eth_bd_base[tx_bindex], ETH_TX_BD, IRQ);
|
SET_FLAG(eth_bd_base[tx_bindex], ETH_TX_BD, IRQ);
|
SET_FLAG(eth_bd_base[tx_bindex], ETH_TX_BD, READY);
|
SET_FLAG(eth_bd_base[tx_bindex], ETH_TX_BD, READY);
|
SET_FLAG(*eth_moder, ETH_MODER, TXEN);
|
SET_FLAG(*eth_moder, ETH_MODER, TXEN);
|
}
|
}
|
|
|
Line 153... |
Line 153... |
|
|
len = GET_FIELD(eth_bd_base[rx_bindex], ETH_RX_BD, LENGTH);
|
len = GET_FIELD(eth_bd_base[rx_bindex], ETH_RX_BD, LENGTH);
|
for (i=0; i<len; i++)
|
for (i=0; i<len; i++)
|
if (r_packet[i] != (unsigned char)i)
|
if (r_packet[i] != (unsigned char)i)
|
{
|
{
|
printf("Failed at byte %d. expect %d, received %d\n", i, i, r_packet[i]);
|
PRINTF("Failed at byte %d. expect %d, received %d\n", i, i, r_packet[i]);
|
exit(1);
|
exit(1);
|
}
|
}
|
}
|
}
|
|
|
static void receive_one_packet_int(void)
|
static void receive_one_packet_int(void)
|
{
|
{
|
int_happend = 0;
|
int_happend = 0;
|
printf("Set BD\n");
|
PRINTF("Set BD\n");
|
eth_bd_base[rx_bindex + 1] = (unsigned long)r_packet;
|
eth_bd_base[rx_bindex + 1] = (unsigned long)r_packet;
|
|
|
printf("SetFlags\n");
|
PRINTF("SetFlags\n");
|
SET_FLAG(eth_bd_base[rx_bindex], ETH_RX_BD, IRQ);
|
SET_FLAG(eth_bd_base[rx_bindex], ETH_RX_BD, IRQ);
|
SET_FLAG(eth_bd_base[rx_bindex], ETH_RX_BD, READY);
|
SET_FLAG(eth_bd_base[rx_bindex], ETH_RX_BD, READY);
|
SET_FLAG(*eth_moder, ETH_MODER, RXEN);
|
SET_FLAG(*eth_moder, ETH_MODER, RXEN);
|
}
|
}
|
|
|
int main()
|
int main()
|
{
|
{
|
printf( "Starting Ethernet test\n" );
|
PRINTF( "Starting Ethernet test\n" );
|
|
|
tx_bindex = 0;
|
tx_bindex = 0;
|
rx_bindex = *eth_tx_bd_num;
|
rx_bindex = *eth_tx_bd_num;
|
|
|
set_mac();
|
set_mac();
|
Line 195... |
Line 195... |
|
|
/*-------------------*/
|
/*-------------------*/
|
/* interrupt test */
|
/* interrupt test */
|
excpt_int = (unsigned long)interrupt_handler;
|
excpt_int = (unsigned long)interrupt_handler;
|
/* Enable interrup ts */
|
/* Enable interrup ts */
|
printf("enable ints\n");
|
PRINTF("enable ints\n");
|
mtspr (SPR_SR, mfspr(SPR_SR) | SPR_SR_IEE);
|
mtspr (SPR_SR, mfspr(SPR_SR) | SPR_SR_IEE);
|
mtspr (SPR_PICMR, mfspr(SPR_PICMR) | (0x00000001L << ETH_IRQ));
|
mtspr (SPR_PICMR, mfspr(SPR_PICMR) | (0x00000001L << ETH_IRQ));
|
|
|
printf("set mask flags TX\n");
|
PRINTF("set mask flags TX\n");
|
SET_FLAG(*eth_int_mask, ETH_INT_MASK, TXB_M);
|
SET_FLAG(*eth_int_mask, ETH_INT_MASK, TXB_M);
|
transmit_one_packet_int();
|
transmit_one_packet_int();
|
tx_bindex += 2;
|
tx_bindex += 2;
|
printf("waiting for int\n");
|
PRINTF("waiting for int\n");
|
while (!int_happend);
|
while (!int_happend);
|
CLEAR_FLAG(*eth_int_mask, ETH_INT_MASK, TXB_M);
|
CLEAR_FLAG(*eth_int_mask, ETH_INT_MASK, TXB_M);
|
|
|
printf("seting mask flag RX\n");
|
PRINTF("seting mask flag RX\n");
|
SET_FLAG(*eth_int_mask, ETH_INT_MASK, RXB_M);
|
SET_FLAG(*eth_int_mask, ETH_INT_MASK, RXB_M);
|
receive_one_packet_int();
|
receive_one_packet_int();
|
rx_bindex += 2;
|
rx_bindex += 2;
|
printf("waiting for int\n");
|
PRINTF("waiting for int\n");
|
while (!int_happend);
|
while (!int_happend);
|
CLEAR_FLAG(*eth_int_mask, ETH_INT_MASK, RXB_M);
|
CLEAR_FLAG(*eth_int_mask, ETH_INT_MASK, RXB_M);
|
|
|
|
|
printf( "Ending Ethernet test\n" );
|
PRINTF( "Ending Ethernet test\n" );
|
|
|
report (0xdeaddead);
|
report (0xdeaddead);
|
exit(0);
|
exit(0);
|
}
|
}
|
|
|