kern

view src/proc-asm.S @ 73:b4b7198986a6

fixed a potential null dereference when deleting a bug in the redblack tree
author John Tsiombikas <nuclear@member.fsf.org>
date Sat, 15 Oct 2011 08:06:10 +0300
parents 437360696883
children
line source
1 .text
2 /* switch_stack(uint32_t new_stack, uint32_t *old_stack_ptr)
3 * switches to the new stack and returns the old stack pointer, which is
4 * also copied to the address passed as the second argument.
5 */
6 .globl switch_stack
7 switch_stack:
8 movl %esp, %eax /* old stack in eax */
9 movl 8(%esp), %edx
10 cmpl $0, %edx /* if old_stack_ptr is null, skip ahead */
11 jz oldp_is_null
12 movl %eax, (%edx) /* otherwise *old_stack_ptr = eax */
13 oldp_is_null:
14 movl 4(%esp), %esp /* set the new stack */
15 ret
17 /* get_instr_stack_ptr(uint32_t *eip, uint32_t *esp)
18 * returns the current instruction and stack pointers at the same
19 * point in execution, so that a newly-forked process with these
20 * values will just return from this function and continue on.
21 */
22 .globl get_instr_stack_ptr
23 get_instr_stack_ptr:
24 call get_instr_ptr
25 movl %eax, 4(%esp)
26 movl %esp, 8(%esp)
27 ret
29 /* get_instr_ptr(void)
30 * returns the address of the next instruction after the call to this function
31 */
32 .globl get_instr_ptr
33 get_instr_ptr:
34 movl (%esp), %eax
35 ret
37 /* get_caller_instr_ptr(void)
38 * returns the address of the next instruction after the call to the function that
39 * called this function.
40 * NOTE: will only work properly when called from a function that uses ebp to point
41 * to its stack frame, which means all of the C functions but pretty much none of
42 * our assembly functions.
43 */
44 .globl get_caller_instr_ptr
45 get_caller_instr_ptr:
46 movl 4(%ebp), %eax
47 ret
49 /* this is where we end up when we first context_switch to a newly forked
50 * process. The interrupt frame is already there, so we just call intr_ret
51 * to return to user space
52 */
53 .globl just_forked
54 just_forked:
55 call intr_ret