2 * Written 1999-03-19 by Jonathan Larmour, Cygnus Solutions
3 * Modifed for touchscreen testing by Richard Panton 13-09-00
4 * This file is in the public domain and may be used for any purpose
7 /* CONFIGURATION CHECKS */
9 #include <pkgconf/system.h> /* which packages are enabled/disabled */
11 # include <pkgconf/kernel.h>
14 # include <pkgconf/libc.h>
16 #ifdef CYGPKG_IO_SERIAL
17 # include <pkgconf/io_serial.h>
22 #ifdef CYGPKG_FS_JFFS2
23 # include <pkgconf/io_flash.h>
27 #include <pkgconf/microwindows.h>
29 #ifndef CYGFUN_KERNEL_API_C
30 # error Kernel API must be enabled to build this application
33 #ifndef CYGPKG_LIBC_STDIO
34 # error C library standard I/O must be enabled to build this application
37 #ifndef CYGPKG_IO_SERIAL_HALDIAG
38 # error I/O HALDIAG pseudo-device driver must be enabled to build this application
43 #include <stdio.h> /* printf */
44 #include <stdlib.h> /* printf */
45 #include <string.h> /* strlen */
46 #include <ctype.h> /* tolower */
47 #include <cyg/kernel/kapi.h> /* All the kernel specific stuff */
48 #include <cyg/hal/hal_arch.h> /* CYGNUM_HAL_STACK_SIZE_TYPICAL */
50 #include <network.h> /* init_all_network_interfaces() */
51 #include <microwin/ecos_mw_app.h>
53 // Define table boundaries
54 CYG_HAL_TABLE_BEGIN( __MW_APP_TAB__, _mw_apps );
55 CYG_HAL_TABLE_END( __MW_APP_TAB_END__, _mw_apps );
56 extern struct _mw_app_entry __MW_APP_TAB__[], __MW_APP_TAB_END__;
58 static char startup_stack[STACKSIZE];
59 cyg_handle_t startup_thread;
60 cyg_thread startup_thread_obj;
63 strcasecmp(const char *s1, const char *s2)
67 while ((c1 = tolower(*s1++)) == (c2 = tolower(*s2++)))
70 return ((unsigned char)c1 - (unsigned char)c2);
74 startup(CYG_ADDRESS data)
76 cyg_ucount32 nanox_data_index;
77 struct _mw_app_entry *nx;
79 printf("SYSTEM INITIALIZATION in progress\n");
81 init_all_network_interfaces();
88 printf("Mount ROM file system\n");
89 #if (defined CYGPKG_HAL_ARM_SA11X0_IPAQ) && (!defined CYGBLD_MICROWINDOWS_VNC_DRIVERS)
90 // Work around hardware anomaly which causes major screen flicker
93 if ((hold_rom_fs = malloc(0x80080)) != 0) {
94 // Note: ROM fs requires 32 byte alignment
95 hold_rom_fs = (char *)(((unsigned long)hold_rom_fs + 31) & ~31);
96 memcpy(hold_rom_fs, 0x50F00000, 0x80000);
97 sprintf(ROM_fs, "0x%08x", hold_rom_fs);
99 printf("Can't allocate memory to hold ROM fs!\n");
103 sprintf(ROM_fs, "0x%08x", 0x50F00000);
104 sprintf(ROM_fs, "0x%08x", 0x61F00000);
106 printf("ROM fs at %s\n", ROM_fs);
107 if ((res = mount(ROM_fs, "/", "romfs")) < 0) {
108 printf("... failed\n");
117 printf("... Mounting JFFS2 on \"/\"\n");
118 res = mount( CYGDAT_IO_FLASH_BLOCK_DEVICE_NAME_1, "/", "jffs2" );
120 printf("Mount \"/\" failed - res: %d\n", res);
126 // Allocate a free thread data slot
127 // Note: all MicroWindows/NanoX threads use this slot for NanoX-private
128 // data. That's why there is only one call here.
129 nanox_data_index = cyg_thread_new_data_index();
130 printf("data index = %d\n", nanox_data_index);
132 printf("Creating system threads\n");
133 for (nx = __MW_APP_TAB__; nx != &__MW_APP_TAB_END__; nx++) {
134 printf("Creating %s thread\n", nx->name);
135 cyg_thread_create(nx->prio,
137 (cyg_addrword_t) nanox_data_index,
139 (void *)nx->stack, STACKSIZE,
143 printf("Starting threads\n");
144 for (nx = __MW_APP_TAB__; nx != &__MW_APP_TAB_END__; nx++) {
145 printf("Starting %s\n", nx->name);
146 cyg_thread_resume(nx->t);
148 (nx->init)(nanox_data_index);
152 printf("SYSTEM THREADS STARTED!\n");
155 void cyg_user_start(void)
157 // Create the initial thread and start it up
158 cyg_thread_create(ECOS_MW_STARTUP_PRIORITY,
162 (void *)startup_stack, STACKSIZE,
164 &startup_thread_obj);
165 cyg_thread_resume(startup_thread);