Changeset 295 for soft/giet_vm/giet_libs/stdio.h
- Timestamp:
- Mar 26, 2014, 6:44:44 PM (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
soft/giet_vm/giet_libs/stdio.h
r267 r295 18 18 #define SYSCALL_TIMER_START 0x04 19 19 #define SYSCALL_TIMER_STOP 0x05 20 #define SYSCALL_ FREE_060x0621 #define SYSCALL_ FREE_070x0720 #define SYSCALL_TTY_GET_LOCK 0x06 21 #define SYSCALL_TTY_RELEASE_LOCK 0x07 22 22 #define SYSCALL_HEAP_INFO 0x08 23 23 #define SYSCALL_LOCAL_TASK_ID 0x09 … … 32 32 #define SYSCALL_FB_SYNC_READ 0x11 33 33 #define SYSCALL_THREAD_ID 0x12 34 #define SYSCALL_ TTY_LOCK0x1334 #define SYSCALL_FREE_13 0x13 35 35 #define SYSCALL_FREE_14 0x14 36 36 #define SYSCALL_FREE_15 0x15 … … 99 99 100 100 ////////////////////////////////////////////////////////////////////////// 101 // MIPS32 related system calls 102 ////////////////////////////////////////////////////////////////////////// 103 104 extern int giet_procid(); 105 106 extern int giet_proctime(); 107 108 ////////////////////////////////////////////////////////////////////////// 109 // TTY device related system calls 110 ////////////////////////////////////////////////////////////////////////// 111 112 extern int giet_tty_putc(char byte); 113 114 extern int giet_tty_puts(char* buf); 115 116 extern int giet_tty_putw(unsigned int val); 117 118 extern int giet_tty_getc_no_irq(char* byte); 119 120 extern int giet_tty_getc(char* byte); 121 122 extern int giet_tty_gets(char* buf, unsigned int bufsize); 123 124 extern int giet_tty_getw(unsigned int* val); 125 126 extern int giet_tty_printf(char* format,...); 127 128 ////////////////////////////////////////////////////////////////////////// 129 // TIMER device related system calls 130 ////////////////////////////////////////////////////////////////////////// 131 132 extern int giet_timer_start(); 133 134 extern int giet_timer_stop(); 101 ////////////////////////////////////////////////////////////////////////// 102 // MIPS32 related system calls 103 ////////////////////////////////////////////////////////////////////////// 104 ////////////////////////////////////////////////////////////////////////// 105 106 ////////////////////////////////////////////////////////////////////////// 107 ////////////////////////////////////////////////////////////////////////// 108 // TTY device related system calls 109 ////////////////////////////////////////////////////////////////////////// 110 ////////////////////////////////////////////////////////////////////////// 111 112 ////////////////////////////////////////////////////////////////////////// 113 // This function is a modified version of the mutek_printf(). 114 // It uses a private terminal allocated to the calling task in the boot. 115 // ("use_tty" argument in xml mapping), and does not take the TTY lock. 116 // It calls several times the _tty_write system function. 117 // Only a limited number of formats are supported: 118 // - %d : signed decimal 119 // - %u : unsigned decimal 120 // - %x : 32 bits hexadecimal 121 // - %l : 64 bits hexadecimal 122 // - %c : char 123 // - %s : string 124 // In case or error returned by syscall, it makes a giet_exit(). 125 ////////////////////////////////////////////////////////////////////////// 126 extern void giet_tty_printf( char* format, ... ); 127 128 ////////////////////////////////////////////////////////////////////////// 129 // This function is a modified version of the mutek_printf(). 130 // It uses the kernel TTY0 as a shared terminal, and it takes the 131 // TTY lock to get exclusive access during the format display. 132 // It calls several times the _tty_write system function. 133 // Only a limited number of formats are supported: 134 // - %d : signed decimal 135 // - %u : unsigned decimal 136 // - %x : 32 bits hexadecimal 137 // - %l : 64 bits hexadecimal 138 // - %c : char 139 // - %s : string 140 // In case or error returned by syscall, it makes a giet_exit(). 141 ////////////////////////////////////////////////////////////////////////// 142 extern void giet_shr_printf( char* format, ... ); 143 144 ////////////////////////////////////////////////////////////////////////// 145 // This blocking function fetches a single character from the private 146 // terminal allocated to the calling task in the boot. 147 // It uses the TTY_RX_IRQ interrupt, and the associated kernel buffer. 148 // In case or error returned by syscall, it makes a giet_exit(). 149 ////////////////////////////////////////////////////////////////////////// 150 extern void giet_tty_getc( char* byte ); 151 152 ////////////////////////////////////////////////////////////////////////// 153 // This blocking function fetches a string from the private terminal 154 // allocated to the calling task to a fixed length buffer. 155 // The terminal index must be defined in the task context in the boot. 156 // It uses the TTY_RX_IRQ interrupt, and the associated kernel buffer. 157 // - Up to (bufsize - 1) characters (including the non printable characters) 158 // are copied into buffer, and the string is completed by a NUL character. 159 // - The <LF> character is interpreted, and the function close the string 160 // with a NUL character if <LF> is read. 161 // - The <DEL> character is interpreted, and the corresponding character(s) 162 // are removed from the target buffer. 163 // - It does not provide an echo. 164 // In case or error returned by syscall, it makes a giet_exit(). 165 ///////////////////////////////////////////////////////////////////////// 166 extern void giet_tty_gets( char* buf, unsigned int bufsize ); 167 168 ///////////////////////////////////////////////////////////////////////// 169 // This blocking function fetches a string of decimal characters (most 170 // significant digit first) to build a 32-bit unsigned integer from 171 // the private TTY terminal allocated to the calling task. 172 // The terminal index must be defined in the task context in the boot. 173 // It uses the TTY_RX_IRQ interrupt, and the associated kernel buffer. 174 // - The non-blocking system function _tty_read is called several times, 175 // and the decimal characters are written in a 32 characters buffer 176 // until a <LF> character is read. 177 // - It ignores non-decimal characters, and displays an echo 178 // system function) for each decimal character. 179 // - The <DEL> character is interpreted, and previous characters can be cancelled. 180 // - When the <LF> character is received, the string is converted to an 181 // unsigned int value. If the number of decimal digit is too large for the 32 182 // bits range, the zero value is returned. 183 // In case or error returned by syscall, it makes a giet_exit(). 184 ////////////////////////////////////////////////////////////////////////// 185 extern void giet_tty_getw( unsigned int* val ); 186 187 ////////////////////////////////////////////////////////////////////////// 188 ////////////////////////////////////////////////////////////////////////// 189 // TIMER device related system calls 190 ////////////////////////////////////////////////////////////////////////// 191 ////////////////////////////////////////////////////////////////////////// 192 193 ////////////////////////////////////////////////////////////////////////// 194 // This function activates the private user timer allocated 195 // to the calling task in the boot phase. 196 // In case or error returned by syscall, it makes a giet_exit(). 197 ////////////////////////////////////////////////////////////////////////// 198 extern void giet_timer_start(); 199 200 ////////////////////////////////////////////////////////////////////////// 201 // This function stops the private user timer allocated 202 // to the calling task. 203 // In case or error returned by syscall, it makes a giet_exit(). 204 ////////////////////////////////////////////////////////////////////////// 205 extern void giet_timer_stop(); 135 206 136 207 ////////////////////////////////////////////////////////////////////////// 137 // Frame buffer device related system calls 138 ////////////////////////////////////////////////////////////////////////// 139 140 extern int giet_fb_sync_read( unsigned int offset, 141 void* buffer, 208 ////////////////////////////////////////////////////////////////////////// 209 // Frame buffer device related system calls 210 ////////////////////////////////////////////////////////////////////////// 211 ////////////////////////////////////////////////////////////////////////// 212 213 ////////////////////////////////////////////////////////////////////////// 214 // This blocking function use a memory copy strategy to transfer data 215 // from the frame buffer device in kernel space to an user buffer. 216 // offset : offset (in bytes) in the frame buffer 217 // buffer : base address of the user buffer 218 // length : number of bytes to be transfered 219 // In case or error returned by syscall, it makes a giet_exit(). 220 ////////////////////////////////////////////////////////////////////////// 221 extern void giet_fb_sync_read( unsigned int offset, 222 void* buffer, 223 unsigned int length ); 224 225 ////////////////////////////////////////////////////////////////////////// 226 // This blocking function use a memory copy strategy to transfer data 227 // from a user buffer to the frame buffer device in kernel space. 228 // offset : offset (in bytes) in the frame buffer 229 // buffer : base address of the memory buffer 230 // length : number of bytes to be transfered 231 // In case or error returned by syscall, it makes a giet_exit(). 232 ////////////////////////////////////////////////////////////////////////// 233 extern void giet_fb_sync_write( unsigned int offset, 234 void* buffer, 235 unsigned int length ); 236 237 ////////////////////////////////////////////////////////////////////////// 238 // This function initializes the two chbuf SRC an DST used by the CMA 239 // controller and activates the CMA channel allocated to the calling task. 240 // - buf0 : first user buffer virtual address 241 // - buf1 : second user buffer virtual address 242 // - length : buffer size (bytes) 243 // In case or error returned by syscall, it makes a giet_exit(). 244 ////////////////////////////////////////////////////////////////////////// 245 extern void giet_fb_cma_init( void* buf0, 246 void* buf1, 142 247 unsigned int length ); 143 248 144 extern int giet_fb_sync_write(unsigned int offset, 145 void* buffer, 146 unsigned int length); 147 148 extern int giet_fb_cma_init( void* buf0, 149 void* buf1, 150 unsigned int length); 151 152 extern int giet_fb_cma_write(unsigned int buf_id); 153 154 extern int giet_fb_cma_stop(); 155 156 ////////////////////////////////////////////////////////////////////////// 157 // Network controller related system calls 158 ////////////////////////////////////////////////////////////////////////// 159 160 extern int giet_nic_cma_start(); 161 162 extern int giet_nic_cma_stop(); 163 164 ////////////////////////////////////////////////////////////////////////// 165 // FAT related system calls 166 ////////////////////////////////////////////////////////////////////////// 167 249 ////////////////////////////////////////////////////////////////////////// 250 // This function initializes the two chbuf SRC an DST used by the CMA 251 // controller and activates the CMA channel allocated to the calling task. 252 // - buf0 : first user buffer virtual address 253 // - buf0 : second user buffer virtual address 254 // - length : buffer size (bytes) 255 // In case or error returned by syscall, it makes a giet_exit(). 256 ////////////////////////////////////////////////////////////////////////// 257 extern void giet_fb_cma_write( unsigned int buf_id ); 258 259 ////////////////////////////////////////////////////////////////////////// 260 // This function desactivates the CMA channel allocated to the task. 261 // In case or error returned by syscall, it makes a giet_exit(). 262 ////////////////////////////////////////////////////////////////////////// 263 extern void giet_fb_cma_stop(); 264 265 ////////////////////////////////////////////////////////////////////////// 266 ////////////////////////////////////////////////////////////////////////// 267 // NIC related system calls 268 ////////////////////////////////////////////////////////////////////////// 269 ////////////////////////////////////////////////////////////////////////// 270 271 ////////////////////////////////////////////////////////////////////////// 272 // This function initializes the memory chbuf used by the CMA controller, 273 // activates the NIC channel allocated to the calling task, 274 // and activates the two CMA channels. 275 // - tx : RX channel if 0 / TX channel if non 0 276 // - buf0 : first user buffer virtual address 277 // - buf1 : second user buffer virtual address 278 // - length : buffer size (bytes) 279 // In case or error returned by syscall, it makes a giet_exit(). 280 ////////////////////////////////////////////////////////////////////////// 281 extern void giet_nic_cma_start(); 282 283 ////////////////////////////////////////////////////////////////////////// 284 // This function desactivates the NIC channel and the two CMA channels 285 // allocated to the calling task. 286 // In case or error returned by syscall, it makes a giet_exit(). 287 ////////////////////////////////////////////////////////////////////////// 288 extern void giet_nic_cma_stop(); 289 290 ////////////////////////////////////////////////////////////////////////// 291 ////////////////////////////////////////////////////////////////////////// 292 // FAT related system calls 293 ////////////////////////////////////////////////////////////////////////// 294 ////////////////////////////////////////////////////////////////////////// 295 296 ////////////////////////////////////////////////////////////////////////// 297 // Open a file identified by a pathname, and contained in the system FAT. 298 // The read/write flags are not supported yet: no effect. 299 // Return -1 in case or error. 300 ////////////////////////////////////////////////////////////////////////// 168 301 extern int giet_fat_open( const char* pathname, 169 302 unsigned int flags ); 170 303 171 extern int giet_fat_read( unsigned int fd, 172 void* buffer, 173 unsigned int count, 174 unsigned int offset ); 175 176 extern int giet_fat_write( unsigned int fd, 177 void* buffer, 178 unsigned int count, 179 unsigned int offset ); 180 181 extern int giet_fat_lseek( unsigned int fd, 182 unsigned int offset, 183 unsigned int whence ); 184 185 extern int giet_fat_fstat( unsigned int fd ); 186 187 extern int giet_fat_close( unsigned int fd ); 188 189 ////////////////////////////////////////////////////////////////////////// 190 // Miscelaneous system calls 191 ////////////////////////////////////////////////////////////////////////// 192 193 extern int giet_vobj_get_vbase( char* vspace_name, 194 char* vobj_name, 195 unsigned int vobj_type, 196 unsigned int* vobj_vaddr); 197 198 extern int giet_procnumber(); 199 304 /////////////////////////////////////////////////////////////////////////////////// 305 // Read "count" sectors from a file identified by "fd", skipping "offset" 306 // sectors in file, and writing into the user "buffer". 307 // The user buffer base address shoulb be 64 bytes aligned. 308 // In case or error returned by syscall, it makes a giet_exit(). 309 /////////////////////////////////////////////////////////////////////////////////// 310 extern void giet_fat_read( unsigned int fd, 311 void* buffer, 312 unsigned int count, 313 unsigned int offset ); 314 315 /////////////////////////////////////////////////////////////////////////////////// 316 // Write "count" sectors from a file identified by "fd", skipping "offset" 317 // sectors in file, and reading from the user "buffer". 318 // The user buffer base address shoulb be 64 bytes aligned. 319 // In case or error returned by syscall, it makes a giet_exit(). 320 /////////////////////////////////////////////////////////////////////////////////// 321 extern void giet_fat_write( unsigned int fd, 322 void* buffer, 323 unsigned int count, 324 unsigned int offset ); 325 326 /////////////////////////////////////////////////////////////////////////////////// 327 // Change the lseek file pointer value for a file identified by "fd". 328 // In case or error returned by syscall, it makes a giet_exit(). 329 /////////////////////////////////////////////////////////////////////////////////// 330 extern void giet_fat_lseek( unsigned int fd, 331 unsigned int offset, 332 unsigned int whence ); 333 334 /////////////////////////////////////////////////////////////////////////////////// 335 // Returns general informations of a file identified by "fd". 336 // (Only the file_size in sectors for this moment) 337 /////////////////////////////////////////////////////////////////////////////////// 338 extern void giet_fat_fstat( unsigned int fd ); 339 340 ////////////////////////////////////////////////////////////////////////// 341 // Close a file identified by "fd". 342 ////////////////////////////////////////////////////////////////////////// 343 extern void giet_fat_close( unsigned int fd ); 344 345 ////////////////////////////////////////////////////////////////////////// 346 ////////////////////////////////////////////////////////////////////////// 347 // Miscelaneous system calls 348 ////////////////////////////////////////////////////////////////////////// 349 ////////////////////////////////////////////////////////////////////////// 350 351 ////////////////////////////////////////////////////////////////////////// 352 // This function returns the processor identifier. 353 ////////////////////////////////////////////////////////////////////////// 354 extern int giet_procid(); 355 356 ////////////////////////////////////////////////////////////////////////// 357 // This function returns the local processor time. 358 ////////////////////////////////////////////////////////////////////////// 359 extern int giet_proctime(); 360 361 ////////////////////////////////////////////////////////////////////////// 362 // This functions returns the local task id. 363 // If processor has n tasks the local task index is ranging from 0 to n-1 364 ////////////////////////////////////////////////////////////////////////// 365 extern int giet_proc_task_id(); 366 367 ////////////////////////////////////////////////////////////////////////// 368 // This functions returns the global task id, (unique in the system). 369 ////////////////////////////////////////////////////////////////////////// 370 extern int giet_global_task_id(); 371 372 ////////////////////////////////////////////////////////////////////////// 373 // This functions returns the thread index of the task in its vspace. 374 ////////////////////////////////////////////////////////////////////////// 375 extern int giet_thread_id(); 376 377 ////////////////////////////////////////////////////////////////////////// 378 // This function returns a pseudo-random value derived from the processor 379 // cycle count. This value is comprised between 0 & 65535. 380 ///////////////////////////////////////////////////////////////////////// 381 extern int giet_rand(); 382 383 ////////////////////////////////////////////////////////////////////////// 384 // This function stops execution of the calling task with a TTY message, 385 // the user task is descheduled and becomes not runable. 386 // It does not consume processor cycles anymore. 387 ////////////////////////////////////////////////////////////////////////// 200 388 extern void giet_exit(); 201 389 202 extern int giet_context_switch(); 203 204 extern int giet_proc_task_id(); 205 206 extern int giet_heap_info( unsigned int* vaddr, 207 unsigned int* size ); 208 209 extern int giet_global_task_id(); 210 211 extern int giet_thread_id(); 212 390 ////////////////////////////////////////////////////////////////////////// 391 // This function uses the giet_exit() system call 392 // and kill the calling task if the condition is false. 393 ////////////////////////////////////////////////////////////////////////// 213 394 extern void giet_assert( unsigned int, 214 395 char* string ); 215 396 216 extern int giet_rand(); 397 ////////////////////////////////////////////////////////////////////////// 398 // This function writes in argument "vobj_vaddr" the virtual base address 399 // of a vobj (defined in the mapping_info data structure), identified by 400 // the two arguments "vspace_name" and "vobj_name". 401 // In case or error returned by syscall, it makes a giet_exit(). 402 // ( vobj not defined or wrong vspace ) 403 ////////////////////////////////////////////////////////////////////////// 404 extern void giet_vobj_get_vbase( char* vspace_name, 405 char* vobj_name, 406 unsigned int* vobj_vaddr); 407 408 ////////////////////////////////////////////////////////////////////////// 409 // This function returns in the "buffer" argument the number of processors 410 // in the cluster specified by the "cluster_xy" argument. 411 // In case or error returned by syscall, it makes a giet_exit(). 412 ////////////////////////////////////////////////////////////////////////// 413 extern void giet_procnumber( unsigned int cluster_xy, 414 unsigned int buffer ); 415 416 ////////////////////////////////////////////////////////////////////////// 417 // The user task calling this function is descheduled and 418 // the processor is allocated to another task. 419 ////////////////////////////////////////////////////////////////////////// 420 extern void giet_context_switch(); 421 422 ////////////////////////////////////////////////////////////////////////// 423 // This function returns the base address and size of the task's heap 424 ////////////////////////////////////////////////////////////////////////// 425 extern void giet_heap_info( unsigned int* vaddr, 426 unsigned int* size ); 427 217 428 218 429 #endif
Note: See TracChangeset
for help on using the changeset viewer.