r_dev_syscall.c 4.21 KB
Newer Older
时昊's avatar
时昊 committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152
/*
****************************************************************************
PROJECT : device driver for V-Lib
FILE    : $Id: r_dev_syscall.c 4063 2014-10-09 08:02:47Z golczewskim $
============================================================================
DESCRIPTION
r7f701412 syscall routines
============================================================================
                            C O P Y R I G H T
============================================================================
                       Copyright (c) 2013 - 2014
                                  by
                       Renesas Electronics (Europe) GmbH.
                           Arcadiastrasse 10
                          D-40472 Duesseldorf
                               Germany
                          All rights reserved.
============================================================================
Purpose: only for testing, not for mass production

DISCLAIMER

LICENSEE has read, understood and accepted the terms and conditions defined in
the license agreement, especially the usage rights. In any case, it is
LICENSEE's responsibility to make sure that any user of the software complies
with the terms and conditions of the signed license agreement.

SAMPLE CODE is not part of the licensed software, as such it must not be used in
mass-production applications. It can only be used for evaluation and
demonstration purposes at customer's premises listed in the signed license
agreement.

****************************************************************************
*/

/*******************************************************************************
  Title: device general (error handling, init/prepare) functions


*/

/*******************************************************************************
  Section: Includes
*/

#include "r_typedefs.h"
#include "r_dev_api.h"

#ifdef R_DBG_PRINT_MSG
    #include <stdio.h>
    #include "r_dbg_api.h"
#endif

#ifdef USE_PBG
    #include "r_pbg_api.h"
#endif

/*******************************************************************************
  Section: Local Types
*/

/*******************************************************************************
  Section: Local Constants
*/

/*******************************************************************************
  Section: Local Variables
*/

/*******************************************************************************
  Section: Local Functions
*/

/*******************************************************************************
  Section: Headers for Assember Functions

  The following two functions are defined in <r_dev_asm.s>
*/

/***********************************************************
  Function: R_DEV_EnterUserModeElevated

  Sets the UserMode bit of the PSW.
  Calling this function reduces the privileges of the application.
  To be called from <R_DEV_SysCallElevated>.

  Parameters:
  void

  Returns:
  void

*/

void R_DEV_EnterUserModeElevated(void);

/***********************************************************
  Function: R_DEV_EnterSupervisorModeElevated

  Clears the UserMode bit of the FEPSW.
  Calling this function elevates the privileges of the application.
  To be called from <R_DEV_SysCallElevated>.

  Parameters:
  void

  Returns:
  void

*/

void R_DEV_EnterSupervisorModeElevated(void);

/*******************************************************************************
  Section: Global Functions
*/

/*******************************************************************************
  Function: R_DEV_SysCallElevated

  see <r_dev_api.h>

*/
uint32_t R_DEV_SysCallElevated(r_dev_SysCall_t Cmd, void *Par1, void *Par2, void *Par3)
{
    uint32_t retval;

    switch ( Cmd )
    {
        case R_DEV_SYSCALL_SUPERVISOR_MODE:
            R_DEV_EnterSupervisorModeElevated( );
            retval = 0;
            break;
        case R_DEV_SYSCALL_USER_MODE:
            R_DEV_EnterUserModeElevated( );
            retval = 0;
            break;
        case R_DEV_SYSCALL_CONFIGURE_PBG:
#ifdef USE_PBG
            retval = ( uint32_t )R_PBG_ConfigureGuard(
                *( r_pbg_Id_t * )Par1, *( r_pbg_Config_t * )Par2);
#else
            retval = 0;
#endif
            break;
        default:
            retval = 1;
            break;
    }

    return retval;
}