kern

annotate src/proc-asm.S @ 57:437360696883

I think we're done for now. two processes seem to be scheduled and switched just fine, fork seems to work (NO CoW YET!)
author John Tsiombikas <nuclear@member.fsf.org>
date Tue, 16 Aug 2011 03:26:53 +0300
parents 4eaecb14fe31
children 64a574189824
rev   line source
nuclear@54 1 .text
nuclear@57 2 /* switch_stack(uint32_t new_stack, uint32_t *old_stack_ptr)
nuclear@57 3 * switches to the new stack and returns the old stack pointer, which is
nuclear@57 4 * also copied to the address passed as the second argument.
nuclear@54 5 */
nuclear@54 6 .globl switch_stack
nuclear@54 7 switch_stack:
nuclear@57 8 movl %esp, %eax /* old stack in eax */
nuclear@57 9 movl 8(%esp), %edx
nuclear@57 10 cmpl $0, %edx /* if old_stack_ptr is null, skip ahead */
nuclear@57 11 jz oldp_is_null
nuclear@57 12 movl %eax, (%edx) /* otherwise *old_stack_ptr = eax */
nuclear@57 13 oldp_is_null:
nuclear@57 14 movl 4(%esp), %esp /* set the new stack */
nuclear@54 15 ret
nuclear@57 16
nuclear@57 17 /* get_instr_stack_ptr(uint32_t *eip, uint32_t *esp)
nuclear@57 18 * returns the current instruction and stack pointers at the same
nuclear@57 19 * point in execution, so that a newly-forked process with these
nuclear@57 20 * values will just return from this function and continue on.
nuclear@57 21 */
nuclear@57 22 .globl get_instr_stack_ptr
nuclear@57 23 get_instr_stack_ptr:
nuclear@57 24 call get_instr_ptr
nuclear@57 25 movl %eax, 4(%esp)
nuclear@57 26 movl %esp, 8(%esp)
nuclear@57 27 ret
nuclear@57 28
nuclear@57 29 /* get_instr_ptr(void)
nuclear@57 30 * returns the address of the next instruction after the call to this function
nuclear@57 31 */
nuclear@57 32 .globl get_instr_ptr
nuclear@57 33 get_instr_ptr:
nuclear@57 34 movl (%esp), %eax
nuclear@57 35 ret
nuclear@57 36
nuclear@57 37 /* get_caller_instr_ptr(void)
nuclear@57 38 * returns the address of the next instruction after the call to the function that
nuclear@57 39 * called this function.
nuclear@57 40 * NOTE: will only work properly when called from a function that uses ebp to point
nuclear@57 41 * to its stack frame, which means all of the C functions but pretty much none of
nuclear@57 42 * our assembly functions.
nuclear@57 43 */
nuclear@57 44 .globl get_caller_instr_ptr
nuclear@57 45 get_caller_instr_ptr:
nuclear@57 46 movl 4(%ebp), %eax
nuclear@57 47 ret
nuclear@57 48
nuclear@57 49 .globl just_forked
nuclear@57 50 just_forked:
nuclear@57 51 call intr_ret