Ignore:
Timestamp:
Jan 29, 2014, 9:30:38 AM (9 years ago)
Author:
alain
Message:

Introducing a minimal GIET:

  • no virtual memory
  • no conyext switch
  • no system calls
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////////////////////////////////////////////////////////////////////////////////////////
    631
    7 #ifndef _STDIO_H_
    8 #define _STDIO_H_
     32#ifndef _GIET_STDIO_H_
     33#define _GIET_STDIO_H_
    934
    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>
    2639
    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
     40typedef unsigned int    size_t;
    3741
    38 typedef unsigned int size_t;
     42// global variables defined in stdio.c
    3943
    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);
     44extern  int volatile    _ioc_lock;
     45extern  int volatile    _ioc_done;
     46extern  int volatile    _ioc_status;
    5147
    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();
     48extern  char volatile   _tty_get_buf[];
     49extern  int volatile    _tty_get_full[];
    6050
    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,...);
     51extern int volatile     _barrier_value[];
     52extern int volatile     _barrier_count[];
     53extern int volatile     _barrier_lock[];
    7254
    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);
     55extern int volatile     _spin_lock[];
    8056
    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
    8958
    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);
     59void*           _memcpy( void* dst, const void* src, size_t size );
    9860
    99 /****************************************************************
    100   These functions access the LOCKS peripheral
    101  ****************************************************************/
    102 int lock_acquire(int lock_index);
    103 int lock_release(int lock_index);
     61unsigned int    _procid();
     62unsigned int    _proctime();
     63unsigned int    _procnumber();
    10464
    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();
     65void            _it_mask();
     66void            _it_enable();
    11167
    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);
     68void            _dcache_buf_invalidate( const void* buffer, size_t size );
    12069
    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);
     70void            _exit();
     71
     72void            _itoa_dec( unsigned int val, char* buf );
     73void            _itoa_hex( unsigned int val, char* buf );
     74
     75int             _tty_write( char* buffer, size_t length, size_t channel );
     76int             _tty_read( char* buffer, size_t channel );
     77void            _tty_puts( char* string );
     78void            _tty_putd( unsigned int val );
     79void            _tty_putx( unsigned int val );
     80void            _tty_get_lock( size_t channel );
     81void            _tty_release_lock( size_t channel );
     82void            _tty_getc( char* buffer );
     83void            _tty_getw( unsigned int* buffer );
     84void            _tty_printf( char* format, ... );
     85
     86void            _ioc_get_lock();
     87void            _ioc_write( size_t lba, void* buffer, size_t count, size_t ext );
     88void            _ioc_read (size_t lba, void* buffer, size_t count, size_t ext );
     89void            _ioc_completed();
     90void            _ioc_isr();
     91
     92void            _mmc_isr();
     93
     94void            _fb_sync_write( size_t offset, void* buffer, size_t length, size_t ext );
     95void            _fb_sync_read( size_t offset, void* buffer, size_t length, size_t ext );
     96
     97void            _release_lock( size_t lock_index );
     98void            _get_lock( size_t lock_index );
     99
     100void            _barrier_init(size_t index, size_t count);
     101void            _barrier_wait(size_t index);
    126102
    127103#endif
Note: See TracChangeset for help on using the changeset viewer.