示例#1
0
// This file is linked in just to make sure that the headers can be
// included from more than one cpp file. The code isn't actually called.

#include "traverse.h"
#include <iostream>

struct Point {
  int x, y;
};
TRAVERSE_STRUCT(Point, FIELD(x) FIELD(y))

void test_linkage() {
  const Point p = {3, 5};
  Point q;
  
  traverse::CoutWriter writer1;
  traverse::BinarySerialize writer2;

  visit(writer1, p);
  visit(writer2, p);

  traverse::BinaryDeserialize reader2{writer2.out.str()};
  visit(reader2, q);
}
示例#2
0
文件: mdp5_kms.c 项目: 24hours/linux
static int mdp5_hw_init(struct msm_kms *kms)
{
	struct mdp5_kms *mdp5_kms = to_mdp5_kms(to_mdp_kms(kms));
	struct drm_device *dev = mdp5_kms->dev;
	uint32_t version, major, minor;
	int ret = 0;

	pm_runtime_get_sync(dev->dev);

	mdp5_enable(mdp5_kms);
	version = mdp5_read(mdp5_kms, REG_MDP5_MDP_VERSION);
	mdp5_disable(mdp5_kms);

	major = FIELD(version, MDP5_MDP_VERSION_MAJOR);
	minor = FIELD(version, MDP5_MDP_VERSION_MINOR);

	DBG("found MDP5 version v%d.%d", major, minor);

	if ((major != 1) || ((minor != 0) && (minor != 2))) {
		dev_err(dev->dev, "unexpected MDP version: v%d.%d\n",
				major, minor);
		ret = -ENXIO;
		goto out;
	}

	mdp5_kms->rev = minor;

	/* Magic unknown register writes:
	 *
	 *    W VBIF:0x004 00000001      (mdss_mdp.c:839)
	 *    W MDP5:0x2e0 0xe9          (mdss_mdp.c:839)
	 *    W MDP5:0x2e4 0x55          (mdss_mdp.c:839)
	 *    W MDP5:0x3ac 0xc0000ccc    (mdss_mdp.c:839)
	 *    W MDP5:0x3b4 0xc0000ccc    (mdss_mdp.c:839)
	 *    W MDP5:0x3bc 0xcccccc      (mdss_mdp.c:839)
	 *    W MDP5:0x4a8 0xcccc0c0     (mdss_mdp.c:839)
	 *    W MDP5:0x4b0 0xccccc0c0    (mdss_mdp.c:839)
	 *    W MDP5:0x4b8 0xccccc000    (mdss_mdp.c:839)
	 *
	 * Downstream fbdev driver gets these register offsets/values
	 * from DT.. not really sure what these registers are or if
	 * different values for different boards/SoC's, etc.  I guess
	 * they are the golden registers.
	 *
	 * Not setting these does not seem to cause any problem.  But
	 * we may be getting lucky with the bootloader initializing
	 * them for us.  OTOH, if we can always count on the bootloader
	 * setting the golden registers, then perhaps we don't need to
	 * care.
	 */

	mdp5_write(mdp5_kms, REG_MDP5_DISP_INTF_SEL, 0);
	mdp5_write(mdp5_kms, REG_MDP5_CTL_OP(0), 0);
	mdp5_write(mdp5_kms, REG_MDP5_CTL_OP(1), 0);
	mdp5_write(mdp5_kms, REG_MDP5_CTL_OP(2), 0);
	mdp5_write(mdp5_kms, REG_MDP5_CTL_OP(3), 0);

out:
	pm_runtime_put_sync(dev->dev);

	return ret;
}
示例#3
0
   Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA

   Author:
	Andi Kleen
*/

#include <stddef.h>
#include "mcelog.h"
#include "bitfield.h"
#include "dunnington.h"

/* Follows Intel IA32 SDM 3b Appendix E.2.1 ++ */

static struct field dunnington_bus_status[] = {
	SBITFIELD(16, "Parity error detected during FSB request phase"),
	FIELD(17, reserved_3bits),
	SBITFIELD(20, "Hard Failure response received for a local transaction"),
	SBITFIELD(21, "Parity error on FSB response field detected"),
	SBITFIELD(22, "Parity data error on inbound data detected"),
	FIELD(23, reserved_3bits),
	FIELD(25, reserved_3bits),
	FIELD(28, reserved_3bits),
	FIELD(31, reserved_1bit),
	{}
};

static char *dnt_front_error[0xf] = {
	[0x1] = "Inclusion error from core 0",
	[0x2] = "Inclusion error from core 1",
	[0x3] = "Write Exclusive error from core 0",
	[0x4] = "Write Exclusive error from core 1",
示例#4
0
/*
 * Examine the archive structure that was read and fill in the
 * current member data with the extracted information.  This handles
 * various types of archive headers.  This can read data from the
 * archive file to obtain a long file name.  Returns TRUE on success.
 */
static BOOL
canonicalize(Archive * arch, const struct ar_hdr * hdr)
{
	char		buf[sizeof(hdr->ar_name) + 1];
	int		n;
	unsigned long	ul;
	unsigned long	bsd_len;

	bsd_len = 0;

	free(arch->name);
	arch->name = 0;

	strncpy(buf, hdr->ar_name, sizeof(hdr->ar_name));
	buf[sizeof(hdr->ar_name)] = 0;

	/*
	 * 1. If shortname matches "^#1/(\d+) *$", then it's a 4.4BSD
	 *    longname.  Read a longname of $1 bytes from ARCH->fd, or
	 *    return FALSE if impossible.
	 */
	if ((n = shortNameMatches44BSD(buf)) != -1)
	{
		/* N is the length of the longname */
		ssize_t cc;

		bsd_len = n;

		MEMB_NAME_ALLOC(n + 1);

		cc = read(arch->fd, arch->name, n);

		if (cc == -1)
		{
			fprintf(stderr, "Error reading longname: %s\n",
				strerror(errno));

			goto free_and_out;
		}

		if (cc != n)
		{
			fprintf(stderr, "Unexpected end of file in longname\n");

			goto free_and_out;
		}

		arch->name[n] = 0;
	}

	/*
	 * 2. Otherwise, if shortname matches "^/(\d+) *$", then it's a SysV
	 *    longname.  Get the longname from the nameTable, or return FALSE
	 *    if there is none.
	 */
	else if ((n = shortNameMatchesSysV(buf)) != -1)
	{
		/*
		 * N is the index of the longname
		 */
		const char *	longname;
		const char *	p;
		size_t		len;

		if (n >= strlen(arch->nameTable))
		{
			fprintf(stderr, "Longname index too large\n");

			return FALSE;
		}

		longname = arch->nameTable + n;

		p = strchr(longname, '/');

		if (!p)
		{
			fprintf(stderr, "Bad longname index\n");

			return FALSE;
		}

		if (p[1] != '\n')
		{
			fprintf(stderr, "Malformed longname table\n");

			return FALSE;
		}

		len = p - longname;
		MEMB_NAME_ALLOC(len + 1);
		strncpy(arch->name, longname, len);
		arch->name[len] = '\0';
	}

	/*
	 * 3. Otherwise, it's just a shortname.  If the shortname contains a
	 *    slash, then the name terminates before the slash; otherwise,
	 *    the name terminates at the first space, or at the end of the
	 *    field if there is none. */
	else
	{
		const char *	p;
		size_t		len;

		p = strchr(buf, '/');

		if (!p)
			p = strchr(buf, ' ');

		if (p)
			len = p - buf;
		else
			len = sizeof(hdr->ar_name);

		MEMB_NAME_ALLOC(len + 1);
		strncpy(arch->name, buf, len);
		arch->name[len] = 0;
	}

	/*
	 * 4. Parse the remaining fields of the header.  Return FALSE if any
	 *    are missing or ill-formed.
	 */
#define FIELD(AFIELD, MFIELD, base)					\
	if (!getNumber(hdr->AFIELD, base, sizeof(hdr->AFIELD), &ul))	\
	{								\
		fprintf(stderr, "Malformed archive member header\n");	\
		goto free_and_out;					\
	}								\
	arch->MFIELD = ul;

	FIELD(ar_date, date, 10);
	FIELD(ar_uid,  uid,  10);
	FIELD(ar_gid,  gid,  10);
	FIELD(ar_mode, mode,  8);
	FIELD(ar_size, size, 10);
#undef FIELD

	/*
	 * 4a. Decide whether a pad byte will be present.u
	 *
	 * The 4.4BSD format is really broken and needs a whole pile of
	 * cruft to deal with it.  There are several cases:
	 *
	 * 1. Even namelen, even memberlen: no pad.
	 * 2. Even namelen, odd memberlen: pad.  Just like SysV.
	 * 3. Odd namelen, even memberlen: pad.  Cruft.
	 * 4. Odd namelen, odd memberlen: no pad.  Cruft.
	 *
	 * Essentially, whenever the namelen is odd, the naive determination
	 * of whether a pad is needed is reversed.
	 */
	if (!bsd_len)
		arch->pad = (arch->size % 2) ? 1 : 0;
	else
	{
		arch->size -= bsd_len;
		arch->pad = (arch->size % 2) ? 1 : 0;

		if (bsd_len % 2)
			arch->pad = !arch->pad;
	}

	/*
	 * 5. Everything was successful.
	 */
	return TRUE;


	/*
	 * 5a. Error exit -- free memory.
	 */
free_and_out:
	free(arch->name);
	arch->name = 0;

	return FALSE;
}
示例#5
0
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/

#include <string.h>
#include <stdio.h>

#include "ras-mce-handler.h"
#include "bitfield.h"

/* Follows Intel IA32 SDM 3b Appendix E.2.1 ++ */

static struct field dunnington_bus_status[] = {
	SBITFIELD(16, "Parity error detected during FSB request phase"),
	FIELD(17, NULL),
	SBITFIELD(20, "Hard Failure response received for a local transaction"),
	SBITFIELD(21, "Parity error on FSB response field detected"),
	SBITFIELD(22, "Parity data error on inbound data detected"),
	FIELD(23, NULL),
	FIELD(25, NULL),
	FIELD(28, NULL),
	FIELD(31, NULL),
	{}
};

static char *dnt_front_error[0xf] = {
	[0x1] = "Inclusion error from core 0",
	[0x2] = "Inclusion error from core 1",
	[0x3] = "Write Exclusive error from core 0",
	[0x4] = "Write Exclusive error from core 1",
示例#6
0
文件: t_vnops.c 项目: 2asoft/freebsd
static void
lookup_complex(const atf_tc_t *tc, const char *mountpath)
{
	char pb[MAXPATHLEN];
	struct stat sb1, sb2;

	USES_DIRS;

	if (FSTYPE_UDF(tc))
		atf_tc_expect_fail("PR kern/49033");

	sprintf(pb, "%s/dir", mountpath);
	if (rump_sys_mkdir(pb, 0777) == -1)
		atf_tc_fail_errno("mkdir");
	if (rump_sys_stat(pb, &sb1) == -1)
		atf_tc_fail_errno("stat 1");

	sprintf(pb, "%s/./dir/../././dir/.", mountpath);
	if (rump_sys_stat(pb, &sb2) == -1)
		atf_tc_fail_errno("stat 2");

	if (memcmp(&sb1, &sb2, sizeof(sb1)) != 0) {
		printf("what\tsb1\t\tsb2\n");

#define FIELD(FN)	\
		printf(#FN "\t%lld\t%lld\n", \
		(long long)sb1.FN, (long long)sb2.FN)
#define TIME(FN)	\
		printf(#FN "\t%lld.%ld\t%lld.%ld\n", \
		(long long)sb1.FN.tv_sec, sb1.FN.tv_nsec, \
		(long long)sb2.FN.tv_sec, sb2.FN.tv_nsec)

		FIELD(st_dev);
		FIELD(st_mode);
		FIELD(st_ino);
		FIELD(st_nlink);
		FIELD(st_uid);
		FIELD(st_gid);
		FIELD(st_rdev);
		TIME(st_atim);
		TIME(st_mtim);
		TIME(st_ctim);
		TIME(st_birthtim);
		FIELD(st_size);
		FIELD(st_blocks);
		FIELD(st_flags);
		FIELD(st_gen);

#undef FIELD
#undef TIME

		atf_tc_fail("stat results differ, see ouput for more details");
	}
	if (FSTYPE_UDF(tc))
		atf_tc_fail("random failure of PR kern/49033 "
			    "did not happen this time");
}
示例#7
0
        restartterm(NULL, 1, NULL);
        return true;
}

/******************************************************************
 * UI
 */

static const struct ui_stat
{
        const char *name;
        int color;
        int offset;
} ui_stats[] = {
#define FIELD(name, color) {#name, color, offsetof(struct cpustat, name)}
        FIELD(nice, COLOR_GREEN), FIELD(user, COLOR_BLUE),
        FIELD(sys, COLOR_RED), FIELD(iowait, COLOR_CYAN),
        FIELD(irq, COLOR_MAGENTA), FIELD(softirq, COLOR_YELLOW),
        // We set the color of the sentinel stat to 0xff so we can
        // safely refer to ui_stats[NSTATS].color as the last, "idle"
        // segment of a bar.
        {NULL, 0xff, 0}
#undef FIELD
};
#define NSTATS (sizeof(ui_stats)/sizeof(ui_stats[0]) - 1)

// If we have too many bars to fit on the screen, we divide the screen
// into "panes".  Wrapping the display into these panes is handled by
// the final output routine.
static struct ui_pane
{
示例#8
0
const int nRecords = 16*1024;
const int nInsertedRecords = 20000;

class Record { 
  public:
    nat8 key;
    nat8 ikey;
    char const* value;
    dbReference<Record>            ref;
    dbArray< dbReference<Record> > iref;
    dbArray< dbReference<Record> > refs;
    dbArray< dbReference<Record> > irefs;

    TYPE_DESCRIPTOR((KEY(key, HASHED|INDEXED), 
		     FIELD(ikey), 
		     FIELD(value), 
		     RELATION(ref, iref),
		     RELATION(refs, irefs),
		     RELATION(iref, ref),
		     RELATION(irefs, refs)));
};

REGISTER(Record);


int main() 
{
    dbDatabase db;
    dbReference<Record>* refs = new dbReference<Record>[nRecords];
    if (db.open("testiref")) { 
示例#9
0
	[0x4F] = "MC_SVID_COMMAND_ERROR",
	[0x52] = "MC_FIVR_CATAS_OVERVOL_FAULT",
	[0x53] = "MC_FIVR_CATAS_OVERCUR_FAULT",
	[0x57] = "MC_SVID_PKGC_REQUEST_FAILED",
	[0x58] = "MC_SVID_IMON_REQUEST_FAILED",
	[0x59] = "MC_SVID_ALERT_REQUEST_FAILED",
	[0x62] = "MC_INVALID_PKGS_RSP_QPI",
	[0x64] = "MC_INVALID_PKG_STATE_CONFIG",
	[0x67] = "MC_HA_IMC_RW_BLOCK_ACK_TIMEOUT",
	[0x6A] = "MC_MSGCH_PMREQ_CMP_TIMEOUT",
	[0x72] = "MC_WATCHDOG_TIMEOUT_PKGS_MASTER",
	[0x81] = "MC_RECOVERABLE_DIE_THERMAL_TOO_HOT"
};

static struct field pcu_mc4[] = {
	FIELD(24, pcu_1),
	{}
};

/* See IA32 SDM Vol3B Table 16-18 */

static struct field memctrl_mc9[] = {
	SBITFIELD(16, "Address parity error"),
	SBITFIELD(17, "HA Wrt buffer Data parity error"),
	SBITFIELD(18, "HA Wrt byte enable parity error"),
	SBITFIELD(19, "Corrected patrol scrub error"),
	SBITFIELD(20, "Uncorrected patrol scrub error"),
	SBITFIELD(21, "Corrected spare error"),
	SBITFIELD(22, "Uncorrected spare error"),
	SBITFIELD(23, "Corrected memory read error"),
	SBITFIELD(24, "iMC, WDB, parity errors"),
示例#10
0
//-------------------------------------------------------------------*--------*
// Sample of database application: game "Guess an animal"
//-------------------------------------------------------------------*--------*

#include "gigabase.h"

const int maxStrLen = 256;


class Guess { 
  public:
    dbReference<Guess> yes;
    dbReference<Guess> no;
    char const* question;

    TYPE_DESCRIPTOR((FIELD(yes), FIELD(question), FIELD(no)));
};

REGISTER(Guess);

void input(char const* prompt, char* buf, size_t buf_size)
{
    char* p;
    do { 
	printf(prompt);
	*buf = '\0';
	fgets(buf, buf_size, stdin);
	p = buf + strlen(buf);
    } while (p <= buf+1); 
    
    if (*(p-1) == '\n') {
示例#11
0
文件: reals.c 项目: Pachot/mlworks
static mlval fmt (mlval arg)
{
  char buffer[40];
  size_t length;
  mlval string;
  mlval format = FIELD (arg, 0);
  double x = GETREAL (FIELD (arg,1));
  int prec = 0;
  /* Check the precision first */
  if (format != EXACT_FORMAT) {
    int format_type = CINT (FIELD (format, 0));
    int min_prec = 0;

    /* Minimum precision is 0 for SCI and FIX, 1 for GEN. */
    if (format_type == GEN_FORMAT) 
      min_prec = 1;

    if (FIELD (format,1) == MLINT (0)) {
      /* Argument is NONE => Default precision. */
      prec = -1;
    } else {
      prec = CINT (FIELD (FIELD (format,1),1));
      if (prec < min_prec)
        exn_raise(perv_exn_ref_size);
    }
  }

  if (isnan (x))
    strcpy (buffer,"nan");
  else
    if (is_infinity (x))
      if (x > 0.0) 
	strcpy (buffer,"+inf");
      else strcpy (buffer,"-inf");
    else
      if (format == EXACT_FORMAT) { /* EXACT conversion required */
	/* Note that this doesn't do the right thing with NaN's, but */
	/* this should be taken care of on the ML side of things */
	int dec;
	int sign;
	char * ptr = buffer;
	char * digits = dtoa (x,0,100,&dec,&sign,NULL);
	char * dptr = digits;
	if (sign)
	  *ptr++ = '~';
	*ptr++ = '0';
	*ptr++ = '.';
	/* Don't copy null byte here */
	while (*dptr)
	  *ptr++=*dptr++;
	if (dec != 0){
	  *ptr++ = 'E';
	  if (dec < 0) {
	    dec = -dec;
	    *ptr++ = '~';
	  }
	  /* Now add the exponent */
	  sprintf (ptr,"%d",dec);
	  ptr += strlen (ptr);
	}
	*ptr++ = '\000';
	freedtoa (digits);
      } else {
	/* Now we have to decipher the format */
	size_t i, plus = 0;
	int point = 0;
	int format_type = CINT (FIELD (format,0));

	if (format_type == FIX_FORMAT) /* FIX */
	  sprintf (buffer, "%.*f", prec < 0 ? 6 : prec, x);
	else if (format_type == GEN_FORMAT) /* GEN */
	  sprintf (buffer, "%.*G", prec < 0 ? 12 : prec,x);
	else if (format_type == SCI_FORMAT) /* SCI */
	  sprintf (buffer, "%.*E", prec < 0 ? 6 : prec, x);
	else sprintf(buffer, "%.18G", x);

	length = strlen(buffer);

	/* Now check for correct printing of negative zeroes */
	if (x == 0.0) {
	  switch (check_neg_zero(&x)) {
	  case 2: /* -0.0 */
	    /* May need to modify the output here */
	    if (*buffer != '-') {
	      /* Yes, we do need to modify */
	      if (*buffer == '+') {
		*buffer = '-';
	      } else {
		for (i = length+1; i > 0; i--) {
		  buffer[i] = buffer[i-1]; /* Move the characters along the buffer */
		};
		length++;
		*buffer = '-';
	      }
	    }
	  case 0: /* Not actually 0.0 at all */
	  case 1: /* +0.0 */
	  default: /* This shouldn't happen */
	    /* No action required here */
	    break;
	  }
	}

	for(i=0; i<length; ++i) {
	  char c = buffer[i];

	  if(c == '-')
	    buffer[i] = '~';
	  else if(c == '.' || c == 'E')
	    point = i;
	  else if(c == '+')
	    plus = i;
	}

	/* Win32 screws up G format by printing too many digits */
	/* in the exponent. So we contract that part if necessary */

	if (point && buffer[point] == 'E') {
	  char c = buffer[point+1];
	  if (c == '+' || c == '~') point++;
	  if (buffer[point+1] == '0' &&
	      isdigit(buffer[point+2]) &&
	      isdigit(buffer[point+3])) {
	    buffer[point+1] = buffer[point+2];
	    buffer[point+2] = buffer[point+3];
	    buffer[point+3] = '\0';
	  }
	}

	if(plus) {
	  for(i=plus; i<length; ++i)
	    buffer[i] = buffer[i+1];
	  length--;
	}
	
	if(!point && (format_type != GEN_FORMAT)
                  && !(format_type == FIX_FORMAT && prec == 0)) {
	  buffer[length++] = '.';
	  buffer[length++] = '0';
	  buffer[length] = '\0';
	}
      }

  length = strlen (buffer);
  string = allocate_string(length+1);
  strcpy(CSTRING(string), buffer);

  return(string);
}
示例#12
0
//-------------------------------------------------------------------*--------*

#include <stdio.h>
#include "fastdb.h"

USE_FASTDB_NAMESPACE

const int nRecords = 100000;
const int nSequentialSearches = 10;

class Record { 
  public:
    dbArray<int4> key;
    dbArray<int4> value;

    TYPE_DESCRIPTOR((KEY(key, HASHED|INDEXED), FIELD(value)));
};

REGISTER(Record);


int main(int argc, char* argv[]) 
{
    int i, j, n, keylen;
    dbDatabase db;
    if (db.open(_T("testarridx"))) { 
        nat8 key = 1999;
        time_t start = time(NULL);
        for (i = 0; i < nRecords; i++) { 
            Record rec;
            key = (3141592621u*key + 2718281829u) % 1000000007u;
示例#13
0
文件: words.c 项目: Pachot/mlworks
static mlval word_times(mlval argument)
{
  unsigned val1 = CWORD(FIELD(argument, 0));
  unsigned val2 = CWORD(FIELD(argument, 1));
  return MLINT(val1 * val2);
}
示例#14
0
	dcResistor,
	dcTransistor,
	dcCondenser,
	dcDiode,
	dcBoard
    };
	
    dbSet<DetailClass> type;

    dbReference<Detail>             assembly;
    dbArray< dbReference<Detail> >  parts;

    TYPE_DESCRIPTOR((KEY(name, HASHED|INDEXED), 
		     RELATION(assembly, parts), 		     
		     RELATION(parts, assembly),
		     FIELD(type)));
    
    void print() const;
};

REGISTER(Detail);


dbSet<Detail::DetailClass> inputDetailClass()
{
    char buf[64], *type = buf;
    printf("Specify detail class(es)\n"
	   "\tr - resistor\n"
	   "\tt - transistor\n"
	   "\tc - condenser\n"
	   "\td - diode\n"
示例#15
0
文件: eta_T_3.c 项目: JasonSome/pbc
/* this is the algorithm 4 in the paper of J.Beuchat et.al, "Algorithms and Arithmetic Operators for Computing
 * the $eta_T$ Pairing in Characteristic Three" */
static void algorithm4(element_t c, element_ptr xp, element_ptr yp,
                       element_ptr xq, element_ptr yq) {
    params *p = PARAM(xp);
    unsigned int re = p->m % 12;
    field_ptr f = FIELD(xp) /*GF(3^m)*/, f6 = FIELD(c) /*GF(3^{6*m})*/;
    element_t e1, xpp, ypp, xqq, yqq, t, nt, nt2, v1, v2, a1, a2, R, u, S;
    element_init(e1, f);
    element_init(xpp, f);
    element_init(ypp, f);
    element_init(xqq, f);
    element_init(yqq, f);
    element_init(t, f);
    element_init(nt, f);
    element_init(nt2, f);
    element_init(v1, f);
    element_init(v2, f);
    element_init(a1, f6);
    element_init(a2, f6);
    element_init(R, f6);
    element_init(u, f);
    element_init(S, f6);
    element_set1(e1);
    element_set(xpp, xp);
    xp = xpp; // clone
    element_add(xp, xp, e1); // xp == xp + b
    element_set(ypp, yp);
    yp = ypp; // clone
    if (re == 1 || re == 11)
        element_neg(yp, yp); // yp == -\mu*b*yp, \mu == 1 when re==1, or 11
    element_set(xqq, xq);
    xq = xqq; // clone
    element_cubic(xq, xq); // xq == xq^3
    element_set(yqq, yq);
    yq = yqq; // clone
    element_cubic(yq, yq); // yq == yq^3
    element_add(t, xp, xq); // t == xp+xq
    element_neg(nt, t); // nt == -t
    element_mul(nt2, t, nt); // nt2 == -t^2
    element_mul(v2, yp, yq); // v2 == yp*yq
    element_mul(v1, yp, t); // v1 == yp*t
    if (re == 7 || re == 11) { // \lambda == 1
        element_t nyp, nyq;
        element_init(nyp, f);
        element_init(nyq, f);
        element_neg(nyp, yp); // nyp == -yp
        element_neg(nyq, yq); // nyq == -yq
        element_set(ITEM(a1,0,0), v1);
        element_set(ITEM(a1,0,1), nyq);
        element_set(ITEM(a1,1,0), nyp);
        element_clear(nyp);
        element_clear(nyq);
    } else { // \lambda == -1
        element_neg(v1, v1); // v1 == -yp*t
        element_set(ITEM(a1,0,0), v1);
        element_set(ITEM(a1,0,1), yq);
        element_set(ITEM(a1,1,0), yp);
    }
    // a2 == -t^2 +yp*yq*s -t*p -p^2
    element_set(ITEM(a2,0,0), nt2);
    element_set(ITEM(a2,0,1), v2);
    element_set(ITEM(a2,1,0), nt);
    element_neg(ITEM(a2,2,0), e1);
    element_mul(R, a1, a2);
    int i;
    for (i = 0; i < (p->m - 1) / 2; i++) {
        element_cubic(R, R);
        element_cubic(xq, xq);
        element_cubic(xq, xq);
        element_sub(xq, xq, e1); // xq <= xq^9-b
        element_cubic(yq, yq);
        element_cubic(yq, yq);
        element_neg(yq, yq); // yq <= -yq^9
        element_add(t, xp, xq); // t == xp+xq
        element_neg(nt, t); // nt == -t
        element_mul(nt2, t, nt); // nt2 == -t^2
        element_mul(u, yp, yq); // u == yp*yq
        element_set0(S);
        element_set(ITEM(S,0,0), nt2);
        element_set(ITEM(S,0,1), u);
        element_set(ITEM(S,1,0), nt);
        element_neg(ITEM(S,2,0), e1);
        element_mul(R, R, S);
    }
    element_set(c, R);
    element_clear(e1);
    element_clear(xpp);
    element_clear(ypp);
    element_clear(xqq);
    element_clear(yqq);
    element_clear(t);
    element_clear(nt);
    element_clear(nt2);
    element_clear(v1);
    element_clear(v2);
    element_clear(a1);
    element_clear(a2);
    element_clear(R);
    element_clear(u);
    element_clear(S);
}
示例#16
0
    [0x00] = "No Error",
    [0x20] = "MC_RCLK_PLL_LOCK_TIMEOUT",
    [0x21] = "MC_PCIE_PLL_LOCK_TIMEOT",
    [0x22] = "MC_BOOT_VID_SET_TIMEOUT",
    [0x23] = "MC_BOOT_FREQUENCY_SET_TIMEOUT",
    [0x24] = "MC_START_IA_CORES_TIMEOUT",
    [0x26] = "MC_PCIE_RCOMP_TIMEOUT",
    [0x27] = "MC_PMA_DNS_COMMAND_TIMEOUT",
    [0x28] = "MC_MESSAGE_CHANNEL_TIMEOUT",
    [0x29] = "MC_GVFSM_BGF_PROGRAM_TIMEOUT",
    [0x2A] = "MC_MC_PLL_LOCK_TIMEOUT",
    [0x2B] = "MC_MS_BGF_PROGRAM_TIMEOUT",
};

static struct field pcu_mc4[] = {
    FIELD(16, pcu_1),
    FIELD(24, pcu_2),
    {}
};

void snb_decode_model(int cputype, int bank, u64 status, u64 misc)
{
    switch (bank) {
    case 4:
        Wprintf("PCU: ");
        decode_bitfield(status, pcu_mc4);
        Wprintf("\n");
        break;
    case 6:
    case 7:
        if (cputype == CPU_SANDY_BRIDGE_EP) {
示例#17
0
文件: eta_T_3.c 项目: JasonSome/pbc
/* computation of $c <- U ^ {3^m+1}$, $U \in T_2(F_{3^3M})$
 * This is the algorithm 7 in the paper above. */
static void algorithm7(element_t c, element_t u) {
    element_ptr u0 = ITEM(u,0,0), u1 = ITEM(u,0,1), u2 = ITEM(u,1,0), u3 =
                                           ITEM(u,1,1), u4 = ITEM(u,2,0), u5 = ITEM(u,2,1);
    field_ptr f = FIELD(u0); /*GF(3^m)*/
    params *p = PARAM(u0);
    element_t a0, a1, a2, a3, a4, a5, a6, m0, m1, m2, m3, m4, m5, m6, m7, m8,
              v0, v1, v2, v3, v4, v5, e1;
    element_init(a0, f);
    element_init(a1, f);
    element_init(a2, f);
    element_init(a3, f);
    element_init(a4, f);
    element_init(a5, f);
    element_init(a6, f);
    element_init(m0, f);
    element_init(m1, f);
    element_init(m2, f);
    element_init(m3, f);
    element_init(m4, f);
    element_init(m5, f);
    element_init(m6, f);
    element_init(m7, f);
    element_init(m8, f);
    element_init(v0, f);
    element_init(v1, f);
    element_init(v2, f);
    element_init(v3, f);
    element_init(v4, f);
    element_init(v5, f);
    element_init(e1, f);
    element_set1(e1);
    element_add(a0, u0, u1);
    element_add(a1, u2, u3);
    element_sub(a2, u4, u5);
    element_mul(m0, u0, u4);
    element_mul(m1, u1, u5);
    element_mul(m2, u2, u4);
    element_mul(m3, u3, u5);
    element_mul(m4, a0, a2);
    element_mul(m5, u1, u2);
    element_mul(m6, u0, u3);
    element_mul(m7, a0, a1);
    element_mul(m8, a1, a2);
    element_add(a3, m5, m6);
    element_sub(a3, a3, m7);
    element_neg(a4, m2);
    element_sub(a4, a4, m3);
    element_sub(a5, m3, m2);
    element_sub(a6, m1, m0);
    element_add(a6, a6, m4);
    if (p->m % 6 == 1) {
        element_add(v0, m0, m1);
        element_add(v0, v0, a4);
        element_add(v0, e1, v0);
        element_sub(v1, m5, m6);
        element_add(v1, v1, a6);
        element_sub(v2, a4, a3);
        element_add(v3, m8, a5);
        element_sub(v3, v3, a6);
        element_add(v4, a3, a4);
        element_neg(v4, v4);
        element_add(v5, m8, a5);
    } else { // p->m % 6 == 5
        element_add(v0, m0, m1);
        element_sub(v0, v0, a4);
        element_add(v0, e1, v0);
        element_sub(v1, m6, m5);
        element_add(v1, v1, a6);
        element_set(v2, a3);
        element_add(v3, m8, a5);
        element_add(v3, v3, a6);
        element_add(v4, a3, a4);
        element_neg(v4, v4);
        element_add(v5, m8, a5);
        element_neg(v5, v5);
    }
    element_set(ITEM(c,0,0), v0);
    element_set(ITEM(c,0,1), v1);
    element_set(ITEM(c,1,0), v2);
    element_set(ITEM(c,1,1), v3);
    element_set(ITEM(c,2,0), v4);
    element_set(ITEM(c,2,1), v5);
    element_clear(a0);
    element_clear(a1);
    element_clear(a2);
    element_clear(a3);
    element_clear(a4);
    element_clear(a5);
    element_clear(a6);
    element_clear(m0);
    element_clear(m1);
    element_clear(m2);
    element_clear(m3);
    element_clear(m4);
    element_clear(m5);
    element_clear(m6);
    element_clear(m7);
    element_clear(m8);
    element_clear(v0);
    element_clear(v1);
    element_clear(v2);
    element_clear(v3);
    element_clear(v4);
    element_clear(v5);
    element_clear(e1);
}
示例#18
0
static int mdp4_hw_init(struct msm_kms *kms)
{
	struct mdp4_kms *mdp4_kms = to_mdp4_kms(to_mdp_kms(kms));
	struct drm_device *dev = mdp4_kms->dev;
	uint32_t version, major, minor, dmap_cfg, vg_cfg;
	unsigned long clk;
	int ret = 0;

	pm_runtime_get_sync(dev->dev);

	mdp4_enable(mdp4_kms);
	version = mdp4_read(mdp4_kms, REG_MDP4_VERSION);
	mdp4_disable(mdp4_kms);

	major = FIELD(version, MDP4_VERSION_MAJOR);
	minor = FIELD(version, MDP4_VERSION_MINOR);

	DBG("found MDP4 version v%d.%d", major, minor);

	if (major != 4) {
		dev_err(dev->dev, "unexpected MDP version: v%d.%d\n",
				major, minor);
		ret = -ENXIO;
		goto out;
	}

	mdp4_kms->rev = minor;

	if (mdp4_kms->dsi_pll_vdda) {
		if ((mdp4_kms->rev == 2) || (mdp4_kms->rev == 4)) {
			ret = regulator_set_voltage(mdp4_kms->dsi_pll_vdda,
					1200000, 1200000);
			if (ret) {
				dev_err(dev->dev,
					"failed to set dsi_pll_vdda voltage: %d\n", ret);
				goto out;
			}
		}
	}

	if (mdp4_kms->dsi_pll_vddio) {
		if (mdp4_kms->rev == 2) {
			ret = regulator_set_voltage(mdp4_kms->dsi_pll_vddio,
					1800000, 1800000);
			if (ret) {
				dev_err(dev->dev,
					"failed to set dsi_pll_vddio voltage: %d\n", ret);
				goto out;
			}
		}
	}

	if (mdp4_kms->rev > 1) {
		mdp4_write(mdp4_kms, REG_MDP4_CS_CONTROLLER0, 0x0707ffff);
		mdp4_write(mdp4_kms, REG_MDP4_CS_CONTROLLER1, 0x03073f3f);
	}

	mdp4_write(mdp4_kms, REG_MDP4_PORTMAP_MODE, 0x3);

	/* max read pending cmd config, 3 pending requests: */
	mdp4_write(mdp4_kms, REG_MDP4_READ_CNFG, 0x02222);

	clk = clk_get_rate(mdp4_kms->clk);

	if ((mdp4_kms->rev >= 1) || (clk >= 90000000)) {
		dmap_cfg = 0x47;     /* 16 bytes-burst x 8 req */
		vg_cfg = 0x47;       /* 16 bytes-burs x 8 req */
	} else {
		dmap_cfg = 0x27;     /* 8 bytes-burst x 8 req */
		vg_cfg = 0x43;       /* 16 bytes-burst x 4 req */
	}

	DBG("fetch config: dmap=%02x, vg=%02x", dmap_cfg, vg_cfg);

	mdp4_write(mdp4_kms, REG_MDP4_DMA_FETCH_CONFIG(DMA_P), dmap_cfg);
	mdp4_write(mdp4_kms, REG_MDP4_DMA_FETCH_CONFIG(DMA_E), dmap_cfg);

	mdp4_write(mdp4_kms, REG_MDP4_PIPE_FETCH_CONFIG(VG1), vg_cfg);
	mdp4_write(mdp4_kms, REG_MDP4_PIPE_FETCH_CONFIG(VG2), vg_cfg);
	mdp4_write(mdp4_kms, REG_MDP4_PIPE_FETCH_CONFIG(RGB1), vg_cfg);
	mdp4_write(mdp4_kms, REG_MDP4_PIPE_FETCH_CONFIG(RGB2), vg_cfg);

	if (mdp4_kms->rev >= 2)
		mdp4_write(mdp4_kms, REG_MDP4_LAYERMIXER_IN_CFG_UPDATE_METHOD, 1);
	mdp4_write(mdp4_kms, REG_MDP4_LAYERMIXER_IN_CFG, 0);

	/* disable CSC matrix / YUV by default: */
	mdp4_write(mdp4_kms, REG_MDP4_PIPE_OP_MODE(VG1), 0);
	mdp4_write(mdp4_kms, REG_MDP4_PIPE_OP_MODE(VG2), 0);
	mdp4_write(mdp4_kms, REG_MDP4_DMA_P_OP_MODE, 0);
	mdp4_write(mdp4_kms, REG_MDP4_DMA_S_OP_MODE, 0);
	mdp4_write(mdp4_kms, REG_MDP4_OVLP_CSC_CONFIG(1), 0);
	mdp4_write(mdp4_kms, REG_MDP4_OVLP_CSC_CONFIG(2), 0);

	if (mdp4_kms->rev > 1)
		mdp4_write(mdp4_kms, REG_MDP4_RESET_STATUS, 1);

	dev->mode_config.allow_fb_modifiers = true;

out:
	pm_runtime_put_sync(dev->dev);

	return ret;
}