- Timestamp:
- Jul 27, 2017, 12:23:29 AM (7 years ago)
- Location:
- trunk/hal
- Files:
-
- 19 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/hal/generic/hal_irqmask.h
r17 r279 38 38 /***************************************************************************************** 39 39 * This function disables all IRQs, and saves the CPU SR state if required. 40 * TODO : Warning this function discards the CU3 access bit41 40 ***************************************************************************************** 42 41 * @ old : address of buffer to save the SR (no save if NULL). -
trunk/hal/generic/hal_special.h
r124 r279 36 36 // ALMOS-MKH uses the following API to access the MMU and other core protected registers. 37 37 /////////////////////////////////////////////////////////////////////////////////////////// 38 39 /***************************************************************************************** 40 * This function returns the calling core status register value. 41 ****************************************************************************************/ 42 inline reg_t hal_get_sr(); 38 43 39 44 /***************************************************************************************** -
trunk/hal/tsar_mips32/core/hal_drivers.c
r266 r279 75 75 /* update the PIC chdev extension */ 76 76 pic->ext.pic.enable_timer = &soclib_pic_enable_timer; 77 pic->ext.pic.enable_ipi = &soclib_pic_enable_ipi; 77 78 pic->ext.pic.enable_irq = &soclib_pic_enable_irq; 78 79 pic->ext.pic.disable_irq = &soclib_pic_disable_irq; -
trunk/hal/tsar_mips32/core/hal_interrupt.c
r238 r279 23 23 24 24 #include <hal_types.h> 25 #include <hal_special.h> 25 26 #include <kernel_config.h> 26 27 #include <thread.h> 28 #include <printk.h> 27 29 #include <do_interrupt.h> 28 30 #include <hal_interrupt.h> 29 #include <mips32_uzone.h>30 31 #include <soclib_pic.h> 31 32 … … 34 35 reg_t * regs_tbl ) 35 36 { 37 irq_dmsg("\n[INFO] %s : enter at cycle %d\n", __FUNCTION__ , hal_time_stamp() ); 38 36 39 // update user time 37 40 thread_user_time_update( this ); … … 45 48 // update kernel time 46 49 thread_kernel_time_update( this ); 50 51 irq_dmsg("\n[INFO] %s : exit at cycle %d\n", __FUNCTION__ , hal_time_stamp() ); 47 52 } -
trunk/hal/tsar_mips32/core/hal_irqmask.c
r62 r279 28 28 inline void hal_disable_irq( uint32_t * old ) 29 29 { 30 register u nsigned int sr;30 register uint32_t sr; 31 31 32 32 __asm__ volatile 33 33 (".set noat \n" 34 ".set noreorder \n" 35 "mfc0 $1, $12 \n" 36 "nop \n" 37 ".set reorder \n" 34 "mfc0 $1, $12 \n" 38 35 "or %0, $0, $1 \n" 39 36 "srl $1, $1, 1 \n" 40 37 "sll $1, $1, 1 \n" 41 38 "mtc0 $1, $12 \n" 42 43 : "=&r" (sr) );39 ".set at \n" 40 : "=&r" (sr) ); 44 41 45 42 if( old ) *old = sr; … … 49 46 inline void hal_enable_irq( uint32_t * old ) 50 47 { 51 register u nsigned int sr;48 register uint32_t sr; 52 49 53 50 __asm__ volatile 54 51 (".set noat \n" 55 ".set noreorder \n"56 52 "mfc0 $1, $12 \n" 57 "nop \n"58 53 "or %0, $0, $1 \n" 59 "ori $1, $1, 0x 1\n"54 "ori $1, $1, 0xFF01 \n" 60 55 "mtc0 $1, $12 \n" 61 "nop \n" 62 ".set reorder \n" 63 ".set at \n" 64 : "=&r" (sr)); 56 ".set at \n" 57 : "=&r" (sr) ); 65 58 66 59 if( old ) *old = sr; … … 71 64 { 72 65 __asm__ volatile 73 (".set noat \n" 74 ".set noreorder \n" 75 "mfc0 $1, $12 \n" 76 "ori $2, $0, 0xFF \n" 77 "and $2, $2, %0 \n" 78 "or $1, $1, $2 \n" 79 "mtc0 $1, $12 \n" 80 ".set reorder \n" 81 ".set at \n" 82 : : "r" (old) : "$2"); 66 ( "mtc0 %0, $12" : : "r" (old) ); 83 67 } 84 68 69 -
trunk/hal/tsar_mips32/core/hal_kentry.S
r121 r279 1 1 /* 2 * hal_kentry.S - exception/interrupt/syscall kernel entry point for MIPS322 * hal_kentry.S - Interrupt / Exception / Syscall kernel entry point for MIPS32 3 3 * 4 4 * AUthors Ghassan Almaless (2007,2008,2009,2010,2011,2012) … … 30 30 # or syscall for the TSAR_MIPS32 architecture. 31 31 # 32 # - If the core is in user mode: 33 # . we desactivate the MMU. 34 # . we save the context in the uzone of the calling thread descriptor. 35 # . we increment the cores_in_kernel variable. 36 # . we call the relevant exception/interrupt/syscall handler 32 # When we enter the kernel, we test the ststus register: 33 # - If the core is in user mode, we desactivate the MMU, and we save 34 # the core context in the uzone of the calling thread descriptor. 35 # - If the core is already in kernel mode (in case of interrupt), 36 # we save the context in the kernel stack. 37 # - In both cases, we increment the cores_in_kernel variable, 38 # and we call the relevant exception/interrupt/syscall handler 37 39 # 38 # - If the core is already in kernel mode: 39 # . we save the context in the kernel stack 40 # . we call the relevant exception/interrupt/syscall handler 41 # 42 # - In both cases, when the handler returns: 43 # . we restore the context 44 # . we reactivate the MMU ??? TODO 40 # When we exit the kernel after handler execution: 41 # - we restore the core context from the uzone 45 42 #--------------------------------------------------------------------------------- 46 43 47 .section .kentry,"ax",@progbits 48 .extern cpu_do_interrupt 49 .extern cpu_do_exception 50 .extern cpu_do_syscall 51 .extern cpu_kentry 52 .extern cpu_kexit 44 .section .kgiet, "ax", @progbits 45 46 .extern hal_do_interrupt 47 .extern hal_do_exception 48 .extern hal_do_syscall 49 .extern cluster_core_kernel_enter 50 .extern cluster_core_kernel_exit 51 53 52 .org 0x180 54 .ent ke ntry55 .global ke ntry56 .global kentry_load 53 .ent kernel_enter 54 .global kernel_enter 55 57 56 .set noat 58 57 .set noreorder … … 67 66 68 67 #--------------------------------------------------------------------------------- 69 # Kernel Entry point 68 # Kernel Entry point for Interrupt / Exception / Syscall 70 69 #--------------------------------------------------------------------------------- 71 70 72 ke ntry:71 kernel_enter: 73 72 mfc0 $26, $12 # read SR to test user/kernel mode 74 73 andi $26, $26, 0x10 # User Mode bitmask … … 101 100 #--------------------------------------------------------------------------------------- 102 101 # this code is executed when the core is in kernel mode: 103 # - we use an uzone allocated in kernel stack.102 # - we use an uzone dynamically allocated in kernel stack. 104 103 # - we set the MMU off, set the MMU data_paddr extension to local_cxy, 105 104 # and save the CP2_MODE and CP2_DEXT to uzone. … … 141 140 142 141 #-------------------------------------------------------------------------------------- 143 # this code is executed in both modes, with the two following assumptions: 144 # - $27 contains the pointer on uzone to save the cpu registers 142 # This code is executed in both modes, and saves the core context, 143 # with the two following assumptions: 144 # - $27 contains the pointer on uzone to save the core registers 145 145 # - $29 contains the kernel stack pointer 146 146 … … 186 186 sw $17, (UZ_CR*4)($27) # Save CR 187 187 188 srl $3, $18, 5 # put SR in kernel mode, IRQ disabled, clear exl 188 # put SR in kernel mode, IRQ disabled, clear exl 189 srl $3, $18, 5 189 190 sll $3, $3, 5 190 191 mtc0 $3, $12 # Set new SR 191 192 192 andi $1, $17, 0x3F # $1 <= XCODE (from CR)193 194 193 # signal that core enters kernel 195 jal cluster_core_kernel_enter 194 la $1, cluster_core_kernel_enter 195 jal $1 196 196 nop 197 197 198 198 #--------------------------------------------------------------------------------------- 199 # Depending on XCODE (in $1) , call the apropriate handler. The three called 200 # functions take the same two arguments: thread pointer and uzone pointer. 199 # This code call the relevant Interrupt / Exception / Syscall handler, 200 # depending on XCODE in CP0_CR, with the two following assumptions: 201 # - $27 contains the pointer on uzone containing to save the core registers 202 # - $29 contains the kernel stack pointer 203 # The three handlers take the same two arguments: thread pointer and uzone pointer. 204 # The uzone pointer is saved in $19 to be used by kernel_exit. 205 206 mfc0 $17, $13 # $1 <= CR 207 andi $1, $1, 0x3F # $1 <= XCODE 201 208 202 209 mfc0 $4, $4, 2 # $4 <= thread pointer (first arg) 203 210 or $5, $0, $27 # $5 <= uzone pointer (second arg) 204 or $19, $0, $27 # $19 <= &uzone (for ke ntry_exit)211 or $19, $0, $27 # $19 <= &uzone (for kernel_exit) 205 212 206 213 ori $8, $0, 0x20 # $8 <= cause syscall … … 215 222 addiu $29, $29, -8 # hal_do_exception has 2 args 216 223 addiu $29, $29, 8 217 j ke ntry_exit # jump to kentry_exit224 j kernel_exit # jump to kernel_exit 218 225 nop 219 226 … … 223 230 addiu $29, $29, -8 # hal_do_syscall has 2 args 224 231 addiu $29, $29, 8 225 j ke ntry_exit # jump to kentry_exit226 or $19, $0, $2232 j kernel_exit # jump to kernel_exit 233 nop 227 234 228 235 cause_int: … … 233 240 234 241 # ----------------------------------------------------------------------------------- 235 # Kentry exit 242 # Kernel exit 243 # The pointer on uzone is supposed to be stored in $19 236 244 # ----------------------------------------------------------------------------------- 237 ke ntry_exit:245 kernel_exit: 238 246 239 247 # signal that core exit kernel 240 jal cluster_core_kernel_exit 248 la $1, cluster_core_kernel_exit 249 jalr $1 250 nop 241 251 242 252 # restore context from uzone … … 286 296 lw $31, (UZ_RA*4)($27) 287 297 288 289 298 lw $26, (UZ_DEXT*4)($27) 290 299 mtc2 $26, $24 # restore CP2_DEXT from uzone 291 300 292 #TODO: optimize 293 lw $26, (UZ_MODE*4)($27) # get saved CP2_MODE from uzone 294 andi $26, $26, 0xc # keep only the TLBs controling bits 295 beq $26, $0, out_mmu_3 # both MSB are 0 (the first two LSB are always set) 296 andi $26, $26, 0x8 297 beq $26, $0, out_mmu_7 # first MSB is 0 (bit 2 is set) 298 299 # Possible value for MMU_MODE 300 # In kernel mode : 0x7/0x3 301 # In user mode : 0xF 302 303 # DP_EXT can either be local or remote 304 # Once these register set we can no longuer 305 # access global data 306 307 out_mmu_F: 308 ori $26, $0, 0xF 309 mtc2 $26, $1 # CP2_MODE <= 0xF 310 j out_kentry 311 nop 312 313 out_mmu_7: 314 ori $26, $0, 0x7 315 mtc2 $26, $1 # CP2_MODE <= 0x7 316 j out_kentry 317 nop 318 319 out_mmu_3: 320 ori $26, $0, 0x3 321 mtc2 $26, $1 # CP2_MODE <= 0x3 322 323 out_kentry: 301 lw $26, (UZ_MODE*4)($27) 302 mtc2 $26, $1 # restore CP2_MODE from uzone 303 324 304 nop 325 305 eret 326 306 327 .end ke ntry307 .end kernel_enter 328 308 .set reorder 329 309 .set at 330 310 331 .ent kentry_load332 kentry_load:333 # theses nops are required to load the eret instruction334 # while we are in virtual mode (processor pipeline) ?335 mtc2 $26, $1 # set MMU MODE336 nop337 nop338 eret339 .end kentry_load340 341 311 #------------------------------------------------------------------------------- 342 312 -
trunk/hal/tsar_mips32/core/hal_kentry.h
r121 r279 24 24 #define _HAL_KENTRY_H_ 25 25 26 /***************************************************************************************27 * This file ... TODO28 **************************************************************************************/29 30 #define KSP 031 #define AT 132 #define V0 233 #define V1 334 #define A0 435 #define A1 536 #define A2 637 #define A3 738 #define T0 839 #define T1 940 #define T2 1041 #define T3 1142 #define T4 1243 #define T5 1344 #define T6 1445 #define T7 1546 #define T8 1647 #define T9 1748 #define S0 1849 #define S1 1950 #define S2 2051 #define S3 2152 #define S4 2253 #define S5 2354 #define S6 2455 #define S7 2556 #define S8 2657 #define GP 2758 #define RA 2859 #define EPC 2960 #define CR 3061 #define SP 3162 #define SR 3263 #define LO 3364 #define HI 3465 #define TLS_K1 3566 #define DP_EXT 36 // DATA PADDR EXTENSION67 #define MMU_MD 37 // MMU MODE68 #define REGS_NR 3869 26 70 27 #define CPU_IN_KERNEL 1 -
trunk/hal/tsar_mips32/core/hal_ppm.c
r107 r279 39 39 // - the 64 bits XPTR value is identical to the 64 bits PADDR value. 40 40 // The pages_tbl[] is mapped in first free page after kernel code. 41 // There is no other reserved zones than the zone occupied by the kernel code.42 41 ////////////////////////////////////////////////////////////////////////////////////////// 43 44 42 45 43 /////////////////////////////////////////// … … 52 50 uint32_t pages_tbl_offset = info->pages_offset; 53 51 uint32_t rsvd_nr = info->rsvd_nr; 54 55 // check no reserved zones other than kernel code for TSAR56 assert( (rsvd_nr == 0 ) , __FUNCTION__ , "NO reserved zones for TSAR\n" );57 52 58 53 // get pointer on local Physical Page Manager -
trunk/hal/tsar_mips32/core/hal_remote.c
r204 r279 34 34 uint32_t cxy = (uint32_t)GET_CXY( xp ); 35 35 36 hal_disable_irq( &save_sr ); 37 38 asm volatile( 39 ".set noreorder \n" 40 "mfc2 $15, $24 \n" /* $15 <= PADDR_EXT */ 41 "mtc2 %2, $24 \n" /* PADDR_EXT <= cxy */ 42 "sb %0, 0(%1) \n" /* *paddr <= value */ 43 "mtc2 $15, $24 \n" /* PADDR_EXT <= $15 */ 36 /* TODO improve all hal remote functions to include SR handling in assembly code */ 37 /* as it is done below for hal_remote_sb */ 38 39 asm volatile( 40 ".set noreorder \n" 41 "mfc0 $14, $12 \n" /* $14 <= CP0_SR */ 42 "srl $13, $14, 1 \n" 43 "sll $13, $13, 1 \n" /* $13 <= SR masked */ 44 "mtc0 $13, $12 \n" /* IRQ disabled */ 45 46 47 "mfc2 $15, $24 \n" /* $15 <= PADDR_EXT */ 48 "mtc2 %2, $24 \n" /* PADDR_EXT <= cxy */ 49 "sb %0, 0(%1) \n" /* *paddr <= value */ 50 "mtc2 $15, $24 \n" /* PADDR_EXT <= $15 */ 51 52 "mtc0 $14, $12 \n" /* SR restored */ 53 44 54 "sync \n" 45 55 ".set reorder \n" 46 : : "r" (data), "r" (ptr), "r" (cxy) : "$15" ); 47 48 hal_restore_irq( save_sr ); 49 56 : : "r" (data), "r" (ptr), "r" (cxy) : "$13", "$14", "$15" ); 50 57 } 51 58 -
trunk/hal/tsar_mips32/core/hal_special.c
r124 r279 32 32 struct thread_s; 33 33 34 ///////////////////////////////// 35 void hal_set_ebase( reg_t base ) 36 { 37 asm volatile ("mtc0 %0, $15, 1" : : "r" (base)); 38 } 34 39 35 40 ////////////////////////// … … 48 53 cycle_t count; 49 54 50 asm volatile ("mfc0 %0, $9 55 asm volatile ("mfc0 %0, $9" : "=&r" (count)); 51 56 52 57 return count; 58 } 59 60 ///////////////////////// 61 inline reg_t hal_get_sr() 62 { 63 register uint32_t sr; 64 65 asm volatile ("mfc0 %0, $12" : "=&r" (sr)); 66 67 return sr; 53 68 } 54 69 … … 90 105 void * thread_ptr; 91 106 92 asm volatile 93 ( "mfc0 %0, $4, 2 \n" 94 : "=&r" (thread_ptr) ); 107 asm volatile ("mfc0 %0, $4, 2" : "=&r" (thread_ptr)); 95 108 96 109 return thread_ptr; … … 100 113 void hal_set_current_thread( struct thread_s * thread ) 101 114 { 102 asm volatile 103 ( "mtc0 %0, $4, 2 \n" 104 : : "r" (thread) ); 115 asm volatile ("mtc0 %0, $4, 2" : : "r" (thread)); 105 116 } 106 117 … … 135 146 register uint32_t sp; 136 147 137 asm volatile 138 ( "or %0, $0, $29 \n" 139 : "=&r" (sp) ); 148 asm volatile ("or %0, $0, $29" : "=&r" (sp)); 140 149 141 150 return sp; -
trunk/hal/tsar_mips32/drivers/soclib_bdv.c
r265 r279 58 58 void __attribute__ ((noinline)) soclib_bdv_cmd( xptr_t th_xp ) 59 59 { 60 uint32_t cmd_type; 61 uint32_t lba; // command argument62 uint32_t count; // command argument63 xptr_t buf_xp; // command argument64 xptr_t dev_xp; // command argument60 uint32_t cmd_type; // IOC_READ / IOC_WRITE / IOC_SYNC_READ 61 uint32_t lba; 62 uint32_t count; 63 xptr_t buf_xp; 64 xptr_t ioc_xp; 65 65 66 66 // get client thread cluster and local pointer … … 69 69 70 70 // get command arguments and extended pointer on IOC device 71 cmd_type = hal_remote_lw ( XPTR( th_cxy , &th_ptr-> command.ioc.type ) );72 lba = hal_remote_lw ( XPTR( th_cxy , &th_ptr-> command.ioc.lba ) );73 count = hal_remote_lw ( XPTR( th_cxy , &th_ptr-> command.ioc.count ) );74 buf_xp = (xptr_t)hal_remote_lwd( XPTR( th_cxy , &th_ptr-> command.ioc.buf_xp ) );75 dev_xp = (xptr_t)hal_remote_lwd( XPTR( th_cxy , &th_ptr->command.ioc.dev_xp ) );71 cmd_type = hal_remote_lw ( XPTR( th_cxy , &th_ptr->ioc_cmd.type ) ); 72 lba = hal_remote_lw ( XPTR( th_cxy , &th_ptr->ioc_cmd.lba ) ); 73 count = hal_remote_lw ( XPTR( th_cxy , &th_ptr->ioc_cmd.count ) ); 74 buf_xp = (xptr_t)hal_remote_lwd( XPTR( th_cxy , &th_ptr->ioc_cmd.buf_xp ) ); 75 ioc_xp = (xptr_t)hal_remote_lwd( XPTR( th_cxy , &th_ptr->ioc_cmd.dev_xp ) ); 76 76 77 77 // get IOC device cluster and local pointer 78 cxy_t dev_cxy = GET_CXY( dev_xp );79 chdev_t * dev_ptr = (chdev_t *)GET_PTR( dev_xp );78 cxy_t ioc_cxy = GET_CXY( ioc_xp ); 79 chdev_t * ioc_ptr = (chdev_t *)GET_PTR( ioc_xp ); 80 80 81 81 // get extended pointer on SOCLIB-BDV peripheral 82 xptr_t bdv_xp = hal_remote_lw( XPTR( dev_cxy , &dev_ptr->base ) );82 xptr_t bdv_xp = hal_remote_lw( XPTR( ioc_cxy , &ioc_ptr->base ) ); 83 83 84 84 // get SOCLIB_BDV device cluster and local pointer … … 114 114 if( status == BDV_READ_SUCCESS ) // successfully completed 115 115 { 116 hal_remote_sw( XPTR( th_cxy , &th_ptr-> command.ioc.error ) , 0 );116 hal_remote_sw( XPTR( th_cxy , &th_ptr->ioc_cmd.error ) , 0 ); 117 117 break; 118 118 } … … 123 123 else // error reported 124 124 { 125 hal_remote_sw( XPTR( th_cxy , &th_ptr-> command.ioc.error ) , 1 );125 hal_remote_sw( XPTR( th_cxy , &th_ptr->ioc_cmd.error ) , 1 ); 126 126 break; 127 127 } … … 161 161 if((status != BDV_READ_SUCCESS) && (status != BDV_WRITE_SUCCESS)) 162 162 { 163 hal_remote_sw( XPTR( client_cxy , &client_ptr-> command.ioc.error ) , 1 );163 hal_remote_sw( XPTR( client_cxy , &client_ptr->ioc_cmd.error ) , 1 ); 164 164 } 165 165 else 166 166 { 167 hal_remote_sw( XPTR( client_cxy , &client_ptr-> command.ioc.error ) , 0 );167 hal_remote_sw( XPTR( client_cxy , &client_ptr->ioc_cmd.error ) , 0 ); 168 168 } 169 169 -
trunk/hal/tsar_mips32/drivers/soclib_dma.c
r261 r279 57 57 58 58 // get command arguments and extended pointer on DMA device 59 dev_xp = (xptr_t)hal_remote_lwd( XPTR( thread_cxy , &thread_ptr-> command.dma.dev_xp ) );60 dst_xp = (xptr_t)hal_remote_lwd( XPTR( thread_cxy , &thread_ptr-> command.dma.dst_xp ) );61 src_xp = (xptr_t)hal_remote_lwd( XPTR( thread_cxy , &thread_ptr-> command.dma.src_xp ) );62 size = hal_remote_lw ( XPTR( thread_cxy , &thread_ptr-> command.dma.size ) );59 dev_xp = (xptr_t)hal_remote_lwd( XPTR( thread_cxy , &thread_ptr->dma_cmd.dev_xp ) ); 60 dst_xp = (xptr_t)hal_remote_lwd( XPTR( thread_cxy , &thread_ptr->dma_cmd.dst_xp ) ); 61 src_xp = (xptr_t)hal_remote_lwd( XPTR( thread_cxy , &thread_ptr->dma_cmd.src_xp ) ); 62 size = hal_remote_lw ( XPTR( thread_cxy , &thread_ptr->dma_cmd.size ) ); 63 63 64 64 // get DMA device cluster and local pointer … … 124 124 // set operation status in command 125 125 error_t error = ( status != DMA_SUCCESS ); 126 hal_remote_sw( XPTR( client_cxy , &client_ptr-> command.dma.error ) , error );126 hal_remote_sw( XPTR( client_cxy , &client_ptr->dma_cmd.error ) , error ); 127 127 128 128 // unblock server thread -
trunk/hal/tsar_mips32/drivers/soclib_hba.c
r211 r279 107 107 108 108 // get command arguments and extended pointer on IOC device 109 cmd_type = hal_remote_lw ( XPTR( th_cxy , &th_ptr-> command.ioc.type ) );110 lba = hal_remote_lw ( XPTR( th_cxy , &th_ptr-> command.ioc.lba ) );111 count = hal_remote_lw ( XPTR( th_cxy , &th_ptr-> command.ioc.count ) );112 buf_xp = (xptr_t)hal_remote_lwd( XPTR( th_cxy , &th_ptr-> command.ioc.buf_xp ) );113 dev_xp = (xptr_t)hal_remote_lwd( XPTR( th_cxy , &th_ptr-> command.ioc.dev_xp ) );109 cmd_type = hal_remote_lw ( XPTR( th_cxy , &th_ptr->ioc_cmd.type ) ); 110 lba = hal_remote_lw ( XPTR( th_cxy , &th_ptr->ioc_cmd.lba ) ); 111 count = hal_remote_lw ( XPTR( th_cxy , &th_ptr->ioc_cmd.count ) ); 112 buf_xp = (xptr_t)hal_remote_lwd( XPTR( th_cxy , &th_ptr->ioc_cmd.buf_xp ) ); 113 dev_xp = (xptr_t)hal_remote_lwd( XPTR( th_cxy , &th_ptr->ioc_cmd.dev_xp ) ); 114 114 115 115 // get IOC device cluster and local pointer … … 225 225 if( error && (fault_id == cmd_id) ) 226 226 { 227 hal_remote_sw( XPTR( th_cxy , &th_ptr-> command.ioc.error ) , 1 );227 hal_remote_sw( XPTR( th_cxy , &th_ptr->ioc_cmd.error ) , 1 ); 228 228 } 229 229 else 230 230 { 231 hal_remote_sw( XPTR( th_cxy , &th_ptr-> command.ioc.error ) , 0 );231 hal_remote_sw( XPTR( th_cxy , &th_ptr->ioc_cmd.error ) , 0 ); 232 232 } 233 233 … … 281 281 if( error && (iter == fault_id ) ) 282 282 { 283 hal_remote_sw( XPTR( client_cxy , &client_ptr-> command.ioc.error ) , 1 );283 hal_remote_sw( XPTR( client_cxy , &client_ptr->ioc_cmd.error ) , 1 ); 284 284 } 285 285 else 286 286 { 287 hal_remote_sw( XPTR( client_cxy , &client_ptr-> command.ioc.error ) , 0 );287 hal_remote_sw( XPTR( client_cxy , &client_ptr->ioc_cmd.error ) , 0 ); 288 288 } 289 289 -
trunk/hal/tsar_mips32/drivers/soclib_mmc.c
r257 r279 1 1 /* 2 * soclib_mmc.c - soclib simple block devicedriver implementation.2 * soclib_mmc.c - soclib L2 cache controller driver implementation. 3 3 * 4 4 * Author Alain Greiner (2016) … … 62 62 63 63 // get command type and extended pointer on MMC device 64 type = hal_remote_lw ( XPTR( th_cxy , &th_ptr-> command.mmc.type ) );65 dev_xp = (xptr_t)hal_remote_lwd( XPTR( th_cxy , &th_ptr-> command.mmc.dev_xp ) );64 type = hal_remote_lw ( XPTR( th_cxy , &th_ptr->mmc_cmd.type ) ); 65 dev_xp = (xptr_t)hal_remote_lwd( XPTR( th_cxy , &th_ptr->mmc_cmd.dev_xp ) ); 66 66 67 67 // get MMC device cluster and local pointer … … 79 79 { 80 80 // get buffer paddr 81 buf_paddr = hal_remote_lwd( XPTR( th_cxy , &th_ptr-> command.mmc.buf_paddr ) );81 buf_paddr = hal_remote_lwd( XPTR( th_cxy , &th_ptr->mmc_cmd.buf_paddr ) ); 82 82 83 83 // split buffer paddr in two 32 bits words … … 86 86 87 87 // get buffer size 88 buf_size = hal_remote_lw( XPTR( th_cxy , &th_ptr-> command.mmc.buf_size ) );88 buf_size = hal_remote_lw( XPTR( th_cxy , &th_ptr->mmc_cmd.buf_size ) ); 89 89 90 90 // get command type … … 102 102 { 103 103 // get src/dst buffer local pointer and register index 104 reg_ptr = (uint32_t *)hal_remote_lpt( XPTR( th_cxy , &th_ptr-> command.mmc.reg_ptr ) );105 reg_index = hal_remote_lw( XPTR( th_cxy , &th_ptr-> command.mmc.reg_index ) );104 reg_ptr = (uint32_t *)hal_remote_lpt( XPTR( th_cxy , &th_ptr->mmc_cmd.reg_ptr ) ); 105 reg_index = hal_remote_lw( XPTR( th_cxy , &th_ptr->mmc_cmd.reg_index ) ); 106 106 107 107 // move register to/from local buffer -
trunk/hal/tsar_mips32/drivers/soclib_nic.c
r259 r279 107 107 108 108 // get command arguments 109 cmd = thread_ptr-> command.nic.cmd;110 buffer = thread_ptr-> command.nic.buffer;111 length = thread_ptr-> command.nic.length;112 dev_xp = thread_ptr-> command.nic.dev_xp;109 cmd = thread_ptr->nic_cmd.cmd; 110 buffer = thread_ptr->nic_cmd.buffer; 111 length = thread_ptr->nic_cmd.length; 112 dev_xp = thread_ptr->nic_cmd.dev_xp; 113 113 114 114 // get local pointer for device … … 212 212 { 213 213 // return chbuf writable 214 thread_ptr-> command.nic.status = true;214 thread_ptr->nic_cmd.status = true; 215 215 } 216 216 else // current container not writable … … 230 230 231 231 // return chbuf writable 232 thread_ptr-> command.nic.status = true;232 thread_ptr->nic_cmd.status = true; 233 233 } 234 234 else // next container full 235 235 { 236 236 // return chbuf non writable 237 thread_ptr-> command.nic.status = false;237 thread_ptr->nic_cmd.status = false; 238 238 } 239 239 } … … 256 256 { 257 257 // return chbuf readable 258 thread_ptr-> command.nic.status = true;258 thread_ptr->nic_cmd.status = true; 259 259 } 260 260 else // current container non readable … … 274 274 275 275 // return chbuf readable 276 thread_ptr-> command.nic.status = true;276 thread_ptr->nic_cmd.status = true; 277 277 } 278 278 else // next container empty 279 279 { 280 280 // return chbuf non readable 281 thread_ptr-> command.nic.status = false;281 thread_ptr->nic_cmd.status = false; 282 282 } 283 283 } -
trunk/hal/tsar_mips32/drivers/soclib_pic.c
r205 r279 83 83 } 84 84 85 86 //////////////////////////////////////////87 uint32_t soclib_pic_ack_timer( lid_t lid )88 {89 // get local XCU segment base90 uint32_t * base = soclib_pic_xcu_base();91 92 // read from register93 return base[(XCU_PTI_ACK << 5) | lid];94 95 } // end soclib_pic_ack_timer()96 97 85 /////////////////////////////////////////// 98 86 void soclib_pic_xcu_status( lid_t lid, … … 113 101 } 114 102 103 //////////////////////////////////////////////////// 104 inline uint32_t soclib_pic_xcu_ack( uint32_t * reg ) 105 { 106 return *reg; 107 } 108 115 109 ///////////////////////////// 116 110 void soclib_pic_irq_handler() … … 120 114 uint32_t pti_status; // PTI index + 1 / no pending PTI if 0 121 115 chdev_t * src_chdev; // pointer on source chdev descriptor 122 uint32_t index; // IRQ index 116 uint32_t index; // WTI / HWI / PTI index 117 uint32_t ack; // XCU acknowledge requires a read... 123 118 124 119 core_t * core = CURRENT_THREAD->core; … … 130 125 &pti_status ); 131 126 127 irq_dmsg("\n[INFO] %s : enter / WTI_STS = %x / HWI_STS = %x / WTI_STS = %x\n", 128 __FUNCTION__ , wti_status , hwi_status , pti_status ); 129 132 130 // analyse status and handle up to 3 pending IRQ (one WTI, one HWI, one PTI) 133 131 … … 140 138 assert( (index == core->lid) , __FUNCTION__ , "illegal IPI index" ); 141 139 142 // TODO acknowledge WTI [AG] 143 144 // TODO force scheduling [AG] 140 // acknowledge WTI 141 uint32_t * base = soclib_pic_xcu_base(); 142 ack = base[(XCU_WTI_REG << 5) | core->lid]; 143 144 // force scheduling 145 sched_yield(); 145 146 } 146 147 else // it is an external device … … 156 157 core->spurious_irqs ++; 157 158 158 // TODO disable this WTI in local XCU [AG] 159 // disable WTI in local XCU controller 160 uint32_t * base = soclib_pic_xcu_base(); 161 base[(XCU_MSK_WTI_DISABLE << 5) | core->lid] = 1 << core->lid; 159 162 } 160 163 else // call relevant ISR … … 183 186 core->spurious_irqs ++; 184 187 185 // TODO disable this HWI in local XCU [AG] 188 // disable HWI in local XCU controller 189 uint32_t * base = soclib_pic_xcu_base(); 190 base[(XCU_MSK_HWI_DISABLE << 5) | core->lid] = 1 << core->lid; 186 191 } 187 192 else // call relevant ISR … … 205 210 206 211 // acknowledge PTI 207 soclib_pic_ack_timer( index ); 208 209 // TODO execute all actions related to TICK event 212 uint32_t * base = soclib_pic_xcu_base(); 213 ack = base[(XCU_PTI_ACK << 5) | core->lid]; 214 215 // execute all actions related to TICK event 210 216 core_clock( core ); 211 217 } … … 431 437 else if( irq_type == SOCLIB_TYPE_WTI ) 432 438 { 433 // enable this WTI in localXCU controller439 // enable this WTI in remote XCU controller 434 440 hal_remote_sw( XPTR( src_chdev_cxy , 435 441 &seg_xcu_ptr[(XCU_MSK_WTI_ENABLE << 5) | lid] ) , (1 << irq_id) ); … … 464 470 else if( irq_type == SOCLIB_TYPE_WTI ) 465 471 { 466 // enable this WTI in localXCU controller472 // enable this WTI in remote XCU controller 467 473 hal_remote_sw( XPTR( src_chdev_cxy , 468 474 &seg_xcu_ptr[(XCU_MSK_WTI_DISABLE << 5) | lid] ) , (1 << irq_id) ); … … 486 492 base[(XCU_PTI_PER << 5) | lid] = period; 487 493 488 // enable thePTI in local XCU controller494 // enable PTI in local XCU controller 489 495 base[(XCU_MSK_PTI_ENABLE << 5) | lid] = 1 << lid; 496 } 497 498 //////////////////////////// 499 void soclib_pic_enable_ipi() 500 { 501 // calling core local index 502 lid_t lid = CURRENT_CORE->lid; 503 504 // get XCU segment base 505 uint32_t * base = soclib_pic_xcu_base(); 506 507 // enable WTI in local XCU controller 508 base[(XCU_MSK_WTI_ENABLE << 5) | lid] = 1 << lid; 490 509 } 491 510 -
trunk/hal/tsar_mips32/drivers/soclib_pic.h
r238 r279 228 228 229 229 /****************************************************************************************** 230 * This function activates the TICKtimer for the calling core.230 * This function activates the PTI timer for the calling core. 231 231 * The <period> argument define the number of cycles between IRQs. 232 232 ****************************************************************************************** … … 234 234 *****************************************************************************************/ 235 235 void soclib_pic_enable_timer( uint32_t period ); 236 237 /****************************************************************************************** 238 * This function activates the WTI[lid] in the local cluster, wherehe lid is the calling 239 * core local index. 240 *****************************************************************************************/ 241 void soclib_pic_enable_ipi(); 236 242 237 243 /****************************************************************************************** … … 279 285 280 286 /****************************************************************************************** 281 * This function acknowledge a PTI IRQ generated by the local XCU for a core282 * identified by the <lid> argument.283 *****************************************************************************************/284 uint32_t soclib_pic_ack_timer( lid_t lid );285 286 /******************************************************************************************287 287 * This function returns in the <hwi_status>, <wti_status>, <pti_status> buffers 288 288 * the local XCU status for a given core identidied by the <lid> argument. -
trunk/hal/tsar_mips32/drivers/soclib_tty.c
r77 r279 54 54 55 55 // get command type and extended pointer on TXT device 56 uint32_t type = hal_remote_lw ( XPTR( th_cxy , &th_ptr-> command.txt.type ) );57 xptr_t dev_xp = (xptr_t)hal_remote_lwd( XPTR( th_cxy , &th_ptr-> command.txt.dev_xp ) );56 uint32_t type = hal_remote_lw ( XPTR( th_cxy , &th_ptr->txt_cmd.type ) ); 57 xptr_t dev_xp = (xptr_t)hal_remote_lwd( XPTR( th_cxy , &th_ptr->txt_cmd.dev_xp ) ); 58 58 59 59 // get TXT device cluster and local pointer … … 103 103 104 104 // get source buffer extended pointer & bytes count 105 uint32_t count = hal_remote_lw ( XPTR( th_cxy , &th_ptr-> command.txt.count ) );106 xptr_t buf_xp = hal_remote_lwd( XPTR( th_cxy , &th_ptr-> command.txt.buf_xp ) );105 uint32_t count = hal_remote_lw ( XPTR( th_cxy , &th_ptr->txt_cmd.count ) ); 106 xptr_t buf_xp = hal_remote_lwd( XPTR( th_cxy , &th_ptr->txt_cmd.buf_xp ) ); 107 107 108 108 // loop on characters … … 127 127 } 128 128 } 129 } 129 } // end soclib_tty_cmd() 130 130 131 131 132 ///////////////////////////////////////////////////////////////// … … 148 149 149 150 // get command arguments 150 type = hal_remote_lw ( XPTR( client_cxy , &client_ptr-> command.txt.type ) );151 count = hal_remote_lw ( XPTR( client_cxy , &client_ptr-> command.txt.count ) );152 buf_xp = hal_remote_lwd( XPTR( client_cxy , &client_ptr-> command.txt.buf_xp ) );151 type = hal_remote_lw ( XPTR( client_cxy , &client_ptr->txt_cmd.type ) ); 152 count = hal_remote_lw ( XPTR( client_cxy , &client_ptr->txt_cmd.count ) ); 153 buf_xp = hal_remote_lwd( XPTR( client_cxy , &client_ptr->txt_cmd.buf_xp ) ); 153 154 154 155 // get SOCLIB_TTY peripheral cluster and local pointer … … 210 211 else // TTY_TX full => update command arguments and exit ISR for retry 211 212 { 212 hal_remote_sw ( XPTR( client_cxy , &client_ptr-> command.txt.count ), count-i );213 hal_remote_swd( XPTR( client_cxy , &client_ptr-> command.txt.buf_xp ), buf_xp+i );213 hal_remote_sw ( XPTR( client_cxy , &client_ptr->txt_cmd.count ), count-i ); 214 hal_remote_swd( XPTR( client_cxy , &client_ptr->txt_cmd.buf_xp ), buf_xp+i ); 214 215 return; 215 216 } … … 223 224 224 225 // set I/O operation status in command 225 hal_remote_sw( XPTR( client_cxy , &client_ptr-> command.txt.error ) , 0 );226 hal_remote_sw( XPTR( client_cxy , &client_ptr->txt_cmd.error ) , 0 ); 226 227 227 228 // unblock server thread … … 230 231 // unblock client thread 231 232 thread_unblock( client_xp , THREAD_BLOCKED_IO ); 232 } 233 233 234 } // end soclib_tty_isr() 235 -
trunk/hal/tsar_mips32/kernel.ld
r63 r279 5 5 6 6 /* Define the kernel code base address */ 7 kernel_base = 0x4000;8 7 9 /* 10 * Set the entry point of the boot-loader (e_entry field in the "boot.elf" 11 * file header) 12 */8 seg_kcode_base = 0x00004000; 9 seg_kgiet_base = 0x80000000; 10 11 /* Set the entry point (e_entry field in the "kernel.elf" file header) */ 13 12 14 13 ENTRY(kernel_init) 15 14 16 /* 17 * Describe how to group the sections 18 */ 15 /* Describe how to group the sections */ 16 19 17 SECTIONS 20 18 { 21 . = kernel_base;19 . = seg_kcode_base; 22 20 seg_kcode : 23 21 { … … 35 33 *(.data*) 36 34 } 35 36 . = seg_kgiet_base; 37 seg_kgiet : 38 { 39 *(.kgiet) 40 } 37 41 }
Note: See TracChangeset
for help on using the changeset viewer.