xref: /freebsd/sys/i386/include/proc.h (revision 8bc792b3845ecf64145fda7964a7b5cc54dea777)
186cb007fSWarner Losh /*-
251369649SPedro F. Giffuni  * SPDX-License-Identifier: BSD-3-Clause
351369649SPedro F. Giffuni  *
45b81b6b3SRodney W. Grimes  * Copyright (c) 1991 Regents of the University of California.
55b81b6b3SRodney W. Grimes  * All rights reserved.
65b81b6b3SRodney W. Grimes  *
75b81b6b3SRodney W. Grimes  * Redistribution and use in source and binary forms, with or without
85b81b6b3SRodney W. Grimes  * modification, are permitted provided that the following conditions
95b81b6b3SRodney W. Grimes  * are met:
105b81b6b3SRodney W. Grimes  * 1. Redistributions of source code must retain the above copyright
115b81b6b3SRodney W. Grimes  *    notice, this list of conditions and the following disclaimer.
125b81b6b3SRodney W. Grimes  * 2. Redistributions in binary form must reproduce the above copyright
135b81b6b3SRodney W. Grimes  *    notice, this list of conditions and the following disclaimer in the
145b81b6b3SRodney W. Grimes  *    documentation and/or other materials provided with the distribution.
15fbbd9655SWarner Losh  * 3. Neither the name of the University nor the names of its contributors
165b81b6b3SRodney W. Grimes  *    may be used to endorse or promote products derived from this software
175b81b6b3SRodney W. Grimes  *    without specific prior written permission.
185b81b6b3SRodney W. Grimes  *
195b81b6b3SRodney W. Grimes  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
205b81b6b3SRodney W. Grimes  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
215b81b6b3SRodney W. Grimes  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
225b81b6b3SRodney W. Grimes  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
235b81b6b3SRodney W. Grimes  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
245b81b6b3SRodney W. Grimes  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
255b81b6b3SRodney W. Grimes  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
265b81b6b3SRodney W. Grimes  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
275b81b6b3SRodney W. Grimes  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
285b81b6b3SRodney W. Grimes  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
295b81b6b3SRodney W. Grimes  * SUCH DAMAGE.
305b81b6b3SRodney W. Grimes  *
3134a8ed1bSRodney W. Grimes  *	from: @(#)proc.h	7.1 (Berkeley) 5/15/91
32c3aac50fSPeter Wemm  * $FreeBSD$
335b81b6b3SRodney W. Grimes  */
345b81b6b3SRodney W. Grimes 
356e393973SGarrett Wollman #ifndef _MACHINE_PROC_H_
366f486a55SPeter Wemm #define	_MACHINE_PROC_H_
376e393973SGarrett Wollman 
3824db0459SJohn Baldwin #include <machine/segments.h>
3924db0459SJohn Baldwin 
4024db0459SJohn Baldwin struct proc_ldt {
4124db0459SJohn Baldwin         caddr_t ldt_base;
4224db0459SJohn Baldwin         int     ldt_len;
4324db0459SJohn Baldwin         int     ldt_refcnt;
4424db0459SJohn Baldwin         u_long  ldt_active;
4524db0459SJohn Baldwin         struct  segment_descriptor ldt_sd;
4624db0459SJohn Baldwin };
475206bca1SLuoqi Chen 
485b81b6b3SRodney W. Grimes /*
499368fc20SNate Williams  * Machine-dependent part of the proc structure for i386.
500ad5e7f3SJeff Roberson  * Table of MD locks:
510ad5e7f3SJeff Roberson  *       t - Descriptor tables lock
525b81b6b3SRodney W. Grimes  */
53b40ce416SJulian Elischer struct mdthread {
54c6a37e84SJohn Baldwin 	int	md_spinlock_count;	/* (k) */
55c6a37e84SJohn Baldwin 	register_t md_saved_flags;	/* (k) */
565730afc9SAlan Cox 	register_t md_spurflt_addr;	/* (k) Spurious page fault address. */
57b40ce416SJulian Elischer };
58b40ce416SJulian Elischer 
595b81b6b3SRodney W. Grimes struct mdproc {
600ad5e7f3SJeff Roberson 	struct proc_ldt *md_ldt;	/* (t) per-process ldt */
615b81b6b3SRodney W. Grimes };
625b81b6b3SRodney W. Grimes 
63ed780687SKonstantin Belousov #define	KINFO_PROC_SIZE 768
64ed780687SKonstantin Belousov 
6543f41dd3SKonstantin Belousov struct syscall_args {
6643f41dd3SKonstantin Belousov 	u_int code;
67cf98bc28SDavid Chisnall 	u_int original_code;
6843f41dd3SKonstantin Belousov 	struct sysent *callp;
6943f41dd3SKonstantin Belousov 	register_t args[8];
7043f41dd3SKonstantin Belousov };
7143f41dd3SKonstantin Belousov 
7224db0459SJohn Baldwin #ifdef	_KERNEL
7324db0459SJohn Baldwin 
74*8bc792b3SMitchell Horne #include <machine/md_var.h>
75*8bc792b3SMitchell Horne 
762a57ca33SAlexander Motin /* Get the current kernel thread stack usage. */
772a57ca33SAlexander Motin #define GET_STACK_USAGE(total, used) do {				\
782a57ca33SAlexander Motin 	struct thread	*td = curthread;				\
79*8bc792b3SMitchell Horne 	(total) = (vm_offset_t)get_pcb_td(td) - td->td_kstack;		\
80*8bc792b3SMitchell Horne 	(used) = (vm_offset_t)get_pcb_td(td) - (vm_offset_t)&td;	\
812a57ca33SAlexander Motin } while (0)
822a57ca33SAlexander Motin 
83b63dc6adSAlfred Perlstein void 	set_user_ldt(struct mdproc *);
84b63dc6adSAlfred Perlstein struct 	proc_ldt *user_ldt_alloc(struct mdproc *, int);
85b63dc6adSAlfred Perlstein void 	user_ldt_free(struct thread *);
869719da13SKonstantin Belousov void	user_ldt_deref(struct proc_ldt *pldt);
8724db0459SJohn Baldwin 
880ad5e7f3SJeff Roberson extern struct mtx dt_lock;
8924db0459SJohn Baldwin #endif	/* _KERNEL */
9024db0459SJohn Baldwin 
916f486a55SPeter Wemm #endif /* !_MACHINE_PROC_H_ */
92