On Mon, Jun 15, 2009 at 1:30 PM, Nicolas Pitre <n...@cam.org> wrote:
>
> On Mon, 15 Jun 2009, Freddie Chopin wrote:
>
> > Nicolas Pitre pisze:
> > > If libftd2xx is not statically
> > > linked, or even not distributed along with the compiled OpenOCD
binary, then
> > > the case against it is highly arguable and far from being a black and
white
> > > picture but rather a large gray spot.
> >
> > That's the problem, because OpenOCD compiled with --enable-ft2232_ftd2xx
> > won't start if there is no ftd2xx.dll library somewhere. This solution
is not
> > good, because when one downloads a complete package, one expects it to
"just
> > work". PPL who use wiggler and have no idea about FTDI would than be
forced to
> > learn about that, find the library somewhere and install (copy) it into
the
> > system.
>
> That's a technical issue with an easy solution.  I wouldn't know how to
> go about it on Windows though, but on Linux this is only a matter of
> using dlopen() and a couple function pointers.
>
> Zach Welch was looking forward to make many parts of OpenOCD dynamically
> loadable.  Maybe the FTDI support would be the best place to start with.



Two ways to do it on Windows.  Use LoadLibrary()/GetProcAddress() or if you
are using the MS linker/libaries, mark ftd2xx.dll as delay load and wrap
calls to it with something like the following:

// See Windows documentation for these defines...
#define FACILITY_VISUALCPP  ((LONG)0x6d)
#define VcppException(sev,err)  ((sev) | (FACILITY_VISUALCPP<<16) | err)

__try
{
   // ftd2xx call
}
__except ((GetExceptionCode() == VcppException(ERROR_SEVERITY_ERROR,
ERROR_MOD_NOT_FOUND) ||
   GetExceptionCode() == VcppException(ERROR_SEVERITY_ERROR,
ERROR_PROC_NOT_FOUND)) ?
   EXCEPTION_EXECUTE_HANDLER : EXCEPTION_CONTINUE_SEARCH )
{
   // return an error
}

The above is how I handle WinUsb.

Usually, you'd only need the exception handling around the delay load dll's
initialization code as you shouldn't call any other functions in it if it
failed its initialization.

Orin.
_______________________________________________
Openocd-development mailing list
Openocd-development@lists.berlios.de
https://lists.berlios.de/mailman/listinfo/openocd-development

Reply via email to