eCos GUI for Synthetic 的研究

发布时间:2011-2-24 08:42    发布者:rickleaf
关键词: eCos , GUI , Synthetic
帖子发的比较仓促,由于帖子大小的问题,补丁在2楼和3楼。
1. 软件下载新版本的eCos已经开始用hg作为代码管理了。
大家可以用以下命令下载最新的eCos源码

hg clone http://hg-pub.ecoscentric.com/ecos/
当然也可以用http://ecos.sourceware.org/getstart.html提供的正式版安装ecos的tcl脚本来安装,因为本人使用的是ubuntu 10.04 amd64版本,所以必须用hg的方式。
2. 安装host工具

所谓host工具是指,ecos在发布的时候一些用来模拟的工具,其中synthetic就是其中的一个。your_ecos_folder/configuremakesudo make install

3. 配置synthetic平台,并且加入microwindows组件

ecosconfig new linux netecosconfig add mwecosconfig treemake

4. 运行synthetic的ecos代码

install/bin/ecos-mw.elf --io


本文地址:https://www.eechina.com/thread-55764-1-1.html     【打印本页】

本站部分文章为转载或网友发布,目的在于传递和分享信息,并不代表本网赞同其观点和对其真实性负责;文章版权归原作者及原出处所有,如涉及作品内容、版权和其它问题,我们将根据著作权人的要求,第一时间更正或删除。
rickleaf 发表于 2011-2-24 08:44:26
系统默认的microwindows有比较多的bug,本人把自己的patch放出了,给大家一起学习。
  1. diff -r 418d34334c77 packages/services/gfx/mw/current/cdl/microwindows.cdl
  2. --- a/packages/services/gfx/mw/current/cdl/microwindows.cdl        Thu Apr 01 13:17:10 2010 +0000
  3. +++ b/packages/services/gfx/mw/current/cdl/microwindows.cdl        Fri Apr 23 14:41:29 2010 +0800
  4. @@ -199,6 +199,66 @@

  5.      }

  6. +    # ecos Linux synth drivers
  7. +    cdl_component CYGPKG_MICROWINDOWS_SYNTH {
  8. +        display   "Build MicroWindows for synthetic target"
  9. +        flavor      none
  10. +    active_if   (CYGPKG_HAL_SYNTH && !CYGBLD_MICROWINDOWS_VNC_DRIVERS)
  11. +        description \
  12. +            "This option builds the drivers for the synthetic target.  The synthetic
  13. +             then provides a virtual screen."
  14. +
  15. +        compile                     \
  16. +            drivers/scr_synth_ecos.c  \
  17. +            drivers/kbd_null.c  \
  18. +            drivers/mou_null.c
  19. +        requires CYGPKG_IO_FRAMEBUF
  20. +        requires CYGBLD_MICROWINDOWS_ECOS
  21. +        requires CYGBLD_MICROWINDOWS_NANOWM
  22. +        requires CYGBLD_MICROWINDOWS_NANOX_DEMOS
  23. +        requires !CYGBLD_MICROWINDOWS_ARM_DRIVERS
  24. +        cdl_option CYGIMP_MICROWINDOWS_TRUECOLOR0888 {
  25. +            display "Assume 32 bits per pixel, RGB == 0888"
  26. +            implements  CYGINT_MICROWINDOWS_SYNTH_DRIVER
  27. +            default_value 1
  28. +            requires { is_substr(CYGPKG_MICROWINDOWS_CFLAGS_ADD, " -DMWPIXEL_FORMAT=MWPF_TRUECOLOR0888 ") }
  29. +            requires { !is_substr(CYGPKG_MICROWINDOWS_CFLAGS_ADD, " -DMWPIXEL_FORMAT=MWPF_TRUECOLOR565 ") }
  30. +            requires { !is_substr(CYGPKG_MICROWINDOWS_CFLAGS_ADD, " -DMWPIXEL_FORMAT=MWPF_TRUECOLOR555 ") }
  31. +            requires { !is_substr(CYGPKG_MICROWINDOWS_CFLAGS_ADD, " -DMWPIXEL_FORMAT=MWPF_TRUECOLOR332 ") }
  32. +        }
  33. +        cdl_option CYGIMP_MICROWINDOWS_TRUECOLOR565 {
  34. +            display "Assume 16 bits per pixel, RGB == 565"
  35. +            implements  CYGINT_MICROWINDOWS_SYNTH_DRIVER
  36. +            default_value 0
  37. +            requires { !is_substr(CYGPKG_MICROWINDOWS_CFLAGS_ADD, " -DMWPIXEL_FORMAT=MWPF_TRUECOLOR0888 ") }
  38. +            requires { is_substr(CYGPKG_MICROWINDOWS_CFLAGS_ADD, " -DMWPIXEL_FORMAT=MWPF_TRUECOLOR565 ") }
  39. +            requires { !is_substr(CYGPKG_MICROWINDOWS_CFLAGS_ADD, " -DMWPIXEL_FORMAT=MWPF_TRUECOLOR555 ") }
  40. +            requires { !is_substr(CYGPKG_MICROWINDOWS_CFLAGS_ADD, " -DMWPIXEL_FORMAT=MWPF_TRUECOLOR332 ") }
  41. +        }
  42. +        cdl_option CYGIMP_MICROWINDOWS_TRUECOLOR555 {
  43. +            display "Assume 16 bits per pixel, RGB == 555"
  44. +            implements  CYGINT_MICROWINDOWS_SYNTH_DRIVER
  45. +            default_value 0
  46. +            requires { !is_substr(CYGPKG_MICROWINDOWS_CFLAGS_ADD, " -DMWPIXEL_FORMAT=MWPF_TRUECOLOR0888 ") }
  47. +            requires { !is_substr(CYGPKG_MICROWINDOWS_CFLAGS_ADD, " -DMWPIXEL_FORMAT=MWPF_TRUECOLOR565 ") }
  48. +            requires { is_substr(CYGPKG_MICROWINDOWS_CFLAGS_ADD, " -DMWPIXEL_FORMAT=MWPF_TRUECOLOR555 ") }
  49. +            requires { !is_substr(CYGPKG_MICROWINDOWS_CFLAGS_ADD, " -DMWPIXEL_FORMAT=MWPF_TRUECOLOR332 ") }
  50. +        }
  51. +        cdl_option CYGIMP_MICROWINDOWS_TRUECOLOR332 {
  52. +            display "Assume 8 bits per pixel, RGB == 332"
  53. +            implements  CYGINT_MICROWINDOWS_SYNTH_DRIVER
  54. +            default_value 0
  55. +            requires { !is_substr(CYGPKG_MICROWINDOWS_CFLAGS_ADD, " -DMWPIXEL_FORMAT=MWPF_TRUECOLOR0888 ") }
  56. +            requires { !is_substr(CYGPKG_MICROWINDOWS_CFLAGS_ADD, " -DMWPIXEL_FORMAT=MWPF_TRUECOLOR565 ") }
  57. +            requires { !is_substr(CYGPKG_MICROWINDOWS_CFLAGS_ADD, " -DMWPIXEL_FORMAT=MWPF_TRUECOLOR555 ") }
  58. +            requires { is_substr(CYGPKG_MICROWINDOWS_CFLAGS_ADD, " -DMWPIXEL_FORMAT=MWPF_TRUECOLOR332 ") }
  59. +        }
  60. +        cdl_interface CYGINT_MICROWINDOWS_SYNTH_DRIVER {
  61. +            display "Number of active synthic graphics drivers"
  62. +            requires { CYGINT_MICROWINDOWS_SYNTH_DRIVER == 1 }
  63. +        }
  64. +    }
  65. +
  66.      cdl_component CYGPKG_MICROWINDOWS_PC {
  67.         display     "Build options for PC hardware"
  68.         flavor      none
  69. @@ -255,7 +315,7 @@
  70.             default_value 0
  71.             compile drivers/scr_bios.c drivers/vgainit.c drivers/vgaplan4.c drivers/memplan4.c
  72.             requires { is_substr(CYGPKG_MICROWINDOWS_CFLAGS_ADD, " -DMWPIXEL_FORMAT=MWPF_PALETTE ") }
  73. -            requires { !is_substr(CYGPKG_MICROWINDOWS_CFLAGS_ADD, " -DMWPIXEL_FORMAT=MWPF_TRUECOLOR0888 ") }
  74. +            requires { !is_substr(CYGPKG_MICROWINDOWS_CFLAGS_ADD, " -DMWPIXEL_FORMAT=MWPF_TRUECOLOR565 ") }
  75.         }
  76.        
  77.         cdl_interface CYGINT_MICROWINDOWS_PC_DRIVER {
  78. @@ -313,6 +373,14 @@
  79.              compile demos/nanox/ntetris.c
  80.              compile -library=libextras.a ecos/ntetris_thread.c
  81.          }
  82. +
  83. +        cdl_option CYGBLD_MICROWINDOWS_NANOX_DEMOS_DEMO {
  84. +            display "Include 'demo' demo"
  85. +            default_value 0
  86. +            no_define
  87. +            compile demos/nanox/demo.c
  88. +            compile -library=libextras.a ecos/demo_thread.c
  89. +        }
  90.      }

  91.      cdl_component CYGPKG_MICROWINDOWS_OPTIONS {
  92. diff -r 418d34334c77 packages/services/gfx/mw/current/src/demos/nanowm/wlist.c
  93. --- a/packages/services/gfx/mw/current/src/demos/nanowm/wlist.c        Thu Apr 01 13:17:10 2010 +0000
  94. +++ b/packages/services/gfx/mw/current/src/demos/nanowm/wlist.c        Fri Apr 23 14:41:29 2010 +0800
  95. @@ -13,7 +13,7 @@

  96. #include "nanowm.h"

  97. -static win *windows = NULL;
  98. +/*static*/ win *windows = NULL;

  99. /*
  100.   * Find the windowlist entry for the specified window ID and return a pointer
  101. diff -r 418d34334c77 packages/services/gfx/mw/current/src/demos/nanox/demo.c
  102. --- a/packages/services/gfx/mw/current/src/demos/nanox/demo.c        Thu Apr 01 13:17:10 2010 +0000
  103. +++ b/packages/services/gfx/mw/current/src/demos/nanox/demo.c        Fri Apr 23 14:41:29 2010 +0800
  104. @@ -6,10 +6,15 @@
  105. #define MWINCLUDECOLORS
  106. #include "nano-X.h"

  107. +
  108. #if DOS_TURBOC
  109. unsigned _stklen = 32768;
  110. #endif

  111. +#if defined(MSDOS) || defined(__ECOS)
  112. +#include
  113. +#endif
  114. +
  115. /*
  116.   * Definitions to make it easy to define cursors
  117.   */
  118. @@ -47,7 +52,7 @@
  119. void do_buttonup(GR_EVENT_BUTTON        *bp);
  120. void do_motion(GR_EVENT_MOUSE                *mp);
  121. void do_keystroke(GR_EVENT_KEYSTROKE        *kp);
  122. -void do_exposure(GR_EVENT_EXPOSURE        *ep);
  123. +static void do_exposure(GR_EVENT_EXPOSURE        *ep);
  124. void do_focusin(GR_EVENT_GENERAL        *gp);
  125. void do_focusout(GR_EVENT_GENERAL        *gp);
  126. void do_enter(GR_EVENT_GENERAL                *gp);
  127. @@ -56,8 +61,13 @@
  128. /* routine to handle errors */
  129. void errorcatcher(GR_EVENT *ep);

  130. +#ifdef __ECOS
  131. int
  132. -main(int argc,char **argv)
  133. +demo_main(int argc, char **argv)
  134. +#else
  135. +int
  136. +main(int argc, char **argv)
  137. +#endif
  138. {
  139.         GR_EVENT        event;                /* current event */
  140.         GR_BITMAP        bitmap1fg[7];        /* bitmaps for first cursor */
  141. @@ -73,8 +83,14 @@
  142.         GrReqShmCmds(655360);
  143.        
  144.         GrGetScreenInfo(&si);
  145. +#ifdef __ECOS
  146. +/* 240x320 screen*/
  147. +COLS = si.cols - 10;
  148. +ROWS = si.rows - 40;
  149. +#else
  150. COLS = si.cols - 40;
  151. ROWS = si.rows - 80;
  152. +#endif

  153.         /* print error, but don't exit*/
  154.         GrSetErrorHandler(errorcatcher);
  155. @@ -375,7 +391,7 @@
  156. /*
  157.   * Here when an exposure event occurs.
  158.   */
  159. -void
  160. +static void
  161. do_exposure(GR_EVENT_EXPOSURE        *ep)
  162. {
  163.         GR_POINT        points[3];
  164. diff -r 418d34334c77 packages/services/gfx/mw/current/src/drivers/scr_synth_ecos.c
  165. --- /dev/null        Thu Jan 01 00:00:00 1970 +0000
  166. +++ b/packages/services/gfx/mw/current/src/drivers/scr_synth_ecos.c        Fri Apr 23 14:41:29 2010 +0800
  167. @@ -0,0 +1,444 @@
  168. +//==========================================================================
  169. +//
  170. +//      scr_synth_ecos.c
  171. +//
  172. +//
  173. +//
  174. +//==========================================================================
  175. +// This file is part of eCos, the Embedded Configurable Operating System.   
  176. +// Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003 Free Software Foundation, Inc.
  177. +//
  178. +// eCos is free software; you can redistribute it and/or modify it under   
  179. +// the terms of the GNU General Public License as published by the Free     
  180. +// Software Foundation; either version 2 or (at your option) any later      
  181. +// version.                                                                 
  182. +//
  183. +// eCos is distributed in the hope that it will be useful, but WITHOUT      
  184. +// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or   
  185. +// FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License   
  186. +// for more details.                                                        
  187. +//
  188. +// You should have received a copy of the GNU General Public License        
  189. +// along with eCos; if not, write to the Free Software Foundation, Inc.,   
  190. +// 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.            
  191. +//
  192. +// As a special exception, if other files instantiate templates or use      
  193. +// macros or inline functions from this file, or you compile this file      
  194. +// and link it with other works to produce a work based on this file,      
  195. +// this file does not by itself cause the resulting work to be covered by   
  196. +// the GNU General Public License. However the source code for this file   
  197. +// must still be made available in accordance with section (3) of the GNU   
  198. +// General Public License v2.                                               
  199. +//
  200. +// This exception does not invalidate any other reasons why a work based   
  201. +// on this file might be covered by the GNU General Public License.         
  202. +// -------------------------------------------                              
  203. +// ####ECOSGPLCOPYRIGHTEND####                                             
  204. +//==========================================================================
  205. +//#####DESCRIPTIONBEGIN####
  206. +//
  207. +// Author(s):    Ricky Wu
  208. +// Contributors:
  209. +// Date:         2010-04-16
  210. +// Purpose:
  211. +// Description:  Microwindows screen driver for synth server on eCos
  212. +//
  213. +//####DESCRIPTIONEND####
  214. +//
  215. +//========================================================================*/
  216. +
  217. +
  218. +
  219. +#define _GNU_SOURCE 1
  220. +
  221. +#include
  222. +
  223. +#include
  224. +#include
  225. +#include
  226. +#include
  227. +#include
  228. +#include
  229. +#include
  230. +#include
  231. +#include
  232. +#include
  233. +#include
  234. +#include
  235. +#include
  236. +#include
  237. +#include "device.h"
  238. +#include "genfont.h"
  239. +#include "genmem.h"
  240. +
  241. +
  242. +static cyg_ucount32 colours[16];
  243. +/* In genmem.c*/
  244. +MWBOOL  set_subdriver(PSD psd, PSUBDRIVER subdriver, MWBOOL init);
  245. +
  246. +/* Prototypes for driver functions */
  247. +static int synth_init(PSD psd);
  248. +static PSD  synth_open(PSD psd);
  249. +static void synth_close(PSD psd);
  250. +static void synth_getscreeninfo(PSD psd,PMWSCREENINFO psi);
  251. +static void synth_drawpixel(PSD psd,MWCOORD x, MWCOORD y, MWPIXELVAL c);
  252. +static MWPIXELVAL synth_readpixel(PSD psd,MWCOORD x, MWCOORD y);
  253. +static void synth_drawhorizline(PSD psd,MWCOORD x1, MWCOORD x2, MWCOORD y, MWPIXELVAL c);
  254. +static void synth_drawvertline(PSD psd,MWCOORD x, MWCOORD y1, MWCOORD y2, MWPIXELVAL c);
  255. +static void synth_fillrect(PSD psd,MWCOORD x1, MWCOORD y1, MWCOORD x2, MWCOORD y2, MWPIXELVAL c);
  256. +static void synth_blit(PSD , MWCOORD, MWCOORD, MWCOORD, MWCOORD, PSD, MWCOORD, MWCOORD, long);
  257. +static void synth_stretchblit(PSD dstpsd, MWCOORD dstx, MWCOORD dsty, MWCOORD dstw,
  258. +                            MWCOORD dsth, PSD srcpsd, MWCOORD srcx, MWCOORD srcy,
  259. +                            MWCOORD srcw, MWCOORD srch, long op);
  260. +static void synth_drawarea(PSD psd, driver_gc_t *gc, int op);
  261. +MWBOOL synth_mapmemgc(PSD, MWCOORD, MWCOORD, int, int, int, int, void *);
  262. +
  263. +
  264. +#define FRAMEBUF cyg_synth_fb0
  265. +
  266. +#define BLACK        cyg_fb_make_colour(&FRAMEBUF,   0,   0,   0)
  267. +#define WHITE        cyg_fb_make_colour(&FRAMEBUF, 255, 255, 255)
  268. +#define RED          cyg_fb_make_colour(&FRAMEBUF, 255,   0,   0)
  269. +#define GREEN        cyg_fb_make_colour(&FRAMEBUF,   0, 255,   0)
  270. +#define BLUE         cyg_fb_make_colour(&FRAMEBUF,   0,   0, 255)
  271. +#define YELLOW       cyg_fb_make_colour(&FRAMEBUF, 255, 255,  80)
  272. +
  273. +
  274. +
  275. +SCREENDEVICE        scrdev = {
  276. +    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL,
  277. +    synth_open,
  278. +    synth_close,
  279. +    synth_getscreeninfo,
  280. +    NULL,
  281. +    synth_drawpixel,     /* DrawPixel subdriver*/
  282. +    synth_readpixel,     /* ReadPixel subdriver*/
  283. +    synth_drawhorizline, /* DrawHorzLine subdriver*/
  284. +    synth_drawvertline,  /* DrawVertLine subdriver*/
  285. +    synth_fillrect,      /* FillRect subdriver*/
  286. +    gen_fonts,
  287. +    synth_blit,          /* Blit subdriver*/
  288. +    NULL,               /* PreSelect*/
  289. +    NULL,              /* DrawArea subdriver*/
  290. +    NULL,               /* SetIOPermissions*/
  291. +    gen_allocatememgc,
  292. +    synth_mapmemgc,
  293. +    gen_freememgc,
  294. +    synth_stretchblit,   /* StretchBlit subdriver*/
  295. +    NULL               /* SetPortrait*/
  296. +};
  297. +
  298. +SUBDRIVER synth_subdriver = {
  299. +    synth_init,
  300. +    synth_drawpixel,
  301. +    synth_readpixel,
  302. +    synth_drawhorizline,
  303. +    synth_drawvertline,
  304. +    synth_fillrect,
  305. +    synth_blit,
  306. +    synth_drawarea,
  307. +    synth_stretchblit
  308. +};
  309. +
  310. +/* Static variables*/
  311. +static int status;                /* 0=never inited, 1=once inited, 2=inited. */
  312. +//static synth_frame_format_t *frame_format;
  313. +
  314. +/* Calc linelen and mmap size, return 0 on fail*/
  315. +static int synth_init(PSD psd)
  316. +{
  317. +    if (!psd->size)
  318. +    {
  319. +        psd->size = psd->yres * psd->xres * psd->bpp / 8;
  320. +        /* convert linelen from byte to pixel len for bpp 16, 24, 32*/
  321. +        psd->linelen = psd->xres;
  322. +    }
  323. +
  324. +    return 1;
  325. +}
  326. +
  327. +static cyg_fb_colour CMWtofb(cyg_fb* fb,MWPIXELVAL c)
  328. +{
  329. +        if (CYG_FB_fb0_FORMAT==CYG_FB_FORMAT_8BPP_TRUE_332)
  330. +        {
  331. +                return cyg_fb_make_colour(fb, (c&0xe0)>>(3+2), (c&0x1c)>>2, (c&0x03));
  332. +            }
  333. +            else if (CYG_FB_fb0_FORMAT==CYG_FB_FORMAT_16BPP_TRUE_555)
  334. +            {
  335. +                return cyg_fb_make_colour(fb, (c&0x7c00)>>(5+5), (c&0x03e0)>>5, (c&0x001f));
  336. +            }
  337. +            else if(CYG_FB_fb0_FORMAT==CYG_FB_FORMAT_16BPP_TRUE_565)
  338. +        {
  339. +                return cyg_fb_make_colour(fb, (c&0xf800)>>(6+5), (c&0x07e0)>>5, (c&0x001f));
  340. +        }
  341. +        else if(CYG_FB_fb0_FORMAT==CYG_FB_FORMAT_32BPP_TRUE_0888)
  342. +        {
  343. +                return cyg_fb_make_colour(fb, (c&0xFF0000)>>(8+8), (c&0x00ff00)>>8, (c&0x0000ff));
  344. +        }
  345. +}
  346. +
  347. +static MWPIXELVAL CFBtoMW(cyg_fb* fb,cyg_fb_colour fb_colour)
  348. +{
  349. +        cyg_ucount8 r,g,b;
  350. +        MWPIXELVAL mMWPIXELVAL=0;
  351. +        cyg_fb_break_colour(fb,fb_colour,&r, &g, &b);
  352. +        if (CYG_FB_fb0_FORMAT==CYG_FB_FORMAT_8BPP_TRUE_332)
  353. +        {
  354. +                mMWPIXELVAL|=r;
  355. +                mMWPIXELVAL<<=3;
  356. +                mMWPIXELVAL|=g;
  357. +                mMWPIXELVAL<<=2;
  358. +                mMWPIXELVAL|=b;
  359. +                return mMWPIXELVAL;
  360. +            }
  361. +            else if (CYG_FB_fb0_FORMAT==CYG_FB_FORMAT_16BPP_TRUE_555)
  362. +            {
  363. +                mMWPIXELVAL|=r;
  364. +                mMWPIXELVAL<<=5;
  365. +                mMWPIXELVAL|=g;
  366. +                mMWPIXELVAL<<=5;
  367. +                mMWPIXELVAL|=b;
  368. +                return mMWPIXELVAL;
  369. +            }
  370. +            else if(CYG_FB_fb0_FORMAT==CYG_FB_FORMAT_16BPP_TRUE_565)
  371. +        {
  372. +                mMWPIXELVAL|=r;
  373. +                mMWPIXELVAL<<=6;
  374. +                mMWPIXELVAL|=g;
  375. +                mMWPIXELVAL<<=5;
  376. +                mMWPIXELVAL|=b;
  377. +                return mMWPIXELVAL;
  378. +        }
  379. +        else if(CYG_FB_fb0_FORMAT==CYG_FB_FORMAT_32BPP_TRUE_0888)
  380. +        {
  381. +                mMWPIXELVAL|=r;
  382. +                mMWPIXELVAL<<=8;
  383. +                mMWPIXELVAL|=g;
  384. +                mMWPIXELVAL<<=8;
  385. +                mMWPIXELVAL|=b;
  386. +                 return mMWPIXELVAL;
  387. +        }
  388. +       
  389. +}
  390. +
  391. +/* Initialise the synth framebuffer */
  392. +static PSD synth_open(PSD psd)
  393. +{
  394. +    /* Get frame format details */
  395. +    cyg_fb_on(&FRAMEBUF);
  396. +
  397. +    psd->xres = psd->xvirtres = CYG_FB_fb0_WIDTH;
  398. +    psd->yres = psd->yvirtres = CYG_FB_fb0_HEIGHT;
  399. +    psd->portrait = MWPORTRAIT_NONE;
  400. +    psd->planes = 1;  /* Should probably find out what this means */
  401. +
  402. +
  403. +    if (CYG_FB_fb0_FORMAT==CYG_FB_FORMAT_8BPP_TRUE_332)
  404. +    {
  405. +        psd->bpp = 8;
  406. +        psd->ncolors = 0xFF + 1;
  407. +        psd->pixtype = MWPF_TRUECOLOR332;
  408. +    }
  409. +    else if (CYG_FB_fb0_FORMAT==CYG_FB_FORMAT_16BPP_TRUE_555)
  410. +    {
  411. +        psd->bpp = 16;
  412. +        psd->ncolors = 0x7FFF + 1;
  413. +        psd->pixtype = MWPF_TRUECOLOR555;
  414. +    }
  415. +    else if (CYG_FB_fb0_FORMAT==CYG_FB_FORMAT_16BPP_TRUE_565)
  416. +    {
  417. +        psd->bpp = 16;
  418. +        psd->ncolors = 0xFFFF + 1;
  419. +        psd->pixtype = MWPF_TRUECOLOR565;
  420. +    }
  421. +    else if (CYG_FB_fb0_FORMAT==CYG_FB_FORMAT_32BPP_TRUE_0888)
  422. +    {
  423. +        psd->bpp = 32;
  424. +        psd->ncolors = 0xFFFFFF + 1;
  425. +        psd->pixtype = MWPF_TRUECOLOR0888;
  426. +    }
  427. +    else
  428. +    {
  429. +        EPRINTF("Unsupported display type\n");
  430. +        goto fail;
  431. +    }
  432. +
  433. +    psd->linelen = CYG_FB_fb0_WIDTH * psd->bpp / 8;;  /* What is linelen?  - linelen in bytes for now...*/
  434. +    psd->size = psd->xres * psd->yres * psd->bpp / 8;
  435. +    psd->flags = PSF_SCREEN | PSF_HAVEBLIT;
  436. +    psd->addr = CYG_FB_fb0_BASE;  /* Test */
  437. +//    psd->addr = NULL;  /* We do not want MW to access the frame buffer directly */
  438. +
  439. +
  440. +    /* We always use our own subdriver */
  441. +    psd->orgsubdriver = &synth_subdriver;
  442. +
  443. +
  444. +    status = 2;
  445. +    return psd;        /* success*/
  446. +
  447. + fail:
  448. +    return NULL;
  449. +}
  450. +
  451. +
  452. +/* Close framebuffer*/
  453. +static void synth_close(PSD psd)
  454. +{
  455. +    EPRINTF("%s - NOT IMPLEMENTED\n", __FUNCTION__);
  456. +}
  457. +
  458. +
  459. +static void synth_drawpixel(PSD psd, MWCOORD x, MWCOORD y, MWPIXELVAL c)
  460. +{
  461. +    cyg_fb_write_pixel(&FRAMEBUF,x, y, CMWtofb(&FRAMEBUF,c));
  462. +    cyg_fb_synch(&FRAMEBUF,0);
  463. +}
  464. +
  465. +
  466. +static MWPIXELVAL synth_readpixel(PSD psd, MWCOORD x, MWCOORD y)
  467. +{
  468. +    return CFBtoMW(&FRAMEBUF,cyg_fb_read_pixel(&FRAMEBUF,x,y));
  469. +}
  470. +
  471. +
  472. +static void synth_drawhorizline(PSD psd, MWCOORD x1, MWCOORD x2, MWCOORD y, MWPIXELVAL c)
  473. +{
  474. +    cyg_fb_write_hline(&FRAMEBUF,x1, y,x2-x1+1, CMWtofb(&FRAMEBUF,c));
  475. +    cyg_fb_synch(&FRAMEBUF,0);
  476. +}
  477. +
  478. +
  479. +static void synth_drawvertline(PSD psd, MWCOORD x, MWCOORD y1, MWCOORD y2, MWPIXELVAL c)
  480. +{
  481. +    cyg_fb_write_vline(&FRAMEBUF,x, y1, y2-y1+1, CMWtofb(&FRAMEBUF,c));
  482. +    cyg_fb_synch(&FRAMEBUF,0);
  483. +
  484. +}
  485. +
复制代码
rickleaf 发表于 2011-2-24 08:44:47

  1. +
  2. +static void synth_fillrect(PSD psd,MWCOORD x1, MWCOORD y1, MWCOORD x2, MWCOORD y2, MWPIXELVAL c)
  3. +{
  4. +    cyg_fb_fill_block(&FRAMEBUF,x1, y1, x2-x1+1, y2-y1+1, CMWtofb(&FRAMEBUF,c));
  5. +    cyg_fb_synch(&FRAMEBUF,0);
  6. +}
  7. +
  8. +
  9. +static void synth_blit(PSD dstpsd, MWCOORD dstx, MWCOORD dsty, MWCOORD w, MWCOORD h,
  10. +                     PSD srcpsd, MWCOORD srcx, MWCOORD srcy, long op)
  11. +{
  12. +    /*
  13. +    if (op != 0)
  14. +    {
  15. +        diag_printf("synth_blit(): op = 0x%x not supported\n", op);
  16. +    }
  17. +
  18. +    if (srcpsd->addr == frame_format->frame_buffer && dstpsd->addr != frame_format->frame_buffer)
  19. +    {
  20. +        synthCopyRect2Buffer(srcx, srcy, w, h, dstpsd->addr, dstpsd->xres, dstpsd->yres, dstx, dsty);
  21. +    }
  22. +    else if (srcpsd->addr != frame_format->frame_buffer && dstpsd->addr == frame_format->frame_buffer)
  23. +    {
  24. +        synthCopyBuffer2Rect(srcpsd->addr, srcpsd->xres, srcpsd->yres, srcx, srcy, dstx, dsty, w, h);
  25. +    }
  26. +    else if (srcpsd->addr == frame_format->frame_buffer && dstpsd->addr == frame_format->frame_buffer)
  27. +    {
  28. +        synthCopyRect(srcx, srcy, w, h, dstx, dsty);
  29. +    }
  30. +    else
  31. +    {
  32. +        diag_printf("synth_blit(): Error unsupported operation\n");
  33. +    }
  34. +    */
  35. +    diag_printf("synth_blit(): Error unsupported operation\n");
  36. +}
  37. +
  38. +static void synth_stretchblit(PSD dstpsd, MWCOORD dstx, MWCOORD dsty, MWCOORD dstw,
  39. +                            MWCOORD dsth, PSD srcpsd, MWCOORD srcx, MWCOORD srcy,
  40. +                            MWCOORD srcw, MWCOORD srch, long op)
  41. +{
  42. +    diag_printf("synth_stretch_blit() not implemented\n");
  43. +}
  44. +
  45. +
  46. +static void synth_getscreeninfo(PSD psd,PMWSCREENINFO psi)
  47. +{
  48. +    psi->rows = psd->yvirtres;
  49. +    psi->cols = psd->xvirtres;
  50. +    psi->planes = psd->planes;
  51. +    psi->bpp = psd->bpp;
  52. +    psi->ncolors = psd->ncolors;
  53. +    psi->pixtype = psd->pixtype;
  54. +    psi->fonts = NUMBER_FONTS;
  55. +    psi->portrait = psd->portrait;
  56. +    psi->fbdriver = true;
  57. +
  58. +    switch (psd->pixtype) {
  59. +    case MWPF_TRUECOLOR332:
  60. +        psi->rmask = 0xE0;
  61. +        psi->gmask = 0x1C;
  62. +        psi->bmask = 0x03;
  63. +        break;
  64. +    case MWPF_TRUECOLOR233:
  65. +        psi->rmask = 0x07;
  66. +        psi->gmask = 0x38;
  67. +        psi->bmask = 0xC0;
  68. +        break;
  69. +    case MWPF_TRUECOLOR555:
  70. +        psi->rmask = 0x7c00;
  71. +        psi->gmask = 0x03e0;
  72. +        psi->bmask = 0x001f;
  73. +        break;
  74. +    case MWPF_TRUECOLOR565:
  75. +        psi->rmask = 0xf800;
  76. +        psi->gmask = 0x07e0;
  77. +        psi->bmask = 0x001f;
  78. +        break;
  79. +    case MWPF_TRUECOLOR0888:
  80. +        psi->rmask = 0xFF0000;
  81. +        psi->gmask = 0x00FF00;
  82. +        psi->bmask = 0x0000FF;
  83. +        break;
  84. +    default:
  85. +        printf("%s - unsupported pixtype\n", __FUNCTION__);
  86. +        psi->rmask = 0xff;
  87. +        psi->gmask = 0xff;
  88. +        psi->bmask = 0xff;
  89. +        break;
  90. +    }
  91. +
  92. +    /* Need to figure out better values possibly */
  93. +    psi->xdpcm = 24;    /* assumes screen width of 24 cm */
  94. +    psi->ydpcm = 18;    /* assumes screen height of 18 cm */
  95. +}
  96. +
  97. +static void synth_drawarea(PSD psd, driver_gc_t *gc, int op)
  98. +{
  99. +    diag_printf("synth_drawarea() not implemented\n");
  100. +}
  101. +
  102. +
  103. +/*
  104. + * Initialize memory device with passed parms,
  105. + * select suitable framebuffer subdriver,
  106. + * and set subdriver in memory device.
  107. + */
  108. +MWBOOL synth_mapmemgc(PSD mempsd,MWCOORD w,MWCOORD h,int planes,int bpp,int linelen,
  109. +    int size,void *addr)
  110. +{
  111. +    PSUBDRIVER subdriver;
  112. +
  113. +    /* initialize mem screen driver*/
  114. +    initmemgc(mempsd, w, h, planes, bpp, linelen, size, addr);
  115. +
  116. +    subdriver = &synth_subdriver;
  117. +
  118. +    /* set and initialize subdriver into mem screen driver*/
  119. +    if(!set_subdriver(mempsd, subdriver, TRUE))
  120. +    {
  121. +        diag_printf("set_subdriver() failed\n");
  122. +        return 0;
  123. +    }
  124. +
  125. +    return 1;
  126. +}
  127. diff -r 418d34334c77 packages/services/gfx/mw/current/src/ecos/demo_thread.c
  128. --- /dev/null        Thu Jan 01 00:00:00 1970 +0000
  129. +++ b/packages/services/gfx/mw/current/src/ecos/demo_thread.c        Fri Apr 23 14:41:29 2010 +0800
  130. @@ -0,0 +1,53 @@
  131. +#include      /* which packages are enabled/disabled */
  132. +#ifdef CYGPKG_KERNEL
  133. +# include
  134. +#endif
  135. +#ifdef CYGPKG_LIBC
  136. +# include
  137. +#endif
  138. +#ifdef CYGPKG_IO_SERIAL
  139. +# include
  140. +#endif
  141. +
  142. +#ifndef CYGFUN_KERNEL_API_C
  143. +# error Kernel API must be enabled to build this application
  144. +#endif
  145. +
  146. +#ifndef CYGPKG_LIBC_STDIO
  147. +# error C library standard I/O must be enabled to build this application
  148. +#endif
  149. +
  150. +#ifndef CYGPKG_IO_SERIAL_HALDIAG
  151. +# error I/O HALDIAG pseudo-device driver must be enabled to build this application
  152. +#endif
  153. +
  154. +/* INCLUDES */
  155. +
  156. +#include                       /* printf */
  157. +#include                       /* printf */
  158. +#include                      /* strlen */
  159. +#include             /* All the kernel specific stuff */
  160. +#include         
  161. +
  162. +#define MWINCLUDECOLORS
  163. +#include "nano-X.h"
  164. +
  165. +#include
  166. +_mw_app("demo", demo, ECOS_MW_APP_PRIORITY, 0);
  167. +
  168. +//
  169. +// Component interfaces
  170. +//
  171. +
  172. +externC int demo_main(int argc, char *argv[]);
  173. +
  174. +/*static*/ void
  175. +demo_thread(CYG_ADDRWORD data)
  176. +{
  177. +    int argc = 1;
  178. +    char *argv[] = {"demo" };
  179. +
  180. +    cyg_thread_delay(10*100);
  181. +    INIT_PER_THREAD_DATA();
  182. +    demo_main(argc, argv);
  183. +}
  184. diff -r 418d34334c77 packages/services/gfx/mw/current/src/ecos/ecos_app.c
  185. --- a/packages/services/gfx/mw/current/src/ecos/ecos_app.c        Thu Apr 01 13:17:10 2010 +0000
  186. +++ b/packages/services/gfx/mw/current/src/ecos/ecos_app.c        Fri Apr 23 14:41:29 2010 +0800
  187. @@ -115,7 +115,11 @@
  188.      {
  189.          int res;
  190.          printf("... Mounting JFFS2 on "/"\n");
  191. +#ifdef CYGPKG_DEVS_FLASH_SYNTH_V2
  192. +        res = mount( "/dev/flash/0/", "/", "jffs2" );
  193. +#else
  194.          res = mount( CYGDAT_IO_FLASH_BLOCK_DEVICE_NAME_1, "/", "jffs2" );
  195. +#endif
  196.          if (res < 0) {
  197.              printf("Mount "/" failed - res: %d\n", res);
  198.          }
  199. diff -r 418d34334c77 packages/services/gfx/mw/current/src/ecos/nanowm_thread.c
  200. --- a/packages/services/gfx/mw/current/src/ecos/nanowm_thread.c        Thu Apr 01 13:17:10 2010 +0000
  201. +++ b/packages/services/gfx/mw/current/src/ecos/nanowm_thread.c        Fri Apr 23 14:41:29 2010 +0800
  202. @@ -43,7 +43,7 @@

  203. externC int nanowm_main(int argc, char *argv[]);

  204. -static void
  205. +/*static*/ void
  206. nanowm_thread(CYG_ADDRWORD data)
  207. {
  208.      int argc = 0;
  209. diff -r 418d34334c77 packages/services/gfx/mw/current/src/ecos/nanox_thread.c
  210. --- a/packages/services/gfx/mw/current/src/ecos/nanox_thread.c        Thu Apr 01 13:17:10 2010 +0000
  211. +++ b/packages/services/gfx/mw/current/src/ecos/nanox_thread.c        Fri Apr 23 14:41:29 2010 +0800
  212. @@ -41,7 +41,7 @@

  213. externC int nanox_main(int argc, char *argv[]);

  214. -static void
  215. +/*static*/ void
  216. nanox_thread(CYG_ADDRWORD data)
  217. {
  218.      int argc = 0;
  219. diff -r 418d34334c77 packages/services/gfx/mw/current/src/ecos/ntetris_thread.c
  220. --- a/packages/services/gfx/mw/current/src/ecos/ntetris_thread.c        Thu Apr 01 13:17:10 2010 +0000
  221. +++ b/packages/services/gfx/mw/current/src/ecos/ntetris_thread.c        Fri Apr 23 14:41:29 2010 +0800
  222. @@ -41,7 +41,7 @@

  223. externC int ntetris_main(int argc, char *argv[]);

  224. -static void
  225. +/*static*/ void
  226. ntetris_thread(CYG_ADDRWORD data)
  227. {
  228.      int argc = 1;
  229. diff -r 418d34334c77 packages/services/gfx/mw/current/src/ecos/world_thread.c
  230. --- a/packages/services/gfx/mw/current/src/ecos/world_thread.c        Thu Apr 01 13:17:10 2010 +0000
  231. +++ b/packages/services/gfx/mw/current/src/ecos/world_thread.c        Fri Apr 23 14:41:29 2010 +0800
  232. @@ -41,7 +41,7 @@

  233. externC int world_main(int argc, char *argv[]);

  234. -static void
  235. +/*static*/ void
  236. world_thread(CYG_ADDRWORD data)
  237. {
  238.      int argc = 1;
  239. diff -r 418d34334c77 packages/services/gfx/mw/current/src/nanox/srvmain.c
  240. --- a/packages/services/gfx/mw/current/src/nanox/srvmain.c        Thu Apr 01 13:17:10 2010 +0000
  241. +++ b/packages/services/gfx/mw/current/src/nanox/srvmain.c        Fri Apr 23 14:41:29 2010 +0800
  242. @@ -47,6 +47,7 @@
  243. # include
  244. # ifdef CYGPKG_NET
  245. #  define NONETWORK 0
  246. +#  define MW_NOSIGNALS 1
  247. # else
  248. #  error Not yet supported.
  249. #  define NONETWORK 1
  250. @@ -725,9 +726,11 @@
  251.         selection_owner.typelist = NULL;

  252. #if !NONETWORK
  253. +#ifndef MW_NOSIGNALS
  254.         /* ignore pipe signal, sent when clients exit*/
  255.         signal(SIGPIPE, SIG_IGN);
  256.         signal(SIGHUP, SIG_IGN);
  257. +#endif

  258.         if (GsOpenSocket() < 0) {
  259.                 EPRINTF("Cannot bind to named socket\n");
复制代码
一朝成名 发表于 2011-2-24 12:30:41
强人。说啥也要顶~~~

我以前用ecos做过产品,现在也不怎么用了,不过还是要感谢你为大家做的贡献。。。。
其实ecos跑GUI没太合适的东西,除了Micro X还有民间人移植的minigui
rickleaf 发表于 2011-2-24 16:04:31
我把minigui,pw和emwin都放上来了,不过emwin和 minigui并不是opensource啊
sw9518 发表于 2011-4-21 09:13:21
牛啊
您需要登录后才可以发表评论 登录 | 立即注册

厂商推荐

相关视频

关于我们  -  服务条款  -  使用指南  -  站点地图  -  友情链接  -  联系我们
电子工程网 © 版权所有   京ICP备16069177号 | 京公网安备11010502021702
快速回复 返回顶部 返回列表