本文整理汇总了C++中print_trapframe函数的典型用法代码示例。如果您正苦于以下问题:C++ print_trapframe函数的具体用法?C++ print_trapframe怎么用?C++ print_trapframe使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了print_trapframe函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: 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.
if(tf->tf_cs && 0x01 == 0) {
panic("page_fault in kernel mode, fault address %d\n", fault_va);
}
// 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:Xmagicer,项目名称:6.828mit,代码行数:23,代码来源:trap.c
示例2: syscall
void syscall(void)
{
assert(current != NULL);
struct trapframe *tf = current->tf;
uint32_t arg[5];
int num = tf->tf_regs.reg_r[MIPS_REG_V0];
//num -= T_SYSCALL;
//kprintf("$ %d %d\n",current->pid, num);
if (num >= 0 && num < NUM_SYSCALLS) {
if (syscalls[num] != NULL) {
arg[0] = tf->tf_regs.reg_r[MIPS_REG_A0];
arg[1] = tf->tf_regs.reg_r[MIPS_REG_A1];
arg[2] = tf->tf_regs.reg_r[MIPS_REG_A2];
arg[3] = tf->tf_regs.reg_r[MIPS_REG_A3];
arg[4] = tf->tf_regs.reg_r[MIPS_REG_T0];
tf->tf_regs.reg_r[MIPS_REG_V0] = syscalls[num] (arg);
return;
}
}
print_trapframe(tf);
panic("undefined syscall %d, pid = %d, name = %s.\n",
num, current->pid, current->name);
}
开发者ID:Aresthu,项目名称:ucore_plus,代码行数:23,代码来源:syscall.c
示例3: unhandled_trap
static void
unhandled_trap(struct hw_trapframe *state, const char* name)
{
static spinlock_t screwup_lock = SPINLOCK_INITIALIZER;
spin_lock(&screwup_lock);
if(in_kernel(state))
{
print_trapframe(state);
panic("Unhandled trap in kernel!\nTrap type: %s", name);
}
else
{
char tf_buf[1024];
format_trapframe(state, tf_buf, sizeof(tf_buf));
warn("Unhandled trap in user!\nTrap type: %s\n%s", name, tf_buf);
backtrace();
spin_unlock(&screwup_lock);
assert(current);
proc_destroy(current);
}
}
开发者ID:kanojs,项目名称:akaros,代码行数:24,代码来源:trap.c
示例4: trap_dispatch
static void
trap_dispatch(struct Trapframe *tf)
{
// Handle processor exceptions.
// LAB 3: Your code here.
int32_t ret;
switch (tf->tf_trapno){
case T_PGFLT:{ //14
page_fault_handler(tf);
return;
}
case T_BRKPT:{ //3
breakpoint_handler(tf);
return;
}
case T_DEBUG:{
breakpoint_handler(tf);
return;
}
case T_SYSCALL:{
ret = system_call_handler(tf);
tf->tf_regs.reg_eax = ret;
return;
}
case IRQ_OFFSET+IRQ_TIMER:{
lapic_eoi();
time_tick();
sched_yield();
return;
}
case IRQ_OFFSET+IRQ_KBD:{
kbd_intr();
return;
}
case IRQ_OFFSET+IRQ_SERIAL:{
serial_intr();
return;
}
case IRQ_OFFSET+IRQ_E1000:{
e1000_trap_handler();
return;
}
}
// Handle spurious interrupts
// The hardware sometimes raises these because of noise on the
// IRQ line or other reasons. We don't care.
if (tf->tf_trapno == IRQ_OFFSET + IRQ_SPURIOUS) {
cprintf("Spurious interrupt on irq 7\n");
print_trapframe(tf);
return;
}
// Handle clock interrupts. Don't forget to acknowledge the
// interrupt using lapic_eoi() before calling the scheduler!
// LAB 4: Your code here.
// Add time tick increment to clock interrupts.
// Be careful! In multiprocessors, clock interrupts are
// triggered on every CPU.
// LAB 6: Your code here.
// Handle keyboard and serial interrupts.
// LAB 5: Your code here.
// Unexpected trap: The user process or the kernel has a bug.
print_trapframe(tf);
if (tf->tf_cs == GD_KT)
panic("unhandled trap in kernel");
else {
env_destroy(curenv);
return;
}
}
开发者ID:1060351485,项目名称:6.828-JOS,代码行数:77,代码来源:trap.c
示例5: trap_dispatch
static void
trap_dispatch(struct trapframe *tf) {
char c;
int ret;
static int counter = 0;
switch (tf->tf_trapno) {
case T_PGFLT: //page fault
if ((ret = pgfault_handler(tf)) != 0) {
print_trapframe(tf);
panic("handle pgfault failed. %e\n", ret);
}
break;
case IRQ_OFFSET + IRQ_TIMER:
#if 0
LAB3 : If some page replacement algorithm(such as CLOCK PRA) need tick to change the priority of pages,
then you can add code here.
#endif
/* LAB1 2010011358: STEP 3 */
/* handle the timer interrupt */
/* (1) After a timer interrupt, you should record this event using a global variable (increase it), such as ticks in kern/driver/clock.c
* (2) Every TICK_NUM cycle, you can print some info using a funciton, such as print_ticks().
* (3) Too Simple? Yes, I think so!
*/
if (++counter == TICK_NUM){
counter = 0;
print_ticks();
}
break;
case IRQ_OFFSET + IRQ_COM1:
c = cons_getc();
cprintf("serial [%03d] %c\n", c, c);
break;
case IRQ_OFFSET + IRQ_KBD:
c = cons_getc();
cprintf("kbd [%03d] %c\n", c, c);
break;
//LAB1 CHALLENGE 1 : YOUR CODE you should modify below codes.
case T_SWITCH_TOU:
asm volatile( "cli;");
tf->tf_ds = 0x23;
tf->tf_es = 0x23;
tf->tf_fs = 0x23;
tf->tf_gs = 0x23;
tf->tf_eflags = tf->tf_eflags | 0x200;
tf->tf_eflags = tf->tf_eflags | 0x3000;
tf->tf_ss = 0x23;
tf->tf_cs = 0x1B;
tf->tf_esp = tf->tf_regs.reg_eax;
break;
case T_SWITCH_TOK:
asm volatile( "cli;");
tf->tf_ds = 0x10;
tf->tf_es = 0x10;
tf->tf_fs = 0x10;
tf->tf_gs = 0x10;
tf->tf_eflags = tf->tf_eflags | 0x200;
tf->tf_eflags = tf->tf_eflags & ~0x3000U | 0x1000U;
tf->tf_ss = 0x10;
tf->tf_cs = 0x8;
break;
case IRQ_OFFSET + IRQ_IDE1:
case IRQ_OFFSET + IRQ_IDE2:
/* do nothing */
break;
default:
// in kernel, it must be a mistake
if ((tf->tf_cs & 3) == 0) {
print_trapframe(tf);
panic("unexpected trap in kernel.\n");
}
}
}
开发者ID:xxr3376,项目名称:my_ucore_lab,代码行数:74,代码来源:trap.c
示例6: 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();
if(!(tf->tf_cs & 0x3))
{
// This happens in kernel mode
if(page_fault_mode == PFM_NONE) {
int i;
u_long ebp = tf->tf_ebp;
for(i = 0; i < 3; i++) {
ebp = backtrace_intrap(ebp);
}
panic("Aiee, page fault in kernel mode va %08x ip %08x\n", fault_va, tf->tf_eip);
}
else
{
Pte *pte;
u_long va = fault_va;
printf("[%08x] PFM_KILL va %08x ip %08x\n",
curenv->env_id, fault_va, tf->tf_eip);
printf("curenv->env_pgdir[PDX(va)] = %08x\n", curenv->env_pgdir[PDX(va)]);
pte = KADDR(PTE_ADDR(curenv->env_pgdir[PDX(va)]));
printf("pte[PTX(va)] = %08x\n", pte[PTX(va)]);
page_fault_mode = PFM_NONE;
env_destroy(curenv);
}
return;
}
if(curenv->env_pgfault_entry)
{
u_int newsp;
struct user_stack_frame *us;
if(tf->tf_esp > UXSTACKTOP-BY2PG &&
tf->tf_esp < UXSTACKTOP)
{
//Page fault within UXSTACKTOP
newsp = tf->tf_esp - 8; // Reserve 2 words for eip and eflags
}
else
{
newsp = UXSTACKTOP;
}
if(newsp < UXSTACKTOP-BY2PG)
goto fail;
//printf("Trap env[%08x] va %08x ip %08x\n", curenv->env_id, fault_va, tf->tf_eip);
//print_trapframe(tf);
//printf("newsp = %08x, tf->tf_esp = %08x\n", newsp, tf->tf_esp);
us = (struct user_stack_frame *)(newsp - sizeof(struct user_stack_frame));
us->fault_va = fault_va;
us->tf_err = tf->tf_err;
us->esp = tf->tf_esp;
us->eip = tf->tf_eip;
us->eflags = tf->tf_eflags;
tf->tf_esp = newsp;
tf->tf_eip = curenv->env_pgfault_entry;
return;
}
fail:
// 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:BGCX262,项目名称:zt-jos-svn-to-git,代码行数:70,代码来源:trap.c
示例7: trap_dispatch
static void
trap_dispatch(struct trapframe *tf) {
char c;
int ret=0;
switch (tf->tf_trapno) {
case T_PGFLT: //page fault
if ((ret = pgfault_handler(tf)) != 0) {
print_trapframe(tf);
if (current == NULL) {
panic("handle pgfault failed. ret=%d\n", ret);
}
else {
if (trap_in_kernel(tf)) {
panic("handle pgfault failed in kernel mode. ret=%d\n", ret);
}
cprintf("killed by kernel.\n");
panic("handle user mode pgfault failed. ret=%d\n", ret);
do_exit(-E_KILLED);
}
}
break;
case T_SYSCALL:
syscall();
break;
case IRQ_OFFSET + IRQ_TIMER:
#if 0
LAB3 : If some page replacement algorithm(such as CLOCK PRA) need tick to change the priority of pages,
then you can add code here.
#endif
/* LAB1 2011010312 : STEP 3 */
/* handle the timer interrupt */
/* (1) After a timer interrupt, you should record this event using a global variable (increase it), such as ticks in kern/driver/clock.c
* (2) Every TICK_NUM cycle, you can print some info using a funciton, such as print_ticks().
* (3) Too Simple? Yes, I think so!
*/
/* LAB5 2011010312 */
/* you should upate you lab1 code (just add ONE or TWO lines of code):
* Every TICK_NUM cycle, you should set current process's current->need_resched = 1
*/
ticks++;
if(ticks == TICK_NUM) {
ticks = 0;
current->need_resched = 1;
}
break;
case IRQ_OFFSET + IRQ_COM1:
c = cons_getc();
cprintf("serial [%03d] %c\n", c, c);
break;
case IRQ_OFFSET + IRQ_KBD:
c = cons_getc();
cprintf("kbd [%03d] %c\n", c, c);
break;
//LAB1 CHALLENGE 1 : YOUR CODE you should modify below codes.
case T_SWITCH_TOU:
case T_SWITCH_TOK:
panic("T_SWITCH_** ??\n");
break;
case IRQ_OFFSET + IRQ_IDE1:
case IRQ_OFFSET + IRQ_IDE2:
/* do nothing */
break;
default:
print_trapframe(tf);
if (current != NULL) {
cprintf("unhandled trap.\n");
do_exit(-E_KILLED);
}
// in kernel, it must be a mistake
panic("unexpected trap in kernel.\n");
}
}
开发者ID:thuyangyu,项目名称:ucore_lab,代码行数:75,代码来源:trap.c
示例8: trap_dispatch
static void
trap_dispatch(struct trapframe *tf) {
char c;
int ret=0;
switch (tf->tf_trapno) {
case T_PGFLT: //page fault
if ((ret = pgfault_handler(tf)) != 0) {
print_trapframe(tf);
if (current == NULL) {
panic("handle pgfault failed. ret=%d\n", ret);
}
else {
if (trap_in_kernel(tf)) {
panic("handle pgfault failed in kernel mode. ret=%d\n", ret);
}
cprintf("killed by kernel.\n");
panic("handle user mode pgfault failed. ret=%d\n", ret);
do_exit(-E_KILLED);
}
}
break;
case T_SYSCALL:
syscall();
break;
case IRQ_OFFSET + IRQ_TIMER:
#if 0
LAB3 : If some page replacement algorithm(such as CLOCK PRA) need tick to change the priority of pages,
then you can add code here.
#endif
/* LAB1 YOUR CODE : STEP 3 */
/* handle the timer interrupt */
/* (1) After a timer interrupt, you should record this event using a global variable (increase it), such as ticks in kern/driver/clock.c
* (2) Every TICK_NUM cycle, you can print some info using a funciton, such as print_ticks().
* (3) Too Simple? Yes, I think so!
*/
/* LAB5 YOUR CODE */
/* you should upate you lab1 code (just add ONE or TWO lines of code):
* Every TICK_NUM cycle, you should set current process's current->need_resched = 1
*/
/* LAB6 YOUR CODE */
/* IMPORTANT FUNCTIONS:
* run_timer_list
*----------------------
* you should update your lab5 code (just add ONE or TWO lines of code):
* Every tick, you should update the system time, iterate the timers, and trigger the timers which are end to call scheduler.
* You can use one funcitons to finish all these things.
*/
ticks ++;
run_timer_list();
break;
case IRQ_OFFSET + IRQ_COM1:
c = cons_getc();
cprintf("serial [%03d] %c\n", c, c);
break;
case IRQ_OFFSET + IRQ_KBD:
c = cons_getc();
cprintf("kbd [%03d] %c\n", c, c);
break;
//LAB1 CHALLENGE 1 : 13307130148 you should modify below codes.
case T_SWITCH_TOU:
cprintf("To user mode\n");
if (tf->tf_cs != USER_CS) {
tfk2u = *tf;
tfk2u.tf_cs = USER_CS;
tfk2u.tf_ds = tfk2u.tf_es = tfk2u.tf_ss = USER_DS;
tfk2u.tf_esp = (uint32_t)tf + sizeof(struct trapframe) - 8;
tfk2u.tf_eflags |= (3 << 12);
*((uint32_t *)tf - 1) = (uint32_t)&tfk2u;
}
break;
case T_SWITCH_TOK:
cprintf("To kernel mode\n");
//panic("T_SWITCH_** ??\n");
struct trapframe *tfu2k;
if (tf->tf_cs != KERNEL_CS) {
tf->tf_cs = KERNEL_CS;
tf->tf_ds = tf->tf_es = KERNEL_DS;
tf->tf_eflags &= ~(3 << 12);
tfu2k = (struct trapframe*)((uint32_t)tf->tf_esp - sizeof(struct trapframe) + 8);
memmove(tfu2k, tf, sizeof(struct trapframe)-8);
*((uint32_t *)tf - 1) = (uint32_t)tfu2k;
}
break;
case IRQ_OFFSET + IRQ_IDE1:
case IRQ_OFFSET + IRQ_IDE2:
/* do nothing */
break;
default:
print_trapframe(tf);
if (current != NULL) {
cprintf("unhandled trap.\n");
do_exit(-E_KILLED);
}
// in kernel, it must be a mistake
panic("unexpected trap in kernel.\n");
}
//.........这里部分代码省略.........
开发者ID:czy941030,项目名称:ucore_lab,代码行数:101,代码来源:trap.c
示例9: trap_dispatch
static void
trap_dispatch(struct Trapframe *tf)
{
// Handle processor exceptions.
// LAB 3: Your code here.
if (tf->tf_trapno == T_BRKPT) {
print_trapframe(tf);
// cprintf("Breakpoint!\n");
while (1)
monitor(NULL);
} else if (tf->tf_trapno == T_PGFLT) {
page_fault_handler(tf);
return;
} else if (tf->tf_trapno == T_SYSCALL) {
uint32_t syscallno;
uint32_t a1, a2, a3, a4, a5;
syscallno = tf->tf_regs.reg_eax;
a1 = tf->tf_regs.reg_edx;
a2 = tf->tf_regs.reg_ecx;
a3 = tf->tf_regs.reg_ebx;
a4 = tf->tf_regs.reg_edi;
a5 = tf->tf_regs.reg_esi;
int32_t ret = syscall(syscallno, a1, a2, a3, a4, a5);
tf->tf_regs.reg_eax = ret;
return;
}
// Handle spurious interrupts
// The hardware sometimes raises these because of noise on the
// IRQ line or other reasons. We don't care.
if (tf->tf_trapno == IRQ_OFFSET + IRQ_SPURIOUS) {
cprintf("Spurious interrupt on irq 7\n");
print_trapframe(tf);
return;
}
// Handle clock interrupts. Don't forget to acknowledge the
// interrupt using lapic_eoi() before calling the scheduler!
// LAB 4: Your code here.
if (tf->tf_trapno == IRQ_OFFSET + IRQ_TIMER) {
time_tick();
lapic_eoi(); /* what's that? */
sched_yield();
}
// Handle keyboard and serial interrupts.
// LAB 5: Your code here.
if (tf->tf_trapno == IRQ_OFFSET + IRQ_KBD) {
kbd_intr();
return;
}
if (tf->tf_trapno == IRQ_OFFSET + IRQ_SERIAL) {
serial_intr();
return;
}
// Unexpected trap: The user process or the kernel has a bug.
print_trapframe(tf);
if (tf->tf_cs == GD_KT)
panic("unhandled trap in kernel");
else {
env_destroy(curenv);
return;
}
}
开发者ID:joe-cai,项目名称:jos,代码行数:65,代码来源:trap.c
示例10: trap_dispatch
static void
trap_dispatch(struct trapframe *tf) {
char c;
int ret;
switch (tf->tf_trapno) {
case T_PGFLT: //page fault
if ((ret = pgfault_handler(tf)) != 0) {
print_trapframe(tf);
panic("handle pgfault failed. %e\n", ret);
}
break;
case IRQ_OFFSET + IRQ_TIMER:
#if 0
LAB3 : If some page replacement algorithm(such as CLOCK PRA) need tick to change the priority of pages,
then you can add code here.
#endif
/* LAB1 YOUR CODE : STEP 3 */
/* handle the timer interrupt */
/* (1) After a timer interrupt, you should record this event using a global variable (increase it), such as ticks in kern/driver/clock.c
* (2) Every TICK_NUM cycle, you can print some info using a funciton, such as print_ticks().
* (3) Too Simple? Yes, I think so!
*/
ticks ++;
if (ticks % TICK_NUM == 0)
print_ticks();
break;
case IRQ_OFFSET + IRQ_COM1:
c = cons_getc();
cprintf("serial [%03d] %c\n", c, c);
break;
case IRQ_OFFSET + IRQ_KBD:
c = cons_getc();
cprintf("kbd [%03d] %c\n", c, c);
if (c == '0')
{
user2kernel(tf);
}
if (c == '3')
{
kernel2user(tf);
}
print_trapframe(tf);
break;
//LAB1 CHALLENGE 1 : YOUR CODE you should modify below codes.
case T_SWITCH_TOU:
kernel2user(tf);
/* if (tf->tf_cs != USER_CS)
{
switchk2u = *tf;
switchk2u.tf_cs = USER_CS;
switchk2u.tf_ds = switchk2u.tf_es = switchk2u.tf_ss = USER_DS;
switchk2u.tf_esp = (uint32_t)tf + sizeof(struct trapframe)-8;
switchk2u.tf_eflags |= FL_IOPL_MASK;
*((uint32_t *)tf -1) = (uint32_t)&switchk2u;
}*/
break;
case T_SWITCH_TOK:
//panic("T_SWITCH_** ??\n");
user2kernel(tf);
/* if (tf->tf_cs != KERNEL_CS)
{
tf->tf_cs = KERNEL_CS;
tf->tf_ds = tf->tf_es = KERNEL_DS;
tf->tf_eflags &= ~FL_IOPL_MASK;
switchu2k = (struct trapframe *)(tf->tf_esp - (sizeof(struct trapframe)-8));
memmove(switchu2k, tf, sizeof(struct trapframe)-8);
*((uint32_t*)tf-1) = (uint32_t)switchu2k;
}*/
break;
case IRQ_OFFSET + IRQ_IDE1:
case IRQ_OFFSET + IRQ_IDE2:
/* do nothing */
break;
default:
// in kernel, it must be a mistake
if ((tf->tf_cs & 3) == 0) {
print_trapframe(tf);
panic("unexpected trap in kernel.\n");
}
}
}
开发者ID:sjyfok,项目名称:moocos,代码行数:85,代码来源:trap.c
示例11: 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.
if (tf->tf_cs == GD_KT) {
print_trapframe(tf);
panic("kernel page fault va %08x ip %08x env %x\n",
fault_va, tf->tf_eip, curenv->env_id);
}
// 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.
//
// 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.
if (!curenv->env_pgfault_upcall) {
goto destroy;
}
// Check that exception stack is allocated
user_mem_assert(curenv, (void *)(UXSTACKTOP - 4), 4, 0);
uintptr_t exstack;
struct UTrapframe *utf;
// Figure out top where trapframe should end, leaving 1 word scratch space
if (tf->tf_esp >= UXSTACKTOP-PGSIZE && tf->tf_esp <= UXSTACKTOP-1) {
exstack = tf->tf_esp - 4; // recursive
}
else {
exstack = UXSTACKTOP; // non-recursive
}
// Check if enough space to copy trapframe
if ((exstack - sizeof(struct UTrapframe)) < UXSTACKTOP-PGSIZE) {
goto destroy;
}
// Set up UTrapframe on exception stack
utf = (struct UTrapframe *) (exstack - sizeof(struct UTrapframe));
utf->utf_fault_va = fault_va;
utf->utf_err = tf->tf_err;
utf->utf_regs = tf->tf_regs;
utf->utf_eip = tf->tf_eip;
utf->utf_eflags = tf->tf_eflags;
utf->utf_esp = tf->tf_esp;
// Fix trapframe to return to user handler
tf->tf_esp = (uintptr_t) utf;
tf->tf_eip = (uintptr_t) curenv->env_pgfault_upcall;
env_run(curenv);
panic("Unreachable code!\n");
destroy:
// 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:bosswissam,项目名称:djos,代码行数:94,代码来源:trap.c
示例12: trap_dispatch
static void
trap_dispatch(struct Trapframe *tf)
{
// Handle processor exceptions.
// LAB 3: Your code here.
switch(tf->tf_trapno) {
case T_PGFLT:
page_fault_handler(tf);
return;
case T_BRKPT:
case T_DEBUG:
monitor(tf);
return;
case T_SYSCALL:
tf->tf_regs.reg_eax = syscall(tf->tf_regs.reg_eax, // syscall #
tf->tf_regs.reg_edx, // arg1
tf->tf_regs.reg_ecx, // arg2
tf->tf_regs.reg_ebx, // arg3
tf->tf_regs.reg_edi, // arg4
tf->tf_regs.reg_esi);// arg5
return;
}
// Handle spurious interrupts
// The hardware sometimes raises these because of noise on the
// IRQ line or other reasons. We don't care.
if (tf->tf_trapno == IRQ_OFFSET + IRQ_SPURIOUS) {
cprintf("Spurious interrupt on irq 7\n");
print_trapframe(tf);
return;
}
// Handle clock interrupts. Don't forget to acknowledge the
// interrupt using lapic_eoi() before calling the scheduler!
// Add time tick increment to clock interrupts.
// Be careful! In multiprocessors, clock interrupts are
// triggered on every CPU.
// LAB 4: Your code here.
// LAB 6: Your code here.
if (tf->tf_trapno == IRQ_OFFSET + IRQ_TIMER) {
time_tick();
lapic_eoi();
sched_yield();
return;
}
// Handle keyboard and serial interrupts.
// LAB 7: Your code here.
if (tf->tf_trapno == IRQ_OFFSET + IRQ_SERIAL) {
serial_intr();
return;
}
if (tf->tf_trapno == IRQ_OFFSET + IRQ_KBD) {
kbd_intr();
return;
}
// Unexpected trap: The user process or the kernel has a bug.
print_trapframe(tf);
if (tf->tf_cs == GD_KT)
panic("unhandled trap in kernel");
else {
env_destroy(curenv);
return;
}
}
开发者ID:bosswissam,项目名称:djos,代码行数:67,代码来源:trap.c
示例13: trap_dispatch
static void
trap_dispatch(struct trapframe *tf) {
char c;
int ret=0;
switch (tf->tf_trapno) {
case T_PGFLT: //page fault
if ((ret = pgfault_handler(tf)) != 0) {
print_trapframe(tf);
if (current == NULL) {
panic("handle pgfault failed. ret=%d\n", ret);
}
else {
if (trap_in_kernel(tf)) {
panic("handle pgfault failed in kernel mode. ret=%d\n", ret);
}
cprintf("killed by kernel.\n");
panic("handle user mode pgfault failed. ret=%d\n", ret);
do_exit(-E_KILLED);
}
}
break;
case T_SYSCALL:
syscall();
break;
case IRQ_OFFSET + IRQ_TIMER:
#if 0
LAB3 : If some page replacement algorithm(such as CLOCK PRA) need tick to change the priority of pages,
then you can add code here.
#endif
/* LAB1 YOUR CODE : STEP 3 */
/* handle the timer interrupt */
/* (1) After a timer interrupt, you should record this event using a global variable (increase it), such as ticks in kern/driver/clock.c
* (2) Every TICK_NUM cycle, you can print some info using a funciton, such as print_ticks().
* (3) Too Simple? Yes, I think so!
*/
/* LAB5 2014011421 */
/* you should upate you lab1 code (just add ONE or TWO lines of code):
* Every TICK_NUM cycle, you should set current process's current->need_resched = 1
*/
/* LAB6 2014011421 */
/* you should upate you lab5 code
* IMPORTANT FUNCTIONS:
* sched_class_proc_tick
*/
/* LAB7 2014011421 */
/* you should upate you lab6 code
* IMPORTANT FUNCTIONS:
* run_timer_list
*/
ticks++;
run_timer_list();
break;
case IRQ_OFFSET + IRQ_COM1:
c = cons_getc();
cprintf("serial [%03d] %c\n", c, c);
break;
case IRQ_OFFSET + IRQ_KBD:
// There are user level shell in LAB8, so we need change COM/KBD interrupt processing.
c = cons_getc();
{
extern void dev_stdin_write(char c);
dev_stdin_write(c);
}
break;
//LAB1 CHALLENGE 1 : YOUR CODE you should modify below codes.
case T_SWITCH_TOU:
if (tf->tf_cs != USER_CS) {
switchk2u = *tf;
switchk2u.tf_cs = USER_CS;
switchk2u.tf_ds = switchk2u.tf_es = switchk2u.tf_ss = USER_DS;
switchk2u.tf_esp = (uint32_t)tf + sizeof(struct trapframe) - 8;
// set eflags, make sure ucore can use io under user mode.
// if CPL > IOPL, then cpu will generate a general protection.
switchk2u.tf_eflags |= FL_IOPL_MASK;
// set temporary stack
// then iret will jump to the right stack
*((uint32_t *)tf - 1) = (uint32_t)&switchk2u;
}
break;
case T_SWITCH_TOK:
if (tf->tf_cs != KERNEL_CS) {
tf->tf_cs = KERNEL_CS;
tf->tf_ds = tf->tf_es = KERNEL_DS;
tf->tf_eflags &= ~FL_IOPL_MASK;
switchu2k = (struct trapframe *)(tf->tf_esp - (sizeof(struct trapframe) - 8));
memmove(switchu2k, tf, sizeof(struct trapframe) - 8);
*((uint32_t *)tf - 1) = (uint32_t)switchu2k;
}
break;
case IRQ_OFFSET + IRQ_IDE1:
case IRQ_OFFSET + IRQ_IDE2:
/* do nothing */
break;
default:
print_trapframe(tf);
if (current != NULL) {
//.........这里部分代码省略.........
开发者ID:18813112822,项目名称:ucore_os,代码行数:101,代码来源:trap.c
示例14: trap_dispatch
static void
trap_dispatch(struct trapframe *tf) {
char c;
switch (tf->tf_trapno) {
case IRQ_OFFSET + IRQ_TIMER:
/* LAB1 YOUR CODE : STEP 3 */
/* handle the timer interrupt */
/* (1) After a timer interrupt, you should record this event using a global variable (increase it), such as ticks in kern/driver/clock.c
* (2) Every TICK_NUM cycle, you can print some info using a funciton, such as print_ticks().
* (3) Too Simple? Yes, I think so!
*/
ticks++;
if (ticks >= TICK_NUM)
{
print_ticks();
ticks = 0;
}
break;
case IRQ_OFFSET + IRQ_COM1:
c = cons_getc();
cprintf("serial [%03d] %c\n", c, c);
break;
case IRQ_OFFSET + IRQ_KBD:
c = cons_getc();
cprintf("kbd [%03d] %c\n", c, c);
break;
//LAB1 CHALLENGE 1 : YOUR CODE you should modify below codes.
case T_SWITCH_TOU:
if (tf->tf_cs != USER_CS)
{
k2u = *tf;
k2u.tf_cs = USER_CS;
k2u.tf_ds = k2u.tf_es = k2u.tf_ss = USER_DS;
k2u.tf_esp = (uint32_t)tf + sizeof(struct trapframe) - 8;
k2u.tf_eflags |= FL_IOPL_MASK;
*((uint32_t *)tf - 1) = (uint32_t)&k2u;
}
break;
case T_SWITCH_TOK:
if (tf->tf_cs != KERNEL_CS)
{
tf->tf_cs = KERNEL_CS;
tf->tf_ds = tf->tf_es = KERNEL_DS;
tf->tf_eflags = tf->tf_eflags & ~FL_IOPL_MASK;
u2k = *((struct trapframe*)(tf->tf_esp - (sizeof(struct trapframe) - 8)));
memmove(&u2k, tf, sizeof(struct trapframe) - 8);
*((uint32_t *)tf - 1) = (uint32_t)&u2k;
}
//panic("T_SWITCH_** ??\n");
break;
case IRQ_OFFSET + IRQ_IDE1:
case IRQ_OFFSET + IRQ_IDE2:
/* do nothing */
break;
default:
// in kernel, it must be a mistake
if ((tf->tf_cs & 3) == 0) {
print_trapframe(tf);
panic("unexpected trap in kernel.\n");
}
}
}
开发者ID:zhangjunqi13,项目名称:ucore_lab,代码行数:63,代码来源:trap.c
示例15: trap_dispatch
static void
trap_dispatch(struct Trapframe *tf)
{
// Handle processor exceptions.
// LAB 3: Your code here.
//---------------------------------------- Lab3 ------------------------------------------------------------
if (tf->tf_trapno == T_PGFLT) {
//cprintf("pagefault!\n");
page_fault_handler(tf);
return;
}
if (tf->tf_trapno == T_BRKPT) {
//cprintf("brkpt!\n");
monitor(tf);
return;
}
if (tf->tf_trapno == T_DEBUG) {
my_monitor(tf);
return;
}
if (tf->tf_trapno == T_SYSCALL) {
//cprintf("Syscall!\n");
tf->tf_regs.reg_eax = syscall(tf->tf_regs.reg_eax, tf->tf_regs.reg_edx, tf->tf_regs.reg_ecx,
tf->tf_regs.reg_ebx, tf->tf_regs.reg_edi, tf->tf_regs.reg_esi);
if (tf->tf_regs.reg_eax < 0)
panic("syscall failed: %e\n", tf->tf_regs.reg_eax);
return;
}
//---------------------------------------- Lab3 ------------------------------------------------------------
// Handle spurious interrupts
// The hardware sometimes raises these because of noise on the
// IRQ line or other reasons. We don't care.
if (tf->tf_trapno == IRQ_OFFSET + IRQ_SPURIOUS) {
cprintf("Spurious interrupt on irq 7\n");
print_trapframe(tf);
return;
}
// Handle clock interrupts. Don't forget to acknowledge the
// interrupt using lapic_eoi() before calling the scheduler!
// LAB 4: Your code here.
//------------ Lab4 ----------------------------------------------------------------------------------------
if (tf->tf_trapno == IRQ_OFFSET + IRQ_TIMER) {
// cprintf("clock interrupt!\n");
lapic_eoi();
sched_yield();
return;
}
//------------ Lab4 ----------------------------------------------------------------------------------------
// Unexpected trap: The user process or the kernel has a bug.
print_trapframe(tf);
if (tf->tf_cs == GD_KT)
panic("unhandled trap in kernel");
else {
env_destroy(curenv);
return;
}
}
开发者ID:CuiZhicheng,项目名称:JOS,代码行数:61,代码来源:trap.c
示例16: 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.
//cprintf("SUNUS : tf eip = %08x\n",tf->tf_eip);
//sunus_dbg(0,3,page_fault_handler);
if((tf->tf_cs & 0x3) != 0x3)
panic("page_fault_handler @ %08x\n",fault_va);
// 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.
//
// 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.
// JAN,10,SUNUS
if(curenv->env_pgfault_upcall)
{
struct UTrapframe utf;
utf.utf_fault_va =fault_va;
utf.utf_err = tf->tf_err;
utf.utf_regs = tf->tf_regs;
utf.utf_eip = tf->tf_eip;
utf.utf_eip = tf->tf_eip;
utf.utf_eflags = tf->tf_eflags;
utf.utf_esp = tf->tf_esp;
if(tf->tf_esp >= (UXSTACKTOP - PGSIZE) && tf->tf_esp <= UXSTACKTOP) /* check if it's in another PGFLT */
{
//LINE 277-279
tf->tf_esp -= 4;
user_mem_assert(curenv, (const void *)(tf->tf_esp - sizeof(utf) - 4), sizeof(utf), PTE_W|PTE_U);// -4 is the extra 32bit
}
else
{
tf->tf_esp = UXSTACKTOP;
user_mem_assert(curenv, (const void *)(tf->tf_esp - sizeof(utf)), sizeof(utf), PTE_W|PTE_U);
}
tf->tf_esp -= sizeof(utf);
if(tf->tf_esp < (UXSTACKTOP - PGSIZE))
{
cprintf("tf->tf_esp < UXSTACKTOP - PGSIZE!\n");
env_destroy(curenv);
return;
}
memmove((void *)(tf->tf_esp), &utf, sizeof(struct UTrapframe));
tf->tf_eip = (uintptr_t)curenv->env_pgfault_upcall;
env_run(curenv);
}
// 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:sunuslee,项目名称:sunus_jos,代码行数:85,代码来源:trap.c
示例17: trap_dispatch
static void
trap_dispatch(struct Trapframe *tf)
{
// Handle processor exceptions.
// LAB 3: Your code here.
// dec 15,2010 sunus
switch(tf->tf_trapno)
{
case T_PGFLT :
{
page_fault_handler(tf);
break;
}
case T_DEBUG :
cprintf("encounter a breakpoint!\n"); /*fall through*/
case T_BRKPT :
{
monitor(tf);
break;
}
case T_SYSCALL :
{
(tf->tf_regs).reg_eax =
syscall(
(tf->tf_regs).reg_eax,
(tf->tf_regs).reg_edx,
(tf->tf_regs).reg_ecx,
(tf->tf_regs).reg_ebx,
(tf->tf_regs).reg_edi,
(tf->tf_regs).reg_esi);
return ;
}
default : ; /* do nothing */
}
// Handle clock interrupts.
// LAB 4: Your code here.
// JAN 30,2011,SUNUS
if(tf->tf_trapno == IRQ_OFFSET + IRQ_TIMER)
{
sched_yield();
return;
}
// Handle spurious interrupts
// The hardware sometimes raises these because of noise on the
// IRQ line or other reasons. We don't care.
if (tf->tf_trapno == IRQ_OFFSET + IRQ_SPURIOUS) {
cprintf("Spurious interrupt on irq 7\n");
print_trapframe(tf);
return;
}
// Unexpected trap: The user process or the kernel has a bug.
print_trapframe(tf);
if (tf->tf_cs == GD_KT)
panic("unhandled trap in kernel");
else {
env_destroy(curenv);
return;
}
}
开发者ID:sunuslee,项目名称:sunus_jos,代码行数:63,代码来源:trap.c
示例18: trap_dispatch
static void
trap_dispatch(struct Trapframe *tf)
{
static int page_to_age = 0;
int page_to_age_first = page_to_age;
int num_page_updates = NPAGEUPDATES_FACTOR*NPAGESFREE_LOW_THRESHOLD;
struct PteChain *pp_refs_chain;
char page_accessed;
// Handle processor exceptions.
// LAB 3: Your code here.
if (tf->tf_trapno == T_PGFLT) {
page_fault_handler(tf);
return;
}
else if (tf->tf_trapno == T_BRKPT) {
monitor(tf); // breakpoint exceptions invoke the kernel monitor
return;
}
else if (tf->tf_trapno == T_SYSCALL) {
tf->tf_regs.reg_eax = syscall(tf->tf_regs.reg_eax, tf->tf_regs.reg_edx, tf->tf_regs.reg_ecx, tf->tf_regs.reg_ebx, tf->tf_regs.reg_edi, tf->tf_regs.reg_esi);
return;
}
// Handle spurious interrupts
// The hardware sometimes raises these because of noise on the
// IRQ line or other reasons. We don't care.
if (tf->tf_trapno == IRQ_OFFSET + IRQ_SPURIOUS) {
cprintf("Spurious interrupt on irq 7\n");
print_trapframe(tf);
return;
}
// Handle clock interrupts. Don't forget to acknowledge the
// interrupt using lapic_eoi() before calling the scheduler!
// LAB 4: Your code here.
if (tf->tf_trapno == IRQ_OFFSET + IRQ_TIMER) {
lapic_eoi();
// Update the age of some
|
请发表评论