Changeset 647 for trunk/kernel/devices/dev_fbf.h
- Timestamp:
- Oct 22, 2019, 1:48:51 PM (4 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/kernel/devices/dev_fbf.h
r483 r647 2 2 * dev_fbf.h - FBF (Block Device Controler) generic device API definition. 3 3 * 4 * Author Alain Greiner (2016 )4 * Author Alain Greiner (2016,2017,2018,2019) 5 5 * 6 6 * Copyright (c) UPMC Sorbonne Universites … … 26 26 27 27 #include <hal_kernel_types.h> 28 #include <shared_fbf.h> 28 29 29 30 /**** Forward declarations ****/ … … 36 37 * This device provide access to an external graphic display, that is seen 37 38 * 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. 39 40 * 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. 46 45 * 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. 51 53 *****************************************************************************************/ 52 54 … … 57 59 typedef struct fbf_extend_s 58 60 { 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. */ 61 64 } 62 65 fbf_extend_t; … … 71 74 IMPL_FBF_SCL = 0, 72 75 IMPL_FBF_I86 = 1, 73 } 76 } 74 77 fbf_impl_t; 75 76 /******************************************************************************************77 * This defines the (implementation independant) command passed to the driver.78 *****************************************************************************************/79 78 80 79 typedef struct fbf_command_s 81 80 { 82 xptr_t dev_xp; /*! extended pointer on device descriptor*/83 uint32_t t o_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) */ 88 87 } 89 88 fbf_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 *****************************************************************************************/ 97 char * dev_fbf_cmd_str( uint32_t cmd_type ); 90 98 91 99 /****************************************************************************************** 92 100 * This function completes the FBF chdev descriptor initialisation. 93 101 * 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. 101 103 ****************************************************************************************** 102 104 * @ chdev : pointer on FBF chdev descriptor. … … 105 107 106 108 /****************************************************************************************** 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. 108 112 ****************************************************************************************** 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. 111 116 *****************************************************************************************/ 112 void dev_fbf_get_size( uint32_t * width, 113 uint32_t * height ); 117 void dev_fbf_get_config( uint32_t * width, 118 uint32_t * height, 119 uint32_t * type ); 114 120 115 121 /****************************************************************************************** 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. 117 128 ****************************************************************************************** 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. 137 133 * @ returns 0 if success / returns EINVAL if error. 138 134 *****************************************************************************************/ 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 ); 135 error_t dev_fbf_move_data( uint32_t cmd_type, 136 void * user_buffer, 137 uint32_t length, 138 uint32_t offset ); 158 139 159 140 #endif /* _DEV_FBF_H */
Note: See TracChangeset
for help on using the changeset viewer.