Ignore:
Timestamp:
Mar 18, 2020, 11:16:59 PM (4 years ago)
Author:
alain
Message:

Introduce remote_buf.c/.h & socket.c/.h files.
Update dev_nic.c/.h files.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/kernel/kern/chdev.h

    r625 r657  
    11/*
    2  * chdev.h - channel device (chdev) descriptor definition.
     2 * chdev.h - channel device (chdev) descriptor and API definition.
    33 *
    4  * Authors  Alain Greiner    (2016)
     4 * Authors  Alain Greiner    (2016,2017,2018,2019,2020)
    55 *
    66 * Copyright (c) UPMC Sorbonne Universites
     
    3636#include <dev_txt.h>
    3737
    38 /******************************************************************************************
     38/****************************************************************************************
    3939 *       Channel Device descriptor definition
    4040 *
     
    4242 * independant) Channel Device descriptor (in brief "chdev").
    4343 * ALMOS-MKH supports multi-channels peripherals, and defines one separated chdev
    44  * descriptor for each channel (and for each RX/TX direction for the NIC and TXT devices).
     44 * descriptor for each channel (and for each RX/TX direction for NIC and TXT devices).
    4545 * Each chdev contains a trans-clusters waiting queue, registering the "client threads",
    4646 * and an associated "server thread", handling these requests.
     
    5050 * - the server cluster, containing the chdev and the server thread,
    5151 * - the I/O cluster, containing the physical device.
    52  *****************************************************************************************/
     52 ***************************************************************************************/
    5353
    5454/****  Forward declarations  ****/
     
    5858struct  boot_info_s;
    5959
    60 /******************************************************************************************
    61  * These macros extract the functionality and the implementation from the peripheral type.
    62  *****************************************************************************************/
     60/****************************************************************************************
     61 * These macros extract functionality and implementation from the peripheral type.
     62 ***************************************************************************************/
    6363 
    6464#define FUNC_FROM_TYPE( type )    ((uint32_t)(type>>16))
    6565#define IMPL_FROM_TYPE( type )    ((uint32_t)(type & 0x0000FFFF))
    6666
    67 /******************************************************************************************
     67/****************************************************************************************
    6868 * This define the generic prototypes for the three functions that must be defined
    6969 * by the drivers implementing a generic device:
     
    7373 * The "cmd", "isr", and "aux" driver functions are registered in the generic chdev
    7474 * descriptor at kernel init, and are called to start and complete an I/O operation. 
    75 *****************************************************************************************/
     75***************************************************************************************/
    7676
    7777typedef void (dev_ini_t) ( xptr_t dev );     
     
    8080typedef void (dev_aux_t) ( void * args ); 
    8181
    82 /******************************************************************************************
     82/****************************************************************************************
    8383 * This enum defines the supported generic device types.
    8484 * These types are functionnal types: all (architecture specific) implementations
     
    8989 *           distributed LAPIC controler, but it does not exist as a chdev in the kernel,
    9090 *           as it is hidden in the driver associated to the PIC device.
    91  *****************************************************************************************/
     91 ***************************************************************************************/
    9292 
    9393enum dev_func_type
     
    116116 * For each device type ***, the specific extension is defined in the "dev_***.h" file.
    117117 *
    118  * NOTE : For most chdevs, the busylock is used to protect the waiting queue changes,
     118 * NOTE . For most chdevs, the busylock is used to protect the waiting queue changes,
    119119 *        when a thread register in this queue, or is removed after service.
    120  *        This busylock is also used to protect direct access to the kernel TXT0 terminal
    121  *        (without using the server thread).
     120 *      . This busylock is also used to protect direct access to the shared
     121 *        kernel TXT0 terminal, that does not use the waiting queue.
     122 *      . For the NIC chdevs it is also used to protect registration (or removal) of a
     123 *        socket in the list of attached sockets rooted in NIC device extension.
    122124 *****************************************************************************************/
    123125
     
    125127{
    126128        uint32_t             func;        /*! peripheral functionnal type                    */
    127         uint32_t             impl;        /*! peripheral inplementation subtype              */
     129        uint32_t             impl;        /*! peripheral implementation type                 */
    128130    uint32_t             channel;     /*! channel index                                  */
    129131    bool_t               is_rx;       /*! relevant for NIC and TXT peripherals           */
     
    185187chdev_directory_t;
    186188
    187 /******************************************************************************************
     189/****************************************************************************************
    188190 * This function display relevant values for a chdev descriptor.
    189  ******************************************************************************************
     191 ****************************************************************************************
    190192 * @ chdev   : pointer on chdev.
    191  *****************************************************************************************/
     193 ***************************************************************************************/
    192194void chdev_print( chdev_t * chdev );
    193195
    194 /******************************************************************************************
     196/****************************************************************************************
    195197 * This function returns a printable string for a device functionnal types.
    196  ******************************************************************************************
     198 ****************************************************************************************
    197199 * @ func_type  : functionnal type.
    198200 * @ return pointer on string.
    199  *****************************************************************************************/
     201 ***************************************************************************************/
    200202char * chdev_func_str( uint32_t func_type );
    201203
    202 /******************************************************************************************
     204/****************************************************************************************
    203205 * This  function allocates memory and initializes a chdev descriptor in local cluster,
    204206 * from arguments values.  It should be called by a local thread.
    205207 * The device specific fields are initialised later.
    206  ******************************************************************************************
     208 ****************************************************************************************
    207209 * @ func      : functionnal type.
    208210 * @ impl      : implementation type.
     
    211213 * @ base      : extended pointer on peripheral segment base.
    212214 * @ return a local pointer on created chdev / return NULL if failure.
    213  *****************************************************************************************/
     215 ***************************************************************************************/
    214216chdev_t * chdev_create( uint32_t    func,
    215217                        uint32_t    impl,
     
    218220                        xptr_t      base );
    219221
    220 /******************************************************************************************
    221  * This function registers the calling thread in the waiting queue of a remote
    222  * chdev descriptor, activates (i.e. unblock) the server thread associated to chdev,
    223  * and blocks itself on the THREAD_BLOCKED_IO condition.
    224  ******************************************************************************************
     222/****************************************************************************************
     223 * This generid function is executed by an user thread requesting an IOC or TXT chdev
     224 * service. It registers the calling thread in the waiting queue of a the remote
     225 * chdev descriptor identified by the <chdev_xp> argument.
     226 * It activates (i.e. unblocks) the server thread associated to chdev, blocks itself,
     227 * and deschedule.  It is supposed to be re-activated by the server thread.
     228 * It can be called by a thread running in any cluster.
     229 * It cannot be used for a NIC or FBF chdev, because it is only convenient for one shot
     230 * I/O operations, as the server thread removes the client thread from the waiting
     231 * queue when it starts to execute the command.
     232 ****************************************************************************************
     233 * Implementation Note:
     234 * The following actions are executed in a critical section, thanks to the
     235 * busylock_acquire / busylock_release mechanism :
     236 * 1) it takes the lock protecting the waiting queue.
     237 * 2) it registers client thread in the server queue.
     238 * 3) it unblocks the server thread from the THREAD_BLOCKED_CLIENT condition.
     239 * 4) it blocks the client thread on the THREAD_BLOCKED_IO condition.
     240 * 5) it send an IPI to the core running the server thread to force scheduling.
     241 * 6) it releases the lock protecting waiting queue.
     242 * 7) it deschedules.
     243 ****************************************************************************************
    225244 * @ chdev_xp  : extended pointer on remote chdev descriptor.
    226  *****************************************************************************************/
     245 ***************************************************************************************/
    227246void chdev_register_command( xptr_t chdev_xp );
    228247
    229 /******************************************************************************************
    230  * This function is executed by the server thread associated to a chdev descriptor.
    231  * It executes an infinite loop to handle sequencially all commands registered by the
    232  * client threads in the device waiting queue, until the queue is empty.
    233  * The driver CMD function being blocking, these functions return only when the command
     248/****************************************************************************************
     249 * This generic function is executed by the server thread associated to an IOC or TXT
     250 * chdev identified by the <chdev> argument, to execute all commands registered in the
     251 * waiting queue attached to this chev.
     252 * When the clients queue is empty, the server thread blocks on the THREAD_BLOCKED_CLIENT
     253 * condition and deschedules. It is supposed to be re-activated by a client thread
     254 * registering a new command.
     255 * It cannot be used for a NIC or FBF chdev, because it is only convenient for one shot
     256 * I/O operations, as the server thread removes the client thread from the waiting
     257 * queue when it starts to execute the command.
     258 ****************************************************************************************
     259 * Implementation Note:
     260 * All driver CMD functions are supposed to be blocking, and return only when the command
    234261 * is completed. These functions can use either a busy waiting policy, or a descheduling
    235  * policy, blocking on the THREAD_BLOCKED_IO_ISR condition, and reactivated by the ISR.
    236  * When the waiting queue is empty, the server thread blocks on the THREAD_BLOCKED_IO_CMD
    237  * condition and deschedule. It is re-activated by a client thread registering a command.
    238  ******************************************************************************************
     262 * policy, blocking on the THREAD_BLOCKED_ISR condition. In the descheduling scenario,
     263 * the server thread is supposed to be reactivated by the ISR attached to the hardware
     264 * interrupts signaling command completion.
     265 ****************************************************************************************
    239266 * @ chdev   : local pointer on device descriptor.
    240  *****************************************************************************************/
     267 ***************************************************************************************/
    241268void chdev_server_func( chdev_t * chdev );
    242269
    243 /******************************************************************************************
     270/****************************************************************************************
    244271 * This function returns an extended pointer on the chdev associated to a pseudo file
    245272 * descriptor (type INODE_TYPE_DEV) identified by the <file_xp> argument.
    246273 * It can be called by a thread running in any cluster.
    247274 * It enters kernel panic if the inode has not the expected type.
    248  ******************************************************************************************
     275 ****************************************************************************************
    249276 * @ file_xp   : extended pointer on the pseudo file descriptor.
    250277 * @ return an extended pointer on chdev.
    251  *****************************************************************************************/
     278 ***************************************************************************************/
    252279xptr_t chdev_from_file( xptr_t file_xp );
    253280
    254 /******************************************************************************************
     281/****************************************************************************************
    255282 * This function displays the local copy of the external chdevs directory.
    256283 * (global variable replicated in all clusters)
    257  *****************************************************************************************/
     284 ***************************************************************************************/
    258285void chdev_dir_display( void );
    259286
    260 /******************************************************************************************
     287/****************************************************************************************
    261288 * This function displays the list of threads registered in the queue associated
    262289 * to the chdev identified by the <chdev_xp>.
    263  ******************************************************************************************
     290 ****************************************************************************************
    264291 * # root_xp  : extended pointer
    265  *****************************************************************************************/
     292 ***************************************************************************************/
    266293void chdev_queue_display( xptr_t chdev_xp );
    267294
Note: See TracChangeset for help on using the changeset viewer.