Changeset 629 for soft/giet_vm/giet_kernel
- Timestamp:
- Jul 18, 2015, 3:00:42 PM (9 years ago)
- Location:
- soft/giet_vm/giet_kernel
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
soft/giet_vm/giet_kernel/ctx_handler.c
r528 r629 39 39 " - CTX_RA = %x\n" 40 40 " - CTX_SP = %x\n" 41 " - CTX_ RUN= %x\n"41 " - CTX_NORUN = %x\n" 42 42 "########## %s\n", 43 43 x , y , p , ltid , … … 49 49 psched->context[ltid][CTX_RA_ID], 50 50 psched->context[ltid][CTX_SP_ID], 51 psched->context[ltid][CTX_ RUN_ID],51 psched->context[ltid][CTX_NORUN_ID], 52 52 string ); 53 53 } // _ctx_display() … … 79 79 next_task_id = tid % tasks; 80 80 // test if the task is runable 81 if ( psched->context[next_task_id][CTX_ RUN_ID])81 if ( psched->context[next_task_id][CTX_NORUN_ID] == 0 ) 82 82 { 83 83 found = 1; -
soft/giet_vm/giet_kernel/ctx_handler.h
r556 r629 14 14 // is launched by the scheduler when there is no other runable task. 15 15 ///////////////////////////////////////////////////////////////////////////////// 16 // A task context is an array of 64 words =256 bytes.16 // A task context is an array of 64 uint32 words => 256 bytes. 17 17 // It contains copies of processor registers (when the task is preempted) 18 // and some general informations associated to a task, such as the peripherals 19 // allocated to the task (private peripheral channel) 18 // and some general informations associated to a task, such as the private 19 // peripheral channels allocated to the task, the vspace index, the various 20 // task index (local / global / application), and the runnable status. 20 21 ///////////////////////////////////////////////////////////////////////////////// 21 22 // ctx[0] <- *** |ctx[8] <- $8 |ctx[16]<- $16 |ctx[24]<- $24 … … 30 31 // ctx[32]<- EPC |ctx[40]<- TTY |ctx[48]<- TRDID |ctx[56]<- *** 31 32 // ctx[33]<- CR |ctx[41]<- CMA_FB |ctx[49]<- GTID |ctx[57]<- *** 32 // ctx[34]<- SR |ctx[42]<- CMA_RX |ctx[50]<- RUN|ctx[58]<- ***33 // ctx[34]<- SR |ctx[42]<- CMA_RX |ctx[50]<- NORUN |ctx[58]<- *** 33 34 // ctx[35]<- BVAR |ctx[43]<- CMA_TX |ctx[51]<- COPROC |ctx[59]<- *** 34 35 // ctx[36]<- PTAB |ctx[44]<- NIC_RX |ctx[52]<- *** |ctx[60]<- *** … … 47 48 ///////////////////////////////////////////////////////////////////////////////// 48 49 49 #define CTX_SP_ID 29 // Stack Pointer50 #define CTX_RA_ID 31 // Return Address50 #define CTX_SP_ID 29 // Stack Pointer 51 #define CTX_RA_ID 31 // Return Address 51 52 52 #define CTX_EPC_ID 32 // Exception Program Counter (CP0)53 #define CTX_CR_ID 33 // Cause Register (CP0)54 #define CTX_SR_ID 34 // Status Register (CP0)55 #define CTX_BVAR_ID 35 // Bad Virtual Address Register (CP0)56 #define CTX_PTAB_ID 36 // Page Table Virtual address57 #define CTX_LTID_ID 37 // Local Task Index (in scheduler)58 #define CTX_VSID_ID 38 // Vspace Index59 #define CTX_PTPR_ID 39 // Page Table Pointer Register (PADDR>>13)53 #define CTX_EPC_ID 32 // Exception Program Counter (CP0) 54 #define CTX_CR_ID 33 // Cause Register (CP0) 55 #define CTX_SR_ID 34 // Status Register (CP0) 56 #define CTX_BVAR_ID 35 // Bad Virtual Address Register (CP0) 57 #define CTX_PTAB_ID 36 // Page Table Virtual address 58 #define CTX_LTID_ID 37 // Local Task Index (in scheduler) 59 #define CTX_VSID_ID 38 // Vspace Index 60 #define CTX_PTPR_ID 39 // Page Table Pointer Register (PADDR>>13) 60 61 61 #define CTX_TTY_ID 40 // private TTY channel index62 #define CTX_CMA_FB_ID 41 // private CMA channel index for FBF write63 #define CTX_CMA_RX_ID 42 // private CMA channel index for NIC_TX64 #define CTX_CMA_TX_ID 43 // private CMA channel index for NIC_RX65 #define CTX_NIC_RX_ID 44 // private NIC channel index RX transfer66 #define CTX_NIC_TX_ID 45 // private NIC channel index TX transfer67 #define CTX_TIM_ID 46 // ptivate TIM channel index68 #define CTX_HBA_ID 47 // private HBA channel index62 #define CTX_TTY_ID 40 // private TTY channel index 63 #define CTX_CMA_FB_ID 41 // private CMA channel index for FBF write 64 #define CTX_CMA_RX_ID 42 // private CMA channel index for NIC_TX 65 #define CTX_CMA_TX_ID 43 // private CMA channel index for NIC_RX 66 #define CTX_NIC_RX_ID 44 // private NIC channel index RX transfer 67 #define CTX_NIC_TX_ID 45 // private NIC channel index TX transfer 68 #define CTX_TIM_ID 46 // ptivate TIM channel index 69 #define CTX_HBA_ID 47 // private HBA channel index 69 70 70 #define CTX_TRDID_ID 48 // Thread Task Index in vspace71 #define CTX_GTID_ID 49 // Global Task Index in all system72 #define CTX_ RUN_ID 50 // Boolean: task runable73 #define CTX_COPROC_ID 51 // cluster_xy : coprocessor coordinates71 #define CTX_TRDID_ID 48 // Thread Task Index in vspace 72 #define CTX_GTID_ID 49 // Global Task Index in all system 73 #define CTX_NORUN_ID 50 // bit-vector : task runable if all zero 74 #define CTX_COPROC_ID 51 // cluster_xy : coprocessor coordinates 74 75 75 76 ///////////////////////////////////////////////////////////////////////////////// 77 // Definition of the NORUN bit-vector masks 78 ///////////////////////////////////////////////////////////////////////////////// 79 80 #define NORUN_MASK_TASK 0x00000001 // Task not active 81 #define NORUN_MASK_IOC 0x00000002 // Task blocked on IOC transfer 82 #define NORUN_MASK_COPROC 0x00000004 // Task blocked on COPROC transfer 76 83 77 84 ///////////////////////////////////////////////////////////////////////////////// -
soft/giet_vm/giet_kernel/exc_handler.c
r547 r629 85 85 86 86 // goes to sleeping state 87 _set_context_slot( CTX_RUN_ID, 0);87 _set_context_slot( CTX_NORUN_ID , 1 ); 88 88 89 // deschedule (suicide)90 unsigned int save_sr; // unused89 // deschedule 90 unsigned int save_sr; 91 91 _it_disable( &save_sr ); 92 92 _ctx_switch(); -
soft/giet_vm/giet_kernel/irq_handler.h
r547 r629 8 8 // They contain the code of used to handlle HWI, WTI, PTI interrupts. 9 9 /////////////////////////////////////////////////////////////////////////// 10 11 #include <giet_config.h> 10 12 11 13 #ifndef _IRQ_HANDLER_H -
soft/giet_vm/giet_kernel/kernel_init.c
r615 r629 113 113 unsigned int _tty0_boot_mode = 0; 114 114 115 // Kernel uses distributed locks to protect MMC116 __attribute__((section(".kdata")))117 unsigned int _mmc_boot_mode = 0;118 119 115 // Kernel uses sqt_lock to protect command allocator in HBA 120 116 __attribute__((section(".kdata"))) … … 131 127 // this variable is defined in tty0.c file 132 128 extern sqt_lock_t _tty0_sqt_lock; 129 130 // this variable is allocated in mmc_kernel.c 131 extern unsigned int _mmc_boot_mode; 133 132 134 133 //////////////////////////////////////////////////////////////////////////////// … … 167 166 #endif 168 167 ////// distributed lock for MMC 168 _mmc_boot_mode = 0; 169 169 _mmc_init_locks(); 170 170 … … 293 293 // compute ctx_epc 294 294 unsigned int* ptr = (unsigned int*)_get_task_slot(x,y,p,ltid,CTX_EPC_ID); 295 _set_task_slot( x,y,p,ltid,CTX_EPC_ID,*ptr);295 _set_task_slot( x , y , p , ltid , CTX_EPC_ID , *ptr ); 296 296 297 297 #if GIET_DEBUG_INIT -
soft/giet_vm/giet_kernel/sys_handler.c
r614 r629 81 81 extern unsigned int _tty_rx_buf[NB_TTY_CHANNELS]; 82 82 83 // allocated in kernel_init.c file 84 extern static_scheduler_t* _schedulers[X_SIZE][Y_SIZE][NB_PROCS_MAX]; 85 83 86 //////////////////////////////////////////////////////////////////////////// 84 87 // Channel allocators for peripherals … … 158 161 &_sys_tim_start, /* 0x15 */ 159 162 &_sys_tim_stop, /* 0x16 */ 160 &_sys_ ukn,/* 0x17 */161 &_sys_ ukn,/* 0x18 */163 &_sys_kill_application, /* 0x17 */ 164 &_sys_exec_application, /* 0x18 */ 162 165 &_sys_context_switch, /* 0x19 */ 163 166 &_sys_vseg_get_vbase, /* 0x1A */ … … 495 498 _it_disable( &save_sr ); 496 499 497 // reset runnable 498 _set_task_slot( x, y, p, ltid, CTX_RUN_ID, 0 ); 500 // set NORUN_MASK_COPROC bit 501 static_scheduler_t* psched = (static_scheduler_t*)_schedulers[x][y][p]; 502 unsigned int* ptr = &psched->context[ltid][CTX_NORUN_ID]; 503 _atomic_or( ptr , NORUN_MASK_COPROC ); 499 504 500 505 // start coprocessor … … 1785 1790 unsigned int y = cluster_xy & ((1<<Y_WIDTH)-1); 1786 1791 unsigned int x = cluster_xy >> Y_WIDTH; 1787 unsigned int lpid= gpid & ((1<<P_WIDTH)-1);1788 1789 unsigned int task_id= _get_context_slot(CTX_LTID_ID);1792 unsigned int p = gpid & ((1<<P_WIDTH)-1); 1793 1794 unsigned int ltid = _get_context_slot(CTX_LTID_ID); 1790 1795 1791 1796 // print exit message 1792 1797 _printf("\n[GIET] Exit task %d on processor[%d,%d,%d] at cycle %d" 1793 1798 "\n Cause : %s\n\n", 1794 task_id, x, y, lpid, date, string ); 1795 1796 // goes to sleeping state 1797 _set_context_slot(CTX_RUN_ID, 0); 1799 ltid, x, y, p, date, string ); 1800 1801 // set NORUN_MASK_TASK bit (non runnable state) 1802 static_scheduler_t* psched = (static_scheduler_t*)_schedulers[x][y][p]; 1803 unsigned int* ptr = &psched->context[ltid][CTX_NORUN_ID]; 1804 _atomic_or( ptr , NORUN_MASK_TASK ); 1798 1805 1799 1806 // deschedule … … 1803 1810 } 1804 1811 1812 /////////////////////////////////////// 1813 int _sys_kill_application( char* name ) 1814 { 1815 mapping_header_t * header = (mapping_header_t *)SEG_BOOT_MAPPING_BASE; 1816 mapping_vspace_t * vspace = _get_vspace_base(header); 1817 mapping_task_t * task = _get_task_base(header); 1818 1819 unsigned int vspace_id; 1820 unsigned int task_id; 1821 unsigned int y_size = header->y_size; 1822 1823 // scan vspaces 1824 for (vspace_id = 0; vspace_id < header->vspaces; vspace_id++) 1825 { 1826 if ( _strcmp( vspace[vspace_id].name, name ) == 0 ) 1827 { 1828 // scan tasks in vspace 1829 for (task_id = vspace[vspace_id].task_offset; 1830 task_id < (vspace[vspace_id].task_offset + vspace[vspace_id].tasks); 1831 task_id++) 1832 { 1833 unsigned int cid = task[task_id].clusterid; 1834 unsigned int x = cid / y_size; 1835 unsigned int y = cid % y_size; 1836 unsigned int p = task[task_id].proclocid; 1837 unsigned int ltid = task[task_id].ltid; 1838 1839 // set NORUN_MASK_TASK bit 1840 static_scheduler_t* psched = (static_scheduler_t*)_schedulers[x][y][p]; 1841 unsigned int* ptr = &psched->context[ltid][CTX_NORUN_ID]; 1842 _atomic_or( ptr , NORUN_MASK_TASK ); 1843 } 1844 return 0; 1845 } 1846 } 1847 return -1; // not found 1848 } 1849 1850 /////////////////////////////////////// 1851 int _sys_exec_application( char* name ) 1852 { 1853 mapping_header_t * header = (mapping_header_t *)SEG_BOOT_MAPPING_BASE; 1854 mapping_vspace_t * vspace = _get_vspace_base(header); 1855 mapping_task_t * task = _get_task_base(header); 1856 mapping_vseg_t * vseg = _get_vseg_base(header); 1857 1858 unsigned int vspace_id; 1859 unsigned int task_id; 1860 unsigned int vseg_id; 1861 1862 unsigned int y_size = header->y_size; 1863 1864 // scan vspaces 1865 for (vspace_id = 0 ; vspace_id < header->vspaces ; vspace_id++) 1866 { 1867 if ( _strcmp( vspace[vspace_id].name, name ) == 0 ) 1868 { 1869 // scan tasks in vspace 1870 for (task_id = vspace[vspace_id].task_offset; 1871 task_id < (vspace[vspace_id].task_offset + vspace[vspace_id].tasks); 1872 task_id++) 1873 { 1874 unsigned int cid = task[task_id].clusterid; 1875 unsigned int x = cid / y_size; 1876 unsigned int y = cid % y_size; 1877 unsigned int p = task[task_id].proclocid; 1878 unsigned int ltid = task[task_id].ltid; 1879 1880 // compute stack pointer value (sp_value) 1881 vseg_id = task[task_id].stack_vseg_id; 1882 unsigned int sp_value = vseg[vseg_id].vbase + vseg[vseg_id].length; 1883 1884 // compute task entry point value (epc_value) 1885 vseg_id = vspace[vspace_id].start_vseg_id; 1886 unsigned int* vaddr = (unsigned int*)( vseg[vseg_id].vbase + 1887 ((task[task_id].startid)<<2) ); 1888 unsigned int epc_value = *vaddr; 1889 1890 // compute reurn address value (ra_value) 1891 unsigned int ra_value = (unsigned int)(&_ctx_eret); 1892 1893 // get scheduler pointer 1894 static_scheduler_t* psched = (static_scheduler_t*)_schedulers[x][y][p]; 1895 1896 // initialise task context: RA / SR / EPC / SP / NORUN slots 1897 psched->context[ltid][CTX_RA_ID] = ra_value; 1898 psched->context[ltid][CTX_SR_ID] = GIET_SR_INIT_VALUE; 1899 psched->context[ltid][CTX_SP_ID] = sp_value; 1900 psched->context[ltid][CTX_EPC_ID] = epc_value; 1901 psched->context[ltid][CTX_NORUN_ID] = 0; 1902 } 1903 return 0; 1904 } 1905 } 1906 return -1; // not found 1907 } 1908 1805 1909 ///////////////////////// 1806 1910 int _sys_context_switch() -
soft/giet_vm/giet_kernel/sys_handler.h
r614 r629 204 204 int _sys_task_exit( char* string ); 205 205 206 int _sys_kill_application( char* name ); 207 208 int _sys_exec_application( char* name ); 209 206 210 int _sys_context_switch(); 207 211
Note: See TracChangeset
for help on using the changeset viewer.