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

...miscelaneous...

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/hal/tsar_mips32/drivers/soclib_fbf.c

    r75 r647  
    22 * soclib_fbf.c - soclib frame-buffer driver implementation.
    33 *
    4  * Author Alain greiner (2016)
     4 * Author Alain greiner (2016,2017,2018,2019)
    55 *
    66 * Copyright (c) UPMC Sorbonne Universites
     
    2222 */
    2323
     24#include <soclib_fbf.h>
     25#include <hal_kernel_types.h>
     26#include <hal_uspace.h>
     27#include <chdev.h>
     28#include <dev_fbf.h>
     29#include <printk.h>
     30#include <thread.h>
     31
     32///////////////////////////////////////
     33void soclib_fbf_init( chdev_t * chdev )
     34{
     35    // set driver specific fields in FBF chdev
     36    chdev->cmd = &soclib_fbf_cmd;
     37    chdev->isr = NULL;
     38
     39    // get extended pointer on SOCLIB_FBF peripheral segment base
     40        xptr_t  base_xp = chdev->base;
     41
     42    // get cluster and local pointer for the SOCLIB_FBF peripheral segment
     43    cxy_t      base_cxy  = GET_CXY( base_xp );
     44    uint32_t * base_ptr  = GET_PTR( base_xp );
     45
     46    // get frame buffer width, height, and type 
     47        uint32_t width  = hal_remote_l32( XPTR( base_cxy , base_ptr + FBF_WIDTH_REG ) );
     48        uint32_t height = hal_remote_l32( XPTR( base_cxy , base_ptr + FBF_HEIGHT_REG ) );
     49    uint32_t type   = hal_remote_l32( XPTR( base_cxy , base_ptr + FBF_SUBSAMPLING_REG ) );
     50
     51    // set FBF chdev extension fields
     52    chdev->ext.fbf.width       = width;
     53    chdev->ext.fbf.height      = height;
     54    chdev->ext.fbf.subsampling = type;
     55
     56}  // end soclib_fbf_init()
     57
     58/////////////////////////////////////////////////////////////////
     59void __attribute__((noinline)) soclib_fbf_cmd( xptr_t thread_xp )
     60{
     61    uint32_t   cmd_type;    // READ / WRITE / SYNC_READ / SYNC_WRITE
     62    uint32_t   offset;
     63    uint32_t   length;
     64    void     * buffer;      // pointer on memory buffer in user space
     65    xptr_t     fbf_xp;
     66    uint32_t   status;      // I/0 operation status (from BDV)
     67
     68    // get client thread cluster and local pointer
     69    cxy_t      th_cxy = GET_CXY( thread_xp );
     70    thread_t * th_ptr = GET_PTR( thread_xp );
     71
     72#if (DEBUG_HAL_FBF|| DEBUG_HAL_FBF)
     73uint32_t    cycle        = (uint32_t)hal_get_cycles();
     74thread_t  * this         = CURRENT_THREAD;
     75process_t * process      = hal_remote_lpt( XPTR( th_cxy , &th_ptr->process ) );
     76pid_t       client_pid   = hal_remote_l32( XPTR( th_cxy , &process->pid ) );
     77trdid_t     client_trdid = hal_remote_l32( XPTR( th_cxy , &th_ptr->trdid ) );
     78#endif
     79
     80    // get command arguments
     81    cmd_type =         hal_remote_l32( XPTR( th_cxy , &th_ptr->fbf_cmd.type   ) );
     82    offset   =         hal_remote_l32( XPTR( th_cxy , &th_ptr->fbf_cmd.offset ) );
     83    length   =         hal_remote_l32( XPTR( th_cxy , &th_ptr->fbf_cmd.length ) );
     84    buffer   =         hal_remote_lpt( XPTR( th_cxy , &th_ptr->fbf_cmd.buffer ) );
     85    fbf_xp   = (xptr_t)hal_remote_l64( XPTR( th_cxy , &th_ptr->fbf_cmd.dev_xp ) );
     86
     87    // get cluster and local pointer on FBF chdev
     88    cxy_t     fbf_cxy = GET_CXY( fbf_xp );
     89    chdev_t * fbf_ptr = GET_PTR( fbf_xp );
     90
     91    // get extended pointer on SOCLIB_FBF peripheral segment base
     92        xptr_t  base_xp = (xptr_t)hal_remote_l64( XPTR( fbf_cxy , &fbf_ptr->base ) );
     93
     94    // execute command
     95    if( cmd_type == FBF_READ )     // use a (kernel -> user) memcpy
     96    {
     97
     98#if DEBUG_HAL_FBF
     99if( DEBUG_HAL_FBF < cycle )
     100printk("\n[%s] thread[%x,%x] / client[%x,%x] / READ / offset / length / buffer %x / cycle %d\n",
     101__FUNCTION__ , this->process->pid, this->trdid,  client_pid, client_trdid,
     102offset, length, buffer, cycle );
     103#endif
     104        hal_copy_to_uspace( buffer,
     105                            base_xp + offset,
     106                            length );
     107
     108    }
     109    else  // cmd_type == FBF_WRITE => use a (user -> kernel)  memcpy
     110    {
     111
     112#if DEBUG_HAL_FBF
     113if( DEBUG_HAL_FBF < cycle )
     114printk("\n[%s] thread[%x,%x] / client[%x,%x] / WRITE / offset / length / buffer %x / cycle %d\n",
     115__FUNCTION__ , this->process->pid, this->trdid, client_pid, client_trdid,
     116offset, length, buffer, cycle );
     117#endif
     118        hal_copy_from_uspace( base_xp + offset,
     119                              buffer,
     120                              length );
     121    }
     122
     123    // set success in command
     124    hal_remote_s32( XPTR( th_cxy , &th_ptr->fbf_cmd.error ) , 0 );
     125           
     126}  // end soclib_fbf_cmd()
     127
Note: See TracChangeset for help on using the changeset viewer.