static int cmd_test(int ac, char **av)
{
	__console_alloc();
	if (ac==1) {
		cpuinfo();
		meminfo();
		uartinfo();
		netinfo();
	}
	else if(!strcmp(av[1],"cpu")) cpuinfo();
	else if(!strcmp(av[1],"mem")) meminfo();
	else if(!strcmp(av[1],"uart")) uartinfo();
	else if(!strcmp(av[1],"net")) netinfo();
	pause1();
}
Exemple #2
0
    void main_page(Database &database, Request &request, std::ostream &fcout)
    {
        (void)database; (void)request;

        struct statvfs stat;
        statvfs("/", &stat);
        fcout << "Total disk space: " << (stat.f_blocks * stat.f_frsize)/1024/1024 << "Mb<br>" << std::endl;
        fcout << "Free disk space: " << (stat.f_bavail * stat.f_bsize)/1024/1024 << "Mb<br>" << std::endl;
        fcout << "Total number of files: " << stat.f_files << "<br>" << std::endl;

        std::ifstream f("/proc/meminfo");
        std::string line;
        for (int i = 0; i < 2; ++i)
        {
            std::getline(f, line);
            fcout << line << "<br>" << std::endl;
        }

        std::ifstream cpuinfo("/proc/cpuinfo");
        while (std::getline(cpuinfo, line))
        {
            if (line.substr(0, strlen("Processor")) == "Processor" || line.substr(0, strlen("model name")) == "model name")
            {
                fcout << line << "<br>" << std::endl;
                break;
            }
        }
    }
Exemple #3
0
unsigned int cSystem::getNumCoresPerCPU(void)
{
#ifdef __unix__
    std::ifstream   cpuinfo("/proc/cpuinfo");
    std::string     line;
    size_t          start, end;

    while (!cpuinfo.eof()) {
        std::getline(cpuinfo,line);

        if (!line.size()) {
            continue;
        }
        if (line.find("cpu cores") != 0) {
            continue;
        }

        for (start = line.find(':'); line[start] < '0' || line[start] > '9'; start++);
        for (end = start; line[end] >= '0' && line[end] <= '9'; end++);
        line = line.substr(start, end-start);

        break;
    }

    return atoi(line.c_str());
#else
    ERROR("getNumCoresPerCPU", "this OS is not yest supported");
#endif
}
Exemple #4
0
static int64_t* get_cpu_frequency_from_file(const char *file, int ncpus)
{
  std::ifstream cpuinfo(file);
  if (cpuinfo.fail()) {
    return nullptr;
  }
  char line[MAX_LINELENGTH];
  int64_t* freqs = new int64_t[ncpus];
  for (int i = 0; i < ncpus; ++i) {
    freqs[i] = 0;
  }
  int processor = -1;

  while (cpuinfo.getline(line, sizeof(line))) {
    if (sscanf(line, "processor : %d", &processor) == 1) {
      continue;
    }
    float freq;
    if (sscanf(line, "cpu MHz : %f", &freq) == 1) {
      if (processor != -1 && processor < ncpus) {
         freqs[processor] = nearbyint(freq);
         processor = -1;
      }
    }
  }
  for (int i = 0; i < ncpus; ++i) {
    if (freqs[i] == 0) {
      delete[] freqs;
      return nullptr;
    }
  }
  return freqs;
}
bool Slave::init(void)
{
    // Check on which hardware we are running based on the info in /proc/cpuinfo.
    // Defaulting to Generic X86
    QString hardwarePlugin("plugins/GenericX86/libgeneric_x86.so");
    QFile cpuinfo("/proc/cpuinfo");
    if (cpuinfo.open(QIODevice::ReadOnly | QIODevice::Text)) {
        qDebug() << "Reading cpuinfo";
        QByteArray content = cpuinfo.readAll();

        // Check for Gumstix Overo
        if (content.contains("Gumstix Overo")) {
            qDebug() << "Detected Gumstix Overo";
            hardwarePlugin = "plugins/GumstixOvero/libgumstix_overo.so";
        }

        cpuinfo.close();
    }


    qDebug() << "Loading hardware plugin:" << hardwarePlugin;
    // FIXME: add proper application specific plugin installation prefix.
    // For now we just seach so that the plugins in source code directories work.
    // FIXME: these doesn't affect pluginLoader?
    this->addLibraryPath("./plugins/GenericX86");
    this->addLibraryPath("./plugins/GumstixOvero");

    QPluginLoader pluginLoader(hardwarePlugin);
    QObject *plugin = pluginLoader.instance();

    if (plugin) {
        hardware = qobject_cast<Hardware*>(plugin);
        if (!hardware) {
            qCritical("Failed cast Hardware");
        }
    } else {
        qCritical("Failed to load plugin: %s", pluginLoader.errorString().toUtf8().data());
        qCritical("Search path: %s", this->libraryPaths().join(",").toUtf8().data());
    }

    // FIXME: get serial device path from hardware plugin?
    cb = new ControlBoard("/dev/ttyUSB0");
    if (!cb->init()) {
        qCritical("Failed to initialize ControlBoard");
        // CHECKME: to return false or not to return false (and do clean up)?
    } else {
        // Set ControlBoard frequency to 50Hz to match standard servos
        cb->setPWMFreq(50);
    }

    return true;
}
Exemple #6
0
QString QSystemDeviceInfoLinuxCommonPrivate::manufacturer()
{
    QFile vendorId("/sys/devices/virtual/dmi/id/board_vendor");
    if (vendorId.open(QIODevice::ReadOnly)) {
        QTextStream cpuinfo(&vendorId);
        return cpuinfo.readLine().trimmed();
    } else {
        QFile file("/proc/cpuinfo");
        if (!file.open(QIODevice::ReadOnly)) {
            qDebug() << "Could not open /proc/cpuinfo";
        } else {
            QTextStream cpuinfo(&file);
            QString line = cpuinfo.readLine();
            while (!line.isNull()) {
                line = cpuinfo.readLine();
                if (line.contains("vendor_id"))
                    return line.split(": ").at(1).trimmed();
            }
        }
    }

    return QString();
}
std::int64_t iware::cpu::frequency() noexcept {
	std::ifstream cpuinfo("/proc/cpuinfo");

	if(!cpuinfo.is_open() || !cpuinfo)
		return 0;

	for(std::string line; std::getline(cpuinfo, line);)
		if(line.find("cpu MHz") == 0) {
			const auto colon_id = line.find_first_of(':');
			return static_cast<int64_t>(std::strtod(line.c_str() + colon_id + 1, nullptr) * 1'000'000);
		}

	return 0;
}
Exemple #8
0
void NeoHardware::findHardwareVersion()
{
    QFile cpuinfo( "/proc/cpuinfo");
    QString inStr;
    cpuinfo.open(QIODevice::ReadOnly | QIODevice::Text);
    QTextStream in(&cpuinfo);
    QString line;
    do {
        line  = in.readLine();
        if (line.contains("Hardware") ){
            QStringList token = line.split(":");
            inStr = token.at(1).simplified();
        }
    } while (!line.isNull());

    cpuinfo.close();
    qLog(Hardware)<<"Neo"<< inStr;

    vsoNeoHardware.setAttribute("Device", inStr);
    vsoNeoHardware.sync();
}
int ringbuf_init(size_t size, size_t n, int key) {
    size_t initsize = 0;
    void *addr = NULL;
    char *ch;
    int id;

#ifdef RB_CACHE_ALIGN
    csize = cpuinfo();
    if (csize > 0)
        cacheline_size = (uint32_t)csize;

    size = size_align(size, cacheline_size);
#endif

    initsize = sizeof(shm_data_t) + size * n;

    id = shmget(key, initsize, SHM_R|SHM_W|IPC_CREAT);
    if (id == 0)
        return -1;

    addr = shmat(id, NULL, 0);
    if (addr == (void*)-1) 
        return -2;

    shm = (shm_data_t*)addr;
    shm->size = size;
    shm->max = n;

    // init mutex_w
    ch = shm->channel;
    shmtx_init(&mutex_w, (shmtx_sh_t*)ch, 0x800);
    shmtx_init(&mutex_r, (shmtx_sh_t*)(ch + 64), 0x800);

#ifdef RB_DEBUG
    printf("index_r: %u, index_w: %u\n", shm->index_r, shm->index_w);
#endif

    return 0;
}
Exemple #10
0
static inline uint64_t getCpuFrequency(void)
{
    uint64_t freq = 0;
    std::string line;
    std::ifstream cpuinfo("/proc/cpuinfo");
    if (cpuinfo.is_open())
    {
        while ( getline (cpuinfo,line) )
        {
            if(line.find("MHz") != line.npos)
                break;
        }
        cpuinfo.close();
    }
    else std::cout << "Unable to open file";

    size_t pos = line.find(":");
    if (pos != line.npos) {
        std::string mhz_str = line.substr(pos+2, line.npos - pos);
        double freq1 = strtod(mhz_str.c_str(), NULL);
        freq = freq1 * 1000000ULL;
    }
    return freq;
}
Exemple #11
0
/*
 * Called after a function declaration which introduces a function definition
 * and before an (optional) old style argument declaration list.
 *
 * Puts all symbols declared in the Prototype or in an old style argument
 * list back to the symbol table.
 *
 * Does the usual checking of storage class, type (return value),
 * redeclaration etc..
 */
void
funcdef(sym_t *fsym)
{
	int	n, warn;
	sym_t	*arg, *sym, *rdsym;

	funcsym = fsym;

	/*
	 * Put all symbols declared in the argument list back to the
	 * symbol table.
	 */
	for (sym = dcs->d_fpsyms; sym != NULL; sym = sym->s_dlnxt) {
		if (sym->s_blklev != -1) {
			if (sym->s_blklev != 1)
				lerror("funcdef() 1");
			inssym(1, sym);
		}
	}

	/*
	 * In osfunc() we did not know whether it is an old style function
	 * definition or only an old style declaration, if there are no
	 * arguments inside the argument list ("f()").
	 */
	if (!fsym->s_type->t_proto && fsym->s_args == NULL)
		fsym->s_osdef = 1;

	chktyp(fsym);

	/*
	 * chktyp() checks for almost all possible errors, but not for
	 * incomplete return values (these are allowed in declarations)
	 */
	if (fsym->s_type->t_subt->t_tspec != VOID &&
	    incompl(fsym->s_type->t_subt)) {
		/* cannot return incomplete type */
		error(67);
	}

	fsym->s_def = DEF;

	if (fsym->s_scl == TYPEDEF) {
		fsym->s_scl = EXTERN;
		/* illegal storage class */
		error(8);
	}

	if (dcs->d_inline)
		fsym->s_inline = 1;

	/*
	 * Arguments in new style function declarations need a name.
	 * (void is already removed from the list of arguments)
	 */
	n = 1;
	for (arg = fsym->s_type->t_args; arg != NULL; arg = arg->s_nxt) {
		if (arg->s_scl == ABSTRACT) {
			if (arg->s_name != unnamed)
				lerror("funcdef() 2");
			/* formal parameter lacks name: param #%d */
			error(59, n);
		} else {
			if (arg->s_name == unnamed)
				lerror("funcdef() 3");
		}
		n++;
	}

	/*
	 * We must also remember the position. s_dpos is overwritten
	 * if this is an old style definition and we had already a
	 * prototype.
	 */
	STRUCT_ASSIGN(dcs->d_fdpos, fsym->s_dpos);

	if ((rdsym = dcs->d_rdcsym) != NULL) {

		if (!isredec(fsym, (warn = 0, &warn))) {

			/*
			 * Print nothing if the newly defined function
			 * is defined in old style. A better warning will
			 * be printed in cluparg().
			 */
			if (warn && !fsym->s_osdef) {
				/* redeclaration of %s */
				(*(sflag ? error : warning))(27, fsym->s_name);
				prevdecl(-1, rdsym);
			}

			/* copy usage information */
			cpuinfo(fsym, rdsym);

			/*
			 * If the old symbol was a prototype and the new
			 * one is none, overtake the position of the
			 * declaration of the prototype.
			 */
			if (fsym->s_osdef && rdsym->s_type->t_proto)
				STRUCT_ASSIGN(fsym->s_dpos, rdsym->s_dpos);

			/* complete the type */
			compltyp(fsym, rdsym);

			/* once a function is inline it remains inline */
			if (rdsym->s_inline)
				fsym->s_inline = 1;

		}

		/* remove the old symbol from the symbol table */
		rmsym(rdsym);

	}

	if (fsym->s_osdef && !fsym->s_type->t_proto) {
		if (sflag && hflag && strcmp(fsym->s_name, "main") != 0)
			/* function definition is not a prototype */
			warning(286);
	}

	if (dcs->d_notyp)
		/* return value is implicitly declared to be int */
		fsym->s_rimpl = 1;

	reached = 1;
}
Exemple #12
0
void
hp700_init(int argc, char *argv[], char *envp[])
{
	int hpmc_br_instr;
	int *p = (int *) i_hpmach_chk;
	register struct mapping *mp;
	int i;
	vm_offset_t addr;
	int pdcerr;
	vm_offset_t first_page;

	struct pdc_coproc pdc_coproc;
	struct pdc_cache pdc_cache;
	struct pdc_model pdc_model;
	struct pdc_iodc_read pdc_iodc;
	extern int crashdump(void);
#ifdef	BTLB
	struct pdc_btlb pdc_btlb;
#endif
#ifdef	HPT
	struct pdc_hwtlb pdc_hwtlb;
	extern struct hpt_entry *hpt_table;
	extern int usehpt;
#endif	

	first_page = move_bootstrap();

	if (argc >= 1 && argc <= 4) {
		char *btstring = boot_string;
		char *src = (argc == 1 ? envp[5] : argv[2]);

		i = 0;
		while (*src != '\0' && i++ <= BOOT_LINE_LENGTH)
			*btstring++ = *src++;
		*btstring = '\0';
	}

	pdc = PAGE0->mem_pdc;

	delay_init();
	pdc_console_init();

	printf("%s", version);

	/*
	 * Determine what the boot program is using as its console
	 * so that we can use the same device.
	 */
	pdcerr = (*pdc)(PDC_IODC, PDC_IODC_READ, &pdc_iodc,
			PAGE0->mem_cons.pz_hpa, PDC_IODC_INDEX_DATA,
			&cons_iodc, sizeof(cons_iodc));
	if (pdcerr == 0)
		bcopy((char *)&PAGE0->mem_cons.pz_dp, (char *)&cons_dp,
		      sizeof(struct device_path));
	else
		printf("Warning: can't id console boot device (PDC Ret'd %d)\n",
		       pdcerr);

        /*
         * Read boot device from PROM
         */
	pdcerr = (*PAGE0->mem_pdc)(PDC_IODC, PDC_IODC_READ, &pdc_iodc,
	                           PAGE0->mem_boot.pz_hpa, PDC_IODC_INDEX_DATA,
	                           &boot_iodc, sizeof(boot_iodc));
	if (pdcerr == 0)
		bcopy((char *)&PAGE0->mem_boot.pz_dp, (char *)&boot_dp,
		      sizeof(struct device_path));
	else
		printf("Warning: can't id boot device (PDC Ret'd %d)\n",
		       pdcerr);
	
	/*
	 * Setup the transfer of control addr to point to the crash dump
	 * initialization code.
	 */
	PAGE0->ivec_toc = crashdump;

	/*
	 * get cache parameters from the PDC
	 */
	(*PAGE0->mem_pdc)(PDC_CACHE, PDC_CACHE_DFLT, &pdc_cache);

	dcache_line_size = pdc_cache.dc_conf.cc_line * 16;
	dcache_line_mask = dcache_line_size - 1;
	dcache_block_size = dcache_line_size * pdc_cache.dc_conf.cc_block;

	dcache_size = pdc_cache.dc_size;
	dcache_base = pdc_cache.dc_base;
	dcache_stride = pdc_cache.dc_stride;
	dcache_count = pdc_cache.dc_count;
	dcache_loop = pdc_cache.dc_loop;

	icache_line_size = pdc_cache.ic_conf.cc_line * 16;
	icache_line_mask = icache_line_size - 1;
	icache_block_size = icache_line_size * pdc_cache.ic_conf.cc_block;

	icache_base = pdc_cache.ic_base;
	icache_stride = pdc_cache.ic_stride;
	icache_count = pdc_cache.ic_count;
	icache_loop = pdc_cache.ic_loop;

	/*
	 * purge TLBs and flush caches
	 */
	ptlball(&pdc_cache);

#ifdef	BTLB
        /*
         * get block tlb information for clearing
         */
	pdcerr = (*pdc)(PDC_BLOCK_TLB, PDC_BTLB_DEFAULT, &pdc_btlb);
	
        if (pdcerr != 0)
                printf("Warning: PDC_BTLB call Ret'd %d\n", pdcerr);

	switch (pdc_btlb.finfo.num_c) {
	/* S-Chip specific */
	case 0: 
		cputype = CPU_PCXS;
		for (i = 0; i < pdc_btlb.finfo.num_i; i++)
			purge_block_itlb(i);
		for (i = 0; i < pdc_btlb.finfo.num_d; i++)
			purge_block_dtlb(i);
		break;
	/* L-Chip specific */
	case 8:
		cputype = CPU_PCXL;
		for (i = 0; i < pdc_btlb.finfo.num_c; i++)
			purge_L_block_ctlb(i);
		break;
	/* T-Chip specific */
	case 16:
		cputype = CPU_PCXT;
		for (i = 0; i < pdc_btlb.finfo.num_c; i++)
			purge_block_ctlb(i);
		break;
	default:
		panic("unrecognized block-TLB, cannot purge block TLB(s)");
		/* NOTREACHED */
	}
#endif

	fcacheall();

	/*
	 * get the cpu type
	 */
	(*PAGE0->mem_pdc)(PDC_MODEL, PDC_MODEL_INFO, &pdc_model);

	machtype = pdc_model.hvers >> 4;

	cpuinfo(&pdc_cache);

	if (dcache_line_size != CACHE_LINE_SIZE)
		printf("WARNING: data cache line size = %d bytes, %s\n",
		       dcache_line_size, "THIS IS *VERY* BAD!");

	/*
	 * Get the instruction to do branch to PDC_HPMC from PDC.  If
	 * successful, then insert the instruction at the beginning
	 * of the HPMC handler.
	 */
	if ((*PAGE0->mem_pdc)(PDC_INSTR, PDC_INSTR_DFLT, &hpmc_br_instr) == 0)
		p[0] = hpmc_br_instr;
	else
		p[0] = 0;

	/* 
	 * Now compute the checksum of the hpmc interrupt vector entry
	 */
	p[5] = -(p[0] + p[1] + p[2] + p[3] + p[4] + p[6] + p[7]);

	/*
	 * setup page size for Mach
	 */
	page_size = HP700_PGBYTES;
	vm_set_page_size();

	/*
	 * configure the devices including memory. Passes back size of 
	 * physical memory in mem_size.
	 */
	busconf();

	/* 
	 * Zero out BSS of kernel before doing anything else. The location
	 * pointed to by &edata is included in the data section.
	 */
	bzero((char*)((vm_offset_t) &edata + 4), (vm_offset_t) &end - 
	      (vm_offset_t) &edata - 4);

        /*
         * Locate any coprocessors and enable them by setting up the CCR.
         * SFU's are ignored (since we dont have any).  Also, initialize
         * the floating point registers here.
         */
        if ((pdcerr = (*pdc)(PDC_COPROC, PDC_COPROC_DFLT, &pdc_coproc)) < 0)
                printf("Warning: PDC_COPROC call Ret'd %d\n", pdcerr);
        copr_sfu_config = pdc_coproc.ccr_enable;
        mtctl(CR_CCR, copr_sfu_config & CCR_MASK);
        fprinit(&fpcopr_version);
	fpcopr_version = (fpcopr_version & 0x003ff800) >> 11;
        mtctl(CR_CCR, 0);

        /*
         * Clear the FAULT light (so we know when we get a real one)
         * PDC_COPROC apparently turns it on (for whatever reason).
         */
        pdcerr = PDC_OSTAT(PDC_OSTAT_RUN) | 0xCEC0;
        (void) (*pdc)(PDC_CHASSIS, PDC_CHASSIS_DISP, pdcerr);

#ifdef TIMEX
	/*
	 * Enable the quad-store instruction.
	 */
	pdcerr = (*pdc)(PDC_MODEL, PDC_MODEL_ENSPEC,
			&pdc_model, pdc_model.pot_key);
	if (pdcerr < 0)
		printf("Warning: PDC enable FP quad-store Ret'd %d\n", pdcerr);
#endif


	/*
	 * Intialize the Event Trace Analysis Package
	 * Static Phase: 1 of 2
	 */
	etap_init_phase1();

	/*
	 * on the hp700 the value in &etext is a pointer to the last word
	 * in the text section. Similarly &edata and &end are pointers to
	 * the last words in the section. We want to change this so that 
	 * these pointers point past the sections that they terminate.
	 */
	text_start = trunc_page((vm_offset_t) &start_text);
	text_end = round_page((vm_offset_t) &etext + 4);

	/*
	 * before we go to all the work to initialize the VM see if we really 
	 * linked the image past the end of the PDC/IODC area.
	 */
	if (text_start < 0x10800)
		panic("kernel text mapped over PDC and IODC memory");

	/*
	 * find ranges of physical memory that isn't allocated to the kernel
	 */

	avail_start = round_page(first_page);
	first_avail = avail_start;
	avail_end = trunc_page(mem_size);
	
	/*
	 * bootstrap the rest of the virtual memory system
	 */
#ifdef MAXMEMBYTES
	if ((avail_end - avail_start) > MAXMEMBYTES) {
		mem_size  = trunc_page(MAXMEMBYTES);
		avail_end = mem_size;
	}
#endif

#ifdef HPT
	/*
	 * If we want to use the HW TLB support, ensure that it exists.
	 */
	if (usehpt &&
	    !((*pdc)(PDC_TLB, PDC_TLB_INFO, &pdc_hwtlb) == 0 &&
	      (pdc_hwtlb.min_size || pdc_hwtlb.max_size)))
		usehpt = 0;
#endif

	pmap_bootstrap(&avail_start, &avail_end);

	/*
	 * set limits on virtual memory and kernel equivalenced memory
	 */
	virtual_avail = avail_end;
	virtual_end = trunc_page(VM_MAX_KERNEL_ADDRESS);

	/*
	 * pmap_bootstrap allocated memory for data structures that must
	 * be equivalently mapped.
	 */
	equiv_end = (long) round_page((vm_offset_t) &end);
	io_end = 0xF0000000;	/* XXX */

	/*
	 * Do block mapping. We are mapping from 0, up through the first
	 * power of 2 address above the end of the equiv region. This 
	 * means some memory gets block mapped that should not be, but
	 * so be it (we make the text writable also :-)). We do this to
	 * conserve block entries since we hope to use them for other
	 * purposes (someday).
	 */
	addr = avail_start;
	if (addr != 1 << log2(addr))
		addr = 1 << log2(addr);

#ifdef	BTLB
	if(pdc_btlb.finfo.num_c)
		printf("%d BTLB entries found.  Block mapping up to 0x%x (0x%x)\n",
		       pdc_btlb.finfo.num_c, addr, avail_start);

	/*
	 * XXX L-CHIP vs T-CHIP vs S-CHIP difference in Block TLB insertion.
	 */
	switch (pdc_btlb.finfo.num_c) {
	/* S-CHIP */
	case 0:
		pmap_block_map(0, addr, VM_PROT_ALL, 0, BLK_ICACHE);
		pmap_block_map(0, addr, VM_PROT_READ|VM_PROT_WRITE,
			       0, BLK_DCACHE);
		break;
	/* L-CHIP */
	case 8:
		pmap_block_map(0, addr, VM_PROT_ALL, 0, BLK_LCOMBINED);
		break;
	/* T-CHIP */
	case 16:
		pmap_block_map(0, addr, VM_PROT_ALL, 0, BLK_COMBINED);
		break;
	default:
		panic("unrecognized block-TLB, cannot map kernel");
		/* NOTREACHED */
	}
#endif

#ifdef	HPT
	/*
	 * Turn on the HW TLB assist.
	 */
	if (usehpt) {
		pdcerr = (*pdc)(PDC_TLB, PDC_TLB_CONFIG,
				&pdc_hwtlb, hpt_table,
				sizeof(struct hpt_entry) * HP700_HASHSIZE,
				PDC_TLB_WORD3);
		if (pdcerr) {
			printf("Warning: HW TLB init failed (%d), disabled\n",
			       pdcerr);
			usehpt = 0;
		} else
			printf("HW TLB initialized (%d entries at 0x%x)\n",
			       HP700_HASHSIZE, hpt_table);
	}
#endif

	/*
	 * map the PDC and IODC area for kernel read/write
	 * XXX - should this be read only?
	 */
	(void) pmap_map(0, 0, text_start, VM_PROT_READ | VM_PROT_WRITE);

	/*
	 * map the kernel text area.
	 */
#if KGDB
	(void) pmap_map(text_start, text_start, text_end, 
			VM_PROT_READ | VM_PROT_EXECUTE | VM_PROT_WRITE);
#else
	(void) pmap_map(text_start, text_start, text_end, 
			VM_PROT_READ | VM_PROT_EXECUTE);
#endif

	/*
	 * map the data section of the kernel
	 */
	(void) pmap_map(text_end, text_end, avail_start,
			VM_PROT_READ | VM_PROT_WRITE);

#ifndef IO_HACK
	/*
	 * map the I/O pages
	 */
	(void) pmap_map(trunc_page(io_size), trunc_page(io_size),
			0, VM_PROT_READ | VM_PROT_WRITE);
#endif

#if 0
	/*
	 * map the breakpoint page
	 */
	(void) pmap_map(break_page, break_page, break_page+HP700_PAGE_SIZE,
			VM_PROT_READ | VM_PROT_EXECUTE);
#endif

	/*
	 * map the interrupt stack red zone.
	 */
	addr = trunc_page((vm_offset_t) &intstack_top);
	(void) pmap_map(addr, addr, addr + PAGE_SIZE, VM_PROT_READ);

	vm_on = 1;
}
int main(int argc, const char** argv) {
  // start logs
  printf("clDeviceQuery Starting...\n\n");
  bool bPassed = true;
  std::string sProfileString = "clDeviceQuery, Platform Name = ";

  // Get OpenCL platform ID for NVIDIA if avaiable, otherwise default
  char cBuffer[1024];
  cl_platform_id clSelectedPlatformID = NULL;
  cl_platform_id* clPlatformIDs;

  cl_uint num_platforms;
  cl_int ciErrNum = clGetPlatformIDs(0, NULL, &num_platforms);
  if (ciErrNum != CL_SUCCESS) {
    printf(" Error %i in clGetPlatformIDs Call!\n\n", ciErrNum);
    bPassed = false;
  } else {
    if (num_platforms == 0) {
      printf("No OpenCL platform found!\n\n");
      bPassed = false;
    } else {
      // if there's one platform or more, make space for ID's
      if ((clPlatformIDs = (cl_platform_id*)malloc(num_platforms * sizeof(cl_platform_id))) == NULL) {
	printf("Failed to allocate memory for cl_platform ID's!\n\n");
	bPassed = false;
      }

      printf("%d OpenCL Platforms found\n\n", num_platforms);
      // get platform info for each platform
      ciErrNum = clGetPlatformIDs (num_platforms, clPlatformIDs, NULL);
      for(cl_uint i = 0; i < num_platforms; ++i) {
	ciErrNum = clGetPlatformInfo (clPlatformIDs[i], CL_PLATFORM_NAME, 1024, &cBuffer, NULL);
	if(ciErrNum == CL_SUCCESS) {
	  clSelectedPlatformID = clPlatformIDs[i];
	  // Get OpenCL platform name and version
	  ciErrNum = clGetPlatformInfo (clSelectedPlatformID, CL_PLATFORM_NAME, sizeof(cBuffer), cBuffer, NULL);
	  if (ciErrNum == CL_SUCCESS) {
	    printf(" CL_PLATFORM_NAME: \t%s\n", cBuffer);
	    sProfileString += cBuffer;
	  } else {
	    printf(" Error %i in clGetPlatformInfo Call !!!\n\n", ciErrNum);
    bPassed = false;
  }
  sProfileString += ", Platform Version = ";

  ciErrNum = clGetPlatformInfo (clSelectedPlatformID, CL_PLATFORM_VERSION, sizeof(cBuffer), cBuffer, NULL);
  if (ciErrNum == CL_SUCCESS) {
    printf(" CL_PLATFORM_VERSION: \t%s\n", cBuffer);
    sProfileString += cBuffer;
  } else {
    printf(" Error %i in clGetPlatformInfo Call !!!\n\n", ciErrNum);
    bPassed = false;
  }

  // Log OpenCL SDK Version # (for convenience:  not specific to OpenCL)
  sProfileString += ", NumDevs = ";

  // Get and log OpenCL device info
  cl_uint ciDeviceCount;
  cl_device_id *devices;
  printf("OpenCL Device Info:\n\n");
  ciErrNum = clGetDeviceIDs (clSelectedPlatformID, CL_DEVICE_TYPE_ALL, 0, NULL, &ciDeviceCount);

  // check for 0 devices found or errors...
  if (ciDeviceCount == 0) {
    printf(" No devices found supporting OpenCL (return code %i)\n\n", ciErrNum);
    bPassed = false;
    sProfileString += "0";
  } else if (ciErrNum != CL_SUCCESS) {
    printf(" Error %i in clGetDeviceIDs call !!!\n\n", ciErrNum);
    bPassed = false;
  } else {
    // Get and log the OpenCL device ID's
    ciErrNum = clGetPlatformInfo (clSelectedPlatformID, CL_PLATFORM_NAME, sizeof(cBuffer), cBuffer, NULL);
    printf(" %u devices found supporting OpenCL on: %s\n\n", ciDeviceCount, cBuffer);
    char cTemp[2];
    sprintf(cTemp, "%u", ciDeviceCount);
    sProfileString += cTemp;
    if ((devices = (cl_device_id*)malloc(sizeof(cl_device_id) * ciDeviceCount)) == NULL) {
      printf(" Failed to allocate memory for devices !!!\n\n");
      bPassed = false;
    }
    ciErrNum = clGetDeviceIDs (clSelectedPlatformID, CL_DEVICE_TYPE_ALL, ciDeviceCount, devices, &ciDeviceCount);
    if (ciErrNum == CL_SUCCESS) {
      for(unsigned int i = 0; i < ciDeviceCount; ++i )  {
        printf(" ----------------------------------\n");
clGetDeviceInfo(devices[i], CL_DEVICE_NAME, sizeof(cBuffer), &cBuffer, NULL);
printf(" Device %s\n", cBuffer);
printf(" ---------------------------------\n");
clPrintDevInfo(devices[i]);
sProfileString += ", Device = ";
sProfileString += cBuffer;
      }
            } else {
      printf(" Error %i in clGetDeviceIDs call !!!\n\n", ciErrNum);
      bPassed = false;
    }
  }

  // masterlog info
  sProfileString += "\n";
  printf("%s", sProfileString.c_str());
}
free(clPlatformIDs);
      }
    }
  }

  // Log system info(for convenience:  not specific to OpenCL)
  printf( "\nSystem Info: \n\n");
  char timestr[255];
  time_t now = time(NULL);
  struct tm  *ts;

  ts = localtime(&now);

  strftime(timestr, 255, " %H:%M:%S, %m/%d/%Y",ts);

  // write time and date to logs
  printf(" Local Time/Date = %s\n", timestr);
  // write proc and OS info to logs
  // parse /proc/cpuinfo
  std::ifstream cpuinfo( "/proc/cpuinfo" ); // open the file in /proc
  std::string tmp;

  int cpu_num = 0;
  std::string cpu_name = "none";
  do {
    cpuinfo >> tmp;

    if( tmp == "processor" )
      cpu_num++;

    if( tmp == "name" ) {
      cpuinfo >> tmp; // skip :

      std::stringstream tmp_stream("");
      do {
	cpuinfo >> tmp;
	if (tmp != std::string("stepping")) {
	  tmp_stream << tmp.c_str() << " ";
	}

      }
      while (tmp != std::string("stepping"));

      cpu_name = tmp_stream.str();
    }
  }
  while ( (! cpuinfo.eof()) );

  // Linux version
  std::ifstream version( "/proc/version" );
  char versionstr[255];

  version.getline(versionstr, 255);

  printf(" CPU Name: %s\n # of CPU processors: %u\n %s\n\n\n",
	 cpu_name.c_str(),cpu_num,versionstr);

  // finish
  printf("TEST %s\n\n", bPassed ? "PASSED" : "FAILED !!!");
}
    void
    Crash::crashHandler( int /*signal*/ )
    {
        // we need to fork to be able to get a
        // semi-decent bt - I dunno why
        const pid_t pid = ::fork();

        if( pid < 0 )
        {
            std::cout << "forking crash reporter failed\n";
            // continuing now can't do no good
            _exit( 1 );
        }
        else if ( pid == 0 )
        {
            // we are the child process (the result of the fork)
            std::cout << "Pana is crashing...sorry this will be a minute...\n";

            QString subject = APP_VERSION " ";
            QString body = i18n(
                    "Pana has crashed.\n\n"
                    "Please help us fix it by clicking send on the crash report, "
                    "If you have time please add a brief description of what was happening just before the crash.\n\n"
                    "Thank you very much.\n\n" );
            body += i18n( "\n\n\n\n\n\n"
                    "The information below is to help identify the problem.\n\n\n ");


            body += "=== Debug information ===\n"
                    "Version:    " APP_VERSION "\n"
                    "Engine:     %1\n"
                    "Build date: " __DATE__ "\n"
                    "CC version: " __VERSION__ "\n"
                    "KDElibs:    " KDE_VERSION_STRING "\n"
                    "Qt:         %2\n"
                    "TagLib:     %3.%4.%5\n"
                    "CPU count:  %6\n";

            QString cpucount = "unknown";
#ifdef __linux__
            QString line;
            uint cpuCount = 0;
            QFile cpuinfo( "/proc/cpuinfo" );
            if ( cpuinfo.open( IO_ReadOnly ) ) {
                while ( cpuinfo.readLine( line, 20000 ) != -1 ) {
                    if ( line.startsWith( "processor" ) ) {
                        ++cpuCount;
                    }
                }
            }
            cpucount = QString::number( cpuCount );
#endif


            body = body.arg( PanaConfig::soundSystem() )
                    .arg( qVersion() )
                    .arg( TAGLIB_MAJOR_VERSION )
                    .arg( TAGLIB_MINOR_VERSION )
                    .arg( TAGLIB_PATCH_VERSION )
                    .arg( cpucount );

            #ifdef NDEBUG
            body += "NDEBUG:     true";
            #endif
            body += '\n';

            /// obtain the backtrace with gdb

            KTempFile temp;
            temp.setAutoDelete( true );

            const int handle = temp.handle();

//             QCString gdb_command_string =
//                     "file panaapp\n"
//                     "attach " + QCString().setNum( ::getppid() ) + "\n"
//                     "bt\n" "echo \\n\n"
//                     "thread apply all bt\n";

            const QCString gdb_batch =
                    "bt\n"
                    "echo \\n\\n\n"
                    "bt full\n"
                    "echo \\n\\n\n"
                    "echo ==== (gdb) thread apply all bt ====\\n\n"
                    "thread apply all bt\n";

            ::write( handle, gdb_batch, gdb_batch.length() );
            ::fsync( handle );

            // so we can read stderr too
            ::dup2( fileno( stdout ), fileno( stderr ) );


            QCString gdb;
            gdb  = "gdb --nw -n --batch -x ";
            gdb += temp.name().latin1();
            gdb += " panaapp ";
            gdb += QCString().setNum( ::getppid() );

            QString bt = runCommand( gdb );

            /// clean up
            bt.remove( "(no debugging symbols found)..." );
            bt.remove( "(no debugging symbols found)\n" );
            bt.replace( QRegExp("\n{2,}"), "\n" ); //clean up multiple \n characters
            bt.stripWhiteSpace();

            /// analyze usefulness
            bool useful = true;
            const QString fileCommandOutput = runCommand( "file `which panaapp`" );

            if( fileCommandOutput.find( "not stripped", false ) == -1 )
                subject += "[___stripped]"; //same length as below
            else
                subject += "[NOTstripped]";

            if( !bt.isEmpty() ) {
                const int invalidFrames = bt.contains( QRegExp("\n#[0-9]+\\s+0x[0-9A-Fa-f]+ in \\?\\?") );
                const int validFrames = bt.contains( QRegExp("\n#[0-9]+\\s+0x[0-9A-Fa-f]+ in [^?]") );
                const int totalFrames = invalidFrames + validFrames;

                if( totalFrames > 0 ) {
                    const double validity = double(validFrames) / totalFrames;
                    subject += QString("[validity: %1]").arg( validity, 0, 'f', 2 );
                    if( validity <= 0.5 ) useful = false;
                }
                subject += QString("[frames: %1]").arg( totalFrames, 3 /*padding*/ );

                if( bt.find( QRegExp(" at \\w*\\.cpp:\\d+\n") ) >= 0 )
                    subject += "[line numbers]";
            }
            else
                useful = false;

            subject += QString("[%1]").arg( PanaConfig::soundSystem().remove( QRegExp("-?engine") ) );

            std::cout << subject.latin1() << std::endl;


            //TODO -fomit-frame-pointer buggers up the backtrace, so detect it
            //TODO -O optimization can rearrange execution and stuff so show a warning for the developer
            //TODO pass the CXXFLAGS used with the email

            if( useful ) {
                body += "==== file `which panaapp` =======\n";
                body += fileCommandOutput + "\n\n";
                body += "==== (gdb) bt =====================\n";
                body += bt + "\n\n";
                body += "==== kdBacktrace() ================\n";
                body += kdBacktrace();

                //TODO startup notification
                kapp->invokeMailer(
                        /*to*/          "*****@*****.**",
                        /*cc*/          QString(),
                        /*bcc*/         QString(),
                        /*subject*/     subject,
                        /*body*/        body,
                        /*messageFile*/ QString(),
                        /*attachURLs*/  QStringList(),
                        /*startup_id*/  "" );
            }
            else {
                std::cout << i18n( "\nPana has crashed.\n\n"
                                   "Perhaps an upgrade is already available "
                                   "which fixes the problem. Please check your distribution's software repository.\n" ).local8Bit();
            }

            //_exit() exits immediately, otherwise this
            //function is called repeatedly ad finitum
            ::_exit( 255 );
        }

        else {
            // we are the process that crashed

            ::alarm( 0 );

            // wait for child to exit
            ::waitpid( pid, NULL, 0 );
            ::_exit( 253 );
        }
    }
Exemple #15
0
// main
int CSysInfoWidget::exec(CMenuTarget *parent, const std::string &/*actionKey*/)
{
	int res = menu_return::RETURN_REPAINT;

	if(mode == SYSINFO)
	{
		sysinfo();
	}
	else if(mode == DMESGINFO)
	{
		dmesg();
	}
	else if(mode == CPUINFO)
	{
		cpuinfo();
	}
	else if(mode == PSINFO)
	{
		ps();
	}

	if (parent)
		parent->hide();

	paintHead();
	paint();
	paintFoot();
	
	frameBuffer->blit();

	neutrino_msg_t msg; 
	neutrino_msg_data_t data;
	int timercount = 0;
	unsigned long long timeoutEnd = g_RCInput->calcTimeoutEnd(5);

	while (msg != (neutrino_msg_t) g_settings.key_channelList_cancel)
	{
		g_RCInput->getMsgAbsoluteTimeout( &msg, &data, &timeoutEnd );

		if (msg <= CRCInput::RC_MaxRC  ) 
			timeoutEnd = g_RCInput->calcTimeoutEnd(5);
		
		if (msg == CRCInput::RC_timeout)
		{
			if (mode == SYSINFO)
			{
				timercount = 0;
				sysinfo();
				selected = 0;
				paintHead();
				paint();
				paintFoot();
			}
			
			if ((mode == DMESGINFO) && (++timercount>11))
			{
				timercount = 0;
				dmesg();
				paintHead();
				paint();
				paintFoot();
			}
			
			if ((mode == PSINFO)&&(refreshIt == true))
			{
				timercount = 0;
				ps();
				paintHead();
				paint();
				paintFoot();
			}

			timeoutEnd = g_RCInput->calcTimeoutEnd(5);
			g_RCInput->getMsgAbsoluteTimeout( &msg, &data, &timeoutEnd );
		}
		
		if ( ((int) msg == g_settings.key_channelList_pageup) && (mode != SYSINFO))
		{
			int step = 0;
			int prev_selected = selected;

			step =  ((int) msg == g_settings.key_channelList_pageup) ? listmaxshow : 1;  // browse or step 1
			selected -= step;
			if((prev_selected - step) < 0) 
				selected = syscount - 1;
			
			if(state == beDefault)
			{
				paintItem(prev_selected - liststart);
				unsigned int oldliststart = liststart;
				liststart = (selected/listmaxshow)*listmaxshow;
				if(oldliststart!=liststart) 
					paint();
				else 
					paintItem(selected - liststart);
			}
		}
		else if (((int) msg == g_settings.key_channelList_pagedown) && (mode != SYSINFO))
		{
			int step = 0;
			int prev_selected = selected;

			step =  ((int) msg == g_settings.key_channelList_pagedown) ? listmaxshow : 1;  // browse or step 1
			selected += step;
			if((int)selected >= syscount) 
				selected = 0;
			
			if(state == beDefault)
			{
				paintItem(prev_selected - liststart);
				unsigned int oldliststart = liststart;
				liststart = (selected/listmaxshow)*listmaxshow;
				if(oldliststart != liststart) 
					paint();
				else 
					paintItem(selected - liststart);
			}
		}
		else if ((msg == CRCInput::RC_red) && (mode != SYSINFO))
		{
			mode = SYSINFO;
			sysinfo();
			selected = 0;
			paintHead();
			paint();
			paintFoot();

		}
		else if ((msg == CRCInput::RC_green) && (mode != DMESGINFO))
		{
			mode = DMESGINFO;
			timercount = 0;
			dmesg();
			selected = 0;
			paintHead();
			paint();
			paintFoot();
		}
		else if ((msg == CRCInput::RC_yellow) && (mode != CPUINFO))
		{
			mode = CPUINFO;
			cpuinfo();
			selected = 0;
			paintHead();
			paint();
			paintFoot();
		}
		else if (msg == CRCInput::RC_blue)
		{
			mode = PSINFO;
			ps();
			selected = 0;
			paintHead();
			paint();
			paintFoot();
		}
		else
		{
			CNeutrinoApp::getInstance()->handleMsg( msg, data );
			// kein canceling...
		}

		frameBuffer->blit();	
	}
	
	hide();
	
	return res;
}
Exemple #16
0
void shell::start()
{
	cout<<"Starting shell : Type help for available commands\n";
	char *cmd=new char[128]  ;
	while(1)
	{	
		//memset(cmd,0,128);
		cout.SetColour(GREEN,BLACK,0);	
		cout<<"NanOS-#>";
		cout.SetColour(WHITE,BLACK,0);
		cin>>cmd;
		//cout<<" \nCommand : "<<cmd<<"\n";
		if(String::strncmp((const char*)cmd,"about",5)==0)
			about();
		else if(String::strncmp((const char*)cmd,"help",4)==0)
			help();
		else if(String::strncmp((const char*)cmd,"clear",5)==0)
			cout.clear();
		else if(String::strncmp((const char*)cmd,"date",4)==0)
			get_cmos_date_time();
		else if(String::strncmp((const char*)cmd,"hello",5)==0)
			cout<<"Hi, how do you do???"<<"\n";
		else if(String::strncmp((const char*)cmd,"cpuinfo",7)==0)
			cpuinfo();
		else if(String::strncmp((const char*)cmd,"meminfo",7)==0)
			meminfo();
		else if(String::strncmp((const char*)cmd,"pci",3)==0)
		{
			pci_bus *sys_pci=pci_bus::Instance();
			sys_pci->list_dev();
		}
		else if(String::strncmp((const char*)cmd,"devclass",8)==0)
		{
			pci_bus *sys_pci=pci_bus::Instance();
			unsigned short x=atoi(cmd+9);
			pci_dev *device=sys_pci->get_dev_by_class(x);
			int i=0;
			while(device)
			{
				cout.flags(hex|showbase);
				cout<<device->bus<<":"<<device->dev<<":"<<device->func<<":";
				cout<<vendor_to_string(device->common->vendor_id)<<":"<<vendor_device_to_string(device->common->vendor_id,device->common->device_id)<<":";
				cout<<class_to_string(device->common->classcode,device->common->subclass)<<":";
				cout<<(int)device->common->classcode<<":"<<(int)device->common->subclass<<":";
				cout<<(int)(device->common->Prog_if)<<":"<<(int)device->common->header_type<<"\n";
				i++;
				device=device->next;
			}
			cout.flags(dec);
			cout<<"Total devices="<<i<<"\n";
		}	
		else if(String::strncmp((const char*)cmd,"bootdev",7)==0)
			{
				extern char *boot_dev;
				cout<<(char *)boot_dev<<"\n";
			}
		
		else if(String::strncmp((const char*)cmd,"tasks",5)==0)
			{
				all_tasks();	
			}
		else if(String::strncmp((const char*)cmd,"ide",3)==0)
			{
				display_slot_info();	
			}
		else if(String::strncmp((const char*)cmd,"hdinfo",6)==0)
		{
			for(int i=0;i<4;i++)
			//if(disks[i])
			{
				//disks[i]->disk_info();
			}
		}
		else if(String::strncmp((const char*)cmd,"sysdriveinfo",12)==0)
		{
			display_sysdrive_info();
		}
		else if(String::strcmp((const char*)cmd, "")==0);
		
		else
			cout<<"Unknown Command\n For available commands type help\n";
		
	}
}
Exemple #17
0
// return TRUE if command has been processed to half further processing
BOOL Plugin_ProcessChannelCommand(int ServerID, int ChannelID, char **Command, char **Args)
{
  BOOL Processed = FALSE;
  char *NewCommand = NULL;
  char *NewArgs = NULL;
  HIRC_ChannelInfo_t CI;
  
  HydraIRC_GetChannelInfo(ChannelID,&CI);

  if (stricmp(*Command,"MODE") == 0)
  {
    if (CI.Mask & HIRC_CI_NAME) // Got channel name ?
    {
      NewCommand = HydraIRC_BuildString(MAX_COMMAND_BUFFER,"RAW");

      if (*Args && (**Args == '+' || **Args == '-'))
        NewArgs = HydraIRC_BuildString(MAX_COMMAND_BUFFER,"MODE %s %s",CI.Name,*Args ? *Args : "");
      else
        NewArgs = HydraIRC_BuildString(MAX_COMMAND_BUFFER,"MODE %s",*Args ? *Args : "");
    }
  }
  else
  if (stricmp(*Command,"TOPIC") == 0)
  {
    if (CI.Mask & HIRC_CI_NAME) // Got channel name ?
    {
      NewCommand = HydraIRC_BuildString(MAX_COMMAND_BUFFER,"RAW");
      if (*Args && **Args)
        NewArgs = HydraIRC_BuildString(MAX_COMMAND_BUFFER,"TOPIC %s :%s",CI.Name,*Args);
      else
        NewArgs = HydraIRC_BuildString(MAX_COMMAND_BUFFER,"TOPIC %s",CI.Name);
    }
  }
  else
  if (stricmp(*Command,"PIMP") == 0)
  {
    NewCommand = HydraIRC_BuildString(MAX_COMMAND_BUFFER,"ME");
#ifdef RELEASE_VERSION
    NewArgs = HydraIRC_BuildString(MAX_COMMAND_BUFFER,"is using HydraIRC " VERSIONSTRING " - Grab it from www.HydraIRC.com");
#else
    NewArgs = HydraIRC_BuildString(MAX_COMMAND_BUFFER,"is using HydraIRC " VERSIONSTRING " - Grab it from #HydraIRC on EFNet");
#endif
  }
  else
  if (stricmp(*Command,"KR") == 0)
  {
    Processed = TRUE;
    if (!*Args || !**Args)
      HydraIRC_ChannelPrintf(ChannelID,BIC_ERROR,"ERROR: <kick reason>");
    else
    {    
      if (g_KickReason) free(g_KickReason);
      g_KickReason = strdup(*Args);
    }
  }
  else
  if (stricmp(*Command,"KICK") == 0)
  {
    Processed = TRUE; // set it to TRUE, in case of errors
    if (CI.Mask & HIRC_CI_NAME) // Got channel name ?
    {
      char *ArgsCpy = NULL;
      char *Nick = NULL;
      char *Message = NULL;

      if (*Args)
      {
        ArgsCpy = strdup(*Args);
        if (ArgsCpy)
        {
          Nick = strtok(ArgsCpy," ");
          Message = strtok(NULL,"");
        }
      }

      if (Nick && *Nick)
      {
        if (!Message)
        {
          if (g_KickReason) 
            Message = g_KickReason;
          else
            Message = "Kick!"; // supply a default kick message
        }

        NewCommand = HydraIRC_BuildString(MAX_COMMAND_BUFFER,"RAW");
        NewArgs = HydraIRC_BuildString(MAX_COMMAND_BUFFER,"KICK %s %s :%s",CI.Name,Nick,Message);
        Processed = FALSE;
      }
      else
        HydraIRC_ChannelPrintf(ChannelID,BIC_ERROR,"ERROR: <nick> [<message>]");

      if (ArgsCpy) free(ArgsCpy);
    }
  }
  else
  if (stricmp(*Command,"SLAP") == 0)
  {
    Processed = TRUE; // set it to TRUE, in case of errors
    if (CI.Mask & HIRC_CI_NAME) // Got channel name ?
    {
      if (*Args && **Args)
      {
        NewCommand = HydraIRC_BuildString(MAX_COMMAND_BUFFER,"ME");
        NewArgs = HydraIRC_BuildString(MAX_COMMAND_BUFFER,PickRandomString(g_SlapMessages,sizeof (g_SlapMessages) / sizeof(char *)),*Args);
        Processed = FALSE;
      }
      else
        HydraIRC_ChannelPrintf(ChannelID,BIC_ERROR,"ERROR: <nick>");
    }
  }
  else
  if (stricmp(*Command,"SYSINFO") == 0)
  {
    NewCommand = HydraIRC_BuildString(MAX_COMMAND_BUFFER,"ME");
    NewArgs = HydraIRC_BuildString(MAX_COMMAND_BUFFER,"is using \x02%s\x02 || \x02%s\x02 || \x02%s\x02", osversion(), cpuinfo(), meminfo());
    Processed = FALSE;
  }
 
  if (NewCommand != NULL)
  {
    sys_Free(*Command); // Free the old command, and then replace it...
    *Command = NewCommand;    
    // Note: NewCommand will eventually be  sys_Free()'d by HydraIRC

    // then do the same for the args
    if (NewArgs != NULL)
    {
      sys_Free(*Args);
      *Args = NewArgs;    
    }
  }

  return Processed;
}