This patch add`s support for Dell-OEM windbg command


Thanks,
Srinivas.G
Dell 
        
diff -Naurp 03-ipmitool_dell_vflash/lib/ipmi_delloem.c 
04-ipmitool_dell_windbg/lib/ipmi_delloem.c
--- 03-ipmitool_dell_vflash/lib/ipmi_delloem.c  2011-08-04 16:48:42.000000000 
+0530
+++ 04-ipmitool_dell_windbg/lib/ipmi_delloem.c  2011-08-04 16:48:42.000000000 
+0530
@@ -64,6 +64,8 @@ POSSIBILITY OF SUCH DAMAGE. 
 #include <ipmitool/ipmi_fru.h>
 #include <ipmitool/ipmi_sensor.h>
 /*------------ipmi headers------------------*/
+#include <ipmitool/ipmi_chassis.h>
+#include <ipmitool/ipmi_sol.h>
 
 
 
@@ -219,6 +221,15 @@ static int ipmi_delloem_vFlash_process(s
 static void ipmi_vFlash_usage(void);
 
 
+/* windbg Function prototypes */
+volatile uint8_t windbgsession = 0;
+static int ipmi_delloem_windbg_main (struct ipmi_intf * intf, int argc, char 
** argv);
+static int ipmi_windbg_start (struct ipmi_intf * intf);
+static int ipmi_windbg_end (struct ipmi_intf * intf);
+static void ipmi_windbg_usage (void);
+
+
+
 /* LED Function prototypes */
 
 static int ipmi_getsesmask(int, char **);
@@ -287,6 +298,10 @@ ipmi_delloem_main(struct ipmi_intf * int
        {
         ipmi_delloem_vFlash_main (intf,argc,argv);     
        }
+       else if (strncmp(argv[current_arg], "windbg\0", 7) == 0) 
+       {
+        ipmi_delloem_windbg_main (intf,argc,argv);             
+       }
     else
     {
         usage();
@@ -320,6 +335,7 @@ static void usage(void)
     if (IsSetLEDSupported())
        lprintf(LOG_NOTICE,    "    setled");         
     lprintf(LOG_NOTICE, "    powermonitor");        
+       lprintf(LOG_NOTICE, "    windbg");      
        lprintf(LOG_NOTICE, "    vFlash");
     lprintf(LOG_NOTICE, "");
     lprintf(LOG_NOTICE, "For help on individual commands type:");
@@ -4749,6 +4765,119 @@ ipmi_vFlash_usage(void)
        lprintf(LOG_NOTICE, "      Shows Extended SD Card information");
        lprintf(LOG_NOTICE, "");
 }
+/*****************************************************************
+* Function Name:       ipmi_delloem_windbg_main
+*
+* Description:         This function processes the delloem windbg command
+* Input:               intf    - ipmi interface
+                       argc    - no of arguments
+                       argv    - argument string array
+* Output:        
+*
+* Return:              return code     0 - success
+*                         -1 - failure
+*
+******************************************************************/
+
+static int ipmi_delloem_windbg_main (struct ipmi_intf * intf, int argc, char 
** argv)
+{
+    int rc = 0;
+
+       current_arg++;
+       if (argv[current_arg] == NULL)
+       {
+               ipmi_windbg_usage();
+               return -1;
+       }               
+       if (strncmp(argv[current_arg], "start\0", 6) == 0)
+       {
+               rc = ipmi_windbg_start(intf);
+       }
+       else if (strncmp(argv[current_arg], "end\0", 4) == 0)
+       {
+               rc = ipmi_windbg_end(intf);
+       }
+       else
+       {
+               ipmi_windbg_usage();
+       }
+}
+
+/*****************************************************************
+* Function Name:       ipmi_windbg_start 
+*
+* Description:         This function Starts the windbg
+* Input : void
+* Output: Start the debug              
+* Return: void 
+*
+******************************************************************/
+static int
+ipmi_windbg_start (struct ipmi_intf * intf)
+{
+       int rc;
+       windbgsession = 1;
+       lprintf(LOG_NOTICE, "Issuing sol activate");
+       lprintf(LOG_NOTICE, "");
+       
+       rc = ipmi_sol_activate(intf,0,0);
+       if (-1 == rc)
+       {
+               lprintf(LOG_NOTICE, "Can not issue sol activate");
+               return;
+       }       
+       
+}
+
+/*****************************************************************
+* Function Name:       ipmi_windbg_end
+*
+* Description:         This function ends the windbg
+* Input : void
+* Output: End the debug                
+* Return: void 
+*
+******************************************************************/
+
+static int
+ipmi_windbg_end(struct ipmi_intf * intf)
+{
+       int rc;
+       lprintf(LOG_NOTICE, "Issuing sol deactivate");
+       lprintf(LOG_NOTICE, "");
+       rc = ipmi_sol_deactivate(intf);
+       if (-1 == rc)
+       {
+               lprintf(LOG_NOTICE, "Can not issue sol deactivate");
+               return;
+       }
+       
+}
+
+
+/*****************************************************************
+* Function Name:       ipmi_windbg_usage
+*
+* Description:         This function displays the usage for using windbg
+* Input : void
+* Output: prints help          
+* Return: void 
+*
+******************************************************************/
+
+static void
+ipmi_windbg_usage(void)
+{
+       lprintf(LOG_NOTICE, "");
+       lprintf(LOG_NOTICE, "   windbg start");
+       lprintf(LOG_NOTICE, "      Starts the windbg session (Cold Reset & SOL 
Activation)");
+       lprintf(LOG_NOTICE, "");
+       lprintf(LOG_NOTICE, "   windbg end");
+       lprintf(LOG_NOTICE, "      Ends the windbg session (SOL Deactivation");
+       lprintf(LOG_NOTICE, "");
+}
+
+
 
 /**********************************************************************
 * Function Name: ipmi_setled_usage
diff -Naurp 03-ipmitool_dell_vflash/lib/ipmi_sol.c 
04-ipmitool_dell_windbg/lib/ipmi_sol.c
--- 03-ipmitool_dell_vflash/lib/ipmi_sol.c      2011-08-04 16:48:43.000000000 
+0530
+++ 04-ipmitool_dell_windbg/lib/ipmi_sol.c      2011-08-04 16:48:42.000000000 
+0530
@@ -41,7 +41,11 @@
 #include <time.h>
 #include <signal.h>
 #include <unistd.h>
-
+// Dwindbg - Start
+#include <fcntl.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+// Dwindbg - End 
 #if defined(HAVE_CONFIG_H)
 # include <config.h>
 #endif
@@ -92,8 +96,14 @@ static struct termios _saved_tio;
 static int            _in_raw_mode = 0;
 static int            _disable_keepalive = 0;
 static int            _use_sol_for_keepalive = 0;
+
+static int           fd = NULL;  // Dwindbg: File descriptor of NULL Modem 
Emulator   
 static int            _keepalive_retries = 0;
 
+static int           ncount = 0; // Dwindbg: Select count
+
+extern volatile uint8_t windbgsession;
+
 extern int verbose;
 
 /*
@@ -1269,11 +1279,18 @@ output(struct ipmi_rs * rsp)
            (rsp->session.payloadtype == IPMI_PAYLOAD_TYPE_SOL))
        {
                int i;
+               if (1 == windbgsession)
+               {
+                       // Dwindbg - Write the data to NULL modem Emulator
+                       write(fd, rsp->data, rsp->data_len);
+               }       
+               else
+               {
+                       for (i = 0; i < rsp->data_len; ++i)
+                               putc(rsp->data[i], stdout);
 
-               for (i = 0; i < rsp->data_len; ++i)
-                       putc(rsp->data[i], stdout);
-
-               fflush(stdout);
+                       fflush(stdout);
+               }                       
        }
 }
 
@@ -1282,7 +1299,7 @@ output(struct ipmi_rs * rsp)
 /*
  * ipmi_sol_deactivate
  */
-static int
+int
 ipmi_sol_deactivate(struct ipmi_intf * intf)
 {
        struct ipmi_rs * rsp;
@@ -1325,7 +1342,15 @@ ipmi_sol_deactivate(struct ipmi_intf * i
        } else {
                lprintf(LOG_ERR, "Error: No response de-activating SOL 
payload");
        }
-
+       if (1 == windbgsession)
+       {       
+               // Dwindbg  - Close the fd 
+               if(NULL!=fd)
+               {
+                       close(fd);
+                       fd = NULL;
+               }       
+       }               
        return -1;
 }
 
@@ -1467,7 +1492,70 @@ processSolUserInput(
 
        return retval;
 }
+/*
+ * Dwindbg - Func
+ * processSolComInput
+ *
+ * Act on Com input into the SOL session.  
+ *
+ * return   0 on success
+ *          1 if we should exit
+ *        
+ */
+static int
+processSolComInput(
+                                       struct ipmi_intf * intf,
+                                       uint8_t    * input,
+                                       uint16_t   buffer_length)
+{
+       struct ipmi_v2_payload v2_payload;
+       int  length               = 0;
+       int  retval               = 0;
+       int  i;
+
+       memset(&v2_payload, 0, sizeof(v2_payload));
+
+       /*
+        * If there is anything to process we dispatch it to the BMC,
+        * send intf->session->sol_data.max_outbound_payload_size bytes
+        * at a time.
+        */
+       if (buffer_length)
+       {
+               struct ipmi_rs * rsp = NULL;
+               int try = 0;
+
+               while (try < intf->session->retry) {
+
+                       v2_payload.payload.sol_packet.character_count = 
buffer_length;
+
+                       rsp = intf->send_sol(intf, &v2_payload);
+
+                       if (rsp)
+                       {
+                               break;
+                       }
+
+                       usleep(5000);
+                       try++;
+               }
+
+               if (! rsp)
+               {
+                       lprintf(LOG_ERR, "Error sending SOL data: FAIL");
+                       retval = -1;
+               }
 
+               /* If the sequence number is set we know we have new data */
+               if (retval == 0)
+                       if ((rsp->session.authtype == 
IPMI_SESSION_AUTHTYPE_RMCP_PLUS) &&
+                           (rsp->session.payloadtype == IPMI_PAYLOAD_TYPE_SOL) 
       &&
+                           (rsp->payload.sol_packet.packet_sequence_number))
+                               output(rsp);
+       }
+
+       return retval;
+}
 static int
 ipmi_sol_keepalive_using_sol(struct ipmi_intf * intf)
 {
@@ -1536,6 +1624,8 @@ ipmi_sol_red_pill(struct ipmi_intf * int
        int    buffer_size = intf->session->sol_data.max_inbound_payload_size;
        int    keepAliveRet = 0;
        int    retrySol = 0;
+       FILE *fd_char;
+       
 
        buffer = (char*)malloc(buffer_size);
        if (buffer == NULL) {
@@ -1553,6 +1643,10 @@ ipmi_sol_red_pill(struct ipmi_intf * int
                FD_ZERO(&read_fds);
                FD_SET(0, &read_fds);
                FD_SET(intf->fd, &read_fds);
+               if (1 == windbgsession)
+               {
+                       FD_SET(fd, &read_fds); // Dwindbg - Set NME fd 
+               }       
 
                /* Send periodic keepalive packet */
                if(_use_sol_for_keepalive == 0)
@@ -1594,8 +1688,23 @@ ipmi_sol_red_pill(struct ipmi_intf * int
                /* Wait up to half a second */
                tv.tv_sec =  0;
                tv.tv_usec = 500000;
+               if (1 == windbgsession)
+               {
+                       if ( fd > intf->fd)
+                       {
+                               
+                               retval = select(fd + 1, &read_fds, NULL, NULL, 
&tv);
+
 
-               retval = select(intf->fd + 1, &read_fds, NULL, NULL, &tv);
+                       }
+                       else
+                       {
+                               retval = select(intf->fd + 1, &read_fds, NULL, 
NULL, &tv);
+                       }
+
+               }
+               else    
+                       retval = select(intf->fd + 1, &read_fds, NULL, NULL, 
&tv);
 
                if (retval)
                {
@@ -1652,7 +1761,39 @@ ipmi_sol_red_pill(struct ipmi_intf * int
                                }
                        }
 
+                       // Dwindbg - Start
+                       /*
+                        * Process input from the windows debugger
+                        */                     
+                       else if (1==windbgsession && FD_ISSET(fd, &read_fds) )
+                       {       
+                               if ( ncount > 0 )
+                               {
+                                       ncount = 0;
+                               bzero(buffer, sizeof(buffer));
+                               
+                               numRead = read(fd,
+                                                                  buffer,
+                                                                       
buffer_size);
+
+                               if (numRead > 0)
+                               {
 
+                                       int rc = processSolUserInput(intf, 
(uint8_t *)buffer, numRead);
+                                       if (rc)
+                                       {
+                                               bShouldExit = 1;
+                                       }
+                               }
+                               else
+                               {
+                                       bShouldExit = 1;
+                               }
+                               }
+                               else
+                                       ncount++;
+                       } 
+                       // Dwindbg - End
                        /*
                         * ERROR in select
                         */
@@ -1691,7 +1832,7 @@ ipmi_sol_red_pill(struct ipmi_intf * int
 /*
  * ipmi_sol_activate
  */
-static int
+int
 ipmi_sol_activate(struct ipmi_intf * intf, int looptest, int interval)
 {
        struct ipmi_rs * rsp;
@@ -1711,7 +1852,15 @@ ipmi_sol_activate(struct ipmi_intf * int
                           "lanplus interface");
                return -1;
        }
-
+       if (1 == windbgsession)
+       {
+               // Dwindbg: Open NULL Modem emulator which is mapped to 
/dev/com8
+               if((fd = open("/dev/com8", O_RDWR|O_NONBLOCK)) < 0)
+               {
+                       perror("failed to open ");
+                       return -1;
+               }
+       }       
 
        /*
         * Setup a callback so that the lanplus processing knows what
@@ -1848,6 +1997,11 @@ ipmi_sol_activate(struct ipmi_intf * int
        if (ipmi_sol_red_pill(intf))
        {
                lprintf(LOG_ERR, "Error in SOL session");
+               if (1 == windbgsession)
+               {
+                       if (NULL !=fd)
+                               close(fd); // Dwindbg: Close NME fd
+               }               
                return -1;
        }
 
------------------------------------------------------------------------------
Get a FREE DOWNLOAD! and learn more about uberSVN rich system, 
user administration capabilities and model configuration. Take 
the hassle out of deploying and managing Subversion and the 
tools developers use with it. 
http://p.sf.net/sfu/wandisco-dev2dev
_______________________________________________
Ipmitool-devel mailing list
Ipmitool-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ipmitool-devel

Reply via email to