Changes between Version 34 and Version 35 of library_stdio
- Timestamp:
- Nov 11, 2014, 3:19:24 PM (10 years ago)
Legend:
- Unmodified
- Added
- Removed
- Modified
-
library_stdio
v34 v35 11 11 Therefore, for all these system calls, the return value has not to be tested by the calling task. 12 12 13 == __1) Processor related system calls__==14 15 === void '''giet_proc_xyp'''( unsigned int* cluster_x, unsigned int* cluster_y unsigned int* lpid )===13 == Processor related system calls == 14 15 === 1) void '''giet_proc_xyp'''( unsigned int* cluster_x, unsigned int* cluster_y unsigned int* lpid )=== 16 16 This function returns the processor identifiers (X,Y,P) from the wired global processor index in CP0_PROCID. 17 17 * cluster_x : X cluster coordinate … … 20 20 No error possible, as the fixed format is gpid = ( ( cluster_x << Y_WIDTH + cluster_y ) << P_WIDTH ) + lpid 21 21 22 === unsigned int '''giet_proctime'''() ===22 === 2) unsigned int '''giet_proctime'''() === 23 23 This function returns the local processor time from the CP0_TIME register (number of cycles from reset). 24 24 No error possible, as the processor implements a 32 bits wrapping register. 25 25 26 === unsigned int '''giet_rand'''() ===26 === 3) unsigned int '''giet_rand'''() === 27 27 This function returns a pseudo-random value derived from both the CP0_PROCID and CP0_TIME registers. 28 28 No error possible, as the return value is always between 0 & 65535. 29 29 30 == __2) Task related system calls__==31 32 === unsigned int '''giet_proc_task_id'''() ===30 == Task related system calls == 31 32 === 1) unsigned int '''giet_proc_task_id'''() === 33 33 This functions returns (from the calling task context) the local task index, identifying the task amongst all task 34 34 running on the same processor. 35 36 35 No error possible. 37 36 38 === unsigned int '''giet_global_task_id'''() ===37 === 2) unsigned int '''giet_global_task_id'''() === 39 38 This functions returns (from the calling task context) the global task id, unique in the system. 40 41 39 No error possible. 42 40 43 === unsigned int '''giet_thread_id'''() ===41 === 3) unsigned int '''giet_thread_id'''() === 44 42 This functions returns (from the calling task context) the thread index, identiying the task in a given vspace. 45 46 43 No error possible. 47 44 48 == __3) TTY related system calls__==45 == TTY related system calls == 49 46 50 47 The GIET_VM allows an user task to use a private TTY terminal, or to display log message on a shared TTY terminal. 51 48 52 === void '''giet_tty_alloc'''() ===49 === 1) void '''giet_tty_alloc'''() === 53 50 This function allocates a private terminal to the calling task, and registers the terminal index in the task context. 54 51 Task exit if no TTY terminal available. 55 52 56 === void '''giet_tty_printf'''( char* format, ... ) ===53 === 2) void '''giet_tty_printf'''( char* format, ... ) === 57 54 This function print formated text on a private terminal that must have been allocated to the calling task in the mapping (''use_tty'' argument). Therefore, it does not take the TTY lock. 58 55 Only a limited number of formats are supported: … … 65 62 Task exit if private terminal index not defined, or in case of illegal format. 66 63 67 === void '''giet_tty_getc'''( char* byte ) ===64 === 3) void '''giet_tty_getc'''( char* byte ) === 68 65 This blocking function fetches a single character from the private terminal that must have been allocated to the calling task in the application mapping. It uses the TTY_RX_IRQ interrupt, and the associated kernel buffer. Task exit if private TTY index not defined. 69 66 70 === void '''giet_tty_getw'''( unsigned int* val ) ===67 === 4) void '''giet_tty_getw'''( unsigned int* val ) === 71 68 This blocking function fetches a string of decimal characters (most significant digit first) to build a 32-bits unsigned integer from the private TTY terminal that must have been allocated to the calling task in the application mapping. It uses the TTY_RX_IRQ interrupt, and the associated kernel buffer. 72 69 The non-blocking system function _tty_read is called several times, and the decimal characters are written in a 32 characters buffer until a <LF> character is read. It ignores non-decimal characters, and displays an echo for each decimal character. The <DEL> character is interpreted, and previous characters can be cancelled. When the <LF> character is received, the string is converted to an unsigned int value. If the number of decimal digit is too large for the 32 bits range, the zero value is returned. 73 70 Task exit if private TTY index not defined. 74 71 75 === void '''giet_tty_gets'''( char* buf, unsigned int bufsize ) ===72 === 5) void '''giet_tty_gets'''( char* buf, unsigned int bufsize ) === 76 73 This blocking function fetches a string from the private terminal that must have been allocated to the calling task in the application mapping. It writes the string to a fixed length buffer. 77 74 It uses the TTY_RX_IRQ interrupt, and the associated kernel buffer. … … 79 76 Task exit if private TTY index not defined. 80 77 81 === void '''giet_shr_printf'''( char* format, ... ) ===82 This function print formated text on a shared terminal arbitrarily allocated by the kernel. It takes the TTY lock for exclusive access. It supports the same formats as the giet_tty_printf() function.78 === 6) void '''giet_shr_printf'''( char* format, ... ) === 79 This function print formated text on the kernel terminal. It takes the TTY lock for exclusive access. It supports the same formats as the giet_tty_printf() function. 83 80 Task exit in case of illegal format. 84 81 85 == __4) Timer related system calls__==82 == Timer related system calls == 86 83 87 84 The GIET_VM allows an user task to activate a private timer channel, generating periodical IRQs. This timer is allocated in the external multi-timers peripheral. 88 85 89 === void '''giet_timer_alloc'''()86 === 1) void '''giet_timer_alloc'''() 90 87 This function allocates a private user timer to the calling task, and registers the channel index in the task context. 91 88 Task exit if no timer channel available 92 89 93 === void '''giet_timer_start'''( unsigned int period )90 === 2) void '''giet_timer_start'''( unsigned int period ) 94 91 This function starts the private timer allocated to the calling task. 95 92 Task exit if no channel allocated. 96 93 97 === void '''giet_timer_stop'''( ) ===94 === 3) void '''giet_timer_stop'''( ) === 98 95 This function stops the private timer allocated to the calling task. 99 96 Task exit if no channel allocated. 100 97 101 == __5) File system related system calls__==98 == File system related system calls == 102 99 103 100 The Giet-VM supports a FAT32 file system. 104 101 105 === int '''giet_fat_open'''( const char* pathname, unsigned int flags ) ===106 Open a file identified by the ''pathname'' argument. The read/write ''flags'' are not supported yet: no effect. Return -1 in case or error.107 108 === void '''giet_fat_read'''( unsigned int fd, void* buffer, unsigned int count, unsigned int offset ) ===102 === 1) int '''giet_fat_open'''( const char* pathname, unsigned int flags ) === 103 This function open a file identified by the ''pathname'' argument. The read/write ''flags'' are not supported yet: no effect. Return -1 in case or error. 104 105 === 2) void '''giet_fat_read'''( unsigned int fd, void* buffer, unsigned int count, unsigned int offset ) === 109 106 Read ''count'' sectors from a file identified by the ''fd'' argument, skipping ''offset'' sectors in file, and writing into the user memory ''buffer''. The user buffer base address should be 64 bytes aligned. 110 107 In case or error, it makes a giet_exit(). 111 108 112 === void '''giet_fat_write'''( unsigned int fd, void* buffer, unsigned int count, unsigned int offset ) ===109 === 3) void '''giet_fat_write'''( unsigned int fd, void* buffer, unsigned int count, unsigned int offset ) === 113 110 Write ''count'' sectors into a file identified by the ''fd'' argument, skipping ''offset'' sectors in file, and reading from the user memory ''buffer''. The user buffer base address should be 64 bytes aligned. 114 111 In case or error, it makes a giet_exit(). 115 112 116 === void '''giet_fat_close'''( unsigned int fd ) ===113 === 4) void '''giet_fat_close'''( unsigned int fd ) === 117 114 Close a file identified by the ''fd'' file descriptor. 118 115 119 116 120 == __6) Network related system calls__ == 121 122 The GIET_VM allows a user task to directly access a private NIC channel, and register the channel index in the task context. 123 124 === void '''giet_nic_tx_alloc'''( ) === 117 == Network related system call == 118 119 The GIET_VM allows a user task to access a private NIC channel, using the CMA component (chained buffers DMA). 120 The NIC channel and the CMA channel are registered in the task context. 121 122 === 1) void '''giet_nic_tx_alloc'''( ) === 125 123 This function allocates a private NIC_TX channel (coming with the associated kernel NIC_TX chbuf), and a private CMA channel to the calling task. It registers the corresponding indexes in the calling task context. 126 124 The calling task exit if no available NIC_TX channel, or no available CMA channel. 127 125 128 === void '''giet_nic_rx_alloc'''( ) ===126 === 2) void '''giet_nic_rx_alloc'''( ) === 129 127 This function allocates a private NIC_RX channel (coming with the associated kernel NIC_RX chbuf), and a private CMA channel to the calling task. It registers the corresponding indexes in the calling task context. 130 128 The calling task exit if no available NIC_RX channel, or no available CMA channel. 131 129 132 === void '''giet_nic_tx_start'''( ) ===130 === 3) void '''giet_nic_tx_start'''( ) === 133 131 This function activates both the NIC_TX channel and the CMA channel allocated to the calling task. 134 132 The calling task exit if no allocated NIC_TX channel or no allocated CMA channel. 135 133 136 === void '''giet_nic_rx_start'''( ) ===134 === 4) void '''giet_nic_rx_start'''( ) === 137 135 This function activates both the NIC_RX channel and the CMA channel allocated to the calling task. 138 136 The calling task exit if no allocated NIC_RX channel or no allocated CMA channel. 139 137 140 === void '''giet_nic_tx_move'''( void* buffer ) ===138 === 5) void '''giet_nic_tx_move'''( void* buffer ) === 141 139 This blocking function requires to transfer one container (4K bytes) from an user space buffer to the Network Controller. 142 140 * '''buffer''' is the container base address in user space. … … 144 142 The calling task exit if no NIC channel allocated to the task, or in case of timeout. 145 143 146 === void '''giet_nic_rx_move'''( void* buffer ) ===144 === 6) void '''giet_nic_rx_move'''( void* buffer ) === 147 145 This blocking function requires to transfer one container (4K bytes) from the Network Controller to an user space buffer. 148 146 * '''buffer''' is the container base address in user space. … … 150 148 The calling task exit if no NIC channel allocated to the task, or in case of timeout. 151 149 152 == __7) Frame Buffer related system calls__ == 153 154 An user task can access the frame buffer through a memcpy() or through the chained buffer DMA controller. 155 156 === void '''giet_fb_sync_read'''( unsigned int offset, void* buffer, unsigned int length ) === 157 This blocking function use a memcopy strategy to transfer data from the frame buffer to an user buffer: ''offset'' defines the offset (in bytes) in the frame buffer, ''buffer'' is the user buffer base address, ''length'' is the number of bytes to be transfered. 158 159 === void '''giet_fb_sync_write'''( unsigned int offset, void* buffer, unsigned int length ) === 160 This blocking function use a memcopy strategy to transfer data from an user buffer to the frame buffer: ''offset'' defines the offset (in bytes) in the frame buffer, ''buffer'' is the user buffer base address, ''length'' is the number of bytes to be transfered. 161 162 === void '''giet_fbf_cma_alloc'''() 150 === 7) void '''giet_nic_tx_stop( ) === 151 This function desactivates both the NIC_TX channel and the CMA channel allocated to the calling task. 152 The calling task exit if no allocated NIC_TX channel or no allocated CMA channel. 153 154 === 8) void '''giet_nic_rx_stop( ) === 155 This function desactivates both the NIC_RX channel and the CMA channel allocated to the calling task. 156 The calling task exit if no allocated NIC_RX channel or no allocated CMA channel. 157 158 == Frame Buffer related system calls == 159 160 An user task can access the frame buffer through a memcpy() or through the chained buffer DMA controller (CMA). 161 The four first functions use a private CMA channel that is registered in the task context. The Two last functions use a memcpy(). 162 163 === 1) void '''giet_fbf_cma_alloc'''() 163 164 This function allocates a private CMA channel to the calling task, and registers the channel index 164 165 in the task context. 165 166 Task exit if no CMA channel available 166 167 167 === void '''giet_fbf_cma_start'''( void* buf0, void* buf1, unsigned int length ) ===168 === 2) void '''giet_fbf_cma_start'''( void* buf0, void* buf1, unsigned int length ) === 168 169 This function initializes the chained buffer DMA controller (CMA) to transfer a stream of images from two user buffers to the frame buffer. It must be used in conjunction with the giet_fbf_cma_display() function. A CMA channel should have been allocated to the calling task in the application mapping. 169 170 * '''buf0('' is the first user buffer base address … … 171 172 * '''length''' is the buffer size (bytes). 172 173 173 === void '''giet_fbf_cma_display'''( unsigned int buffer ) ===174 === 3) void '''giet_fbf_cma_display'''( unsigned int buffer ) === 174 175 This function enables the transfer of the buffer specified by the ''buffer'' argument (0 or 1). 175 176 176 === void '''giet_fbf_cma_stop'''( ) ===177 === 4) void '''giet_fbf_cma_stop'''( ) === 177 178 This function desactivates the CMA channel allocated to the calling task. 178 179 179 == __8) Miscelaneous system calls__ == 180 181 === void '''giet_exit'''( char* string ) === 180 === 5) void '''giet_fb_sync_read'''( unsigned int offset, void* buffer, unsigned int length ) === 181 This blocking function use a memcopy strategy to transfer data from the frame buffer to an user buffer: ''offset'' defines the offset (in bytes) in the frame buffer, ''buffer'' is the user buffer base address, ''length'' is the number of bytes to be transfered. 182 183 === 6) void '''giet_fb_sync_write'''( unsigned int offset, void* buffer, unsigned int length ) === 184 This blocking function use a memcopy strategy to transfer data from an user buffer to the frame buffer: ''offset'' defines the offset (in bytes) in the frame buffer, ''buffer'' is the user buffer base address, ''length'' is the number of bytes to be transfered. 185 186 187 == 8) Miscelaneous system calls == 188 189 === 1) void '''giet_exit'''( char* string ) === 182 190 This function stops execution of the calling task with a TTY message explaining the cause. The user task is descheduled and becomes not runable: it does not consume processor cycles anymore. 183 191 184 === void '''giet_assert'''( unsigned int condition, char* string ) ===192 === 2) void '''giet_assert'''( unsigned int condition, char* string ) === 185 193 This function uses the giet_exit() system call to kill the calling task if the condition is false. 186 194 187 === void '''giet_context_switch'''() ===195 === 3) void '''giet_context_switch'''() === 188 196 The user task calling this function is descheduled and the processor is allocated to another task. 189 197 190 === void '''giet_procnumber'''( unsigned int cluster_xy, unsigned int buffer ) ===198 === 4) void '''giet_procnumber'''( unsigned int cluster_xy, unsigned int buffer ) === 191 199 This function returns in the ''buffer'' argument the number of processors in the cluster specified by the ''cluster_xy'' argument. In case or error (such as illegal cluster index), it makes a giet_exit(). 192 200 193 === void '''giet_vobj_get_vbase'''( char* vspace_name, char* vobj_name, unsigned int* vbase) ===201 === 5) void '''giet_vobj_get_vbase'''( char* vspace_name, char* vobj_name, unsigned int* vbase) === 194 202 This function returns in argument ''vbase'' the virtual base address of a vobj defined in the mapping_info data structure. The vobj is identified by the two arguments ''vspace_name'' and ''vobj_name''. In case of error (such as undefined vspace or undefined vobj), it makes a giet_exit(). 195 203 196 === void '''giet_vobj_get_length'''( char* vspace_name, char* vobj_name, unsigned int* length) ===204 === 6) void '''giet_vobj_get_length'''( char* vspace_name, char* vobj_name, unsigned int* length) === 197 205 This function returns in argument ''length'' the length (bytes) of a vobj defined in the mapping_info data structure. The vobj is identified by the two arguments ''vspace_name'' and ''vobj_name''. In case of error (such as undefined vspace or undefined vobj), it makes a giet_exit(). 198 206 199 === void '''giet_heap_info'''( unsigned int* vaddr, unsigned int* length, unsigned int x, unsigned int y );207 === 7) void '''giet_heap_info'''( unsigned int* vaddr, unsigned int* length, unsigned int x, unsigned int y ); 200 208 This function supports access to the running task's heap or to a remote heap. If (x < X_SIZE) and (y < Y_SIZE), it returns the base address and length of the heap associated to any task running on cluster(x,y). Otherwise, it returns the base address and length of the heap associated to the calling task. In case of error (such as undefined heap segment in the selected cluster, it returns heap_size = 0). 201 209 202 === void '''giet_get_xy'''( void* ptr, unsigned int* px, unsigned int* py ) ===210 === 8) void '''giet_get_xy'''( void* ptr, unsigned int* px, unsigned int* py ) === 203 211 This function takes as input a virtual address (''ptr'' argument), and returns through the ''px,py'' arguments the coordinates of the cluster containing the physical address associated to ''ptr''. In case of error (unmapped virtual address), it makes a giet_exit(). 204 212