summaryrefslogtreecommitdiffstats
path: root/src/usr/util/runtime/rt_cmds.C
diff options
context:
space:
mode:
authorCorey Swenson <cswenson@us.ibm.com>2016-09-20 13:29:49 -0500
committerDaniel M. Crowell <dcrowell@us.ibm.com>2016-10-12 11:55:48 -0400
commitd32a09cc6edff8d296f64238fd5c0884472fcbc0 (patch)
tree6098d70e3013894002ec2a8df0dc34016c58883a /src/usr/util/runtime/rt_cmds.C
parent3ab150991f977e81505114f0a20a9d5e5e29f230 (diff)
downloadtalos-hostboot-d32a09cc6edff8d296f64238fd5c0884472fcbc0.tar.gz
talos-hostboot-d32a09cc6edff8d296f64238fd5c0884472fcbc0.zip
Enable Host interface run_command
Change-Id: I689d0f20d65f75299a341f23c2eb1b923dd2aa76 RTC:146148 Reviewed-on: http://ralgit01.raleigh.ibm.com/gerrit1/29980 Tested-by: Jenkins Server <pfd-jenkins+hostboot@us.ibm.com> Tested-by: FSP CI Jenkins <fsp-CI-jenkins+hostboot@us.ibm.com> Reviewed-by: Elizabeth K. Liner <eliner@us.ibm.com> Reviewed-by: Daniel M. Crowell <dcrowell@us.ibm.com>
Diffstat (limited to 'src/usr/util/runtime/rt_cmds.C')
-rw-r--r--src/usr/util/runtime/rt_cmds.C101
1 files changed, 101 insertions, 0 deletions
diff --git a/src/usr/util/runtime/rt_cmds.C b/src/usr/util/runtime/rt_cmds.C
new file mode 100644
index 000000000..b94fdd23e
--- /dev/null
+++ b/src/usr/util/runtime/rt_cmds.C
@@ -0,0 +1,101 @@
+/* IBM_PROLOG_BEGIN_TAG */
+/* This is an automatically generated prolog. */
+/* */
+/* $Source: src/usr/util/runtime/rt_cmds.C $ */
+/* */
+/* OpenPOWER HostBoot Project */
+/* */
+/* Contributors Listed Below - COPYRIGHT 2015,2016 */
+/* [+] International Business Machines Corp. */
+/* */
+/* */
+/* Licensed under the Apache License, Version 2.0 (the "License"); */
+/* you may not use this file except in compliance with the License. */
+/* You may obtain a copy of the License at */
+/* */
+/* http://www.apache.org/licenses/LICENSE-2.0 */
+/* */
+/* Unless required by applicable law or agreed to in writing, software */
+/* distributed under the License is distributed on an "AS IS" BASIS, */
+/* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or */
+/* implied. See the License for the specific language governing */
+/* permissions and limitations under the License. */
+/* */
+/* IBM_PROLOG_END_TAG */
+#include <runtime/interface.h>
+#include <stdio.h>
+#include <trace/interface.H>
+#include <string.h>
+#include "../utilbase.H"
+
+/**
+ * @brief Execute an arbitrary command inside Hostboot Runtime
+ * @param[in] Number of arguments (standard C args)
+ * @param[in] Array of argument values (standard C args)
+ * @param[out] Response message (NULL terminated), memory allocated
+ * by hbrt, if o_outString is NULL then no response will
+ * be sent
+ * @return 0 on success, else error code
+ */
+int hbrtCommand( int argc,
+ const char** argv,
+ char** o_outString )
+{
+ int rc = 0;
+ UTIL_FT("Executing run_command : argc=%d, o_outString=%p",
+ argc, o_outString);
+
+ if( !argc )
+ {
+ UTIL_FT("run_command : Number of arguments = 0");
+ return rc;
+ }
+
+ if( argv == NULL )
+ {
+ UTIL_FT("run_command : Argument array is empty");
+ return rc;
+ }
+
+ for( int aa=0; aa<argc; aa++ )
+ {
+ UTIL_FT("run_command : %d=%s",aa,argv[aa]);
+ }
+
+ // If no output is specified, trace it instead
+ bool l_traceOut = false;
+ char* l_outPtr = NULL; //local value to use if needed
+ char** l_output = o_outString;
+ if( o_outString == NULL )
+ {
+ l_output = &l_outPtr;
+ l_traceOut = true;
+ }
+
+ // Test path
+ if( (argc == 2) && !strcmp( argv[0], "testRunCommand" ) )
+ {
+ *l_output = new char[strlen(argv[1])+1+5];//arg0+arg1+\0
+ sprintf( *l_output, "TEST:%s", argv[1] );
+ }
+
+ if( l_traceOut && (*l_output != NULL) )
+ {
+ UTIL_FT("Output::%s",*l_output);
+ delete *l_output;
+ }
+
+ return rc;
+}
+
+
+struct registerCmds
+{
+ registerCmds()
+ {
+ getRuntimeInterfaces()->run_command = &hbrtCommand;
+ }
+};
+
+registerCmds g_registerCmds;
+
OpenPOWER on IntegriCloud