Back to home page

LXR

 
 

    


File indexing completed on 2025-05-11 08:22:49

0001 /* SPDX-License-Identifier: BSD-2-Clause */
0002 
0003 /**
0004  * @file
0005  *
0006  * @ingroup RTEMSBSPsARMFVP
0007  *
0008  * @brief This header file provides the semihosting API.
0009  */
0010 
0011 /*
0012  * Copyright (C) 2020 embedded brains GmbH & Co. KG
0013  *
0014  * Redistribution and use in source and binary forms, with or without
0015  * modification, are permitted provided that the following conditions
0016  * are met:
0017  * 1. Redistributions of source code must retain the above copyright
0018  *    notice, this list of conditions and the following disclaimer.
0019  * 2. Redistributions in binary form must reproduce the above copyright
0020  *    notice, this list of conditions and the following disclaimer in the
0021  *    documentation and/or other materials provided with the distribution.
0022  *
0023  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
0024  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
0025  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
0026  * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
0027  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
0028  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
0029  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
0030  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
0031  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
0032  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
0033  * POSSIBILITY OF SUCH DAMAGE.
0034  */
0035 
0036 #ifndef _BSPS_ARM_FVP_SEMIHOSTING_H
0037 #define _BSPS_ARM_FVP_SEMIHOSTING_H
0038 
0039 #include <stdint.h>
0040 
0041 #ifdef __cplusplus
0042 extern "C" {
0043 #endif
0044 
0045 /**
0046  * @addtogroup RTEMSBSPsARMFVP
0047  *
0048  * @{
0049  */
0050 
0051 #define SYS_CLOCK 0x10
0052 #define SYS_CLOSE 0x02
0053 #define SYS_ELAPSED 0x30
0054 #define SYS_ERRNO 0x13
0055 #define SYS_EXIT 0x18
0056 #define SYS_EXIT_EXTENDED 0x20
0057 #define SYS_FLEN 0x0c
0058 #define SYS_GET_CMDLINE 0x15
0059 #define SYS_HEAPINFO 0x16
0060 #define SYS_ISERROR 0x08
0061 #define SYS_ISTTY 0x09
0062 #define SYS_OPEN 0x01
0063 #define SYS_READ 0x06
0064 #define SYS_READC 0x07
0065 #define SYS_REMOVE 0x0e
0066 #define SYS_RENAME 0x0f
0067 #define SYS_SEEK 0x0a
0068 #define SYS_SYSTEM 0x12
0069 #define SYS_TICKFREQ 0x31
0070 #define SYS_TIME 0x11
0071 #define SYS_TMPNAM 0x0d
0072 #define SYS_WRITE 0x05
0073 #define SYS_WRITEC 0x03
0074 #define SYS_WRITE0 0x04
0075 
0076 #define ADP_Stopped_BranchThroughZero 0x20000
0077 #define ADP_Stopped_UndefinedInstr 0x20001
0078 #define ADP_Stopped_SoftwareInterrupt 0x20002
0079 #define ADP_Stopped_PrefetchAbort 0x20003
0080 #define ADP_Stopped_DataAbort 0x20004
0081 #define ADP_Stopped_AddressException 0x20005
0082 #define ADP_Stopped_IRQ 0x20006
0083 #define ADP_Stopped_FIQ 0x20007
0084 #define ADP_Stopped_BreakPoint 0x20020
0085 #define ADP_Stopped_WatchPoint 0x20021
0086 #define ADP_Stopped_StepComplete 0x20022
0087 #define ADP_Stopped_RunTimeErrorUnknown 0x20023
0088 #define ADP_Stopped_InternalError 0x20024
0089 #define ADP_Stopped_UserInterruption 0x20025
0090 #define ADP_Stopped_ApplicationExit 0x20026
0091 #define ADP_Stopped_StackOverflow 0x20027
0092 #define ADP_Stopped_DivisionByZero 0x20028
0093 #define ADP_Stopped_OSSpecific 0x20029
0094 
0095 static inline uintptr_t arm_fvp_semihosting_call(
0096   uintptr_t op,
0097   uintptr_t params
0098 )
0099 {
0100   register uintptr_t op_and_return_reg __asm__("r0");
0101   register uintptr_t params_reg __asm__("r1");
0102 
0103   op_and_return_reg = op;
0104   params_reg = params;
0105 
0106   __asm__ volatile (
0107 #ifdef __thumb__
0108     "svc #0xab"
0109 #else
0110     "svc #0x123456"
0111 #endif
0112     : "=r" (op_and_return_reg)
0113     : "0" (op_and_return_reg), "r" (params_reg)
0114     : "memory"
0115   );
0116 
0117   return op_and_return_reg;
0118 }
0119 
0120 void arm_fvp_console_output( char c );
0121 
0122 int arm_fvp_console_input( void );
0123 
0124 /** @} */
0125 
0126 #ifdef __cplusplus
0127 }
0128 #endif
0129 
0130 #endif /* _BSPS_ARM_FVP_SEMIHOSTING_H */