當前位置: 首頁>>代碼示例>>C++>>正文


C++ __volatile函數代碼示例

本文整理匯總了C++中__volatile函數的典型用法代碼示例。如果您正苦於以下問題:C++ __volatile函數的具體用法?C++ __volatile怎麽用?C++ __volatile使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。


在下文中一共展示了__volatile函數的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C++代碼示例。

示例1: elf64_exec

static int
elf64_exec(struct preloaded_file *fp)
{
    struct file_metadata	*md;
    Elf_Ehdr		*hdr;
    pt_entry_t		pte;
    uint64_t		bi_addr;

    md = file_findmetadata(fp, MODINFOMD_ELFHDR);
    if (md == NULL)
        return (EINVAL);
    hdr = (Elf_Ehdr *)&(md->md_data);

    bi_load(fp, &bi_addr);

    printf("Entering %s at 0x%lx...\n", fp->f_name, hdr->e_entry);

    ldr_enter(fp->f_name);

    __asm __volatile("rsm psr.ic|psr.i;;");
    __asm __volatile("srlz.i;;");

    /*
     * Region 6 is direct mapped UC and region 7 is direct mapped
     * WC. The details of this is controlled by the Alt {I,D}TLB
     * handlers. Here we just make sure that they have the largest
     * possible page size to minimise TLB usage.
     */
    ia64_set_rr(IA64_RR_BASE(6), (6 << 8) | (28 << 2));
    ia64_set_rr(IA64_RR_BASE(7), (7 << 8) | (28 << 2));

    pte = PTE_PRESENT | PTE_MA_WB | PTE_ACCESSED | PTE_DIRTY |
          PTE_PL_KERN | PTE_AR_RWX | PTE_ED;

    __asm __volatile("mov cr.ifa=%0" :: "r"(IA64_RR_BASE(7)));
    __asm __volatile("mov cr.itir=%0" :: "r"(28 << 2));
    __asm __volatile("ptr.i %0,%1" :: "r"(IA64_RR_BASE(7)), "r"(28<<2));
    __asm __volatile("ptr.d %0,%1" :: "r"(IA64_RR_BASE(7)), "r"(28<<2));
    __asm __volatile("srlz.i;;");
    __asm __volatile("itr.i itr[%0]=%1;;" :: "r"(0), "r"(pte));
    __asm __volatile("srlz.i;;");
    __asm __volatile("itr.d dtr[%0]=%1;;" :: "r"(0), "r"(pte));
    __asm __volatile("srlz.i;;");

    enter_kernel(hdr->e_entry, bi_addr);

    /* NOTREACHED */
    return (0);
}
開發者ID:oza,項目名稱:FreeBSD-7.3-dyntick,代碼行數:49,代碼來源:exec.c

示例2: platform_reset

void
platform_reset(void)
{
	volatile unsigned int * p = (void *)0xb8008000;
	/* 
	 * TODO: we should take care of TLB stuff here. Otherwise
	 * board does not boots properly next time
	 */

	/* Write 0x8000_0001 to the Reset register */
	*p = 0x80000001;

	__asm __volatile("li	$25, 0xbfc00000");
	__asm __volatile("j	$25");
}
開發者ID:coyizumi,項目名稱:cs111,代碼行數:15,代碼來源:idt_machdep.c

示例3: _pthread_spin_lock

int
_pthread_spin_lock(pthread_spinlock_t *lock)
{
	struct pthread_spinlock	*lck;
	struct pthread *self = _pthread_self();
	int count, oldval, ret;

	if (lock == NULL || (lck = *lock) == NULL)
		ret = EINVAL;
	else if (lck->s_owner == self)
		ret = EDEADLK;
	else {
		do {
			count = SPIN_COUNT;
			while (lck->s_lock) {
#ifdef __i386__
				/* tell cpu we are spinning */
				__asm __volatile("pause");
#endif
				if (--count <= 0) {
					count = SPIN_COUNT;
					_pthread_yield();
				}
			}
			atomic_swap_int(&(lck)->s_lock, 1, &oldval);
		} while (oldval);

		lck->s_owner = self;
		ret = 0;
	}

	return (ret);
}
開發者ID:AhmadTux,項目名稱:freebsd,代碼行數:33,代碼來源:thr_pspinlock.c

示例4: _BSP_Fatal_error

void _BSP_Fatal_error(unsigned int v)
{
  _BSP_GPLED0_on();
  _BSP_GPLED1_on();
  printk("%s PANIC ERROR %x\n",_RTEMS_version, v);
  __asm__ __volatile ("sc");
}
開發者ID:epicsdeb,項目名稱:rtems,代碼行數:7,代碼來源:bspstart.c

示例5: pthread_spin_unlock

int
pthread_spin_unlock (pthread_spinlock_t *lock)
{
  __asm __volatile ("membar #StoreStore | #LoadStore");
  *lock = 0;
  return 0;
}
開發者ID:Akheon23,項目名稱:chromecast-mirrored-source.toolchain,代碼行數:7,代碼來源:pthread_spin_unlock.c

示例6: r4k_icache_sync_range_index_16

void
r4k_icache_sync_range_index_16(vaddr_t va, vsize_t size)
{
	vaddr_t eva;

	eva = round_line(va + size);
	va = trunc_line(va);

	mips_dcache_wbinv_range_index(va, (eva - va));

	__asm __volatile("sync");

	/*
	 * Since we're doing Index ops, we expect to not be able
	 * to access the address we've been given.  So, get the
	 * bits that determine the cache index, and make a KSEG0
	 * address out of them.
	 */
	va = MIPS_PHYS_TO_KSEG0(va & mips_picache_way_mask);

	eva = round_line(va + size);
	va = trunc_line(va);

	while ((eva - va) >= (32 * 16)) {
		cache_r4k_op_32lines_16(va, CACHE_R4K_I|CACHEOP_R4K_INDEX_INV);
		va += (32 * 16);
	}

	while (va < eva) {
		cache_op_r4k_line(va, CACHE_R4K_I|CACHEOP_R4K_INDEX_INV);
		va += 16;
	}
}
開發者ID:MarginC,項目名稱:kame,代碼行數:33,代碼來源:cache_r4k.c

示例7: getchar_ext

/**
 * Returns the next character or blocks indefinitely. The related input_t
 * structure (scancode, flags, keycode value) is copied into the supplied ptr
 */
char getchar_ext(input_t *input)
{
    char c;
    while ((c = getch_ext(input)) == -1)
    {
        __asm __volatile("sti; hlt");
    }
    return c;
}
開發者ID:fatman2021,項目名稱:byok,代碼行數:13,代碼來源:kb.c

示例8: cpu_coredump

/*
 * Dump the machine specific header information at the start of a core dump.
 */
int
cpu_coredump(struct lwp *l, struct coredump_iostate *iocookie,
    struct core *chdr)
{
  /* XXX implement, pause in ski */
  __asm __volatile("break.i 1");

  return -1;
}
開發者ID:ryo,項目名稱:netbsd-src,代碼行數:12,代碼來源:core_machdep.c

示例9: cpu_idle

void
cpu_idle(void)
{
	struct thread *td = curthread;
	struct mdglobaldata *gd = mdcpu;
	int reqflags;

	crit_exit();
	KKASSERT(td->td_critcount == 0);
	cpu_enable_intr();
	for (;;) {
		/*
		 * See if there are any LWKTs ready to go.
		 */
		lwkt_switch();

		/*
		 * The idle loop halts only if no threads are scheduleable
		 * and no signals have occured.
		 */
		if (cpu_idle_hlt &&
		    (td->td_gd->gd_reqflags & RQF_IDLECHECK_WK_MASK) == 0) {
			splz();
#ifdef SMP
			KKASSERT(MP_LOCK_HELD() == 0);
#endif
			if ((td->td_gd->gd_reqflags & RQF_IDLECHECK_WK_MASK) == 0) {
#ifdef DEBUGIDLE
				struct timeval tv1, tv2;
				gettimeofday(&tv1, NULL);
#endif
				reqflags = gd->mi.gd_reqflags &
					   ~RQF_IDLECHECK_WK_MASK;
				umtx_sleep(&gd->mi.gd_reqflags, reqflags,
					   1000000);
#ifdef DEBUGIDLE
				gettimeofday(&tv2, NULL);
				if (tv2.tv_usec - tv1.tv_usec +
				    (tv2.tv_sec - tv1.tv_sec) * 1000000 
				    > 500000) {
					kprintf("cpu %d idlelock %08x %08x\n",
						gd->mi.gd_cpuid,
						gd->mi.gd_reqflags,
						gd->gd_fpending);
				}
#endif
			}
			++cpu_idle_hltcnt;
		} else {
			splz();
#ifdef SMP
			__asm __volatile("pause");
#endif
			++cpu_idle_spincnt;
		}
	}
}
開發者ID:AhmadTux,項目名稱:DragonFlyBSD,代碼行數:57,代碼來源:cpu_regs.c

示例10: apicHardSleep

void apicHardSleep(uint32_t millisecond) {
    apic::registers[APIC_TIMER_CURRENT_COUNT_REGISTER] = 0xFFFFFFFFu;
    uint32_t target = (apic::busFrequency * millisecond) / 1000;
    uint32_t current;
    do {
        __asm__ __volatile ("HLT");
        current = apic::registers[APIC_TIMER_CURRENT_COUNT_REGISTER];
    } while (0xFFFFFFFFu - current < target);
}
開發者ID:citiral,項目名稱:olliOS,代碼行數:9,代碼來源:sleep.cpp

示例11: badaddr

static int
badaddr(void *addr, size_t size)
{
	struct thread	*td;
	jmp_buf		env, *oldfaultbuf;
	int		x;

	/* Get rid of any stale machine checks that have been waiting.  */
	__asm __volatile ("sync; isync");

	td = curthread;

	oldfaultbuf = td->td_pcb->pcb_onfault;
	td->td_pcb->pcb_onfault = &env;
	if (setjmp(env)) {
		td->td_pcb->pcb_onfault = oldfaultbuf;
		__asm __volatile ("sync");
		return 1;
	}

	__asm __volatile ("sync");

	switch (size) {
	case 1:
		x = *(volatile int8_t *)addr;
		break;
	case 2:
		x = *(volatile int16_t *)addr;
		break;
	case 4:
		x = *(volatile int32_t *)addr;
		break;
	default:
		panic("badaddr: invalid size (%zd)", size);
	}

	/* Make sure we took the machine check, if we caused one. */
	__asm __volatile ("sync; isync");

	td->td_pcb->pcb_onfault = oldfaultbuf;
	__asm __volatile ("sync");	/* To be sure. */

	return (0);
}
開發者ID:outbackdingo,項目名稱:uBSD,代碼行數:44,代碼來源:grackle.c

示例12: cpu_halt

void
cpu_halt(void)
{

	/* We should have shutdown by now, if not enter a low power sleep */
	intr_disable();
	while (1) {
		__asm __volatile("wfi");
	}
}
開發者ID:ralphost,項目名稱:NextBSD,代碼行數:10,代碼來源:machdep.c

示例13: socfpga_trampoline

static void
socfpga_trampoline(void)
{

	__asm __volatile(
			"ldr pc, 1f\n"
			".globl mpentry_addr\n"
			"mpentry_addr:\n"
			"1: .space 4\n");
}
開發者ID:hbsciw,項目名稱:freebsd,代碼行數:10,代碼來源:socfpga_mp.c

示例14: rk30xx_boot2

static void
rk30xx_boot2(void)
{

	__asm __volatile(
			   "ldr pc, 1f\n"
			   ".globl mpentry_addr\n"
			   "mpentry_addr:\n"
			"1: .space 4\n");
}
開發者ID:hbsciw,項目名稱:freebsd,代碼行數:10,代碼來源:rk30xx_mp.c

示例15: enter_kernel

/*
 * Entered with psr.ic and psr.i both zero.
 */
void
enter_kernel(uint64_t start, uint64_t bi)
{

    __asm __volatile("srlz.i;;");
    __asm __volatile("mov cr.ipsr=%0"
                     :: "r"(IA64_PSR_IC
                            | IA64_PSR_DT
                            | IA64_PSR_RT
                            | IA64_PSR_IT
                            | IA64_PSR_BN));
    __asm __volatile("mov cr.iip=%0" :: "r"(start));
    __asm __volatile("mov cr.ifs=r0;;");
    __asm __volatile("mov ar.rsc=0;; flushrs;;");
    __asm __volatile("mov r8=%0" :: "r" (bi));
    __asm __volatile("rfi;;");

    /* NOTREACHED */
}
開發者ID:oza,項目名稱:FreeBSD-7.3-dyntick,代碼行數:22,代碼來源:exec.c


注:本文中的__volatile函數示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。