Rev 210 | Rev 430 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 210 | Rev 414 | ||
---|---|---|---|
Line 29... | Line 29... | ||
29 | #ifndef __CONTEXT_H__ |
29 | #ifndef __CONTEXT_H__ |
30 | #define __CONTEXT_H__ |
30 | #define __CONTEXT_H__ |
31 | 31 | ||
32 | #include <arch/types.h> |
32 | #include <arch/types.h> |
33 | #include <typedefs.h> |
33 | #include <typedefs.h> |
- | 34 | #include <arch/context.h> |
|
- | 35 | ||
34 | 36 | ||
35 | #ifndef context_set |
37 | #ifndef context_set |
36 | #define context_set(c, _pc, stack, size) \ |
38 | #define context_set(c, _pc, stack, size) \ |
37 | (c)->pc = (__address) (_pc); \ |
39 | (c)->pc = (__address) (_pc); \ |
38 | (c)->sp = ((__address) (stack)) + (size) - SP_DELTA; |
40 | (c)->sp = ((__address) (stack)) + (size) - SP_DELTA; |
39 | #endif /* context_set */ |
41 | #endif /* context_set */ |
40 | 42 | ||
41 | extern int context_save(context_t *c); |
43 | extern int context_save_arch(context_t *c); |
42 | extern void context_restore(context_t *c) __attribute__ ((noreturn)); |
44 | extern 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 | */ |
|
- | 58 | static 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 | */ |
|
- | 79 | static inline void context_restore(context_t *c) |
|
- | 80 | { |
|
- | 81 | context_restore_arch(c); |
|
- | 82 | } |
|
43 | 83 | ||
44 | #endif |
84 | #endif |