1 /* ----------------------------------------------------------------------- *
2  *
3  *   Copyright 2006 Erwan Velu - All Rights Reserved
4  *
5  *   This program is free software; you can redistribute it and/or modify
6  *   it under the terms of the GNU General Public License as published by
7  *   the Free Software Foundation, Inc., 53 Temple Place Ste 330,
8  *   Boston MA 02111-1307, USA; either version 2 of the License, or
9  *   (at your option) any later version; incorporated herein by reference.
10  *
11  * ----------------------------------------------------------------------- */
12 
13 #ifndef DMI_H
14 #define DMI_H
15 #include <inttypes.h>
16 #define MAX_DMI_MEMORY_ITEMS 32
17 #define MAX_DMI_CACHE_ITEMS 32
18 #define OEM_STRINGS_SIZE 512
19 #define HARDWARE_SECURITY_SIZE 16
20 
21 #define PAGE_SIZE 4096
22 
23 extern const char *out_of_spec;
24 extern const char *bad_index;
25 
26 #define WORD(x) (uint16_t)(*(const uint16_t *)(x))
27 #define DWORD(x) (uint32_t)(*(const uint32_t *)(x))
28 #define QWORD(x) (*(const uint64_t *)(x))
29 
30 enum { DMI_TABLE_PRESENT = 100, ENODMITABLE };
31 
32 #include "dmi_bios.h"
33 #include "dmi_system.h"
34 #include "dmi_base_board.h"
35 #include "dmi_chassis.h"
36 #include "dmi_processor.h"
37 #include "dmi_memory.h"
38 #include "dmi_battery.h"
39 #include "dmi_ipmi.h"
40 #include "dmi_cache.h"
41 
42 extern char display_line;
43 #define moreprintf(...) do { display_line++; if (display_line == 24) { char tempbuf[10]; display_line=0; printf("Press enter to continue"); fgets(tempbuf, sizeof tempbuf, stdin);}  printf ( __VA_ARGS__); } while (0);
44 
45 typedef struct {
46     uint16_t num;
47     uint16_t len;
48     uint16_t ver;
49     uint32_t base;
50     uint16_t major_version;
51     uint16_t minor_version;
52 } dmi_table;
53 
54 struct dmi_header {
55     uint8_t type;
56     uint8_t length;
57     uint16_t handle;
58     uint8_t *data;
59 };
60 
61 typedef struct {
62     s_bios bios;
63     s_system system;
64     s_base_board base_board;
65     s_chassis chassis;
66     s_processor processor;
67     s_battery battery;
68     s_memory_module memory_module[MAX_DMI_MEMORY_ITEMS];
69     s_memory memory[MAX_DMI_MEMORY_ITEMS];
70     s_ipmi ipmi;
71     s_cache cache[MAX_DMI_CACHE_ITEMS];
72     int memory_module_count;
73     int memory_count;
74     int cache_count;
75     dmi_table dmitable;
76     char oem_strings[OEM_STRINGS_SIZE];
77     struct {
78 	char power_on_passwd_status[HARDWARE_SECURITY_SIZE];
79 	char keyboard_passwd_status[HARDWARE_SECURITY_SIZE];
80 	char administrator_passwd_status[HARDWARE_SECURITY_SIZE];
81 	char front_panel_reset_status[HARDWARE_SECURITY_SIZE];
82 	bool filled;
83     } hardware_security;
84 } s_dmi;
85 
86 void to_dmi_header(struct dmi_header *h, uint8_t * data);
87 void dmi_bios_runtime_size(uint32_t code, s_dmi * dmi);
88 const char *dmi_string(struct dmi_header *dm, uint8_t s);
89 int dmi_checksum(uint8_t * buf, int len);
90 void parse_dmitable(s_dmi * dmi);
91 void dmi_decode(struct dmi_header *h, uint16_t ver, s_dmi * dmi);
92 int dmi_iterate(s_dmi * dmi);
93 
94 /* dmi_utils.c */
95 void display_bios_characteristics(s_dmi * dmi);
96 void display_base_board_features(s_dmi * dmi);
97 void display_processor_flags(s_dmi * dmi);
98 #endif
99