Changeset 4b2c872d in mainline


Ignore:
Timestamp:
2005-10-18T09:33:02Z (19 years ago)
Author:
Jakub Jermar <jakub@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
8005218
Parents:
22f7769
Message:

Create generic context_save() and context_restore().
These two functions are defined inline and only call context_save_arch() and context_restore_arch(), respectively.
The main purpose of this is to enable centralized commenting of these important and tricky functions.

Files:
17 edited

Legend:

Unmodified
Added
Removed
  • arch/amd64/include/context.h

    r22f7769 r4b2c872d  
    4545 */
    4646struct context {
    47     __u64 sp;
    48     __u64 pc;
     47    __address sp;
     48    __address pc;
    4949   
    5050    __u64 rbx;
  • arch/amd64/src/context.S

    r22f7769 r4b2c872d  
    2929.text
    3030
    31 .global context_save
    32 .global context_restore
     31.global context_save_arch
     32.global context_restore_arch
    3333
    3434#include <arch/context_offset.h>
     
    3636## Save current CPU context
    3737#
    38 # Save CPU context to the kernel_context variable
     38# Save CPU context to context_t variable
    3939# pointed by the 1st argument. Returns 1 in EAX.
    4040#
    41 context_save:
     41context_save_arch:
    4242        movq (%rsp), %rdx     # the caller's return %eip
    4343        # In %edi is passed 1st argument
     
    5959## Restore current CPU context
    6060#
    61 # Restore CPU context from the kernel_context variable
     61# Restore CPU context from context_t variable
    6262# pointed by the 1st argument. Returns 0 in EAX.
    6363#
    64 context_restore:       
     64context_restore_arch:   
    6565        movq OFFSET_R15(%rdi), %r15
    6666        movq OFFSET_R14(%rdi), %r14
  • arch/ia32/include/context.h

    r22f7769 r4b2c872d  
    4747 */
    4848struct context {
    49         __u32 sp;
    50         __u32 pc;
     49        __address sp;
     50        __address pc;
    5151        __u32 ebx;
    5252        __u32 esi;
  • arch/ia32/src/context.s

    r22f7769 r4b2c872d  
    2929.text
    3030
    31 .global context_save
    32 .global context_restore
     31.global context_save_arch
     32.global context_restore_arch
    3333
    3434
    3535## Save current CPU context
    3636#
    37 # Save CPU context to the kernel_context variable
     37# Save CPU context to the context_t variable
    3838# pointed by the 1st argument. Returns 1 in EAX.
    3939#
    40 context_save:
     40context_save_arch:
    4141        movl 0(%esp),%eax       # the caller's return %eip
    4242        movl 4(%esp),%edx       # address of the kernel_context variable to save context to
     
    5454
    5555
    56 ## Restore current CPU context
     56## Restore saved CPU context
    5757#
    58 # Restore CPU context from the kernel_context variable
     58# Restore CPU context from context_t variable
    5959# pointed by the 1st argument. Returns 0 in EAX.
    6060#
    61 context_restore:
     61context_restore_arch:
    6262        movl 4(%esp),%eax       # address of the kernel_context variable to restore context from
    6363        movl 0(%eax),%esp       # ctx->sp -> %esp
  • arch/ia64/include/context.h

    r22f7769 r4b2c872d  
    3131
    3232#include <arch/types.h>
     33#include <typedefs.h>
    3334#include <align.h>
    3435
     
    5152        (c)->pc = (__address) _pc;                                                      \
    5253        (c)->bsp = ((__address) stack) + ALIGN(sizeof(the_t), STACK_ALIGNMENT);         \
    53         (c)->sp = ((__address) stack) + ALIGN((size) - SP_DELTA, STACK_ALIGNMENT);
     54        (c)->sp = ((__address) stack) + ALIGN((size), STACK_ALIGNMENT) - SP_DELTA;
    5455
    5556/*
     
    6667        __u64 ar_unat_callee;
    6768        __u64 ar_rsc;
    68         __u64 bsp;      /* ar_bsp */
     69        __address bsp;          /* ar_bsp */
    6970        __u64 ar_rnat;
    7071        __u64 ar_lc;
     
    7879        __u64 r6;
    7980        __u64 r7;
    80         __u64 sp;               /* r12 */
     81        __address sp;           /* r12 */
    8182        __u64 r13;
    8283       
     
    8485         * Branch registers
    8586         */
    86         __u64 pc;               /* b0 */
     87        __address pc;           /* b0 */
    8788        __u64 b1;
    8889        __u64 b2;
  • arch/ia64/src/context.S

    r22f7769 r4b2c872d  
    2929.text
    3030
    31 .global context_save
    32 .global context_restore
     31.global context_save_arch
     32.global context_restore_arch
    3333
    34 context_save:
     34context_save_arch:
    3535        alloc loc0 = ar.pfs, 1, 8, 0, 0
    3636        mov loc1 = ar.unat      ;;
     
    113113        br.ret.sptk.many b0
    114114
    115 context_restore:
     115context_restore_arch:
    116116        alloc loc0 = ar.pfs, 1, 8, 0, 0 ;;
    117117
  • arch/mips32/include/context.h

    r22f7769 r4b2c872d  
    4949 */
    5050struct context {
    51         __u32 sp;
    52         __u32 pc;
     51        __address sp;
     52        __address pc;
    5353       
    5454        __u32 s0;
  • arch/mips32/src/context.S

    r22f7769 r4b2c872d  
    3737.set nomacro
    3838
    39 .global context_save
    40 .global context_restore
     39.global context_save_arch
     40.global context_restore_arch
    4141
    4242.macro CONTEXT_STORE r
     
    7373
    7474       
    75 context_save:
     75context_save_arch:
    7676        CONTEXT_STORE $a0
    7777
     
    8080        li $2, 1       
    8181       
    82 context_restore:
     82context_restore_arch:
    8383        CONTEXT_LOAD $a0
    8484
  • arch/ppc32/include/context.h

    r22f7769 r4b2c872d  
    3636struct context {
    3737        __u32 r0;
    38         __u32 sp;
     38        __address sp;
    3939        __u32 r2;
    4040        __u32 r3;
     
    6767        __u32 r30;
    6868        __u32 r31;
    69         __u32 pc;
     69        __address pc;
    7070        ipl_t ipl;
    7171} __attribute__ ((packed));
  • arch/ppc32/src/context.S

    r22f7769 r4b2c872d  
    3131.text   
    3232
    33 .global context_save
    34 .global context_restore
     33.global context_save_arch
     34.global context_restore_arch
    3535
    36 context_save:
     36context_save_arch:
    3737        REGISTERS_STORE r3
    3838       
     
    4444        blr
    4545       
    46 context_restore:
     46context_restore_arch:
    4747        REGISTERS_LOAD r3
    4848       
  • include/context.h

    r22f7769 r4b2c872d  
    3232#include <arch/types.h>
    3333#include <typedefs.h>
     34#include <arch/context.h>
     35
    3436
    3537#ifndef context_set
     
    3941#endif /* context_set */
    4042
    41 extern int context_save(context_t *c);
    42 extern void context_restore(context_t *c) __attribute__ ((noreturn));
     43extern int context_save_arch(context_t *c);
     44extern void context_restore_arch(context_t *c) __attribute__ ((noreturn));
     45
     46/** Save register context.
     47 *
     48 * Save current register context (including stack pointers)
     49 * to context structure.
     50 *
     51 * Note that call to context_restore() will return at the same
     52 * address as the corresponding call to context_save().
     53 *
     54 * @param c Context structure.
     55 *
     56 * @return context_save() returns 1, context_restore() returns 0.
     57 */
     58static inline int context_save(context_t *c)
     59{
     60        return context_save_arch(c);
     61}
     62
     63/** Restore register context.
     64 *
     65 * Restore previously saved register context (including stack pointers)
     66 * from context structure.
     67 *
     68 * Note that this function does not normally return.
     69 * Instead, it returns at the same address as the
     70 * corresponding call to context_save(), the only
     71 * difference being return value.
     72 *
     73 * Note that content of any local variable defined by
     74 * the caller of context_save() is undefined after
     75 * context_restore().
     76 *
     77 * @param c Context structure.
     78 */
     79static inline void context_restore(context_t *c)
     80{
     81        context_restore_arch(c);
     82}
    4383
    4484#endif
  • src/main/main.c

    r22f7769 r4b2c872d  
    247247         * switch to this cpu's private stack prior to waking kmp up.
    248248         */
    249         context_set(&CPU->saved_context, FADDR(main_ap_separated_stack), CPU->stack, CPU_STACK_SIZE);
     249        context_set(&CPU->saved_context, FADDR(main_ap_separated_stack), (__address) CPU->stack, CPU_STACK_SIZE);
    250250        context_restore(&CPU->saved_context);
    251251        /* not reached */
  • src/proc/scheduler.c

    r22f7769 r4b2c872d  
    314314         */
    315315        context_save(&CPU->saved_context);
    316         context_set(&CPU->saved_context, FADDR(scheduler_separated_stack), CPU->stack, CPU_STACK_SIZE);
     316        context_set(&CPU->saved_context, FADDR(scheduler_separated_stack), (__address) CPU->stack, CPU_STACK_SIZE);
    317317        context_restore(&CPU->saved_context);
    318318        /* not reached */
  • src/proc/thread.c

    r22f7769 r4b2c872d  
    196196               
    197197                context_save(&t->saved_context);
    198                 context_set(&t->saved_context, FADDR(cushion), t->kstack, THREAD_STACK_SIZE);
     198                context_set(&t->saved_context, FADDR(cushion), (__address) t->kstack, THREAD_STACK_SIZE);
    199199               
    200200                the_initialize((the_t *) t->kstack);
  • src/synch/waitq.c

    r22f7769 r4b2c872d  
    3131#include <synch/spinlock.h>
    3232#include <proc/thread.h>
     33#include <proc/scheduler.h>
    3334#include <arch/asm.h>
    3435#include <arch/types.h>
  • tools/amd64/gencontext.c

    r22f7769 r4b2c872d  
    44typedef long long __u64;
    55typedef __u64 ipl_t;
     6typedef __u64 __address;
    67
    78#define __amd64_TYPES_H__
  • tools/mips32/gencontext.c

    r22f7769 r4b2c872d  
    11#include <stdio.h>
    2 
    32
    43typedef unsigned int __u32;
    54typedef __u32 ipl_t;
     5typedef __u32 __address;
    66
    77#define __mips32_TYPES_H__
Note: See TracChangeset for help on using the changeset viewer.