Changeset 5eae56a in mainline


Ignore:
Timestamp:
2014-09-03T20:50:12Z (10 years ago)
Author:
Jakub Jermar <jakub@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
4b334fd6
Parents:
e74b24f
Message:

Autogenerate ia32 kernel context_t and its offsets.

Location:
kernel/arch/ia32
Files:
1 added
1 deleted
3 edited

Legend:

Unmodified
Added
Removed
  • kernel/arch/ia32/Makefile.inc

    re74b24f r5eae56a  
    107107
    108108ARCH_AUTOGENS_AG = \
    109         arch/$(KARCH)/include/arch/istate_struct.ag
     109        arch/$(KARCH)/include/arch/istate_struct.ag \
     110        arch/$(KARCH)/include/arch/context_struct.ag
    110111
  • kernel/arch/ia32/include/arch/context.h

    re74b24f r5eae56a  
    3737
    3838#include <typedefs.h>
     39#include <arch/context_struct.h>
    3940
    4041#define STACK_ITEM_SIZE  4
     
    5556        } while (0)
    5657
    57 /*
    58  * Only save registers that must be preserved across
    59  * function calls.
    60  */
    61 typedef struct {
    62         uintptr_t sp;
    63         uintptr_t pc;
    64         uint32_t ebx;
    65         uint32_t esi;
    66         uint32_t edi;
    67         uint32_t ebp;
    68         ipl_t ipl;
    69 } __attribute__ ((packed)) context_t;
    70 
    7158#endif
    7259
  • kernel/arch/ia32/src/context.S

    re74b24f r5eae56a  
    2727#
    2828
    29 #include <arch/context_offset.h>
     29#include <arch/context_struct.h>
    3030
    3131.text
     
    4141#
    4242context_save_arch:
    43         movl 0(%esp),%eax       # save pc value into eax       
    44         movl 4(%esp),%edx       # address of the context variable to save context to
     43        movl 0(%esp), %eax      # save pc value into eax       
     44        movl 4(%esp), %edx      # address of the context variable to save context to
    4545
    46                 # save registers to given structure
    47         CONTEXT_SAVE_ARCH_CORE %edx %eax
     46        # save registers to given structure
     47        movl %esp, CONTEXT_OFFSET_SP(%edx)      # %esp -> ctx->sp
     48        movl %eax, CONTEXT_OFFSET_PC(%edx)      # %eip -> ctx->pc
     49        movl %ebx, CONTEXT_OFFSET_EBX(%edx)     # %ebx -> ctx->ebx
     50        movl %esi, CONTEXT_OFFSET_ESI(%edx)     # %esi -> ctx->esi
     51        movl %edi, CONTEXT_OFFSET_EDI(%edx)     # %edi -> ctx->edi
     52        movl %ebp, CONTEXT_OFFSET_EBP(%edx)     # %ebp -> ctx->ebp
    4853
    49         xorl %eax,%eax          # context_save returns 1
     54        xorl %eax, %eax         # context_save returns 1
    5055        incl %eax
    5156        ret
     
    5863#
    5964context_restore_arch:
    60         movl 4(%esp),%eax       # address of the context variable to restore context from
     65        movl 4(%esp), %eax      # address of the context variable to restore context from
    6166
    62                 # restore registers from given structure
    63         CONTEXT_RESTORE_ARCH_CORE %eax %edx
     67        # restore registers from given structure
     68        movl CONTEXT_OFFSET_SP(%eax), %esp      # ctx->sp -> %esp
     69        movl CONTEXT_OFFSET_PC(%eax), %edx      # ctx->pc -> \pc
     70        movl CONTEXT_OFFSET_EBX(%eax), %ebx     # ctx->ebx -> %ebx
     71        movl CONTEXT_OFFSET_ESI(%eax), %esi     # ctx->esi -> %esi
     72        movl CONTEXT_OFFSET_EDI(%eax), %edi     # ctx->edi -> %edi
     73        movl CONTEXT_OFFSET_EBP(%eax), %ebp     # ctx->ebp -> %ebp
    6474
    65         movl %edx,0(%esp)       # put saved pc on stack
    66         xorl %eax,%eax          # context_restore returns 0
     75        movl %edx, 0(%esp)      # put saved pc on stack
     76        xorl %eax, %eax         # context_restore returns 0
    6777        ret
     78
Note: See TracChangeset for help on using the changeset viewer.