- Timestamp:
- Jun 28, 2017, 5:32:42 PM (7 years ago)
- Location:
- trunk/hal/tsar_mips32/core
- Files:
-
- 4 deleted
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/hal/tsar_mips32/core/hal_uspace.c
r62 r87 50 50 "mtc2 $14, $1 \n" /* MMU_MODE <= DTLB ON */ 51 51 "lw $13, 0(%0) \n" /* read data from user space */ 52 "mtc2 $1 4, $1 \n" /* restore MMU_MODE */52 "mtc2 $15, $1 \n" /* restore MMU_MODE */ 53 53 "sw $13, 0(%1) \n" /* store data to kernel space */ 54 54 : : "r"( src ) , "r"( dst ) : "$13","$14","$15", "memory" ); … … 65 65 "mtc2 $14, $1 \n" /* MMU_MODE <= DTLB ON */ 66 66 "lb $13, 0(%0) \n" /* read data from user space */ 67 "mtc2 $1 4, $1 \n" /* restore MMU_MODE */67 "mtc2 $15, $1 \n" /* restore MMU_MODE */ 68 68 "sb $13, 0(%1) \n" /* store data to kernel space */ 69 69 : : "r"( src ) , "r"( dst ) : "$13","$14","$15", "memory" ); … … 74 74 75 75 hal_restore_irq( save_sr ); 76 } 76 77 } // end hal_copy_from_uspace() 77 78 78 79 /////////////////////////////////////////// … … 83 84 uint32_t save_sr; 84 85 uint32_t i; 85 uint32_t wsize; // number of words 86 uint32_t wsize; // number of words if aligned 86 87 uint32_t src = (uint32_t)k_src; 87 88 uint32_t dst = (uint32_t)u_dst; 88 89 89 if( (dst & 0x3) || (src & 0x3) ) wsize = 0; // do it all in bytes90 if( (dst & 0x3) || (src & 0x3) ) wsize = 0; // not aligned 90 91 else wsize = size >> 2; 91 92 … … 100 101 "mtc2 $14, $1 \n" /* MMU_MODE <= DTLB ON */ 101 102 "sw $13, 0(%1) \n" /* store data to user space */ 102 "mtc2 $1 4, $1 \n" /* restore MMU_MODE */103 "mtc2 $15, $1 \n" /* restore MMU_MODE */ 103 104 : : "r"( src ) , "r"( dst ) : "$13","$14","$15", "memory" ); 104 105 … … 115 116 "mtc2 $14, $1 \n" /* MMU_MODE <= DTLB ON */ 116 117 "sb $13, 0(%1) \n" /* store data to user space */ 117 "mtc2 $1 4, $1 \n" /* restore MMU_MODE */118 "mtc2 $15, $1 \n" /* restore MMU_MODE */ 118 119 : : "r"( src ) , "r"( dst ) : "$13","$14","$15", "memory" ); 119 120 … … 123 124 124 125 hal_restore_irq( save_sr ); 125 } 126 127 } // end hal_copy_to_uspace() 128 129 ////////////////////////////////////////// 130 void hal_strcpy_from_uspace( char * k_dst, 131 char * u_src ) 132 133 { 134 uint32_t save_sr; 135 uint32_t src = (uint32_t)u_src; 136 uint32_t dst = (uint32_t)k_dst; 137 138 hal_disable_irq( &save_sr ); 139 140 // loop on characters while non NUL 141 asm volatile( 142 "mfc2 $15, $1 \n" /* save current MMU_MODE */ 143 "1: \n" /* loop entry */ 144 "ori $14, $0, 0x7 \n" 145 "mtc2 $14, $1 \n" /* MMU_MODE <= DTLB ON */ 146 "lb $13, 0(%0) \n" /* read char from user space */ 147 "mtc2 $15, $1 \n" /* restore MMU_MODE */ 148 "sb $13, 0(%1) \n" /* store char to kernel space */ 149 "addi %0, %0, 1 \n" /* increment SRC pointer */ 150 "addi %1, %1, 1 \n" /* increment DST pointer */ 151 "bne $13, $0, 1b \n" /* test NUL */ 152 "nop \n" 153 : : "r"( src ) , "r"( dst ) : "$13","$14","$15", "memory" ); 154 155 hal_restore_irq( save_sr ); 156 157 } // hal_strcpy_from_uspace() 158 159 ////////////////////////////////////////// 160 void hal_strcpy_to_uspace( char * u_dst, 161 char * k_src ) 162 163 { 164 uint32_t save_sr; 165 uint32_t src = (uint32_t)k_src; 166 uint32_t dst = (uint32_t)u_dst; 167 168 hal_disable_irq( &save_sr ); 169 170 // loop on characters while non NUL 171 asm volatile( 172 "mfc2 $15, $1 \n" /* save current MMU_MODE */ 173 "1: \n" /* loop entry */ 174 "lb $13, 0(%0) \n" /* read char from kernel space */ 175 "ori $14, $0, 0x7 \n" 176 "mtc2 $14, $1 \n" /* MMU_MODE <= DTLB ON */ 177 "sb $13, 0(%1) \n" /* store char to user space */ 178 "mtc2 $15, $1 \n" /* restore MMU_MODE */ 179 "addi %0, %0, 1 \n" /* increment SRC pointer */ 180 "addi %1, %1, 1 \n" /* increment DST pointer */ 181 "bne $13, $0, 1b \n" /* test NUL */ 182 "nop \n" 183 : : "r"( src ) , "r"( dst ) : "$13","$14","$15", "memory" ); 184 185 hal_restore_irq( save_sr ); 186 187 } // hal_strcpy_from_uspace() 126 188 127 189 /////////////////////////////////////////////// … … 143 205 144 206 "1: \n" 145 "lb $13, 0(%0) \n" /* read datafrom kernel space */207 "lb $13, 0(%0) \n" /* read char from kernel space */ 146 208 "addi $13, $13, 1 \n" /* increment address */ 147 209 "bne $13, $0, 1b \n" /* loop until NUL found */
Note: See TracChangeset
for help on using the changeset viewer.