Changeset 625 for trunk/hal/tsar_mips32/core/hal_special.c
- Timestamp:
- Apr 10, 2019, 10:09:39 AM (5 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/hal/tsar_mips32/core/hal_special.c
r624 r625 40 40 extern cxy_t local_cxy; 41 41 extern void hal_kentry_enter( void ); 42 43 //////////////////////////////////////////////////////////////////////////////// 44 // For the TSAR architecture, this function registers the address of the 45 // hal_kentry_enter() function in the MIPS32 cp0_ebase register. 46 //////////////////////////////////////////////////////////////////////////////// 47 void hal_set_kentry( void ) 48 { 49 uint32_t kentry = (uint32_t)(&hal_kentry_enter); 50 51 asm volatile("mtc0 %0, $15, 1" : : "r" (kentry) ); 52 } 42 53 43 54 ///////////////////////////////////////////////////////////////////////////////// … … 48 59 void hal_mmu_init( gpt_t * gpt ) 49 60 { 50 51 // set PT1 base address in mmu_ptpr register 61 // set PT1 base address in cp2_ptpr register 52 62 uint32_t ptpr = (((uint32_t)gpt->ptr) >> 13) | (local_cxy << 19); 53 63 asm volatile ( "mtc2 %0, $0 \n" : : "r" (ptpr) ); 54 64 55 // set ITLB | ICACHE | DCACHE bits in mmu_mode register65 // set ITLB | ICACHE | DCACHE bits in cp2_mode register 56 66 asm volatile ( "ori $26, $0, 0xB \n" 57 67 "mtc2 $26, $1 \n" ); … … 59 69 60 70 //////////////////////////////////////////////////////////////////////////////// 61 // For the TSAR architecture, this function registers the address of the 62 // hal_kentry_enter() function in the MIPS32 cp0_ebase register. 63 //////////////////////////////////////////////////////////////////////////////// 64 void hal_set_kentry( void ) 65 { 66 uint32_t kentry = (uint32_t)(&hal_kentry_enter); 67 68 asm volatile("mtc0 %0, $15, 1" : : "r" (kentry) ); 69 } 70 71 //////////////////////////////// 71 // For the TSAR architecture, this function returns the current value 72 // of the 32 bits c0_sr register 73 //////////////////////////////////////////////////////////////////////////////// 74 inline reg_t hal_get_sr( void ) 75 { 76 reg_t sr; 77 78 asm volatile ("mfc0 %0, $12" : "=&r" (sr)); 79 80 return sr; 81 } 82 83 //////////////////////////////////////////////////////////////////////////////// 84 // For the TSAR architecture, this function returns the 10 LSB bits 85 // of the 32 bits c0_ebase register : Y (4 bits) | Y (4 bits) | LID (2 bits) 86 //////////////////////////////////////////////////////////////////////////////// 72 87 inline gid_t hal_get_gid( void ) 73 88 { … … 79 94 } 80 95 81 /////////////////////////////////// 96 //////////////////////////////////////////////////////////////////////////////// 97 // For the TSAR architecture, this function returns the current value 98 // of the 32 bits c0_count cycle counter. 99 //////////////////////////////////////////////////////////////////////////////// 82 100 inline reg_t hal_time_stamp( void ) 83 101 { … … 87 105 88 106 return count; 89 }90 91 ///////////////////////////////92 inline reg_t hal_get_sr( void )93 {94 reg_t sr;95 96 asm volatile ("mfc0 %0, $12" : "=&r" (sr));97 98 return sr;99 107 } 100 108 … … 131 139 } 132 140 133 /////////////////////////////////////////////////////// 141 //////////////////////////////////////////////////////////////////////////////// 142 // For the TSAR architecture, this function returns the current value 143 // of the 32 bits c0_th register. 144 //////////////////////////////////////////////////////////////////////////////// 134 145 inline struct thread_s * hal_get_current_thread( void ) 135 146 { … … 141 152 } 142 153 143 /////////////////////////////////////////////////////// 154 //////////////////////////////////////////////////////////////////////////////// 155 // For the TSAR architecture, this function set a new value 156 // to the 32 bits c0_th register. 157 //////////////////////////////////////////////////////////////////////////////// 144 158 void hal_set_current_thread( struct thread_s * thread ) 145 159 { … … 182 196 } 183 197 184 /////////////////////////// 185 uint32_t hal_get_sp( void ) 198 //////////////////////////////////////////////////////////////////////////////// 199 // For the TSAR architecture, this function returns the current value 200 // of the 32 bits sp_29 register. 201 //////////////////////////////////////////////////////////////////////////////// 202 reg_t hal_get_sp( void ) 186 203 { 187 204 register uint32_t sp; … … 190 207 191 208 return sp; 192 }193 194 /////////////////////////////////////195 uint32_t hal_set_sp( void * new_val )196 {197 register uint32_t sp;198 199 asm volatile200 ( "or %0, $0, $29 \n"201 "or $29, $0, %1 \n"202 : "=&r" (sp) : "r" (new_val) );203 204 return sp;205 }206 207 ///////////////////////////208 uint32_t hal_get_ra( void )209 {210 register uint32_t ra;211 212 asm volatile ("or %0, $0, $31" : "=&r" (ra));213 214 return ra;215 209 } 216 210
Note: See TracChangeset
for help on using the changeset viewer.