| 1 | /////////////////////////////////////////////////////////////////////////////////// | 
|---|
| 2 | // File     : tty_driver.h | 
|---|
| 3 | // Date     : 01/11/2013 | 
|---|
| 4 | // Author   : alain greiner | 
|---|
| 5 | // Copyright (c) UPMC-LIP6 | 
|---|
| 6 | /////////////////////////////////////////////////////////////////////////////////// | 
|---|
| 7 | // The tty_driver.c and tty_drivers.h files are part ot the GIET-VM kernel. | 
|---|
| 8 | // This driver supports the SocLib vci_multi_tty component. | 
|---|
| 9 | // | 
|---|
| 10 | // The total number of TTY terminals must be defined by the configuration | 
|---|
| 11 | // parameter NB_TTY_CHANNELS in the hard_config.h file. | 
|---|
| 12 | // | 
|---|
| 13 | // The "system" terminal is TTY[0]. | 
|---|
| 14 | // The "user" TTYs are allocated to applications requesting it. | 
|---|
| 15 | // | 
|---|
| 16 | // The SEG_TTY_BASE address must be defined in the hard_config.h file. | 
|---|
| 17 | // | 
|---|
| 18 | // All physical accesses to device registers are done by the two | 
|---|
| 19 | // _tty_get_register(), _tty_set_register() low-level functions, | 
|---|
| 20 | // that are handling virtual / physical addressing. | 
|---|
| 21 | /////////////////////////////////////////////////////////////////////////////////// | 
|---|
| 22 |  | 
|---|
| 23 | #ifndef _GIET_TTY_DRIVERS_H_ | 
|---|
| 24 | #define _GIET_TTY_DRIVERS_H_ | 
|---|
| 25 |  | 
|---|
| 26 | #include "locks.h" | 
|---|
| 27 |  | 
|---|
| 28 | /////////////////////////////////////////////////////////////////////////////////// | 
|---|
| 29 | //                     registers offsets | 
|---|
| 30 | /////////////////////////////////////////////////////////////////////////////////// | 
|---|
| 31 |  | 
|---|
| 32 | enum TTY_registers | 
|---|
| 33 | { | 
|---|
| 34 | TTY_WRITE   = 0, | 
|---|
| 35 | TTY_STATUS  = 1, | 
|---|
| 36 | TTY_READ    = 2, | 
|---|
| 37 | TTY_CONFIG  = 3, | 
|---|
| 38 | /**/ | 
|---|
| 39 | TTY_SPAN    = 4, | 
|---|
| 40 | }; | 
|---|
| 41 |  | 
|---|
| 42 | //////////////////////////////////////////////////////////////////////////////////// | 
|---|
| 43 | //               global variables | 
|---|
| 44 | //////////////////////////////////////////////////////////////////////////////////// | 
|---|
| 45 |  | 
|---|
| 46 | extern simple_lock_t  _tty_tx_lock[]; | 
|---|
| 47 |  | 
|---|
| 48 | extern unsigned int   _tty_rx_buf[]; | 
|---|
| 49 | extern unsigned int   _tty_rx_full[]; | 
|---|
| 50 |  | 
|---|
| 51 | ////////////////////////////////////////////////////////////////////////////////// | 
|---|
| 52 | //                    access functions | 
|---|
| 53 | ////////////////////////////////////////////////////////////////////////////////// | 
|---|
| 54 |  | 
|---|
| 55 | extern unsigned int _tty_get_register( unsigned int channel, | 
|---|
| 56 | unsigned int index ); | 
|---|
| 57 |  | 
|---|
| 58 | extern void _tty_set_register( unsigned int channel, | 
|---|
| 59 | unsigned int index, | 
|---|
| 60 | unsigned int value ); | 
|---|
| 61 |  | 
|---|
| 62 | extern void _tty_init( unsigned int channel ); | 
|---|
| 63 |  | 
|---|
| 64 | ////////////////////////////////////////////////////////////////////////////////// | 
|---|
| 65 | //                 Interrupt Service Routine | 
|---|
| 66 | /////////////////////////////////////////////////////////////////////////////////// | 
|---|
| 67 |  | 
|---|
| 68 | extern void _tty_rx_isr( unsigned int irq_type, | 
|---|
| 69 | unsigned int irq_id, | 
|---|
| 70 | unsigned int channel ); | 
|---|
| 71 |  | 
|---|
| 72 | extern void _tty_tx_isr( unsigned int irq_type, | 
|---|
| 73 | unsigned int irq_id, | 
|---|
| 74 | unsigned int channel ); | 
|---|
| 75 |  | 
|---|
| 76 |  | 
|---|
| 77 | #endif | 
|---|
| 78 |  | 
|---|
| 79 | // Local Variables: | 
|---|
| 80 | // tab-width: 4 | 
|---|
| 81 | // c-basic-offset: 4 | 
|---|
| 82 | // c-file-offsets:((innamespace . 0)(inline-open . 0)) | 
|---|
| 83 | // indent-tabs-mode: nil | 
|---|
| 84 | // End: | 
|---|
| 85 | // vim: filetype=c:expandtab:shiftwidth=4:tabstop=4:softtabstop=4 | 
|---|
| 86 |  | 
|---|