xref: /freebsd/sys/i386/include/proc.h (revision ed7806879b9fb7bd34a9ec2ae1360760e87d244d)
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) */
54b40ce416SJulian Elischer };
55b40ce416SJulian Elischer 
565b81b6b3SRodney W. Grimes struct mdproc {
570ad5e7f3SJeff Roberson 	struct proc_ldt *md_ldt;	/* (t) per-process ldt */
585b81b6b3SRodney W. Grimes };
595b81b6b3SRodney W. Grimes 
60*ed780687SKonstantin Belousov #define KINFO_PROC_SIZE 768
61*ed780687SKonstantin Belousov 
6224db0459SJohn Baldwin #ifdef	_KERNEL
6324db0459SJohn Baldwin 
642a57ca33SAlexander Motin /* Get the current kernel thread stack usage. */
652a57ca33SAlexander Motin #define GET_STACK_USAGE(total, used) do {				\
662a57ca33SAlexander Motin 	struct thread	*td = curthread;				\
672a57ca33SAlexander Motin 	(total) = td->td_kstack_pages * PAGE_SIZE;			\
682a57ca33SAlexander Motin 	(used) = (char *)td->td_kstack +				\
692a57ca33SAlexander Motin 	    td->td_kstack_pages * PAGE_SIZE -				\
702a57ca33SAlexander Motin 	    (char *)&td;						\
712a57ca33SAlexander Motin } while (0)
722a57ca33SAlexander Motin 
73b63dc6adSAlfred Perlstein void 	set_user_ldt(struct mdproc *);
74b63dc6adSAlfred Perlstein struct 	proc_ldt *user_ldt_alloc(struct mdproc *, int);
75b63dc6adSAlfred Perlstein void 	user_ldt_free(struct thread *);
769719da13SKonstantin Belousov void	user_ldt_deref(struct proc_ldt *pldt);
7724db0459SJohn Baldwin 
780ad5e7f3SJeff Roberson extern struct mtx dt_lock;
790ad5e7f3SJeff Roberson 
8024db0459SJohn Baldwin #endif	/* _KERNEL */
8124db0459SJohn Baldwin 
826f486a55SPeter Wemm #endif /* !_MACHINE_PROC_H_ */
83