1181430Sstas/*-
2330449Seadler * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
3330449Seadler *
4181430Sstas * Copyright (c) 2006, 2008 Stanislav Sedov <stas@FreeBSD.org>.
5181430Sstas * All rights reserved.
6181430Sstas *
7181430Sstas * Redistribution and use in source and binary forms, with or without
8181430Sstas * modification, are permitted provided that the following conditions
9181430Sstas * are met:
10181430Sstas * 1. Redistributions of source code must retain the above copyright
11181430Sstas *    notice, this list of conditions and the following disclaimer.
12181430Sstas * 2. Redistributions in binary form must reproduce the above copyright
13181430Sstas *    notice, this list of conditions and the following disclaimer in the
14181430Sstas *    documentation and/or other materials provided with the distribution.
15181430Sstas *
16181430Sstas * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
17181430Sstas * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
18181430Sstas * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
19181430Sstas * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
20181430Sstas * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
21181430Sstas * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
22181430Sstas * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
23181430Sstas * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24181430Sstas * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
25181430Sstas * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26181430Sstas *
27181430Sstas * $FreeBSD: stable/11/usr.sbin/cpucontrol/amd.h 330449 2018-03-05 07:26:05Z eadler $
28181430Sstas */
29181430Sstas
30181430Sstas#ifndef AMD_H
31181430Sstas#define	AMD_H
32181430Sstas
33181430Sstas/*
34181430Sstas * Prototypes.
35181430Sstas */
36181430Sstasucode_probe_t	amd_probe;
37181430Sstasucode_update_t	amd_update;
38308760Savgucode_probe_t	amd10h_probe;
39308760Savgucode_update_t	amd10h_update;
40181430Sstas
41181430Sstastypedef struct amd_fw_header {
42181430Sstas	uint32_t	date;		/* Update creation date. */
43181430Sstas	uint32_t	xz0[2];
44181430Sstas	uint32_t	checksum;	/* ucode checksum. */
45181430Sstas	uint32_t	xz1[2];
46181430Sstas	uint32_t	signature;	/* Low byte of cpuid(0). */
47181430Sstas	uint32_t	magic;		/* 0x0Xaaaaaa */
48181430Sstas	uint32_t	xz2[8];
49181430Sstas} amd_fw_header_t;
50181430Sstas
51181430Sstas#define	AMD_MAGIC	0xaaaaaa
52181430Sstas
53308760Savg/*
54308760Savg * AMD family 10h and later.
55308760Savg */
56308760Savgtypedef struct amd_10h_fw_header {
57308760Savg	uint32_t	data_code;
58308760Savg	uint32_t	patch_id;
59308760Savg	uint16_t	mc_patch_data_id;
60308760Savg	uint8_t		mc_patch_data_len;
61308760Savg	uint8_t		init_flag;
62308760Savg	uint32_t	mc_patch_data_checksum;
63308760Savg	uint32_t	nb_dev_id;
64308760Savg	uint32_t	sb_dev_id;
65308760Savg	uint16_t	processor_rev_id;
66308760Savg	uint8_t		nb_rev_id;
67308760Savg	uint8_t		sb_rev_id;
68308760Savg	uint8_t		bios_api_rev;
69308760Savg	uint8_t		reserved1[3];
70308760Savg	uint32_t	match_reg[8];
71308760Savg} amd_10h_fw_header_t;
72308760Savg
73308760Savgtypedef struct equiv_cpu_entry {
74308760Savg	uint32_t	installed_cpu;
75308760Savg	uint32_t	fixed_errata_mask;
76308760Savg	uint32_t	fixed_errata_compare;
77308760Savg	uint16_t	equiv_cpu;
78308760Savg	uint16_t	res;
79308760Savg} equiv_cpu_entry_t;
80308760Savg
81308760Savgtypedef struct section_header {
82308760Savg	uint32_t	type;
83308760Savg	uint32_t	size;
84308760Savg} section_header_t;
85308760Savg
86308760Savgtypedef struct container_header {
87308760Savg	uint32_t	magic;
88308760Savg} container_header_t;
89308760Savg
90308760Savg#define	AMD_10H_MAGIC			0x414d44
91308760Savg#define AMD_10H_EQUIV_TABLE_TYPE	0
92308760Savg#define AMD_10H_uCODE_TYPE		1
93308760Savg
94181430Sstas#endif /* !AMD_H */
95