00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00031 #include "jtagctrl_factory.h"
00032 #include <string.h>
00033 #include <stdio.h>
00034
00035 #ifdef HAVE_CONFIG_H
00036 #include <config.h>
00037 #endif
00038
00039 #ifdef USE_JTAG_CONTROL_EZUSB
00040 #include "ezusb_jtag.h"
00041 #endif
00042 #ifdef USE_JTAG_CONTROL_PP
00043 #include "pp_jtag.h"
00044 #endif
00045 #ifdef USE_JTAG_CONTROL_PPNEW
00046 #include "jtag_driver.h"
00047 #include "jtag_commander.h"
00048 #include "altera_jtag.h"
00049 #include "jtag_pp_commander.h"
00050 #endif // USE_JTAG_CONTROL_PPNEW
00051
00052 JTAGControlFactory::JTAGControlFactory(void)
00053 {
00054 #ifdef USE_JTAG_CONTROL_EZUSB
00055 controls.push_back(new EzUSBJTAG());
00056 #endif
00057 #ifdef USE_JTAG_CONTROL_PP
00058 controls.push_back(new PPJTAG());
00059 #endif
00060 #ifdef USE_JTAG_CONTROL_PPNEW
00061 JTAG_Driver * driver ;
00062 driver = (JTAG_Driver *)new AlteraByteBlasterJTAG();
00063 controls.push_back(new JTAG_ParallelPort_Commander( driver ));
00064 #endif // USE_JTAG_CONTROL_PPNEW
00065 }
00066
00067 JTAGControlFactory::~JTAGControlFactory(void)
00068 {
00069 for (std::vector<JTAGControl *>::iterator it=controls.begin(); it!=controls.end(); ++it)
00070 {
00071 assert(*it);
00072 delete (*it);
00073 }
00074 controls.clear();
00075 }
00076
00077 JTAGControl *JTAGControlFactory::getPrefered(const char *name, int argc, char *argv[]) const
00078 {
00079 for (std::vector<JTAGControl *>::const_iterator it=controls.begin(); it!=controls.end(); ++it)
00080 {
00081 assert(*it);
00082 if (strcmp((*it)->getName(), name)==0)
00083 {
00084 if ((*it)->init(argc, argv))
00085 return (*it);
00086 }
00087 }
00088 return NULL;
00089 }
00090
00091 JTAGControl *JTAGControlFactory::getAvailable(int argc, char *argv[]) const
00092 {
00093 for (std::vector<JTAGControl *>::const_iterator it=controls.begin(); it!=controls.end(); ++it)
00094 {
00095 assert (*it);
00096 if ((*it)->init(argc, argv))
00097 return (*it);
00098 }
00099 return NULL;
00100 }
00101
00102 void JTAGControlFactory::dumpList(void) const
00103 {
00104 for (std::vector<JTAGControl *>::const_iterator it=controls.begin(); it!=controls.end(); ++it)
00105 {
00106 assert(*it);
00107 printf("%s\n", (*it)->getName());
00108 }
00109 }