From cf078ec3598f0d427a8887f928c009fb66d001f7 Mon Sep 17 00:00:00 2001 From: Stefan Lankes Date: Wed, 2 Mar 2011 06:28:50 +0100 Subject: [PATCH] add a function to read the instruction pointer --- arch/x86/include/asm/processor.h | 2 ++ arch/x86/kernel/entry.asm | 19 ++++++++++++++++++- 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/arch/x86/include/asm/processor.h b/arch/x86/include/asm/processor.h index d6cdfd2e..f21b200f 100644 --- a/arch/x86/include/asm/processor.h +++ b/arch/x86/include/asm/processor.h @@ -119,6 +119,8 @@ static inline void tlb_flush(void) write_cr3(val); } +void read_eip(void); + /* * invalidate (not flush!) lines in L1 that map to MPB lines */ diff --git a/arch/x86/kernel/entry.asm b/arch/x86/kernel/entry.asm index 83633d20..e24e201a 100644 --- a/arch/x86/kernel/entry.asm +++ b/arch/x86/kernel/entry.asm @@ -106,6 +106,12 @@ idt_load: lidt [idtp] ret +global read_eip +read_eip: + pop eax ; Get the return address + jmp eax ; Return. Can't use RET because return + ; address popped off the stack. + ; In just a few pages in this tutorial, we will add our Interrupt ; Service Routines (ISRs) right here! global isr0 @@ -141,6 +147,7 @@ global isr29 global isr30 global isr31 global isrsyscall +global jump_to_child ; 0: Divide By Zero Exception isr0: @@ -446,6 +453,17 @@ isrsyscall: pop ebp iret +jump_to_child: + add esp, 4 + mov eax, 0 ; child got always zero as return value + pop ebx + pop ecx + pop edx + pop esi + pop edi + pop ebp + iret + global irq0 global irq1 global irq2 @@ -791,7 +809,6 @@ apic_svr: push byte 127 jmp irq_common_stub - irq_common_stub: pusha