source: trunk/kernel/devices/dev_fbf.h@ 649

Last change on this file since 649 was 647, checked in by alain, 7 years ago

...miscelaneous...

File size: 6.7 KB
Line 
1/*
2 * dev_fbf.h - FBF (Block Device Controler) generic device API definition.
3 *
4 * Author Alain Greiner (2016,2017,2018,2019)
5 *
6 * Copyright (c) UPMC Sorbonne Universites
7 *
8 * This file is part of ALMOS-MKH
9 *
10 * ALMOS-MKH is free software; you can redistribute it and/or modify it
11 * under the terms of the GNU General Public License as published by
12 * the Free Software Foundation; version 2.0 of the License.
13 *
14 * ALMOS-MKH is distributed in the hope that it will be useful, but
15 * WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 * General Public License for more details.
18 *
19 * You should have received a copy of the GNU General Public License
20 * along with ALMOS-kernel; if not, write to the Free Software Foundation,
21 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
22 */
23
24#ifndef _DEV_FBF_H
25#define _DEV_FBF_H
26
27#include <hal_kernel_types.h>
28#include <shared_fbf.h>
29
30/**** Forward declarations ****/
31
32struct chdev_s;
33
34/*****************************************************************************************
35 * Generic Frame Buffer Controler definition
36 *
37 * This device provide access to an external graphic display, that is seen
38 * as a fixed size frame buffer, mapped in the kernel address space.
39 * The supported pixel encoding types are defined in the <shared_fbf.h> file.
40 *
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.
45 *
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.
53 *****************************************************************************************/
54
55/******************************************************************************************
56 * This defines the (implementation independant) extension for the generic FBF device.
57 *****************************************************************************************/
58
59typedef struct fbf_extend_s
60{
61 uint32_t width; /*! number of pixels per line. */
62 uint32_t height; /*! total number of lines. */
63 uint32_t subsampling; /*! pixel encoding type. */
64}
65fbf_extend_t;
66
67/******************************************************************************************
68 * This enum defines the various implementations of the generic FBF peripheral.
69 * It must be kept consistent with the define in arch_info.h file.
70 *****************************************************************************************/
71
72enum fbf_impl_e
73{
74 IMPL_FBF_SCL = 0,
75 IMPL_FBF_I86 = 1,
76}
77fbf_impl_t;
78
79typedef struct fbf_command_s
80{
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) */
87}
88fbf_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 );
98
99/******************************************************************************************
100 * This function completes the FBF chdev descriptor initialisation.
101 * It calls the specific driver initialisation function, to initialise the hardware
102 * device and the chdev extension. It must be called by a local thread.
103 ******************************************************************************************
104 * @ chdev : pointer on FBF chdev descriptor.
105 *****************************************************************************************/
106void dev_fbf_init( struct chdev_s * chdev );
107
108/******************************************************************************************
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.
112 ******************************************************************************************
113 * @ width : [out] number of pixels per line.
114 * @ height : [out] total number of lines.
115 * @ type : [out] pixel encoding type.
116 *****************************************************************************************/
117void dev_fbf_get_config( uint32_t * width,
118 uint32_t * height,
119 uint32_t * type );
120
121/******************************************************************************************
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.
128 ******************************************************************************************
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.
133 * @ returns 0 if success / returns EINVAL if error.
134 *****************************************************************************************/
135error_t dev_fbf_move_data( uint32_t cmd_type,
136 void * user_buffer,
137 uint32_t length,
138 uint32_t offset );
139
140#endif /* _DEV_FBF_H */
Note: See TracBrowser for help on using the repository browser.