Ignore:
Timestamp:
Oct 22, 2019, 1:48:51 PM (3 years ago)
Author:
alain
Message:

...miscelaneous...

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/kernel/devices/dev_fbf.h

    r483 r647  
    22 * dev_fbf.h - FBF (Block Device Controler) generic device API definition.
    33 *
    4  * Author  Alain Greiner    (2016)
     4 * Author  Alain Greiner    (2016,2017,2018,2019)
    55 *
    66 * Copyright (c) UPMC Sorbonne Universites
     
    2626
    2727#include <hal_kernel_types.h>
     28#include <shared_fbf.h>
    2829
    2930/****  Forward declarations  ****/
     
    3637 * This device provide access to an external graphic display, that is seen
    3738 * as a fixed size frame buffer, mapped in the kernel address space.
    38  * Each pixel takes one byte defining 256 levels of gray.
     39 * The supported  pixel encoding types are defined in the <shared_fbf.h> file.
    3940 *
    40  * It supports five command types:
    41  * - SIZE  : return the Frame buffer width and height.
    42  * - ALLOC : give exclusive ownership of the frame buffer to the requesting process.
    43  * - FREE  : release the exclusive ownership to the kernel.
    44  * - READ  : move a given number of bytes from the frame buffer to a memory buffer.
    45  * - WRITE : move a given number of bytes from a memory buffer to the frame buffer.
     41 * It supports three command types:
     42 * GET_CONFIG : return frame buffer size and type.
     43 * READ       : move bytes from frame buffer to memory / deschedule the calling thread.
     44 * WRITE      : move bytes from memory to frame buffer / deschedule the calling thread.
    4645 *
    47  * It does not creates the associated server thread.
    48  * - The SIZE, ALLOC, FREE commands are directly handled by the FBF device.
    49  * - The READ & WRITE commands are actually registered in the DMA device waiting queue,
    50  *   using the local DMA channel defined by the calling core lid.
     46 * The READ and WRITE operations do not use the FBF device waiting queue,
     47 * the server thread, and the IOC IRQ. The client thread does not deschedule:
     48 * it registers the command in the thread descriptor, and calls directly the FBF driver.
     49 * that makes a (user <-> kernel) memcpy.
     50 *
     51 * Note: As we don't use any external DMA to move data, but a purely software approach,
     52 * there is no L2/L3 coherence issue.
    5153 *****************************************************************************************/
    5254
     
    5759typedef struct fbf_extend_s
    5860{
    59     uint32_t           width;     /*! number of pixels per line.                         */
    60     uint32_t           height;    /*! total number of lines.                             */
     61    uint32_t           width;         /*! number of pixels per line.                     */
     62    uint32_t           height;        /*! total number of lines.                         */
     63    uint32_t           subsampling;   /*! pixel encoding type.                           */
    6164}
    6265fbf_extend_t;
     
    7174    IMPL_FBF_SCL =   0,     
    7275    IMPL_FBF_I86 =   1, 
    73 }
     76} 
    7477fbf_impl_t;
    75 
    76 /******************************************************************************************
    77  * This defines the (implementation independant)  command passed to the driver.
    78  *****************************************************************************************/
    7978
    8079typedef struct fbf_command_s
    8180{
    82     xptr_t      dev_xp;     /*! extended pointer on device descriptor                    */
    83     uint32_t    to_fbf;     /*! requested operation type.                                */
    84     uint32_t    length;     /*! number of bytes.                                         */
    85     uint32_t    offset;     /*! offset in frame buffer (bytes)                           */
    86     xptr_t      buf_xp;     /*! extended pointer on memory buffer                        */
    87     uint32_t    error;      /*! operation status (0 if success)                          */
     81    xptr_t      dev_xp;        /*! extended pointer on device descriptor                 */
     82    uint32_t    type;          /*! requested operation type.                             */
     83    uint32_t    length;        /*! number of bytes.                                      */
     84    uint32_t    offset;        /*! offset in frame buffer (bytes)                        */
     85    void      * buffer;        /*! pointer on memory buffer in user space                */
     86    uint32_t    error;         /*! operation status (0 if success)                       */
    8887}
    8988fbf_command_t;
     89
     90
     91/******************************************************************************************
     92 * This function returns a printable string for a given FBF command  <cmd_type>.
     93 ******************************************************************************************
     94 * @ cmd_type   :  FBF command type (defined in shared_fbf.h file).
     95 * @ returns a string pointer.
     96 *****************************************************************************************/
     97char * dev_fbf_cmd_str( uint32_t cmd_type );
    9098
    9199/******************************************************************************************
    92100 * This function completes the FBF chdev descriptor initialisation.
    93101 * It calls the specific driver initialisation function, to initialise the hardware
    94  * device and the specific data structures when required by the implementation.
    95  * It must be called by a local thread.
    96  *
    97  * TODO In this first approach, the "width" and "height" parameters are defined
    98  * by the CONFIG_FBF_WIDTH & CONFIG_FBF_HEIGHT in the kernel_config.h file.
    99  * These parameters should be provided by the driver, accessing dedicated
    100  * adressable registers in the FBF controler.
     102 * device and the chdev extension. It must be called by a local thread.
    101103 ******************************************************************************************
    102104 * @ chdev      : pointer on FBF chdev descriptor.
     
    105107
    106108/******************************************************************************************
    107  * This function returns the fixed size frame buffer features.
     109 * This function returns the frame buffer size and type.
     110 * It does NOT access the hardware, as the size and type have been registered
     111 * in the chdev descriptor extension.
    108112 ******************************************************************************************
    109  * @ width     : number of pixels (bytes) per line.
    110  * @ heigth    : total number of lines.
     113 * @ width     : [out] number of pixels per line.
     114 * @ height    : [out] total number of lines.
     115 * @ type      : [out] pixel encoding type.
    111116 *****************************************************************************************/
    112 void dev_fbf_get_size( uint32_t  * width,
    113                        uint32_t  * height );
     117void dev_fbf_get_config( uint32_t  * width,
     118                         uint32_t  * height,
     119                         uint32_t  * type );
    114120
    115121/******************************************************************************************
    116  * This function try to get the exclusive ownership of the frame buffer.
     122 * This blocking function moves <length> bytes between the frame buffer, starting from
     123 * byte defined by <offset>, and an user buffer defined by the <user_buffer> argument.
     124 * It can be called by a client thread running in any cluster.
     125 * The transfer direction are defined by the <cmd_type> argument.
     126 * The request is registered in the client thread descriptor, but the client thread is
     127 * not descheduled, and calls directly the FBF driver.
    117128 ******************************************************************************************
    118  * @ return 0 if success / return EINVAL if frame buffer already allocated.
    119  *****************************************************************************************/
    120 error_t dev_fbf_alloc( void );
    121 
    122 /******************************************************************************************
    123  * This function releases the exclusive ownership of the frame buffer.
    124  *****************************************************************************************/
    125 void dev_fbf_free( void );
    126 
    127 /******************************************************************************************
    128  * This blocking function try to tranfer <length> bytes from the frame buffer, starting
    129  * from <offset>, to the memory buffer defined by <buffer> argument.
    130  * The corresponding request is actually registered in the local DMA device waiting
    131  * queue that has the same index as the calling core. The calling thread is descheduled,
    132  * waiting on transfer completion. It will be resumed by the DMA IRQ signaling completion.
    133  ******************************************************************************************
    134  * @ buffer    : local pointer on target buffer in memory.
    135  * @ length    : number of bytes.
    136  * @ offset    : first byte in frame buffer.   
     129 * @ cmd_type    : FBF_READ / FBF_WRITE / FBF_SYNC_READ / FBF_SYN_WRITE.
     130 * @ user_buffer : pointer on memory buffer in user space.
     131 * @ length      : number of bytes.
     132 * @ offset      : first byte in frame buffer.   
    137133 * @ returns 0 if success / returns EINVAL if error.
    138134 *****************************************************************************************/
    139 error_t dev_fbf_read( char         * buffer,
    140                       uint32_t       length,
    141                       uint32_t       offset );
    142 
    143 /******************************************************************************************
    144  * This blocking function try to tranfer <length> bytes from a memory buffer defined
    145  * by <buffer> argument, to the frame buffer, starting from <offset>.
    146  * The corresponding request is actually registered in the local DMA device waiting
    147  * queue, that has the same index as the calling core. The calling thread is descheduled,
    148  * waiting on transfer completion. It will be resumed by the DMA IRQ signaling completion.
    149  ******************************************************************************************
    150  * @ buffer    : local pointer on source buffer in memory.
    151  * @ length    : number of bytes.
    152  * @ offset    : first byte in frame buffer.   
    153  * @ returns 0 if success / returns EINVAL if error.
    154  *****************************************************************************************/
    155 error_t dev_fbf_write( char         * buffer,
    156                        uint32_t       length,
    157                        uint32_t       offset );
     135error_t dev_fbf_move_data( uint32_t   cmd_type,
     136                           void     * user_buffer,
     137                           uint32_t   length,
     138                           uint32_t   offset );
    158139
    159140#endif  /* _DEV_FBF_H */
Note: See TracChangeset for help on using the changeset viewer.