[PATCH] rtems: Add rtems_status_code_description()

Sebastian Huber sebastian.huber at embedded-brains.de
Wed Feb 5 16:25:46 UTC 2014


---
 cpukit/rtems/Makefile.am                           |    1 +
 cpukit/rtems/include/rtems/rtems/status.h          |   10 +++
 cpukit/rtems/src/statusdesc.c                      |   69 ++++++++++++++++++++
 doc/user/Makefile.am                               |   11 ++-
 doc/user/dirstat.t                                 |   64 ++++++++++++++++++
 doc/user/dirstat.texi                              |   37 -----------
 doc/user/example.texi                              |    2 +-
 testsuites/sptests/spinternalerror02/init.c        |   21 ++++++-
 .../spinternalerror02/spinternalerror02.scn        |   31 +++++++++
 9 files changed, 203 insertions(+), 43 deletions(-)
 create mode 100644 cpukit/rtems/src/statusdesc.c
 create mode 100644 doc/user/dirstat.t
 delete mode 100644 doc/user/dirstat.texi

diff --git a/cpukit/rtems/Makefile.am b/cpukit/rtems/Makefile.am
index fd5af5a..f219db8 100644
--- a/cpukit/rtems/Makefile.am
+++ b/cpukit/rtems/Makefile.am
@@ -255,6 +255,7 @@ librtems_a_SOURCES += src/workspacegreedy.c
 librtems_a_SOURCES += src/modes.c
 
 librtems_a_SOURCES += src/status.c
+librtems_a_SOURCES += src/statusdesc.c
 
 if HAS_MP
 # We only build multiprocessing related files if HAS_MP was defined
diff --git a/cpukit/rtems/include/rtems/rtems/status.h b/cpukit/rtems/include/rtems/rtems/status.h
index 8904288..19df500 100644
--- a/cpukit/rtems/include/rtems/rtems/status.h
+++ b/cpukit/rtems/include/rtems/rtems/status.h
@@ -241,6 +241,16 @@ RTEMS_INLINE_ROUTINE bool rtems_are_statuses_equal(
  */
 int rtems_status_code_to_errno(rtems_status_code sc);
 
+/**
+ * @brief Returns a description for a status code.
+ *
+ * @param[in] code The status code.
+ *
+ * @retval description The status code description.
+ * @retval ? The passed status code is invalid.
+ */
+const char *rtems_status_code_description( rtems_status_code code );
+
 /**@}*/
 
 #ifdef __cplusplus
diff --git a/cpukit/rtems/src/statusdesc.c b/cpukit/rtems/src/statusdesc.c
new file mode 100644
index 0000000..4cc426d
--- /dev/null
+++ b/cpukit/rtems/src/statusdesc.c
@@ -0,0 +1,69 @@
+/**
+ * @file
+ *
+ * @ingroup ClassicStatus
+ */
+
+/*
+ * Copyright (c) 2014 embedded brains GmbH.  All rights reserved.
+ *
+ *  embedded brains GmbH
+ *  Dornierstr. 4
+ *  82178 Puchheim
+ *  Germany
+ *  <rtems at embedded-brains.de>
+ *
+ * The license and distribution terms for this file may be
+ * found in the file LICENSE in this distribution or at
+ * http://www.rtems.com/license/LICENSE.
+ */
+
+#if HAVE_CONFIG_H
+  #include "config.h"
+#endif
+
+#include <rtems.h>
+
+static const char *const status_code_desc[] = {
+  "RTEMS_SUCCESSFUL",
+  "RTEMS_TASK_EXITTED",
+  "RTEMS_MP_NOT_CONFIGURED",
+  "RTEMS_INVALID_NAME",
+  "RTEMS_INVALID_ID",
+  "RTEMS_TOO_MANY",
+  "RTEMS_TIMEOUT",
+  "RTEMS_OBJECT_WAS_DELETED",
+  "RTEMS_INVALID_SIZE",
+  "RTEMS_INVALID_ADDRESS",
+  "RTEMS_INVALID_NUMBER",
+  "RTEMS_NOT_DEFINED",
+  "RTEMS_RESOURCE_IN_USE",
+  "RTEMS_UNSATISFIED",
+  "RTEMS_INCORRECT_STATE",
+  "RTEMS_ALREADY_SUSPENDED",
+  "RTEMS_ILLEGAL_ON_SELF",
+  "RTEMS_ILLEGAL_ON_REMOTE_OBJECT",
+  "RTEMS_CALLED_FROM_ISR",
+  "RTEMS_INVALID_PRIORITY",
+  "RTEMS_INVALID_CLOCK",
+  "RTEMS_INVALID_NODE",
+  "RTEMS_NOT_CONFIGURED",
+  "RTEMS_NOT_OWNER_OF_RESOURCE",
+  "RTEMS_NOT_IMPLEMENTED",
+  "RTEMS_INTERNAL_ERROR",
+  "RTEMS_NO_MEMORY",
+  "RTEMS_IO_ERROR",
+  "RTEMS_PROXY_BLOCKING"
+};
+
+const char *rtems_status_code_description( rtems_status_code code )
+{
+  size_t i = code;
+  const char *desc = "?";
+
+  if ( i < RTEMS_ARRAY_SIZE( status_code_desc ) ) {
+    desc = status_code_desc [i];
+  }
+
+  return desc;
+}
diff --git a/doc/user/Makefile.am b/doc/user/Makefile.am
index 7992b29..1b6ddcb 100644
--- a/doc/user/Makefile.am
+++ b/doc/user/Makefile.am
@@ -8,14 +8,14 @@ PROJECT = c_user
 include $(top_srcdir)/project.am
 include $(top_srcdir)/main.am
 
-FILES = bsp.texi dirstat.texi example.texi glossary.texi preface.texi
+FILES = bsp.texi example.texi glossary.texi preface.texi
 
 GENERATED_FILES = overview.texi concepts.texi datatypes.texi init.texi \
     task.texi intr.texi clock.texi timer.texi sem.texi msg.texi event.texi \
     signal.texi part.texi region.texi dpmem.texi io.texi fatal.texi \
     schedule.texi rtmon.texi barrier.texi bsp.texi userext.texi conf.texi \
     mp.texi stackchk.texi cpuuse.texi object.texi chains.texi timespec.texi \
-    cbs.texi
+    cbs.texi dirstat.texi
 
 COMMON_FILES += $(top_srcdir)/common/cpright.texi
 
@@ -193,10 +193,15 @@ cbs.texi: cbs.t
 	    -u "Top" \
 	    -n "Directive Status Codes" < $< > $@
 
+dirstat.texi: dirstat.t
+	$(BMENU2) -p "Constant Bandwidth Server Scheduler API CBS_GET_APPROVED_BUDGET - Get scheduler approved execution time" \
+	    -u "Top" \
+	    -n "Example Application" < $< > $@
+
 EXTRA_DIST = bsp.t cbs.t clock.t chains.t concepts.t cpuuse.t datatypes.t conf.t \
     dpmem.t event.t fatal.t init.t intr.t io.t mp.t msg.t overview.t \
     part.t region.t rtmon.t sem.t schedule.t signal.t stackchk.t \
-    task.t timer.t userext.t $(TXT_FILES) $(PNG_FILES) $(EPS_IMAGES) \
+    task.t timer.t userext.t dirstat.t $(TXT_FILES) $(PNG_FILES) $(EPS_IMAGES) \
     $(noinst_DATA)
 
 CLEANFILES += c_user.info c_user.info-? c_user.info-??
diff --git a/doc/user/dirstat.t b/doc/user/dirstat.t
new file mode 100644
index 0000000..adb675d
--- /dev/null
+++ b/doc/user/dirstat.t
@@ -0,0 +1,64 @@
+ at c
+ at c  COPYRIGHT (c) 1989-2011.
+ at c  On-Line Applications Research Corporation (OAR).
+ at c  All rights reserved.
+
+ at chapter Directive Status Codes
+
+ at section Introduction
+
+ at table @b
+ at item @code{@value{RPREFIX}SUCCESSFUL} - successful completion
+ at item @code{@value{RPREFIX}TASK_EXITTED} - returned from a task
+ at item @code{@value{RPREFIX}MP_NOT_CONFIGURED} - multiprocessing not configured
+ at item @code{@value{RPREFIX}INVALID_NAME} - invalid object name
+ at item @code{@value{RPREFIX}INVALID_ID} - invalid object id
+ at item @code{@value{RPREFIX}TOO_MANY} - too many
+ at item @code{@value{RPREFIX}TIMEOUT} - timed out waiting
+ at item @code{@value{RPREFIX}OBJECT_WAS_DELETED} - object was deleted while waiting
+ at item @code{@value{RPREFIX}INVALID_SIZE} - invalid specified size
+ at item @code{@value{RPREFIX}INVALID_ADDRESS} - invalid address specified
+ at item @code{@value{RPREFIX}INVALID_NUMBER} - number was invalid
+ at item @code{@value{RPREFIX}NOT_DEFINED} - item not initialized
+ at item @code{@value{RPREFIX}RESOURCE_IN_USE} - resources outstanding
+ at item @code{@value{RPREFIX}UNSATISFIED} - request not satisfied
+ at item @code{@value{RPREFIX}INCORRECT_STATE} - task is in wrong state
+ at item @code{@value{RPREFIX}ALREADY_SUSPENDED} - task already in state
+ at item @code{@value{RPREFIX}ILLEGAL_ON_SELF} - illegal for calling task
+ at item @code{@value{RPREFIX}ILLEGAL_ON_REMOTE_OBJECT} - illegal for remote object
+ at item @code{@value{RPREFIX}CALLED_FROM_ISR} - invalid environment
+ at item @code{@value{RPREFIX}INVALID_PRIORITY} - invalid task priority
+ at item @code{@value{RPREFIX}INVALID_CLOCK} - invalid time buffer
+ at item @code{@value{RPREFIX}INVALID_NODE} - invalid node id
+ at item @code{@value{RPREFIX}NOT_CONFIGURED} - directive not configured
+ at item @code{@value{RPREFIX}NOT_OWNER_OF_RESOURCE} - not owner of resource
+ at item @code{@value{RPREFIX}NOT_IMPLEMENTED} - directive not implemented
+ at item @code{@value{RPREFIX}INTERNAL_ERROR} - RTEMS inconsistency detected
+ at item @code{@value{RPREFIX}NO_MEMORY} - could not get enough memory
+ at end table
+
+ at section Directives
+
+ at page
+ at subsection STATUS_CODE_DESCRIPTION - Returns a description for a status code
+
+ at cindex fatal error
+
+ at subheading CALLING SEQUENCE:
+
+ at ifset is-C
+ at findex rtems_status_code_description
+ at example
+const char *rtems_status_code_description(
+  rtems_status_code code
+);
+ at end example
+ at end ifset
+
+ at subheading DIRECTIVE STATUS CODES
+
+The status code description or "?" in case the passed status code is invalid.
+
+ at subheading DESCRIPTION:
+
+Returns a description for a status code.
diff --git a/doc/user/dirstat.texi b/doc/user/dirstat.texi
deleted file mode 100644
index 17a7edd..0000000
--- a/doc/user/dirstat.texi
+++ /dev/null
@@ -1,37 +0,0 @@
- at c
- at c  COPYRIGHT (c) 1989-2011.
- at c  On-Line Applications Research Corporation (OAR).
- at c  All rights reserved.
-
- at node Directive Status Codes, Example Application, Constant Bandwidth Server Scheduler API CBS_GET_APPROVED_BUDGET - Get scheduler approved execution time, Top
- at chapter Directive Status Codes
- at table @b
- at item @code{@value{RPREFIX}SUCCESSFUL} - successful completion
- at item @code{@value{RPREFIX}TASK_EXITTED} - returned from a task
- at item @code{@value{RPREFIX}MP_NOT_CONFIGURED} - multiprocessing not configured
- at item @code{@value{RPREFIX}INVALID_NAME} - invalid object name
- at item @code{@value{RPREFIX}INVALID_ID} - invalid object id
- at item @code{@value{RPREFIX}TOO_MANY} - too many
- at item @code{@value{RPREFIX}TIMEOUT} - timed out waiting
- at item @code{@value{RPREFIX}OBJECT_WAS_DELETED} - object was deleted while waiting
- at item @code{@value{RPREFIX}INVALID_SIZE} - invalid specified size
- at item @code{@value{RPREFIX}INVALID_ADDRESS} - invalid address specified
- at item @code{@value{RPREFIX}INVALID_NUMBER} - number was invalid
- at item @code{@value{RPREFIX}NOT_DEFINED} - item not initialized
- at item @code{@value{RPREFIX}RESOURCE_IN_USE} - resources outstanding
- at item @code{@value{RPREFIX}UNSATISFIED} - request not satisfied
- at item @code{@value{RPREFIX}INCORRECT_STATE} - task is in wrong state
- at item @code{@value{RPREFIX}ALREADY_SUSPENDED} - task already in state
- at item @code{@value{RPREFIX}ILLEGAL_ON_SELF} - illegal for calling task
- at item @code{@value{RPREFIX}ILLEGAL_ON_REMOTE_OBJECT} - illegal for remote object
- at item @code{@value{RPREFIX}CALLED_FROM_ISR} - invalid environment
- at item @code{@value{RPREFIX}INVALID_PRIORITY} - invalid task priority
- at item @code{@value{RPREFIX}INVALID_CLOCK} - invalid time buffer
- at item @code{@value{RPREFIX}INVALID_NODE} - invalid node id
- at item @code{@value{RPREFIX}NOT_CONFIGURED} - directive not configured
- at item @code{@value{RPREFIX}NOT_OWNER_OF_RESOURCE} - not owner of resource
- at item @code{@value{RPREFIX}NOT_IMPLEMENTED} - directive not implemented
- at item @code{@value{RPREFIX}INTERNAL_ERROR} - RTEMS inconsistency detected
- at item @code{@value{RPREFIX}NO_MEMORY} - could not get enough memory
- at end table
-
diff --git a/doc/user/example.texi b/doc/user/example.texi
index f95868e..71a71ab 100644
--- a/doc/user/example.texi
+++ b/doc/user/example.texi
@@ -3,7 +3,7 @@
 @c  On-Line Applications Research Corporation (OAR).
 @c  All rights reserved.
 
- at node Example Application, Glossary, Directive Status Codes, Top
+ at node Example Application, Glossary, Directive Status Codes STATUS_CODE_DESCRIPTION - Returns a description for a status code, Top
 @chapter Example Application
 
 @example
diff --git a/testsuites/sptests/spinternalerror02/init.c b/testsuites/sptests/spinternalerror02/init.c
index 4b89e6c..b08a7d4 100644
--- a/testsuites/sptests/spinternalerror02/init.c
+++ b/testsuites/sptests/spinternalerror02/init.c
@@ -1,8 +1,8 @@
 /*
- * Copyright (c) 2012 embedded brains GmbH.  All rights reserved.
+ * Copyright (c) 2012-2014 embedded brains GmbH.  All rights reserved.
  *
  *  embedded brains GmbH
- *  Obere Lagerstr. 30
+ *  Donierstr. 4
  *  82178 Puchheim
  *  Germany
  *  <rtems at embedded-brains.de>
@@ -52,12 +52,29 @@ static void test_fatal_source_description(void)
   rtems_test_assert( source - 3 == RTEMS_FATAL_SOURCE_EXCEPTION );
 }
 
+static void test_status_code_description(void)
+{
+  rtems_status_code code = 0;
+  const char *desc = NULL;
+  const char *desc_last;
+
+  do {
+    desc_last = desc;
+    desc = rtems_status_code_description( code );
+    ++code;
+    puts( desc );
+  } while ( desc != desc_last );
+
+  rtems_test_assert( code - 3 == RTEMS_PROXY_BLOCKING );
+}
+
 static void Init(rtems_task_argument arg)
 {
   puts("\n\n*** TEST SPINTERNALERROR 2 ***");
 
   test_internal_error_description();
   test_fatal_source_description();
+  test_status_code_description();
 
   puts("*** END OF TEST SPINTERNALERROR 2 ***");
 
diff --git a/testsuites/sptests/spinternalerror02/spinternalerror02.scn b/testsuites/sptests/spinternalerror02/spinternalerror02.scn
index 9d7a722..65fd425 100644
--- a/testsuites/sptests/spinternalerror02/spinternalerror02.scn
+++ b/testsuites/sptests/spinternalerror02/spinternalerror02.scn
@@ -39,4 +39,35 @@ RTEMS_FATAL_SOURCE_STACK_CHECKER
 RTEMS_FATAL_SOURCE_EXCEPTION
 ?
 ?
+RTEMS_SUCCESSFUL
+RTEMS_TASK_EXITTED
+RTEMS_MP_NOT_CONFIGURED
+RTEMS_INVALID_NAME
+RTEMS_INVALID_ID
+RTEMS_TOO_MANY
+RTEMS_TIMEOUT
+RTEMS_OBJECT_WAS_DELETED
+RTEMS_INVALID_SIZE
+RTEMS_INVALID_ADDRESS
+RTEMS_INVALID_NUMBER
+RTEMS_NOT_DEFINED
+RTEMS_RESOURCE_IN_USE
+RTEMS_UNSATISFIED
+RTEMS_INCORRECT_STATE
+RTEMS_ALREADY_SUSPENDED
+RTEMS_ILLEGAL_ON_SELF
+RTEMS_ILLEGAL_ON_REMOTE_OBJECT
+RTEMS_CALLED_FROM_ISR
+RTEMS_INVALID_PRIORITY
+RTEMS_INVALID_CLOCK
+RTEMS_INVALID_NODE
+RTEMS_NOT_CONFIGURED
+RTEMS_NOT_OWNER_OF_RESOURCE
+RTEMS_NOT_IMPLEMENTED
+RTEMS_INTERNAL_ERROR
+RTEMS_NO_MEMORY
+RTEMS_IO_ERROR
+RTEMS_PROXY_BLOCKING
+?
+?
 *** END OF TEST SPINTERNALERROR 2 ***
-- 
1.7.7




More information about the devel mailing list