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) = (char *)td->td_kstack +				\
17	    td->td_kstack_pages * PAGE_SIZE -				\
18	    (char *)&td;						\
19} while (0)
20
21static __inline bool
22kstack_contains(struct thread *td, vm_offset_t va, size_t len)
23{
24	return (va >= td->td_kstack && va + len >= va &&
25	    va + len <= td->td_kstack + td->td_kstack_pages * PAGE_SIZE);
26}
27#endif	/* _SYS_PROC_H_ */
28
29#endif