TacOS  0.2
 Tout Structures de données Fichiers Fonctions Variables Définitions de type Énumérations Macros
context.h
Aller à la documentation de ce fichier.
1 
30 #ifndef _CONTEXT_H
31 #define _CONTEXT_H
32 
33 #include <kprocess.h>
34 
35 static inline void RESTORE_CONTEXT() __attribute__((always_inline));
36 static inline void PUSH_CONTEXT() __attribute__((always_inline));
37 
38 static inline void RESTORE_CONTEXT(){
39  asm(
40  /*On dépile les registres pour les mettre en place */
41  "pop %gs\n\t"
42  "pop %fs\n\t"
43  "pop %es\n\t"
44  "pop %ds\n\t"
45  "pop %edi\n\t"
46  "pop %esi\n\t"
47  "pop %ebp\n\t"
48  "pop %ebx\n\t"
49  "pop %edx\n\t"
50  "pop %ecx\n\t"
51  "pop %eax\n\t"
52 
53  /* Et on switch! (enfin! >_<) */
54  "iret\n\t"
55  );
56 }
57 
58 static inline void PUSH_CONTEXT(process_t* current) {
59  asm(
60  "push %0\n\t"
61  "push %1\n\t"
62  "push %2\n\t"
63  "push %3\n\t"
64  "push %4\n\t"
65  "push %5\n\t"
66  ::"m" (current->regs.eax),
67  "m" (current->regs.ecx),
68  "m" (current->regs.edx),
69  "m" (current->regs.ebx),
70  "m" (current->regs.ebp),
71  "m" (current->regs.esi)
72  );
73  asm(
74  "push %0\n\t"
75  "push %1\n\t"
76  "push %2\n\t"
77  "push %3\n\t"
78  "push %4\n\t"
79  ::
80  "m" (current->regs.edi),
81  "m" (current->regs.ds),
82  "m" (current->regs.es),
83  "m" (current->regs.fs),
84  "m" (current->regs.gs)
85  );
86 }
87 
88 
89 #endif /* _CONTEXT_H */
Structure représentant un processus.
Definition: kprocess.h:92
Création de nouveaux processus.