当前位置: 首页>>代码示例>>C++>>正文


C++ rcr2函数代码示例

本文整理汇总了C++中rcr2函数的典型用法代码示例。如果您正苦于以下问题:C++ rcr2函数的具体用法?C++ rcr2怎么用?C++ rcr2使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了rcr2函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: do_page_fault

static void 
do_page_fault(struct frame *tf)
{
	struct vm_area_struct *vma;
	struct mm_struct *mm = curtask->mm;
	viraddr_t address = rcr2();
	
	if (address >= KERNEL_BASE_ADDR) {
		//
	}
	
	vma = find_vma(mm, address);


	if (!vma || vma->vm_start > address) {
		printk("task [%08d] access invalid vma:%x, exiting\n",curtask->pid,address);
		do_exit(curtask);
	} else {
		pte_t *pte = _page_walk (task2pgd(curtask),address,true);
		if (!pte) {
			printk("!pte do_page_fault!!!!\n");
			do_exit(curtask);
		}
		handle_pte_fault(mm, vma, address, pte,tf->tf_trapno);
	}
}
开发者ID:Zhang626,项目名称:miniOS,代码行数:26,代码来源:interrupt.c

示例2: print_trapframe

void
print_trapframe(struct Trapframe *tf)
{
	cprintf("TRAP frame at %p\n", tf);
	print_regs(&tf->tf_regs);
	cprintf("  es   0x----%04x\n", tf->tf_es);
	cprintf("  ds   0x----%04x\n", tf->tf_ds);
	cprintf("  trap 0x%08x %s\n", tf->tf_trapno, trapname(tf->tf_trapno));
	// If this trap was a page fault that just happened
	// (so %cr2 is meaningful), print the faulting linear address.
	if (tf == last_tf && tf->tf_trapno == T_PGFLT)
		cprintf("  cr2  0x%08x\n", rcr2());
	cprintf("  err  0x%08x", tf->tf_err);
	// For page faults, print decoded fault error code:
	// U/K=fault occurred in user/kernel mode
	// W/R=a write/read caused the fault
	// PR=a protection violation caused the fault (NP=page not present).
	if (tf->tf_trapno == T_PGFLT)
		cprintf(" [%s, %s, %s]\n",
			tf->tf_err & 4 ? "user" : "kernel",
			tf->tf_err & 2 ? "write" : "read",
			tf->tf_err & 1 ? "protection" : "not-present");
	else
		cprintf("\n");
	cprintf("  eip  0x%08x\n", tf->tf_eip);
	cprintf("  cs   0x----%04x\n", tf->tf_cs);
	cprintf("  flag 0x%08x\n", tf->tf_eflags);
	if ((tf->tf_cs & 3) != 0) {
		cprintf("  esp  0x%08x\n", tf->tf_esp);
		cprintf("  ss   0x----%04x\n", tf->tf_ss);
	}
}
开发者ID:Xmagicer,项目名称:6.828mit,代码行数:32,代码来源:trap.c

示例3: print_frame

void print_frame(struct frame *tf)
{
	STATIC_INIT_SPIN_LOCK(pflock);
	spin_lock(&pflock);
	printk("TRAP frame at %p from CPU %d\n", tf, get_cpuid());
	print_regs(&tf->tf_regs);
	printk("  es   0x----%04x\n", tf->tf_es);
	printk("  ds   0x----%04x\n", tf->tf_ds);
	printk("  trap 0x%08x %s\n", tf->tf_trapno, trapname(tf->tf_trapno));
	// If this trap was a page fault that just happened
	// (so %cr2 is meaningful), print the faulting linear address.
	if (tf->tf_trapno == T_PGFLT)
		printk("  cr2  0x%08x\n", rcr2());
	printk("  err  0x%08x", tf->tf_err);
	// For page faults, print decoded fault error code:
	// U/K=fault occurred in user/kernel mode
	// W/R=a write/read caused the fault
	// PR=a protection violation caused the fault (NP=page not present).
	if (tf->tf_trapno == T_PGFLT)
		printk(" [%s, %s, %s]\n",
			tf->tf_err & 4 ? "user" : "kernel",
			tf->tf_err & 2 ? "write" : "read",
			tf->tf_err & 1 ? "protection" : "not-present");
	else
		printk("\n");
	printk("  eip  0x%08x\n", tf->tf_eip);
	printk("  cs   0x----%04x\n", tf->tf_cs);
	printk("  flag 0x%08x\n", tf->tf_eflags);
	if ((tf->tf_cs & 3) != 0) {
		printk("  esp  0x%08x\n", tf->tf_esp);
		printk("  ss   0x----%04x\n", tf->tf_ss);
	}
	spin_unlock(&pflock);
}
开发者ID:Zhang626,项目名称:miniOS,代码行数:34,代码来源:interrupt.c

示例4: isr_pgfault

void
isr_pgfault(struct trapframe* tf) {
    (void) tf;

    uint32_t fault_addr = rcr2();
    print("fa: %x\n", fault_addr);
}
开发者ID:plurmiscuous,项目名称:JinxOS,代码行数:7,代码来源:vmm.c

示例5: page_fault_handler

void
page_fault_handler(struct Trapframe *tf)
{
	uint32_t fault_va;

	// Read processor's CR2 register to find the faulting address
	fault_va = rcr2();
	cprintf("fault_va: %x\n", fault_va);

	// Handle kernel-mode page faults.

	// LAB 3: Your code here.
	if ((tf->tf_cs&3) == 0) {
		panic("Kernel page fault!");
	}

	// We've already handled kernel-mode exceptions, so if we get here,
	// the page fault happened in user mode.

	// Call the environment's page fault upcall, if one exists.  Set up a
	// page fault stack frame on the user exception stack (below
	// UXSTACKTOP), then branch to curenv->env_pgfault_upcall.
	if (curenv->env_pgfault_upcall) {
		//
		// The page fault upcall might cause another page fault, in which case
		// we branch to the page fault upcall recursively, pushing another
		// page fault stack frame on top of the user exception stack.
		//
		// The trap handler needs one word of scratch space at the top of the
		// trap-time stack in order to return.  In the non-recursive case, we
		// don't have to worry about this because the top of the regular user
		// stack is free.  In the recursive case, this means we have to leave
		// an extra word between the current top of the exception stack and
		// the new stack frame because the exception stack _is_ the trap-time
		// stack.
		//
		// If there's no page fault upcall, the environment didn't allocate a
		// page for its exception stack or can't write to it, or the exception
		// stack overflows, then destroy the environment that caused the fault.
		// Note that the grade script assumes you will first check for the page
		// fault upcall and print the "user fault va" message below if there is
		// none.  The remaining three checks can be combined into a single test.
		//
		// Hints:
		//   user_mem_assert() and env_run() are useful here.
		//   To change what the user environment runs, modify 'curenv->env_tf'
		//   (the 'tf' variable points at 'curenv->env_tf').

		// LAB 4: Your code here.
	}

	// Destroy the environment that caused the fault.
	cprintf("[%08x] user fault va %08x ip %08x\n",
		curenv->env_id, fault_va, tf->tf_eip);
	print_trapframe(tf);
	env_destroy(curenv);
}
开发者ID:1060351485,项目名称:jos,代码行数:57,代码来源:trap.c

示例6: pgfault_handler

static int
pgfault_handler(struct trapframe *tf) {
    extern struct mm_struct *check_mm_struct;
    print_pgfault(tf);
    if (check_mm_struct != NULL) {
        return do_pgfault(check_mm_struct, tf->tf_err, rcr2());
    }
    panic("unhandled page fault.\n");
}
开发者ID:huhanGitHub,项目名称:Ucore,代码行数:9,代码来源:trap.c

示例7: kmm_pgfault

void
kmm_pgfault(struct trapframe *tf)
{
	// uint64_t  err  = tf->tf_err;
	uintptr_t addr = rcr2();

	if (addr >= PBASE && addr < PBASE + PSIZE)
	{
		pgd_t *pgd = KADDR_DIRECT(PTE_ADDR(rcr3()));
		pud_t *pud;
		pmd_t *pmd;
		pte_t *ptd;
		
		/* PHYSICAL ADDRRESS ACCESSING */
		if (last_pgd != NULL)
		{
			pud = KADDR_DIRECT(PGD_ADDR(last_pgd[PGX(last_addr)]));
			pmd = KADDR_DIRECT(PUD_ADDR(pud[PUX(last_addr)]));
			ptd = KADDR_DIRECT(PMD_ADDR(pmd[PMX(last_addr)]));

			ptd[PTX(last_addr)] = 0;
			if (ptd == temp_ptd)
			{
				pmd[PUX(last_addr)] = 0;
				if (pmd == temp_pmd)
				{
					pud[PUX(last_addr)] = 0;
					if (pud == temp_pud)
						last_pgd[PGX(last_addr)] = 0;
				}
				
				if (last_pgd == pgd)
				{
					invlpg((void *)last_addr);
				}
			}
		}

		if (pgd[PGX(last_addr)] == 0)
			pgd[PGX(last_addr)] = PADDR_DIRECT(temp_pud) | PTE_W | PTE_P;
		pud = KADDR_DIRECT(PGD_ADDR(pgd[PGX(last_addr)]));
		if (pud[PUX(last_addr)] == 0)
			pud[PUX(last_addr)] = PADDR_DIRECT(temp_pmd) | PTE_W | PTE_P;
		pmd = KADDR_DIRECT(PUD_ADDR(pud[PUX(last_addr)]));
		if (pmd[PMX(last_addr)] == 0)
			pmd[PMX(last_addr)] = PADDR_DIRECT(temp_ptd) | PTE_W | PTE_P;
		ptd = KADDR_DIRECT(PMD_ADDR(pmd[PMX(last_addr)]));

		ptd[PTX(last_addr)] = PADDR_DIRECT(addr) | PTE_W | PTE_P;

		last_pgd = pgd;
		last_addr = addr;

		/* XXX? */
		// invlpg((void *)addr);
	}
}
开发者ID:SteveHuang27,项目名称:ucore-x64-smp,代码行数:57,代码来源:kmm.c

示例8: print_pgfault

static inline void
print_pgfault(struct trapframe *tf) {
    /* error_code:
     * bit 0 == 0 means no page found, 1 means protection fault
     * bit 1 == 0 means read, 1 means write
     * bit 2 == 0 means kernel, 1 means user
     * */
    cprintf("page fault at 0x%08x: %c/%c [%s].\n", rcr2(),
            (tf->tf_err & 4) ? 'U' : 'K',
            (tf->tf_err & 2) ? 'W' : 'R',
            (tf->tf_err & 1) ? "protection fault" : "no page found");
}
开发者ID:huhanGitHub,项目名称:Ucore,代码行数:12,代码来源:trap.c

示例9: page_fault_handler

void
page_fault_handler(struct Trapframe *tf)
{
	u_int fault_va;

	// Read processor's CR2 register to find the faulting address
	fault_va = rcr2();


	// User-mode exception - destroy the environment.
	printf("[%08x] user fault va %08x ip %08x\n",
		curenv->env_id, fault_va, tf->tf_eip);
	print_trapframe(tf);
	env_destroy(curenv);
}
开发者ID:jjli418,项目名称:jos,代码行数:15,代码来源:trap.c

示例10: pgfault_handler

static int pgfault_handler(struct trapframe *tf)
{
	extern struct mm_struct *check_mm_struct;
	struct mm_struct *mm;
	if (check_mm_struct != NULL) {
		assert(pls_read(current) == pls_read(idleproc));
		mm = check_mm_struct;
	} else {
		if (pls_read(current) == NULL) {
			print_trapframe(tf);
			print_pgfault(tf);
			panic("unhandled page fault.\n");
		}
		mm = pls_read(current)->mm;
	}
	return do_pgfault(mm, tf->tf_err, rcr2());
}
开发者ID:TySag,项目名称:project,代码行数:17,代码来源:trap.c

示例11: trap_print

static void
trap_print(const struct trapframe *frame, const lwp_t *l)
{
	const int type = frame->tf_trapno;

	if (frame->tf_trapno < trap_types) {
		printf("fatal %s", trap_type[type]);
	} else {
		printf("unknown trap %d", type);
	}
	printf(" in %s mode\n", (type & T_USER) ? "user" : "supervisor");

	printf("trap type %d code %x eip %x cs %x eflags %x cr2 %lx "
	    "ilevel %x esp %x\n",
	    type, frame->tf_err, frame->tf_eip, frame->tf_cs, frame->tf_eflags,
	    (long)rcr2(), curcpu()->ci_ilevel, frame->tf_esp);

	printf("curlwp %p pid %d lid %d lowest kstack %p\n",
	    l, l->l_proc->p_pid, l->l_lid, KSTACK_LOWEST_ADDR(l));
}
开发者ID:goroutines,项目名称:rumprun,代码行数:20,代码来源:trap.c

示例12: page_fault_handler

void
page_fault_handler(struct Trapframe *tf)
{
	uint32_t fault_va;

	// Read processor's CR2 register to find the faulting address
	fault_va = rcr2();

	// Handle kernel-mode page faults.

	// LAB 3: Your code here.

	// We've already handled kernel-mode exceptions, so if we get here,
	// the page fault happened in user mode.

	// Destroy the environment that caused the fault.
	cprintf("[%08x] user fault va %08x ip %08x\n",
		curenv->env_id, fault_va, tf->tf_eip);
	print_trapframe(tf);
	env_destroy(curenv);
}
开发者ID:ouyangjn,项目名称:joos,代码行数:21,代码来源:trap.c

示例13: pgfault_handler

static int
pgfault_handler(struct trapframe *tf) {
    extern struct mm_struct *check_mm_struct;
    if(check_mm_struct !=NULL) { //used for test check_swap
            print_pgfault(tf);
        }
    struct mm_struct *mm;
    if (check_mm_struct != NULL) {
        assert(current == idleproc);
        mm = check_mm_struct;
    }
    else {
        if (current == NULL) {
            print_trapframe(tf);
            print_pgfault(tf);
            panic("unhandled page fault.\n");
        }
        mm = current->mm;
    }
    return do_pgfault(mm, tf->tf_err, rcr2());
}
开发者ID:thuyangyu,项目名称:ucore_lab,代码行数:21,代码来源:trap.c

示例14: pgflt_handler

void pgflt_handler(tf_t *tf)
{
	unsigned int cur_pid;
	unsigned int errno;
	unsigned int fault_va;

	cur_pid = get_curid();
	errno = tf -> err;
	fault_va = rcr2();

  //Uncomment this line if you need to see the information of the sequence of page faults occured.
	//KERN_DEBUG("Page fault: VA 0x%08x, errno 0x%08x, process %d, EIP 0x%08x.\n", fault_va, errno, cur_pid, tf -> eip);

	if (errno & PFE_PR) {
		trap_dump(tf);
		KERN_PANIC("Permission denied: va = 0x%08x, errno = 0x%08x.\n", fault_va, errno);
		return;
	}

	if (alloc_page(cur_pid, fault_va, PTE_W | PTE_U | PTE_P) == MagicNumber)
    KERN_PANIC("Page allocation failed: va = 0x%08x, errno = 0x%08x.\n", fault_va, errno);

}
开发者ID:shengnwen,项目名称:Yale-OperatingSystems,代码行数:23,代码来源:TTrapHandler.c

示例15: trap

//PAGEBREAK: 41
void
trap(struct trapframe *tf)
{
  if(tf->trapno == T_SYSCALL){
    if(proc->killed)
      exit();
    proc->tf = tf;
    syscall();
    if(proc->killed)
      exit();
    return;
  }

  switch(tf->trapno){
  case T_IRQ0 + IRQ_TIMER:
    if(cpu->id == 0){
      acquire(&tickslock);
      ticks++;
      wakeup(&ticks);
      release(&tickslock);
      extern struct {
        struct spinlock lock;
        struct proc proc[NPROC];
      } ptable;

      struct proc *p;

      acquire(&ptable.lock);
      for(p = ptable.proc; p < &ptable.proc[NPROC]; p++) {
          if (p->ticks > 0) {
              p->ticks--;
              if (p->ticks == 0) {
                  p->alarm = 1;
              }
          }
      }
      release(&ptable.lock);
    }
    lapiceoi();
    break;
  case T_IRQ0 + IRQ_IDE:
    ideintr();
    lapiceoi();
    break;
  case T_IRQ0 + IRQ_IDE+1:
    // Bochs generates spurious IDE1 interrupts.
    break;
  case T_IRQ0 + IRQ_KBD:
    kbdintr();
    lapiceoi();
    break;
  case T_IRQ0 + IRQ_COM1:
    uartintr();
    lapiceoi();
    break;
  case T_IRQ0 + 7:
  case T_IRQ0 + IRQ_SPURIOUS:
    cprintf("cpu%d: spurious interrupt at %x:%x\n",
            cpu->id, tf->cs, tf->eip);
    lapiceoi();
    break;

    case T_DIVIDE:
    cprintf("Divide by 0 exception\n");
    // Check if the process has a SIGFPE handler
    if (!(proc->sighandlers[SIGFPE] < 0)) {
        send_signal(tf, SIGFPE);
        break;
    }
    cprintf("No signal handler found\n");
    // If not let it fall through
   
  //PAGEBREAK: 13
  default:
    if(proc == 0 || (tf->cs&3) == 0){
      // In kernel, it must be our mistake.
      cprintf("unexpected trap %d from cpu %d eip %x (cr2=0x%x)\n",
              tf->trapno, cpu->id, tf->eip, rcr2());
      panic("trap");
    }
    // In user space, assume process misbehaved.
    cprintf("pid %d %s: trap %d err %d on cpu %d "
            "eip 0x%x addr 0x%x--kill proc\n",
            proc->pid, proc->name, tf->trapno, tf->err, cpu->id, tf->eip, 
            rcr2());
    proc->killed = 1;
  }

 if (proc != 0 && proc->state == RUNNING && proc->alarm > 0 && (tf->cs&3) == DPL_USER ) {
    proc->alarm = 0;
    cprintf("sending signal\n");
    send_signal(tf, SIGALRM);
  }
  // Process exit occurs when it has been killed & is in user space.
  // (If it is still in the kernel, keep running 
  // until returns with system call
  if(proc && proc->killed && (tf->cs&3) == DPL_USER)
    exit();

//.........这里部分代码省略.........
开发者ID:deanrexines,项目名称:xv6_stage1_fixed,代码行数:101,代码来源:trap.c


注:本文中的rcr2函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。