r_dev_asm.s 4.8 KB
Newer Older
hu's avatar
hu 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 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182
/*
****************************************************************************
PROJECT : Vlib Device Driver 
FILE    : $Id: r_dev_asm.s 11006 2016-11-07 16:32:44Z michael.golczewski $
============================================================================ 
DESCRIPTION
assembler support function 
============================================================================
                            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.

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

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

        .text

/***********************************************************
  Function: _R_DEV_Nop

  Nop instruction that can be used instead of asm("nop")
  for the sake of MISRA compliance.  

  Parameters:
  
*/
/* REPLACED by GHS Intrinsics (see: v800_ghs.h)
        .globl _R_DEV_Nop
_R_DEV_Nop: 
		nop
		jmp     [lp]
*/


/***********************************************************
  Function: _R_DEV_SyncP

  CPU pipeline sync 

  Parameters: none
  
*/
/* REPLACED by GHS Intrinsics (see: v800_ghs.h)
        .globl _R_DEV_SyncP
_R_DEV_SyncP: 
		syncp
		jmp     [lp]
*/


/***********************************************************
  Function: _R_DEV_SyncM

  CPU memory sync 

  Parameters: none
  
*/
/* REPLACED by GHS Intrinsics (see: v800_ghs.h)
        .globl _R_DEV_SyncM
_R_DEV_SyncM: 
		syncm
		jmp     [lp]
*/


/***********************************************************
  Function: _R_DEV_SysCall

  Do a SysCall to get elevated rights.
  
  Parameters:
  
*/
        .globl _R_DEV_SysCall
_R_DEV_SysCall: 
        /* 0x10: TRAP1 (Vector 0x10 is equal to a EIIC value of 0x50) */
        trap    0x10    
		jmp     [lp]
		
		
		
/***********************************************************
  Function: _R_DEV_Trap1

  Trap handler of the DEV driver.

  This function is called by 'R_DEV_SysCall'
  
  Parameters:
  
*/
        .globl _TRAP1
_TRAP1: 
        .globl _R_DEV_Trap1
_R_DEV_Trap1:
        pushsp	lp-lp
        
        /* sub-routine */
        jarl    _R_DEV_SysCallElevated,lp

        popsp	lp-lp
	    eiret
	
	

/***********************************************************
  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:
  
*/
        .globl _R_DEV_EnterUserModeElevated
_R_DEV_EnterUserModeElevated: 
        /* EIPSW: regID: 1, selID: 0 <= We're supposed to be in TRAP1 */
        /* FEPSW: regID: 3, selID: 0 */
        /* PSW:   regID: 5, selID: 0 */
        /* The selection of the correct xxPSW can be done by evaluating PSW.NP and PSW.DI */
		mov     (1<<30), r7    /* Load Bitmask for UM into r7 */
		stsr    1,  r6, 0      /* Load PSW into r6 */
		or      r7, r6         /* Apply Bitmask to r6 */
		ldsr    r6, 1,  0      /* Load r6 into PSW */
		jmp     [lp]
		
		
		
/***********************************************************
  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:
  
*/
        .globl _R_DEV_EnterSupervisorModeElevated
_R_DEV_EnterSupervisorModeElevated: 
        /* EIPSW: regID: 1, selID: 0 <= We're supposed to be in TRAP1 */
        /* FEPSW: regID: 3, selID: 0 */
        /* PSW:   regID: 5, selID: 0 */
        /* The selection of the correct xxPSW can be done by evaluating PSW.NP and PSW.DI */
		mov     ~(1<<30), r7   /* Load Bitmask for UM into r7 */
		stsr    1,  r6, 0      /* Load EIPSW into r6 */
		and     r7, r6         /* Apply Bitmask to r6 */
		ldsr    r6, 1,  0      /* Load r6 into EIPSW */
		jmp     [lp]



        
       /* EOF */