示例#1
0
文件: iconlib.c 项目: erikarn/amiwm
static LONG unpack_rle(unsigned char *src, LONG srclen, char *dst, LONG dstlen,
		       int bpp, int comp)
{
  char *dst0 = dst;
  unsigned char *srcn = src+srclen;
  int bits=0, data=0;
  if(!comp) {
    if(srclen>dstlen)
      srclen = dstlen;
    memcpy(dst, src, srclen);
    return srclen;
  }
  while(dstlen>0) {
    int code;
    GETBITS(code, 8);
    if(code&0x80) {
      char rpt;
      GETBITS(rpt, bpp);
      code -= 0x100;
      if((dstlen-=(1-code))<0)
	break;
      do { *dst++ = rpt; } while(code++);
    } else {
      if((dstlen-=(code+1))<0)
	break;
      do GETBITS(*dst++, bpp); while(code--);
    }
  }
  if(src != srcn)
    fprintf(stderr, "Warning:  Left %d bytes unused.\n", srcn-src);
  return dst-dst0;
}
示例#2
0
INLINE USHORT decode_p(void){
	USHORT i, j, m;

	j = pt_table[GETBITS(8)];
	if (j < np) {
		DROPBITS(pt_len[j]);
	} else {
		DROPBITS(8);
		i = GETBITS(16);
		m = 0x8000;
		do {
			if (i & m) j = right[j];
			else             j = left [j];
			m >>= 1;
		} while (j >= np);
		DROPBITS(pt_len[j] - 8);
	}

	if (j != np-1) {
		if (j > 0) {
			j = (USHORT)(GETBITS(i=(USHORT)(j-1)) | (1U << (j-1)));
			DROPBITS(i);
		}
		lastlen=j;
	}

	return lastlen;

}
示例#3
0
void DXFBdr::load(CFRecord& record)
{
	_UINT32 flags;
	record >> flags;
	
	dgLeft		= static_cast<unsigned char>(GETBITS(flags, 0, 3));
	dgRight		= static_cast<unsigned char>(GETBITS(flags, 4, 7));
	dgTop		= static_cast<unsigned char>(GETBITS(flags, 8, 11));
	dgBottom	= static_cast<unsigned char>(GETBITS(flags, 12, 15));
	
	icvLeft		= static_cast<unsigned char>(GETBITS(flags, 16, 22));
	icvRight	= static_cast<unsigned char>(GETBITS(flags, 23, 29));
	
	bitDiagDown = GETBIT(flags, 30);
	bitDiagUp	= GETBIT(flags, 31);

	record >> flags;
	
	icvTop		= static_cast<unsigned char>(GETBITS(flags, 0, 6));
	icvBottom	= static_cast<unsigned char>(GETBITS(flags, 7, 13));
	icvDiag		= static_cast<unsigned char>(GETBITS(flags, 14, 20));
	
	dgDiag		= static_cast<unsigned char>(GETBITS(flags, 21, 24));

}
示例#4
0
void AutoFilter::readFields(CFRecord& record)
{
	size_t pos_record = record.getRdPtr();

	if (size == 0xffffffff) size = record.getDataSize() - pos_record;

	if (size > 0)
	{
		bExist = true;
	}

	m_bAutoFilter12 = false;

	unsigned short flags;
	record >> iEntry >> flags;
	
	wJoin		= GETBITS(flags, 0, 1);
	
	fSimple1	= GETBIT(flags, 2);
	fSimple2	= GETBIT(flags, 3);
	fTopN		= GETBIT(flags, 4);
	fTop		= GETBIT(flags, 5); //top(1) or bottom(0)
	fPercent	= GETBIT(flags, 6);
	
	wTopN		= GETBITS(flags, 7, 15);

	unsigned short	_iEntry		= iEntry;
	unsigned char	_wJoin		= wJoin;			
	unsigned short	_wTopN		= wTopN;			
	
	if (fTopN != 1)
	{
		record >> doper1;			
		record >> doper2;
	}
示例#5
0
文件: u_deep.c 项目: agwatic/PUAE
INLINE USHORT DecodePosition(void){
	USHORT i, j, c;

	i = GETBITS(8);  DROPBITS(8);
	c = (USHORT) (d_code[i] << 8);
	j = d_len[i];
	i = (USHORT) (((i << j) | GETBITS(j)) & 0xff);  DROPBITS(j);

	return (USHORT) (c | i) ;
}
void List12TableStyleClientInfo::load(CFRecord& record)
{	
	unsigned short flags;
	record >> flags;

	fFirstColumn = static_cast<unsigned char>(GETBITS(flags, 0, 1));
	fLastColumn = static_cast<unsigned char>(GETBITS(flags, 1, 2));
	fRowStripes = static_cast<unsigned char>(GETBITS(flags, 3, 4));
	fColumnStripes = static_cast<unsigned char>(GETBITS(flags, 5, 6));
	fDefaultStyle  = static_cast<unsigned char>(GETBITS(flags, 9, 10));

	record >> stListStyleName;
}
示例#7
0
void BookExt::readFields(CFRecord& record)
{
	FrtHeader header(rt_BookExt);
	record >> header;

	record >> cb;
	_UINT32 flags;
	
	if (record.loadAnyData(flags))
	{	
		fDontAutoRecover		= GETBIT(flags, 0);
		fHidePivotList			= GETBIT(flags, 1);
		fFilterPrivacy			= GETBIT(flags, 2);
		fEmbedFactoids			= GETBIT(flags, 3);
		mdFactoidDisplay		= GETBITS(flags, 4, 5);
		fSavedDuringRecovery	= GETBIT(flags, 6);
		fCreatedViaMinimalSave	= GETBIT(flags, 7);
		fOpenedViaDataRecovery	= GETBIT(flags, 8);
		fOpenedViaSafeLoad		= GETBIT(flags, 9);
	}
	else return;


	if(cb > 20)
	{
		record >> grbit1;
	}
示例#8
0
void PtgMemNoMemN::load(CFRecord& record)
{
	unsigned char rec_type;
	record >> rec_type;
	type1 = GETBITS(rec_type, 5, 6);
	record >> cce;
}
示例#9
0
void BookBool::readFields(CFRecord& record)
{
	unsigned short flags;
	record >> flags;
	
	fNoSaveSup			= GETBIT(flags, 0);
	fHasEnvelope		= GETBIT(flags, 2);
	fEnvelopeVisible	= GETBIT(flags, 3);
	fEnvelopeInitDone	= GETBIT(flags, 4);
	
	unsigned char grUpdateLinks_num = GETBITS(flags, 5, 6);
	switch(grUpdateLinks_num)
	{
		case 0:
			grUpdateLinks = std::wstring (L"userSet");
			break;
		case 1:
			grUpdateLinks = std::wstring (L"never");
			break;
		case 2:
			grUpdateLinks = std::wstring (L"always");
			break;
		default:
			throw;// EXCEPT::RT::WrongBiffRecord("Unsupported value of grUpdateLinks.", record.getTypeString());

	}
	
	fHideBorderUnselLists = GETBIT(flags, 8);
}
示例#10
0
void SortData::readFields(CFRecord& record)
{
	unsigned short flags;

	record >> frtHeader >> flags;

	fCol			= GETBIT(flags, 0);
	fCaseSensitive	= GETBIT(flags, 1);
	fAltMethod		= GETBIT(flags, 2);
	sfp				= GETBITS(flags, 3, 5);
	
	RFX rfx_orig;
	record >> rfx_orig >> cconditions;
	rfx = static_cast<std::wstring >(rfx_orig);
	
	record >> idParent;
	
	std::list<CFRecordPtr>& recs = continue_records[rt_ContinueFrt12];
	while(!recs.empty())
	{
		record.appendRawData(recs.front()->getData() + 12, recs.front()->getDataSize() - 12);
		recs.pop_front();
	}
	
	for(unsigned int i = 0; i < cconditions; ++i)
	{
		SortCond12Ptr sort_cond(new SortCond12);
		record >> *sort_cond;
		sortCond12Array.push_back(sort_cond);
	}

}
UWORD32 ih264d_get_bits_h264(dec_bit_stream_t *ps_bitstrm, UWORD32 u4_num_bits)
{
    UWORD32 u4_code = 0;
    if(u4_num_bits)
        GETBITS(u4_code, ps_bitstrm->u4_ofst, ps_bitstrm->pu4_buffer, u4_num_bits);
    return (u4_code);
}
示例#12
0
INLINE USHORT decode_c(void){
	USHORT i, j, m;

	j = c_table[GETBITS(12)];
	if (j < N1) {
		DROPBITS(c_len[j]);
	} else {
		DROPBITS(12);
		i = GETBITS(16);
		m = 0x8000;
		do {
			if (i & m) j = right[j];
			else              j = left [j];
			m >>= 1;
		} while (j >= N1);
		DROPBITS(c_len[j] - 12);
	}
	return j;
}
示例#13
0
static USHORT read_tree_p(void){
	USHORT i,n;

	n = GETBITS(5);
	DROPBITS(5);
	if (n>0){
		for (i=0; i<n; i++) {
			pt_len[i] = (UCHAR)GETBITS(4);
			DROPBITS(4);
		}
		for (i=n; i<np; i++) pt_len[i] = 0;
		if (make_table(np,pt_len,8,pt_table)) return 1;
	} else {
		n = GETBITS(5);
		DROPBITS(5);
		for (i=0; i<np; i++) pt_len[i] = 0;
		for (i=0; i<256; i++) pt_table[i] = n;
	}
	return 0;
}
示例#14
0
static USHORT read_tree_c(void){
	USHORT i,n;

	n = GETBITS(9);
	DROPBITS(9);
	if (n>0){
		for (i=0; i<n; i++) {
			c_len[i] = (UCHAR)GETBITS(5);
			DROPBITS(5);
		}
		for (i=n; i<510; i++) c_len[i] = 0;
		if (make_table(510,c_len,12,c_table)) return 1;
	} else {
		n = GETBITS(9);
		DROPBITS(9);
		for (i=0; i<510; i++) c_len[i] = 0;
		for (i=0; i<4096; i++) c_table[i] = n;
	}
	return 0;
}
示例#15
0
文件: melcode.c 项目: burlen/PVGdcm
/* argument is the number of pixels left to  end-of-line (bound on run length) */
int process_run_dec(int lineleft, int color)  
{
  int runlen = 0;
    
  do {
    register int temp, hits;
    temp = zeroLUT[(byte)(~(reg >> 24))];   /* number of leading ones in the
                 input stream, up to 8 */
    for ( hits = 1; hits<=temp; hits++ ) 
    {
      runlen += melcorder[color];
      if ( runlen >= lineleft )
      { /* reached end-of-line */
        if ( runlen==lineleft && melcstate[color] < MELCSTATES ) 
        {
          melclen[color] = J[++melcstate[color]];
          melcorder[color] = (1L<<melclen[color]);
        }
        FILLBUFFER(hits); /* actual # of 1's consumed */
        return lineleft; 
      }
      if ( melcstate[color] < MELCSTATES ) 
      {
        melclen[color] = J[++melcstate[color]];
        melcorder[color] = (1L<<melclen[color]);
      }
    }  
    if (temp != 8) 
    {
      FILLBUFFER(temp + 1);  /* consume the leading
              0 of the remainder encoding */
      break;
        }
        FILLBUFFER(8);
  } while ( 1 );

  /* read the length of the remainder */
  if ( melclen[color] ) 
  {
    register int temp;
    GETBITS(temp, melclen[color]);  /*** GETBITS is a macro, not a function */
    runlen += temp;
  }
  limit_reduce = melclen[color]+1;

  /* adjust melcoder parameters */
  if ( melcstate[color] ) 
  {
    melclen[color] = J[--melcstate[color]];
    melcorder[color] = (1L<<melclen[color]);
  }

  return runlen;
}
示例#16
0
void LbsDropData::load(CFRecord& record)
{
	unsigned short flags;
	record >> flags >> cLine >> dxMin >> str;
	wStyle = GETBITS(flags, 0, 1);
	fFiltered = GETBIT(flags, 3);

	if(0 != (str.getStructSize() & 1))
	{
		record.skipNunBytes(1); // padding
	}

}
示例#17
0
void Feat11WSSListInfo::load(CFRecord& record)
{
	_UINT32	flags1, reserved;
	_UINT16 unused2;
	unsigned char flags2;
	
	record >> LCID >> cDec >> flags1 >> flags2 >> bDefaultType >> unused2;

	switch(lfdt)
	{
	case 0x00000002://Number
	case 0x00000006://Currency
		rgbDV = BiffStructurePtr(new Xnum); break;
	case 0x00000003://Boolean
		rgbDV = BiffStructurePtr(new BIFF_DWORD); break;
	case 0x00000004:
		rgbDV = BiffStructurePtr(new DateAsNum); break;
	case 0x00000005://Invalid
	case 0x00000007://Invalid
	case 0x00000009://Invalid
	case 0x0000000a://Invalid
		break;
	case 0x00000001://Short Text
	case 0x00000008://Choice
	case 0x0000000b://Multi-choice
		rgbDV = BiffStructurePtr(new XLUnicodeString); break;
	}
	if (rgbDV)
		rgbDV->load(record);

	record >> strFormula;
	record >> reserved;


	fPercent		= GETBIT(flags1, 0);
	fDecSet			= GETBIT(flags1, 1);
	fDateOnly		= GETBIT(flags1, 2);
	fReadingOrder	= GETBITS(flags1, 3, 4);
	fRichText		= GETBIT(flags1, 5);
	fUnkRTFormatting= GETBIT(flags1, 6);
	fAlertUnkRTFormatting = GETBIT(flags1, 7);

	fReadOnly		= GETBIT(flags2, 0);
	fRequired		= GETBIT(flags2, 1);
	fMinSet			= GETBIT(flags2, 2);
	fMaxSet			= GETBIT(flags2, 3);
	fDefaultSet		= GETBIT(flags2, 4);
	fDefaultDateToday = GETBIT(flags2, 5);
	fLoadFormula	= GETBIT(flags2, 6);
	fAllowFillIn	= GETBIT(flags2, 6);
}
示例#18
0
void Text::readFields(CFRecord& record)
{
	unsigned short flags1;
	unsigned short flags2;
	record >> at  >> vat >> wBkgMode >> rgbText >> x >> y >> dx >> dy >> flags1;
	
	if (record.getGlobalWorkbookInfo()->Version < 0x0600)
	{
		int orient = GETBITS(flags1, 8, 10);
		switch(orient)
		{
			case 0:	trot = 0;		break;		// Text orientation: not rotated.
			case 1: trot = 0xff;	break;		// Text orientation: vertically stacked.
			case 2: trot = 90;		break;		// Text orientation: 90 deg counterclockwise.
			case 3: trot = 270;		break;		// Text orientation: 90 deg clockwise.
		}
	}
	else
	{
		record >> icvText >> flags2 >> trot;
		//icv -> from Palette
		dlp				= static_cast<unsigned char>(GETBITS(flags2, 0, 3));
		iReadingOrder	= static_cast<unsigned char>(GETBITS(flags2, 14, 15));
	}
	
	fAutoColor			= GETBIT(flags1, 0);
	fShowKey			= GETBIT(flags1, 1);
	fShowValue			= GETBIT(flags1, 2);
	fAutoText			= GETBIT(flags1, 4);
	fGenerated			= GETBIT(flags1, 5);
	fDeleted			= GETBIT(flags1, 6);
	fAutoMode			= GETBIT(flags1, 7);
	fShowLabelAndPerc	= GETBIT(flags1, 11);
	fShowPercent		= GETBIT(flags1, 12);
	fShowBubbleSizes	= GETBIT(flags1, 13);
	fShowLabel			= GETBIT(flags1, 14);

}
示例#19
0
void Row::readFields(CFRecord& record)
{
	global_info_ = record.getGlobalWorkbookInfo();
	record >> rw >> colMic >> colMac >> miyRw;

	record.skipNunBytes(4); // reserved / unused

	unsigned short flags;
	record >> flags;
	
	iOutLevel	= GETBITS(flags, 0, 2);
	fCollapsed	= GETBIT(flags, 4);
	fDyZero		= GETBIT(flags, 5);
	fUnsynced	= GETBIT(flags, 6);
	fGhostDirty = GETBIT(flags, 7);

	record >> flags;

	ixfe_val	= GETBITS(flags, 0, 11);
	fExAsc		= GETBIT(flags, 12);
	fExDes		= GETBIT(flags, 13);
	fPhonetic	= GETBIT(flags, 14);
}
示例#20
0
USHORT Unpack_QUICK(UCHAR *in, UCHAR *out, USHORT origsize){
	USHORT i, j;
	UCHAR *outend;

	initbitbuf(in);

	outend = out+origsize;
	while (out < outend) {
		if (GETBITS(1)!=0) {
			DROPBITS(1);
			*out++ = text[quick_text_loc++ & QBITMASK] = (UCHAR)GETBITS(8);  DROPBITS(8);
		} else {
			DROPBITS(1);
			j = (USHORT) (GETBITS(2)+2);  DROPBITS(2);
			i = (USHORT) (quick_text_loc - GETBITS(8) - 1);  DROPBITS(8);
			while(j--) {
				*out++ = text[quick_text_loc++ & QBITMASK] = text[i++ & QBITMASK];
			}
		}
	}
	quick_text_loc = (USHORT)((quick_text_loc+5) & QBITMASK);

	return 0;
}
示例#21
0
文件: u_deep.c 项目: agwatic/PUAE
INLINE USHORT DecodeChar(void){
	USHORT c;

	c = son[R];

	/* travel from root to leaf, */
	/* choosing the smaller child node (son[]) if the read bit is 0, */
	/* the bigger (son[]+1} if 1 */
	while (c < T) {
		c = son[c + GETBITS(1)];
		DROPBITS(1);
	}
	c -= T;
	update(c);
	return c;
}
示例#22
0
文件: Qsir.cpp 项目: ShockwaveNN/core
void Qsir::readFields(CFRecord& record)
{
	_UINT32 flags;

	record >> frtRefHeaderU >> cbQsirSaved >> cbQsifSaved >> flags >> iSortCustom >> cQsif >> cpstDeleted >> idFieldNext >> ccolExtraLeft >> ccolExtraRight;
	record >> idList >> rgbTitle;
	
	fPersist			= GETBIT(flags, 0);
	fPersistSort		= GETBIT(flags, 1);
	fPersistAutoFilter	= GETBIT(flags, 2);
	fSorted				= GETBIT(flags, 20);
	fCaseSensSort		= GETBIT(flags, 21);
	fHdrRowSort			= GETBIT(flags, 22);
	fidWrapped			= GETBIT(flags, 23);
	fTitlesOld			= GETBIT(flags, 25);
	wVerBeforeRefreshAlert = GETBITS(flags, 26, 30);
}
示例#23
0
文件: Qsif.cpp 项目: ONLYOFFICE/core
void Qsif::readFields(CFRecord& record)
{
	unsigned short flags1, flags2;
	record >> frtHeaderOld >> flags1 >> flags2 >> idField;

	fUserIns	= GETBIT(flags1, 0);
	fFillDown	= GETBIT(flags1, 1);
	fSortDes	= GETBIT(flags1, 2);
	iSortKey	= GETBITS(flags1, 3, 10);
	fRowNums	= GETBIT(flags1, 11);
	fSorted		= GETBIT(flags1, 13);

	fClipped	= GETBIT(flags2, 0);

	if (record.getRdPtr() >= record.getDataSize())
		return;

	record >> idList >> rgbTitle;
}
示例#24
0
文件: ARJDEP.C 项目: gibs75/demOS
void GET_THEM(void)
{
    p.d0.l = 1;												  // MOVEQ   #1,D0           ; minimum fillbits
    p.d5.l = 0;												  // MOVEQ   #0,D5           ; value
LOOP:
    p.carry = (p.d1.l & 0x80000000UL) != 0;
    p.d1.l += p.d1.l;										  // ADD.L   D1,D1           ; shift bit outside
	if ( p.carry )										      // BCC.S   EINDE           ; if '1' end decode
	{
  	    p.d5.w += p.d5.w;
	    p.d5.w ++;  										  // ADDX.W  D5,D5           ; value *2+1
                
	    p.d0.w ++;											  // ADDQ.W  #1,D0           ; extra fill
        p.d2.w ++;            								  // ADDQ.W  #1,D2           ; extra get
	
	    if ( p.a3.w != p.d0.w )								  // CMP.W   A3,D0           ; max bits
		    goto LOOP;										  // BNE.S   LOOP            ; nog mal
        p.d0.w --;											  // SUBQ.W  #1,D0           ; 1 bit less to trash
   }                                                          // EINDE:

    FILLBITS();												  // BSR.S   FILLBITS        ; trash bits
    p.d0.w = p.d2.w;                                          // MOVE.W  D2,D0           ; bits to get
	GETBITS();
}
示例#25
0
文件: asmgen.c 项目: tparys/caspr
int asmgen_parse_value(struct ScanData *scanner,
		       struct SymTab **curSyms,
		       unsigned int *pResult) {
  struct Token curToken;
  unsigned int lval, rval;
  
  /* scan next token or expression */
  switch (get_token(&curToken, scanner)) {
    
  case TOK_INT:
    /* integer value, just pass it back */
    DEBUG(1) printf("Got an integer - %d\n", curToken.value);
    lval = curToken.value;
    if (curToken.limHigh - curToken.limLow < 8*sizeof(lval) - 1) {
      /* if token is specified with a bitslice, use only those bits */
      lval = GETBITS(curToken.limLow, curToken.limHigh, lval);
    }
    *pResult = lval;
    return 0;
    break;
    
  case TOK_IDENT:
    /* identifier, locate it in the symbol table */
    DEBUG(1) printf("Got a symbol lookup - '%s'\n", curToken.token);
    if (symtab_lookup(curSyms, curToken.token, NULL, (int*)&lval) == 0) {
      /* symbol table lookup success */
      if (curToken.limHigh - curToken.limLow < 8*sizeof(lval) - 1) {
	/* if token is specified with a bitslice, use only those bits */
	lval = GETBITS(curToken.limLow, curToken.limHigh, lval);
      }
      *pResult = lval;
      return 0;
    }
    printf("ERROR - Symbol '%s' Not Found\n", curToken.token);
    break;
    
  case TOK_LPAREN:
    /* left parentheses, beginning of an arithmetic expression */
    
    /* start by evaluating first term (may be another expression */
    if (asmgen_parse_value(scanner, curSyms, &lval) != 0) {
      /* error parsing sub-expression */
      printf("ERROR - Cannot Parse Arithmetic Expression\n");
      return -1;
    }
    
    /* inner loop to evalate left-to-right arithmetic expressions */
    while (1) {
      /* get next token */
      switch (get_token(&curToken, scanner)) {
	
      case TOK_RPAREN:
	/* close parentheses, end of sub-expression */
	*pResult = lval;
	return 0;
	break;
	
      case TOK_ARITHOP:
	/* arithmetic operation (+/-), get right hand value */
	if (asmgen_parse_value(scanner, curSyms, &rval) != 0) {
	  /* error parsing sub-expression */
	  printf("ERROR - Cannot Parse Arithmetic Expression\n");
	  return -1;
	}
	
	/* handle arithmetic operation */
	switch (curToken.token[0]) {
	case '+':
	  lval += rval;
	  break;
	case '-':
	  lval -= rval;
	  break;
	default:
	  /* unhandled */
	  printf("ERROR - Unknown Arithmetic operation '%s'\n", curToken.token);
	  return -1;
	  break;
	}
	break;
	
      default:
	printf("ERROR - Unexpected token '%s' while parsing subexpression\n",
	       curToken.token);
	return -1;
	break;
      }
    }
    break;
    
  default:
    /* unknown token */
    printf("Unhandled token \'%s\'\n", curToken.token);
    break;
  }
  return -1;
}
static int dec_rec2(struct in *in, struct dec_hufftbl *hu, int *runp, int c, int i)
{
	LEBI_DCL;

	LEBI_GET(in);
	if (i) 
	{
		UNGETBITS(in, i & 127);
		*runp = i >> 8 & 15;
		i >>= 16;
	}
	else
	{
		for (i = DECBITS;
		(c = ((c << 1) | GETBITS(in, 1))) >= (hu->maxcode[i]); i++);
		if (i >= 16) 
		{
			in->marker = M_BADHUFF;
			return 0;
		}
		i = hu->vals[hu->valptr[i] + c - hu->maxcode[i - 1] * 2];
		*runp = i >> 4;
		i &= 15;
	}
	if (i == 0)
	{	/* sigh, 0xf0 is 11 bit */
		LEBI_PUT(in);
		return 0;
	}
	/* receive part */
示例#27
0
文件: asmgen.c 项目: tparys/caspr
int asmgen_assemble(struct SymTab **curSyms,
		    FILE *input,
		    char *data) {
  struct ScanData cfgScan;
  struct Token curToken;
  struct ASMRecord *instr;
  struct ASMRecord *asmcfg = NULL;
  unsigned int argCount, fieldNum, value;
  unsigned int offset = 0, outBits;
  int x;
  
  /* set up the scanner */
  SCANNER_INIT(&cfgScan, input);
  
  /* try to assemble this thing */
  while (1) {
    switch (get_token(&curToken, &cfgScan)) {
      
    case TOK_EOF:
      /* end of file, stop assembling */
      return 0;
      break;
      
    case TOK_LABEL:
    case TOK_ENDL:
      /* ignore these tokens, just pass over */
      break;
      
    case TOK_DIRECTIVE:
      /* directive, pass current data to directive handler */
      directive_parse(&cfgScan, &curToken, NULL, &asmcfg, &offset);
      break;
      
    case TOK_IDENT:
      /* assume this is a format entry */
      DEBUG(1) printf("\nAssembling mnemonic %s\n", curToken.token);
      
      /* find instruction layout */
      for (instr = asmcfg; (instr!=NULL) &&
	     (strcmp(instr->mnemonic, curToken.token) != 0);
	     instr = instr->next) { }
      
      /* shouldn't happen, but just in case */
      if (instr == NULL) {
	printf("ERROR - Unexpected instruction %s\n", curToken.token);
	return -1;
      }
      
      /* got it, so start assembling */
      DEBUG(1) printf("Found format for instruction %s, %d bytes\n",
		      curToken.token, instr->byte_count);

      outBits = instr->asm_mask;
      for (argCount=0; argCount<instr->num_args; argCount++) {
	/* parse next token or parenthesized expression */
	if (asmgen_parse_value(&cfgScan, curSyms, &value) != 0) {
	  fprintf(stderr, "ERROR - Argument %d bad, line %d\n",
		  argCount, curToken.linenum);
	  return -1;
	  }
	if (CHECK_FIELD_TOO_SMALL(instr->arg_widths[argCount], value)) {
	  printf("WARNING - Value 0x%x not representable with %d bits, line %d\n",
		 value, instr->arg_widths[argCount], curToken.linenum);
	}
	
	/* token OK, fill in all fields using this */
	for (fieldNum=0; instr->fmt_args[fieldNum].argNum > -1; fieldNum++) {
	  if (argCount == instr->fmt_args[fieldNum].argNum) {
	    DEBUG(1) printf("Field number %d uses arg %d (value 0x%x)\n",
			    fieldNum, argCount, value);
	    outBits |= GETBITS(0,instr->arg_widths[argCount], value)
	      << instr->fmt_args[fieldNum].argOffset;
	  }
	}
      }
      
      /* expect the newline at the end */
      if (get_token(&curToken, &cfgScan) != TOK_ENDL) {
	fprintf(stderr, "ERROR - Bad token %s at end of line %d\n",
		curToken.token, curToken.linenum);
	return -1;
      }
      
      /* fill in the assembled instruction into the data buffer */
      DEBUG(1) printf("Outputting %d bytes\n", instr->byte_count);
      for (x=(instr->byte_count-1); x>=0; x--) {
	data[offset] = GETBITS(8*x,(8*x)+7, outBits);
	DEBUG(1) printf("Assembled %02x\n", data[offset]);
	offset += 1;
      }
      
      break;
      
    default:
      /* dunno, this is bad */
      fprintf(stderr, "ERROR - Bad token %s at line %d\n",
		curToken.token, curToken.linenum);
	return -1;
      break;
    }
  }
  
  return 0;
}
示例#28
0
文件: timer.c 项目: mrd/terrier
static inline u32 is_timer_overflow_interrupt(int i)
{
  return GETBITS(gptimer[i]->TISR, 1, 1);
}
示例#29
0
文件: timer.c 项目: mrd/terrier
void timer_init(void)
{
  int i;
#ifdef USE_VMM
  if(vmm_map_region(&l4wakeup_region) != OK) {
    early_panic("Unable to map L4 wakeup registers.");
    return;
  }
  if(vmm_map_region(&l4perip_region) != OK) {
    early_panic("Unable to map L4 peripheral registers.");
    return;
  }
#ifdef OMAP3530
  if(vmm_map_region(&l4core_region) != OK) {
    early_panic("Unable to map L4 core registers.");
    return;
  }
#endif
#ifdef OMAP4460
  if(vmm_map_region(&l4abe_region) != OK) {
    early_panic("Unable to map L4 ABE registers.");
    return;
  }
#endif
#endif

#ifdef OMAP3530
  /* For some reason, this is defaulting to SYS_CLK on my board, even
   * though the manual says otherwise. Set it to 32K_FCLK, div-by-1. */
  *CM_CLKSEL_WKUP = (*CM_CLKSEL_WKUP & (~0x7)) | 0x2;
#endif
#ifdef OMAP4460
  DLOG(1, "CM_WKUP_GPTIMER1_CLKCTRL=%#x (%s)\n", *CM_WKUP_GPTIMER1_CLKCTRL, GETBITS(*CM_WKUP_GPTIMER1_CLKCTRL, 24, 1) ? "32kHz" : "SYS_CLK");
#endif

#ifdef OMAP4460
  GBLTIMER = (void *) (arm_config_base_address() + 0x200);
  PVTTIMER = (void *) (arm_config_base_address() + 0x600);
  WATCHDOG = (void *) (arm_config_base_address() + 0x620);
#ifdef USE_VMM
  timer_region.pstart = ((u32) PVTTIMER) & 0xFFF00000;
  timer_region.vstart = (void *) (((u32) PVTTIMER) & 0xFFF00000);
  /* ensure mapping of private/global timers */
  if(vmm_map_region(&timer_region) != OK) {
    early_panic("Unable to map private/global timers.");
    return;
  }
#endif
  PVTTIMER->control = 0;
  WATCHDOG->control = 0;
  GBLTIMER->control = 0;
#endif

  for(i=0;i<NUM_TIMERS;i++) {
    intc_set_irq_handler(GPTIMER_BASE_IRQ + i, timer_irq_handler);
    intc_unmask_irq(GPTIMER_BASE_IRQ + i);
    DLOG(1, "gptimer[%d] revision=%#x TCLR=%#x\n", i+1, gptimer[i+1]->TIDR, gptimer[i+1]->TCLR);
  }

  /* OMAP4460 TRM p892 */
  DLOG(1, "*CM_CLKMODE_DPLL_PER=%#x\n", *((u32 *) 0x4A008140));
  /* OMAP4460 TRM p895 */
  DLOG(1, "*CM_CLKSEL_DPLL_PER=%#x\n", *((u32 *) 0x4A00814C));

  timing_loop();
}
示例#30
0
#include <Binary/CFRecord.h>

namespace XLS
{


BiffStructurePtr CondFmtStructure::clone()
{
	return BiffStructurePtr(new CondFmtStructure(*this));
}


void CondFmtStructure::load(CFRecord& record)
{
	record >> ccf;
	unsigned short flags;
	record >> flags;
	fToughRecalc = GETBIT(flags, 0);
	nID = GETBITS(flags, 1, 15);
	record >> refBound >> sqref;
}


const CellRef CondFmtStructure::getLocation() const
{
	return sqref.getLocationFirstCell();
}

} // namespace XLS