xref: /freebsd/sys/amd64/include/md_var.h (revision 756bc3adc578077d530e7f64683d4fc8383030ce)
1b5e8ce9fSBruce Evans /*-
251369649SPedro F. Giffuni  * SPDX-License-Identifier: BSD-3-Clause
351369649SPedro F. Giffuni  *
4b5e8ce9fSBruce Evans  * Copyright (c) 1995 Bruce D. Evans.
5b5e8ce9fSBruce Evans  * All rights reserved.
6b5e8ce9fSBruce Evans  *
7b5e8ce9fSBruce Evans  * Redistribution and use in source and binary forms, with or without
8b5e8ce9fSBruce Evans  * modification, are permitted provided that the following conditions
9b5e8ce9fSBruce Evans  * are met:
10b5e8ce9fSBruce Evans  * 1. Redistributions of source code must retain the above copyright
11b5e8ce9fSBruce Evans  *    notice, this list of conditions and the following disclaimer.
12b5e8ce9fSBruce Evans  * 2. Redistributions in binary form must reproduce the above copyright
13b5e8ce9fSBruce Evans  *    notice, this list of conditions and the following disclaimer in the
14b5e8ce9fSBruce Evans  *    documentation and/or other materials provided with the distribution.
15b5e8ce9fSBruce Evans  * 3. Neither the name of the author nor the names of contributors
16b5e8ce9fSBruce Evans  *    may be used to endorse or promote products derived from this software
17b5e8ce9fSBruce Evans  *    without specific prior written permission.
18b5e8ce9fSBruce Evans  *
19b5e8ce9fSBruce Evans  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
20b5e8ce9fSBruce Evans  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
21b5e8ce9fSBruce Evans  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
22b5e8ce9fSBruce Evans  * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
23b5e8ce9fSBruce Evans  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
24b5e8ce9fSBruce Evans  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
25b5e8ce9fSBruce Evans  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
26b5e8ce9fSBruce Evans  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
27b5e8ce9fSBruce Evans  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
28b5e8ce9fSBruce Evans  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
29b5e8ce9fSBruce Evans  * SUCH DAMAGE.
30b5e8ce9fSBruce Evans  *
31c3aac50fSPeter Wemm  * $FreeBSD$
32b5e8ce9fSBruce Evans  */
33b5e8ce9fSBruce Evans 
345ea3094eSBrooks Davis #ifdef __i386__
355ea3094eSBrooks Davis #include <i386/md_var.h>
365ea3094eSBrooks Davis #else /* !__i386__ */
375ea3094eSBrooks Davis 
38b5e8ce9fSBruce Evans #ifndef _MACHINE_MD_VAR_H_
39b5e8ce9fSBruce Evans #define	_MACHINE_MD_VAR_H_
40b5e8ce9fSBruce Evans 
417c958a41SKonstantin Belousov #include <x86/x86_var.h>
42b5e8ce9fSBruce Evans 
435e8ea68fSKonstantin Belousov extern char	ctx_switch_xsave[];
44df013409SKonstantin Belousov extern char	ctx_switch_xsave32[];
45cd155b56SDon Lewis extern int	hw_lower_amd64_sharedpage;
46319117fdSKonstantin Belousov extern int	hw_ibrs_disable;
473621ba1eSKonstantin Belousov extern int	hw_ssb_disable;
48c1141fbaSKonstantin Belousov extern int	nmi_flush_l1d_sw;
492dec2b4aSKonstantin Belousov extern int	syscall_ret_l1d_flush_mode;
500d2a2989SPeter Wemm 
516bc6a542SKonstantin Belousov extern vm_paddr_t intel_graphics_stolen_base;
526bc6a542SKonstantin Belousov extern vm_paddr_t intel_graphics_stolen_size;
536bc6a542SKonstantin Belousov 
549ce875d9SKonstantin Belousov extern int la57;
559ce875d9SKonstantin Belousov 
56e18380e3SKonstantin Belousov extern vm_paddr_t kernphys;
57e18380e3SKonstantin Belousov extern vm_paddr_t KERNend;
583705dda7SKonstantin Belousov 
596a382136SKonstantin Belousov extern bool efi_boot;
606a382136SKonstantin Belousov 
61562bc0a9SEdward Tomasz Napierala struct	__mcontext;
627c958a41SKonstantin Belousov struct	savefpu;
63cd155b56SDon Lewis struct	sysentvec;
647c958a41SKonstantin Belousov 
650f7c159fSKonstantin Belousov void	amd64_conf_fast_syscall(void);
667c958a41SKonstantin Belousov void	amd64_db_resume_dbreg(void);
67*756bc3adSMark Johnston vm_paddr_t amd64_loadaddr(void);
68cd155b56SDon Lewis void	amd64_lower_shared_page(struct sysentvec *);
6910ff5eebSKonstantin Belousov void	amd64_bsp_pcpu_init1(struct pcpu *pc);
7010ff5eebSKonstantin Belousov void	amd64_bsp_pcpu_init2(uint64_t rsp0);
7110ff5eebSKonstantin Belousov void	amd64_bsp_ist_init(struct pcpu *pc);
7220aee906SKonstantin Belousov void	amd64_syscall(struct thread *td, int traced);
732dec2b4aSKonstantin Belousov void	amd64_syscall_ret_flush_l1d(int error);
742dec2b4aSKonstantin Belousov void	amd64_syscall_ret_flush_l1d_recalc(void);
75b63dc6adSAlfred Perlstein void	doreti_iret(void) __asm(__STRING(doreti_iret));
76b63dc6adSAlfred Perlstein void	doreti_iret_fault(void) __asm(__STRING(doreti_iret_fault));
772dec2b4aSKonstantin Belousov void	flush_l1d_sw_abi(void);
782c66cccaSKonstantin Belousov void	ld_ds(void) __asm(__STRING(ld_ds));
792c66cccaSKonstantin Belousov void	ld_es(void) __asm(__STRING(ld_es));
802c66cccaSKonstantin Belousov void	ld_fs(void) __asm(__STRING(ld_fs));
812c66cccaSKonstantin Belousov void	ld_gs(void) __asm(__STRING(ld_gs));
82a35d07a8SKonstantin Belousov void	ld_fsbase(void) __asm(__STRING(ld_fsbase));
83a35d07a8SKonstantin Belousov void	ld_gsbase(void) __asm(__STRING(ld_gsbase));
842c66cccaSKonstantin Belousov void	ds_load_fault(void) __asm(__STRING(ds_load_fault));
852c66cccaSKonstantin Belousov void	es_load_fault(void) __asm(__STRING(es_load_fault));
862c66cccaSKonstantin Belousov void	fs_load_fault(void) __asm(__STRING(fs_load_fault));
872c66cccaSKonstantin Belousov void	gs_load_fault(void) __asm(__STRING(gs_load_fault));
88a35d07a8SKonstantin Belousov void	fsbase_load_fault(void) __asm(__STRING(fsbase_load_fault));
89a35d07a8SKonstantin Belousov void	gsbase_load_fault(void) __asm(__STRING(gsbase_load_fault));
90c64b7013SAlan Cox void	fpstate_drop(struct thread *td);
91c64b7013SAlan Cox void	pagezero(void *addr);
92afa88623SPeter Wemm void	setidt(int idx, alias_for_inthand_t *func, int typ, int dpl, int ist);
935e921ff4SKonstantin Belousov void	set_top_of_stack_td(struct thread *td);
948c6f8f3dSKonstantin Belousov struct savefpu *get_pcb_user_save_td(struct thread *td);
958c6f8f3dSKonstantin Belousov struct savefpu *get_pcb_user_save_pcb(struct pcb *pcb);
966bc6a542SKonstantin Belousov void	pci_early_quirks(void);
97562bc0a9SEdward Tomasz Napierala void	get_fpcontext(struct thread *td, struct __mcontext *mcp,
98562bc0a9SEdward Tomasz Napierala 	    char **xfpusave, size_t *xfpusave_len);
99562bc0a9SEdward Tomasz Napierala int	set_fpcontext(struct thread *td, struct __mcontext *mcp,
100562bc0a9SEdward Tomasz Napierala 	    char *xfpustate, size_t xfpustate_len);
101b5e8ce9fSBruce Evans 
102b5e8ce9fSBruce Evans #endif /* !_MACHINE_MD_VAR_H_ */
1035ea3094eSBrooks Davis 
1045ea3094eSBrooks Davis #endif /* __i386__ */
105