Changes between Version 16 and Version 17 of kernel_syscalls
- Timestamp:
- Nov 11, 2014, 3:01:05 PM (11 years ago)
Legend:
- Unmodified
- Added
- Removed
- Modified
-
kernel_syscalls
v16 v17 8 8 9 9 10 == __TTY related syscall handlers__==10 == TTY related syscall handlers == 11 11 12 === int '''_sys_tty_alloc'''() ===12 === 1) int '''_sys_tty_alloc'''() === 13 13 This function allocates a private TTY terminal to the calling task, and registers the TTY index in the task context. 14 14 Returns 0 if success, returns -1 if not enough terminals. 15 15 16 === int '''_sys_tty_write'''( const char* buffer, unsigned int length, unsigned int channel ) ===16 === 2) int '''_sys_tty_write'''( const char* buffer, unsigned int length, unsigned int channel ) === 17 17 This non-blocking function writes a character string from a fixed-length buffer to a TTY terminal identified by the channel argument. If channel argument is 0xFFFFFFFF, the TTY index is found in the task context. 18 18 It is non blocking: it tests the TTY_STATUS register, and stops the transfer as soon as the TTY_STATUS[WRITE] bit is set. Returns -1 if no TTT terminal allocated to the calling task. Returns the number of characters that have been written if a terminal is allocated. 19 19 20 === int '''_sys_tty_read'''( char* buffer, unsigned int length, unsigned int channel ) ===20 === 3) int '''_sys_tty_read'''( char* buffer, unsigned int length, unsigned int channel ) === 21 21 This non-blocking function fetches one character from the terminal identified by the ''channel'' argument. If the ''channel'' argument is 0xFFFFFFFF, the TTY index is obtained from the current task context. 22 22 It uses the TTY_GET_IRQ[tty_id] interrupt and the buffer must have been filled by the TTY_ISR. … … 24 24 Returns -1 if no TTY terminal allocated to the calling task. Returns the number of characters that have been read if a terminal is allocated (can be 0 or 1). 25 25 26 === int '''_sys_tty_get_lock'''( unsigned int channel, unsigned int* save_sr_ptr ) ===26 === 4) int '''_sys_tty_get_lock'''( unsigned int channel, unsigned int* save_sr_ptr ) === 27 27 This blocking function try to take the lock protecting exclusive access to TTY terminal identified by the "channel" argument. It enters a critical section before taking the lock, and save the SR value at address defined by the ''save_sr_ptr'' argument. Returns -1 if no TTY terminal allocated to the calling task. If a TTY terminal is allocated, it returns only when the lock has been successfully taken. 28 28 29 === int '''_sys_tty_release_lock'''( unsigned int channel, unsigned int* save_sr_ptr ) ===29 === 5) int '''_sys_tty_release_lock'''( unsigned int channel, unsigned int* save_sr_ptr ) === 30 30 This function releases the lock protecting exclusive access to TTY terminal identified by the ''channel'' argument. 31 31 It exit the critical section after lock release, and restore SR value from address defined by the ''save_sr_ptr'' argument. Returns -1 if no TTY terminal allocated to the calling task. … … 33 33 34 34 35 == __TIM retated syscall handlers__==35 == TIM retated syscall handlers == 36 36 37 === int '''_sys_tim_alloc'''() ===37 === 1) int '''_sys_tim_alloc'''() === 38 38 This function allocates a private timer to the calling task, and register the timer index in the task context. 39 39 Return -1 if no timer available. 40 40 41 === int '''_sys_tim_start'''( unsigned int period ) ===41 === 2) int '''_sys_tim_start'''( unsigned int period ) === 42 42 This function starts the user timer channel allocated to the calling task. 43 43 Returns 0 if success. Returns -1 if no allocated timer. 44 44 45 === int '''_sys_tim_stop'''() ===45 === 3) int '''_sys_tim_stop'''() === 46 46 This function stops the user timer channel allocated to the calling task. 47 47 Returns 0 if success. Returns -1 if no allocated timer. … … 49 49 50 50 51 == __NIC related syscall handlers__==51 == NIC related syscall handlers == 52 52 53 These '4 functions can be used for both a NIC_RX or NIC_TX channel, depending on the '''is_rx''' argument.53 These 4 functions can be used for both a NIC_RX or NIC_TX channel, depending on the '''is_rx''' argument. 54 54 55 === int '''_sys_nic_alloc'''( unsigned int is_rx) ===55 === 1) int '''_sys_nic_alloc'''( unsigned int is_rx, unsigned int mac4, unsigned int mac2 ) === 56 56 This function allocates a private NIC_RX or NIC_TX channel, the associated chbuf, and a private CMA channel to the calling task, and register these channel indexes in the task context. 57 * '''is_isr''' : boolean (RX transfer if non zero) 57 58 Returns 0 if success. Return -1 if no NIC channel available, or if no CMA channel available. 58 59 59 === int '''_sys_nic_start'''( unsigned int is_rx ) === 60 This function starts the NIC and the CMA channels allocated to the calling task. 60 === 2) int '''_sys_nic_start'''( unsigned int is_rx ) === 61 This function starts the NIC channel allocated to the calling task, and starts the CMA transfer between the internal NIC chbuf and the kernel chbuf allocated to the calling task. 62 * '''is_isr''' : boolean (RX transfer if non zero) 63 * '''mac4''' : 32 LSB bits of the MAC address 64 * '''mac4''' : 16 MSB bits of the MAC address 61 65 Returns 0 if success. Returns -1 if no NIC channel or no CMA channel allocated to the calling task. 62 66 63 === int '''_sys_nic_move'''( unsigned int is_rx, void* buffer ) ===67 === 3) int '''_sys_nic_move'''( unsigned int is_rx, void* buffer ) === 64 68 This function moves one 4kbytes container between the kernel chbuf allocated to the calling task, and an user buffer. 65 * '''is_ rx''' defines the transfer direction (user -> kernel for TX / kernel -> user for RX)69 * '''is_isr''' : boolean (RX transfer if non zero) 66 70 * '''buffer''' is the user buffer virtual base address. 67 71 It is blocking if the kernel chbuf is empty (for an RX transfer) or full (for a TX transfer). The bloking situation … … 69 73 Returns 0 if success, returns -1 if the user buffer address is illegal, or if there is no NIC_RX channel allocated to the calling task, or if the timeout is elapsed. 70 74 71 === int '''_sys_nic_stop'''( unsigned int is_rx ) ===75 === 4) int '''_sys_nic_stop'''( unsigned int is_rx ) === 72 76 This function stops the NIC and the CMA channels allocated to the calling task. 77 * '''is_isr''' : boolean (RX transfer if non zero) 73 78 Returns 0 if success. Returns -1 if no NIC channel or no CMA channel allocated to the calling task. 74 79 75 80 76 81 77 == __ FBF related syscall handlers__==82 == FBF related syscall handlers == 78 83 79 84 There exist two methods to access the ''vci_framebuffer'': … … 81 86 * The _sys_fbf_cma_alloc(), _sys_fbf_cma_start(), _sys_fbf_cma_display(), and _sys_fbf_cma_stop() functions use the ''vci_chbuf_dma'' component to transfer a stream of images from an user space chained buffer (two buffers) to the frame buffer. 82 87 83 === int '''_sys_fbf_sync_write'''( unsigned int offset, void* buffer, unsigned int length ) === 84 This function transfer data from an user buffer to the frame_buffer device using a memcpy. 85 * '''offset''' : offset (in bytes) in the frame buffer. 86 * '''buffer''' : base address of the memory buffer. 87 * '''length''' : number of bytes to be transfered. 88 89 === int '''_sys_fbf_sync_read'''( unsigned int offset, void* buffer, unsigned int length ) === 90 This function transfer data from the frame_buffer device to anuser buffer using a memcpy. 91 * '''offset''' : offset (in bytes) in the frame buffer. 92 * '''buffer''' : base address of the memory buffer. 93 * '''length''' : number of bytes to be transfered. 94 95 === int '''_sys_fbf_cma_alloc'''() === 88 === 1) int '''_sys_fbf_cma_alloc'''() === 96 89 This function allocates a private CMA channel to the calling task, and register the channel index in the task context. 97 90 Return -1 if no CMA channel available. 98 91 99 === int '''_sys_fbf_cma_start'''( void* vbase0, void* vbase1, unsigned int length ) ===92 === 2) int '''_sys_fbf_cma_start'''( void* vbase0, void* vbase1, unsigned int length ) === 100 93 This function initializes the CMA channel to start the transfer of a stream of images from an user chbuf (two buffers) to the frame buffer chbuf (one single buffer). The user buffers must be aligned on a word boundary. 101 94 * '''vbase0''' : virtual base address of the first user buffer. … … 110 103 Return -1 if no CMA channel allocated to the calling task, or if user buffers not aligned on a word boundary. 111 104 112 === int '''_sys_fbf_cma_display'''( unsigned int index ) ===105 === 3) int '''_sys_fbf_cma_display'''( unsigned int index ) === 113 106 This function is used in conjunction with the _fbf_cma_start() function, and must be called each time a new user buffer is available for display, to set the user buffer status in the chbuf descriptor. 114 107 The '''buffer''' argument define the user buffer index (0 => buf0 / not 0 => buf1). … … 120 113 Return -1 if no CMA channel allocated to the calling task. 121 114 122 === int '''_sys_fbf_cma_stop'''() ===115 === 4) int '''_sys_fbf_cma_stop'''() === 123 116 This function desactivares the CMA channel allocated to the calling task. 124 117 Return 0 in case of success. 125 118 Return -1 if no CMA channel allocated to the calling task. 126 119 120 === 5) int '''_sys_fbf_sync_write'''( unsigned int offset, void* buffer, unsigned int length ) === 121 This function transfer data from an user buffer to the frame_buffer device using a memcpy. 122 * '''offset''' : offset (in bytes) in the frame buffer. 123 * '''buffer''' : base address of the memory buffer. 124 * '''length''' : number of bytes to be transfered. 127 125 126 === 6) int '''_sys_fbf_sync_read'''( unsigned int offset, void* buffer, unsigned int length ) === 127 This function transfer data from the frame_buffer device to anuser buffer using a memcpy. 128 * '''offset''' : offset (in bytes) in the frame buffer. 129 * '''buffer''' : base address of the memory buffer. 130 * '''length''' : number of bytes to be transfered. 128 131 129 132 130 133 == __Miscelaneous syscall handlers__ == 131 134 132 === int '''_sys_ukn'''() ===133 Function executed in case of undefined syscall 135 === 1) int '''_sys_ukn'''() === 136 This function executed in case of undefined syscall. It just display an error message on TTY0. 134 137 135 === int '''_sys_proc_xyp'''( unsigned int* x, unsigned int*, unsigned int* p ) ===138 === 2) int '''_sys_proc_xyp'''( unsigned int* x, unsigned int*, unsigned int* p ) === 136 139 This function returns the processor (x,y,p) identifiers. 137 140 138 === int '''_sys_task_exit'''() ===141 === 3) int '''_sys_task_exit'''() === 139 142 The calling task goes to sleeping state, after printing an exit message. 140 143 It is descheduled and enters the "not runable" mode. 141 144 142 === int '''_context_switch'''() ===145 === 4) int '''_context_switch'''() === 143 146 This function deschedules the calling task. It mask interrupts before calling the _ctx_switch, and restore it when the task is rescheduled. 144 147 145 === int '''_sys_local_task_id'''() ===148 === 5) int '''_sys_local_task_id'''() === 146 149 This function returns the current task local index (amongst tasks running on a given processor). 147 150 148 === int '''_sys_global_task_id'''() ===151 === 6) int '''_sys_global_task_id'''() === 149 152 This function returns the current task global index (amongst all tasks running on all processors). 150 153 151 === int '''_sys_thread_id'''() ===154 === 7) int '''_sys_thread_id'''() === 152 155 This function returns the current task thread index (amongst all tasks in a given multi-tasks application). 153 156 154 === int '''_sys_procs_number'''( unsigned int x, unsigned int y, unsigned int* number ) ===157 === 8) int '''_sys_procs_number'''( unsigned int x, unsigned int y, unsigned int* number ) === 155 158 Returns in the ''number'' argument the number of processors in cluster[x,y]. 156 159 157 === int '''_sys_vobj_get_vbase'''( char* vspace_name, char* vobj_name, unsigned int* vbase ) ===160 === 9) int '''_sys_vobj_get_vbase'''( char* vspace_name, char* vobj_name, unsigned int* vbase ) === 158 161 This function returns in the ''vbase'' argument the virtual base address of the vobj identified by the (vspace_name / vobj_name ) couple. Returns 0 if success, -1 if vobj not found. 159 162 160 === int '''_sys_vobj_get_length'''( char* vspace_name, char* vobj_name, unsigned int* length ) ===163 === 10) int '''_sys_vobj_get_length'''( char* vspace_name, char* vobj_name, unsigned int* length ) === 161 164 This function returns in the ''length'' argument the length of the vobj identified by the (vspace_name / vobj_name ) couple. Returns 0 if success, -1 if vobj not found 162 165 163 === int '''_sys_xy_from_ptr'''( void* ptr, unsigned int* x, unsigned int* y ) ===166 === 11) int '''_sys_xy_from_ptr'''( void* ptr, unsigned int* x, unsigned int* y ) === 164 167 This function returns in the (x,y) arguments the coordinates of the cluster where is mapped the ptr virtual address. It use the _get_context_slot() function to get the calling task page table, and uses the _v2p_translate() function to obtain the physical address. Returns 0 if success, -1 if ptr not mapped in the calling task vspace. 165 168 166 === int '''_sys_heap_info'''( unsigned int* vaddr, unsigned int* length, unsigned int x, unsigned int y ) ===169 === 12) int '''_sys_heap_info'''( unsigned int* vaddr, unsigned int* length, unsigned int x, unsigned int y ) === 167 170 This function returns the information associated to a heap : vaddr and length. 168 171 * If (x < X_SIZE) and (y < Y_SIZE), it return the heap associated to any task running in cluster(x,y).