Exemplo n.º 1
0
/* delay x useconds AND preserve advance timestamp value */
void __udelay (unsigned long usec)
{
	ulong tmo, tmp;

	if (usec >= 1000) {		/* if "big" number, spread normalization to seconds */
		tmo = usec / 1000;	/* start to normalize for usec to ticks per sec */
		tmo *= CONFIG_SYS_HZ;	/* find number of "ticks" to wait to achieve target */
		tmo /= 1000;		/* finish normalize. */
	} else {			/* else small number, don't kill it prior to HZ multiply */
		tmo = usec * CONFIG_SYS_HZ;
		tmo /= (1000*1000);
	}

	tmp = get_timer (0);		/* get current timestamp */
	if ((tmo + tmp + 1) < tmp) {	/* if setting this forward will roll */
					/* time stamp, then reset time */
		gd->lastinc = READ_TIMER;	/* capture incrementer value */
		gd->tbl = 0;			/* start time stamp */
	} else {
		tmo	+= tmp;		/* else, set advancing stamp wake up time */
	}
	while (get_timer_masked () < tmo)/* loop till event */
		/*NOP*/;
}
Exemplo n.º 2
0
ulong get_timer (ulong base)
{
	return get_timer_masked () - base;
}
Exemplo n.º 3
0
/*
 * return difference between timer ticks and base
 */
ulong get_timer(ulong base)
{
	debug("%s(%lx)\n", __func__, base);
	return get_timer_masked() - base;
}
Exemplo n.º 4
0
static int nextchar(struct state  *pSB)
{
	const struct keyboardmap *pKB = KbMapping;
	int c = -1;

	if(!SequencePtr)	/* no sequence of characters being output ? */
	{
		/*
		** read from keyboard port and pass the keycode
		** through the encoder
		*/
nextk:	if(!Kbd_tstc())			/* any  key available ?   */
			return(-1);
		else if((c = Kbd_getc()) < 0)
			return(c);			/* error reading keyboard */
		else if((c & MkBrkMask) == MakeCode)
		{
			Released = 0;		/* key pressed: continue  */
			if(MkBrkMask == 0xffffffff)
				goto nextk;		/* consume make code */
			else
				c &= ~MkBrkMask;	/* strip make bit(s) from keycode */
		}
		else if((c & MkBrkMask) == BreakCode)
		{
			Released = 1;		/* key released: continue */
			if(MkBrkMask == 0xffffffff)
				goto nextk;		/* consume break code */
			else
				c &= ~MkBrkMask;	/* strip break bit(s) from keycode */
		}
		else if((c = encode(pSB, pKB, c, Released, &SequencePtr)) >= 0)
		{
			/*
			** debouncing: some keyboards need this...
			*/
#ifdef CFG_DEBOUNCE_TOUT
			if(c == LastKey)
			{
				if(get_timer_masked() < CFG_DEBOUNCE_TOUT)
				{	/* skip this key */
					goto nextk;
				}
				
			}
			else
			{
				reset_timer_masked();
				LastKey = c;
			}
#endif
			return(c);			/* normal character: return it */
		}
	}
	if(SequencePtr)	/* a sequence of characters being output ? */
	{
		c = *SequencePtr++;	/* get next key of sequence     */
		if(!*SequencePtr)	/* end of sequence ?            */
			SequencePtr = (unsigned char*)0;  /* terminate it */
	}
	return(c);
}
Exemplo n.º 5
0
/*
 * timer without interrupts
 */
unsigned long get_timer(unsigned long base)
{
    return get_timer_masked() - base;
}
Exemplo n.º 6
0
Arquivo: timer.c Projeto: monojo/xu3
/*
 * Suriyan - we are trying to make this function more like a milli second
 * timer - this is required as most, if not all functions call get_timer
 * assuming it increments every milli second. If not it create issues with
 * USB code - EHCI timed out on TD.
 */
unsigned long get_timer(unsigned long base)
{
        base *= 1000;
        return (get_timer_masked() - base)/1000;
}
Exemplo n.º 7
0
ulong get_timer(ulong base)
{
	return ((get_timer_masked() / (CONFIG_SYS_HZ_CLOCK / 1000)) -
		base);
}
Exemplo n.º 8
0
ulong get_timer (ulong base_ticks)
{
	return get_timer_masked () - base_ticks;
}
Exemplo n.º 9
0
void aee_timer_stop(struct aee_timer *t)
{
    t->acc_ms += (get_timer_masked() - t->start_ms);
    t->start_ms = 0;
}
Exemplo n.º 10
0
void aee_timer_start(struct aee_timer *t)
{
    t->start_ms = get_timer_masked();
}
Exemplo n.º 11
0
int flash_erase(flash_info_t *info, int s_first, int s_last)
{
	vu_char *caddr = (vu_char *)(info->start[0]);
	vu_char *caddr_s;
	int flag, prot, sect;
	int rc;

	if (info->flash_id == FLASH_UNKNOWN) {
		printf("Can't erase unknown flash type %08lx - aborted\n", info->flash_id);
		return (ERR_UNKNOWN_FLASH_TYPE);
	}

	if ((s_first < 0) || (s_first > s_last)) {
		printf("- No sectors to erase\n");
		return (ERR_INVAL);
	}

	prot = 0;
	for (sect = s_first; sect <= s_last; ++sect) {
		if (info->protect[sect]) {
			prot++;
		}
	}

	if (prot) {
		printf("- Warning: %d protected sectors will not be erased\n", prot);
	} else {
		printf("\n");
	}

	/* Disable interrupts which might cause a timeout here */
	flag = disable_interrupts();

	/* Start erase on unprotected sectors */
	for (sect = s_first; sect <= s_last; sect++) {
		if (info->protect[sect] == 0) {	/* not protected */
			caddr_s = (vu_char *)(info->start[sect]);

			printf("Erasing sector %2d @ %08lX... ", sect, info->start[sect]);

			caddr[0xAAA] = 0xAA;
			caddr[0x555] = 0x55;
			caddr[0xAAA] = 0x80;
			caddr[0xAAA] = 0xAA;
			caddr[0x555] = 0x55;
			caddr_s[0] = 0x30;

			reset_timer_masked();

			rc = ERR_OK;
			do {
				u8 result;

				if (get_timer_masked() > CFG_FLASH_ERASE_TOUT) {
					rc = ERR_TIMOUT;
					break;
				}

				result = caddr_s[0];

				if (result & 0x80) {
					break;
				}
				if (result & 0x20) {
					rc = ERR_PROG_ERROR;
					break;
				}
			} while (!rc);

			caddr[0xAAA] = 0x0F;

			if (rc == ERR_OK) {
				printf("OK\n");
			} else {
				printf("Failed");
				return (rc);
			}
		}
	}

	/* re-enable interrupts if necessary */
	if (flag)
		enable_interrupts();

	/* reset to read mode */
	caddr = (vu_char *)info->start[0];
	caddr[0] = 0xF0; /* reset bank */
	udelay_masked(10000);

	return (ERR_OK);
}
Exemplo n.º 12
0
/*
 * timer without interrupts
 */
ulong get_timer(ulong base)
{
	return (get_timer_masked() / GPT_RESOLUTION) - base;
}
Exemplo n.º 13
0
unsigned long long get_ticks(void)
{
	return get_timer_masked();
}
Exemplo n.º 14
0
ulong get_timer (ulong base)
{
	return (get_timer_masked () - base)>>16;
}
Exemplo n.º 15
0
/* spl_image defined in spl.c */
void spl_sboot_extend(void)
{
	uint8_t csum[20];
	uint8_t out_digest[20];

	uint8_t image_buffer[SBOOT_SPL_READ_SIZE];
	SHA1_CTX ctx;

#ifdef CONFIG_SBOOT_TIMING
	uint32_t timer_begin = get_timer_masked();
#endif

	sha1_starts(&ctx);
	/* Only support MMC/FAT */
#if defined(CONFIG_SPL_MMC_SUPPORT) && defined(CONFIG_SPL_FAT_SUPPORT)
	/* Todo: add a configuration option to limit the memory read length.
	 * This will allow us to SHA1 in blocks.
	 * Todo: add a configuration option to use the TPM's SHA1 for extreme
	 * memory contention scenarios. */
	sha1_update(&ctx, (unsigned char *) spl_image.load_addr, spl_image.size);
#else
#warning "Warning: sboot does not support the U-Boot storage configuration."
#endif
	sha1_finish(&ctx, csum);

	if (sboot_extend(SBOOT_PCR_UBOOT, csum, out_digest) != SBOOT_SUCCESS) {
		puts("SPL: (sboot) error while measuring U-Boot\n");
		goto finished;
	}

	sha1_starts(&ctx);
	/* Extend EEPROM, support I2C only */
#ifdef CONFIG_ENV_EEPROM_IS_ON_I2C
	/*
	for (i = 0; i * SBOOT_SPL_READ_SIZE < CONFIG_SYS_I2C_EEPROM_SIZE; ++i) {
		memset(image_buffer, 0, SBOOT_SPL_READ_SIZE);
		if (i2c_read(CONFIG_SYS_I2C_EEPROM_ADDR, 0, CONFIG_SYS_I2C_EEPROM_ADDR_LEN,
				image_buffer, SBOOT_SPL_READ_SIZE)) {
			puts("SPL: (sboot) could not read the EEPROM\n");
			return;
		}
		sha1_update(&ctx, image_buffer, SBOOT_SPL_READ_SIZE);
	}*/
	debug("SPL: (sboot) measuring EEPROM\n");
	i2c_read(CONFIG_SYS_I2C_EEPROM_ADDR, 0, CONFIG_SYS_I2C_EEPROM_ADDR_LEN, image_buffer, CONFIG_SYS_I2C_EEPROM_SIZE);
	sha1_update(&ctx, image_buffer, CONFIG_SYS_I2C_EEPROM_SIZE);
	debug("SPL: (sboot) finished\n");
#else
#warning "Warning: sboot does not support the ENV storage configuration."
#endif
	sha1_finish(&ctx, csum);

	if (sboot_extend(SBOOT_PCR_CHIPSET_CONFIG, csum, out_digest) != SBOOT_SUCCESS) {
		puts("SPL: (sboot) error while measuring chipset config\n");
		goto finished;
	}

finished:
#ifdef CONFIG_SBOOT_TIMING
	report_time("extend", get_timer_masked() - timer_begin);
#endif

	return;
}
Exemplo n.º 16
0
int
flash_erase(flash_info_t * info, int s_first, int s_last)
{
	int flag, prot, sect;
	ulong type, start, last;
	int rcode = 0;

	if ((s_first < 0) || (s_first > s_last)) {
		if (info->flash_id == FLASH_UNKNOWN) {
			printf("- missing\n");
		} else {
			printf("- no sectors to erase\n");
		}
		return 1;
	}

	type = (info->flash_id & FLASH_VENDMASK);
	if ((type != FLASH_MAN_INTEL)) {
		printf("Can't erase unknown flash type %08lx - aborted\n",
		       info->flash_id);
		return 1;
	}

	prot = 0;
	for (sect = s_first; sect <= s_last; ++sect) {
		if (info->protect[sect]) {
			prot++;
		}
	}

	if (prot) {
		printf("- Warning: %d protected sectors will not be erased!\n",
		       prot);
	} else {
		printf("\n");
	}

	start = get_timer(0);
	last = start;

	/* Disable interrupts which might cause a timeout here */
	flag = disable_interrupts();

	/* Start erase on unprotected sectors */
	for (sect = s_first; sect <= s_last; sect++) {
		if (info->protect[sect] == 0) {	/* not protected */
			FPWV *addr = (FPWV *) (info->start[sect]);
			FPW status;

			printf("Erasing sector %2d ... ", sect);

			/* arm simple, non interrupt dependent timer */
			reset_timer_masked();

			*addr = (FPW) 0x00500050;	/* clear status register */
			*addr = (FPW) 0x00200020;	/* erase setup */
			*addr = (FPW) 0x00D000D0;	/* erase confirm */

			while (((status =
				 *addr) & (FPW) 0x00800080) !=
			       (FPW) 0x00800080) {
				if (get_timer_masked() > CONFIG_SYS_FLASH_ERASE_TOUT) {
					printf("Timeout\n");
					*addr = (FPW) 0x00B000B0;	/* suspend erase         */
					*addr = (FPW) 0x00FF00FF;	/* reset to read mode */
					rcode = 1;
					break;
				}
			}

			*addr = (FPW) 0x00500050;	/* clear status register cmd.   */
			*addr = (FPW) 0x00FF00FF;	/* resest to read mode          */

			printf(" done\n");
		}
	}
	return rcode;
}