]> git.proxmox.com Git - mirror_edk2.git/commitdiff
Add support for semihosting with GCC. Still needs more testing.
authorandrewfish <andrewfish@6f19259b-4bc3-4df7-8a09-765794883524>
Wed, 15 Dec 2010 01:00:54 +0000 (01:00 +0000)
committerandrewfish <andrewfish@6f19259b-4bc3-4df7-8a09-765794883524>
Wed, 15 Dec 2010 01:00:54 +0000 (01:00 +0000)
git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@11168 6f19259b-4bc3-4df7-8a09-765794883524

ArmPkg/Library/SemihostLib/Arm/GccSemihost.S [new file with mode: 0755]
ArmPkg/Library/SemihostLib/Arm/SemihostPrivate.h
ArmPkg/Library/SemihostLib/SemihostLib.inf

diff --git a/ArmPkg/Library/SemihostLib/Arm/GccSemihost.S b/ArmPkg/Library/SemihostLib/Arm/GccSemihost.S
new file mode 100755 (executable)
index 0000000..aa8b16a
--- /dev/null
@@ -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
+
+
index 7763d07abcf677e6eafeee0919c1acd10928dad5..f8a76528f152f11d8d148294e88ca42d2451e852 100644 (file)
@@ -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
index 61a82b8ab169c2debd59182c8f28f3244d84ddf0..f575a35f05426a6db10ad23bb6b050ce08bc4d60 100644 (file)
@@ -28,6 +28,7 @@
 #  VALID_ARCHITECTURES           = ARM\r
 #\r
 [Sources.ARM]\r
+  Arm/GccSemihost.S | GCC\r
   Arm/SemihostLib.c\r
 \r
 \r