Index: sockets/xif/ethernat/ethernat.c =================================================================== RCS file: /mint/freemint/sys/sockets/xif/ethernat/ethernat.c,v retrieving revision 1.9 diff -u -8 -p -r1.9 ethernat.c --- sockets/xif/ethernat/ethernat.c 14 Feb 2013 19:31:52 -0000 1.9 +++ sockets/xif/ethernat/ethernat.c 14 Feb 2013 19:44:30 -0000 @@ -48,16 +48,17 @@ #include "inet4/if.h" #include "inet4/ifeth.h" #include "netinfo.h" #include "mint/delay.h" #include "mint/mdelay.h" #include "mint/sockio.h" #include "mint/endian.h" +#include "mint/arch/asm_spl.h" /* spl() */ #include "91c111.h" #include "ethernat_200Hzint.h" #include // Define the 91c111 hardware registers @@ -141,16 +142,20 @@ static void ethernat_service (struct net static void ethernat_install_int (void); /* Convert single hex char to short */ short ch2i(char); // Convert long to hex ascii void hex2ascii(ulong l, uchar* c); +/* To know if the EtherNat is present through a bus error*/ +extern void ethernat_probe_asm(void); +void ethernat_probe_c(void); +static int found = 0; // Variable for locking out interrupt when accessing the hardware static volatile int in_use = 0; // If this variable equals 1, then the interrupt will do nothing until init is done (=0) static volatile int initializing = 1; static volatile int autoneg = 0; @@ -693,34 +698,37 @@ long driver_init (void) { // static char message[100]; //static char eth_fname[128]; long ferror; short fhandle; char macbuf[13]; + short sr; short sysdrv; char ethernat_inf[] = "A:\\ETHERNAT.INF"; // c_conws("Driver init\n\r"); // Lock out interrupt function initializing = 1; in_use = 1; // First check that the Ethernat card can be found - if((*LAN_BANK & 0x00ff) != 0x0033) - { -// ksprintf (message, "EtherNat not found! \n\r"); -// c_conws (message); + sr = spl7 (); + ethernat_probe_asm(); + spl (sr); - return -1; + if(!found) + { + c_conws ("\n\n\r\033pEtherNat not found!\033q\n\n\r"); + return -1; } // c_conws("Efter koll av ethernat\n\r"); //c_conws("*********************************\n\r"); //c_conws("******* EtherNat driver *********\n\r"); //c_conws("*********************************\n\r"); @@ -952,18 +960,24 @@ driver_init (void) //ksprintf (message, "OK\n\r"); //c_conws (message); #endif c_conws("Init succeeded\n\r"); return 0; } +void +ethernat_probe_c (void) +{ + if((*LAN_BANK & 0x00ff) != 0x0033) + return; - + found = 1; +} static void ethernat_install_int (void) { c_conws("install int\n\r"); //debug #ifdef USE_I6 Index: sockets/xif/ethernat/ethernat_200Hzint.s =================================================================== RCS file: /mint/freemint/sys/sockets/xif/ethernat/ethernat_200Hzint.s,v retrieving revision 1.1 diff -u -8 -p -r1.1 ethernat_200Hzint.s --- sockets/xif/ethernat/ethernat_200Hzint.s 22 Jan 2008 10:23:36 -0000 1.1 +++ sockets/xif/ethernat/ethernat_200Hzint.s 14 Feb 2013 19:44:30 -0000 @@ -34,16 +34,18 @@ .globl _old_200Hz_int .globl _interrupt_200Hz .globl _old_i6_int .globl _interrupt_i6 .globl _ethernat_int .globl _set_old_int_lvl .globl _set_int_lvl6 + .globl _ethernat_probe_asm, + .globl _ethernat_probe_c .text dc.l 0x58425241 | XBRA dc.l 0x00000000 | (no cookie) _old_200Hz_int: ds.l 1 @@ -86,8 +88,34 @@ _set_old_int_lvl: _set_int_lvl6: move.w d0,-(sp) move.w sr,d0 andi.w #0xf0ff,d0 ori.w #0x0600,d0 move.w d0,sr move.w (sp)+,d0 rts + + +| Change bus error exception handler +| Call probe function +| Enable again the old bus error handler +_ethernat_probe_asm: + movem.l a0-a7/d0-d7,-(sp) + move.w sr,-(sp) + move.l 8,old_berr + lea berr,a0 + move.l a0,8 + move.l sp,old_stack +| move.l _ethernat_probe_c,a0 +| jsr (a0) + bsr _ethernat_probe_c +berr: + move.l old_berr,8 + move.l old_stack,sp + move.w (sp)+,sr + movem.l (sp)+,d0-d7/a0-a7 + rts + +old_stack: + ds.l 1 +old_berr: + ds.l 1