1 /* 2 * This file is in the public domain. 3 */ 4 5 #ifndef _MACHINE_STACK_H_ 6 #define _MACHINE_STACK_H_ 7 8 #include <x86/stack.h> 9 10 #ifdef _SYS_PROC_H_ 11 12 /* Get the current kernel thread stack usage. */ 13 #define GET_STACK_USAGE(total, used) do { \ 14 struct thread *td = curthread; \ 15 (total) = td->td_kstack_pages * PAGE_SIZE; \ 16 (used) = td->td_kstack + td->td_kstack_pages * PAGE_SIZE - \ 17 (char *)&td; \ 18 } while (0) 19 20 static __inline bool 21 kstack_contains(struct thread *td, vm_offset_t va, size_t len) 22 { 23 return (va >= (vm_offset_t)td->td_kstack && va + len >= va && 24 va + len <= (vm_offset_t)td->td_kstack + td->td_kstack_pages * 25 PAGE_SIZE); 26 } 27 #endif /* _SYS_PROC_H_ */ 28 29 #endif 30