Changeset 637 for trunk/hal/tsar_mips32
- Timestamp:
- Jul 18, 2019, 2:06:55 PM (5 years ago)
- Location:
- trunk/hal/tsar_mips32/core
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/hal/tsar_mips32/core/hal_gpt.c
r635 r637 133 133 /////////////////////////////////////////////////////////////////////////////////////// 134 134 135 #define GPT_LOCK_WATCHDOG 100000 135 #define GPT_LOCK_WATCHDOG 1000000 136 136 137 137 ///////////////////////////////////// -
trunk/hal/tsar_mips32/core/hal_uspace.c
r626 r637 32 32 /////////////////////////////////////////////////////////////////////////////////////// 33 33 // This function moves <size> bytes from a source buffer in user virtual space, 34 // defined by the <u_src > argument, to a destination kernel buffer, defined by the35 // <k_ cxy> and <k_dst> arguments.36 // It works in a critical section, as it modifies brieflytwo CP2 registers:34 // defined by the <u_src_ptr> argument, to a destination kernel buffer, defined by the 35 // <k_dst_xp> argument. 36 // It works in a critical section, as it modifies two CP2 registers: 37 37 // It activates briefly the DATA_MMU by writing into the CP2_MODE register to access the 38 38 // user buffer, and modifies the CP2_DATA_EXT register to access the kernel buffer. … … 41 41 // If the buffers are not aligned, it moves all data byte per byte. 42 42 /////////////////////////////////////////////////////////////////////////////////////// 43 // @ k_cxy : cluster of destination kernel buffer 44 // @ k_dst : pointer on destination kernel buffer 45 // @ u_src : pointer on source user buffer 43 // @ k_dst_xp : extended pointer on destination kernel buffer 44 // @ u_src_ptr : pointer on source user buffer 46 45 // @ size : number of bytes to move 47 46 /////////////////////////////////////////////////////////////////////////////////////// 48 void hal_copy_from_uspace( cxy_t k_cxy, 49 void * k_dst, 50 void * u_src, 47 void hal_copy_from_uspace( xptr_t k_dst_xp, 48 void * u_src_ptr, 51 49 uint32_t size ) 52 50 { 53 51 uint32_t save_sr; 54 uint32_t words; // number of words (if buffers aligned) 55 uint32_t src = (uint32_t)u_src; 56 uint32_t dst = (uint32_t)k_dst; 52 uint32_t words; // number of words (if buffers aligned) 53 uint32_t src = (uint32_t)u_src_ptr; 54 uint32_t dst = (uint32_t)GET_PTR( k_dst_xp ); 55 uint32_t cxy = (uint32_t)GET_CXY( k_dst_xp ); 56 57 57 58 58 #if DEBUG_HAL_USPACE … … 61 61 if( cycle > DEBUG_HAL_USPACE ) 62 62 printk("\n[%s] thread[%x,%x] enter / %d bytes / u_buf(%x,%x) -> k_buf(%x,%x) / cycle %d\n", 63 __FUNCTION__, this->process->pid, this->trdid, size, local_cxy, u_src, k_cxy, k_dst, cycle );63 __FUNCTION__, this->process->pid, this->trdid, size, local_cxy, src, cxy, dst, cycle ); 64 64 #endif 65 65 … … 80 80 "ori $13, $12, 0x4 \n" /* $13 <= MMU_MODE with DTLB */ 81 81 82 /* save old MMU_DATA_EXT and set k_cxy in it*/82 /* save old MMU_DATA_EXT and set cxy in it */ 83 83 "mfc2 $16, $24 \n" /* $16 <= old MMU_DATA_EXT */ 84 "mtc2 %4, $24 \n" /* MMU_DATA_EXT <= k_cxy*/84 "mtc2 %4, $24 \n" /* MMU_DATA_EXT <= cxy */ 85 85 86 86 /* transfer one word per iteration in first loop if aligned */ … … 118 118 ".set reorder \n" 119 119 : 120 : "r"(src) , "r"(dst) , "r"(words) , "r"(size) , "r"( k_cxy)120 : "r"(src) , "r"(dst) , "r"(words) , "r"(size) , "r"(cxy) 121 121 : "$8","$9","$10","$11","$12","$13","$14","$15","$16","memory" ); 122 122 … … 128 128 if( cycle > DEBUG_HAL_USPACE ) 129 129 printk("\n[%s] thread[%x,%x] moved %d bytes / u_buf(%x,%x) -> k_buf(%x,%x) / cycle %d\n", 130 __FUNCTION__, this->process->pid, this->trdid, size, local_cxy, u_src, k_cxy, k_dst, cycle );130 __FUNCTION__, this->process->pid, this->trdid, size, local_cxy, src, cxy, dst, cycle ); 131 131 #endif 132 132 … … 135 135 /////////////////////////////////////////////////////////////////////////////////////// 136 136 // This function moves <size> bytes from a source kernel buffer, defined by the 137 // <k_ cxy> and <k_src> arguments, to a destination buffer in user virtual space,138 // defined by the <u_dst> argument.139 // It works in a critical section, as it modifies brieflytwo CP2 registers:137 // <k_src_xp> argument, to a destination buffer in user virtual space, defined by 138 // the <u_dst_ptr> argument. 139 // It works in a critical section, as it modifies two CP2 registers: 140 140 // It activates briefly the DATA_MMU by writing into the CP2_MODE register to access the 141 141 // user buffer, and modifies the CP2_DATA_EXT register to access the kernel buffer. … … 144 144 // If the buffers are not aligned, it moves all data byte per byte. 145 145 /////////////////////////////////////////////////////////////////////////////////////// 146 // @ k_cxy : cluster of destination kernel buffer 147 // @ k_dst : pointer on destination kernel buffer 148 // @ u_src : pointer on source user buffer 149 // @ size : number of bytes to move 150 /////////////////////////////////////////////////////////////////////////////////////// 151 void hal_copy_to_uspace( cxy_t k_cxy, 152 void * k_src, 153 void * u_dst, 146 // @ u_dst_ptr : pointer on destination user buffer 147 // @ k_src_xp : extended pointer on source kernel buffer 148 // @ size : number of bytes to move 149 /////////////////////////////////////////////////////////////////////////////////////// 150 void hal_copy_to_uspace( void * u_dst_ptr, 151 xptr_t k_src_xp, 154 152 uint32_t size ) 155 153 { 156 154 uint32_t save_sr; 157 uint32_t words; // number of words (if buffers aligned) 158 uint32_t src = (uint32_t)k_src; 159 uint32_t dst = (uint32_t)u_dst; 155 uint32_t words; // number of words (if buffers aligned) 156 uint32_t dst = (uint32_t)u_dst_ptr; 157 uint32_t src = (uint32_t)GET_PTR( k_src_xp ); 158 uint32_t cxy = (uint32_t)GET_CXY( k_src_xp ); 160 159 161 160 #if DEBUG_HAL_USPACE … … 164 163 if( cycle > DEBUG_HAL_USPACE ) 165 164 printk("\n[%s] thread[%x,%x] enter / %d bytes / k_buf(%x,%x) -> u_buf(%x,%x) / cycle %d\n", 166 __FUNCTION__, this->process->pid, this->trdid, size, k_cxy, k_src, local_cxy, u_dst, cycle );165 __FUNCTION__, this->process->pid, this->trdid, size, cxy, src, local_cxy, dst, cycle ); 167 166 #endif 168 167 … … 183 182 "ori $13, $12, 0x4 \n" /* $13 <= MMU_MODE with DTLB */ 184 183 185 /* save old MMU_DATA_EXT and set k_cxy in it*/184 /* save old MMU_DATA_EXT and set cxy in it */ 186 185 "mfc2 $16, $24 \n" /* $16 <= old MMU_DATA_EXT */ 187 "mtc2 %4, $24 \n" /* MMU_DATA_EXT <= k_cxy*/186 "mtc2 %4, $24 \n" /* MMU_DATA_EXT <= cxy */ 188 187 189 188 /* transfer one word per iteration in first loop if aligned */ … … 221 220 ".set reorder \n" 222 221 : 223 : "r"(src) , "r"(dst) , "r"(words) , "r"(size) , "r"( k_cxy)222 : "r"(src) , "r"(dst) , "r"(words) , "r"(size) , "r"(cxy) 224 223 : "$8","$9","$10","$11","$12","$13","$14","$15","$16","memory" ); 225 224 … … 231 230 if( cycle > DEBUG_HAL_USPACE ) 232 231 printk("\n[%s] thread[%x,%x] moved %d bytes / k_buf(%x,%x) -> u_buf(%x,%x) / cycle %d\n", 233 __FUNCTION__, this->process->pid, this->trdid, size, k_cxy, k_src, local_cxy, u_dst, cycle );232 __FUNCTION__, this->process->pid, this->trdid, size, cxy, src, local_cxy, dst, cycle ); 234 233 #endif 235 234 236 235 } // end hal_copy_to_uspace() 237 236 238 ////////////////////////////////////////////// 239 void hal_strcpy_from_uspace( char * k_dst,240 char * u_src ,237 ///////////////////////////////////////////////// 238 void hal_strcpy_from_uspace( xptr_t k_dst_xp, 239 char * u_src_ptr, 241 240 uint32_t size ) 242 241 { 243 242 uint32_t save_sr; 244 uint32_t src = (uint32_t)u_src; 245 uint32_t dst = (uint32_t)k_dst; 243 uint32_t src = (uint32_t)u_src_ptr; 244 uint32_t dst = (uint32_t)GET_PTR( k_dst_xp ); 245 uint32_t cxy = (uint32_t)GET_CXY( k_dst_xp ); 246 246 247 247 hal_disable_irq( &save_sr ); 248 248 249 249 // loop on characters while ( (character != NUL) and (count < size ) ) 250 250 251 asm volatile( 251 252 ".set noreorder \n" 253 254 /* save old MMU_DATA_EXT and set cxy in it */ 255 "mfc2 $16, $24 \n" /* $16 <= old MMU_DATA_EXT */ 256 "mtc2 %3, $24 \n" /* MMU_DATA_EXT <= cxy */ 257 252 258 "move $11, %0 \n" /* $11 <= count == size */ 253 259 "move $12, %1 \n" /* $12 <= u_src */ 254 260 "move $13, %2 \n" /* $13 <= k_dst */ 255 "mfc2 $15, $1 \n" /* $15 <= mode DTLB and ITLB off */ 256 "ori $14, $15, 0x4 \n" /* $14 <= mode DTLB on */ 261 "mfc2 $15, $1 \n" /* $15 <= MMU_MODE */ 262 "ori $14, $15, 0x4 \n" /* $14 <= MMU_MODE / DTLB ON */ 263 257 264 "1: \n" 258 265 "mtc2 $14, $1 \n" /* MMU_MODE <= DTLB ON */ 259 266 "lb $10, 0($12) \n" /* read char from user space */ 260 "mtc2 $15, $1 \n" /* restore DTLB and ITLB off*/267 "mtc2 $15, $1 \n" /* MMU_MODE <= DTLB OFF */ 261 268 "sb $10, 0($13) \n" /* store char to kernel space */ 262 269 "beq $10, $0, 2f \n" /* exit if char = 0 */ … … 268 275 "2: \n" 269 276 "nop \n" 277 278 /* restore old MMU_DATA_EXT register */ 279 "mtc2 $16, $24 \n" /* MMU_DATA_EXT <= $16 */ 280 270 281 ".set reorder \n" 271 282 : 272 : "r"(size) ,"r"(src),"r"(dst)273 : "$10","$11","$12","$13","$14","$15" );283 : "r"(size) , "r"(src) , "r"(dst) , "r"(cxy) 284 : "$10","$11","$12","$13","$14","$15","$16" ); 274 285 275 286 hal_restore_irq( save_sr ); … … 277 288 } // hal_strcpy_from_uspace() 278 289 279 //////////////////////////////////////////// 280 void hal_strcpy_to_uspace( char * u_dst ,281 char * k_src,290 //////////////////////////////////////////////// 291 void hal_strcpy_to_uspace( char * u_dst_ptr, 292 xptr_t k_src_xp, 282 293 uint32_t size ) 283 294 { 284 295 uint32_t save_sr; 285 uint32_t src = (uint32_t)k_src; 286 uint32_t dst = (uint32_t)u_dst; 296 uint32_t dst = (uint32_t)u_dst_ptr; 297 uint32_t src = (uint32_t)GET_PTR( k_src_xp ); 298 uint32_t cxy = (uint32_t)GET_CXY( k_src_xp ); 287 299 288 300 hal_disable_irq( &save_sr ); 289 301 290 302 // loop on characters while ( (character != NUL) and (count < size) ) 303 291 304 asm volatile( 292 305 ".set noreorder \n" 306 307 /* save old MMU_DATA_EXT and set cxy in it */ 308 "mfc2 $16, $24 \n" /* $16 <= old MMU_DATA_EXT */ 309 "mtc2 %3, $24 \n" /* MMU_DATA_EXT <= cxy */ 310 293 311 "move $11, %0 \n" /* $11 <= count == size */ 294 312 "move $12, %1 \n" /* $12 <= k_src */ 295 313 "move $13, %2 \n" /* $13 <= u_dst */ 296 "mfc2 $15, $1 \n" /* $15 <= mode DTLB and ITLB off */ 297 "ori $14, $15, 0x4 \n" /* $14 <= mode DTLB on */ 314 "mfc2 $15, $1 \n" /* $15 <= MMU_MODE */ 315 "ori $14, $15, 0x4 \n" /* $14 <= MMU_MODE modified */ 316 298 317 "1: \n" 299 318 "lb $10, 0($12) \n" /* read char from kernel space */ 300 319 "mtc2 $14, $1 \n" /* MMU_MODE <= DTLB ON */ 301 320 "sb $10, 0($13) \n" /* store char to user space */ 302 "mtc2 $15, $1 \n" /* restore DTLB and ITLB off*/321 "mtc2 $15, $1 \n" /* MMU_MODE <= DTLB OFF */ 303 322 "beq $10, $0, 2f \n" /* exit if char == 0 */ 304 323 "addi $11, $11, -1 \n" /* decrement count */ 305 324 "addi $12, $12, 1 \n" /* increment k_src pointer */ 306 "beq $11, $0, 2f \n" /* exit if count == size*/325 "beq $11, $0, 2f \n" /* exit if count == 0 */ 307 326 "addi $13, $13, 1 \n" /* increment u_src pointer */ 308 327 "j 1b \n" /* jump to next iteration */ 309 328 "2: \n" 310 329 "nop \n" 330 331 /* restore old MMU_DATA_EXT register */ 332 "mtc2 $16, $24 \n" /* MMU_DATA_EXT <= $16 */ 333 311 334 ".set reorder \n" 312 335 : 313 : "r"(size) ,"r"(src),"r"(dst)314 : "$10","$11","$12","$13","$14","$15" );336 : "r"(size) , "r"(src) , "r"(dst) , "r"(cxy) 337 : "$10","$11","$12","$13","$14","$15","$16" ); 315 338 316 339 hal_restore_irq( save_sr ); -
trunk/hal/tsar_mips32/core/hal_vmm.c
r635 r637 111 111 printk("\n[%s] thread[%x,%x] registered kcode vseg[%x,%x] in cluster %x\n", 112 112 __FUNCTION__, this->process->pid, this->trdid, info->kcode_base, info->kcode_size, local_cxy ); 113 hal_vmm_display( &process_zero, true );113 hal_vmm_display( XPTR( local_cxy, &process_zero ) , true ); 114 114 #endif 115 115 … … 136 136 printk("\n[%s] thread[%x,%x] enter in cluster %x \n", 137 137 __FUNCTION__, this->process->pid, this->trdid, cxy ); 138 hal_vmm_display( &process_zero , true ); 139 hal_vmm_display( process , true ); 138 hal_vmm_display( XPTR( local_cxy , process ) , true ); 140 139 #endif 141 140 … … 190 189 __FUNCTION__, this->process->pid, this->trdid, 191 190 vseg_type_str(vseg->type) , vseg->min, (vseg->max - vseg->min) ); 192 hal_vmm_display( process, true );191 hal_vmm_display( XPTR( local_cxy , process ) , true ); 193 192 #endif 194 193
Note: See TracChangeset
for help on using the changeset viewer.