| 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 | //////////////////////////////////////////////////////////////////////////////////////// | 
|---|
| 31 |  | 
|---|
| 32 | #ifndef _GIET_STDIO_H_ | 
|---|
| 33 | #define _GIET_STDIO_H_ | 
|---|
| 34 |  | 
|---|
| 35 | #include "tty.h" | 
|---|
| 36 | #include "block_device.h" | 
|---|
| 37 | #include "hard_config.h" | 
|---|
| 38 | #include <stdarg.h> | 
|---|
| 39 |  | 
|---|
| 40 | typedef unsigned int    size_t; | 
|---|
| 41 |  | 
|---|
| 42 | // constants | 
|---|
| 43 |  | 
|---|
| 44 | #define CLUSTER_IO (((X_IO) << (Y_WIDTH)) | (Y_IO)) | 
|---|
| 45 |  | 
|---|
| 46 | // functions defined in stdio.c | 
|---|
| 47 |  | 
|---|
| 48 | void*           _memcpy( void* dst, const void* src, size_t size ); | 
|---|
| 49 |  | 
|---|
| 50 | void            _extended_memcpy( unsigned int dst_cluster, | 
|---|
| 51 | unsigned int dst_address, | 
|---|
| 52 | unsigned int src_cluster, | 
|---|
| 53 | unsigned int src_address, | 
|---|
| 54 | unsigned int length ); | 
|---|
| 55 | inline unsigned int _procid(); | 
|---|
| 56 | inline unsigned int _proctime(); | 
|---|
| 57 | inline unsigned int _procnumber(); | 
|---|
| 58 |  | 
|---|
| 59 | inline unsigned int _io_cluster(); | 
|---|
| 60 |  | 
|---|
| 61 | unsigned int    _rand(); | 
|---|
| 62 |  | 
|---|
| 63 | void            _it_mask(); | 
|---|
| 64 | void            _it_enable(); | 
|---|
| 65 |  | 
|---|
| 66 | int             _sr_read(); | 
|---|
| 67 | void            _sr_write(int sr); | 
|---|
| 68 |  | 
|---|
| 69 | void            _dcache_buf_invalidate( const void* buffer, size_t size ); | 
|---|
| 70 |  | 
|---|
| 71 | void            _exit(); | 
|---|
| 72 |  | 
|---|
| 73 | void            _itoa_dec( unsigned int val, char* buf ); | 
|---|
| 74 | void            _itoa_hex( unsigned int val, char* buf ); | 
|---|
| 75 |  | 
|---|
| 76 | int             _tty_write( char* buffer, size_t length, size_t channel ); | 
|---|
| 77 | int             _tty_read( char* buffer, size_t channel ); | 
|---|
| 78 | void            _tty_puts( char* string ); | 
|---|
| 79 | void            _tty_putd( unsigned int val ); | 
|---|
| 80 | void            _tty_putx( unsigned int val ); | 
|---|
| 81 | void            _tty_get_lock( size_t channel ); | 
|---|
| 82 | void            _tty_release_lock( size_t channel ); | 
|---|
| 83 | void            _tty_getc( char* buffer ); | 
|---|
| 84 | void            _tty_getw( unsigned int* buffer ); | 
|---|
| 85 | void            _tty_printf( char* format, ... ); | 
|---|
| 86 | void            _tty_isr(); | 
|---|
| 87 |  | 
|---|
| 88 | void            _ioc_get_lock(); | 
|---|
| 89 | void            _ioc_write( size_t lba, void* buffer, size_t count, size_t ext ); | 
|---|
| 90 | void            _ioc_read (size_t lba, void* buffer, size_t count, size_t ext ); | 
|---|
| 91 | unsigned int    _ioc_get_blocksize(); | 
|---|
| 92 | void            _ioc_completed(); | 
|---|
| 93 | void            _ioc_isr(); | 
|---|
| 94 |  | 
|---|
| 95 | void            _mmc_isr(); | 
|---|
| 96 |  | 
|---|
| 97 | void            _fb_sync_write( unsigned int offset, | 
|---|
| 98 | unsigned int buffer, | 
|---|
| 99 | unsigned int length, | 
|---|
| 100 | unsigned int ext ); | 
|---|
| 101 | void            _fb_sync_read(  unsigned int offset, | 
|---|
| 102 | unsigned int buffer, | 
|---|
| 103 | unsigned int length, | 
|---|
| 104 | unsigned int ext ); | 
|---|
| 105 |  | 
|---|
| 106 | void            _release_lock( size_t lock_index ); | 
|---|
| 107 | void            _get_lock( size_t lock_index ); | 
|---|
| 108 |  | 
|---|
| 109 | void            _barrier_init(size_t index, size_t count); | 
|---|
| 110 | void            _barrier_wait(size_t index); | 
|---|
| 111 |  | 
|---|
| 112 | volatile unsigned char _byte_extended_read( unsigned int cluster, | 
|---|
| 113 | unsigned int address ); | 
|---|
| 114 | volatile unsigned int  _word_extended_read( unsigned int cluster, | 
|---|
| 115 | unsigned int address ); | 
|---|
| 116 |  | 
|---|
| 117 | void            _word_extended_write( unsigned int   cluster, | 
|---|
| 118 | unsigned int   address, | 
|---|
| 119 | unsigned int   word ); | 
|---|
| 120 | void            _byte_extended_write( unsigned int   cluster, | 
|---|
| 121 | unsigned int   address, | 
|---|
| 122 | unsigned char  byte ); | 
|---|
| 123 | #endif | 
|---|
| 124 |  | 
|---|
| 125 | // Local Variables: | 
|---|
| 126 | // tab-width: 4; | 
|---|
| 127 | // c-basic-offset: 4; | 
|---|
| 128 | // c-file-offsets:((innamespace . 0)(inline-open . 0)); | 
|---|
| 129 | // indent-tabs-mode: nil; | 
|---|
| 130 | // End: | 
|---|
| 131 | // | 
|---|
| 132 | // vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=4:softtabstop=4 | 
|---|
| 133 |  | 
|---|