Home | History | Annotate | Download | only in Library
      1 /** @file
      2 
      3   Copyright (c) 2008 - 2009, Apple Inc. All rights reserved.<BR>
      4   Portions copyright (c) 2011, 2012, ARM Ltd. All rights reserved.<BR>
      5 
      6   This program and the accompanying materials
      7   are licensed and made available under the terms and conditions of the BSD License
      8   which accompanies this distribution.  The full text of the license may be found at
      9   http://opensource.org/licenses/bsd-license.php
     10 
     11   THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
     12   WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
     13 
     14 **/
     15 
     16 #ifndef __SEMIHOSTING_H__
     17 #define __SEMIHOSTING_H__
     18 
     19 /*
     20  *
     21  *  Please refer to ARM RVDS 3.0 Compiler and Libraries Guide for more information
     22  *  about the semihosting interface.
     23  *
     24  */
     25 
     26 #define SEMIHOST_FILE_MODE_READ     (0 << 2)
     27 #define SEMIHOST_FILE_MODE_WRITE    (1 << 2)
     28 #define SEMIHOST_FILE_MODE_APPEND   (2 << 2)
     29 #define SEMIHOST_FILE_MODE_UPDATE   (1 << 1)
     30 #define SEMIHOST_FILE_MODE_BINARY   (1 << 0)
     31 #define SEMIHOST_FILE_MODE_ASCII    (0 << 0)
     32 
     33 BOOLEAN
     34 SemihostConnectionSupported (
     35   VOID
     36   );
     37 
     38 RETURN_STATUS
     39 SemihostFileOpen (
     40   IN  CHAR8  *FileName,
     41   IN  UINT32 Mode,
     42   OUT UINTN  *FileHandle
     43   );
     44 
     45 RETURN_STATUS
     46 SemihostFileSeek (
     47   IN UINTN  FileHandle,
     48   IN UINTN  Offset
     49   );
     50 
     51 RETURN_STATUS
     52 SemihostFileRead (
     53   IN     UINTN  FileHandle,
     54   IN OUT UINTN  *Length,
     55   OUT    VOID   *Buffer
     56   );
     57 
     58 RETURN_STATUS
     59 SemihostFileWrite (
     60   IN     UINTN  FileHandle,
     61   IN OUT UINTN  *Length,
     62   IN     VOID   *Buffer
     63   );
     64 
     65 RETURN_STATUS
     66 SemihostFileClose (
     67   IN UINTN  FileHandle
     68   );
     69 
     70 RETURN_STATUS
     71 SemihostFileLength (
     72   IN  UINTN  FileHandle,
     73   OUT UINTN  *Length
     74   );
     75 
     76 /**
     77   Get a temporary name for a file from the host running the debug agent.
     78 
     79   @param[out]  Buffer      Pointer to the buffer where the temporary name has to
     80                            be stored
     81   @param[in]   Identifier  File name identifier (integer in the range 0 to 255)
     82   @param[in]   Length      Length of the buffer to store the temporary name
     83 
     84   @retval  RETURN_SUCCESS            Temporary name returned
     85   @retval  RETURN_INVALID_PARAMETER  Invalid buffer address
     86   @retval  RETURN_ABORTED            Temporary name not returned
     87 
     88 **/
     89 RETURN_STATUS
     90 SemihostFileTmpName(
     91   OUT  VOID   *Buffer,
     92   IN   UINT8  Identifier,
     93   IN   UINTN  Length
     94   );
     95 
     96 RETURN_STATUS
     97 SemihostFileRemove (
     98   IN CHAR8 *FileName
     99   );
    100 
    101 /**
    102   Rename a specified file.
    103 
    104   @param[in]  FileName     Name of the file to rename.
    105   @param[in]  NewFileName  The new name of the file.
    106 
    107   @retval  RETURN_SUCCESS            File Renamed
    108   @retval  RETURN_INVALID_PARAMETER  Either the current or the new name is not specified
    109   @retval  RETURN_ABORTED            Rename failed
    110 
    111 **/
    112 RETURN_STATUS
    113 SemihostFileRename(
    114   IN  CHAR8  *FileName,
    115   IN  CHAR8  *NewFileName
    116   );
    117 
    118 CHAR8
    119 SemihostReadCharacter (
    120   VOID
    121   );
    122 
    123 VOID
    124 SemihostWriteCharacter (
    125   IN CHAR8 Character
    126   );
    127 
    128 VOID
    129 SemihostWriteString (
    130   IN CHAR8 *String
    131   );
    132 
    133 UINT32
    134 SemihostSystem (
    135   IN CHAR8 *CommandLine
    136   );
    137 
    138 #endif // __SEMIHOSTING_H__
    139