[313] | 1 | /*
|
---|
| 2 | * TOPPERS/ASP Kernel
|
---|
| 3 | * Toyohashi Open Platform for Embedded Real-Time Systems/
|
---|
| 4 | * Advanced Standard Profile Kernel
|
---|
| 5 | *
|
---|
| 6 | * Copyright (C) 2000-2003 by Embedded and Real-Time Systems Laboratory
|
---|
| 7 | * Toyohashi Univ. of Technology, JAPAN
|
---|
| 8 | * Copyright (C) 2005,2006 by Embedded and Real-Time Systems Laboratory
|
---|
| 9 | * Graduate School of Information Science, Nagoya Univ., JAPAN
|
---|
| 10 | * Copyright (C) 2008-2010 by Witz Corporation, JAPAN
|
---|
| 11 | *
|
---|
| 12 | * ä¸è¨èä½æ¨©è
|
---|
| 13 | ã¯ï¼ä»¥ä¸ã® (1)ï½(4) ã®æ¡ä»¶ãï¼Free Software Foundation
|
---|
| 14 | * ã«ãã£ã¦å
|
---|
| 15 | ¬è¡¨ããã¦ãã GNU General Public License ã® Version 2 ã«è¨
|
---|
| 16 | * è¿°ããã¦ããæ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§ã¢ï¼æ¬ã½ããã¦ã§ã¢
|
---|
| 17 | * ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ã使ç¨ã»è¤è£½ã»æ¹å¤ã»åé
|
---|
| 18 | å¸ï¼ä»¥ä¸ï¼
|
---|
| 19 | * å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
|
---|
| 20 | * (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
|
---|
| 21 | * 権表示ï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
|
---|
| 22 | * ã¹ã³ã¼ãä¸ã«å«ã¾ãã¦ãããã¨ï¼
|
---|
| 23 | * (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
|
---|
| 24 | * ç¨ã§ããå½¢ã§åé
|
---|
| 25 | å¸ããå ´åã«ã¯ï¼åé
|
---|
| 26 | å¸ã«ä¼´ãããã¥ã¡ã³ãï¼å©ç¨
|
---|
| 27 | * è
|
---|
| 28 | ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
|
---|
| 29 | * ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
|
---|
| 30 | * (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
|
---|
| 31 | * ç¨ã§ããªãå½¢ã§åé
|
---|
| 32 | å¸ããå ´åã«ã¯ï¼æ¬¡ã®ããããã®æ¡ä»¶ãæºããã
|
---|
| 33 | * ã¨ï¼
|
---|
| 34 | * (a) åé
|
---|
| 35 | å¸ã«ä¼´ãããã¥ã¡ã³ãï¼å©ç¨è
|
---|
| 36 | ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
|
---|
| 37 | * ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
|
---|
| 38 | * (b) åé
|
---|
| 39 | å¸ã®å½¢æ
|
---|
| 40 | ãï¼å¥ã«å®ããæ¹æ³ã«ãã£ã¦ï¼TOPPERSããã¸ã§ã¯ãã«
|
---|
| 41 | * å ±åãããã¨ï¼
|
---|
| 42 | * (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
|
---|
| 43 | * 害ãããï¼ä¸è¨èä½æ¨©è
|
---|
| 44 | ããã³TOPPERSããã¸ã§ã¯ããå
|
---|
| 45 | 責ãããã¨ï¼
|
---|
| 46 | *
|
---|
| 47 | * æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
|
---|
| 48 | ã
|
---|
| 49 | * ãã³TOPPERSããã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ãã®é©ç¨å¯è½æ§ã
|
---|
| 50 | * å«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´
|
---|
| 51 | * æ¥çã¾ãã¯éæ¥çã«çãããããªãæ害ã«é¢ãã¦ãï¼ãã®è²¬ä»»ãè² ããªãï¼
|
---|
| 52 | *
|
---|
| 53 | */
|
---|
| 54 |
|
---|
| 55 | /*
|
---|
| 56 | * ããã»ããµã®ç¹æ®å½ä»¤ã®ã¤ã³ã©ã¤ã³é¢æ°å®ç¾©
|
---|
| 57 | */
|
---|
| 58 |
|
---|
| 59 | #ifndef TOPPERS_PRC_INSN_H
|
---|
| 60 | #define TOPPERS_PRC_INSN_H
|
---|
| 61 |
|
---|
| 62 |
|
---|
| 63 | static uint32_t current_psw( void );
|
---|
| 64 | static void set_psw( uint32_t psw );
|
---|
| 65 | Inline uint32_t current_ipl( void );
|
---|
| 66 | Inline void set_ipl( uint32_t ipl );
|
---|
| 67 | static void disint( void );
|
---|
| 68 | static void enaint( void );
|
---|
| 69 | static uint16_t rev_endian_uint16( uint16_t data );
|
---|
| 70 | static uint32_t rev_endian_uint32( uint32_t data );
|
---|
| 71 |
|
---|
| 72 |
|
---|
| 73 | /*
|
---|
| 74 | * Iãã©ã°, IPLãåå¾ããããã®ãã¯ãå®ç¾©
|
---|
| 75 | */
|
---|
| 76 | #define PSW_I_MASK ( 0x00010000UL )
|
---|
| 77 | #define PSW_IPL_MASK ( 0x0F000000UL )
|
---|
| 78 |
|
---|
| 79 |
|
---|
| 80 | /*
|
---|
| 81 | * ããã»ããµã¹ãã¼ã¿ã¹ã¬ã¸ã¹ã¿(PSW)ã®ç¾å¨å¤ã®èªåºã
|
---|
| 82 | */
|
---|
| 83 | #pragma inline_asm current_psw
|
---|
| 84 | static uint32_t
|
---|
| 85 | current_psw( void )
|
---|
| 86 | {
|
---|
| 87 | mvfc psw, r1
|
---|
| 88 | }
|
---|
| 89 |
|
---|
| 90 |
|
---|
| 91 | /*
|
---|
| 92 | * ããã»ããµã¹ãã¼ã¿ã¹ã¬ã¸ã¹ã¿(PSW)ã¸è¨å®
|
---|
| 93 | */
|
---|
| 94 | #pragma inline_asm set_psw
|
---|
| 95 | static void
|
---|
| 96 | set_psw( uint32_t psw )
|
---|
| 97 | {
|
---|
| 98 | mvtc r1, psw
|
---|
| 99 | }
|
---|
| 100 |
|
---|
| 101 |
|
---|
| 102 | /*
|
---|
| 103 | * IPLã®ç¾å¨å¤ã®èªåºã
|
---|
| 104 | */
|
---|
| 105 | Inline uint32_t
|
---|
| 106 | current_ipl( void )
|
---|
| 107 | {
|
---|
| 108 | return ( uint32_t )( current_psw() & PSW_IPL_MASK );
|
---|
| 109 | }
|
---|
| 110 |
|
---|
| 111 |
|
---|
| 112 | /*
|
---|
| 113 | * IPLã¸è¨å®
|
---|
| 114 | */
|
---|
| 115 | Inline void
|
---|
| 116 | set_ipl( uint32_t ipl )
|
---|
| 117 | {
|
---|
| 118 | set_psw( ( current_psw() & ( ~PSW_IPL_MASK ) ) | ipl );
|
---|
| 119 | }
|
---|
| 120 |
|
---|
| 121 |
|
---|
| 122 | /*
|
---|
| 123 | * NMIãé¤ããã¹ã¦ã®å²è¾¼ã¿ã®ç¦æ¢
|
---|
| 124 | */
|
---|
| 125 | #pragma inline_asm disint
|
---|
| 126 | static void
|
---|
| 127 | disint( void )
|
---|
| 128 | {
|
---|
| 129 | clrpsw i
|
---|
| 130 | }
|
---|
| 131 |
|
---|
| 132 |
|
---|
| 133 | /*
|
---|
| 134 | * NMIãé¤ããã¹ã¦ã®å²è¾¼ã¿ã®è¨±å¯
|
---|
| 135 | */
|
---|
| 136 | #pragma inline_asm enaint
|
---|
| 137 | static void
|
---|
| 138 | enaint( void )
|
---|
| 139 | {
|
---|
| 140 | setpsw i
|
---|
| 141 | }
|
---|
| 142 |
|
---|
| 143 |
|
---|
| 144 | /*
|
---|
| 145 | * ã¨ã³ãã£ã¢ã³å¤æ 16bit
|
---|
| 146 | */
|
---|
| 147 | #pragma inline_asm rev_endian_uint16
|
---|
| 148 | static uint16_t
|
---|
| 149 | rev_endian_uint16( uint16_t data )
|
---|
| 150 | {
|
---|
| 151 | revw r1, r1
|
---|
| 152 | }
|
---|
| 153 |
|
---|
| 154 | /*
|
---|
| 155 | * ã¨ã³ãã£ã¢ã³å¤æ 32bit
|
---|
| 156 | */
|
---|
| 157 | #pragma inline_asm rev_endian_uint32
|
---|
| 158 | static uint32_t
|
---|
| 159 | rev_endian_uint32( uint32_t data )
|
---|
| 160 | {
|
---|
| 161 | revl r1, r1
|
---|
| 162 | }
|
---|
| 163 |
|
---|
| 164 |
|
---|
| 165 | #endif /* TOPPERS_PRC_INSN_H */
|
---|