Beispiel #1
0
static int
sb_write_config(sb_t *sbh, uint bus, uint dev, uint func, uint off, void *buf, int len)
{
	uint coreidx, n;
	void *regs;
	sbconfig_t *sb;
	pci_config_regs *cfg;

	if (dev >= SB_MAXCORES || (off + len) > sizeof(pci_config_regs))
		return -1;
	cfg = &sb_config_regs[dev];

	ASSERT(ISALIGNED(off, len));
	ASSERT(ISALIGNED((uintptr)buf, len));

	/* Emulate BAR sizing */
	if (off >= OFFSETOF(pci_config_regs, base[0]) && off <= OFFSETOF(pci_config_regs, base[3]) &&
	    len == 4 && *((uint32 *) buf) == ~0) {
		coreidx = sb_coreidx(sbh);
		if ((regs = sb_setcoreidx(sbh, dev))) {
			sb = (sbconfig_t *)((ulong) regs + SBCONFIGOFF);
			/* Highest numbered address match register */
			n = (R_REG(&sb->sbidlow) & SBIDL_AR_MASK) >> SBIDL_AR_SHIFT;
			if (off == OFFSETOF(pci_config_regs, base[0]))
				cfg->base[0] = ~(sb_size(R_REG(&sb->sbadmatch0)) - 1);
			else if (off == OFFSETOF(pci_config_regs, base[1]) && n >= 1)
				cfg->base[1] = ~(sb_size(R_REG(&sb->sbadmatch1)) - 1);
			else if (off == OFFSETOF(pci_config_regs, base[2]) && n >= 2)
				cfg->base[2] = ~(sb_size(R_REG(&sb->sbadmatch2)) - 1);
			else if (off == OFFSETOF(pci_config_regs, base[3]) && n >= 3)
				cfg->base[3] = ~(sb_size(R_REG(&sb->sbadmatch3)) - 1);
		}
static
String_buf read_mace4_input(FILE *fp)
{
  char line[1000], *s;  /* the first 999 chars of the line */
  String_buf sb = get_string_buf();
  BOOL ok = FALSE;

  s = fgets(line, 1000, fp);
  while (s && !substring("==== end of input", s)) {
    if (!ok && (initial_substring("clauses(", s) ||
		initial_substring("formulas(", s))) {
      if (sb_size(sb) != 0)
	sb_append(sb, "\n");  /* no newline before first list */
      ok = TRUE;
    }
    
    if (ok) {
      sb_append(sb, s);
      if (initial_substring("end_of_list.", s))
	ok = FALSE;
    }
      
    s = fgets(line, 1000, fp);
  }

  if (!s)
    fatal_error("read_mace4_input, \"==== end of input\" not found");

  return sb;
}  /* read_mace4_input */
Beispiel #3
0
Datei: ocl.c Projekt: nasa/QuIP
static void ocl_info(QSP_ARG_DECL  Compute_Platform *cpp)
{
	int s;

	sprintf(MSG_STR,"Vendor:  %s",OCLPF_VENDOR(cpp));
	prt_msg(MSG_STR);
	sprintf(MSG_STR,"Version:  %s",OCLPF_VERSION(cpp));
	prt_msg(MSG_STR);
	sprintf(MSG_STR,"Profile:  %s",OCLPF_PROFILE(cpp));
	prt_msg(MSG_STR);

	// The extensions can be long...
	s = (int) strlen(OCLPF_EXTENSIONS(cpp))+strlen(EXTENSIONS_PREFIX)+2;
	if( s > sb_size(QS_SCRATCH) )
		enlarge_buffer( QS_SCRATCH, s );
	sprintf(sb_buffer(QS_SCRATCH),"%s%s\n",EXTENSIONS_PREFIX,OCLPF_EXTENSIONS(cpp));
	prt_msg(sb_buffer(QS_SCRATCH));
}
Beispiel #4
0
size_t
proc_do_get_proc_nr()
{ return sb_size(&proc_tree); }