Example #1
0
 int get_argv_ordered(vector<string> const & args,
                      vector<string> & argvals) {
   // the first token is the name of the operation
   if ((args.size() < 2) || (args[0] != string("gq")) || (args[1] != m_cmdName) ||
       (!m_bVarArgs && ((args.size() - 2) != m_cmdArgs.size()))) {
     whereami(__FILE__, __LINE__);
     return Q_FAIL;
   }
   argvals.clear();
   if (args.size() > 2) {
     argvals.resize(m_cmdArgs.size());
     for (vector<string>::const_iterator i = args.begin() + 2, iEnd = args.end(); i != iEnd; ++i) {
       size_t eq_loc = i->find('=');
       if (eq_loc == string::npos) {
         whereami(__FILE__, __LINE__);
         return Q_FAIL;
       }
       string arg = i->substr(0, eq_loc);
       string val = i->substr(eq_loc + 1);
       int index = (m_cmdArgs.size() == 0 ? -1 :
                    m_cmdArgs.find(arg) == m_cmdArgs.end() ? - 1 :
                    m_cmdArgs[arg]);
       if ((index < 0) || (index >= int(m_cmdArgs.size())) ||
           (!m_bVarArgs && (val.empty() || !argvals[index].empty()))) {
         whereami(__FILE__, __LINE__);
         return Q_FAIL;
       }
       argvals[index] = val;
     }
   }
   return Q_PASS;
 }
Example #2
0
 int execute_cmd(vector<string> const & args, string & result) {
   if ((args.size() < 2) || (args[0] != string("gq"))) {
     whereami(__FILE__, __LINE__);
     return Q_FAIL;
   }
   if (m_cmd.find(args[1]) == m_cmd.end()) {
     whereami(__FILE__, __LINE__);
     return Q_FAIL;
   }
   return m_cmd[args[1]]->operator()(args, result);
 }
Example #3
0
void __assertion_handle_failure(const struct __assertion_point *point) {
	if (cpudata_var(assert_recursive_lock)) {
		printk("\nrecursion detected on CPU %d\n",
				cpu_get_id());
		goto out;
	}
	cpudata_var(assert_recursive_lock) = 1;

	spin_lock_ipl_disable(&assert_lock);

	print_oops();
	printk(
		" ASSERTION FAILED on CPU %d\n"
		LOCATION_FUNC_FMT("\t", "\n") "\n"
		"%s\n",

		cpu_get_id(),
		LOCATION_FUNC_ARGS(&point->location),
		point->expression);

	if (*__assertion_message_buff)
		printk("\n\t(%s)\n", __assertion_message_buff);

	whereami();

	spin_unlock(&assert_lock);  /* leave IRQs off */

out:
	arch_shutdown(ARCH_SHUTDOWN_MODE_ABORT);
	/* NOTREACHED */
}
Example #4
0
char *
eclipsehome(void)
{
    if (!eclipsehome_)
    {
	eclipsehome_ = whereami();
	if (!eclipsehome_)
	{
	    char buf1[MAX_PATH_LEN];
	    int size=MAX_PATH_LEN;
	    if (ec_env_lookup("ECLIPSEDIR", buf1, &size))
	    {
		(void) canonical_filename(buf1, buf);
		if (buf[0] != '/')
		{
		    char buf2[MAX_PATH_LEN];
		    strcpy(buf2, buf);
		    get_cwd(buf, MAX_PATH_LEN);
		    strcat(buf, buf2);
		}
		eclipsehome_ = buf;
	    }
	    else
	    {
#ifdef _WIN32
		eclipsehome_ = "//C/Eclipse";
#else
		eclipsehome_ = "/usr/local/eclipse";
#endif
	    }
	}
    }
    return eclipsehome_;
}
Example #5
0
int check_firmware(int fd) {

   frm_hdr_t it, bkp;
   char     *filebuf;
   ssize_t   red, filesize, err;

   if (gV > 1) puts("check_firmware");

   memset((char*)&it, 0, sizeof(it));
   memset((char*)&bkp, 0, sizeof(bkp));

   if ((red = read(fd, &it, sizeof(it))) != sizeof(it))      die("Reading header:");

   if (strncmp(FIRM_MAGIC, (char *)it.fm_magic, strlen(FIRM_MAGIC))) die("Bad magic!");

   memcpy((char*)&bkp, (char*)&it, sizeof(it));
   swap_endianness(&it);

   filesize = 392; //it.fm_hdr_len + it.mdul_hdr_len * it.num_mduls;
   if (!(filebuf = malloc(filesize*sizeof(unsigned char)))) die ("Malloc failed:");
   memset(filebuf, 0, filesize);
   filesize -= sizeof(bkp);
   memcpy(filebuf, &bkp, sizeof(bkp));
   if (sizeof(bkp)!=136) die("oops");
//   if ((red = read(fd, filebuf, filesize)) != filesize) die("Reading headers:");

   if ((red = read(fd, filebuf+sizeof(bkp), filesize)) != filesize) die("Reading headers:");
   if (red + 136 != filesize+sizeof(bkp)) {
     die("oops2");
   }
   if (gV > 1)
    printf("We got %d modules weighing %d bytes and a %d bytes header. Total Header size: %ld bytes\n",
     it.num_mduls, it.mdul_hdr_len, it.fm_hdr_len, filesize+sizeof(it));
  if (it.num_mduls > 20 || it.mdul_hdr_len > 0x1000 || it.fm_hdr_len > 0x1000)
    return(printf("Incorrect header length\n"));

   if (!(err = check_fmhdr(filebuf, filesize+sizeof(it)))) {
     mdul_hdr_t * mdl;
     for (int i = 0; i < it.num_mduls && !err; ++i) {

       if (gV > 1) printf("\n\n--- MODULE %d ---\n",i);
       if (MUST_DUMP) {
         if (curDumpFd) xclose(&curDumpFd);
         if (MUST_SPLIT_HDR && curHdrDumpFd) xclose(&curHdrDumpFd);
         currentDumpFd(); // to reset inner variable
         createDumpFd(mdl);
       mdl = (mdul_hdr_t*) (filebuf + it.fm_hdr_len + (i * it.mdul_hdr_len));
       whereami(fd);
       err = check_mdul_hdr(fd, mdl);

       }
     }
   }
   free(filebuf);
   return err;
}
Example #6
0
 int execute_command(vector<string> const & args,
                     string & result) {
   if (args[0] == string("sort")) {
     return sort_GPU(args[1], args[2]);
   } else {
     cerr << "ERROR: only fop sort [asc|dsc] is currently supported" << endl;
     whereami(__FILE__, __LINE__);
     return Q_FAIL;
   }
 }
Example #7
0
 int execute_command(vector<string> const & args,
                     string & result) {
   if (args[2] == "shift") {
     return f1_shift_f2_GPU(args[0], args[1], args[3], args[4]);
   } else {
     cerr << "ERROR: only f1opf2 shift is currently supported" << endl;
     whereami(__FILE__, __LINE__);
     return Q_FAIL;
   }
 }
Example #8
0
/*
  Write one bit data to Phy Controller
*/
static void phy_write_1bit(u32 ee_addr, u32 phy_data)
{
 whereami("phy_write_1bit\n");
 outl(phy_data, ee_addr);                        /* MII Clock Low */
 eeprom_delay();
 outl(phy_data|MDCLKH, ee_addr);                 /* MII Clock High */
 eeprom_delay();
 outl(phy_data, ee_addr);                        /* MII Clock Low */
 eeprom_delay();
}
Example #9
0
 int operator()(vector<string> const & args,
                string & result) {
   vector<string> argv;
   if (get_argv_ordered(args, argv) != Q_PASS) {
     whereami(__FILE__, __LINE__);
     return Q_FAIL;
   }
   int retval = execute_command(argv, result);
   cudaDeviceSynchronize();
   return retval;
 }
Example #10
0
/*
  Read one bit phy data from PHY controller
*/
static int phy_read_1bit(u32 ee_addr)
{
 int phy_data;

 whereami("phy_read_1bit\n");

 outl(0x50000, ee_addr);
 eeprom_delay();

 phy_data=(inl(ee_addr)>>19) & 0x1;

 outl(0x40000, ee_addr);
 eeprom_delay();

 return phy_data;
}
Example #11
0
/*
  Read a word data from phy register
*/
static int phy_read(int location)
{
 int i, phy_addr=1;
 u16 phy_data;
 u32 io_dcr9;

 whereami("phy_read\n");

 io_dcr9 = ioaddr + CSR9;

 /* Send 33 synchronization clock to Phy controller */
 for (i=0; i<34; i++)
     phy_write_1bit(io_dcr9, PHY_DATA_1);

 /* Send start command(01) to Phy */
 phy_write_1bit(io_dcr9, PHY_DATA_0);
 phy_write_1bit(io_dcr9, PHY_DATA_1);

 /* Send read command(10) to Phy */
 phy_write_1bit(io_dcr9, PHY_DATA_1);
 phy_write_1bit(io_dcr9, PHY_DATA_0);

 /* Send Phy addres */
 for (i=0x10; i>0; i=i>>1)
     phy_write_1bit(io_dcr9, phy_addr&i ? PHY_DATA_1: PHY_DATA_0);
   
 /* Send register addres */
 for (i=0x10; i>0; i=i>>1)
     phy_write_1bit(io_dcr9, location&i ? PHY_DATA_1: PHY_DATA_0);

 /* Skip transition state */
 phy_read_1bit(io_dcr9);

 /* read 16bit data */
 for (phy_data=0, i=0; i<16; i++) {
   phy_data<<=1;
   phy_data|=phy_read_1bit(io_dcr9);
 }

 return phy_data;
}
Example #12
0
/*
  Write a word to Phy register
*/
static void phy_write(int location, u16 phy_data)
{
 u16 i, phy_addr=1;
 u32 io_dcr9; 

 whereami("phy_write\n");

 io_dcr9 = ioaddr + CSR9;

 /* Send 33 synchronization clock to Phy controller */
 for (i=0; i<34; i++)
   phy_write_1bit(io_dcr9, PHY_DATA_1);

 /* Send start command(01) to Phy */
 phy_write_1bit(io_dcr9, PHY_DATA_0);
 phy_write_1bit(io_dcr9, PHY_DATA_1);

 /* Send write command(01) to Phy */
 phy_write_1bit(io_dcr9, PHY_DATA_0);
 phy_write_1bit(io_dcr9, PHY_DATA_1);

 /* Send Phy addres */
 for (i=0x10; i>0; i=i>>1)
   phy_write_1bit(io_dcr9, phy_addr&i ? PHY_DATA_1: PHY_DATA_0);

 /* Send register addres */
 for (i=0x10; i>0; i=i>>1)
   phy_write_1bit(io_dcr9, location&i ? PHY_DATA_1: PHY_DATA_0);

 /* written trasnition */
 phy_write_1bit(io_dcr9, PHY_DATA_1);
 phy_write_1bit(io_dcr9, PHY_DATA_0);

 /* Write a word data to PHY controller */
 for (i=0x8000; i>0; i>>=1)
   phy_write_1bit(io_dcr9, phy_data&i ? PHY_DATA_1: PHY_DATA_0);
}