c9ae4ab8b108bbd2b9165058f36b13dfd0319d6a
[pintos-anon] / src / threads / switch.h
1 #ifndef HEADER_SWITCH_H
2 #define HEADER_SWITCH_H 1
3
4 #ifndef __ASSEMBLER__
5 /* switch_thread()'s stack frame. */
6 struct switch_frame 
7   {
8     uint32_t ebx;               /*  0: Saved %ebx. */
9     uint32_t ebp;               /*  4: Saved %ebp. */
10     uint32_t esi;               /*  8: Saved %esi. */
11     uint32_t edi;               /* 12: Saved %edi. */
12     void (*eip) (void);         /* 16: Return address. */
13     struct thread *cur;         /* 20: thread_switch()'s CUR argument. */
14     struct thread *next;        /* 24: thread_switch()'s NEXT argument. */
15   };
16
17 /* Switches from CUR, which must be the running thread, to NEXT,
18    which must also be running thread_switch(), returning CUR in
19    NEXT's context. */
20 struct thread *switch_threads (struct thread *cur, struct thread *next);
21
22 struct switch_thunk_frame 
23   {
24     void (*eip) (void);
25   };
26
27 /* Pops the CUR and NEXT arguments off the stack, for use in
28    initializing threads. */
29 void switch_thunk (void);
30 #endif
31
32 /* Offsets used by switch.S. */
33 #define SWITCH_CUR      20
34 #define SWITCH_NEXT     24
35
36 #endif /* switch.h */