openMMC
Open Source Modular MMC for AMCs
Loading...
Searching...
No Matches
sdr.h
Go to the documentation of this file.
1/*
2 * openMMC -- Open Source modular IPM Controller firmware
3 *
4 * Copyright (C) 2015 Piotr Miedzik <P.Miedzik@gsi.de>
5 * Copyright (C) 2015-2016 Henrique Silva <henrique.silva@lnls.br>
6 *
7 * This program is free software: you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation, either version 3 of the License, or
10 * (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program. If not, see <http://www.gnu.org/licenses/>.
19 *
20 * @license GPL-3.0+ <http://spdx.org/licenses/GPL-3.0+>
21 */
22
23#ifndef SDR_H_
24#define SDR_H_
25
26#include "ipmb.h"
27
28#define NUM_SENSOR 21 /* Number of sensors */
29#define NUM_SDR (NUM_SENSOR+1) /* Number of SDRs */
30
31/* Sensor Types */
32#define SENSOR_TYPE_TEMPERATURE 0x01
33#define SENSOR_TYPE_VOLTAGE 0x02
34#define SENSOR_TYPE_CURRENT 0x03
35#define SENSOR_TYPE_FAN 0x04
36#define SENSOR_TYPE_WATCHDOG 0x23
37#define SENSOR_TYPE_VERSION_CHANGE 0x2B
38#define SENSOR_TYPE_HOT_SWAP 0xF2
39
40/* Assertion Event Codes */
41#define ASSERTION_EVENT 0x00
42#define DEASSERTION_EVENT 0x80
43
44/* Sensor States */
45#define SENSOR_STATE_NORMAL 0x00 // temperature is in normal range
46#define SENSOR_STATE_LOW 0x01 // temperature is below lower non critical
47#define SENSOR_STATE_LOW_CRIT 0x02 // temperature is below lower critical
48#define SENSOR_STATE_LOW_NON_REC 0x04 // temperature is below lower non recoverable
49#define SENSOR_STATE_HIGH 0x08 // temperature is higher upper non critical
50#define SENSOR_STATE_HIGH_CRIT 0x10 // temperature is higher upper critical
51#define SENSOR_STATE_HIGH_NON_REC 0x20 // temperature is higher high non recoverable
52
53/* IPMI Sensor Events */
54#define IPMI_THRESHOLD_LNC_GL 0x00 // lower non critical going low
55#define IPMI_THRESHOLD_LNC_GH 0x01 // lower non critical going high
56#define IPMI_THRESHOLD_LC_GL 0x02 // lower critical going low
57#define IPMI_THRESHOLD_LC_GH 0x03 // lower critical going HIGH
58#define IPMI_THRESHOLD_LNR_GL 0x04 // lower non recoverable going low
59#define IPMI_THRESHOLD_LNR_GH 0x05 // lower non recoverable going high
60#define IPMI_THRESHOLD_UNC_GL 0x06 // upper non critical going low
61#define IPMI_THRESHOLD_UNC_GH 0x07 // upper non critical going high
62#define IPMI_THRESHOLD_UC_GL 0x08 // upper critical going low
63#define IPMI_THRESHOLD_UC_GH 0x09 // upper critical going HIGH
64#define IPMI_THRESHOLD_UNR_GL 0x0A // upper non recoverable going low
65#define IPMI_THRESHOLD_UNR_GH 0x0B // upper non recoverable going high
66
67/* Constants for comparison function */
68#define UNSIGNED 0x00
69#define SIGNED 0x01
70
71#define LOWER_EQ 0x00
72#define UPPER_EQ 0x01
73
74
75typedef enum {
76 TYPE_01 = 0x1,
77 TYPE_02 = 0x2,
78 TYPE_11 = 0x11,
79 TYPE_12 = 0x12
81
82typedef struct {
83 uint8_t recID_LSB;
84 uint8_t recID_MSB;
85 uint8_t SDRversion;
86 uint8_t rectype;
87 uint8_t reclength;
89
90typedef struct {
92 uint8_t ownerID;
93 uint8_t ownerLUN;
94 uint8_t sensornum;
95 uint8_t entityID;
97 uint8_t sensorinit;
98 uint8_t sensorcap;
99 uint8_t sensortype;
109 uint8_t M;
110 uint8_t M_tol;
111 uint8_t B;
112 uint8_t B_accuracy;
114 uint8_t Rexp_Bexp;
117 uint8_t normal_max;
118 uint8_t normal_min;
129 uint8_t reserved1;
130 uint8_t reserved2;
131 uint8_t OEM;
132 uint8_t IDtypelen;
133 char IDstring[16]; // bits 49-64 (0x40 length max)
134} SDR_type_01h_t; /* Full sensor */
135
136typedef struct {
138 // RECORD KEY BYTES
139 uint8_t ownerID;
140 uint8_t ownerLUN;
141 uint8_t sensornum;
142 // record body bytes
143 uint8_t entityID;
145 uint8_t sensorinit;
146 uint8_t sensorcap;
147 uint8_t sensortype;
156 uint8_t record_sharing[2];
159 uint8_t reserved1;
160 uint8_t reserved2;
161 uint8_t reserved3;
162 uint8_t OEM;
163 uint8_t IDtypelen;
164 char IDstring[16]; // bits 32-64 (0x40 length max)
165} SDR_type_02h_t; /* Compact Sensor */
166
167typedef struct {
169 uint8_t slaveaddr;
170 uint8_t chnum;
172 uint8_t device_cap;
173 uint8_t reserved[3];
174 uint8_t entityID;
176 uint8_t OEM;
177 uint8_t IDtypelen;
178 char IDstring[16];
180
181typedef struct sensor_t {
182 uint8_t num;
184 void * sdr;
185 uint8_t sdr_length;
186 uint8_t diag_devID;
187 uint8_t state;
188 uint8_t old_state;
190 uint8_t chipid;
191 uint8_t signed_flag;
192 uint8_t event_scan;
193 uint8_t ownerID; /* This field is repeated here because its value is assigned during initialization, so it can't be const */
194 uint8_t entityinstance; /* This field is repeated here because its value is assigned during initialization, so it can't be const */
195 TaskHandle_t * task_handle;
196 struct {
210 void* settings;
211 struct sensor_t *next;
213
214extern volatile uint8_t sdr_count;
215extern sensor_t *sdr_head;
216extern sensor_t *sdr_tail;
217
218extern const SDR_type_12h_t SDR0;
220
221#define GET_SENSOR_TYPE(sensor) ((SDR_type_01h_t *)sensor->sdr)->sensortype
222
223#define GET_EVENT_TYPE_CODE(n) ((SDR_type_01h_t *)sensor->sdr)->event_reading_type
224
225void sdr_init( void );
226void amc_sdr_init( void );
227#ifdef MODULE_RTM
228void rtm_sdr_init( void );
229#endif
230void sensor_init( void );
231void sensor_enable(sensor_t *sensor);
232void sensor_disable(sensor_t *sensor);
233void check_sensor_event( sensor_t * sensor );
234void sensor_state_check( sensor_t *sensor );
235sensor_t * sdr_insert_entry( SDR_TYPE type, void * sdr, TaskHandle_t *monitor_task, uint8_t diag_id, uint8_t slave_addr);
236void sdr_remove_entry( sensor_t * entry );
237void sdr_pop( void );
238sensor_t * sdr_add_settings(uint8_t chipid, void * settings);
240sensor_t * find_sensor_by_id( uint8_t id );
241
242#endif
Definitions used in IPMB Layer.
void rtm_sdr_init(void)
Definition sdr_list.c:179
void sensor_disable(sensor_t *sensor)
Definition sdr.c:244
SDR_TYPE
Definition sdr.h:75
@ TYPE_02
Definition sdr.h:77
@ TYPE_11
Definition sdr.h:78
@ TYPE_12
Definition sdr.h:79
@ TYPE_01
Definition sdr.h:76
void sdr_remove_entry(sensor_t *entry)
Definition sdr.c:200
sensor_t * sdr_head
Definition sdr.c:41
sensor_t * find_sensor_by_id(uint8_t id)
Definition sdr.c:188
sensor_t * sdr_tail
Definition sdr.c:42
const SDR_type_12h_t SDR0
Definition sdr.c:677
struct sensor_t sensor_t
void sdr_init(void)
Definition sdr.c:117
void sdr_pop(void)
Definition sdr.c:228
void amc_sdr_init(void)
Definition sdr_list.c:1014
sensor_t * find_sensor_by_sdr(void *sdr)
Definition sdr.c:175
volatile uint8_t sdr_count
Definition sdr.c:39
void sensor_init(void)
Definition sdr.c:90
void check_sensor_event(sensor_t *sensor)
Definition sdr.c:503
void sensor_enable(sensor_t *sensor)
Definition sdr.c:239
const SDR_type_12h_t SDR_RTM_DEV_LOCATOR
Definition sdr.c:701
sensor_t * sdr_add_settings(uint8_t chipid, void *settings)
Definition sdr.c:162
sensor_t * sdr_insert_entry(SDR_TYPE type, void *sdr, TaskHandle_t *monitor_task, uint8_t diag_id, uint8_t slave_addr)
Definition sdr.c:129
void sensor_state_check(sensor_t *sensor)
Definition sdr.c:475
Definition sdr.h:82
uint8_t reclength
Definition sdr.h:87
uint8_t SDRversion
Definition sdr.h:85
uint8_t recID_MSB
Definition sdr.h:84
uint8_t recID_LSB
Definition sdr.h:83
uint8_t rectype
Definition sdr.h:86
Definition sdr.h:90
uint16_t assertion_event_mask
Definition sdr.h:101
uint8_t lower_noncritical_thr
Definition sdr.h:126
uint16_t deassertion_event_mask
Definition sdr.h:102
uint8_t upper_nonrecover_thr
Definition sdr.h:121
uint8_t B
Definition sdr.h:111
uint8_t analog_flags
Definition sdr.h:115
uint8_t ownerID
Definition sdr.h:92
uint8_t sensorinit
Definition sdr.h:97
uint8_t sensortype
Definition sdr.h:99
uint8_t sensor_units_3
Definition sdr.h:107
uint8_t OEM
Definition sdr.h:131
uint8_t sensor_units_2
Definition sdr.h:106
uint8_t reserved1
Definition sdr.h:129
uint8_t entityinstance
Definition sdr.h:96
uint8_t event_reading_type
Definition sdr.h:100
uint8_t IDtypelen
Definition sdr.h:132
uint8_t M
Definition sdr.h:109
uint8_t sensor_min_reading
Definition sdr.h:120
uint8_t readable_threshold_mask
Definition sdr.h:104
uint8_t M_tol
Definition sdr.h:110
SDR_entry_hdr_t hdr
Definition sdr.h:91
uint8_t sensorcap
Definition sdr.h:98
uint8_t nominal_reading
Definition sdr.h:116
uint8_t lower_critical_thr
Definition sdr.h:125
uint8_t pos_thr_hysteresis
Definition sdr.h:127
uint8_t Rexp_Bexp
Definition sdr.h:114
uint8_t acc_exp_sensor_dir
Definition sdr.h:113
uint8_t normal_max
Definition sdr.h:117
uint8_t sensor_units_1
Definition sdr.h:105
uint8_t entityID
Definition sdr.h:95
uint8_t upper_noncritical_thr
Definition sdr.h:123
uint8_t neg_thr_hysteresis
Definition sdr.h:128
uint8_t ownerLUN
Definition sdr.h:93
uint8_t lower_nonrecover_thr
Definition sdr.h:124
uint8_t upper_critical_thr
Definition sdr.h:122
uint8_t settable_threshold_mask
Definition sdr.h:103
uint8_t reserved2
Definition sdr.h:130
uint8_t B_accuracy
Definition sdr.h:112
uint8_t normal_min
Definition sdr.h:118
uint8_t sensornum
Definition sdr.h:94
uint8_t sensor_max_reading
Definition sdr.h:119
uint8_t linearization
Definition sdr.h:108
Definition sdr.h:136
uint8_t ownerLUN
Definition sdr.h:140
uint8_t reserved3
Definition sdr.h:161
uint16_t deassertion_event_mask
Definition sdr.h:150
uint8_t sensornum
Definition sdr.h:141
uint8_t IDtypelen
Definition sdr.h:163
uint16_t assertion_event_mask
Definition sdr.h:149
uint8_t sensor_units_1
Definition sdr.h:153
uint8_t reserved2
Definition sdr.h:160
uint8_t reserved1
Definition sdr.h:159
uint8_t sensortype
Definition sdr.h:147
uint8_t OEM
Definition sdr.h:162
uint8_t sensor_units_2
Definition sdr.h:154
uint8_t readable_threshold_mask
Definition sdr.h:152
uint8_t sensorinit
Definition sdr.h:145
uint8_t pos_thr_hysteresis
Definition sdr.h:157
uint8_t entityID
Definition sdr.h:143
uint8_t sensorcap
Definition sdr.h:146
uint8_t ownerID
Definition sdr.h:139
uint8_t neg_thr_hysteresis
Definition sdr.h:158
uint8_t event_reading_type
Definition sdr.h:148
uint8_t entityinstance
Definition sdr.h:144
SDR_entry_hdr_t hdr
Definition sdr.h:137
uint8_t settable_threshold_mask
Definition sdr.h:151
uint8_t sensor_units_3
Definition sdr.h:155
Definition sdr.h:167
uint8_t entityID
Definition sdr.h:174
uint8_t IDtypelen
Definition sdr.h:177
uint8_t power_notification_global_init
Definition sdr.h:171
uint8_t device_cap
Definition sdr.h:172
uint8_t chnum
Definition sdr.h:170
SDR_entry_hdr_t hdr
Definition sdr.h:168
uint8_t entityinstance
Definition sdr.h:175
uint8_t OEM
Definition sdr.h:176
uint8_t slaveaddr
Definition sdr.h:169
Definition sdr.h:181
uint16_t upper_critical_go_low
Definition sdr.h:200
TaskHandle_t * task_handle
Definition sdr.h:195
uint16_t upper_non_recoverable_go_high
Definition sdr.h:197
struct sensor_t * next
Definition sdr.h:211
uint8_t diag_devID
Definition sdr.h:186
uint16_t lower_non_critical_go_low
Definition sdr.h:208
uint8_t old_state
Definition sdr.h:188
uint16_t lower_critical_go_low
Definition sdr.h:206
uint8_t sdr_length
Definition sdr.h:185
uint16_t upper_non_critical_go_high
Definition sdr.h:201
uint8_t signed_flag
Definition sdr.h:191
uint8_t chipid
Definition sdr.h:190
SDR_TYPE sdr_type
Definition sdr.h:183
uint16_t lower_non_recoverable_go_low
Definition sdr.h:204
uint16_t lower_non_recoverable_go_high
Definition sdr.h:203
uint16_t upper_non_critical_go_low
Definition sdr.h:202
uint16_t lower_critical_go_high
Definition sdr.h:205
uint16_t upper_non_recoverable_go_low
Definition sdr.h:198
uint16_t readout_value
Definition sdr.h:189
uint8_t entityinstance
Definition sdr.h:194
uint16_t lower_non_critical_go_high
Definition sdr.h:207
struct sensor_t::@3 asserted_event
uint8_t num
Definition sdr.h:182
uint16_t upper_critical_go_high
Definition sdr.h:199
void * settings
Definition sdr.h:210
uint8_t state
Definition sdr.h:187
void * sdr
Definition sdr.h:184
uint8_t ownerID
Definition sdr.h:193
uint8_t event_scan
Definition sdr.h:192