Example #1
0
int hmfsi_target_probe(struct target *cfam, struct target *targets, int max_target_count)
{
	struct target *target = targets;
	uint64_t value, chip_id;
	int target_count = 0, i;

	for (i = 0; i < 8 && i < max_target_count; i++) {
		mfsi_target_init(target, "MFSI Port", 0x80000 + i * HMFSI_STRIDE, cfam);
		if (read_target(target, 0xc09, &value)) {
			target_del(target);
			continue;
		}

		/* Ignore unknown chip ids */
		chip_id = GETFIELD(PPC_BITMASK32(12, 19), value);
		if (chip_id != 0xea && chip_id != 0xd3) {
			target_del(target);
			continue;
		}

		target++;
		target_count++;
	}

	return target_count;
}
Example #2
0
int main(int argc, char **argv)
{
	unsigned char t; 
	int hi = atoi(argv[2]);
	int low = atoi(argv[3]);
	sscanf(argv[1], "%i", &t);

	printf("mask %d,%d 0x%02x\n", hi, low, GETFIELD(t, hi, low));
}
Example #3
0
static int64_t opb_read(struct lpcm *lpc, uint32_t addr, uint32_t *data,
		        uint32_t sz)
{
	uint64_t ctl = ECCB_CTL_MAGIC | ECCB_CTL_READ, stat;
	int64_t rc, tout;

	if (lpc->mbase)
		return opb_mmio_read(lpc, addr, data, sz);

	if (sz != 1 && sz != 2 && sz != 4) {
		prerror("Invalid data size %d\n", sz);
		return OPAL_PARAMETER;
	}

	ctl = SETFIELD(ECCB_CTL_DATASZ, ctl, sz);
	ctl = SETFIELD(ECCB_CTL_ADDRLEN, ctl, ECCB_ADDRLEN_4B);
	ctl = SETFIELD(ECCB_CTL_ADDR, ctl, addr);
	rc = xscom_write(lpc->chip_id, lpc->xbase + ECCB_CTL, ctl);
	if (rc) {
		log_simple_error(&e_info(OPAL_RC_LPC_READ),
			"LPC: XSCOM write to ECCB CTL error %lld\n", rc);
		return rc;
	}

	for (tout = 0; tout < ECCB_TIMEOUT; tout++) {
		rc = xscom_read(lpc->chip_id, lpc->xbase + ECCB_STAT,
				&stat);
		if (rc) {
			log_simple_error(&e_info(OPAL_RC_LPC_READ),
				"LPC: XSCOM read from ECCB STAT err %lld\n",
									rc);
			return rc;
		}
		if (stat & ECCB_STAT_OP_DONE) {
			uint32_t rdata = GETFIELD(ECCB_STAT_RD_DATA, stat);
			if (stat & ECCB_STAT_ERR_MASK) {
				log_simple_error(&e_info(OPAL_RC_LPC_READ),
					"LPC: Error status: 0x%llx\n", stat);
				return OPAL_HARDWARE;
			}
			switch(sz) {
			case 1:
				*data = rdata >> 24;
				break;
			case 2:
				*data = rdata >> 16;
				break;
			default:
				*data = rdata;
				break;
			}
			return 0;
		}
		time_wait_nopoll(100);
	}
Example #4
0
File: cfam.c Project: shenki/pdbg
enum chip_type get_chip_type(uint64_t chip_id)
{
	switch(GETFIELD(PPC_BITMASK32(12, 19), chip_id)) {
	case 0xea:
		return CHIP_P8;
	case 0xd3:
		return CHIP_P8NV;
	case 0xd1:
		return CHIP_P9;
	default:
		return CHIP_UNKNOWN;
	}
}
int WiFiEngine_RegisterMIBTable(const void *table, size_t size, uint32_t vaddr)
{
   struct mib_table *tmp;
   mib_object_reference_type_t type;
   mib_object_size_description_t sdesc;
   uint32_t addr;
   uint32_t esize;

   tmp = DriverEnvironment_Malloc(sizeof(*tmp) - sizeof(tmp->table) + size);
   if(tmp == NULL) {
      DE_TRACE_STATIC(TR_ALWAYS, "failed to allocate memory for MIB table\n");
      return WIFI_ENGINE_FAILURE_RESOURCES;
   }
   DE_MEMCPY(tmp->table, table, size);
   tmp->size = size;
   tmp->vaddr = vaddr;

   type = (mib_object_reference_type_t)GETFIELD(tmp->table[0].storage_description, REFERENCE_TYPE);
   sdesc = (mib_object_size_description_t)GETFIELD(tmp->table[0].storage_description, OBJECT_SIZE_DESCRIPTION);
   addr = GETADDR(tmp->table[0].reference);
   esize = GETFIELD(tmp->table[0].storage_description, OBJECT_SIZE);
   if(type != MIB_OBJECT_REFERENCE_TYPE_MIB_TABLE
      || sdesc != MIB_OBJECT_SIZE_DESCRIPTION_FIXED_SIZE
      || !ADDRVALID(addr, tmp)) {
      DE_TRACE_INT5(TR_ALWAYS, "bad MIB table format t:%x s:%x a:%x e:%x v:%x\n",
            type, sdesc, addr, esize, ADDRVALID(addr, tmp));
      DriverEnvironment_Free(tmp);
      return WIFI_ENGINE_FAILURE_INVALID_DATA;
   }
   tmp->rootindex = ADDRTOINDEX(addr, tmp);
   tmp->rootentries = esize;

   wei_free_mibtable();

   mibtable = tmp;

   return WIFI_ENGINE_SUCCESS;
}
Example #6
0
static t_sfilter *sfilter_convert( PGresult *res, int tup )
{
	t_sfilter *h;
	int f;

	if( ! res )
		return NULL;

	if( tup >= PQntuples(res) )
		return NULL;

	if( NULL == (h = malloc(sizeof(t_sfilter))))
		return NULL;
	memset( h, 0, sizeof(t_sfilter));

	GETFIELD(f,"id", clean1 );
	h->id = pgint(res, tup, f);

	GETFIELD(f,"name", clean1 );
	if( NULL == ( h->name = pgstring(res, tup, f )))
		goto clean1;

	GETFIELD(f,"filter", clean1 );
	if( NULL == ( h->filter = pgstring(res, tup, f )))
		goto clean2;

	return h;

clean2:
	free(h->name);

clean1:
	free(h);

	return NULL;
}
Example #7
0
static void xscom_handle_ind_error(uint64_t data, uint32_t gcid,
				   uint64_t pcb_addr, bool is_write)
{
	unsigned int stat = GETFIELD(XSCOM_DATA_IND_ERR, data);
	bool timeout = !(data & XSCOM_DATA_IND_COMPLETE);

	/* XXX: Create error log entry ? */
	if (timeout)
		log_simple_error(&e_info(OPAL_RC_XSCOM_INDIRECT_RW),
			"XSCOM: indirect %s timeout, gcid=0x%x pcb_addr=0x%llx"
			" stat=0x%x\n",
			is_write ? "write" : "read", gcid, pcb_addr, stat);
	else
		log_simple_error(&e_info(OPAL_RC_XSCOM_INDIRECT_RW),
			"XSCOM: indirect %s error, gcid=0x%x pcb_addr=0x%llx"
			" stat=0x%x\n",
			is_write ? "write" : "read", gcid, pcb_addr, stat);
}
Example #8
0
static int64_t xscom_handle_error(uint64_t hmer, uint32_t gcid, uint32_t pcb_addr,
			      bool is_write, int64_t retries,
			      int64_t *xscom_clear_retries)
{
	unsigned int stat = GETFIELD(SPR_HMER_XSCOM_STATUS, hmer);
	int64_t rc = OPAL_HARDWARE;

	/* XXX Figure out error codes from doc and error
	 * recovery procedures
	 */
	switch(stat) {
	case 1:
		/*
		 * XSCOM engine is blocked, need to retry. Reset XSCOM
		 * engine after crossing retry threshold before
		 * retrying again.
		 */
		if (retries && !(retries  % XSCOM_BUSY_RESET_THRESHOLD)) {
			prlog(PR_NOTICE, "XSCOM: Busy even after %d retries, "
				"resetting XSCOM now. Total retries  = %lld\n",
				XSCOM_BUSY_RESET_THRESHOLD, retries);
			xscom_reset(gcid, true);

		}

		/* Log error if we have retried enough and its still busy */
		if (retries == XSCOM_BUSY_MAX_RETRIES)
			log_simple_error(&e_info(OPAL_RC_XSCOM_BUSY),
				"XSCOM: %s-busy error gcid=0x%x pcb_addr=0x%x "
				"stat=0x%x\n", is_write ? "write" : "read",
				gcid, pcb_addr, stat);
		return OPAL_XSCOM_BUSY;

	case 2: /* CPU is asleep, reset XSCOM engine and return */
		xscom_reset(gcid, false);
		return OPAL_XSCOM_CHIPLET_OFF;
	case 3: /* Partial good */
		rc = OPAL_XSCOM_PARTIAL_GOOD;
		break;
	case 4: /* Invalid address / address error */
		rc = OPAL_XSCOM_ADDR_ERROR;
		if (xscom_clear_error(gcid, pcb_addr)) {
			/* return busy if retries still pending. */
			if ((*xscom_clear_retries)--)
				return OPAL_XSCOM_BUSY;

			prlog(PR_DEBUG, "XSCOM: error recovery failed for "
				"gcid=0x%x pcb_addr=0x%x\n", gcid, pcb_addr);

		}
		break;
	case 5: /* Clock error */
		rc = OPAL_XSCOM_CLOCK_ERROR;
		break;
	case 6: /* Parity error  */
		rc = OPAL_XSCOM_PARITY_ERROR;
		break;
	case 7: /* Time out */
		rc = OPAL_XSCOM_TIMEOUT;
		break;
	}

	/* XXX: Create error log entry ? */
	log_simple_error(&e_info(OPAL_RC_XSCOM_RW),
		"XSCOM: %s error gcid=0x%x pcb_addr=0x%x stat=0x%x\n",
		is_write ? "write" : "read", gcid, pcb_addr, stat);

	/* We need to reset the XSCOM or we'll hang on the next access */
	xscom_reset(gcid, false);

	/* Non recovered ... just fail */
	return rc;
}
Example #9
0
int
Pass1(FILE *fd, unsigned applied)
{
    u_char *p,*q;
    MD5_CTX ctx;
    int i,j,sep,cnt;
    u_char *md5=0,*name=0,*trash=0;
    struct CTM_Syntax *sp;
    int slashwarn=0, match=0, total_matches=0;
    unsigned current;
    char md5_1[33];

    if(Verbose>3)
	printf("Pass1 -- Checking integrity of incoming CTM-patch\n");
    MD5Init (&ctx);

    GETFIELD(p,' ');				/* CTM_BEGIN */
    if(strcmp(p,"CTM_BEGIN")) {
	Fatal("Probably not a CTM-patch at all.");
	if(Verbose>3)
	    fprintf(stderr,"Expected \"CTM_BEGIN\" got \"%s\".\n",p);
	return 1;
    }

    GETFIELDCOPY(Version,' ');				/* <Version> */
    if(strcmp(Version,VERSION)) {
	Fatal("CTM-patch is wrong version.");
	if(Verbose>3)
	    fprintf(stderr,"Expected \"%s\" got \"%s\".\n",VERSION,p);
	return 1;
    }

    GETFIELDCOPY(Name,' ');				/* <Name> */
    GETFIELDCOPY(Nbr,' ');				/* <Nbr> */
    GETFIELDCOPY(TimeStamp,' ');			/* <TimeStamp> */
    GETFIELDCOPY(Prefix,'\n');				/* <Prefix> */

    sscanf(Nbr, "%u", &current);
    if (FilterList || ListIt)
	current = 0;	/* ignore if -l or if filters are present */
    if(current && current <= applied) {
	if(Verbose > 0)
	    fprintf(stderr,"Delta number %u is already applied; ignoring.\n",
		    current);
	return Exit_Version;
    }

    for(;;) {
	Delete(md5);
	Delete(name);
	Delete(trash);
	cnt = -1;
	/* if a filter list is defined we assume that all pathnames require
	   an action opposite to that requested by the first filter in the
	   list.
	   If no filter is defined, all pathnames are assumed to match. */
	match = (FilterList ? !(FilterList->Action) : CTM_FILTER_ENABLE);

	GETFIELD(p,' ');			/* CTM_something */

	if (p[0] != 'C' || p[1] != 'T' || p[2] != 'M') {
	    Fatal("Expected CTM keyword.");
	    fprintf(stderr,"Got [%s]\n",p);
	    return 1;
	}

	if(!strcmp(p+3,"_END"))
	    break;

	for(sp=Syntax;sp->Key;sp++)
	    if(!strcmp(p+3,sp->Key))
		goto found;
	Fatal("Expected CTM keyword.");
	fprintf(stderr,"Got [%s]\n",p);
	return 1;
    found:
	if(Verbose > 5)
	    fprintf(stderr,"%s ",sp->Key);
	for(i=0;(j = sp->List[i]);i++) {
	    if (sp->List[i+1] && (sp->List[i+1] & CTM_F_MASK) != CTM_F_Bytes)
		sep = ' ';
	    else
		sep = '\n';

	    if(Verbose > 5)
	        fprintf(stderr," %x(%d)",sp->List[i],sep);

	    switch (j & CTM_F_MASK) {
		case CTM_F_Name: /* XXX check for garbage and .. */
		    GETFIELDCOPY(name,sep);
		    j = strlen(name);
		    if(name[j-1] == '/' && !slashwarn)  {
			fprintf(stderr,"Warning: contains trailing slash\n");
			slashwarn++;
		    }
		    if (name[0] == '/') {
			Fatal("Absolute paths are illegal.");
			Delete(name);
			return Exit_Mess;
		    }
		    q = name;
		    for (;;) {
			if (q[0] == '.' && q[1] == '.')
			    if (q[2] == '/' || q[2] == '\0') {
				Fatal("Paths containing '..' are illegal.");
				Delete(name);
				return Exit_Mess;
			    }
			if ((q = strchr(q, '/')) == NULL)
			    break;
			q++;
		    }

		    /* if we have been asked to `keep' files then skip
		       removes; i.e. we don't match these entries at
		       all. */
		    if (KeepIt &&
			(!strcmp(sp->Key,"DR") || !strcmp(sp->Key,"FR"))) {
			match = CTM_FILTER_DISABLE;
			break;
		    }

		    /* If filter expression have been defined, match the
		       path name against the expression list.  */
		    
		    if (FilterList) {
			struct CTM_Filter *filter;

			for (filter = FilterList; filter; 
			     filter = filter->Next) {
				if (0 == regexec(&filter->CompiledRegex, name,
					0, 0, 0))
					/* if the name matches, adopt the 
					   action */
					match = filter->Action;
			}
		    }

		    /* Add up the total number of matches */
		    total_matches += match;
		    break;
		case CTM_F_Uid:
		    GETFIELD(p,sep);
		    while(*p) {
			if(!isdigit(*p)) {
			    Fatal("Non-digit in uid.");
			    return 32;
			}
			p++;
		    }
		    break;
		case CTM_F_Gid:
		    GETFIELD(p,sep);
		    while(*p) {
			if(!isdigit(*p)) {
			    Fatal("Non-digit in gid.");
			    return 32;
			}
			p++;
		    }
		    break;
		case CTM_F_Mode:
		    GETFIELD(p,sep);
		    while(*p) {
			if(!isdigit(*p)) {
			    Fatal("Non-digit in mode.");
			    return 32;
			}
			p++;
		    }
		    break;
		case CTM_F_MD5:
		    if(j & CTM_Q_MD5_Chunk) {
			GETFIELDCOPY(md5,sep);  /* XXX check for garbage */
		    } else if(j & CTM_Q_MD5_Before) {
			GETFIELD(p,sep);  /* XXX check for garbage */
		    } else if(j & CTM_Q_MD5_After) {
			GETFIELD(p,sep);  /* XXX check for garbage */
		    } else {
			fprintf(stderr,"List = 0x%x\n",j);
			Fatal("Unqualified MD5.");
			return 32;
		    }
		    break;
		case CTM_F_Count:
		    GETBYTECNT(cnt,sep);
		    break;
		case CTM_F_Bytes:
		    if(cnt < 0) WRONG
		    GETDATA(trash,cnt);
		    p = MD5Data(trash,cnt,md5_1);
		    if(md5 && strcmp(md5,p)) {
			Fatal("Internal MD5 failed.");
			return Exit_Garbage;
		default:
			fprintf(stderr,"List = 0x%x\n",j);
			Fatal("List had garbage.");
			return Exit_Garbage;
		    }
	    }
	}
	if(Verbose > 5)
	    putc('\n',stderr);
	if(ListIt && match)
	    printf("> %s %s\n", sp->Key, name);
    }

    Delete(md5);
    Delete(name);
    Delete(trash);

    q = MD5End (&ctx,md5_1);
    if(Verbose > 2)
	printf("Expecting Global MD5 <%s>\n",q);
    GETFIELD(p,'\n');			/* <MD5> */
    if(Verbose > 2)
	printf("Reference Global MD5 <%s>\n",p);
    if(strcmp(q,p)) {
	Fatal("MD5 sum doesn't match.");
	fprintf(stderr,"\tI have:<%s>\n",q);
	fprintf(stderr,"\tShould have been:<%s>\n",p);
	return Exit_Garbage;
    }
    if (-1 != getc(fd)) {
	if(!Force) {
	    Fatal("Trailing junk in CTM-file.  Can Force with -F.");
	    return 16;
	}
    }
    if ((Verbose > 1) && (0 == total_matches))
	printf("No matches in \"%s\"\n", FileName);
    return (total_matches ? Exit_OK : Exit_NoMatch);
}
int
wei_get_mib_object(const mib_id_t *mib_id, 
                   mib_object_entry_t *entry)
{
   mib_object_reference_type_t type;
   mib_object_size_description_t sdesc;
   uint32_t addr;
   uint32_t size;
   unsigned int mib_id_index = 0;
   unsigned int component;
   unsigned int final_component;
   unsigned int index;
   unsigned int nentries;
   mib_object_entry_t *oe;

   if(mibtable == NULL || mib_id == NULL || entry == NULL)
   {
      return WIFI_ENGINE_FAILURE;
   }

   index = mibtable->rootindex;
   nentries = mibtable->rootentries;
   component = (unsigned int)(mib_id->octets[0]) - 1;

   while(1) {
      final_component = (mib_id_index >= MIB_IDENTIFIER_MAX_LENGTH - 1)
         || (mib_id->octets[mib_id_index + 1] == 0);

      if(component >= nentries) {
         DE_TRACE_STATIC(TR_MIB, "component too large\n");
         return WIFI_ENGINE_FAILURE;
      }
      index += component;
      if(index >= mibtable->size / MIBENTRYSIZE) {
         DE_TRACE_STATIC(TR_MIB, "bad address\n");
         return WIFI_ENGINE_FAILURE;
      }
      oe = &mibtable->table[index];
      type = (mib_object_reference_type_t)GETFIELD(oe->storage_description, REFERENCE_TYPE);
      sdesc = (mib_object_size_description_t)GETFIELD(oe->storage_description, OBJECT_SIZE_DESCRIPTION);
      addr = GETADDR(oe->reference);
      size = GETFIELD(oe->storage_description, OBJECT_SIZE);

      if(type == MIB_OBJECT_REFERENCE_TYPE_MIB_TABLE) {
         if(final_component) {
            DE_TRACE_STATIC(TR_MIB, "non-leaf\n");
            return WIFI_ENGINE_FAILURE;
         }
         if(sdesc != MIB_OBJECT_SIZE_DESCRIPTION_FIXED_SIZE) {
            DE_TRACE_STATIC(TR_MIB, "unexpected size description type\n");
            return WIFI_ENGINE_FAILURE;
         }
         if(!ADDRVALID(addr, mibtable)) {
            DE_TRACE_STATIC(TR_MIB, "bad address\n");
            return WIFI_ENGINE_FAILURE;
         }
         index = ADDRTOINDEX(addr, mibtable);
         nentries = size;
         mib_id_index++;
         component = (unsigned int)(mib_id->octets[mib_id_index]) - 1;
         continue;
      } else if(type == MIB_OBJECT_REFERENCE_TYPE_MIB_SUBTABLE) {
         if(sdesc != MIB_OBJECT_SIZE_DESCRIPTION_FIXED_SIZE) {
            DE_TRACE_STATIC(TR_MIB, "unexpected size description type\n");
            return WIFI_ENGINE_FAILURE;
         }
         if(size != 2) {
            DE_TRACE_INT(TR_MIB, "unexpected subtable size (%u)\n", size);
            return WIFI_ENGINE_FAILURE;
         }
         if(!ADDRVALID(addr, mibtable)) {
            DE_TRACE_STATIC(TR_MIB, "bad address\n");
            return WIFI_ENGINE_FAILURE;
         }
         index = ADDRTOINDEX(addr, mibtable);
         nentries = size;
         if(final_component) {
            component = 0;
         } else {
            component = 1;
         }
         continue;
      } else {
         if(!final_component) {
            DE_TRACE_STATIC(TR_MIB, "leaf with more components\n");
            return WIFI_ENGINE_FAILURE;
         }
         *entry = *oe;
         break;
      }
   }
   return WIFI_ENGINE_SUCCESS;
}
Example #11
0
enum gcerror mmu2d_set_master(struct mmu2dcontext *ctxt)
{
#if MMU_ENABLE
	enum gcerror gcerror;
	struct gcmommumaster *gcmommumaster;
	struct gcmommuinit *gcmommuinit;
	unsigned int size, status, enabled;
	struct mmu2dprivate *mmu = get_mmu();

	if ((ctxt == NULL) || (ctxt->mmu == NULL))
		return GCERR_MMU_CTXT_BAD;

	/* Read the MMU status. */
	status = gc_read_reg(GCREG_MMU_CONTROL_Address);
	enabled = GETFIELD(status, GCREG_MMU_CONTROL, ENABLE);

	/* Is MMU enabled? */
	if (enabled) {
		GCPRINT(NULL, 0, GC_MOD_PREFIX
			"gcx: mmu is already enabled.\n",
			__func__, __LINE__);

		/* Allocate command buffer space. */
		gcerror = cmdbuf_alloc(sizeof(struct gcmommumaster),
					(void **) &gcmommumaster, NULL);
		if (gcerror != GCERR_NONE)
			return GCERR_SETGRP(gcerror, GCERR_MMU_MTLB_SET);

		/* Program master table address. */
		gcmommumaster->master_ldst = gcmommumaster_master_ldst;
		gcmommumaster->master = ctxt->physical;
	} else {
		GCPRINT(NULL, 0, GC_MOD_PREFIX
			"gcx: mmu is disabled, enabling.\n",
			__func__, __LINE__);

		/* MMU disabled, force physical mode. */
		cmdbuf_physical(true);

		/* Allocate command buffer space. */
		size = sizeof(struct gcmommuinit) + cmdbuf_flush(NULL);
		gcerror = cmdbuf_alloc(size, (void **) &gcmommuinit, NULL);
		if (gcerror != GCERR_NONE)
			return GCERR_SETGRP(gcerror, GCERR_MMU_INIT);

		/* Program the safe zone and the master table address. */
		gcmommuinit->safe_ldst = gcmommuinit_safe_ldst;
		gcmommuinit->safe = mmu->safezone.physical;
		gcmommuinit->mtlb = ctxt->physical;

		/* Execute the buffer. */
		cmdbuf_flush(gcmommuinit + 1);

		/* Resume normal mode. */
		cmdbuf_physical(false);

		/*
		* Enable MMU. For security reasons, once it is enabled,
		* the only way to disable is to reset the system.
		*/
		gc_write_reg(
			GCREG_MMU_CONTROL_Address,
			SETFIELDVAL(0, GCREG_MMU_CONTROL, ENABLE, ENABLE));
	}

	return GCERR_NONE;
#else
	if ((ctxt == NULL) || (ctxt->mmu == NULL))
		return GCERR_MMU_CTXT_BAD;

	return GCERR_NONE;
#endif
}
Example #12
0
do_one_cycle()
{
  instruction = ucode[mpc_bank[cur_task]][instruction_address];
  mi_rsel = GETFIELD(instruction, MI_RSEL);
  mi_aluf = GETFIELD(instruction, MI_ALUF);
  mi_bs = GETFIELD(instruction, MI_BS);
  mi_f1 = GETFIELD(instruction, MI_F1);
  mi_f2 = GETFIELD(instruction, MI_F2);
  mi_t = GETFIELD(instruction, MI_T);
  mi_l = GETFIELD(instruction, MI_L);
  mi_next = GETFIELD(instruction, MI_NEXT);

  /* check that F1 != 7 and F2 != 7 */
  switch(mi_bs) {
  case MI_BS_READR: {
    bus = r_reg[mi_rsel];
    break;
  }
  case MI_BS_LOADR: {
    bus = 0;
    break;
  }
  case MI_BS_NONE: {
    break;
  }
  case MI_BS_TASK_1: {
    break;
  }
  case MI_BS_TASK_2: {
    
    break;
  }
  case MI_BS_GETMD: {
    bus = get_md(); /* a function to handle side effects */
    break;
  }
  case MI_BS_MOUSE: {
    bus = 0xfff0 | (mouse_reg & 0xf);
    break;
  }
  case MI_BS_DISP: {
    bus = 
    break;
  }
  }
  t_from_alu = 0;
  switch(mi_aluf) {
  case MI_ALUF_BUS: {
    alu_out = bus;
    t_from_alu = 1;
    break;
  }
 case MI_ALUF_T: {
   alu_out = t_reg;
   break;
 }
 case MI_ALUF_BUS_OR_T: {
   alu_out = bus | t_reg;
   t_from_alu = 1;
   break;
 }
 case MI_ALUF_BUS_AND_T: {
   alu_out = bus & t_reg;
   break;
 }
 case MI_ALUF_BUS_XOR_T: {
   alu_out = bus ^ t_reg;
   break;
 }
 case MI_ALUF_BUS_ADD_1: {
   alu_out = bus + 1;
   t_from_alu = 1;
   break;
 }
 case MI_ALUF_BUS_SUB_1: {
   alu_out = bus - 1;
   t_from_alu = 1;
   break;
 }
 case MI_ALUF_BUS_ADD_T: {
   alu_out = bus + t_reg;
   break;
 }
 case MI_ALUF_BUS_SUB_T: {
   alu_out = bus - t_reg;
   break;
 }
 case MI_ALUF_BUS_SUB_T_SUB_1: {
   alu_out = bus - t_reg - 1;
   break;
 }
 case MI_ALUF_BUS_ADD_T_ADD_1: {
   alu_out = bus + t_reg + 1;
   t_from_alu = 1;
   break;
 }
 case MI_ALUF_BUS_ADD_SKIP: {
   alu_out = bus + skip;
   t_from_alu = 1;
   break;
 }
 case MI_ALUF_BUS_DOT_T: {
   alu_out = bus & t_reg;
   t_from_alu = 1;
   break;
 }
 case MI_ALUF_BUS_AND_NOT_T: {
   alu_out = bus & (~t_reg);
   break;
 }
 case MI_ALUF_BUS_UNDEF_1: {
   assert(0);
   break;
 }
 case MI_ALUF_BUS_UNDEF_2: {
   assert(0);
   break;
 }
  }
  if (mi_loadt) {
    if (t_from_alu) {
      t_reg = alu_out;
    } else {
      t_reg = bus;
    }
  }

  lmmar_cycle();
  wite_rs_cycle();
}
Example #13
0
int
PassB(FILE *fd)
{
    u_char *p,*q;
    MD5_CTX ctx;
    int i,j,sep,cnt;
    u_char *md5=0,*md5before=0,*trash=0,*name=0,*uid=0,*gid=0,*mode=0;
    struct CTM_Syntax *sp;
    FILE *b = 0;	/* backup command */
    u_char buf[BUFSIZ];
    char md5_1[33];
    int ret = 0;
    int match = 0;
    struct CTM_Filter *filter = NULL;

    if(Verbose>3)
	printf("PassB -- Backing up files which would be changed.\n");

    MD5Init (&ctx);
    snprintf(buf, sizeof(buf), fmtcheck(TarCmd, TARCMD), BackupFile);
    b=popen(buf, "w");
    if(!b) { warn("%s", buf); return Exit_Garbage; }

    GETFIELD(p,' '); if(strcmp("CTM_BEGIN",p)) WRONG
    GETFIELD(p,' '); if(strcmp(Version,p)) WRONG
    GETFIELD(p,' '); if(strcmp(Name,p)) WRONG
    GETFIELD(p,' '); if(strcmp(Nbr,p)) WRONG
    GETFIELD(p,' '); if(strcmp(TimeStamp,p)) WRONG
    GETFIELD(p,'\n'); if(strcmp(Prefix,p)) WRONG

    for(;;) {
	Delete(md5);
	Delete(uid);
	Delete(gid);
	Delete(mode);
	Delete(md5before);
	Delete(trash);
	Delete(name);
	cnt = -1;

	GETFIELD(p,' ');

	if (p[0] != 'C' || p[1] != 'T' || p[2] != 'M') WRONG

	if(!strcmp(p+3,"_END"))
	    break;

	for(sp=Syntax;sp->Key;sp++)
	    if(!strcmp(p+3,sp->Key))
		goto found;
	WRONG
    found:
	for(i=0;(j = sp->List[i]);i++) {
	    if (sp->List[i+1] && (sp->List[i+1] & CTM_F_MASK) != CTM_F_Bytes)
		sep = ' ';
	    else
		sep = '\n';

	    switch (j & CTM_F_MASK) {
		case CTM_F_Name: GETNAMECOPY(name,sep,j, Verbose); break;
		case CTM_F_Uid:  GETFIELDCOPY(uid,sep); break;
		case CTM_F_Gid:  GETFIELDCOPY(gid,sep); break;
		case CTM_F_Mode: GETFIELDCOPY(mode,sep); break;
		case CTM_F_MD5:
		    if(j & CTM_Q_MD5_Before)
			GETFIELDCOPY(md5before,sep);
		    else
			GETFIELDCOPY(md5,sep);
		    break;
		case CTM_F_Count: GETBYTECNT(cnt,sep); break;
		case CTM_F_Bytes: GETDATA(trash,cnt); break;
		default: WRONG
		}
	    }
	/* XXX This should go away.  Disallow trailing '/' */
	j = strlen(name)-1;
	if(name[j] == '/') name[j] = '\0';

	if (KeepIt && 
	    (!strcmp(sp->Key,"DR") || !strcmp(sp->Key,"FR")))
	    continue;
		
	/* match the name against the elements of the filter list.  The
	   action associated with the last matched filter determines whether
	   this file should be ignored or backed up. */
	match = (FilterList ? !(FilterList->Action) : CTM_FILTER_ENABLE);
	for (filter = FilterList; filter; filter = filter->Next) {
	    if (0 == regexec(&filter->CompiledRegex, name, 0, 0, 0))
		match = filter->Action;
	}

	if (CTM_FILTER_DISABLE == match)
		continue;

	if (!strcmp(sp->Key,"FS") || !strcmp(sp->Key,"FN") ||
	    !strcmp(sp->Key,"AS") || !strcmp(sp->Key,"DR") || 
	    !strcmp(sp->Key,"FR")) {
	    /* send name to the archiver for a backup */
	    cnt = strlen(name);
	    if (cnt != fwrite(name,1,cnt,b) || EOF == fputc('\n',b)) {
		warn("%s", name);
		pclose(b);
		WRONG;
	    }
	}
    }

    ret = pclose(b);

    Delete(md5);
    Delete(uid);
    Delete(gid);
    Delete(mode);
    Delete(md5before);
    Delete(trash);
    Delete(name);

    q = MD5End (&ctx,md5_1);
    GETFIELD(p,'\n');			/* <MD5> */
    if(strcmp(q,p)) WRONG
    if (-1 != getc(fd)) WRONG
    return ret;
}