xref: /minix3/sys/arch/x86/include/cpu_ucode.h (revision 84d9c625bfea59e274550651111ae9edfdc40fbd)
1*84d9c625SLionel Sambuc /* $NetBSD: cpu_ucode.h,v 1.3 2012/10/17 20:19:55 drochner Exp $ */
21cd76c75SBen Gras /*
31cd76c75SBen Gras  * Copyright (c) 2012 The NetBSD Foundation, Inc.
41cd76c75SBen Gras  * All rights reserved.
51cd76c75SBen Gras  *
61cd76c75SBen Gras  * This code is derived from software contributed to The NetBSD Foundation
71cd76c75SBen Gras  * by Christoph Egger.
81cd76c75SBen Gras  *
91cd76c75SBen Gras  * Redistribution and use in source and binary forms, with or without
101cd76c75SBen Gras  * modification, are permitted provided that the following conditions
111cd76c75SBen Gras  * are met:
121cd76c75SBen Gras  * 1. Redistributions of source code must retain the above copyright
131cd76c75SBen Gras  *    notice, this list of conditions and the following disclaimer.
141cd76c75SBen Gras  * 2. Redistributions in binary form must reproduce the above copyright
151cd76c75SBen Gras  *    notice, this list of conditions and the following disclaimer in the
161cd76c75SBen Gras  *    documentation and/or other materials provided with the distribution.
171cd76c75SBen Gras  *
181cd76c75SBen Gras  * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
191cd76c75SBen Gras  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
201cd76c75SBen Gras  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
211cd76c75SBen Gras  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
221cd76c75SBen Gras  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
231cd76c75SBen Gras  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
241cd76c75SBen Gras  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
251cd76c75SBen Gras  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
261cd76c75SBen Gras  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
271cd76c75SBen Gras  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
281cd76c75SBen Gras  * POSSIBILITY OF SUCH DAMAGE.
291cd76c75SBen Gras  */
301cd76c75SBen Gras 
311cd76c75SBen Gras #ifndef _X86_CPU_UCODE_H_
321cd76c75SBen Gras #define _X86_CPU_UCODE_H_
331cd76c75SBen Gras 
341cd76c75SBen Gras #define CPU_UCODE_LOADER_AMD 0
351cd76c75SBen Gras struct cpu_ucode_version_amd {
361cd76c75SBen Gras 	uint64_t version;
371cd76c75SBen Gras };
381cd76c75SBen Gras 
391cd76c75SBen Gras #define CPU_UCODE_LOADER_INTEL1 1
401cd76c75SBen Gras struct cpu_ucode_version_intel1 {
411cd76c75SBen Gras 	uint32_t ucodeversion;
421cd76c75SBen Gras 	int platformid;
431cd76c75SBen Gras };
441cd76c75SBen Gras 
451cd76c75SBen Gras #ifdef _KERNEL
461cd76c75SBen Gras #include <sys/cpu.h>
471cd76c75SBen Gras #include <sys/cpuio.h>
481cd76c75SBen Gras #include <dev/firmload.h>
491cd76c75SBen Gras 
501cd76c75SBen Gras int cpu_ucode_amd_get_version(struct cpu_ucode_version *);
51*84d9c625SLionel Sambuc #ifdef COMPAT_60
521cd76c75SBen Gras int compat6_cpu_ucode_amd_get_version(struct compat6_cpu_ucode *);
53*84d9c625SLionel Sambuc #endif
541cd76c75SBen Gras int cpu_ucode_amd_firmware_open(firmware_handle_t *, const char *);
551cd76c75SBen Gras int cpu_ucode_amd_apply(struct cpu_ucode_softc *, int);
561cd76c75SBen Gras 
571cd76c75SBen Gras int cpu_ucode_intel_get_version(struct cpu_ucode_version *);
581cd76c75SBen Gras int cpu_ucode_intel_firmware_open(firmware_handle_t *, const char *);
591cd76c75SBen Gras int cpu_ucode_intel_apply(struct cpu_ucode_softc *, int);
601cd76c75SBen Gras #endif /* _KERNEL */
611cd76c75SBen Gras 
621cd76c75SBen Gras struct intel1_ucode_header {
631cd76c75SBen Gras 	uint32_t	uh_header_ver;
641cd76c75SBen Gras 	uint32_t	uh_rev;
651cd76c75SBen Gras 	uint32_t	uh_date;
661cd76c75SBen Gras 	uint32_t	uh_signature;
671cd76c75SBen Gras 	uint32_t	uh_checksum;
681cd76c75SBen Gras 	uint32_t	uh_loader_rev;
691cd76c75SBen Gras 	uint32_t	uh_proc_flags;
701cd76c75SBen Gras 	uint32_t	uh_data_size;
711cd76c75SBen Gras 	uint32_t	uh_total_size;
721cd76c75SBen Gras 	uint32_t	uh_reserved[3];
731cd76c75SBen Gras };
741cd76c75SBen Gras 
751cd76c75SBen Gras struct intel1_ucode_proc_signature {
761cd76c75SBen Gras 	uint32_t	ups_signature;
771cd76c75SBen Gras 	uint32_t	ups_proc_flags;
781cd76c75SBen Gras 	uint32_t	ups_checksum;
791cd76c75SBen Gras };
801cd76c75SBen Gras 
811cd76c75SBen Gras struct intel1_ucode_ext_table {
821cd76c75SBen Gras 	uint32_t	uet_count;
831cd76c75SBen Gras 	uint32_t	uet_checksum;
841cd76c75SBen Gras 	uint32_t	uet_reserved[3];
851cd76c75SBen Gras 	struct intel1_ucode_proc_signature uet_proc_sig[1];
861cd76c75SBen Gras };
871cd76c75SBen Gras 
881cd76c75SBen Gras #endif
89