168349Sobrien/*- 268349Sobrien * Copyright (c) 1991 Regents of the University of California. 3354939Sdelphij * All rights reserved. 468349Sobrien * 568349Sobrien * Redistribution and use in source and binary forms, with or without 668349Sobrien * modification, are permitted provided that the following conditions 768349Sobrien * are met: 8103373Sobrien * 1. Redistributions of source code must retain the above copyright 968349Sobrien * notice, this list of conditions and the following disclaimer. 1068349Sobrien * 2. Redistributions in binary form must reproduce the above copyright 1168349Sobrien * notice, this list of conditions and the following disclaimer in the 1268349Sobrien * documentation and/or other materials provided with the distribution. 13103373Sobrien * 4. Neither the name of the University nor the names of its contributors 1468349Sobrien * may be used to endorse or promote products derived from this software 1568349Sobrien * without specific prior written permission. 1668349Sobrien * 17159764Sobrien * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 18159764Sobrien * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 19159764Sobrien * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 20288143Sdelphij * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 21226048Sobrien * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 22159764Sobrien * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 23226048Sobrien * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 24354939Sdelphij * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 25354939Sdelphij * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 26226048Sobrien * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 27226048Sobrien * SUCH DAMAGE. 28226048Sobrien * 29159764Sobrien * from: @(#)proc.h 7.1 (Berkeley) 5/15/91 30226048Sobrien * $FreeBSD: releng/10.3/sys/i386/include/proc.h 233291 2012-03-22 04:52:51Z alc $ 31226048Sobrien */ 32226048Sobrien 33226048Sobrien#ifndef _MACHINE_PROC_H_ 34159764Sobrien#define _MACHINE_PROC_H_ 35226048Sobrien 36226048Sobrien#include <machine/segments.h> 37267843Sdelphij 38267843Sdelphijstruct proc_ldt { 39328874Seadler caddr_t ldt_base; 40267843Sdelphij int ldt_len; 41328874Seadler int ldt_refcnt; 42328874Seadler u_long ldt_active; 43328874Seadler struct segment_descriptor ldt_sd; 44328874Seadler}; 45267843Sdelphij 46288143Sdelphij/* 47159764Sobrien * Machine-dependent part of the proc structure for i386. 48159764Sobrien * Table of MD locks: 49159764Sobrien * t - Descriptor tables lock 50159764Sobrien */ 51288143Sdelphijstruct mdthread { 52159764Sobrien int md_spinlock_count; /* (k) */ 53159764Sobrien register_t md_saved_flags; /* (k) */ 54159764Sobrien register_t md_spurflt_addr; /* (k) Spurious page fault address. */ 55159764Sobrien}; 56159764Sobrien 57159764Sobrienstruct mdproc { 58159764Sobrien struct proc_ldt *md_ldt; /* (t) per-process ldt */ 59288143Sdelphij}; 60159764Sobrien 61159764Sobrien#define KINFO_PROC_SIZE 768 62159764Sobrien 63159764Sobrien#ifdef _KERNEL 64159764Sobrien 65226048Sobrien/* Get the current kernel thread stack usage. */ 66103373Sobrien#define GET_STACK_USAGE(total, used) do { \ 67226048Sobrien struct thread *td = curthread; \ 68103373Sobrien (total) = td->td_kstack_pages * PAGE_SIZE; \ 69103373Sobrien (used) = (char *)td->td_kstack + \ 70103373Sobrien td->td_kstack_pages * PAGE_SIZE - \ 71103373Sobrien (char *)&td; \ 72103373Sobrien} while (0) 73288143Sdelphij 74103373Sobrienvoid set_user_ldt(struct mdproc *); 75103373Sobrienstruct proc_ldt *user_ldt_alloc(struct mdproc *, int); 76103373Sobrienvoid user_ldt_free(struct thread *); 77103373Sobrienvoid user_ldt_deref(struct proc_ldt *pldt); 78103373Sobrien 79288143Sdelphijextern struct mtx dt_lock; 80103373Sobrien 81103373Sobrienstruct syscall_args { 82328874Seadler u_int code; 83103373Sobrien struct sysent *callp; 84103373Sobrien register_t args[8]; 85103373Sobrien int narg; 86103373Sobrien}; 87288143Sdelphij#endif /* _KERNEL */ 88103373Sobrien 89103373Sobrien#endif /* !_MACHINE_PROC_H_ */ 90103373Sobrien