xref: /freebsd/sys/i386/include/proc.h (revision 5730afc9b6405f9325dfbbf7164dd6c818191ff5)
186cb007fSWarner Losh /*-
25b81b6b3SRodney W. Grimes  * Copyright (c) 1991 Regents of the University of California.
35b81b6b3SRodney W. Grimes  * All rights reserved.
45b81b6b3SRodney W. Grimes  *
55b81b6b3SRodney W. Grimes  * Redistribution and use in source and binary forms, with or without
65b81b6b3SRodney W. Grimes  * modification, are permitted provided that the following conditions
75b81b6b3SRodney W. Grimes  * are met:
85b81b6b3SRodney W. Grimes  * 1. Redistributions of source code must retain the above copyright
95b81b6b3SRodney W. Grimes  *    notice, this list of conditions and the following disclaimer.
105b81b6b3SRodney W. Grimes  * 2. Redistributions in binary form must reproduce the above copyright
115b81b6b3SRodney W. Grimes  *    notice, this list of conditions and the following disclaimer in the
125b81b6b3SRodney W. Grimes  *    documentation and/or other materials provided with the distribution.
135b81b6b3SRodney W. Grimes  * 4. Neither the name of the University nor the names of its contributors
145b81b6b3SRodney W. Grimes  *    may be used to endorse or promote products derived from this software
155b81b6b3SRodney W. Grimes  *    without specific prior written permission.
165b81b6b3SRodney W. Grimes  *
175b81b6b3SRodney W. Grimes  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
185b81b6b3SRodney W. Grimes  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
195b81b6b3SRodney W. Grimes  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
205b81b6b3SRodney W. Grimes  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
215b81b6b3SRodney W. Grimes  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
225b81b6b3SRodney W. Grimes  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
235b81b6b3SRodney W. Grimes  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
245b81b6b3SRodney W. Grimes  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
255b81b6b3SRodney W. Grimes  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
265b81b6b3SRodney W. Grimes  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
275b81b6b3SRodney W. Grimes  * SUCH DAMAGE.
285b81b6b3SRodney W. Grimes  *
2934a8ed1bSRodney W. Grimes  *	from: @(#)proc.h	7.1 (Berkeley) 5/15/91
30c3aac50fSPeter Wemm  * $FreeBSD$
315b81b6b3SRodney W. Grimes  */
325b81b6b3SRodney W. Grimes 
336e393973SGarrett Wollman #ifndef _MACHINE_PROC_H_
346f486a55SPeter Wemm #define	_MACHINE_PROC_H_
356e393973SGarrett Wollman 
3624db0459SJohn Baldwin #include <machine/segments.h>
3724db0459SJohn Baldwin 
3824db0459SJohn Baldwin struct proc_ldt {
3924db0459SJohn Baldwin         caddr_t ldt_base;
4024db0459SJohn Baldwin         int     ldt_len;
4124db0459SJohn Baldwin         int     ldt_refcnt;
4224db0459SJohn Baldwin         u_long  ldt_active;
4324db0459SJohn Baldwin         struct  segment_descriptor ldt_sd;
4424db0459SJohn Baldwin };
455206bca1SLuoqi Chen 
465b81b6b3SRodney W. Grimes /*
479368fc20SNate Williams  * Machine-dependent part of the proc structure for i386.
480ad5e7f3SJeff Roberson  * Table of MD locks:
490ad5e7f3SJeff Roberson  *       t - Descriptor tables lock
505b81b6b3SRodney W. Grimes  */
51b40ce416SJulian Elischer struct mdthread {
52c6a37e84SJohn Baldwin 	int	md_spinlock_count;	/* (k) */
53c6a37e84SJohn Baldwin 	register_t md_saved_flags;	/* (k) */
54*5730afc9SAlan Cox 	register_t md_spurflt_addr;	/* (k) Spurious page fault address. */
55b40ce416SJulian Elischer };
56b40ce416SJulian Elischer 
575b81b6b3SRodney W. Grimes struct mdproc {
580ad5e7f3SJeff Roberson 	struct proc_ldt *md_ldt;	/* (t) per-process ldt */
595b81b6b3SRodney W. Grimes };
605b81b6b3SRodney W. Grimes 
61ed780687SKonstantin Belousov #define	KINFO_PROC_SIZE 768
62ed780687SKonstantin Belousov 
6324db0459SJohn Baldwin #ifdef	_KERNEL
6424db0459SJohn Baldwin 
652a57ca33SAlexander Motin /* Get the current kernel thread stack usage. */
662a57ca33SAlexander Motin #define GET_STACK_USAGE(total, used) do {				\
672a57ca33SAlexander Motin 	struct thread	*td = curthread;				\
682a57ca33SAlexander Motin 	(total) = td->td_kstack_pages * PAGE_SIZE;			\
692a57ca33SAlexander Motin 	(used) = (char *)td->td_kstack +				\
702a57ca33SAlexander Motin 	    td->td_kstack_pages * PAGE_SIZE -				\
712a57ca33SAlexander Motin 	    (char *)&td;						\
722a57ca33SAlexander Motin } while (0)
732a57ca33SAlexander Motin 
74b63dc6adSAlfred Perlstein void 	set_user_ldt(struct mdproc *);
75b63dc6adSAlfred Perlstein struct 	proc_ldt *user_ldt_alloc(struct mdproc *, int);
76b63dc6adSAlfred Perlstein void 	user_ldt_free(struct thread *);
779719da13SKonstantin Belousov void	user_ldt_deref(struct proc_ldt *pldt);
7824db0459SJohn Baldwin 
790ad5e7f3SJeff Roberson extern struct mtx dt_lock;
800ad5e7f3SJeff Roberson 
81afe1a688SKonstantin Belousov struct syscall_args {
82afe1a688SKonstantin Belousov 	u_int code;
83afe1a688SKonstantin Belousov 	struct sysent *callp;
84afe1a688SKonstantin Belousov 	register_t args[8];
85afe1a688SKonstantin Belousov 	int narg;
86afe1a688SKonstantin Belousov };
8724db0459SJohn Baldwin #endif	/* _KERNEL */
8824db0459SJohn Baldwin 
896f486a55SPeter Wemm #endif /* !_MACHINE_PROC_H_ */
90