]> git.zerfleddert.de Git - rsbs2/blobdiff - bmc/ipmb.c
add howto exception list
[rsbs2] / bmc / ipmb.c
index 65ddea0b36a7bf4b810e82f82fa0df0e7d9f5f16..b18d664acd67992b280cbbd2f774cb81790db397 100644 (file)
@@ -1,3 +1,4 @@
+#include <avr/pgmspace.h>
 #include <string.h>
 #include <stdio.h>
 
 #include <string.h>
 #include <stdio.h>
 
@@ -17,7 +18,7 @@ uint8_t ipmb_csum(unsigned char *buf, int len)
        return -csum;
 }
 
        return -csum;
 }
 
-void ipmb_send(struct ipmb_resp *resp)
+void ipmb_send(struct ipmb_resp *resp, const unsigned char *data, uint8_t datalen)
 {
        unsigned char buf[24];
        int len;
 {
        unsigned char buf[24];
        int len;
@@ -31,8 +32,8 @@ void ipmb_send(struct ipmb_resp *resp)
        buf[3] = resp->rsSA;
        buf[4] = ((resp->rqSEQ)<<2) | (resp->rsLUN & 0x3);
        buf[5] = resp->cmd;
        buf[3] = resp->rsSA;
        buf[4] = ((resp->rqSEQ)<<2) | (resp->rsLUN & 0x3);
        buf[5] = resp->cmd;
-       memcpy(buf+6, resp->data, resp->datalen);
-       len = resp->datalen + 7;
+       memcpy_P(buf+6, data, datalen);
+       len = datalen + 7;
        buf[len-1] = ipmb_csum(buf+3, len - 4);
 
 #ifdef DEBUG
        buf[len-1] = ipmb_csum(buf+3, len - 4);
 
 #ifdef DEBUG
@@ -71,24 +72,36 @@ void ipmb_dump_req(struct ipmb_req *req)
 
 void ipmb_invalid(struct ipmb_resp *resp)
 {
 
 void ipmb_invalid(struct ipmb_resp *resp)
 {
-#if 0
-       static unsigned char cmd_invalid[] = {0xc2};
+#if 1
+       static const unsigned char cmd_invalid[] PROGMEM = {IPMB_CC_INVALID};
 
 
-       resp->data = cmd_invalid;
-       resp->datalen = sizeof(cmd_invalid);
-       ipmb_send(resp);
+       ipmb_send(resp, cmd_invalid, sizeof(cmd_invalid));
 #endif
 }
 
 void ipmb_cmd(struct ipmb_req *req)
 {
        struct ipmb_resp resp;
 #endif
 }
 
 void ipmb_cmd(struct ipmb_req *req)
 {
        struct ipmb_resp resp;
-       static unsigned char get_devid[] =
+       static const unsigned char get_devid[] PROGMEM =
                {IPMB_CC_NORMALLY, 0x42, 0x42, 0x01, 0x01, 0x51, 0xff /* Add. Dev. Supp */, 0x00, 0x00, 0x00, 0x00, 0x00 };
                {IPMB_CC_NORMALLY, 0x42, 0x42, 0x01, 0x01, 0x51, 0xff /* Add. Dev. Supp */, 0x00, 0x00, 0x00, 0x00, 0x00 };
-       static unsigned char get_wd_timer[] =
+       static const unsigned char get_wd_timer[] PROGMEM =
                {IPMB_CC_NORMALLY, 0x42, 0x00, 0x00, 0x04, 0xff, 0xff, 0xfe, 0xfe};
                {IPMB_CC_NORMALLY, 0x42, 0x00, 0x00, 0x04, 0xff, 0xff, 0xfe, 0xfe};
-       static unsigned char cc_normal[] =
+       static const unsigned char cc_normal[] PROGMEM =
                {IPMB_CC_NORMALLY};
                {IPMB_CC_NORMALLY};
+       static const unsigned char sel_info[] PROGMEM =
+               {IPMB_CC_NORMALLY, 0x51, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00};
+       static const unsigned char sel_alloc_info[] PROGMEM =
+               {IPMB_CC_NORMALLY, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
+       static const unsigned char sel_entry[] PROGMEM =
+               {IPMB_CC_ERROR};
+       static const unsigned char sel_timestamp[] PROGMEM =
+               {IPMB_CC_NORMALLY, 0x00, 0x00, 0x00, 0x00};
+       static const unsigned char chassis_status[] PROGMEM =
+               {IPMB_CC_NORMALLY, 0x60, 0x10, 0x00, 0x00};
+       static const unsigned char reserve_sdr[] PROGMEM =
+               {IPMB_CC_NORMALLY, 0x00, 0x00};
+       static const unsigned char get_sdr[] PROGMEM =
+               {IPMB_CC_NORMALLY, 0xff, 0xff};
 
        resp.rqSA = req->rqSA;
        resp.netFn = req->netFn+1;
 
        resp.rqSA = req->rqSA;
        resp.netFn = req->netFn+1;
@@ -101,11 +114,12 @@ void ipmb_cmd(struct ipmb_req *req)
        switch (req->netFn) {
                case IPMB_NETFN_CHASSIS:
                        switch (req->cmd) {
        switch (req->netFn) {
                case IPMB_NETFN_CHASSIS:
                        switch (req->cmd) {
+                               case IPMB_CHASSIS_GET_STATUS:
+                                       ipmb_send(&resp, chassis_status, sizeof(chassis_status));
+                                       break;
                                case IPMB_CHASSIS_CONTROL:
                                        chassis_control(*(req->data));
                                case IPMB_CHASSIS_CONTROL:
                                        chassis_control(*(req->data));
-                                       resp.data = cc_normal;
-                                       resp.datalen = sizeof(cc_normal);
-                                       ipmb_send(&resp);
+                                       ipmb_send(&resp, cc_normal, sizeof(cc_normal));
                                        break;
                                default:
 #ifdef DEBUG
                                        break;
                                default:
 #ifdef DEBUG
@@ -119,6 +133,30 @@ void ipmb_cmd(struct ipmb_req *req)
 
                case IPMB_NETFN_SENSOR_EVENT:
                        switch (req->cmd) {
 
                case IPMB_NETFN_SENSOR_EVENT:
                        switch (req->cmd) {
+                               case IPMB_SE_PLATFORM_EVENT:
+                                       /*
+                                        * >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
+                                        * Connection Header:
+                                        *         rs Slave Addr.: 0x24
+                                        *         netFn: 0x04, LUN: 0x00
+                                        * Data:
+                                        *         rq Slave Addr.: 0x28
+                                        *         rqSeq: 0x03, rqLUN: 0x00
+                                        *         cmd: 0x02
+                                        *         Data: 0x03 0xc8 0x00 0x6f 0x61 0x8f 0x03
+                                        * <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
+                                        * data[0] - EvMRev:                            0x03
+                                        * data[1] - Sensor Type:                       0xc8
+                                        * data[2] - Sensor #:                          0x00
+                                        * data[3] - Event Dir(1)|Event Type(7):        0x6f: 0x0|0x6f (assert, discrete)
+                                        * data[4] - Event Data:                        0x61
+                                        * data[5] - Event Data:                        0x8f
+                                        * data[6] - Event Data:                        0x03
+                                        */
+                                       ipmb_send(&resp, cc_normal, sizeof(cc_normal));
+                                       break;
+
+                                       
                                default:
 #ifdef DEBUG
                                        printf("Unknown sensor cmd 0x%02x\n", req->cmd);
                                default:
 #ifdef DEBUG
                                        printf("Unknown sensor cmd 0x%02x\n", req->cmd);
@@ -132,15 +170,11 @@ void ipmb_cmd(struct ipmb_req *req)
                case IPMB_NETFN_APP:
                        switch (req->cmd) {
                                case IPMB_APP_GET_DEVICE_ID:
                case IPMB_NETFN_APP:
                        switch (req->cmd) {
                                case IPMB_APP_GET_DEVICE_ID:
-                                       resp.data = get_devid;
-                                       resp.datalen = sizeof(get_devid);
-                                       ipmb_send(&resp);
+                                       ipmb_send(&resp, get_devid, sizeof(get_devid));
                                        break;
 
                                case IPMB_APP_GET_WATCHDOG_TIMER:
                                        break;
 
                                case IPMB_APP_GET_WATCHDOG_TIMER:
-                                       resp.data = get_wd_timer;
-                                       resp.datalen = sizeof(get_wd_timer);
-                                       ipmb_send(&resp);
+                                       ipmb_send(&resp, get_wd_timer, sizeof(get_wd_timer));
                                        break;
 
                                default:
                                        break;
 
                                default:
@@ -155,6 +189,24 @@ void ipmb_cmd(struct ipmb_req *req)
 
                case IPMB_NETFN_STORAGE:
                        switch (req->cmd) {
 
                case IPMB_NETFN_STORAGE:
                        switch (req->cmd) {
+                               case IPMB_STORAGE_RESERVE_SDR:
+                                       ipmb_send(&resp, reserve_sdr, sizeof(reserve_sdr));
+                                       break;
+                               case IPMB_STORAGE_GET_SDR:
+                                       ipmb_send(&resp, get_sdr, sizeof(get_sdr));
+                                       break;
+                               case IPMB_STORAGE_GET_SEL_INFO:
+                                       ipmb_send(&resp, sel_info, sizeof(sel_info));
+                                       break;
+                               case IPMB_STORAGE_GET_SEL_ALLOCATION:
+                                       ipmb_send(&resp, sel_alloc_info, sizeof(sel_alloc_info));
+                                       break;
+                               case IPMB_STORAGE_GET_SEL_ENTRY:
+                                       ipmb_send(&resp, sel_entry, sizeof(sel_entry));
+                                       break;
+                               case IPMB_STORAGE_GET_SEL_TIME:
+                                       ipmb_send(&resp, sel_timestamp, sizeof(sel_timestamp));
+                                       break;
                                default:
 #ifdef DEBUG
                                        printf("Unknown storage cmd 0x%02x\n", req->cmd);
                                default:
 #ifdef DEBUG
                                        printf("Unknown storage cmd 0x%02x\n", req->cmd);
Impressum, Datenschutz