uboot/board/esd/common/xilinx_jtag/lenval.h
<<
>>
Prefs
   1/*
   2 * (C) Copyright 2003
   3 * Stefan Roese, esd gmbh germany, stefan.roese@esd-electronics.com
   4 *
   5 * See file CREDITS for list of people who contributed to this
   6 * project.
   7 *
   8 * This program is free software; you can redistribute it and/or
   9 * modify it under the terms of the GNU General Public License as
  10 * published by the Free Software Foundation; either version 2 of
  11 * the License, or (at your option) any later version.
  12 *
  13 * This program is distributed in the hope that it will be useful,
  14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
  15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  16 * GNU General Public License for more details.
  17 *
  18 * You should have received a copy of the GNU General Public License
  19 * along with this program; if not, write to the Free Software
  20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
  21 * MA 02111-1307 USA
  22 */
  23
  24/*******************************************************/
  25/* file: lenval.h                                      */
  26/* abstract:  This file contains a description of the  */
  27/*            data structure "lenval".                 */
  28/*******************************************************/
  29
  30#ifndef lenval_dot_h
  31#define lenval_dot_h
  32
  33/* the lenVal structure is a byte oriented type used to store an */
  34/* arbitrary length binary value. As an example, the hex value   */
  35/* 0x0e3d is represented as a lenVal with len=2 (since 2 bytes   */
  36/* and val[0]=0e and val[1]=3d.  val[2-MAX_LEN] are undefined    */
  37
  38/* maximum length (in bytes) of value to read in        */
  39/* this needs to be at least 4, and longer than the     */
  40/* length of the longest SDR instruction.  If there is, */
  41/* only 1 device in the chain, MAX_LEN must be at least */
  42/* ceil(27/8) == 4.  For 6 devices in a chain, MAX_LEN  */
  43/* must be 5, for 14 devices MAX_LEN must be 6, for 20  */
  44/* devices MAX_LEN must be 7, etc..                     */
  45/* You can safely set MAX_LEN to a smaller number if you*/
  46/* know how many devices will be in your chain.         */
  47#define MAX_LEN 7000
  48
  49
  50typedef struct var_len_byte
  51{
  52        short len;   /* number of chars in this value */
  53        unsigned char val[MAX_LEN+1];  /* bytes of data */
  54} lenVal;
  55
  56
  57/* return the long representation of a lenVal */
  58extern long value(lenVal *x);
  59
  60/* set lenVal equal to value */
  61extern void initLenVal(lenVal *x, long value);
  62
  63/* check if expected equals actual (taking the mask into account) */
  64extern short EqualLenVal(lenVal *expected, lenVal *actual, lenVal *mask);
  65
  66/* add val1+val2 and put the result in resVal */
  67extern void addVal(lenVal *resVal, lenVal *val1, lenVal *val2);
  68
  69/* return the (byte, bit) of lv (reading from left to right) */
  70extern short RetBit(lenVal *lv, int byte, int bit);
  71
  72/* set the (byte, bit) of lv equal to val (e.g. SetBit("00000000",byte, 1)
  73   equals "01000000" */
  74extern void SetBit(lenVal *lv, int byte, int bit, short val);
  75
  76/* read from XSVF numBytes bytes of data into x */
  77extern void  readVal(lenVal *x, short numBytes);
  78
  79#endif
  80