blob: 8a39ab90ac3057140ea249175d8bc765ce86e36a [file] [log] [blame]
Stefan Reinauer6540ae52007-07-12 16:35:42 +00001/*****************************************************************************\
2 * layout.h
Stefan Reinauer6540ae52007-07-12 16:35:42 +00003 *****************************************************************************
4 * Copyright (C) 2002-2005 The Regents of the University of California.
5 * Produced at the Lawrence Livermore National Laboratory.
6 * Written by Dave Peterson <dsp@llnl.gov> <dave_peterson@pobox.com>.
7 * UCRL-CODE-2003-012
8 * All rights reserved.
9 *
Uwe Hermann6e565942008-03-01 19:06:32 +000010 * This file is part of nvramtool, a utility for reading/writing coreboot
Stefan Reinauerf527e702008-01-18 15:33:49 +000011 * parameters and displaying information from the coreboot table.
Uwe Hermann6e565942008-03-01 19:06:32 +000012 * For details, see http://coreboot.org/nvramtool.
Stefan Reinauer6540ae52007-07-12 16:35:42 +000013 *
14 * Please also read the file DISCLAIMER which is included in this software
15 * distribution.
16 *
17 * This program is free software; you can redistribute it and/or modify it
18 * under the terms of the GNU General Public License (as published by the
19 * Free Software Foundation) version 2, dated June 1991.
20 *
21 * This program is distributed in the hope that it will be useful, but
22 * WITHOUT ANY WARRANTY; without even the IMPLIED WARRANTY OF
23 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the terms and
24 * conditions of the GNU General Public License for more details.
Stefan Reinauer6540ae52007-07-12 16:35:42 +000025\*****************************************************************************/
26
Uwe Hermann6e565942008-03-01 19:06:32 +000027#ifndef LAYOUT_H
28#define LAYOUT_H
Stefan Reinauer6540ae52007-07-12 16:35:42 +000029
30#include "common.h"
Stefan Reinauer7223ab72008-01-18 16:17:44 +000031#include "coreboot_tables.h"
Stefan Reinauer6540ae52007-07-12 16:35:42 +000032
33#define LAYOUT_ENTRY_OVERLAP (LAYOUT_RESULT_START + 0)
34#define LAYOUT_ENTRY_BAD_LENGTH (LAYOUT_RESULT_START + 1)
35#define LAYOUT_DUPLICATE_ENUM (LAYOUT_RESULT_START + 2)
36#define LAYOUT_SUMMED_AREA_START_NOT_ALIGNED (LAYOUT_RESULT_START + 3)
37#define LAYOUT_SUMMED_AREA_END_NOT_ALIGNED (LAYOUT_RESULT_START + 4)
38#define LAYOUT_CHECKSUM_LOCATION_NOT_ALIGNED (LAYOUT_RESULT_START + 5)
39#define LAYOUT_INVALID_SUMMED_AREA (LAYOUT_RESULT_START + 6)
40#define LAYOUT_CHECKSUM_OVERLAPS_SUMMED_AREA (LAYOUT_RESULT_START + 7)
41#define LAYOUT_SUMMED_AREA_OUT_OF_RANGE (LAYOUT_RESULT_START + 8)
42#define LAYOUT_CHECKSUM_LOCATION_OUT_OF_RANGE (LAYOUT_RESULT_START + 9)
43
Stefan Reinauer90b96b62010-01-13 21:00:23 +000044typedef enum {
Vikram Narayanana8111cf2012-04-14 15:25:13 +053045 CMOS_ENTRY_ENUM = 'e',
46 CMOS_ENTRY_HEX = 'h',
47 CMOS_ENTRY_STRING = 's',
48 CMOS_ENTRY_RESERVED = 'r',
Stefan Reinauer90b96b62010-01-13 21:00:23 +000049} cmos_entry_config_t;
Stefan Reinauer6540ae52007-07-12 16:35:42 +000050
51/* This represents a CMOS parameter. */
Stefan Reinauer90b96b62010-01-13 21:00:23 +000052typedef struct {
53 unsigned bit;
54 unsigned length;
55 cmos_entry_config_t config;
56 unsigned config_id;
57 char name[CMOS_MAX_NAME_LENGTH + 1];
58} cmos_entry_t;
Stefan Reinauer6540ae52007-07-12 16:35:42 +000059
60/* This represents a possible value for a CMOS parameter of type
61 * CMOS_ENTRY_ENUM.
62 */
Stefan Reinauer90b96b62010-01-13 21:00:23 +000063typedef struct {
64 unsigned config_id;
65 unsigned long long value;
66 char text[CMOS_MAX_TEXT_LENGTH + 1];
67} cmos_enum_t;
Stefan Reinauer6540ae52007-07-12 16:35:42 +000068
Stefan Reinauer90b96b62010-01-13 21:00:23 +000069/* This represents the location of the CMOS checksum and the area over
70 * which it is computed. Depending on the context, the values may be
71 * represented as either bit positions or byte positions.
Stefan Reinauer6540ae52007-07-12 16:35:42 +000072 */
Stefan Reinauer90b96b62010-01-13 21:00:23 +000073typedef struct {
74 unsigned summed_area_start; /* first checksummed location */
75 unsigned summed_area_end; /* last checksummed location */
76 unsigned checksum_at; /* location of checksum */
77} cmos_checksum_layout_t;
Stefan Reinauer6540ae52007-07-12 16:35:42 +000078
79extern const char checksum_param_name[];
80
81extern unsigned cmos_checksum_start;
82
83extern unsigned cmos_checksum_end;
84
85extern unsigned cmos_checksum_index;
86
87typedef void (*cmos_layout_get_fn_t) (void);
88
Stefan Reinauer90b96b62010-01-13 21:00:23 +000089void register_cmos_layout_get_fn(cmos_layout_get_fn_t fn);
90void get_cmos_layout(void);
91int add_cmos_entry(const cmos_entry_t * e, const cmos_entry_t ** conflict);
92const cmos_entry_t *find_cmos_entry(const char name[]);
93const cmos_entry_t *first_cmos_entry(void);
94const cmos_entry_t *next_cmos_entry(const cmos_entry_t * last);
95int add_cmos_enum(const cmos_enum_t * e);
96const cmos_enum_t *find_cmos_enum(unsigned config_id, unsigned long long value);
97const cmos_enum_t *first_cmos_enum(void);
98const cmos_enum_t *next_cmos_enum(const cmos_enum_t * last);
99const cmos_enum_t *first_cmos_enum_id(unsigned config_id);
100const cmos_enum_t *next_cmos_enum_id(const cmos_enum_t * last);
101int is_checksum_name(const char name[]);
102int checksum_layout_to_bytes(cmos_checksum_layout_t * layout);
103void checksum_layout_to_bits(cmos_checksum_layout_t * layout);
Stefan Reinauer6540ae52007-07-12 16:35:42 +0000104
Stefan Reinauer90b96b62010-01-13 21:00:23 +0000105#endif /* LAYOUT_H */