Kevin O'Connor | 3df600b | 2013-09-14 19:28:55 -0400 | [diff] [blame] | 1 | // Misc function and variable declarations. |
| 2 | #ifndef __STACKS_H |
| 3 | #define __STACKS_H |
| 4 | |
| 5 | #include "types.h" // u32 |
| 6 | |
Kevin O'Connor | 55215cd | 2014-04-11 11:20:41 -0400 | [diff] [blame^] | 7 | #define CALL32SMM_CMDID 0xb5 |
| 8 | #define CALL32SMM_ENTERID 0x1234 |
| 9 | #define CALL32SMM_RETURNID 0x5678 |
| 10 | |
Kevin O'Connor | 3df600b | 2013-09-14 19:28:55 -0400 | [diff] [blame] | 11 | // stacks.c |
Kevin O'Connor | 55215cd | 2014-04-11 11:20:41 -0400 | [diff] [blame^] | 12 | extern int HaveSmmCall32; |
Kevin O'Connor | 1389eee | 2014-09-29 19:08:57 -0400 | [diff] [blame] | 13 | u32 call32(void *func, u32 eax, u32 errret); |
Kevin O'Connor | 3df600b | 2013-09-14 19:28:55 -0400 | [diff] [blame] | 14 | extern u8 ExtraStack[], *StackPos; |
| 15 | u32 stack_hop(u32 eax, u32 edx, void *func); |
| 16 | u32 stack_hop_back(u32 eax, u32 edx, void *func); |
Kevin O'Connor | fabc1b5 | 2014-09-29 19:18:25 -0400 | [diff] [blame] | 17 | int on_extra_stack(void); |
Kevin O'Connor | 3df600b | 2013-09-14 19:28:55 -0400 | [diff] [blame] | 18 | struct bregs; |
Kevin O'Connor | 79c3ab3 | 2014-09-30 00:11:38 -0400 | [diff] [blame] | 19 | void farcall16(struct bregs *callregs); |
| 20 | void farcall16big(struct bregs *callregs); |
| 21 | void __call16_int(struct bregs *callregs, u16 offset); |
Kevin O'Connor | 3df600b | 2013-09-14 19:28:55 -0400 | [diff] [blame] | 22 | #define call16_int(nr, callregs) do { \ |
| 23 | extern void irq_trampoline_ ##nr (); \ |
| 24 | __call16_int((callregs), (u32)&irq_trampoline_ ##nr ); \ |
| 25 | } while (0) |
Kevin O'Connor | 43197a2 | 2014-06-06 13:49:33 -0400 | [diff] [blame] | 26 | void reset(void); |
Kevin O'Connor | 3df600b | 2013-09-14 19:28:55 -0400 | [diff] [blame] | 27 | extern struct thread_info MainThread; |
| 28 | struct thread_info *getCurThread(void); |
| 29 | void yield(void); |
| 30 | void yield_toirq(void); |
Kevin O'Connor | d29ce62 | 2014-04-07 12:15:34 -0400 | [diff] [blame] | 31 | void thread_init(void); |
| 32 | int threads_during_optionroms(void); |
Kevin O'Connor | 3df600b | 2013-09-14 19:28:55 -0400 | [diff] [blame] | 33 | void run_thread(void (*func)(void*), void *data); |
| 34 | void wait_threads(void); |
| 35 | struct mutex_s { u32 isLocked; }; |
| 36 | void mutex_lock(struct mutex_s *mutex); |
| 37 | void mutex_unlock(struct mutex_s *mutex); |
| 38 | void start_preempt(void); |
| 39 | void finish_preempt(void); |
| 40 | int wait_preempt(void); |
| 41 | void check_preempt(void); |
Kevin O'Connor | 7f54bf7 | 2013-12-30 22:04:28 -0500 | [diff] [blame] | 42 | u32 call32_params(void *func, u32 eax, u32 edx, u32 ecx, u32 errret); |
Kevin O'Connor | 3df600b | 2013-09-14 19:28:55 -0400 | [diff] [blame] | 43 | |
Kevin O'Connor | fabc1b5 | 2014-09-29 19:18:25 -0400 | [diff] [blame] | 44 | // Inline functions |
| 45 | |
| 46 | // Check if a call to stack_hop_back is needed. |
| 47 | static inline int |
| 48 | need_hop_back(void) |
| 49 | { |
Kevin O'Connor | 8056825 | 2014-09-29 19:39:31 -0400 | [diff] [blame] | 50 | return !MODESEGMENT || on_extra_stack(); |
Kevin O'Connor | fabc1b5 | 2014-09-29 19:18:25 -0400 | [diff] [blame] | 51 | } |
| 52 | |
Kevin O'Connor | 3df600b | 2013-09-14 19:28:55 -0400 | [diff] [blame] | 53 | #endif // stacks.h |