xref: /freebsd/sys/x86/include/ucode.h (revision 97edfc1b456be505af1e592ddad4c0bac6bc0b46)
1*97edfc1bSMark Johnston /*-
2*97edfc1bSMark Johnston  * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
3*97edfc1bSMark Johnston  *
4*97edfc1bSMark Johnston  * Copyright (c) 2018 The FreeBSD Foundation
5*97edfc1bSMark Johnston  *
6*97edfc1bSMark Johnston  * This software was developed by Mark Johnston under sponsorship from
7*97edfc1bSMark Johnston  * the FreeBSD Foundation.
8*97edfc1bSMark Johnston  *
9*97edfc1bSMark Johnston  * Redistribution and use in source and binary forms, with or without
10*97edfc1bSMark Johnston  * modification, are permitted provided that the following conditions
11*97edfc1bSMark Johnston  * are met:
12*97edfc1bSMark Johnston  * 1. Redistributions of source code must retain the above copyright
13*97edfc1bSMark Johnston  *    notice, this list of conditions and the following disclaimer.
14*97edfc1bSMark Johnston  * 2. Redistributions in binary form must reproduce the above copyright
15*97edfc1bSMark Johnston  *    notice, this list of conditions and the following disclaimer in the
16*97edfc1bSMark Johnston  *    documentation and/or other materials provided with the distribution.
17*97edfc1bSMark Johnston  *
18*97edfc1bSMark Johnston  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
19*97edfc1bSMark Johnston  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
20*97edfc1bSMark Johnston  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
21*97edfc1bSMark Johnston  * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
22*97edfc1bSMark Johnston  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
23*97edfc1bSMark Johnston  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
24*97edfc1bSMark Johnston  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
25*97edfc1bSMark Johnston  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
26*97edfc1bSMark Johnston  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
27*97edfc1bSMark Johnston  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
28*97edfc1bSMark Johnston  * SUCH DAMAGE.
29*97edfc1bSMark Johnston  *
30*97edfc1bSMark Johnston  * $FreeBSD$
31*97edfc1bSMark Johnston  */
32*97edfc1bSMark Johnston 
33*97edfc1bSMark Johnston #ifndef _MACHINE_UCODE_H_
34*97edfc1bSMark Johnston #define	_MACHINE_UCODE_H_
35*97edfc1bSMark Johnston 
36*97edfc1bSMark Johnston struct ucode_intel_header {
37*97edfc1bSMark Johnston 	uint32_t	header_version;
38*97edfc1bSMark Johnston 	int32_t		update_revision;
39*97edfc1bSMark Johnston 	uint32_t	dat;
40*97edfc1bSMark Johnston 	uint32_t	processor_signature;
41*97edfc1bSMark Johnston 	uint32_t	checksum;
42*97edfc1bSMark Johnston 	uint32_t	loader_revision;
43*97edfc1bSMark Johnston 	uint32_t	processor_flags;
44*97edfc1bSMark Johnston #define	UCODE_INTEL_DEFAULT_DATA_SIZE		2000
45*97edfc1bSMark Johnston 	uint32_t	data_size;
46*97edfc1bSMark Johnston 	uint32_t	total_size;
47*97edfc1bSMark Johnston 	uint32_t	reserved[3];
48*97edfc1bSMark Johnston };
49*97edfc1bSMark Johnston 
50*97edfc1bSMark Johnston struct ucode_intel_extsig_table {
51*97edfc1bSMark Johnston 	uint32_t	signature_count;
52*97edfc1bSMark Johnston 	uint32_t	signature_table_checksum;
53*97edfc1bSMark Johnston 	uint32_t	reserved[3];
54*97edfc1bSMark Johnston 	struct ucode_intel_extsig {
55*97edfc1bSMark Johnston 		uint32_t	processor_signature;
56*97edfc1bSMark Johnston 		uint32_t	processor_flags;
57*97edfc1bSMark Johnston 		uint32_t	checksum;
58*97edfc1bSMark Johnston 	} entries[0];
59*97edfc1bSMark Johnston };
60*97edfc1bSMark Johnston 
61*97edfc1bSMark Johnston int	ucode_intel_load(void *data, bool unsafe);
62*97edfc1bSMark Johnston size_t	ucode_load_bsp(uintptr_t free);
63*97edfc1bSMark Johnston void	ucode_load_ap(int cpu);
64*97edfc1bSMark Johnston void	ucode_reload(void);
65*97edfc1bSMark Johnston void *	ucode_update(void *data);
66*97edfc1bSMark Johnston 
67*97edfc1bSMark Johnston #endif /* _MACHINE_UCODE_H_ */
68