Nano-x programming, #1: Introduction and security
Jollen
Output at August 11,200 AM
Ben
First, we need to explain the basic concepts and architecture of Microsoft Windows, and then explain how to enable Microsoft Windows to support X11.
Is a hello World Program. At the beginning, we will first develop Microsoft Windows on X.
Later, we will move the development environment to the embedded Linux system later.
Author: Yan junhong
Www.jollen.org
Microwindows Network Resources
Http://www.microwindow.org Official Website
SDK hand: http://embedded.centurysoftware.com/docs/nx/
Getting Started: http://home.twcny.rr.com/embedded/microwin/install/index.html
Lower limit (original limit): ftp://microwindows.org/pub/microwindows/microwindows-0.89.tar.gz
Lower cycle (font, including Chinese font): ftp://microwindows.org/pub/microwindows/microwindows-fonts-0.89.tar.gz
Microwindows Introduction
Layered design)
Microwindows is a three-dimensional Architecture Design for microservices, which is divided into three parts:
- Lowest level
-Canvas, mouse/touchpad, keyboard, and other hardware driver.
- Mid Level
-The portable memory engine (graphics engine) that can be ported (portable) and device-independent ).
- Upper Level
-The API provided to programmer. Our program can only call the Microwindows API for programming.
What we want to learn is the most popular API. The main purpose of this tutorial is to introduce how to use the Microwindows API.
Microwindows Linux Driver Support
Microwindows supports the framebuffer of Linux 2.2.x in terms of terminal screens. It can also run in 16-bit embedded Linux kernel (elks.
In terms of mouse, Microwindows supports GPM and serial port mouse, as well as touch panel drivers.
For zookeeper, Microwindows supports tty zookeeper fetch, which can be used in both Linux and elks.
Hardware Device |
Driver |
Linux 2.2.x framebuffer |
Scr_fb.c FB. c fblin[1248] . C |
GPM mouse |
Mou_gpm.c |
Serial mouse |
Mou_ser.c |
Touch Panel |
Mou_tp.c |
Tty keyboard |
Kbd_tty.c |
Microwindows APIs
Microwindows has two different APIs:
- Microwindows API
- Nano-x API
Microwindows
API is compatible with Microsoft Win32 and wince GDI, so the firewall Window System of Microwindows API is
Message-based architecture (that is, the plain window system of message-passing system ).
The nano-x API can be roughly equivalent to a small X Server System. The nano-x API is designed based on the internal xlib API. Therefore, we can directly understand that the client/server architecture is built using the guest window system designed by the nano-x API.
Microsoft Windows endpoints
1. Support for X on the PC, which is easy for zookeeper development.
2. role supports framebuffer for embedded system.
3. The system is small.
4. Simple API learning.
5. Support for handling TrueType fonts.
6. Support Arm/MIPS/elks.
*Elks is a 16-bit Linux kernel.
Server guard Microwindows
Microwindows
You can run not only on framebuffer, but also on X. At the beginning of Microsoft Windows, we will first
So the Microwindows program runs on X Window System after there is no specific explanation.
To enable Microsoft Windows to record data on X, you must first set the following parameters before performing the operation:
1. download microsoft windows and start it.
2. Rows X Window System, into the structured environment; to the microwin-0.89/src/rows xconfigure. (Limit 1)
Protocol 1: Microwindows Interface
3. ThenSelect
Below are several projects:
Compiling options-> optimize
Platform-> Linux (native)
Platform-> Linux (native)-> options-> screen driver-> X11 (Click Options to set the resolution)
Platform-> Linux (native)-> options-> mouse driver-> GPM mouse (instead of your mouse)
Platform-> Linux (native)-> options-> keyboard driver-> tty
I/O-> have file I/O
I/O-> have BMP support
I/O-> have JPEG support
I/O-> have FreeType support (TrueType fonts) (Click Options to set the path. Please use free type 1, red Hat Linux 7.x users should set include dir to/usr/include/freetype1,
Because the creator can upload a Chinese font, select FreeType for support.
)
Libraries to compile-> nanox)
Libraries to compile-> libraries to shared libs !)
Libraries to compile-> nanox-> options-> enable shared mem support
Libraries to compile-> nanox-> options-> compile demos)
4. Set the rows in microwin-0.89/src/Make
Start renewal.
5. Try again laterMake install
Security. Because we have checked shared libraries, we can delete the following cases (not enough !) :
/Usr/lib/libmwdrivers.
/Usr/lib/libmwengine.
/Usr/lib/libmwfonts.
/Usr/lib/libmwobjects.
/Usr/lib/libnano-X.a
/Usr/lib/libvncauth.
6. And then to the microwin-0.89/src/bin/Under the rows of examples:
$./Nano-X & sleep 1 (nano X server in Microsoft Windows)
$./Nanowm & sleep 1 (Window Manager of anao X Server)
$./Demo & (Program)
7. If you can see this aspect, it indicates that the Microwindows security is successful. Next, you can start the first program!
Nano-x API ingress-Hello World
* This tutorial is based on the nano-x API. If you are interested in Microwindows APIs, you can refer to official website files.
#include <stdio.h>
#include <microwin/nano-X.h>
GR_WINDOW_ID wid;
GR_GC_ID gc;
void event_handler (GR_EVENT *event);
int main (void)
{
if (GrOpen() < 0) {
fprintf (stderr, "GrOpen failed");
exit (1);
}
gc = GrNewGC();
GrSetGCForeground (gc, 0xFF0000);
wid = GrNewWindowEx(GR_WM_PROPS_APPFRAME |
GR_WM_PROPS_CAPTION |
GR_WM_PROPS_CLOSEBOX,
"jollen.org",
GR_ROOT_WINDOW_ID,
0, 0, 200, 200, 0xFFFFFF);
GrSelectEvents(wid, GR_EVENT_MASK_CLOSE_REQ | GR_EVENT_MASK_EXPOSURE);
GrMapWindow(wid);
GrMainLoop(event_handler);
}
void event_handler (GR_EVENT *event)
{
switch (event->type)
{
case GR_EVENT_TYPE_EXPOSURE:
GrText(wid, gc, 50, 50, "Hello World", -1, GR_TFASCII);
break;
case GR_EVENT_TYPE_CLOSE_REQ:
GrClose();
exit (0);
default: break;
}
}
This is a hello World Program for Microsoft Windows. During the upgrade, the nano-X program should be connected:
Gcc-O hello. c-Lnano-x
Using this program, we can determine whether or not the Microwindows system can be accessed and used. Before the procedure, do not forget to run nano-X and nanowm!
Lifecycle 2: Hello World
In the next phase, we will begin to explain the content of this program and more Microwindows programming.