Index: sys/usb/src.km/ucd/ethernat/ethernat_int.S =================================================================== RCS file: /mint/freemint/sys/usb/src.km/ucd/ethernat/ethernat_int.S,v retrieving revision 1.1 diff -u -8 -p -r1.1 ethernat_int.S --- sys/usb/src.km/ucd/ethernat/ethernat_int.S 29 Apr 2011 11:39:28 -0000 1.1 +++ sys/usb/src.km/ucd/ethernat/ethernat_int.S 15 Feb 2013 07:28:03 -0000 @@ -37,16 +37,18 @@ #define _cpld_cr 0x80000023 // Ethernat cpld control reg .globl _old_int .globl _interrupt .globl _ethernat_int .globl _set_old_int_lvl .globl _set_int_lvl6 .globl _hook_reset_vector + .globl _ethernat_probe_asm, + .globl _ethernat_probe_c .text dc.l 0x58425241 // XBRA dc.l 0x00000000 // (no cookie) _old_int: ds.l 1 _interrupt: @@ -97,12 +99,34 @@ oldreset: newreset: move.b _cpld_cr,d0 and.b 0xF9,d0 //0xFB USB, 0xF9 USB+ETH move.b d0,_cpld_cr move.l oldreset,_resvector move.l oldvalid,_resvalid jmp (a6) - .bss oldvalid: .ds.l 1 +// 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 + 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 + Index: sys/usb/src.km/ucd/ethernat/ethernat_int.h =================================================================== RCS file: /mint/freemint/sys/usb/src.km/ucd/ethernat/ethernat_int.h,v retrieving revision 1.1 diff -u -8 -p -r1.1 ethernat_int.h --- sys/usb/src.km/ucd/ethernat/ethernat_int.h 29 Apr 2011 11:39:28 -0000 1.1 +++ sys/usb/src.km/ucd/ethernat/ethernat_int.h 15 Feb 2013 07:28:03 -0000 @@ -31,9 +31,16 @@ extern void (*old_int)(void); // interrupt wrapper routine void interrupt(void); void hook_reset_vector(void); void set_old_int_lvl(void); void set_int_lvl6(void); +/* + * To know if the EtherNat is present through the bus error + */ +void ethernat_probe_asm(void); +void ethernat_probe_c(void); + + #endif // _ethernat_int_h Index: sys/usb/src.km/ucd/ethernat/isp116x-hcd.c =================================================================== RCS file: /mint/freemint/sys/usb/src.km/ucd/ethernat/isp116x-hcd.c,v retrieving revision 1.1 diff -u -8 -p -r1.1 isp116x-hcd.c --- sys/usb/src.km/ucd/ethernat/isp116x-hcd.c 29 Apr 2011 11:39:28 -0000 1.1 +++ sys/usb/src.km/ucd/ethernat/isp116x-hcd.c 15 Feb 2013 07:28:04 -0000 @@ -58,16 +58,17 @@ */ #include #include /* Setexc */ #include "mint/mint.h" #include "libkern/libkern.h" #include "mint/dcntl.h" +#include "mint/arch/asm_spl.h" /* spl() */ #include "../../config.h" #include "../../endian/io.h" #include "../../usb.h" #include "../ucd_defs.h" #include "ethernat_int.h" #define VER_MAJOR 0 @@ -175,16 +176,17 @@ struct ucdinfo *uinf; /****************************************************************************/ struct isp116x isp116x_dev; struct isp116x_platform_data isp116x_board; static long got_rhsc; /* root hub status change */ struct usb_device *devgone; /* device which was disconnected */ static long rh_devnum; /* address of Root Hub endpoint */ +static int found = 0; /* * interrupt handling - bottom half */ void _cdecl ethernat_int (void); /* * interrupt handling - top half */ @@ -1921,27 +1923,49 @@ usb_lowlevel_stop(void) struct isp116x *isp116x = &isp116x_dev; if (!isp116x->disabled) isp116x_stop(isp116x); return 0; } +void +ethernat_probe_c (void) +{ + if (!((*ETHERNAT_CPLD_CR) == (*ETHERNAT_CPLD_CR))) + return; + + found = 1; +} + long _cdecl init (struct kentry *k, struct ucdinfo *uinfo, char **reason) { long ret; + short sr; kentry = k; uinf = uinfo; if (check_kentry_version()) return -1; + /* Check that the Ethernat card can be found */ + sr = spl7 (); + ethernat_probe_asm(); + spl (sr); + + if(!found) + { + c_conws ("\n\r\033pEtherNat not found!\033q\n\n\r"); + DEBUG (("EtherNat not found!")); + return -1; + } + c_conws (MSG_BOOT); c_conws (MSG_GREET); DEBUG (("%s: enter init", __FILE__)); ret = (*uinf->ucd_register)(ðernat_uif); if (ret) { DEBUG (("%s: ucd register failed!", __FILE__));