Fork us on GitHub Follow us on Facebook Follow us on Twitter

Changeset 0aee9b4 in mainline


Ignore:
Timestamp:
2014-09-02T20:31:13Z (7 years ago)
Author:
Jakub Jermar <jakub@…>
Branches:
lfn, master
Children:
b3222a3
Parents:
4dc7a84
Message:

Autogenerate amd64 kernel context_t and its offsets.

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

Legend:

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

    r4dc7a84 r0aee9b4  
    8888
    8989ARCH_AUTOGENS_AG = \
    90         arch/$(KARCH)/include/arch/istate_struct.ag
     90        arch/$(KARCH)/include/arch/istate_struct.ag \
     91        arch/$(KARCH)/include/arch/context_struct.ag
    9192
  • kernel/arch/amd64/include/arch/context.h

    r4dc7a84 r0aee9b4  
    3636#define KERN_amd64_CONTEXT_H_
    3737
    38 #include <typedefs.h>
     38#include <arch/context_struct.h>
    3939
    4040/*
     
    5252        } while (0)
    5353
    54 /* We include only registers that must be preserved
    55  * during function call
    56  */
    57 typedef struct {
    58         uintptr_t sp;
    59         uintptr_t pc;
    60        
    61         uint64_t rbx;
    62         uint64_t rbp;
    63        
    64         uint64_t r12;
    65         uint64_t r13;
    66         uint64_t r14;
    67         uint64_t r15;
    68        
    69         ipl_t ipl;
    70 } __attribute__ ((packed)) context_t;
    71 
    7254#endif
    7355
  • kernel/arch/amd64/src/context.S

    r4dc7a84 r0aee9b4  
    3232.global context_restore_arch
    3333
    34 #include <arch/context_offset.h>
     34#include <arch/context_struct.h>
    3535
    3636## Save current CPU context
     
    4343       
    4444        # 1st argument passed in %edi
    45         CONTEXT_SAVE_ARCH_CORE %rdi %rdx
     45        movq %rdx, CONTEXT_OFFSET_PC(%rdi)
     46        movq %rsp, CONTEXT_OFFSET_SP(%rdi)
     47       
     48        movq %rbx, CONTEXT_OFFSET_RBX(%rdi)
     49        movq %rbp, CONTEXT_OFFSET_RBP(%rdi)
     50        movq %r12, CONTEXT_OFFSET_R12(%rdi)
     51        movq %r13, CONTEXT_OFFSET_R13(%rdi)
     52        movq %r14, CONTEXT_OFFSET_R14(%rdi)
     53        movq %r15, CONTEXT_OFFSET_R15(%rdi)
    4654       
    4755        xorl %eax, %eax       # context_save returns 1
     
    5664#
    5765context_restore_arch:
    58         CONTEXT_RESTORE_ARCH_CORE %rdi %rdx
     66        movq CONTEXT_OFFSET_R15(%rdi), %r15
     67        movq CONTEXT_OFFSET_R14(%rdi), %r14
     68        movq CONTEXT_OFFSET_R13(%rdi), %r13
     69        movq CONTEXT_OFFSET_R12(%rdi), %r12
     70        movq CONTEXT_OFFSET_RBP(%rdi), %rbp
     71        movq CONTEXT_OFFSET_RBX(%rdi), %rbx
     72       
     73        movq CONTEXT_OFFSET_SP(%rdi), %rsp   # ctx->sp -> %rsp
     74       
     75        movq CONTEXT_OFFSET_PC(%rdi), %rdx
    5976       
    6077        movq %rdx, (%rsp)
     
    6279        xorl %eax, %eax       # context_restore returns 0
    6380        ret
     81
Note: See TracChangeset for help on using the changeset viewer.