Changeset 49


Ignore:
Timestamp:
Jun 26, 2017, 1:40:02 PM (8 years ago)
Author:
max@…
Message:

style

Location:
trunk/kernel/devices
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/kernel/devices/dev_txt.c

    r23 r49  
    11/*
    22 * dev_txt.c - TXT (Text Terminal) generic device API implementation.
    3  * 
     3 *
    44 * Author  Alain Greiner    (2016)
    55 *
     
    4343{
    4444    // the local ICU chdev must be initialized before the TXT chdev, because
    45     // the TXT chdev initialisation requires allocation of a WTI from local ICU
     45    // the TXT chdev initialization requires allocation of a WTI from local ICU
    4646    xptr_t  icu_xp  = chdev_dir.icu[local_cxy];
    4747    assert( (icu_xp != XPTR_NULL) , __FUNCTION__ , "ICU not initialised before TXT" );
     
    7777    dev_icu_enable_irq( lid , WTI_TYPE , wti_id , chdev );
    7878
    79     // link IOC IRQ to WTI mailbox in PIC component 
     79    // link IOC IRQ to WTI mailbox in PIC component
    8080    uint32_t irq_id = chdev_pic_input.txt[channel];
    8181    dev_pic_bind_irq( irq_id , local_cxy , wti_id );
     
    8989                                  &chdev_sequencial_server,
    9090                                  chdev,
    91                                   lid ); 
     91                                  lid );
    9292    assert( (error == 0) , __FUNCTION__ , "cannot create server thread" );
    9393
    9494    // set "server" field in chdev descriptor
    9595    chdev->server = new_thread;
    96    
     96
    9797    // start server thread
    9898    thread_unblock( XPTR( local_cxy , new_thread ) , THREAD_BLOCKED_GLOBAL );
    99 
    100 } // end dev_txt_init()
    101 
     99}
    102100
    103101//////////////////////////////////////////////////////////////////////////////////
     
    111109    thread_t * this = CURRENT_THREAD;
    112110
    113     txt_dmsg("\n[INFO] in %s : thread %x in process %x enters\n", 
     111    txt_dmsg("\n[INFO] in %s : thread %x in process %x enters\n",
    114112                 __FUNCTION__ , this->trdid , this->process->pid );
    115113
     
    133131    chdev_register_command( dev_xp , this );
    134132
    135     txt_dmsg("\n[INFO] in %s : thread %x in process %x completes / error = %d\n", 
     133    txt_dmsg("\n[INFO] in %s : thread %x in process %x completes / error = %d\n",
    136134             __FUNCTION__ , this->trdid , this->process->pid , this->command.txt.error );
    137135
    138136    // return I/O operation status from calling thread descriptor
    139     return this->command.txt.error; 
    140 
    141 }  // end dev_txt_access()
     137    return this->command.txt.error;
     138}
    142139
    143140/////////////////////////////////////////
     
    148145    return dev_txt_access( TXT_WRITE , channel , buffer , count );
    149146}
    150  
     147
    151148/////////////////////////////////////////
    152149error_t dev_txt_read( uint32_t   channel,
     
    161158                            uint32_t   count )
    162159{
    163     // get pointer on calling thread 
     160    // get pointer on calling thread
    164161    thread_t * this = CURRENT_THREAD;
    165162
    166     // get extended pointer on TXT[0] chdev 
     163    // get extended pointer on TXT[0] chdev
    167164    xptr_t  dev_xp = chdev_dir.txt[channel];
    168165
    169166    assert( (dev_xp != XPTR_NULL) , __FUNCTION__ , "undefined TXT0 chdev descriptor" );
    170167
    171     // register command in calling thread 
     168    // register command in calling thread
    172169    this->command.txt.dev_xp  = dev_xp;
    173170    this->command.txt.type    = TXT_SYNC_WRITE;
     
    175172    this->command.txt.count   = count;
    176173
    177     // get driver command function 
     174    // get driver command function
    178175    cxy_t       dev_cxy = GET_CXY( dev_xp );
    179176    chdev_t   * dev_ptr = (chdev_t *)GET_PTR( dev_xp );
    180177    dev_cmd_t * cmd = (dev_cmd_t *)hal_remote_lpt( XPTR( dev_cxy , &dev_ptr->cmd ) );
    181178
    182     // call directly driver command 
     179    // call directly driver command
    183180    cmd( XPTR( local_cxy , this ) );
    184181
    185182    // return I/O operation status from calling thread descriptor
    186183    return this->command.txt.error;
    187  
    188 }  // end dev_txt_sync_write()
     184}
    189185
  • trunk/kernel/devices/dev_txt.h

    r23 r49  
    11/*
    22 * dev_txt.h - TXT (Text Terminal) generic device API definition.
    3  * 
     3 *
    44 * Author  Alain Greiner    (2016)
    55 *
     
    3535 *     Generic Text Terminal device definition.
    3636 *
    37  * This multi-channels generic TXT device provide access to a text terminal.
     37 * This multi-channels generic TXT device provides access to a text terminal.
    3838 * It supports three operation types :
    3939 * - TXT_READ : read a single character from the text terminal identified by its channel
     
    4242 *   index, using a descheduling strategy for the calling thread.
    4343 * - TXT_SYNC_WRITE : write a character string to the terminal identified by its channel
    44  *   index, using a busy waiting strategy for the calling thread. 
     44 *   index, using a busy waiting strategy for the calling thread.
    4545 *****************************************************************************************/
    4646
     
    5252enum txt_impl_e
    5353{
    54     IMPL_TXT_TTY =   0,     
    55     IMPL_TXT_X86 =   1, 
     54    IMPL_TXT_TTY =   0,
     55    IMPL_TXT_X86 =   1,
    5656}
    5757txt_impl_t;
    5858
    5959/******************************************************************************************
    60  * This defines the (implementation independant) command passed to the driver.
     60 * This defines the (implementation independent) command passed to the driver.
    6161 *****************************************************************************************/
    6262
     
    8080/******************************************************************************************
    8181 * This function completes the TXT chdev descriptor initialisation,
    82 i * namely the link with the implementation specific driver.
     82 * namely the link with the implementation specific driver.
    8383 * The func, impl, channel, is_rxt, base fields have been previously initialised.
    8484 * It calls the specific driver initialisation function, to initialise the hardware
     
    9292
    9393/******************************************************************************************
    94  * This blocking function read a single character from the terminal identified
     94 * This blocking function reads a single character from the terminal identified
    9595 * by the "channel" argument. The corresponding request is actually registered in the
    9696 * chdev requests queue, and the calling thread is descheduled, blocked until
     
    106106
    107107/******************************************************************************************
    108  * This blocking function writes  characters on the terminal identified
     108 * This blocking function writes characters on the terminal identified
    109109 * by the "channel" argument. The corresponding request is actually registered in the
    110110 * chdev requests queue, and the calling thread is descheduled, blocked until
     
    121121                       uint32_t        count );
    122122
    123  /***************************************************************************************
    124  * This low-level blocking function is used by the kernel to display one string on a 
    125  * given TXT channel without descheduling the calling thread,  without registering it
    126  * in the TXT device waiting queue, and without using the TXT irq. 
     123/***************************************************************************************
     124 * This low-level blocking function is used by the kernel to display one string on a
     125 * given TXT channel without descheduling the calling thread, without registering it
     126 * in the TXT device waiting queue, and without using the TXT irq.
    127127 ****************************************************************************************
    128128 * @ channel   : TXT channel index.
     
    135135                            uint32_t   count );
    136136
    137 
    138137#endif  /* _DEV_TXT_H_ */
Note: See TracChangeset for help on using the changeset viewer.