本文原创,转载请注明出处 (rickleaf)
Microwindows 在发布之初,提供了两种API接口,WinAPI和Nano-X
之前本博客曾经讨论过如何应用ecos自带的Microwindows的Nano-X接口,并且应用了FLNX作为Nano-X下面轻量级的GUI库。
那么ecos下面的Microwindows的WINAPI支持吗?
2. MWIN的移植
参考了新版Microwindows的WINAPI对ecos是支持的,不过老板不的Microwindows采用的select函数和unix是共用的。
所以我稍微做了一次改动就可以在ecos上运行起来了。
首先是cdl,加入mwin的代码
cdl_component CYGBLD_MICROWINDOWS_MW {
display "Build the Windows-compatible API"
default_value 0
requires CYGPKG_KERNEL
# NANO X
compile /
mwin/winclip.c /
mwin/windefw.c /
mwin/winevent.c /
mwin/winexpos.c /
mwin/winfont.c /
mwin/wingdi.c /
mwin/winmain.c /
mwin/winrgn.c /
mwin/winsbar.c /
mwin/winuser.c /
mwin/bmp/microwin.c /
mwin/bmp/penguin.c /
mwin/winlib/draw3d.c /
mwin/winlib/ptinsid.c /
mwin/winlib/insetr.c /
mwin/winlib/fastfill.c /
mwin/winlib/graph3d.c /
mwin/winlib/mwuser.c /
mwin/winlib/button.c /
mwin/winlib/edit.c /
mwin/winlib/listbox.c /
mwin/winlib/progbar.c /
mwin/winlib/static.c /
mwin/winlib/combobox.c /
mwin/winlib/caret.c /
mwin/winlib/scrlbar.c /
ecos/ecos_winmain.c
cdl_option CYGBLD_MICROWINDOWS_MW_DEMO {
display "Build complete eCos MicroWindows WAPI application"
default_value 0
make -priority 320 {
<PREFIX>/bin/ecos_mwin.elf : $(PREFIX)/lib/target.ld $(PREFIX)/lib/vectors.o $(PREFIX)/lib/libtarget.a $(PREFIX)/lib/libextras.a $(REPOSITORY)/$(PACKAGE)/src/demos/mwin/mdemo.c
@sh -c "mkdir -p $(dir $@)"
$(CC) -c $(INCLUDE_PATH) $(CFLAGS) -o $(PREFIX)/lib/mdemo.o $(REPOSITORY)/$(PACKAGE)/src/demos/mwin/mdemo.c
$(CC) $(LDFLAGS) -L$(PREFIX)/lib -Ttarget.ld -o $@ $(PREFIX)/lib/mdemo.o
}
}
}
要加入我们自己的ecos_winmain.c
#include <cyg/kernel/kapi.h>
#include <pkgconf/system.h>
extern void invoke_WinMain(int argc, char** argv);
#define STACK_SIZE (16*1024)
struct ecos_winmain_data
{
cyg_thread thread;
cyg_handle_t handle;
char stack[STACK_SIZE] __attribute__ ((aligned(16)));
int argc;
char** argv;
};
static void winmain_mainloop(cyg_addrword_t data)
{
struct ecos_winmain_data* winmain_data=(struct ecos_winmain_data*)data;
invoke_WinMain(winmain_data->argc, winmain_data->argv);
}
void start_WinMain_thread(int priority, int argc, char** argv)
{
static struct ecos_winmain_data winmain_data;
winmain_data.argc=argc;
winmain_data.argv=argv;
cyg_thread_create(priority, winmain_mainloop, (cyg_addrword_t) &winmain_data,
"winmain", (void *) winmain_data.stack, STACK_SIZE,
&winmain_data.handle, &winmain_data.thread);
cyg_thread_resume(winmain_data.handle);
}
void start_WinMain(int argc, char** argv)
{
invoke_WinMain(argc, argv);
}
#ifndef CYGPKG_LIBC_STARTUP
#include <cyg/infra/diag.h>
void exit(int status)
{
diag_printf("exit(%d) was called !/n", status);
}
#endif
然后修改mdemo,让他能在ecos上运行
Microwindows 在发布之初,提供了两种API接口,WinAPI和Nano-X
之前本博客曾经讨论过如何应用ecos自带的Microwindows的Nano-X接口,并且应用了FLNX作为Nano-X下面轻量级的GUI库。
那么ecos下面的Microwindows的WINAPI支持吗?
2. MWIN的移植
参考了新版Microwindows的WINAPI对ecos是支持的,不过老板不的Microwindows采用的select函数和unix是共用的。
所以我稍微做了一次改动就可以在ecos上运行起来了。
首先是cdl,加入mwin的代码
cdl_component CYGBLD_MICROWINDOWS_MW {
display "Build the Windows-compatible API"
default_value 0
requires CYGPKG_KERNEL
# NANO X
compile /
mwin/winclip.c /
mwin/windefw.c /
mwin/winevent.c /
mwin/winexpos.c /
mwin/winfont.c /
mwin/wingdi.c /
mwin/winmain.c /
mwin/winrgn.c /
mwin/winsbar.c /
mwin/winuser.c /
mwin/bmp/microwin.c /
mwin/bmp/penguin.c /
mwin/winlib/draw3d.c /
mwin/winlib/ptinsid.c /
mwin/winlib/insetr.c /
mwin/winlib/fastfill.c /
mwin/winlib/graph3d.c /
mwin/winlib/mwuser.c /
mwin/winlib/button.c /
mwin/winlib/edit.c /
mwin/winlib/listbox.c /
mwin/winlib/progbar.c /
mwin/winlib/static.c /
mwin/winlib/combobox.c /
mwin/winlib/caret.c /
mwin/winlib/scrlbar.c /
ecos/ecos_winmain.c
cdl_option CYGBLD_MICROWINDOWS_MW_DEMO {
display "Build complete eCos MicroWindows WAPI application"
default_value 0
make -priority 320 {
<PREFIX>/bin/ecos_mwin.elf : $(PREFIX)/lib/target.ld $(PREFIX)/lib/vectors.o $(PREFIX)/lib/libtarget.a $(PREFIX)/lib/libextras.a $(REPOSITORY)/$(PACKAGE)/src/demos/mwin/mdemo.c
@sh -c "mkdir -p $(dir $@)"
$(CC) -c $(INCLUDE_PATH) $(CFLAGS) -o $(PREFIX)/lib/mdemo.o $(REPOSITORY)/$(PACKAGE)/src/demos/mwin/mdemo.c
$(CC) $(LDFLAGS) -L$(PREFIX)/lib -Ttarget.ld -o $@ $(PREFIX)/lib/mdemo.o
}
}
}
要加入我们自己的ecos_winmain.c
#include <cyg/kernel/kapi.h>
#include <pkgconf/system.h>
extern void invoke_WinMain(int argc, char** argv);
#define STACK_SIZE (16*1024)
struct ecos_winmain_data
{
cyg_thread thread;
cyg_handle_t handle;
char stack[STACK_SIZE] __attribute__ ((aligned(16)));
int argc;
char** argv;
};
static void winmain_mainloop(cyg_addrword_t data)
{
struct ecos_winmain_data* winmain_data=(struct ecos_winmain_data*)data;
invoke_WinMain(winmain_data->argc, winmain_data->argv);
}
void start_WinMain_thread(int priority, int argc, char** argv)
{
static struct ecos_winmain_data winmain_data;
winmain_data.argc=argc;
winmain_data.argv=argv;
cyg_thread_create(priority, winmain_mainloop, (cyg_addrword_t) &winmain_data,
"winmain", (void *) winmain_data.stack, STACK_SIZE,
&winmain_data.handle, &winmain_data.thread);
cyg_thread_resume(winmain_data.handle);
}
void start_WinMain(int argc, char** argv)
{
invoke_WinMain(argc, argv);
}
#ifndef CYGPKG_LIBC_STARTUP
#include <cyg/infra/diag.h>
void exit(int status)
{
diag_printf("exit(%d) was called !/n", status);
}
#endif
然后修改mdemo,让他能在ecos上运行
----------- packages/services/gfx/mw/current/src/demos/mwin/mdemo.c -----------
@@ -6,9 +6,10 @@
#define MWINCLUDECOLORS
#include "windows.h"
#include "wintern.h" /* for MwSetDesktopWallpaper*/
-
#include "device.h"
-
+#if __ECOS
+#include "ecos_winmain.h"
+#endif
#if DOS_TURBOC
unsigned _stklen = 4096;
#endif
@@ -486,3 +487,10 @@
}
return 0;
}
+
+#if __ECOS
+void cyg_user_start(void)
+{
+ start_WinMain_thread(10,0,0);
+}
+#endif
本文原创,转载请注明出处 (rickleaf)