summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xArmPkg/Library/SemihostLib/Arm/GccSemihost.S35
-rw-r--r--ArmPkg/Library/SemihostLib/Arm/SemihostPrivate.h24
-rw-r--r--ArmPkg/Library/SemihostLib/SemihostLib.inf1
3 files changed, 59 insertions, 1 deletions
diff --git a/ArmPkg/Library/SemihostLib/Arm/GccSemihost.S b/ArmPkg/Library/SemihostLib/Arm/GccSemihost.S
new file mode 100755
index 0000000000..aa8b16ad51
--- /dev/null
+++ b/ArmPkg/Library/SemihostLib/Arm/GccSemihost.S
@@ -0,0 +1,35 @@
+#------------------------------------------------------------------------------
+#
+# Copyright (c) 2008 - 2010, Apple Inc. All rights reserved.<BR>
+#
+# This program and the accompanying materials
+# are licensed and made available under the terms and conditions of the BSD License
+# which accompanies this distribution. The full text of the license may be found at
+# http://opensource.org/licenses/bsd-license.php
+#
+# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+#
+#------------------------------------------------------------------------------
+
+.text
+.align 2
+
+.globl ASM_PFX(GccSemihostCall)
+INTERWORK_FUNC(GccSemihostCall)
+
+/*
+ Semihosting operation request mechanism
+
+ SVC 0x123456 in ARM state (for all architectures)
+ SVC 0xAB in Thumb state (excluding ARMv7-M)
+ BKPT 0xAB for ARMv7-M (Thumb-2 only)
+
+ R0 - operation type
+ R1 - block containing all other parametes
+ */
+ASM_PFX(GccSemihostCall):
+ svc #0x123456
+ bx lr
+
+
diff --git a/ArmPkg/Library/SemihostLib/Arm/SemihostPrivate.h b/ArmPkg/Library/SemihostLib/Arm/SemihostPrivate.h
index 7763d07abc..f8a76528f1 100644
--- a/ArmPkg/Library/SemihostLib/Arm/SemihostPrivate.h
+++ b/ArmPkg/Library/SemihostLib/Arm/SemihostPrivate.h
@@ -42,7 +42,7 @@ typedef struct {
UINT32 CommandLength;
} SEMIHOST_SYSTEM_BLOCK;
-#ifdef __CC_ARM
+#if defined(__CC_ARM)
#if defined(__thumb__)
#define SWI 0xAB
@@ -141,6 +141,28 @@ _Semihost_SYS_SYSTEM(
#define Semihost_SYS_REMOVE(RemoveBlock) _Semihost_SYS_REMOVE(0x0E, RemoveBlock)
#define Semihost_SYS_SYSTEM(SystemBlock) _Semihost_SYS_SYSTEM(0x12, SystemBlock)
+#elif defined(__GNUC__) // __CC_ARM
+
+#define SEMIHOST_SUPPORTED TRUE
+
+UINT32
+GccSemihostCall (
+ IN UINT32 Operation,
+ IN UINTN SystemBlockAddress
+ ); // __attribute__ ((interrupt ("SVC")));
+
+#define Semihost_SYS_OPEN(OpenBlock) GccSemihostCall(0x01, (UINTN)(OpenBlock))
+#define Semihost_SYS_CLOSE(Handle) GccSemihostCall(0x02, (UINTN)(Handle))
+#define Semihost_SYS_WRITE0(String) GccSemihostCall(0x04, (UINTN)(String))
+#define Semihost_SYS_WRITEC(Character) GccSemihostCall(0x03, (UINTN)(Character))
+#define Semihost_SYS_WRITE(WriteBlock) GccSemihostCall(0x05, (UINTN)(WriteBlock))
+#define Semihost_SYS_READ(ReadBlock) GccSemihostCall(0x06, (UINTN)(ReadBlock))
+#define Semihost_SYS_READC() GccSemihostCall(0x07, (UINTN)(0))
+#define Semihost_SYS_SEEK(SeekBlock) GccSemihostCall(0x0A, (UINTN)(SeekBlock))
+#define Semihost_SYS_FLEN(Handle) GccSemihostCall(0x0C, (UINTN)(Handle))
+#define Semihost_SYS_REMOVE(RemoveBlock) GccSemihostCall(0x0E, (UINTN)(RemoveBlock))
+#define Semihost_SYS_SYSTEM(SystemBlock) GccSemihostCall(0x12, (UINTN)(SystemBlock))
+
#else // __CC_ARM
#define SEMIHOST_SUPPORTED FALSE
diff --git a/ArmPkg/Library/SemihostLib/SemihostLib.inf b/ArmPkg/Library/SemihostLib/SemihostLib.inf
index 61a82b8ab1..f575a35f05 100644
--- a/ArmPkg/Library/SemihostLib/SemihostLib.inf
+++ b/ArmPkg/Library/SemihostLib/SemihostLib.inf
@@ -28,6 +28,7 @@
# VALID_ARCHITECTURES = ARM
#
[Sources.ARM]
+ Arm/GccSemihost.S | GCC
Arm/SemihostLib.c