1993-06-12 14:58:17 +00:00
|
|
|
/*-
|
2017-11-20 19:43:44 +00:00
|
|
|
* SPDX-License-Identifier: BSD-3-Clause
|
|
|
|
*
|
1993-06-12 14:58:17 +00:00
|
|
|
* Copyright (c) 1990 The Regents of the University of California.
|
|
|
|
* All rights reserved.
|
|
|
|
*
|
|
|
|
* This code is derived from software contributed to Berkeley by
|
|
|
|
* William Jolitz.
|
|
|
|
*
|
|
|
|
* Redistribution and use in source and binary forms, with or without
|
|
|
|
* modification, are permitted provided that the following conditions
|
|
|
|
* are met:
|
|
|
|
* 1. Redistributions of source code must retain the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer.
|
|
|
|
* 2. Redistributions in binary form must reproduce the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer in the
|
|
|
|
* documentation and/or other materials provided with the distribution.
|
2017-02-28 23:42:47 +00:00
|
|
|
* 3. Neither the name of the University nor the names of its contributors
|
1993-06-12 14:58:17 +00:00
|
|
|
* may be used to endorse or promote products derived from this software
|
|
|
|
* without specific prior written permission.
|
|
|
|
*
|
|
|
|
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
|
|
|
|
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
|
|
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
|
|
|
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
|
|
|
|
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
|
|
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
|
|
|
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
|
|
|
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
|
|
|
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
|
|
|
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
|
|
|
* SUCH DAMAGE.
|
|
|
|
*
|
1993-10-08 20:51:00 +00:00
|
|
|
* from: @(#)pcb.h 5.10 (Berkeley) 5/12/91
|
1999-08-28 01:08:13 +00:00
|
|
|
* $FreeBSD$
|
1993-06-12 14:58:17 +00:00
|
|
|
*/
|
|
|
|
|
1993-10-08 20:51:00 +00:00
|
|
|
#ifndef _I386_PCB_H_
|
|
|
|
#define _I386_PCB_H_
|
|
|
|
|
1993-06-12 14:58:17 +00:00
|
|
|
/*
|
|
|
|
* Intel 386 process control block
|
|
|
|
*/
|
2005-04-14 04:13:27 +00:00
|
|
|
#ifndef _KERNEL
|
|
|
|
#include <machine/segments.h>
|
|
|
|
#endif
|
1994-08-13 03:50:34 +00:00
|
|
|
#include <machine/npx.h>
|
1993-06-12 14:58:17 +00:00
|
|
|
|
2015-11-12 22:00:59 +00:00
|
|
|
/*
|
|
|
|
* NB: The fields marked with (*) are used by kernel debuggers. Their
|
|
|
|
* ABI should be preserved.
|
|
|
|
*/
|
1993-06-12 14:58:17 +00:00
|
|
|
struct pcb {
|
2015-11-12 22:00:59 +00:00
|
|
|
int pcb_edi; /* (*) */
|
|
|
|
int pcb_esi; /* (*) */
|
|
|
|
int pcb_ebp; /* (*) */
|
|
|
|
int pcb_esp; /* (*) */
|
|
|
|
int pcb_ebx; /* (*) */
|
|
|
|
int pcb_eip; /* (*) */
|
2014-11-02 22:58:30 +00:00
|
|
|
struct segment_descriptor pcb_fsd;
|
|
|
|
struct segment_descriptor pcb_gsd;
|
|
|
|
int pcb_ds;
|
|
|
|
int pcb_es;
|
|
|
|
int pcb_fs;
|
|
|
|
int pcb_gs;
|
|
|
|
int pcb_ss;
|
|
|
|
int pcb_cr0;
|
|
|
|
int pcb_cr2;
|
|
|
|
int pcb_cr3;
|
|
|
|
int pcb_cr4;
|
1999-07-09 04:16:00 +00:00
|
|
|
int pcb_dr0;
|
|
|
|
int pcb_dr1;
|
|
|
|
int pcb_dr2;
|
|
|
|
int pcb_dr3;
|
|
|
|
int pcb_dr6;
|
|
|
|
int pcb_dr7;
|
|
|
|
|
2014-11-02 22:58:30 +00:00
|
|
|
struct region_descriptor pcb_gdt;
|
|
|
|
struct region_descriptor pcb_idt;
|
|
|
|
uint16_t pcb_ldt;
|
|
|
|
uint16_t pcb_tr;
|
|
|
|
|
2002-01-17 17:49:23 +00:00
|
|
|
u_int pcb_flags;
|
1999-07-09 04:16:00 +00:00
|
|
|
#define PCB_DBREGS 0x02 /* process using debug registers */
|
2002-09-16 19:25:41 +00:00
|
|
|
#define PCB_NPXINITDONE 0x08 /* fpu state is initialized */
|
2002-11-07 01:34:23 +00:00
|
|
|
#define PCB_VM86CALL 0x10 /* in vm86 call */
|
2010-06-05 15:59:59 +00:00
|
|
|
#define PCB_NPXUSERINITDONE 0x20 /* user fpu state is initialized */
|
|
|
|
#define PCB_KERNNPX 0x40 /* kernel uses npx */
|
2002-11-07 01:34:23 +00:00
|
|
|
|
2014-11-02 22:58:30 +00:00
|
|
|
uint16_t pcb_initial_npxcw;
|
|
|
|
|
1993-06-12 14:58:17 +00:00
|
|
|
caddr_t pcb_onfault; /* copyin/out fault recovery */
|
1997-08-09 00:04:06 +00:00
|
|
|
struct pcb_ext *pcb_ext; /* optional pcb extension */
|
Remove all kernel uses of pcb_psl, but keep in in the struct to
preserve the ABI and API for applications. It was removed in the port
to amd64, but was remained as garbage giving a micro-pessimization and
spurious single-step traps on i386.
pcb_psl was intended to be used just to do a context switch of PSL_I,
but this context switch was null in most or all versions, and
mis-switching of PSL_T was done instead.
Some history:
- in 386BSD-0.0, cpu_switch() ran at splhigh() and splhigh() did too
much interrupt disabling, so interrupts were hard-disabled across
cpu_switch() and too many other places
- in 386BSD-0.0-patchkit through FreeBSD-4 and FreeBSD-5 before
SMPng, splhigh() did soft interrupt masking, and cpu_switch() was
excessively cautious and did a cli at the start and a sti at the
end to hard-disable interrupts across the switch
- SMPng replaced the spl's and cli's by spinlocks (just sched_lock?),
so interrupts were hard-disabled across cpu_switch() and too many
other places again
- initial attempts to fix this intended to restore some soft
interrupt disabling, but to support variations in this cpu_switch()
used pushfl/popfl into pcb_psl to avoid hard-coding the assumption
that the initial and final states have PSL_I enabled. But the
version with soft interrupt disabling wasn't used for long, or was
never committed, (except I always used my different version of it
for UP) so the pushfl/popl and pcb_psl to hold them have been doing
less than nothing for about 14 years.
2016-09-17 14:00:52 +00:00
|
|
|
int pcb_waspsl; /* unused padding for ABI and API compat */
|
2005-04-13 18:13:40 +00:00
|
|
|
u_long pcb_vm86[2]; /* vm86bios scratch space */
|
2010-06-05 15:59:59 +00:00
|
|
|
union savefpu *pcb_save;
|
Add SMP/i386 suspend/resume support.
Most part is merged from amd64.
- i386/acpica/acpi_wakecode.S
Replaced with amd64 code (from realmode to paging enabling code).
- i386/acpica/acpi_wakeup.c
Replaced with amd64 code (except for wakeup_pagetables stuff).
- i386/include/pcb.h
- i386/i386/genassym.c
Added PCB new members (CR0, CR2, CR4, DS, ED, FS, SS, GDT, IDT, LDT
and TR) needed for suspend/resume, not for context switch.
- i386/i386/swtch.s
Added suspendctx() and resumectx().
Note that savectx() was not changed and used for suspending (while
amd64 code uses it).
BSP and AP execute the same sequence, suspendctx(), acpi_wakecode()
and resumectx() for suspend/resume (in case of UP system also).
- i386/i386/apic_vector.s
Added cpususpend().
- i386/i386/mp_machdep.c
- i386/include/smp.h
Added cpususpend_handler().
- i386/include/apicvar.h
- kern/subr_smp.c
- sys/smp.h
Added IPI_SUSPEND and suspend_cpus().
- i386/i386/initcpu.c
- i386/i386/machdep.c
- i386/include/md_var.h
- pc98/pc98/machdep.c
Moved initializecpu() declarations to md_var.h.
MFC after: 3 days
2012-05-18 18:55:58 +00:00
|
|
|
|
2014-11-02 22:58:30 +00:00
|
|
|
uint32_t pcb_pad[10];
|
2014-09-06 15:23:28 +00:00
|
|
|
};
|
2014-08-30 17:48:38 +00:00
|
|
|
|
2014-11-02 22:58:30 +00:00
|
|
|
/* Per-CPU state saved during suspend and resume. */
|
2014-09-06 15:23:28 +00:00
|
|
|
struct susppcb {
|
|
|
|
struct pcb sp_pcb;
|
2014-11-02 22:58:30 +00:00
|
|
|
|
|
|
|
/* fpu context for suspend/resume */
|
|
|
|
void *sp_fpususpend;
|
1993-06-12 14:58:17 +00:00
|
|
|
};
|
|
|
|
|
1999-12-29 04:46:21 +00:00
|
|
|
#ifdef _KERNEL
|
2004-07-10 19:56:00 +00:00
|
|
|
struct trapframe;
|
|
|
|
|
|
|
|
void makectx(struct trapframe *, struct pcb *);
|
2012-06-09 00:37:26 +00:00
|
|
|
int savectx(struct pcb *) __returns_twice;
|
2012-06-13 21:03:01 +00:00
|
|
|
void resumectx(struct pcb *) __fastcall;
|
1993-06-12 14:58:17 +00:00
|
|
|
#endif
|
1993-10-08 20:51:00 +00:00
|
|
|
|
|
|
|
#endif /* _I386_PCB_H_ */
|