arm: Expose the constants which select a semihosting operation.
authorGabe Black <gabeblack@google.com>
Wed, 26 Feb 2020 03:16:06 +0000 (19:16 -0800)
committerGabe Black <gabeblack@google.com>
Thu, 27 Feb 2020 13:03:13 +0000 (13:03 +0000)
Give these constants meaningful names instead of opaque constants only
visible in the .cc file.

Change-Id: Ib88912dae79960f785099c236c337db52a69d563
Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/25945
Reviewed-by: Chun-Chen TK Hsu <chunchenhsu@google.com>
Reviewed-by: Giacomo Travaglini <giacomo.travaglini@arm.com>
Maintainer: Giacomo Travaglini <giacomo.travaglini@arm.com>
Tested-by: kokoro <noreply+kokoro@google.com>
src/arch/arm/semihosting.cc
src/arch/arm/semihosting.hh

index e85fe7ead943139396aa01a787e30216d8a2f606..4f897e208fe644317e76fdf437c625bf653a5170 100644 (file)
 #include "sim/system.hh"
 
 const std::map<uint32_t, ArmSemihosting::SemiCall> ArmSemihosting::calls{
-    { 0x01, { "SYS_OPEN", &ArmSemihosting::callOpen, 3, 3 } },
-    { 0x02, { "SYS_CLOSE", &ArmSemihosting::callClose, 1, 1 } },
+    { SYS_OPEN,     { "SYS_OPEN", &ArmSemihosting::callOpen, 3, 3 } },
+    { SYS_CLOSE,    { "SYS_CLOSE", &ArmSemihosting::callClose, 1, 1 } },
 
     // Write(C|0) are special since we want to read the character
     // manually. We therefore declare them as having 0 params.
-    { 0x03, { "SYS_WRITEC", &ArmSemihosting::callWriteC, 0, 0 } },
-    { 0x04, { "SYS_WRITE0", &ArmSemihosting::callWrite0, 1, 1 } },
-
-    { 0x05, { "SYS_WRITE", &ArmSemihosting::callWrite, 3, 3 } },
-    { 0x06, { "SYS_READ", &ArmSemihosting::callRead, 3, 3 } },
-    { 0x07, { "SYS_READC", &ArmSemihosting::callReadC, 0, 0 } },
-    { 0x08, { "SYS_ISERROR", &ArmSemihosting::callIsError, 1, 1 } },
-    { 0x09, { "SYS_ISTTY", &ArmSemihosting::callIsTTY, 1, 1 } },
-    { 0x0A, { "SYS_SEEK", &ArmSemihosting::callSeek, 2, 2 } },
-    { 0x0C, { "SYS_FLEN", &ArmSemihosting::callFLen, 1, 1 } },
-    { 0x0D, { "SYS_TMPNAM", &ArmSemihosting::callTmpNam, 3, 3 } },
-    { 0x0E, { "SYS_REMOVE", &ArmSemihosting::callRemove, 2, 2} },
-    { 0x0F, { "SYS_RENAME", &ArmSemihosting::callRename, 4, 4} },
-    { 0x10, { "SYS_CLOCK", &ArmSemihosting::callClock, 0, 0} },
-    { 0x11, { "SYS_TIME", &ArmSemihosting::callTime, 0, 0} },
-    { 0x12, { "SYS_SYSTEM", &ArmSemihosting::callSystem, 2, 2} },
-    { 0x13, { "SYS_ERRNO", &ArmSemihosting::callErrno, 0, 0 } },
-    { 0x15, { "SYS_GET_CMDLINE", &ArmSemihosting::callGetCmdLine, 2, 2} },
-    { 0x16, { "SYS_HEAPINFO", &ArmSemihosting::callHeapInfo, 1, 1} },
+    { SYS_WRITEC,   { "SYS_WRITEC", &ArmSemihosting::callWriteC, 0, 0 } },
+    { SYS_WRITE0,   { "SYS_WRITE0", &ArmSemihosting::callWrite0, 1, 1 } },
+
+    { SYS_WRITE,    { "SYS_WRITE", &ArmSemihosting::callWrite, 3, 3 } },
+    { SYS_READ,     { "SYS_READ", &ArmSemihosting::callRead, 3, 3 } },
+    { SYS_READC,    { "SYS_READC", &ArmSemihosting::callReadC, 0, 0 } },
+    { SYS_ISERROR,  { "SYS_ISERROR", &ArmSemihosting::callIsError, 1, 1 } },
+    { SYS_ISTTY,    { "SYS_ISTTY", &ArmSemihosting::callIsTTY, 1, 1 } },
+    { SYS_SEEK,     { "SYS_SEEK", &ArmSemihosting::callSeek, 2, 2 } },
+    { SYS_FLEN,     { "SYS_FLEN", &ArmSemihosting::callFLen, 1, 1 } },
+    { SYS_TMPNAM,   { "SYS_TMPNAM", &ArmSemihosting::callTmpNam, 3, 3 } },
+    { SYS_REMOVE,   { "SYS_REMOVE", &ArmSemihosting::callRemove, 2, 2} },
+    { SYS_RENAME,   { "SYS_RENAME", &ArmSemihosting::callRename, 4, 4} },
+    { SYS_CLOCK,    { "SYS_CLOCK", &ArmSemihosting::callClock, 0, 0} },
+    { SYS_TIME,     { "SYS_TIME", &ArmSemihosting::callTime, 0, 0} },
+    { SYS_SYSTEM,   { "SYS_SYSTEM", &ArmSemihosting::callSystem, 2, 2} },
+    { SYS_ERRNO,    { "SYS_ERRNO", &ArmSemihosting::callErrno, 0, 0 } },
+    { SYS_GET_CMDLINE,
+        { "SYS_GET_CMDLINE", &ArmSemihosting::callGetCmdLine, 2, 2} },
+    { SYS_HEAPINFO, { "SYS_HEAPINFO", &ArmSemihosting::callHeapInfo, 1, 1} },
 
     // Exit is special and requires custom handling in aarch32.
-    { 0x18, { "SYS_EXIT", &ArmSemihosting::callExit, 0, 2 } },
-    { 0x20, { "SYS_EXIT_EXTENDED", &ArmSemihosting::callExitExtended, 2, 2 } },
+    { SYS_EXIT,     { "SYS_EXIT", &ArmSemihosting::callExit, 0, 2 } },
+    { SYS_EXIT_EXTENDED,
+        { "SYS_EXIT_EXTENDED", &ArmSemihosting::callExitExtended, 2, 2 } },
 
-    { 0x30, { "SYS_ELAPSED", &ArmSemihosting::callElapsed, 0, 0 } },
-    { 0x31, { "SYS_TICKFREQ", &ArmSemihosting::callTickFreq, 0, 0 } },
+    { SYS_ELAPSED,  { "SYS_ELAPSED", &ArmSemihosting::callElapsed, 0, 0 } },
+    { SYS_TICKFREQ, { "SYS_TICKFREQ", &ArmSemihosting::callTickFreq, 0, 0 } },
 };
 
 const std::vector<const char *> ArmSemihosting::fmodes{
index 3b5b46ea68e62a0c73b0699a0746b873a0d02ced..104b479c5e8a672b5010df04bdd1633fe2ac8aa4 100644 (file)
@@ -68,6 +68,36 @@ class ThreadContext;
 class ArmSemihosting : public SimObject
 {
   public:
+
+    enum Operation {
+        SYS_OPEN = 0x01,
+        SYS_CLOSE = 0x02,
+        SYS_WRITEC = 0x03,
+        SYS_WRITE0 = 0x04,
+        SYS_WRITE = 0x05,
+        SYS_READ = 0x06,
+        SYS_READC = 0x07,
+        SYS_ISERROR = 0x08,
+        SYS_ISTTY = 0x09,
+        SYS_SEEK = 0x0A,
+        SYS_FLEN = 0x0C,
+        SYS_TMPNAM = 0x0D,
+        SYS_REMOVE = 0x0E,
+        SYS_RENAME = 0x0F,
+        SYS_CLOCK = 0x10,
+        SYS_TIME = 0x11,
+        SYS_SYSTEM = 0x12,
+        SYS_ERRNO = 0x13,
+        SYS_GET_CMDLINE = 0x15,
+        SYS_HEAPINFO = 0x16,
+        SYS_EXIT = 0x18,
+        SYS_EXIT_EXTENDED = 0x20,
+        SYS_ELAPSED = 0x30,
+        SYS_TICKFREQ = 0x31,
+
+        MaxStandardOp = 0xFF
+    };
+
     ArmSemihosting(const ArmSemihostingParams *p);
 
     /** Perform an Arm Semihosting call from aarch64 code. */