OpenCores
URL https://opencores.org/ocsvn/openrisc/openrisc/trunk

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [rtos/] [ecos-3.0/] [packages/] [devs/] [framebuf/] [synth/] [current/] [src/] [gen_synthfb.tcl] - Blame information for rev 867

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 786 skrzyp
#!/usr/bin/env tclsh
2
 
3
#===============================================================================
4
#
5
#    gen_synthfb.tcl
6
#
7
#    Generate header files for all enabled synthetic target framebuffer devices.
8
#
9
#===============================================================================
10
# ####ECOSGPLCOPYRIGHTBEGIN####                                             
11
# -------------------------------------------                               
12
# This file is part of eCos, the Embedded Configurable Operating System.    
13
# Copyright (C) 2008 Free Software Foundation, Inc.                         
14
#
15
# eCos is free software; you can redistribute it and/or modify it under     
16
# the terms of the GNU General Public License as published by the Free      
17
# Software Foundation; either version 2 or (at your option) any later       
18
# version.                                                                  
19
#
20
# eCos is distributed in the hope that it will be useful, but WITHOUT       
21
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or     
22
# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License     
23
# for more details.                                                         
24
#
25
# You should have received a copy of the GNU General Public License         
26
# along with eCos; if not, write to the Free Software Foundation, Inc.,     
27
# 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.             
28
#
29
# As a special exception, if other files instantiate templates or use       
30
# macros or inline functions from this file, or you compile this file       
31
# and link it with other works to produce a work based on this file,        
32
# this file does not by itself cause the resulting work to be covered by    
33
# the GNU General Public License. However the source code for this file     
34
# must still be made available in accordance with section (3) of the GNU    
35
# General Public License v2.                                                
36
#
37
# This exception does not invalidate any other reasons why a work based     
38
# on this file might be covered by the GNU General Public License.          
39
# -------------------------------------------                               
40
# ####ECOSGPLCOPYRIGHTEND####                                               
41
#===============================================================================
42
######DESCRIPTIONBEGIN####
43
#
44
# Author(s):    bartv
45
# Date:         2005-10-28
46
#
47
# This script is invoked via a custom make rule to generate files
48
# <cyg/io/framebufs/synth_fb.h> and synth_fbs.c
49
#
50
#####DESCRIPTIONEND####
51
#===============================================================================
52
 
53
proc do_it { prefix } {
54
    set pkgconf_file    [file join $prefix "include/pkgconf/devs_framebuf_synth.h"]
55
    if { ! [file exists $pkgconf_file] } {
56
        puts stderr "gen_synthfb.tcl: missing configuration header $pkgconf_file"
57
        exit 1
58
    }
59
    set fd [open $pkgconf_file "r"]
60
    set data [read $fd]
61
    close $fd
62
 
63
    array set defines   [list]
64
    foreach line [split $data "\n"] {
65
        if { [regexp -- {^\#define[[:space:]]*([a-zA-Z_][a-zA-Z0-9_]*)[[:space:]]+([^[:space:]]+)$} $line junk symbol value] } {
66
            set defines($symbol) $value
67
        }
68
    }
69
 
70
    set data \
71
        "/*
72
 * File <cyg/io/framebufs/synth_fb.h>
73
 *
74
 * This is a generated file - do not edit!
75
 * It should not be \#include'd directly. Instead use <cyg/io/framebuf.h>
76
 */
77
 
78
#include <cyg/io/framebuf.inl>
79
 
80
"
81
 
82
    for { set fb 0 } { $fb < 4 } { incr fb } {
83
        if { ! [info exists defines(CYGPKG_DEVS_FRAMEBUF_SYNTH_FB[set fb])] } {
84
            continue
85
        }
86
 
87
        set width       $defines(CYGNUM_DEVS_FRAMEBUF_SYNTH_FB[set fb]_WIDTH)
88
        set height      $defines(CYGNUM_DEVS_FRAMEBUF_SYNTH_FB[set fb]_HEIGHT)
89
        set flags0  "(CYG_FB_FLAGS0_LINEAR_FRAMEBUFFER | \\\n    CYG_FB_FLAGS0_DOUBLE_BUFFER | \\\n"
90
        if { [info exists defines(CYGIMP_DEVS_FRAMEBUF_SYNTH_FB[set fb]_VIEWPORT) ] } {
91
            set viewport_width  $defines(CYGNUM_DEVS_FRAMEBUF_SYNTH_FB[set fb]_VIEWPORT_WIDTH)
92
            set viewport_height $defines(CYGNUM_DEVS_FRAMEBUF_SYNTH_FB[set fb]_VIEWPORT_HEIGHT)
93
            append flags0 "    CYG_FB_FLAGS0_VIEWPORT | \\\n"
94
        } else {
95
            set viewport_width  $width
96
            set viewport_height $height
97
        }
98
        if { [info exists defines(CYGNUM_DEVS_FRAMEBUF_SYNTH_FB[set fb]_PAGE_FLIPPING)] } {
99
            append flags0 "    CYG_FB_FLAGS0_PAGE_FLIPPING | \\\n"
100
        }
101
        set paletted            1
102
        switch -- $defines(CYGDAT_DEVS_FRAMEBUF_SYNTH_FB[set fb]_FORMAT) {
103
            1BPP_BE_PAL888 {
104
                set format          "CYG_FB_FORMAT_1BPP_PAL888"
105
                set suffix          "1BE"
106
                set depth           1
107
                set stride          [expr ($width + 7) >> 3]
108
            }
109
            1BPP_LE_PAL888 {
110
                append flags0   "    CYG_FB_FLAGS0_LE | \\\n"
111
                set format          "CYG_FB_FORMAT_1BPP_PAL888"
112
                set suffix          "1LE"
113
                set depth           1
114
                set stride          [expr ($width + 7) >> 3]
115
            }
116
            2BPP_BE_PAL888 {
117
                set format          "CYG_FB_FORMAT_2BPP_PAL888"
118
                set suffix          "2BE"
119
                set depth       2
120
                set stride          [expr ($width + 3) >> 2]
121
            }
122
            2BPP_LE_PAL888 {
123
                append flags0   "    CYG_FB_FLAGS0_LE | \\\n"
124
                set format          "CYG_FB_FORMAT_2BPP_PAL888"
125
                set suffix          "2LE"
126
                set depth           2
127
                set stride          [expr ($width + 3) >> 2]
128
            }
129
            4BPP_BE_PAL888 {
130
                set format          "CYG_FB_FORMAT_4BPP_PAL888"
131
                set suffix          "4BE"
132
                set depth           4
133
                set stride          [expr ($width + 1) >> 1]
134
            }
135
            4BPP_LE_PAL888 {
136
                append flags0   "    CYG_FB_FLAGS0_LE | \\\n"
137
                set format          "CYG_FB_FORMAT_4BPP_PAL888"
138
                set suffix          "4LE"
139
                set depth           4
140
                set stride          [expr ($width + 1) >> 1]
141
            }
142
            8BPP_PAL888 {
143
                set format          "CYG_FB_FORMAT_8BPP_PAL888"
144
                set suffix          "8"
145
                set depth           8
146
                set stride          $width
147
            }
148
            8BPP_TRUE_332 {
149
                set format                      "CYG_FB_FORMAT_8BPP_TRUE_332"
150
                set suffix                      "8"
151
                set paletted                0
152
                set make_colour_fn          "cyg_fb_dev_make_colour_8bpp_true_332"
153
                set break_colour_fn         "cyg_fb_dev_break_colour_8bpp_true_332"
154
                set make_colour_macro   "CYG_FB_MAKE_COLOUR_8BPP_TRUE_332"
155
                set break_colour_macro  "CYG_FB_BREAK_COLOUR_8BPP_TRUE_332"
156
                set depth                       8
157
                set stride                      $width
158
            }
159
            16BPP_TRUE_565 {
160
                set format                      "CYG_FB_FORMAT_16BPP_TRUE_565"
161
                set suffix                      "16"
162
                set paletted                0
163
                set make_colour_fn          "cyg_fb_dev_make_colour_16bpp_true_565"
164
                set break_colour_fn         "cyg_fb_dev_break_colour_16bpp_true_565"
165
                set make_colour_macro   "CYG_FB_MAKE_COLOUR_16BPP_TRUE_565"
166
                set break_colour_macro  "CYG_FB_BREAK_COLOUR_16BPP_TRUE_565"
167
                set depth                       16
168
                set stride                      [expr $width * 2]
169
            }
170
            16BPP_TRUE_555 {
171
                set format                      "CYG_FB_FORMAT_16BPP_TRUE_555"
172
                set suffix                      "16"
173
                set paletted                0
174
                set make_colour_fn          "cyg_fb_dev_make_colour_16bpp_true_555"
175
                set break_colour_fn         "cyg_fb_dev_break_colour_16bpp_true_555"
176
                set make_colour_macro   "CYG_FB_MAKE_COLOUR_16BPP_TRUE_555"
177
                set break_colour_macro  "CYG_FB_BREAK_COLOUR_16BPP_TRUE_555"
178
                set depth                       16
179
                set stride                      [expr $width * 2]
180
            }
181
            32BPP_TRUE_0888 {
182
                set format                      "CYG_FB_FORMAT_32BPP_TRUE_0888"
183
                set suffix                      "32"
184
                set paletted                0
185
                set make_colour_fn          "cyg_fb_dev_make_colour_32bpp_true_0888"
186
                set break_colour_fn         "cyg_fb_dev_break_colour_32bpp_true_0888"
187
                set make_colour_macro   "CYG_FB_MAKE_COLOUR_32BPP_TRUE_0888"
188
                set break_colour_macro  "CYG_FB_BREAK_COLOUR_32BPP_TRUE_0888"
189
                set depth                       32
190
                set stride                      [expr $width * 4]
191
            }
192
        }
193
        if { $paletted } {
194
            append flags0               "    CYG_FB_FLAGS0_PALETTE | \\\n    CYG_FB_FLAGS0_WRITEABLE_PALETTE | \\\n"
195
            set write_palette_fn        "cyg_synth_fb_write_palette"
196
            set read_palette_fn         "cyg_synth_fb_read_palette"
197
            set make_colour_fn          "cyg_fb_nop_make_colour"
198
            set break_colour_fn         "cyg_fb_nop_break_colour"
199
        } else {
200
            append flags0               "    CYG_FB_FLAGS0_TRUE_COLOUR | \\\n"
201
            set write_palette_fn        "cyg_fb_nop_write_palette"
202
            set read_palette_fn         "cyg_fb_nop_read_palette"
203
        }
204
        append flags0           "    CYG_FB_FLAGS0_BLANK)"
205
 
206
        # The framebuffer parameters
207
        append data \
208
            "
209
extern cyg_fb cyg_synth_fb[set fb];
210
extern cyg_uint8* cyg_synth_fb[set fb]_base;
211
#define CYG_FB_fb[set fb]_STRUCT            cyg_synth_fb[set fb]
212
#define CYG_FB_fb[set fb]_DEPTH             $depth
213
#define CYG_FB_fb[set fb]_FORMAT            $format
214
#define CYG_FB_fb[set fb]_WIDTH             $width
215
#define CYG_FB_fb[set fb]_HEIGHT            $height
216
#define CYG_FB_fb[set fb]_VIEWPORT_WIDTH    $viewport_width
217
#define CYG_FB_fb[set fb]_VIEWPORT_HEIGHT   $viewport_height
218
#define CYG_FB_fb[set fb]_BASE              cyg_synth_fb[set fb]_base
219
#define CYG_FB_fb[set fb]_STRIDE            $stride
220
#define CYG_FB_fb[set fb]_FLAGS0            $flags0
221
#define CYG_FB_fb[set fb]_FLAGS1            0
222
#define CYG_FB_fb[set fb]_FLAGS2            0
223
#define CYG_FB_fb[set fb]_FLAGS3            0
224
"
225
 
226
        # These macros are not part of the usual framebuffer set, but are
227
        # useful because of the configurable nature of the synthetic target
228
        append data \
229
            "
230
#define CYG_FB_fb[set fb]_SUFFIX            $suffix
231
#define CYG_FB_fb[set fb]_READ_PALETTE_FN   $read_palette_fn
232
#define CYG_FB_fb[set fb]_WRITE_PALETTE_FN  $write_palette_fn
233
#define CYG_FB_fb[set fb]_MAKE_COLOUR_FN    $make_colour_fn
234
#define CYG_FB_fb[set fb]_BREAK_COLOUR_FN   $break_colour_fn
235
"
236
        # And the macro API, all done in terms of the linear framebuffer functions.
237
        append data \
238
            "
239
#define CYG_FB_fb[set fb]_PIXELx_VAR(  _fb_, _id_)    CYG_FB_PIXELx_VAR_[set suffix](  _fb_, _id_)
240
#define CYG_FB_fb[set fb]_PIXELx_SET(  _fb_, _id_, _x_, _y_) \\
241
    CYG_MACRO_START \\
242
    CYG_FB_PIXELx_SET_[set suffix](  _fb_, _id_, CYG_FB_fb[set fb]_BASE, CYG_FB_fb[set fb]_STRIDE, _x_, _y_); \\
243
    CYG_MACRO_END
244
#define CYG_FB_fb[set fb]_PIXELx_GET(  _fb_, _id_, _x_, _y_) \\
245
    CYG_MACRO_START \\
246
    CYG_FB_PIXELx_GET_[set suffix](  _fb_, _id_, CYG_FB_fb[set fb]_BASE, CYG_FB_fb[set fb]_STRIDE, _x_, _y_); \\
247
    CYG_MACRO_END
248
#define CYG_FB_fb[set fb]_PIXELx_ADDX( _fb_, _id_, _incr_) \\
249
    CYG_MACRO_START \\
250
    CYG_FB_PIXELx_ADDX_[set suffix]( _fb_, _id_, CYG_FB_fb[set fb]_STRIDE, _incr_); \\
251
    CYG_MACRO_END
252
#define CYG_FB_fb[set fb]_PIXELx_ADDY( _fb_, _id_, _incr_) \\
253
    CYG_MACRO_START \\
254
    CYG_FB_PIXELx_ADDY_[set suffix]( _fb_, _id_, CYG_FB_fb[set fb]_STRIDE, _incr_); \\
255
    CYG_MACRO_END
256
#define CYG_FB_fb[set fb]_PIXELx_WRITE(_fb_, _id_, _colour_) \\
257
    CYG_MACRO_START \\
258
    CYG_FB_PIXELx_WRITE_[set suffix](_fb_, _id_, _colour_); \\
259
    CYG_MACRO_END
260
#define CYG_FB_fb[set fb]_PIXELx_READ( _fb_, _id_) \\
261
    ({ CYG_FB_PIXELx_READ_[set suffix]( _fb_, _id_); })
262
#define CYG_FB_fb[set fb]_PIXELx_FLUSHABS( _fb_, _id_, _x0_, _y0_, _width_, _height_) \\
263
    CYG_MACRO_START \\
264
    CYG_FB_PIXELx_FLUSHABS_[set suffix](_fb_, _id_, _x0_, _y0_, _width_, _height_); \\
265
    CYG_MACRO_END
266
#define CYG_FB_fb[set fb]_PIXELx_FLUSHREL( _fb_, _id_, _x0_, _y0_, _dx_, _dy_) \\
267
    CYG_MACRO_START \\
268
    CYG_FB_PIXELx_FLUSHREL_[set suffix](_fb_, _id_, _x0_, _y0_, _dx_, _dy_); \\
269
    CYG_MACRO_END
270
 
271
#define CYG_FB_fb[set fb]_WRITE_PIXEL(_x_, _y_, _colour_) \\
272
    CYG_MACRO_START \\
273
    cyg_fb_linear_write_pixel_[set suffix]_inl(CYG_FB_fb[set fb]_BASE, CYG_FB_fb[set fb]_STRIDE, \\
274
                                    _x_, _y_, _colour_); \\
275
    CYG_MACRO_END
276
#define CYG_FB_fb[set fb]_READ_PIXEL(_x_, _y_) \\
277
    ({ cyg_fb_linear_read_pixel_[set suffix]_inl(CYG_FB_fb[set fb]_BASE, CYG_FB_fb[set fb]_STRIDE, _x_, _y_); })
278
#define CYG_FB_fb[set fb]_WRITE_HLINE(_x_, _y_, _len_, _colour_) \\
279
    CYG_MACRO_START \\
280
    cyg_fb_linear_write_hline_[set suffix]_inl(CYG_FB_fb[set fb]_BASE, CYG_FB_fb[set fb]_STRIDE, \\
281
                                    _x_, _y_, _len_, _colour_); \\
282
    CYG_MACRO_END
283
#define CYG_FB_fb[set fb]_WRITE_VLINE(_x_, _y_, _len_, _colour_) \\
284
    CYG_MACRO_START \\
285
    cyg_fb_linear_write_vline_[set suffix]_inl(CYG_FB_fb[set fb]_BASE, CYG_FB_fb[set fb]_STRIDE, \\
286
                                    _x_, _y_, _len_, _colour_); \\
287
    CYG_MACRO_END
288
#define CYG_FB_fb[set fb]_FILL_BLOCK(_x_, _y_, _width_, _height_, _colour_) \\
289
    CYG_MACRO_START \\
290
    cyg_fb_linear_fill_block_[set suffix]_inl(CYG_FB_fb[set fb]_BASE, CYG_FB_fb[set fb]_STRIDE, \\
291
                                   _x_, _y_, _width_, _height_, _colour_); \\
292
    CYG_MACRO_END
293
#define CYG_FB_fb[set fb]_WRITE_BLOCK(_x_, _y_, _width_, _height_, _data_, _offset_, _data_stride_) \\
294
    CYG_MACRO_START \\
295
    cyg_fb_linear_write_block_[set suffix]_inl(CYG_FB_fb[set fb]_BASE, CYG_FB_fb[set fb]_STRIDE, \\
296
                                    _x_, _y_, _width_, _height_, _data_, _offset_, _data_stride_); \\
297
    CYG_MACRO_END
298
#define CYG_FB_fb[set fb]_READ_BLOCK(_x_, _y_, _width_, _height_, _data_, _offset_, _data_stride_) \\
299
    CYG_MACRO_START \\
300
    cyg_fb_linear_read_block_[set suffix]_inl(CYG_FB_fb[set fb]_BASE, CYG_FB_fb[set fb]_STRIDE, \\
301
                                   _x_, _y_, _width_, _height_, _data_, _offset_, _data_stride_); \\
302
    CYG_MACRO_END
303
#define CYG_FB_fb[set fb]_MOVE_BLOCK(_x_, _y_, _width_, _height_, _new_x_, _new_y_) \\
304
    CYG_MACRO_START \\
305
    cyg_fb_linear_move_block_[set suffix]_inl(CYG_FB_fb[set fb]_BASE, CYG_FB_fb[set fb]_STRIDE, \\
306
                                   _x_, _y_, _width_, _height_, _new_x_, _new_y_); \\
307
    CYG_MACRO_END
308
"
309
        if { !$paletted } {
310
            append data \
311
                "
312
#define CYG_FB_fb[set fb]_MAKE_COLOUR(_r_, _g_, _b_)                \\
313
    ({ [set make_colour_macro](_r_, _g_, _b_); })
314
#define CYG_FB_fb[set fb]_BREAK_COLOUR(_colour_, _r_, _g_, _b_)     \\
315
    CYG_MACRO_START                                                 \\
316
    [set break_colour_macro](_colour_, _r_, _g_, _b_);              \\
317
    CYG_MACRO_END
318
"
319
        }
320
    }
321
 
322
    set old_data ""
323
    set framebuf_file [file join $prefix "include/cyg/io/framebufs/synth_fb.h"]
324
    if { [file exists $framebuf_file] && [file readable $framebuf_file] } {
325
        set fd [open $framebuf_file "r"]
326
        set old_data [read $fd]
327
        close $fd
328
    }
329
    if { ! [string equal $old_data $data] } {
330
        if { ! [info exists [file dirname $framebuf_file]] } {
331
            file mkdir [file dirname $framebuf_file]
332
        }
333
        set fd [open $framebuf_file "w"]
334
        puts -nonewline $fd $data
335
        close $fd
336
    }
337
}
338
 
339
if { 0 == $::argc } {
340
    puts stderr "gen_synthfb.tcl: missing argument for install directory"
341
    exit 1
342
}
343
if { [catch { do_it [lindex $::argv 0] } msg] } {
344
    puts stderr "gen_synthfb.tcl: internal error"
345
    puts stderr "    $msg"
346
    exit 1
347
}
348
exit 0
349
 

powered by: WebSVN 2.1.0

© copyright 1999-2025 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.