Changeset 622 for trunk/softs/giet_tsar/stdio.h
- Timestamp:
- Jan 29, 2014, 9:30:38 AM (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/softs/giet_tsar/stdio.h
r158 r622 1 /********************************************************************************* 2 fichier stdio.h 3 Written Alain greiner & Nicolas Pouillon 4 Date : 15/09/2009 5 *********************************************************************************/ 1 //////////////////////////////////////////////////////////////////////////////////////// 2 // File : stdio.h 3 // Written by Alain Greiner 4 // Date : 17/01/2014 5 // 6 // This file define varions functions that can be used by applications to access 7 // peripherals, or other ressources such as processor registers, spin_locks 8 // or synchronisation barriers. 9 // It is dedicated for the TSAR multi-processors multi_clusters architecture. 10 // There is NO separation between application code and system code. 11 // This basic GIET does not use the virtual memory, and does nort support multi-tasking. 12 // 13 //The supported peripherals are: 14 //- the SoClib multi_tty 15 //- The SoCLib frame_buffer 16 //- The SoCLib block_device 17 // 18 //The following parameters must be defined in the hard_config.h file. 19 //- X_SIZE : number of clusters in a row 20 //- Y_SIZE : number of clusters in a column 21 //- X_WIDTH : number of bits for X field in proc_id 22 //- Y_WIDTH : number of bits for Y field in proc_id 23 //- NB_PROCS_MAX : max number of processor per cluster 24 //- NB_TTY_CHANNELS : max number of TTY channels 25 // 26 //The follobing base addresses must be defined in the ldscript 27 //- seg_tty_base 28 //- seg_fbf_base 29 //- seg_ioc_base 30 //////////////////////////////////////////////////////////////////////////////////////// 6 31 7 #ifndef _ STDIO_H_8 #define _ STDIO_H_32 #ifndef _GIET_STDIO_H_ 33 #define _GIET_STDIO_H_ 9 34 10 #define SYSCALL_PROCID 0x00 11 #define SYSCALL_PROCTIME 0x01 12 #define SYSCALL_TTY_WRITE 0x02 13 #define SYSCALL_TTY_READ 0x03 14 #define SYSCALL_TIMER_WRITE 0x04 15 #define SYSCALL_TIMER_READ 0x05 16 #define SYSCALL_GCD_WRITE 0x06 17 #define SYSCALL_GCD_READ 0x07 18 #define SYSCALL_ICU_WRITE 0x08 19 #define SYSCALL_ICU_READ 0x09 20 #define SYSCALL_TTY_READ_IRQ 0x0A 21 #define SYSCALL_TTY_WRITE_IRQ 0x0B 22 #define SYSCALL_LOCKS_WRITE 0x0C 23 #define SYSCALL_LOCKS_READ 0x0D 24 #define SYSCALL_EXIT 0x0E 25 #define SYSCALL_PROCNUMBER 0x0F 35 #include "tty.h" 36 #include "block_device.h" 37 #include "hard_config.h" 38 #include <stdarg.h> 26 39 27 #define SYSCALL_FB_SYNC_WRITE 0x10 28 #define SYSCALL_FB_SYNC_READ 0x11 29 #define SYSCALL_FB_WRITE 0x12 30 #define SYSCALL_FB_READ 0x13 31 #define SYSCALL_FB_COMPLETED 0x14 32 #define SYSCALL_IOC_WRITE 0x15 33 #define SYSCALL_IOC_READ 0x16 34 #define SYSCALL_IOC_COMPLETED 0x17 35 #define SYSCALL_BARRIER_INIT 0x18 36 #define SYSCALL_BARRIER_WAIT 0x19 40 typedef unsigned int size_t; 37 41 38 typedef unsigned int size_t; 42 // global variables defined in stdio.c 39 43 40 /**************************************************************** 41 this is a generic C function to implement all system calls. 42 - The first argument is the system call index. 43 - The four next arguments are the system call arguments. 44 They will be written in registers $2, $4, $5, $6, $7. 45 ****************************************************************/ 46 int sys_call(int call_no, 47 int arg_o, 48 int arg_1, 49 int arg_2, 50 int arg_3); 44 extern int volatile _ioc_lock; 45 extern int volatile _ioc_done; 46 extern int volatile _ioc_status; 51 47 52 /**************************************************************** 53 These functions access the MIPS protected registers 54 ****************************************************************/ 55 int procid(); 56 int proctime(); 57 int procnumber(); 58 int exit(); 59 int rand(); 48 extern char volatile _tty_get_buf[]; 49 extern int volatile _tty_get_full[]; 60 50 61 /**************************************************************** 62 These functions access the MULTI_TTY peripheral 63 ****************************************************************/ 64 int tty_puts(char* string); 65 int tty_putc(char byte); 66 int tty_putw(int word); 67 int tty_getc(char* byte); 68 int tty_getc_irq(char* byte); 69 int tty_gets_irq(char* buf, int bufsize); 70 int tty_getw_irq(int* word); 71 int tty_printf(char* format,...); 51 extern int volatile _barrier_value[]; 52 extern int volatile _barrier_count[]; 53 extern int volatile _barrier_lock[]; 72 54 73 /**************************************************************** 74 These functions access the MULTI_TIMER peripheral 75 ****************************************************************/ 76 int timer_set_mode(int timer_index, int mode); 77 int timer_set_period(int timer_index, int period); 78 int timer_reset_irq(int timer_index); 79 int timer_get_time(int timer_index, int* time); 55 extern int volatile _spin_lock[]; 80 56 81 /**************************************************************** 82 These functions access the GCD peripheral 83 ****************************************************************/ 84 int gcd_set_opa(int val); 85 int gcd_set_opb(int val); 86 int gcd_start(); 87 int gcd_get_result(int* val); 88 int gcd_get_status(int* val); 57 // functions defined in stdio.c 89 58 90 /**************************************************************** 91 These functions access the ICU peripheral 92 ****************************************************************/ 93 int icu_set_mask(int val); 94 int icu_clear_mask(int val); 95 int icu_get_mask(int* buffer); 96 int icu_get_irqs(int* buffer); 97 int icu_get_index(int* buffer); 59 void* _memcpy( void* dst, const void* src, size_t size ); 98 60 99 /**************************************************************** 100 These functions access the LOCKS peripheral 101 ****************************************************************/ 102 int lock_acquire(int lock_index); 103 int lock_release(int lock_index); 61 unsigned int _procid(); 62 unsigned int _proctime(); 63 unsigned int _procnumber(); 104 64 105 /**************************************************************** 106 These functions access the BLOCK_DEVICE peripheral 107 ****************************************************************/ 108 int ioc_read(size_t lba, void* buffer, size_t count); 109 int ioc_write(size_t lba, void* buffer, size_t count); 110 int ioc_completed(); 65 void _it_mask(); 66 void _it_enable(); 111 67 112 /**************************************************************** 113 These functions access the FRAME_BUFFER peripheral 114 ****************************************************************/ 115 int fb_read(size_t offset, void* buffer, size_t length); 116 int fb_write(size_t offset, void* buffer, size_t length); 117 int fb_completed(); 118 int fb_sync_read(size_t offset, void* buffer, size_t length); 119 int fb_sync_write(size_t offset, void* buffer, size_t length); 68 void _dcache_buf_invalidate( const void* buffer, size_t size ); 120 69 121 /**************************************************************** 122 These functions access the synchronization barriers 123 ****************************************************************/ 124 int barrier_init(size_t index, size_t count); 125 int barrier_wait(size_t index); 70 void _exit(); 71 72 void _itoa_dec( unsigned int val, char* buf ); 73 void _itoa_hex( unsigned int val, char* buf ); 74 75 int _tty_write( char* buffer, size_t length, size_t channel ); 76 int _tty_read( char* buffer, size_t channel ); 77 void _tty_puts( char* string ); 78 void _tty_putd( unsigned int val ); 79 void _tty_putx( unsigned int val ); 80 void _tty_get_lock( size_t channel ); 81 void _tty_release_lock( size_t channel ); 82 void _tty_getc( char* buffer ); 83 void _tty_getw( unsigned int* buffer ); 84 void _tty_printf( char* format, ... ); 85 86 void _ioc_get_lock(); 87 void _ioc_write( size_t lba, void* buffer, size_t count, size_t ext ); 88 void _ioc_read (size_t lba, void* buffer, size_t count, size_t ext ); 89 void _ioc_completed(); 90 void _ioc_isr(); 91 92 void _mmc_isr(); 93 94 void _fb_sync_write( size_t offset, void* buffer, size_t length, size_t ext ); 95 void _fb_sync_read( size_t offset, void* buffer, size_t length, size_t ext ); 96 97 void _release_lock( size_t lock_index ); 98 void _get_lock( size_t lock_index ); 99 100 void _barrier_init(size_t index, size_t count); 101 void _barrier_wait(size_t index); 126 102 127 103 #endif
Note: See TracChangeset
for help on using the changeset viewer.