Changeset 629 for soft/giet_vm/giet_kernel/sys_handler.c
- Timestamp:
- Jul 18, 2015, 3:00:42 PM (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
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()
Note: See TracChangeset
for help on using the changeset viewer.