FreeCalypso > hg > fc-tourmaline
comparison src/cs/drivers/drv_app/r2d/r2d_inits.c @ 0:4e78acac3d88
src/{condat,cs,gpf,nucleus}: import from Selenite
author | Mychaela Falconia <falcon@freecalypso.org> |
---|---|
date | Fri, 16 Oct 2020 06:23:26 +0000 |
parents | |
children | 1821e301a65b |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:4e78acac3d88 |
---|---|
1 /** | |
2 | |
3 @file: r2d_inits.c | |
4 | |
5 @author Christophe Favergeon | |
6 | |
7 @version 0.1 | |
8 | |
9 Purpose: Initializations routines for R2D | |
10 | |
11 */ | |
12 | |
13 /* | |
14 | |
15 Date Modification | |
16 ------------------------------------ | |
17 03/05/2002 Create | |
18 | |
19 | |
20 (C) Copyright 2002 by Texas Instruments Incorporated, All Rights Reserved | |
21 */ | |
22 | |
23 | |
24 #include "rv/general.h" | |
25 | |
26 #include "rvm/rvm_gen.h" | |
27 #include "rvm/rvm_ext_priorities.h" | |
28 #include "rvm/rvm_use_id_list.h" | |
29 | |
30 #include "r2d/r2d_pool_size.h" /* Stack & Memory Bank sizes definitions */ | |
31 | |
32 #include "r2d/r2d_config.h" | |
33 #include "r2d/r2d.h" | |
34 #include "r2d/r2d_i.h" | |
35 #include "r2d/r2d_env.h" | |
36 #include "r2d/r2d_independance_layer.h" | |
37 #include "r2d/r2d_messages.h" | |
38 #include "r2d/uwire.h" | |
39 | |
40 | |
41 #ifndef _WINDOWS | |
42 #ifndef _SIZE_T | |
43 #define _SIZE_T | |
44 typedef unsigned int size_t; | |
45 #endif | |
46 #endif | |
47 | |
48 #ifndef _WINDOWS | |
49 void *memcpy(void *s1, const void *s2, register size_t n); | |
50 void *memmove(void *s1, const void *s2, size_t n); | |
51 #endif | |
52 | |
53 extern T_R2D_ERROR r2d_font_init(void); | |
54 extern void r2d_font_clean(void);extern void r2d_core(UINT32 param); | |
55 | |
56 | |
57 /* global memory bank ID */ | |
58 extern T_RVF_MB_ID r2d_mb_id; | |
59 | |
60 /* Global standard graphical context */ | |
61 | |
62 extern T_R2D_GC_PTR r2d_g_lcd_gc; | |
63 | |
64 | |
65 | |
66 #if (R2D_ASM == R2D_ON) | |
67 extern T_RVF_MUTEX * r2d_g_blit_mutex; | |
68 extern UINT32 r2d_g_old_foreground_pixelvalue; | |
69 extern UINT32 r2d_g_old_background_pixelvalue; | |
70 #endif | |
71 | |
72 extern T_RVF_MUTEX * r2d_g_global_mutex; | |
73 | |
74 | |
75 | |
76 #if (R2D_REFRESH == R2D_VERTICAL) | |
77 extern UINT32 r2d_lcd_memory_words[(((R2D_WIDTH*R2D_MWHEIGHT)+1)<<R2D_LONGSIZE_FACTOR)]; | |
78 #else | |
79 extern UINT32 r2d_lcd_memory_words[(((R2D_MWWIDTH*R2D_HEIGHT)+1)<<R2D_LONGSIZE_FACTOR)]; | |
80 #endif | |
81 | |
82 extern INT16 r2d_update_ul_x,r2d_update_ul_y,r2d_update_br_x,r2d_update_br_y; | |
83 | |
84 extern void r2d_reinit_update_region(void); | |
85 | |
86 void (*IND_r2d_reinit_update_region)(void)=r2d_reinit_update_region; | |
87 | |
88 extern T_R2D_FONT_DESCRIPTION *r2d_g_font_configuration; | |
89 | |
90 | |
91 #if (R2D_EMBEDDED_LCD == R2D_PC_COLOR_LCD) | |
92 #include "r2d/lcds/ColorPC/r2d_task_init_i.c" | |
93 #endif | |
94 | |
95 #if (R2D_EMBEDDED_LCD == R2D_PC_CSAMPLE) | |
96 #include "r2d/lcds/PC_CSAMPLE/r2d_task_init_i.c" | |
97 #endif | |
98 | |
99 #if (R2D_EMBEDDED_LCD == R2D_PC_DSAMPLE) | |
100 #include "r2d/lcds/PC_DSAMPLE/r2d_task_init_i.c" | |
101 #endif | |
102 | |
103 #if (R2D_EMBEDDED_LCD == R2D_MIRRORED_LCD) | |
104 #ifdef CONFIG_TARGET_C139 | |
105 #include "r2d/lcds/c139/r2d_task_init_i.c" | |
106 #else | |
107 #include "r2d/lcds/Simple/r2d_task_init_i.c" | |
108 #endif | |
109 #endif | |
110 | |
111 #if (R2D_EMBEDDED_LCD == R2D_CUSTOMER_LCD) | |
112 #include "r2d/lcds/Customer/r2d_task_init_i.c" | |
113 #endif | |
114 | |
115 #if (R2D_EMBEDDED_LCD == R2D_HORIZONTAL_LCD) | |
116 #include "r2d/lcds/Horizontal/r2d_task_init_i.c" | |
117 #endif | |
118 | |
119 #if (R2D_EMBEDDED_LCD == R2D_SIMPLE_LCD) | |
120 #include "r2d/lcds/Simple/r2d_task_init_i.c" | |
121 #endif | |
122 | |
123 #if (R2D_EMBEDDED_LCD == R2D_BOARD_COLOR_LCD) | |
124 #include "r2d/lcds/ColorBoard/r2d_task_init_i.c" | |
125 #endif | |
126 | |
127 #if (R2D_EMBEDDED_LCD == R2D_BOARD_DSAMPLE) | |
128 #ifdef CONFIG_TARGET_LUNA | |
129 #include "r2d/lcds/luna/r2d_task_init_i.c" | |
130 #else | |
131 #include "r2d/lcds/D_Sample/r2d_task_init_i.c" | |
132 #endif | |
133 #endif | |
134 | |
135 #if (R2D_EMBEDDED_LCD == R2D_BOARD_BW_DSAMPLE) | |
136 #ifdef CONFIG_TARGET_LUNA | |
137 #include "r2d/lcds/luna/r2d_task_init_i.c" | |
138 #else | |
139 #include "r2d/lcds/BW_D_Sample/r2d_task_init_i.c" | |
140 #endif | |
141 #endif | |
142 | |
143 UINT32 r2d_get_memory_bank_size() | |
144 { | |
145 return(R2D_MB_PRIM_SIZE); | |
146 } | |
147 | |
148 #if ((!defined DEPENDENCY) && (R2D_MB_PRIM_SIZE != R2D_MB1_SIZE)) | |
149 /* If the R2D Memory Bank sizes defined in rvf_pool_size.h differs from */ | |
150 /* the one returned by the previous function, compilation is STOPPED. */ | |
151 #error R2D Memory Bank size mismatch! | |
152 #endif | |
153 | |
154 | |
155 | |
156 //////////////////////////////////////// | |
157 // | |
158 // Software entity initialization | |
159 | |
160 // Allocate the LCD framebuffer and dithering matrix | |
161 // Clear the framebuffer to 0 | |
162 // (Which does not mean intensity 0 since the meaning | |
163 // of 0 is dependent on the LCD). | |
164 | |
165 static void r2d_lcd_init(void) | |
166 { | |
167 UINT16 length; | |
168 // UINT32 *p; | |
169 T_RVF_RET err; | |
170 | |
171 | |
172 R2D_MALLOC(r2d_mb_id,T_R2D_FRAMEBUFFER,sizeof(T_R2D_FRAMEBUFFER),r2d_g_framebuffer); | |
173 | |
174 if (r2d_g_framebuffer !=NULL) | |
175 { | |
176 // length+1 is used instead of length because in the refresh loop | |
177 // one may need to read one word past the end of the real datas | |
178 #if (R2D_REFRESH==R2D_VERTICAL) | |
179 // Column is contiguous in memory | |
180 length=R2D_WIDTH*R2D_MWHEIGHT; | |
181 //R2D_MALLOC(r2d_mb_id,UINT32,((length+1)<<R2D_LONGSIZE_FACTOR),r2d_g_framebuffer->p_memory_words); | |
182 r2d_g_framebuffer->p_memory_words=r2d_lcd_memory_words; | |
183 | |
184 // No deletion at the end since memory_word is NOT a dynamical object | |
185 r2d_g_framebuffer->refcount=-1; | |
186 | |
187 // 0 is a special LCD kind : size of the framebuffer | |
188 // is hardcoded to quick pixel generation | |
189 r2d_g_framebuffer->kind=0; | |
190 r2d_g_framebuffer->p_frame_buffer_end=r2d_g_framebuffer->p_memory_words+length; | |
191 r2d_g_framebuffer->width=R2D_WIDTH; | |
192 r2d_g_framebuffer->height=R2D_HEIGHT; | |
193 #else | |
194 // Line is contiguous in memory | |
195 length=R2D_HEIGHT*R2D_MWWIDTH; | |
196 r2d_g_framebuffer->p_memory_words=r2d_lcd_memory_words; | |
197 | |
198 r2d_g_framebuffer->refcount=-1; | |
199 // 0 is a special LCD kind : size of the framebuffer | |
200 // is hardcoded to quick pixel generation | |
201 r2d_g_framebuffer->kind=0; | |
202 r2d_g_framebuffer->p_frame_buffer_end=r2d_g_framebuffer->p_memory_words+length; | |
203 r2d_g_framebuffer->width=R2D_WIDTH; | |
204 r2d_g_framebuffer->height=R2D_HEIGHT; | |
205 #endif | |
206 | |
207 R2D_MALLOC(r2d_mb_id,T_RVF_MUTEX,sizeof(T_RVF_MUTEX),r2d_g_framebuffer->mutex); | |
208 if (r2d_g_framebuffer->mutex!=NULL) | |
209 { | |
210 err=rvf_initialize_mutex(r2d_g_framebuffer->mutex); | |
211 if (err!=RVF_OK) | |
212 { | |
213 R2D_FREE(r2d_g_framebuffer->mutex); | |
214 R2D_FREE(r2d_g_framebuffer); | |
215 r2d_g_framebuffer=NULL; | |
216 | |
217 } | |
218 } | |
219 else | |
220 { | |
221 R2D_FREE(r2d_g_framebuffer); | |
222 r2d_g_framebuffer=NULL; | |
223 | |
224 } | |
225 | |
226 } | |
227 IND_r2d_reinit_update_region(); | |
228 | |
229 | |
230 } | |
231 | |
232 T_RVM_RETURN r2d_cleanup(void) | |
233 { | |
234 /* | |
235 ** free all memory buffer previously allocated. | |
236 ** DO NOT SEND MESSAGES | |
237 */ | |
238 r2d_refresh_task_kill(); | |
239 #if (R2D_ASM == R2D_ON) | |
240 rvf_delete_mutex(r2d_g_blit_mutex); | |
241 R2D_FREE(r2d_g_blit_mutex); | |
242 #endif | |
243 rvf_delete_mutex(r2d_g_global_mutex); | |
244 R2D_FREE(r2d_g_global_mutex); | |
245 r2d_release_context(r2d_g_lcd_gc); | |
246 r2d_release_framebuffer(r2d_g_framebuffer); | |
247 R2D_FREE(r2d_g_dithering_matrix); | |
248 R2D_FREE(r2d_g_font_configuration); | |
249 | |
250 return(RV_OK); | |
251 } | |
252 | |
253 | |
254 | |
255 /****************************************************************************** | |
256 * Function : xxx_init | |
257 * | |
258 * Description : This function is called by the RV manager to initialize the | |
259 * xxx SWE before creating the task and calling xxx_start. | |
260 * | |
261 * Parameters : None | |
262 * | |
263 * Return : T_RVM_RETURN | |
264 * | |
265 * History : 0.1 (20-August-2000) | |
266 * | |
267 * | |
268 ******************************************************************************/ | |
269 T_RVM_RETURN r2d_initializations(void) | |
270 { | |
271 /* | |
272 ** Put local SWE initialization here | |
273 */ | |
274 | |
275 T_R2D_ERROR err; | |
276 | |
277 r2d_lcd_init(); | |
278 if (r2d_g_framebuffer==NULL) | |
279 goto r2d_init_error; | |
280 | |
281 r2d_dithering_init(); | |
282 if (r2d_g_dithering_matrix==NULL) | |
283 { | |
284 r2d_release_framebuffer(r2d_g_framebuffer); | |
285 goto r2d_init_error; | |
286 } | |
287 | |
288 R2D_MALLOC(r2d_mb_id,T_R2D_FONT_DESCRIPTION, | |
289 sizeof(T_R2D_FONT_DESCRIPTION)*36,r2d_g_font_configuration); | |
290 | |
291 if (r2d_g_font_configuration ==NULL) | |
292 { | |
293 r2d_release_framebuffer(r2d_g_framebuffer); | |
294 R2D_FREE(r2d_g_dithering_matrix); | |
295 goto r2d_init_error; | |
296 } | |
297 | |
298 err=r2d_font_init(); | |
299 if (err!=R2D_OK) | |
300 { | |
301 r2d_release_framebuffer(r2d_g_framebuffer); | |
302 R2D_FREE(r2d_g_dithering_matrix); | |
303 goto r2d_init_error; | |
304 } | |
305 | |
306 | |
307 r2d_g_default_font_framebuffer=r2d_g_font_configuration[R2D_MEDIUM_SYSTEM_NORMAL].framebuffer; | |
308 r2d_g_default_font_metrics=r2d_g_font_configuration[R2D_MEDIUM_SYSTEM_NORMAL].metrics; | |
309 r2d_g_default_font_table=r2d_g_font_configuration[R2D_MEDIUM_SYSTEM_NORMAL].table; | |
310 | |
311 r2d_refresh_task_init(); | |
312 | |
313 r2d_g_lcd_gc=r2d_new_lcd_context(r2d_mb_id); | |
314 if (r2d_g_lcd_gc==NULL) | |
315 { | |
316 r2d_font_clean(); | |
317 r2d_release_framebuffer(r2d_g_framebuffer); | |
318 R2D_FREE(r2d_g_dithering_matrix); | |
319 goto r2d_init_error; | |
320 } | |
321 | |
322 r2d_g_event_was_sent=FALSE; | |
323 r2d_g_refresh_disabled=0; | |
324 | |
325 #if (R2D_ASM == R2D_ON) | |
326 | |
327 R2D_MALLOC(r2d_mb_id,T_RVF_MUTEX,sizeof(T_RVF_MUTEX),r2d_g_blit_mutex); | |
328 if (r2d_g_blit_mutex==NULL) | |
329 { | |
330 r2d_font_clean(); | |
331 r2d_release_framebuffer(r2d_g_framebuffer); | |
332 R2D_FREE(r2d_g_dithering_matrix); | |
333 goto r2d_init_error; | |
334 } | |
335 | |
336 err=rvf_initialize_mutex(r2d_g_blit_mutex); | |
337 if (err!=RVF_OK) | |
338 { | |
339 R2D_FREE(r2d_g_blit_mutex); | |
340 r2d_font_clean(); | |
341 r2d_release_framebuffer(r2d_g_framebuffer); | |
342 R2D_FREE(r2d_g_dithering_matrix); | |
343 goto r2d_init_error; | |
344 } | |
345 | |
346 // Mode of initial asm blit rect | |
347 r2d_g_old_mode=R2D_COPY_MODE; | |
348 r2d_g_old_use_foreground=FALSE; | |
349 r2d_g_old_srcdst=R2D_LCDLCD; | |
350 r2d_g_old_foreground_pixelvalue=((T_R2D_GC*)r2d_g_lcd_gc)->foreground_pixel_value; | |
351 r2d_g_old_background_pixelvalue=((T_R2D_GC*)r2d_g_lcd_gc)->background_pixel_value; | |
352 | |
353 #endif | |
354 | |
355 R2D_MALLOC(r2d_mb_id,T_RVF_MUTEX,sizeof(T_RVF_MUTEX),r2d_g_global_mutex); | |
356 if (r2d_g_global_mutex==NULL) | |
357 { | |
358 r2d_font_clean(); | |
359 r2d_release_framebuffer(r2d_g_framebuffer); | |
360 R2D_FREE(r2d_g_dithering_matrix); | |
361 #if (R2D_ASM == R2D_ON) | |
362 rvf_delete_mutex(r2d_g_blit_mutex); | |
363 R2D_FREE(r2d_g_blit_mutex); | |
364 #endif | |
365 goto r2d_init_error; | |
366 } | |
367 | |
368 err=rvf_initialize_mutex(r2d_g_global_mutex); | |
369 if (err!=RVF_OK) | |
370 { | |
371 R2D_FREE(r2d_g_global_mutex); | |
372 r2d_font_clean(); | |
373 r2d_release_framebuffer(r2d_g_framebuffer); | |
374 R2D_FREE(r2d_g_dithering_matrix); | |
375 #if (R2D_ASM == R2D_ON) | |
376 rvf_delete_mutex(r2d_g_blit_mutex); | |
377 R2D_FREE(r2d_g_blit_mutex); | |
378 #endif | |
379 goto r2d_init_error; | |
380 } | |
381 | |
382 | |
383 return RV_OK; | |
384 | |
385 | |
386 r2d_init_error: return RV_MEMORY_ERR; | |
387 } | |
388 |