1139731Simp/*-
24Srgrimes * Copyright (c) 1991 Regents of the University of California.
34Srgrimes * All rights reserved.
44Srgrimes *
54Srgrimes * Redistribution and use in source and binary forms, with or without
64Srgrimes * modification, are permitted provided that the following conditions
74Srgrimes * are met:
84Srgrimes * 1. Redistributions of source code must retain the above copyright
94Srgrimes *    notice, this list of conditions and the following disclaimer.
104Srgrimes * 2. Redistributions in binary form must reproduce the above copyright
114Srgrimes *    notice, this list of conditions and the following disclaimer in the
124Srgrimes *    documentation and/or other materials provided with the distribution.
134Srgrimes * 4. Neither the name of the University nor the names of its contributors
144Srgrimes *    may be used to endorse or promote products derived from this software
154Srgrimes *    without specific prior written permission.
164Srgrimes *
174Srgrimes * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
184Srgrimes * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
194Srgrimes * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
204Srgrimes * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
214Srgrimes * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
224Srgrimes * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
234Srgrimes * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
244Srgrimes * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
254Srgrimes * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
264Srgrimes * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
274Srgrimes * SUCH DAMAGE.
284Srgrimes *
29621Srgrimes *	from: @(#)proc.h	7.1 (Berkeley) 5/15/91
3050477Speter * $FreeBSD: releng/10.2/sys/amd64/include/proc.h 233291 2012-03-22 04:52:51Z alc $
314Srgrimes */
324Srgrimes
33719Swollman#ifndef _MACHINE_PROC_H_
3425549Speter#define	_MACHINE_PROC_H_
35719Swollman
36190620Skib#include <machine/segments.h>
37190620Skib
38190620Skibstruct proc_ldt {
39190620Skib	caddr_t ldt_base;
40190620Skib	int     ldt_refcnt;
41190620Skib};
42190620Skib
434Srgrimes/*
44114349Speter * Machine-dependent part of the proc structure for AMD64.
454Srgrimes */
4683366Sjulianstruct mdthread {
47144637Sjhb	int	md_spinlock_count;	/* (k) */
48144637Sjhb	register_t md_saved_flags;	/* (k) */
49233291Salc	register_t md_spurflt_addr;	/* (k) Spurious page fault address. */
5083366Sjulian};
5183366Sjulian
524Srgrimesstruct mdproc {
53190620Skib	struct proc_ldt *md_ldt;	/* (t) per-process ldt */
54190620Skib	struct system_segment_descriptor md_ldt_sd;
554Srgrimes};
564Srgrimes
57207269Skib#define	KINFO_PROC_SIZE 1088
58207269Skib#define	KINFO_PROC32_SIZE 768
59207152Skib
60175846Smav#ifdef	_KERNEL
61175846Smav
62175846Smav/* Get the current kernel thread stack usage. */
63175846Smav#define GET_STACK_USAGE(total, used) do {				\
64175846Smav	struct thread	*td = curthread;				\
65175846Smav	(total) = td->td_kstack_pages * PAGE_SIZE;			\
66175846Smav	(used) = (char *)td->td_kstack +				\
67175846Smav	    td->td_kstack_pages * PAGE_SIZE -				\
68175846Smav	    (char *)&td;						\
69175846Smav} while (0)
70175846Smav
71190620Skibvoid set_user_ldt(struct mdproc *);
72190620Skibstruct proc_ldt *user_ldt_alloc(struct proc *, int);
73190620Skibvoid user_ldt_free(struct thread *);
74190620Skibvoid user_ldt_deref(struct proc_ldt *);
75190620Skibstruct sysarch_args;
76190620Skibint sysarch_ldt(struct thread *td, struct sysarch_args *uap, int uap_space);
77190620Skibint amd64_set_ldt_data(struct thread *td, int start, int num,
78190620Skib    struct user_segment_descriptor *descs);
79190620Skib
80190620Skibextern struct mtx dt_lock;
81190620Skibextern int max_ldt_segment;
82190620Skib
83208453Skibstruct syscall_args {
84208453Skib	u_int code;
85208453Skib	struct sysent *callp;
86208453Skib	register_t args[8];
87208453Skib	int narg;
88208453Skib};
89175846Smav#endif  /* _KERNEL */
90175846Smav
9125549Speter#endif /* !_MACHINE_PROC_H_ */
92