]> git.zerfleddert.de Git - rsbs2/commitdiff
implement all remaining IPMB queries seen on the wire
authorMichael Gernoth <michael@gernoth.net>
Mon, 23 Aug 2010 22:46:50 +0000 (00:46 +0200)
committerMichael Gernoth <michael@gernoth.net>
Mon, 23 Aug 2010 22:46:50 +0000 (00:46 +0200)
bmc/config.h
bmc/i2c.c
bmc/i2c.h
bmc/ipmb.c
bmc/ipmb.h
bmc/usart.c
bmc/usart.h

index 83a346cba2b159770c71f1f24a1c53e4bce45991..b1e4e1273695a769fc7083e25e4cf1d13f4f505d 100644 (file)
@@ -1,4 +1,8 @@
+#define BMC_ADDR 0x24
+
 #define POWERUP_TIME_MS                200
 #define POWERDOWN_TIME_MS      5000
 #define RESET_TIME_MS          200
 #define POWER_CYCLE_PAUSE_MS   500
+
+#define BAUD 38400UL
index bd4d69ca589595a16b4254d2e79eca0f0e0eca43..07d2e7902a4e5a6858a550dd7c423baf450f5b6f 100644 (file)
--- a/bmc/i2c.c
+++ b/bmc/i2c.c
@@ -3,6 +3,7 @@
 #include <stdio.h>
 #include "i2c.h"
 #include "bmc.h"
+#include "config.h"
 #include "ipmb.h"
 
 #define TWCR_ACK TWCR = (1<<TWEN)|(1<<TWIE)|(1<<TWINT)|(1<<TWEA)|(0<<TWSTA)|(0<<TWSTO)|(0<<TWWC);  
index 7b783d76f3f3120fedf89c611f3a8d72ee26f27e..2e48d1c785b0f4c35d6ea5d9e1ad03fbdfc6243f 100644 (file)
--- a/bmc/i2c.h
+++ b/bmc/i2c.h
@@ -1,5 +1,3 @@
-#define BMC_ADDR 0x24
-
 extern volatile unsigned char i2c_databuf[24];
 extern volatile uint8_t i2c_len;
 extern volatile uint8_t i2c_done;
index 023b240a785ab7271f9a387d4a7ee8917028d470..fa057c92925404b3de34292c098c6506a9374e97 100644 (file)
@@ -17,7 +17,7 @@ uint8_t ipmb_csum(unsigned char *buf, int len)
        return -csum;
 }
 
-void ipmb_send(struct ipmb_resp *resp)
+void ipmb_send(struct ipmb_resp *resp, unsigned char *data, uint8_t datalen)
 {
        unsigned char buf[24];
        int len;
@@ -31,8 +31,8 @@ void ipmb_send(struct ipmb_resp *resp)
        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(buf+6, data, datalen);
+       len = datalen + 7;
        buf[len-1] = ipmb_csum(buf+3, len - 4);
 
 #ifdef DEBUG
@@ -71,12 +71,10 @@ void ipmb_dump_req(struct ipmb_req *req)
 
 void ipmb_invalid(struct ipmb_resp *resp)
 {
-#if 0
-       static unsigned char cmd_invalid[] = {0xc2};
+#if 1
+       static unsigned char cmd_invalid[] = {IPMB_CC_INVALID};
 
-       resp->data = cmd_invalid;
-       resp->datalen = sizeof(cmd_invalid);
-       ipmb_send(resp);
+       ipmb_send(resp, cmd_invalid, sizeof(cmd_invalid));
 #endif
 }
 
@@ -89,6 +87,20 @@ void ipmb_cmd(struct ipmb_req *req)
                {IPMB_CC_NORMALLY, 0x42, 0x00, 0x00, 0x04, 0xff, 0xff, 0xfe, 0xfe};
        static unsigned char cc_normal[] =
                {IPMB_CC_NORMALLY};
+       static unsigned char sel_info[] =
+               {IPMB_CC_NORMALLY, 0x51, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00};
+       static unsigned char sel_alloc_info[] =
+               {IPMB_CC_NORMALLY, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
+       static unsigned char sel_entry[] =
+               {IPMB_CC_ERROR};
+       static unsigned char sel_timestamp[] =
+               {IPMB_CC_NORMALLY, 0x00, 0x00, 0x00, 0x00};
+       static unsigned char chassis_status[] =
+               {IPMB_CC_NORMALLY, 0x60, 0x10, 0x00, 0x00};
+       static unsigned char reserve_sdr[] =
+               {IPMB_CC_NORMALLY, 0x00, 0x00};
+       static unsigned char get_sdr[] =
+               {IPMB_CC_NORMALLY, 0xff, 0xff};
 
        resp.rqSA = req->rqSA;
        resp.netFn = req->netFn+1;
@@ -101,11 +113,12 @@ void ipmb_cmd(struct ipmb_req *req)
        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));
-                                       resp.data = cc_normal;
-                                       resp.datalen = sizeof(cc_normal);
-                                       ipmb_send(&resp);
+                                       ipmb_send(&resp, cc_normal, sizeof(cc_normal));
                                        break;
                                default:
 #ifdef DEBUG
@@ -139,9 +152,7 @@ void ipmb_cmd(struct ipmb_req *req)
                                         * data[5] - Event Data:                        0x8f
                                         * data[6] - Event Data:                        0x03
                                         */
-                                       resp.data = cc_normal;
-                                       resp.datalen = sizeof(cc_normal);
-                                       ipmb_send(&resp);
+                                       ipmb_send(&resp, cc_normal, sizeof(cc_normal));
                                        break;
 
                                        
@@ -158,15 +169,11 @@ void ipmb_cmd(struct ipmb_req *req)
                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:
-                                       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:
@@ -181,6 +188,24 @@ void ipmb_cmd(struct ipmb_req *req)
 
                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);
index 1be0a486f7f58e0194cc078a752f106cace9aea8..c02b38f339f865b178c496328214679ec780903c 100644 (file)
@@ -6,7 +6,11 @@
 
 #define IPMB_SE_PLATFORM_EVENT         0x02
 
+#define IPMB_STORAGE_RESERVE_SDR       0x22
+#define IPMB_STORAGE_GET_SDR           0x23
 #define IPMB_STORAGE_GET_SEL_INFO      0x40
+#define IPMB_STORAGE_GET_SEL_ALLOCATION        0x41
+#define IPMB_STORAGE_GET_SEL_ENTRY     0x43
 #define IPMB_STORAGE_GET_SEL_TIME      0x48
 
 #define IPMB_NETFN_CHASSIS             0x00
@@ -42,8 +46,6 @@ struct ipmb_resp {
        uint8_t rqSEQ;
        uint8_t rsLUN;
        uint8_t cmd;
-       unsigned char *data;
-       uint8_t datalen;
 };
 
 void decode_ipmb_pkt(unsigned char *buf, int len);
index f92edbdda41d7bae4210a62189a9a4c462dd6883..605c7944a268b834ef3b2c9cecbb103e56e427f9 100644 (file)
@@ -1,6 +1,7 @@
 #include <avr/io.h>
 #include <stdio.h>
 
+#include "config.h"
 #include "usart.h"
 
 #ifdef DEBUG
index d0ce4a58426d976b3808c4157aca83136fa16150..95ae6b7b3b17870831429f4e94282a3a748bede0 100644 (file)
@@ -1,3 +1 @@
-#define BAUD 9600UL
-
 void usart_init();
Impressum, Datenschutz