Пример #1
0
char *
flags_to_string (FlagType flags, int object_type)
{
  return common_flags_to_string (flags,
				 object_type,
				 object_flagbits,
				 ENTRIES (object_flagbits));
}
Пример #2
0
char *
pcbflags_to_string (FlagType flags)
{
  return common_flags_to_string (flags,
				 ALL_TYPES,
				 pcb_flagbits,
				 ENTRIES (pcb_flagbits));
}
Пример #3
0
PRIVATE void KeyboardInit(void)
{
  static void *q[20] ;
  
  kybd_queue = OSQCreate(q, ENTRIES(q)) ;
  SetISR(IRQ2INT(IRQ_KYBD), OSKeyboardISR) ;
  outportb(0x21, inportb(0x21) & ~0x02) ;
}
Пример #4
0
FlagType
string_to_pcbflags (const char *flagstring,
		    int (*error) (const char *msg))
{
  return common_string_to_flags (flagstring,
				 error,
				 pcb_flagbits,
				 ENTRIES (pcb_flagbits));
}
Пример #5
0
static struct cmd *find_command(const char *name)
{
    for(int i = 0; i < ENTRIES(commands); i++) {
        struct cmd *cmd = &commands[i];

        if(strcmp(name, cmd->name) == 0) {
            return cmd;
        }
    }

    return NULL;
}
Пример #6
0
int main(void)
	{
	static struct {int a[8], b[8], sum ; } testcase[] =
		{
		{{0,0,0,0,0,0,0,1},{0,0,0,0,0,0,0,1},0},
		{{1,1,1,1,1,1,1,1},{1,0,0,0,0,0,0,0},0},
		{{1,0,1,0,1,0,1,0},{1,0,1,0,1,0,1,0},-86},
		{{1,1,0,1,0,0,0,0},{0,1,1,0,1,1,1,1},1},
		{{1,0,1,0,1,0,1,0},{0,1,0,1,0,1,0,1},-1}
		} ;
	int k ;

	InitializeHardware(HEADER, PROJECT_NAME) ;

	for (;;)
		{
		for (k = 0; k < ENTRIES(testcase); k++)
			{
			int *a = testcase[k].a ;
			int *b = testcase[k].b ;
			int sum[8] ;
			uint32_t before, after, cycles ;

			printf(" Test Case %d: ", k+1) ;
			PrintBits(a) ;
			printf("+") ;
			PrintBits(b) ;
			printf("\n") ;

			printf("   Correct Sum: ") ;
			PrintByte(testcase[k].sum) ;
			printf("\n") ;

            before = GetClockCycleCount() ;
			AddBinary(a, b, sum) ;
            after  = GetClockCycleCount() ;
            cycles = after - before ;

			printf("      Your Sum: ") ;
			if (PrintBits(sum) != (uint8_t) testcase[k].sum) printf(" %s", ERROR_FLAG) ;
			printf("\n") ;
			printf("  Clock Cycles: %lu\n", cycles) ;

			printf("\n") ;

			WaitForPushButton() ;
			}

		printf("Press button to start over.\n") ;
		WaitForPushButton() ;
		ClearDisplay() ;
		}
	}
int main(void)
	{
	static struct
		{
		uint32_t	word ;
		int			lsb ;
		int			width ;
		uint32_t	value ;
		} testcase[] =
		{
		{0xFFFFFFFF,  5, 7,  0},
		{0x00000000, 22, 5, -1}
		} ;
	int k ;

	InitializeHardware(HEADER, PROJECT_NAME) ;

	for (;;)
		{
		for (k = 0; k < ENTRIES(testcase); k++)
			{
			uint32_t	word	= testcase[k].word ;
			int			lsb		= testcase[k].lsb ;
			int			width	= testcase[k].width ;
			uint32_t	value	= testcase[k].value ;
			uint32_t	result, answer	= BFI(word, lsb, width, value) ;
			uint32_t    before, after, cycles ;

            before = GetClockCycleCount() ;
			result = BitFieldInsert(word, lsb, width, value) ;
            after  = GetClockCycleCount() ;
            cycles = after - before ;

			printf("   Test Case %d: %08X,%d,%d,%d\n", k+1,
				(unsigned) word, lsb, width, (int) value) ;

			printf("Correct Result: %08X\n", (unsigned) answer) ;

			printf("   Your Result: %08X", (unsigned) result) ;
			if (result != answer) printf(" %s", ERROR_FLAG) ;
			printf("\n") ;

			printf("  Clock Cycles: %lu\n\n", cycles) ;

			WaitForPushButton() ;
			}

		printf("Press button to start over.\n") ;
		WaitForPushButton() ;
		ClearDisplay() ;
		}
	}
Пример #8
0
static int
keyword(const char *s)
{
	int i;

	if (! s) {
		return K_none;
	}
	for (i = 0; i < ENTRIES(keywords); ++i) {
		if (keywords[i] && strcasecmp(s, keywords[i]) == 0)
			return i;
	}
	return -1;
}
int main(void)
    {
	static uint32_t testcase[] =
		{
		0x12345678,	0x0000FFFF,	0x00FF00FF
		} ;

	InitializeHardware(HEADER, PROJECT_NAME) ;

	for (;;)
		{
		int k ;

		for (k = 0; k < ENTRIES(testcase); k++)
			{
			uint32_t word = testcase[k] ;
			uint32_t result, answer = REV(word) ;
			uint32_t before, after, cycles ;

            before = GetClockCycleCount() ;
			result = ReverseByteOrder(word) ;
            after  = GetClockCycleCount() ;
            cycles = after - before ;

			printf("   Test Case %d: %08X (hex)\n", k+1, (unsigned) word) ;

			printf("Correct Result: %08X\n", (unsigned) answer) ;

			printf("   Your Result: %08X", (unsigned) result) ;
			if (result != answer) printf(" %s", ERROR_FLAG) ;
			printf("\n") ;

			printf("  Clock Cycles: %lu\n\n", cycles) ;

			WaitForPushButton() ;
			}

		printf("Press button to start over.\n") ;
		WaitForPushButton() ;
		ClearDisplay() ;
		}
    }
Пример #10
0
int main(void)
	{
	static struct {int a[8], b[8], sum ; } testcase[] =
		{
		{{0,0,0,0,0,0,0,1},{0,0,0,0,0,0,0,1},0},
		{{1,1,1,1,1,1,1,1},{1,0,0,0,0,0,0,0},0},
		{{1,0,1,0,1,0,1,0},{1,0,1,0,1,0,1,0},-86},
		{{1,1,0,1,0,0,0,0},{0,1,1,0,1,1,1,1},1},
		{{1,0,1,0,1,0,1,0},{0,1,0,1,0,1,0,1},-1}
		} ;
	int k ;


		for (k = 0; k < ENTRIES(testcase); k++)
			{
			int *a = testcase[k].a ;
			int *b = testcase[k].b ;
			int sum[8] ;
			uint32_t before, after, cycles ;

			printf(" Test Case %d: \n", k+1) ;
			PrintBits(a) ;
			printf("\n") ;
			PrintBits(b) ;
			printf("\n") ;

			printf("   Correct Sum: \n") ;
			PrintByte(testcase[k].sum);
			printf("\n") ;

			AddBinary(a, b, sum) ;

			printf("      Your Sum: \n") ;
			PrintBits(sum);
			printf("\n") ;

			printf("\n") ;

			}

		printf("Press button to start over.\n") ;
		}
Пример #11
0
static int help(int argc, char *argv[])
{
    struct cmd *cmd;

    if(argc == 1) {
        printf("available commands:\n");
        for (int i=0; i < ENTRIES(commands); i++) {
            printf("%-15s", commands[i].name);
            if (((i + 1) % 5) == 0) {
                printf("\n");
            }
        }
        printf("\n");
        return 0;
    }

    if((cmd = find_command(argv[1])) != NULL) {
        printf("%s: %s\n", argv[1], cmd->usage);
        return 0;
    } else {
        printf("%s: %s: command not found\n", argv[0], argv[1]);
        return 1;
    }
}
Пример #12
0
/*
=============
HL_PrintBSPFileSizes

Dumps info about current file
=============
*/
void HL_PrintBSPFileSizes(void)
{
	int	totalmemory = 0;

	qprintf("\n");
	qprintf("Object names  Objects/Maxobjs  Memory / Maxmem  Fullness\n" );
	qprintf("------------  ---------------  ---------------  --------\n" );

	totalmemory += ArrayUsage( "models",		hl_nummodels,		ENTRIES(hl_dmodels),		ENTRYSIZE(hl_dmodels) );
	totalmemory += ArrayUsage( "planes",		hl_numplanes,		ENTRIES(hl_dplanes),		ENTRYSIZE(hl_dplanes) );
	totalmemory += ArrayUsage( "vertexes",		hl_numvertexes,	ENTRIES(hl_dvertexes),	ENTRYSIZE(hl_dvertexes) );
	totalmemory += ArrayUsage( "nodes",			hl_numnodes,		ENTRIES(hl_dnodes),		ENTRYSIZE(hl_dnodes) );
	totalmemory += ArrayUsage( "texinfos",		hl_numtexinfo,		ENTRIES(hl_texinfo),		ENTRYSIZE(hl_texinfo) );
	totalmemory += ArrayUsage( "faces",			hl_numfaces,		ENTRIES(hl_dfaces),		ENTRYSIZE(hl_dfaces) );
	totalmemory += ArrayUsage( "clipnodes",	hl_numclipnodes,	ENTRIES(hl_dclipnodes),	ENTRYSIZE(hl_dclipnodes) );
	totalmemory += ArrayUsage( "leaves",		hl_numleafs,		ENTRIES(hl_dleafs),		ENTRYSIZE(hl_dleafs) );
	totalmemory += ArrayUsage( "marksurfaces",hl_nummarksurfaces,ENTRIES(hl_dmarksurfaces),ENTRYSIZE(hl_dmarksurfaces) );
	totalmemory += ArrayUsage( "surfedges",	hl_numsurfedges,	ENTRIES(hl_dsurfedges),	ENTRYSIZE(hl_dsurfedges) );
	totalmemory += ArrayUsage( "edges",			hl_numedges,		ENTRIES(hl_dedges),		ENTRYSIZE(hl_dedges) );

	totalmemory += GlobUsage( "texdata",		hl_texdatasize,	sizeof(hl_dtexdata) );
	totalmemory += GlobUsage( "lightdata",		hl_lightdatasize,	sizeof(hl_dlightdata) );
	totalmemory += GlobUsage( "visdata",		hl_visdatasize,	sizeof(hl_dvisdata) );
	totalmemory += GlobUsage( "entdata",		hl_entdatasize,	sizeof(hl_dentdata) );

	qprintf( "=== Total BSP file data space used: %d bytes ===\n\n", totalmemory );
}
Пример #13
0
/*
=============
PrintBSPFileSizes

Dumps info about current file
=============
*/
void PrintBSPFileSizes (void)
{
	int	numtextures = texdatasize ? ((dmiptexlump_t*)dtexdata)->nummiptex : 0;
	int	totalmemory = 0;

	printf("\n");
	printf("Object names  Objects/Maxobjs  Memory / Maxmem  Fullness\n" );
	printf("------------  ---------------  ---------------  --------\n" );

	totalmemory += ArrayUsage( "models",		nummodels,		ENTRIES(dmodels),		ENTRYSIZE(dmodels) );
	totalmemory += ArrayUsage( "planes",		numplanes,		ENTRIES(dplanes),		ENTRYSIZE(dplanes) );
	totalmemory += ArrayUsage( "vertexes",		numvertexes,	ENTRIES(dvertexes),		ENTRYSIZE(dvertexes) );
	totalmemory += ArrayUsage( "nodes",			numnodes,		ENTRIES(dnodes),		ENTRYSIZE(dnodes) );
	totalmemory += ArrayUsage( "texinfos",		numtexinfo,		ENTRIES(texinfo),		ENTRYSIZE(texinfo) );
	totalmemory += ArrayUsage( "faces",			numfaces,		ENTRIES(dfaces),		ENTRYSIZE(dfaces) );
	totalmemory += ArrayUsage( "clipnodes",		numclipnodes,	ENTRIES(dclipnodes),	ENTRYSIZE(dclipnodes) );
	totalmemory += ArrayUsage( "leaves",		numleafs,		ENTRIES(dleafs),		ENTRYSIZE(dleafs) );
	totalmemory += ArrayUsage( "marksurfaces",	nummarksurfaces,ENTRIES(dmarksurfaces),	ENTRYSIZE(dmarksurfaces) );
	totalmemory += ArrayUsage( "surfedges",		numsurfedges,	ENTRIES(dsurfedges),	ENTRYSIZE(dsurfedges) );
	totalmemory += ArrayUsage( "edges",			numedges,		ENTRIES(dedges),		ENTRYSIZE(dedges) );

	totalmemory += GlobUsage( "texdata",		texdatasize,	sizeof(dtexdata) );
	totalmemory += GlobUsage( "lightdata",		lightdatasize,	sizeof(dlightdata) );
	totalmemory += GlobUsage( "visdata",		visdatasize,	sizeof(dvisdata) );
	totalmemory += GlobUsage( "entdata",		entdatasize,	sizeof(dentdata) );

	printf( "=== Total BSP file data space used: %d bytes ===\n", totalmemory );
}
Пример #14
0
int
main ()
{
  time_t now;
  int i;
  int errors = 0, count = 0;

  time (&now);
  srandom ((unsigned int) now + getpid ());

  grow_layer_list (0);
  for (i = 0; i < 16; i++)
    {
      int j;
      char *p;
      if (i != 1 && i != 4 && i != 5 && i != 9)
	set_layer_list (i, 1);
      else
	set_layer_list (i, 0);
      p = print_layer_list ();
      printf ("%2d : %20s =", i, p);
      parse_layer_list (p + 1, 0);
      for (j = 0; j < num_layers; j++)
	printf (" %d", layers[j]);
      printf ("\n");
    }

  while (count < 1000000)
    {
      FlagHolder fh;
      char *str;
      FlagType new_flags;
      int i;
      int otype;

      otype = ALL_TYPES;
      fh.Flags = empty_flags;
      for (i = 0; i < ENTRIES (object_flagbits); i++)
	{
	  if (TEST_FLAG (object_flagbits[i].mask, &fh))
	    continue;
	  if ((otype & object_flagbits[i].object_types) == 0)
	    continue;
	  if ((random () & 4) == 0)
	    continue;

	  otype &= object_flagbits[i].object_types;
	  SET_FLAG (object_flagbits[i].mask, &fh);
	}

      if (otype & PIN_TYPES)
	for (i = 0; i < MAX_LAYER; i++)
	  if (random () & 4)
	    ASSIGN_THERM (i, 3, &fh);

      str = flags_to_string (fh.Flags, otype);
      new_flags = string_to_flags (str, 0);

      count++;
      if (FLAGS_EQUAL (fh.Flags, new_flags))
	continue;

      dump_flag (&fh.Flags);
      printf (" ");
      dump_flag (&new_flags);
      printf ("\n");
      if (++errors == 5)
	exit (1);
    }

  while (count < 1000000)
    {
      FlagHolder fh;
      char *str;
      FlagType new_flags;
      int i;
      int otype;

      otype = ALL_TYPES;
      fh.Flags = empty_flags;
      for (i = 0; i < ENTRIES (pcb_flagbits); i++)
	{
	  if (TEST_FLAG (pcb_flagbits[i].mask, &fh))
	    continue;
	  if ((random () & 4) == 0)
	    continue;

	  otype &= pcb_flagbits[i].object_types;
	  SET_FLAG (pcb_flagbits[i].mask, &fh);
	}

      str = pcbflags_to_string (fh.Flags);
      new_flags = string_to_pcbflags (str, 0);

      count++;
      if (FLAGS_EQUAL (fh.Flags, new_flags))
	continue;

      dump_flag (&fh.Flags);
      printf (" ");
      dump_flag (&new_flags);
      printf ("\n");
      if (++errors == 5)
	exit (1);
    }
  printf ("%d out of %d failed\n", errors, count);
  return errors;
}
Пример #15
0
/*add mutex*/
static void adxl34x_work(struct work_struct *work)
{
	struct adxl34x *ac = container_of(work, struct adxl34x, work);
	struct adxl34x_platform_data *pdata = &ac->pdata;
	int int_stat, tap_stat, samples;

	/*
	 * ACT_TAP_STATUS should be read before clearing the interrupt
	 * Avoid reading ACT_TAP_STATUS in case TAP detection is disabled
	 */

	mutex_lock(&ac->mutex);
	if (pdata->tap_axis_control & (TAP_X_EN | TAP_Y_EN | TAP_Z_EN))
		tap_stat = AC_READ(ac, ACT_TAP_STATUS);
	else
		tap_stat = 0;

	int_stat = AC_READ(ac, INT_SOURCE);

#if 0
	if (int_stat & FREE_FALL)
		adxl34x_report_key_single(ac->input, pdata->ev_code_ff);

	if (int_stat & OVERRUN)
		dev_dbg(&ac->bus->dev, "OVERRUN\n");

	if (int_stat & SINGLE_TAP) {
		if (tap_stat & TAP_X_SRC)
			adxl34x_report_key_single(ac->input,
						  pdata->ev_code_tap_x);
		if (tap_stat & TAP_Y_SRC)
			adxl34x_report_key_single(ac->input,
						  pdata->ev_code_tap_y);
		if (tap_stat & TAP_Z_SRC)
			adxl34x_report_key_single(ac->input,
						  pdata->ev_code_tap_z);
	}

	if (int_stat & DOUBLE_TAP) {
		if (tap_stat & TAP_X_SRC)
			adxl34x_report_key_double(ac->input,
						  pdata->ev_code_tap_x);
		if (tap_stat & TAP_Y_SRC)
			adxl34x_report_key_double(ac->input,
						  pdata->ev_code_tap_y);
		if (tap_stat & TAP_Z_SRC)
			adxl34x_report_key_double(ac->input,
						  pdata->ev_code_tap_z);
	}

	if (pdata->ev_code_act_inactivity) {
		if (int_stat & ACTIVITY)
			input_report_key(ac->input,
					 pdata->ev_code_act_inactivity, 1);
		if (int_stat & INACTIVITY)
			input_report_key(ac->input,
					 pdata->ev_code_act_inactivity, 0);
	}
#endif
	if (int_stat & (DATA_READY | WATERMARK)) {

		if (pdata->fifo_mode)
			samples = ENTRIES(AC_READ(ac, FIFO_STATUS)) + 1;
		else
			samples = 1;

		for (; samples > 0; samples--) {
			adxl34x_service_ev_fifo(ac);
		/*
		 * To ensure that the FIFO has
		 * completely popped, there must be at least 5 us between
		 * the end of reading the data registers, signified by the
		 * transition to register 0x38 from 0x37 or the CS pin
		 * going high, and the start of new reads of the FIFO or
		 * reading the FIFO_STATUS register. For SPI operation at
		 * 1.5 MHz or lower, the register addressing portion of the
		 * transmission is sufficient delay to ensure the FIFO has
		 * completely popped. It is necessary for SPI operation
		 * greater than 1.5 MHz to de-assert the CS pin to ensure a
		 * total of 5 us, which is at most 3.4 us at 5 MHz
		 * operation.
		 */
			if (ac->fifo_delay && (samples > 1))
				udelay(3);
		}
	}

	input_sync(ac->input);
	enable_irq(ac->bus->irq);
	mutex_unlock(&ac->mutex);
}