blob: 09f4d7641a16b6756a46b91554486aa8ae3ad461 [file] [log] [blame]
Alexandru Gagniuce644bad2012-08-07 19:38:32 -05001/*
2 * This file is part of the coreboot project.
3 *
4 * Copyright (C) 2012 Alexandru Gagniuc <mr.nuke.me@gmail.com>
5 *
6 * This program is free software: you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation, either version 2 of the License, or
9 * (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
Alexandru Gagniuce644bad2012-08-07 19:38:32 -050015 */
16#ifndef __UPDATE_UCODE_H
17#define __UPDATE_UCODE_H
18
19#include <console/console.h>
20#include <cpu/cpu.h>
21
22#define MSR_IA32_BIOS_UPDT_TRIG 0x00000079
23#define MSR_IA32_BIOS_SIGN_ID 0x0000008b
24#define MSR_UCODE_UPDATE_STATUS 0x00001205
25
26#define NANO_UCODE_SIGNATURE 0x53415252
27#define NANO_UCODE_HEADER_SIZE 0x30
28
29/* These are values returned by the CPU after we attempt microcode updates.
30 * We care what these values are exactly, so we define them to be sure */
31typedef enum {
32 UCODE_UPDATE_NOT_ATTEMPTED = 0x0,
33 UCODE_UPDATE_SUCCESS = 0x1,
34 UCODE_UPDATE_FAIL = 0x2,
35 UCODE_UPDATE_WRONG_CPU = 0x3,
36 UCODE_INVALID_UPDATE_BLOCK = 0x4,
37} ucode_update_status;
38
39
40typedef enum {
41 NANO_UCODE_VALID = 0, /* We only care that valid == 0 */
42 NANO_UCODE_SIGNATURE_ERROR,
43 NANO_UCODE_WRONG_SIZE,
44 NANO_UCODE_CHECKSUM_FAIL,
45} ucode_validity;
46
47typedef struct {
48 u32 signature; /* NANO_UCODE_SIGNATURE */
49 u32 update_revision; /* Revision of the update header */
50 u16 year; /* Year of patch release */
51 u8 day; /* Day of patch release */
52 u8 month; /* Month of patch release */
53 u32 applicable_fms; /* Fam/model/stepping to which ucode applies */
54 u32 checksum; /* Two's complement checksum of ucode+header */
55 u32 loader_revision; /* Revision of hardware ucode update loader*/
Martin Roth4c3ab732013-07-08 16:23:54 -060056 u32 rfu_1; /* Reserved for future use */
Alexandru Gagniuce644bad2012-08-07 19:38:32 -050057 u32 payload_size; /* Size of the ucode payload only */
58 u32 total_size; /* Size of the ucode, including header */
59 char name[8]; /* ASCII string of ucode filename */
Martin Roth4c3ab732013-07-08 16:23:54 -060060 u32 rfu_2; /* Reserved for future use */
Alexandru Gagniuce644bad2012-08-07 19:38:32 -050061 /* First double-word of the ucode payload
62 * Its address represents the beginning of the ucode update we need to
63 * send to the CPU */
64 u32 ucode_start;
65
66} nano_ucode_header;
67
68unsigned int nano_update_ucode(void);
69
70#endif /* __UPDATE_UCODE_H */