]> git.zerfleddert.de Git - linexec-j720/commitdiff
Initial import of xdadeveloper linexec sources
authormichael <michael>
Sun, 24 Jul 2005 17:24:33 +0000 (17:24 +0000)
committermichael <michael>
Sun, 24 Jul 2005 17:24:33 +0000 (17:24 +0000)
37 files changed:
Makefile [new file with mode: 0644]
Makefile.project [new file with mode: 0644]
ReadMe.txt [new file with mode: 0644]
ReadMe.wine [new file with mode: 0644]
StdAfx.cpp [new file with mode: 0644]
StdAfx.h [new file with mode: 0644]
WhatsNew.txt [new file with mode: 0644]
asm/asm-wince.asm [new file with mode: 0644]
asm/asm-wince.asm.bz2 [new file with mode: 0644]
asm/asm.asm [new file with mode: 0644]
asm/asm.asm.bz2 [new file with mode: 0644]
asm/asmstuff-wince.asm [new file with mode: 0644]
asm/asmstuff-wince.asm.bz2 [new file with mode: 0644]
asm/asmstuff.asm [new file with mode: 0644]
asm/asmstuff.asm.bz2 [new file with mode: 0644]
asm/test123.asm [new file with mode: 0644]
asm/test123.asm.bz2 [new file with mode: 0644]
boot.cpp [new file with mode: 0644]
booting.bmp [new file with mode: 0644]
config.h [new file with mode: 0644]
gpio.cpp [new file with mode: 0644]
graphics.cpp [new file with mode: 0644]
linexec.vcb [new file with mode: 0644]
linexec.vcl [new file with mode: 0644]
linexec.vco [new file with mode: 0644]
linexec.vcp [new file with mode: 0644]
linexec.vcw [new file with mode: 0644]
memory.cpp [new file with mode: 0644]
newres.h [new file with mode: 0644]
resource.h [new file with mode: 0644]
setup.h [new file with mode: 0644]
tester1.aps [new file with mode: 0644]
tester1.cpp [new file with mode: 0644]
tester1.h [new file with mode: 0644]
tester1.ico [new file with mode: 0644]
tester1.rc [new file with mode: 0644]
uart.cpp [new file with mode: 0644]

diff --git a/Makefile b/Makefile
new file mode 100644 (file)
index 0000000..34412f2
--- /dev/null
+++ b/Makefile
@@ -0,0 +1,114 @@
+# Makefile for building PocketPC ARM binary from Linux using wine and EVC
+# By pigeon
+# Inspired by HRET written by anpaza
+# Requires GNU Make, wine, and stuff from EVC, read ReadMe.wine
+
+#============================================== User-defined variables ======#
+# The directory where your MSVC for StrongARM and the SDK is installed.
+# You should set up WINE (see /etc/wine.reg) so that it "sees" this drive
+#BASE=d:\\msvc-arm
+BASE=c:\\evc
+
+#=========================================================== Compilers ======#
+# Set some env vars for msvc to use
+WINEPATH=$(BASE)\\
+WINE=wine --debugmsg fixme-console
+
+# Output directory
+OUT=out/
+
+
+# Makefile.project contains sources, target name, and libs
+include Makefile.project
+
+SUB1 = $(SRCS:.cpp=.obj)
+SUB2 = $(SUB1:.asm=.obj)
+SUB3 = $(SUB2:.rc=.res)
+SUB4 = $(SUB3:%.obj=$(OUT)%.obj)
+OBJS = $(SUB4:%.res=$(OUT)%-res.obj)
+
+
+.SUFFIXES:
+.SUFFIXES: .exe .obj .res .asm -res.obj
+
+
+# You shouldn't need to change anything below.
+
+CXX=$(WINE) -- $(BASE)\\clarm.exe -c
+
+CXXFLAGS.DEF=-DARM -D_ARM_ -DUNICODE -D_UNICODE -DUNDER_CE=300 -D_WIN32_WCE=300
+CXXFLAGS.INC=-Iinclude -I$(INCLUDE) $(CFLAGS)
+
+#-Oxs 
+# Uncomment this for Dell Axim
+#CXXFLAGS.DEF+=-DAXIM
+
+CXXFLAGS=-nologo -W3 -Zi -Od $(CXXFLAGS.DEF) $(CXXFLAGS.INC)
+
+
+ASM=$(WINE) -- $(BASE)\\armasm.exe
+#ASMFLAGS=-arch 4 -cpu StrongARM1 -32
+
+
+RC=$(WINE) -- $(BASE)\\rc.exe
+#RCFLAGS=-r -l 0x409 $(CXXFLAGS.DEF) $(CXXFLAGS.INC)
+RCFLAGS=$(CXXFLAGS.DEF) $(CXXFLAGS.INC)
+
+
+CVTRES=$(WINE) -- $(BASE)\\cvtres.exe
+CVTRESFLAGS=-machine:arm -windowsce
+
+
+LD=$(WINE) -- $(BASE)\\link.exe
+
+
+
+# From EVC project settings
+LDFLAGS= \
+    -nologo \
+    -base:"0x00010000" \
+    -stack:0x10000,0x1000 \
+    -entry:"WinMainCRTStartup" \
+    -align:"4096" \
+    -machine:ARM \
+    -subsystem:windowsce,3.0 \
+    -incremental:yes \
+    -libpath:$(LIB)
+
+
+#export MSC_CMD_FLAGS=/c
+
+
+#============================================================= Targets ======#
+all: $(OUT) $(OUT)$(TARGETBIN)
+
+
+clean:
+       rm -rf $(OUT)
+
+#dep:
+#      makedep -r $(CXXFLAGS.DEF) $(CXXFLAGS.INC) -p'$$(OUT)' -o.obj src/*.cpp
+
+
+$(OUT)$(TARGETBIN): $(OBJS)
+
+
+#=============================================================== Rules ======#
+$(OUT)%.obj: %.cpp
+       $(CXX) $(CXXFLAGS) -Fo$@ $<
+
+$(OUT)%.obj: %.asm
+       $(ASM) $(ASMFLAGS) -o $@ $<
+
+$(OUT)%.res: %.rc
+       $(RC) $(RCFLAGS) -fo $@ $<
+
+$(OUT)%-res.obj: $(OUT)%.res
+       $(CVTRES) $(CVTRESFLAGS) -out:$@ $<
+
+$(OUT)%.exe:
+       $(LD) $(LDFLAGS) -out:$@ $(^) $(LIBS)
+
+$(OUT):
+       mkdir $@
+
diff --git a/Makefile.project b/Makefile.project
new file mode 100644 (file)
index 0000000..c25460b
--- /dev/null
@@ -0,0 +1,30 @@
+# Makefile.project
+# You specify target name, source files, flags for compiling/building here
+
+
+TARGETBIN = linexec.exe
+
+# TODO: I had to make sure all sources are at the current directory, fix this
+# in the future maybe.
+# (You may want to symlink asmstuff.asm and asm.asm)
+
+SRCS = \
+    StdAfx.cpp         \
+    gpio.cpp           \
+    memory.cpp         \
+    uart.cpp           \
+    boot.cpp           \
+    graphics.cpp       \
+    tester1.cpp                \
+    asmstuff.asm       \
+    asm.asm            \
+    tester1.rc
+
+# xscale vs strongarm
+#CFLAGS = -DSTRONGARM=1
+LIBS = aygshell.lib
+
+INCLUDE=/opt/toolchain/arm-wince-pe/include/ppc/
+LIB=/opt/toolchain/arm-wince-pe/lib/ppc/
+
+
diff --git a/ReadMe.txt b/ReadMe.txt
new file mode 100644 (file)
index 0000000..c5d3c57
--- /dev/null
@@ -0,0 +1,77 @@
+Linux loader for Pocket PC\r
+\r
+\r
+How to compile:\r
+\r
+1. Two asm files from asm directory has to be compiled with armasm.exe. This will create two \r
+obj files, that should be copied into lib directory(and will be included in the project)\r
+2. Compile & link project\r
+\r
+The c++ source file also contains some routines to read physical memory and to translate virtual mem to phys.\r
+However, the translation is limited and not fully implemented.\r
+\r
+The booting of Linux begins IMMEDIATELLY after program is started.\r
+zImage filename is "image2" (without "")\r
+initrd filename is "initrd"\r
+\r
+If it for some reason freezes try removing pieces of code that write into Frame buffer on Axim\r
+(this fb is beyond limits of physical memory and should not cause problems on IPAQ. adr=0x14042000)\r
+\r
+Limitations: There are some limitations of file sizes.\r
+\r
+If a screen with Hello World appears, there was a problem in booting. Check filenames.\r
+\r
+To make it work for SA11x0 you will have to change these lines in asm.asm:\r
+       ldr     r5, =0xa0000100\r
+\r
+       ldr     r7, =0xa0400000\r
+\r
+with proper adresses and limits of memory( just change the "a" with "8" I think)\r
+Also KERNELCOPY and INITRD macros have to be changed.\r
+\r
+\r
+author: Demo; cooldemo@inmail.sk\r
+\r
+\r
+================================================================================\r
+\r
+Amendment by Pigeon:\r
+\r
+linexec has been changed a lot and therefore some stuff in the above readme\r
+might not be true anymore. But anyway, here is how you use linexec:\r
+\r
+\r
+To use linexec, you need 4 files.\r
+\r
+linexec config file: params\r
+\r
+Create a file called "params", and put it under either "\My Documents\", or\r
+"\CF Card\". If you really care where and what this file is called, edit\r
+tester1.cpp and look for load_boot() call.\r
+\r
+This params file specifies three lines of config for:\r
+kernel image\r
+initrd image\r
+kernel args\r
+\r
+For example, my params looks like this:\r
+\My Documents\zimage\r
+\My Documents\initrd.gz\r
+init=/linuxrc keepinitrd root=/dev/rd/0\r
+\r
+\r
+(This is what I actually have in my params file, but remember this might not\r
+work for your kernel/device)\r
+\r
+(Also a note for the params file, seems that the code is only happy if the\r
+file is in unix format, i.e. newline as \r, but not dos format)\r
+\r
+\r
+And yes, if you see "Hello World", you've got something wrong.\r
+\r
+\r
+Pigeon.\r
+\r
+\r
+\r
+\r
diff --git a/ReadMe.wine b/ReadMe.wine
new file mode 100644 (file)
index 0000000..32409f5
--- /dev/null
@@ -0,0 +1,81 @@
+
+README for Makefile.wine
+
+With thanks to anpaza, I got this very basic Makefile to use wine and evc to
+build pocketpc arm binary programs, so I don't have to boot into windows just
+for building linexec.
+
+
+So what do you need?
+(Guns, lots of guns)
+====================
+
+- WINE
+    I didn't know if there's any specific version you'll need, my WINE just
+work straight away.
+
+
+- EVC
+    You can download that from Micro$oft site. Note, I need to build linexec
+for my pocketpc 2002, and I needed EVC 3, and EVC 4 didn't work. For reference,
+the file I downloaded is evt2002web_min.exe
+
+    And then, you can unpack the EVC installation .exe with unzip. Then you can
+start hunting for files you need. So far I figured files that you'll need are:
+
+    Binary:
+
+    (In WCE/wce300/BIN/)
+    ARMASM.EXE
+    C1XX_ARM.DLL
+    C2_ARM.EXE
+    CLARM.EXE
+    LINK.EXE
+    MSPDB60.DLL
+
+    (In COMMON/EVC/BIN/)
+    RC.EXE
+    RCDLL.DLL
+    CVTRES.EXE
+
+
+    Headers:
+
+    *.h in SDKs/PocketPC_2002_SDK/program files/pocket pc 2002/include/
+    *.h in SDKs/PocketPC_2002_SDK/program files/pocket pc 2002/atl/include
+    *.h in SDKs/PocketPC_2002_SDK/program files/pocket pc 2002/atl/src
+
+
+    Libs:
+    *.lib in SDKs/PocketPC_2002_SDK/program files/pocket pc 2002/lib/arm/
+
+
+    Just put them in a sane place for your own convenience.
+
+
+The actual action
+=================
+
+If you want to use these Makefile stuff for building other pocketpc app, have
+a read on Makefile.project and Makefile.wine, you'll pretty much understand
+what is going on.
+
+Set those path for your wine in the Makefile.wine, put in binary and sources
+names/files in Makefile.project.
+
+In a nutshell:
+
+- tune BASE in Makefile.wine
+- tune TARGETBIN SRCS CFLAGS LIBS INCLUDE LIB in Makefile.project
+
+By default all output files (obj/exe/res/etc) will be in the out/ directory.
+
+Finally, "make" will build them all, "make clean" will simply kill out/
+
+
+
+
+
+pigeon
+
+
diff --git a/StdAfx.cpp b/StdAfx.cpp
new file mode 100644 (file)
index 0000000..e7b4a61
--- /dev/null
@@ -0,0 +1,8 @@
+// stdafx.cpp : source file that includes just the standard includes
+//     tester1.pch will be the pre-compiled header
+//     stdafx.obj will contain the pre-compiled type information
+
+#include "stdafx.h"
+
+// TODO: reference any additional headers you need in STDAFX.H
+// and not in this file
diff --git a/StdAfx.h b/StdAfx.h
new file mode 100644 (file)
index 0000000..fbbf3ee
--- /dev/null
+++ b/StdAfx.h
@@ -0,0 +1,49 @@
+// stdafx.h : include file for standard system include files,
+\r
+//  or project specific include files that are used frequently, but
+\r
+//      are changed infrequently
+\r
+//
+\r
+
+\r
+#if !defined(AFX_STDAFX_H__E553AB80_24B1_4900_9879_D30DA5DD7F8A__INCLUDED_)
+\r
+#define AFX_STDAFX_H__E553AB80_24B1_4900_9879_D30DA5DD7F8A__INCLUDED_
+\r
+
+\r
+#if _MSC_VER > 1000
+\r
+#pragma once
+\r
+#endif // _MSC_VER > 1000
+\r
+
+\r
+#define WIN32_LEAN_AND_MEAN            // Exclude rarely-used stuff from Windows headers
+\r
+
+\r
+// Windows Header Files:
+\r
+#include <windows.h>
+\r
+\r
+// Local Header Files
+\r
+
+\r
+// TODO: reference additional headers your program requires here
+\r
+
+\r
+//{{AFX_INSERT_LOCATION}}
+\r
+// Microsoft eMbedded Visual C++ will insert additional declarations immediately before the previous line.
+\r
+
+\r
+#endif // !defined(AFX_STDAFX_H__E553AB80_24B1_4900_9879_D30DA5DD7F8A__INCLUDED_)
+\r
diff --git a/WhatsNew.txt b/WhatsNew.txt
new file mode 100644 (file)
index 0000000..a5e940a
--- /dev/null
@@ -0,0 +1,2 @@
+v1.3   It is no longer necessery to recompile *.asm files for different machine types, since machine number is passed through DRAMloader.      Added boot logo.        Parameters are read from \CF Card\params file, the format can be seen in boot.cpp file.v1.0
+       initial release?
\ No newline at end of file
diff --git a/asm/asm-wince.asm b/asm/asm-wince.asm
new file mode 100644 (file)
index 0000000..a34be6e
--- /dev/null
@@ -0,0 +1,99 @@
+       TTL     C:\pocket\test\asm.cpp\r\r
+\r\r
+       AREA    |.drectve|, DRECTVE\r\r
+       DCB     "-defaultlib:coredll.lib "\r\r
+       DCB     "-defaultlib:corelibc.lib "\r\r
+\r\r
+       EXPORT  |?do_it@@YAXXZ|                         ; do_it\r\r
+       AREA    |.pdata|, PDATA\r\r
+|$T222|        DCD     |?do_it@@YAXXZ|\r\r
+       DCD     0x40000100\r\r
+       AREA    |.text|, CODE\r\r
+|?do_it@@YAXXZ| PROC                                   ; do_it\r\r
+|$M220|\r\r
+       \r\r
+       mcr     p15, 0, r0, c7, c5, 0           ;/* invalidate i cache & BTB */\r\r
+                                                                               ;       CPWAIT  r0\r\r
+       mrc     p15, 0, r0, c2, c0, 0\r\r
+       mov     r0, r0\r\r
+       sub     pc, pc, #4              \r\r
+                                                                               ;       ldr     r9, =0xa1300100\r\r
+\r\r
+               mov             r9, r1                                  ;       add             r9, r1, #0x100  \r\r
+               ldr             r5, =0xa0000100                 ;       ldr             r5, =0xa0000100\r\r
+               ldr             r7, =0xa0100000\r\r
+label   ldr     r8, [r9]\r\r
+        str     r8, [r5]\r\r
+               add     r9, r9, #4 \r\r
+               add     r5, r5, #4 \r\r
+               cmp             r5, r7\r\r
+               blt             label\r\r
+\r\r
+crash  b crash\r\r
+\r\r
+       MOV             r4, #0xA0000000\r\r
+       add             r2,r4,#0x8000\r\r
+       \r\r
+       mov     r11,r2\r\r
+       ldr             r10,=337\r\r
+\r\r
+;      mcr     p15, 0, r0, c7, c10, 4 ;/* drain the write buffer*/\r\r
+\r\r
+;      CPWAIT  r0\r\r
+;      mrc     p15, 0, r0, c2, c0, 0\r\r
+;      mov     r0, r0\r\r
+;      sub     pc, pc, #4              \r\r
+\r\r
+\r\r
+       mcr     p15, 0, r0, c8, c7, 0x00        ;/* invalidate I+D TLB */\r\r
+;      CPWAIT  r0\r\r
+       mrc     p15, 0, r0, c2, c0, 0\r\r
+       mov     r0, r0\r\r
+       sub     pc, pc, #4              \r\r
+\r\r
+;      //; they skipped this, unnecessary? seems like we need to do this\r\r
+       mcr     p15, 0, r0, c7, c5, 0           ;/* invalidate i cache & BTB */\r\r
+       \r\r
+; S bit set, p and d bit set (no 26 bit mode)\r\r
+;      mov     r3, #0x120      ; xscale says p needs to be 0 ???\r\r
+;      mcr     p15, 0, r3, c1, c0, 0   ;/* disable the MMU */\r\r
+\r\r
+;      CPWAIT  r0\r\r
+;      mrc     p15, 0, r0, c2, c0, 0\r\r
+;      mov     r0, r0\r\r
+;      sub     pc, pc, #4              \r\r
+\r\r
+\r\r
+;        /*; make sure the pipeline is emptied*/\r\r
+        mov     r0,#0\r\r
+        mov     r0,r0\r\r
+        mov     r0,r0\r\r
+        mov     r0,r0\r\r
+\r\r
+;      /* zero PID in Process ID Virtual Address Map register. */\r\r
+;      mov     r0, #0\r\r
+       mcr     p15, 0, r0, c13, c0, 0\r\r
+\r\r
+\r\r
+;      CPWAIT  r0\r\r
+       mrc     p15, 0, r0, c2, c0, 0\r\r
+       mov     r0, r0\r\r
+       sub     pc, pc, #4              \r\r
+\r\r
+;      ldr     r5, =0xA00512F5\r\r
+;      ldr     r8, =0xefef0000\r\r
+;      str     r8, [r5] \r\r
+\r\r
+\r\r
+       mov     r0, #0\r\r
+    mov     r1, r10\r\r
+       ldr     r2, [r2, #0]\r\r
+       mov     r2, #0\r\r
+       mov     pc, r11 \r\r
+\r\r
+\r\r
+|$M221|\r\r
+\r\r
+       ENDP  ; |?do_it@@YAXXZ|, do_it\r\r
+\r\r
+       END\r\r
diff --git a/asm/asm-wince.asm.bz2 b/asm/asm-wince.asm.bz2
new file mode 100644 (file)
index 0000000..247cdc3
Binary files /dev/null and b/asm/asm-wince.asm.bz2 differ
diff --git a/asm/asm.asm b/asm/asm.asm
new file mode 100644 (file)
index 0000000..fa9a15c
--- /dev/null
@@ -0,0 +1,103 @@
+       TTL     C:\pocket\test\asm.cpp\r
+\r
+       AREA    |.drectve|, DRECTVE\r
+       DCB     "-defaultlib:coredll.lib "\r
+       DCB     "-defaultlib:corelibc.lib "\r
+\r
+       EXPORT  |?do_it@@YAXXZ|                         ; do_it\r
+       AREA    |.pdata|, PDATA\r
+|$T222|        DCD     |?do_it@@YAXXZ|\r
+       DCD     0x40000100\r
+       AREA    |.text|, CODE\r
+|?do_it@@YAXXZ| PROC                                   ; do_it\r
+|$M220|\r
+\r
+\r
+               mcr     p15, 0, r0, c7, c5, 0   ;/* invalidate i cache & BTB */\r
+               mrc     p15, 0, r0, c2, c0, 0\r
+               mov     r0, r0\r
+               sub     pc, pc, #4              \r
+\r
+\r
+; turn off LCD controller...\r
+; I couldn't figure out how to use armasm.exe conditional with variables\r
+; #if xscale\r
+;              ldr     r9, =0x44000000\r
+;              ldr     r8, [r9]\r
+;              orr     r8, r8, #0x400\r
+;              str     r8, [r9]\r
+\r
+; #elif strongarm\r
+               ldr     r9, =0xb0100000\r
+               ldr     r8, [r9]\r
+               bic     r8, r8, #1\r
+               str     r8, [r9]\r
+\r
+; turn off unused serial ports\r
+\r
+               mov r8, #0\r
+               ldr r9, =0x80010000\r
+               str r8, [r9, #0xC]\r
+               ldr r9, =0x80050000\r
+               str r8, [r9, #0xC]\r
+\r
+; #endif\r
+\r
+               add     r9, r1, #0x100\r
+\r
+; #if xscale\r
+;              ldr     r5, =0xa0000100\r
+;              ldr     r7, =0xa0400000\r
+\r
+; #elif strongarm\r
+               ldr     r5, =0xc0000100\r
+               ldr     r7, =0xc0400000\r
+; #endif\r
+\r
+\r
+label          ldr     r8, [r9]\r
+               str     r8, [r5]\r
+               add     r9, r9, #4 \r
+               add     r5, r5, #4 \r
+               cmp     r5, r7\r
+               blt     label\r
+\r
+; #if xscale\r
+;              MOV     r4, #0xA0000000\r
+\r
+; #elif strongarm\r
+               MOV     r4, #0xc0000000\r
+; #endif\r
+\r
+               add     r11,r4,#0x8000\r
+\r
+               mov     r10,r2          ;machine number passed from DRAMloader\r
+\r
+               mcr     p15, 0, r0, c8, c7, 0x00 ;/* invalidate I+D TLB */\r
+               mrc     p15, 0, r0, c2, c0, 0\r
+               mov     r0, r0\r
+               sub     pc, pc, #4              \r
+\r
+; they skipped this, unnecessary? seems like we need to do this\r
+\r
+               mcr     p15, 0, r0, c7, c5, 0   ;/* invalidate i cache & BTB */\r
+       \r
+               mov     r0, #0\r
+               mcr     p15, 0, r0, c13, c0, 0\r
+               mrc     p15, 0, r0, c2, c0, 0\r
+               mov     r0, r0\r
+               sub     pc, pc, #4              \r
+\r
+               mov     r0, #0\r
+               mov     r1, r10\r
+               ldr     r2, [r2, #0]\r
+               mov     r2, #0\r
+\r
+; Jump into the kernel:\r
+               mov             pc, r11 \r
+\r
+\r
+|$M221|\r
+       ENDP  ; |?do_it@@YAXXZ|, do_it\r
+       END\r
+\r
diff --git a/asm/asm.asm.bz2 b/asm/asm.asm.bz2
new file mode 100644 (file)
index 0000000..ca734be
Binary files /dev/null and b/asm/asm.asm.bz2 differ
diff --git a/asm/asmstuff-wince.asm b/asm/asmstuff-wince.asm
new file mode 100644 (file)
index 0000000..76095e1
--- /dev/null
@@ -0,0 +1,70 @@
+       TTL     C:\pocket\asmstuff\asmstuff.cpp\r\r
+\r\r
+       AREA    |.drectve|, DRECTVE\r\r
+       DCB     "-defaultlib:coredll.lib "\r\r
+       DCB     "-defaultlib:corelibc.lib "\r\r
+\r\r
+       EXPORT  |?read_mmu@@YAHXZ|                      ; read_mmu\r\r
+       AREA    |.pdata|, PDATA\r\r
+|$T229|        DCD     |?read_mmu@@YAHXZ|\r\r
+       DCD     0x40000200\r\r
+       AREA    |.text|, CODE\r\r
+|?read_mmu@@YAHXZ| PROC                                        ; read_mmu\r\r
+|$M227|\r\r
+       mov       r0, #0x33  ; 0x33 = 51\r\r
+       mrc     p15, 0, r0, c2, c0, 0 \r\r
+       mov       pc, lr\r\r
+|$M228|\r\r
+       ENDP  ; |?read_mmu@@YAHXZ|, read_mmu\r\r
+\r\r
+       EXPORT  |?IntOff@@YAXXZ|                        ; IntOff\r\r
+       AREA    |.pdata|, PDATA\r\r
+|$T233|        DCD     |?IntOff@@YAXXZ|\r\r
+       DCD     0x40000100\r\r
+       AREA    |.text|, CODE\r\r
+|?IntOff@@YAXXZ| PROC                                  ; IntOff\r\r
+; Line 9\r\r
+       mrs     r4,cpsr\r\r
+       orr     r1,r4,#0xef\r\r
+       msr     cpsr_c,r1\r\r
+       mov       pc, lr\r\r
+|$M231|\r\r
+       mov       pc, lr\r\r
+|$M232|\r\r
+       ENDP  ; |?IntOff@@YAXXZ|, IntOff\r\r
+\r\r
+\r\r
+       EXPORT  |?DRAMloader@@YAXI@Z|           ; DRAMloader\r\r
+       AREA    |.pdata|, PDATA\r\r
+|$T237|        DCD     |?DRAMloader@@YAXI@Z|\r\r
+       DCD     0x40000b04\r\r
+       AREA    |.text|, CODE\r\r
+|?DRAMloader@@YAXI@Z| PROC                             ; DRAMloader\r\r
+       mov       r12, sp\r\r
+       stmdb     sp!, {r0}                                     ; stmfd\r\r
+       stmdb     sp!, {r12, lr}                        ; stmfd\r\r
+       sub       sp, sp, #4\r\r
+|$M235|\r\r
+       ldr       r3, [sp, #0xC]                        ; 0xC = 12\r\r
+       str       r3, [sp]\r\r
+       ldr       r1, [sp]\r\r
+       ldr     r0, =0x3fff\r\r
+       mcr     p15, 0, r0, c7, c10, 4          ; Enable access\r\r
+       mrc             p15, 0, r0, c2, c0, 0\r\r
+       mov             r0, r0\r\r
+       mrc     p15, 0, r3, c1, c0, 0           ;/* disable the MMU */\r\r
+       and     r3, r3, #0xfffffffe             ; xscale says p needs to be 0 ???\r\r
+       mov             r3, #0x120\r\r
+       mcr     p15, 0, r3, c1, c0, 0           ;/* disable the MMU */\r\r
+                                                                               ;       CPWAIT  r0\r\r
+       mrc             p15, 0, r0, c2, c0, 0\r\r
+       mov             r0, r0                                          \r\r
+\r\r
+       mov             pc,r1                                           ; GO GO GO GO GO\r\r
+                                                                               ; can't get here ??? -- jw, 20030517\r\r
+       add       sp, sp, #4\r\r
+       ldmia     sp, {sp, pc}  ; ldmfd\r\r
+|$M236|\r\r
+       ENDP  ; |?DRAMloader@@YAXI@Z|, DRAMloader\r\r
+\r\r
+       END
\ No newline at end of file
diff --git a/asm/asmstuff-wince.asm.bz2 b/asm/asmstuff-wince.asm.bz2
new file mode 100644 (file)
index 0000000..cd6376a
Binary files /dev/null and b/asm/asmstuff-wince.asm.bz2 differ
diff --git a/asm/asmstuff.asm b/asm/asmstuff.asm
new file mode 100644 (file)
index 0000000..e737feb
--- /dev/null
@@ -0,0 +1,78 @@
+       TTL     C:\pocket\asmstuff\asmstuff.cpp
+\r
+       AREA    |.drectve|, DRECTVE
+       DCB     "-defaultlib:coredll.lib "
+       DCB     "-defaultlib:corelibc.lib "
+\r
+       EXPORT  |?read_mmu@@YAHXZ|                      ; read_mmu
+       AREA    |.pdata|, PDATA
+|$T231|        DCD     |?read_mmu@@YAHXZ|
+       DCD     0x40000200
+       AREA    |.text|, CODE
+|?read_mmu@@YAHXZ| PROC                                        ; read_mmu
+|$M229|
+\r
+       mrc     p15, 0, r0, c2, c0, 0 
+       mov       pc, lr
+\r
+|$M230|
+       ENDP  ; |?read_mmu@@YAHXZ|, read_mmu
+\r
+       EXPORT  |?IntOff@@YAXXZ|                        ; IntOff
+       AREA    |.pdata|, PDATA
+|$T235|        DCD     |?IntOff@@YAXXZ|
+       DCD     0x40000100
+       AREA    |.text|, CODE
+|?IntOff@@YAXXZ| PROC                                  ; IntOff
+|$M233|
+\r
+       mrs             r4,cpsr
+       orr             r1,r4,#0xef
+       msr             cpsr_c,r1
+       mov             pc, lr
+\r
+|$M234|
+       ENDP  ; |?IntOff@@YAXXZ|, IntOff
+\r
+\r
+       EXPORT  |?DRAMloader@@YAXII@Z|                  ; DRAMloader
+       AREA    |.pdata|, PDATA
+|$T239|        DCD     |?DRAMloader@@YAXII@Z|
+       DCD     0x40001004
+       AREA    |.text|, CODE
+|?DRAMloader@@YAXII@Z| PROC                            ; DRAMloader
+\r
+       mov       r12, sp
+       stmdb     sp!, {r0, r1}  ; stmfd
+       stmdb     sp!, {r12, lr}  ; stmfd
+       sub       sp, sp, #8
+\r
+|$M237|
+\r
+       ldr             r3, [sp, #0x10]  ; 0x10 = 16
+       str             r3, [sp]
+       ldr             r2, [sp, #0x14]  ; 0x14 = 20
+       str             r2, [sp, #4]
+\r
+       ldr             r1, [sp]           ; jump address
+       ldr             r2, [sp, #4]       ; machine number
+\r
+       ldr             r0, =0x3fff
+       mcr     p15, 0, r0, c7, c10, 4 ;Enable access
+       mrc             p15, 0, r0, c2, c0, 0\r
+       mov             r0, r0
+\r
+       mrc     p15, 0, r3, c1, c0, 0   ;/* disable the MMU */\r
+       and     r3, r3, #0xfffffffe     ; xscale says p needs to be 0 ???\r
+       mov     r3, #0x120\r
+       mcr     p15, 0, r3, c1, c0, 0   ;/* disable the MMU */
+       mrc     p15, 0, r0, c2, c0, 0
+       mov     r0, r0
+
+; Jump into do_it and the kernel\r
+       mov     pc,r1                   ; machine number is in register r2
+\r
+|$M238|
+       ENDP  ; |?DRAMloader@@YAXII@Z|, DRAMloader
+       END
+\r
diff --git a/asm/asmstuff.asm.bz2 b/asm/asmstuff.asm.bz2
new file mode 100644 (file)
index 0000000..7c3a827
Binary files /dev/null and b/asm/asmstuff.asm.bz2 differ
diff --git a/asm/test123.asm b/asm/test123.asm
new file mode 100644 (file)
index 0000000..2559552
--- /dev/null
@@ -0,0 +1,7 @@
+loopl  ldr             r5, =0xA0051000                                 ; right before we jump in\r\r
+       ldr             r6, =0xA0051100\r\r
+       ldr             r8, =0xFE00FE00\r\r
+       str     r8, [r5] \r\r
+       add             r5, r5, #0x04\r\r
+       cmp                     r5,r6\r\r
+       blt             loopl
\ No newline at end of file
diff --git a/asm/test123.asm.bz2 b/asm/test123.asm.bz2
new file mode 100644 (file)
index 0000000..84ee2b8
Binary files /dev/null and b/asm/test123.asm.bz2 differ
diff --git a/boot.cpp b/boot.cpp
new file mode 100644 (file)
index 0000000..1d3706a
--- /dev/null
+++ b/boot.cpp
@@ -0,0 +1,321 @@
+#include "stdafx.h"\r
+#include "tester1.h"\r
+#include <commctrl.h>\r
+//#include <aygshell.h>\r
+#include <sipapi.h>\r
+#include "setup.h"\r
+\r
+\r
+#define BOOT_LOGO_PATH "\\My Documents\\booting.bmp"\r
+#define BOOT_LOGO_PATH_CF "\\CF Card\\booting.bmp"\r
+#define BOOT_LOGO_DONE_PATH "\\My Documents\\done.bmp"\r
+#define BOOT_LOGO_DONE_PATH_CF "\\CF Card\\done.bmp"\r
+#define DONE1_X        100\r
+#define DONE1_Y        100\r
+#define DONE2_X        100\r
+#define DONE2_Y        130\r
+\r
+\r
+void setup_linux_params(long bootimg_dest, UINT32 initrd,UINT32 initrdl, long dram_size, const char *cmdline, char*base)\r
+{\r
+       int rootdev = 0x00ff;\r
+       struct tag *tag;\r
+       int newcmdlinelen = 0;\r
+       char *newcmdline = NULL;\r
+\r
+\r
+       tag = (struct tag *)(base+0x100);\r
+\r
+       tag->hdr.tag = ATAG_CORE;\r
+       tag->hdr.size = tag_size(tag_core);\r
+       tag->u.core.flags =0;\r
+       tag->u.core.pagesize = 0x00001000;\r
+       tag->u.core.rootdev = rootdev;\r
+       tag = tag_next(tag);\r
+\r
+       // now the cmdline tag\r
+       tag->hdr.tag = ATAG_CMDLINE;\r
+       // must be at least +3!! 1 for the null and 2 for the ???\r
+       tag->hdr.size = (strlen(cmdline) + 3 + sizeof(struct tag_header)) >> 2;\r
+       //tag->hdr.size = (strlen(cmdline) + 10 + sizeof(struct tag_header)) >> 2;\r
+       strcpy(tag->u.cmdline.cmdline,cmdline);\r
+       tag = tag_next(tag);\r
+\r
+\r
+       // now the mem32 tag\r
+       tag->hdr.tag = ATAG_MEM;\r
+       tag->hdr.size = tag_size(tag_mem32);\r
+       tag->u.mem.size = dram_size;\r
+       tag->u.mem.start = MEM_START;\r
+       tag = tag_next(tag);\r
+       \r
+\r
+       /* and now the initrd tag */\r
+       if (initrdl) {\r
+               tag->hdr.tag = INITRD_TAG;\r
+               tag->hdr.size = tag_size(tag_initrd);\r
+               tag->u.initrd.start = initrd;\r
+               tag->u.initrd.size = initrdl;\r
+               tag = tag_next(tag);\r
+       }\r
+   \r
+       tag->hdr.tag = ATAG_VIDEOTEXT;\r
+       tag->hdr.size = tag_size(tag_videotext);\r
+       tag->u.videotext.video_lines = 40;\r
+       tag->u.videotext.video_cols = 30;\r
+       tag = tag_next(tag);\r
+\r
+       // now the NULL tag\r
+       tag->hdr.tag = ATAG_NONE;\r
+       tag->hdr.size = 0;\r
+}\r
+\r
+\r
+\r
+\r
+\r
+/* loading process:\r
+function do_it is loaded onto address KERNELCOPY along with parameters(offset=0x100) and\r
+kernel image(offset=0x8000). Afterwards DRAMloader is called; it disables MMU and\r
+jumps onto KERNELCOPY. Function do_it then copies kernel image to its proper address(0xA0008000) \r
+and calls it.\r
+Initrd is loaded onto address INITRD and the address is passed to kernel via ATAG\r
+*/\r
+\r
+\r
+// This resets some devices\r
+void ResetDevices()\r
+{\r
+#ifndef STRONGARM\r
+       WritePhysical(0x4050000C,0); // Reset AC97\r
+       WritePhysical(0x48000014,0); // Reset PCMCIA\r
+       for(int i=0;i<0x3C;i+=4)\r
+               WritePhysical(0x40000000,8); // Set DMAs to Stop state\r
+       WritePhysical(0x400000F0,0); // DMA do not gen interrupt\r
+       SetGPIOio(28,0);                        // AC97\r
+       SetGPIOio(29,0);                        // AC97/I2S\r
+       SetGPIOio(30,0);                        // I2S/AC97\r
+       SetGPIOio(31,0);                        // I2S/AC97\r
+       SetGPIOio(32,0);                        // AC97/I2S\r
+       SetGPIOalt(28,0);\r
+       SetGPIOalt(29,0);\r
+       SetGPIOalt(30,0);\r
+       SetGPIOalt(31,0);\r
+       SetGPIOalt(32,0);\r
+#endif\r
+}\r
+\r
+\r
+\r
+\r
+void mymemcpy(char* a, char* b, int size);\r
+\r
+void boot_linux(char *filename,char* initrd,char *param)\r
+{\r
+       FILE *fd=fopen(filename,"rb");\r
+       int ret;\r
+\r
+       FILE* fd1;\r
+\r
+       long initrdl;\r
+       long len;\r
+\r
+#ifndef STRONGARM\r
+       Image image;\r
+       Image image_done;\r
+#endif\r
+\r
+\r
+\r
+       if(!fd)\r
+       {\r
+               FILE *logfd=fopen("\\bootlog.txt","a");\r
+               fprintf(logfd, "Booting: ***FAILED TO OPEN %s***\n",filename);\r
+               fclose(logfd);\r
+               return;\r
+       }\r
+\r
+       fseek(fd,0,SEEK_END);\r
+       len=ftell(fd);\r
+       fseek(fd,0,SEEK_SET);\r
+\r
+       fd1=fopen(initrd,"rb");\r
+       initrdl=0;\r
+       if(fd1) \r
+       {\r
+               fseek(fd1,0,SEEK_END);\r
+               initrdl=ftell(fd1);\r
+               fseek(fd1,0,SEEK_SET);\r
+       }\r
+       FILE *logfd=fopen("\\bootlog.txt","a");\r
+       fprintf(logfd, "Booting: Images.");\r
+       fclose(logfd);\r
+\r
+       \r
+#ifndef STRONGARM\r
+       /* i haven't ported this to strongarm, hope this is not important to\r
+        * anyone */\r
+       init_fb();\r
+       try_fb();\r
+\r
+       image=ReadBMP(BOOT_LOGO_PATH);\r
+       if (!image.p) image=ReadBMP(BOOT_LOGO_PATH_CF);\r
+       image_done=ReadBMP(BOOT_LOGO_DONE_PATH);\r
+       if (!image_done.p) image_done = ReadBMP(BOOT_LOGO_DONE_PATH_CF);\r
+       if (image.p) ShowImage(image.p,image.x,image.y);\r
+#endif\r
+       \r
+       logfd=fopen("\\bootlog.txt","a");\r
+       fprintf(logfd, "Booting: entering supervisor mode.");\r
+       fclose(logfd);\r
+\r
+       /* now becoming supervisor. */\r
+       SetThreadPriority(GetCurrentThread(),THREAD_PRIORITY_TIME_CRITICAL);\r
+//     CeSetThreadQuantum(GetCurrentThread(),0);\r
+       SetKMode(1);\r
+       SetProcPermissions(0xffffffff);\r
+       /* <ibot> rooooooooot has landed! */\r
+\r
+       logfd=fopen("\\bootlog.txt","a");\r
+       fprintf(logfd, "Booting: supervisor mode.");\r
+       fclose(logfd);\r
+\r
+       void *mmu=(void*)read_mmu();\r
+       UINT32 *data=NULL,*lcd=NULL,*intr=NULL,*_mmu=NULL;\r
+       char *watch=NULL,*krnl=NULL;\r
+\r
+\r
+       IntOff();\r
+\r
+\r
+       char *kernel_copy2=(char*)VirtualAlloc((void*)0x0,0x8000+len, MEM_RESERVE|MEM_TOP_DOWN,PAGE_READWRITE);\r
+       ret=VirtualCopy((void*)kernel_copy2,(void *) (KERNELCOPY/256),  0x8000+len, PAGE_READWRITE|PAGE_NOCACHE|PAGE_PHYSICAL);\r
+\r
+       char *initrd_copy2;\r
+\r
+\r
+       if(fd1)\r
+       {\r
+               initrd_copy2=(char*)VirtualAlloc((void*)0x0,initrdl, MEM_RESERVE|MEM_TOP_DOWN,PAGE_READWRITE);\r
+               ret=VirtualCopy((void*)initrd_copy2,(void *) (INITRD/256),      initrdl, PAGE_READWRITE|PAGE_NOCACHE|PAGE_PHYSICAL);\r
+       }\r
+\r
+       void(*relmemcpy)(char*,char*,int);\r
+       relmemcpy=(void (__cdecl *)(char *,char *,int))VirtualAlloc((void*)0x0, 1024, MEM_RESERVE|MEM_TOP_DOWN,PAGE_READWRITE);\r
+\r
+       /* ask joshua */\r
+#ifndef STRONGARM\r
+       ret=VirtualCopy((void*)relmemcpy,(void *) (0xa0001000/256),     1024, PAGE_READWRITE|PAGE_NOCACHE|PAGE_PHYSICAL);\r
+#else\r
+       ret=VirtualCopy((void*)relmemcpy,(void *) (0xc0001000/256),     1024, PAGE_READWRITE|PAGE_NOCACHE|PAGE_PHYSICAL);\r
+#endif\r
+\r
+       if(!kernel_copy2) return;\r
+\r
+\r
+       UINT32 phys_addr;\r
+       phys_addr=KERNELCOPY;\r
+\r
+\r
+       char *data1,*data2;\r
+\r
+       data1=(char*)malloc(len);\r
+\r
+       char *initrd1=NULL;\r
+\r
+       if(fd1) initrd1=(char*)malloc(initrdl);\r
+\r
+       if(!data1) return;\r
+\r
+       if(!ret) return;\r
+\r
+       data2= (char*)do_it;\r
+\r
+\r
+       fread(data1,len,1,fd);\r
+       fclose(fd);\r
+\r
+\r
+       if(fd1)\r
+       {\r
+               fread(initrd1,initrdl,1,fd1);\r
+               fclose(fd1);\r
+       }\r
+\r
+       // Do not block interrupts before they are needed anymore\r
+       // Like reading the SD card.\r
+       intr=(UINT32*)VirtualAlloc((void*)0x0,0x100, MEM_RESERVE,PAGE_READWRITE);\r
+\r
+       // Interrupt control registers\r
+       ret=VirtualCopy((void*)intr,(void *) (ICIP/256), 0x100, PAGE_READWRITE|PAGE_NOCACHE|PAGE_PHYSICAL);\r
+\r
+       intr[1]=0;\r
+\r
+//     ResetDevices();\r
+\r
+       UART_puts("LinExec: Passing the point of no return.. Now.\r\n");\r
+\r
+       UINT32  crc=0;\r
+\r
+       setup_linux_params(BOOTIMG, INITRD,initrdl, MEM_SIZE*1024*1024 , param,kernel_copy2);\r
+\r
+       memcpy(relmemcpy,mymemcpy,1024);\r
+       relmemcpy(kernel_copy2,data2,0x100);\r
+\r
+       if(fd1)\r
+               relmemcpy(initrd_copy2,initrd1,initrdl);\r
+\r
+       relmemcpy(kernel_copy2+0x8000,data1,len);\r
+\r
+       UART_puts("LinExec: Entering DRAMloader...\r\n");\r
+       \r
+       DRAMloader(phys_addr, MACH_TYPE);\r
+}\r
+\r
+void mymemcpy(char* a, char* b, int size)\r
+{\r
+       while (size)\r
+       {\r
+               *a=*b;\r
+               size--;\r
+               a++; b++;\r
+       };\r
+};\r
+\r
+/*\r
+       Loads parameters from file given.\r
+       The file has to be:\r
+       kernel image\r
+       initrd\r
+       kernel cmdline\r
+*/\r
+\r
+void load_boot(char *ParamFile)\r
+{\r
+       FILE *stream;\r
+\r
+       UART_setup();\r
+\r
+       stream=fopen(ParamFile,"r");\r
+       if(!stream) {\r
+               FILE *logfd=fopen("\\bootlog.txt","a");\r
+               fprintf(logfd, "Booting: ***FAILED TO OPEN %s***\n",ParamFile);\r
+               fclose(logfd);\r
+               return;\r
+       }\r
+       char cmd[200],image[50],initrd[50];\r
+\r
+       fgets(image,50,stream);\r
+       image[strlen(image)-1]=0; // remove \n from the end\r
+       \r
+       fgets(initrd,50,stream);\r
+       initrd[strlen(initrd)-1]=0;\r
+       \r
+       fgets(cmd,200,stream);\r
+       cmd[strlen(cmd)-1]=0;\r
+\r
+       fclose(stream);\r
+\r
+       UART_puts("LinExec: Beginning boot_linux.\r\n");\r
+       boot_linux(image,initrd,cmd);\r
+}      \r
diff --git a/booting.bmp b/booting.bmp
new file mode 100644 (file)
index 0000000..ec4c57a
Binary files /dev/null and b/booting.bmp differ
diff --git a/config.h b/config.h
new file mode 100644 (file)
index 0000000..e2f6029
--- /dev/null
+++ b/config.h
@@ -0,0 +1,72 @@
+#define STRONGARM 1\r
+
+#ifndef STRONGARM
+
+/* xscale */
+
+#define MEM_START      0xa0000000
+\r
+/* Memory in MByte */\r
+#define MEM_SIZE       64\r
+
+#define KERNELCOPY     0xa0a00000
+//#define KERNELCOPY   0xa0800000  
+
+#define INITRD         0xa0d00000
+#define INITRD_TAG     ATAG_INITRD2
+
+/* Interrupt controller */
+#define ICIP           0x40D00000
+
+#define UARTBASE       0x40100000\r
+#define UARTDATA       0x00\r
+#define UARTSTATUS     0x14\r
+#define UARTTXRDY      5\r
+#define UARTTXBIT      0\r
+\r
+/* Not used */
+#define BOOTIMG                0xa0008000
+\r
+/* MACH_TYPE_H1900 */
+#define MACH_TYPE_JORNADA720           48\r
+#define MACH_TYPE      48
+
+#else
+
+/* strongarm */
+
+#define MEM_START      0xc0000000
+
+/* Memory in MByte */\r
+#define MEM_SIZE       32\r
+\r
+#define KERNELCOPY     0xc0a00000
+
+#define INITRD         0xc0d00000
+#define INITRD_TAG     ATAG_INITRD
+
+/* Interrupt controller */
+#define ICIP           0x90050000
+
+#define UARTBASE       0x80030000\r
+#define UARTDATA       0x14\r
+#define UARTSTATUS     0x20\r
+#define UARTTXRDY      2\r
+#define UARTTXBIT      0\r
+\r
+/* Not used */
+#define BOOTIMG                0xc0008000
+\r
+/* MACH_TYPE_H3600 */
+//#define MACH_TYPE    22
+
+/* MACH_TYPE_H3800 */
+//#define MACH_TYPE    137
+\r
+/* MACH_TYPE_XDA */\r
+#define MACH_TYPE_JORNADA720           48\r
+#define MACH_TYPE      48\r
+
+#endif
+
+
diff --git a/gpio.cpp b/gpio.cpp
new file mode 100644 (file)
index 0000000..d1d6f65
--- /dev/null
+++ b/gpio.cpp
@@ -0,0 +1,119 @@
+#include "stdafx.h"
+#include "tester1.h"
+#include <commctrl.h>
+//#include <aygshell.h>
+#include <sipapi.h>
+#include "setup.h"
+
+#define GPIO   0x40E00000
+#define GPIO_MEDIAQ 0x14040000
+#define MQ_OFF 0x008
+\r
+int GPIOalt[81],GPIOio[81],GPIOst[81],mediaq;
+\r
+void SetGPIOio(int i,int io) // set GPIO as io == 1 output  io == 0 input
+{
+       UINT32 *gpio=(UINT32*)VirtualAlloc((void*)0x0,0x100, MEM_RESERVE,PAGE_READWRITE);
+       VirtualCopy((void*)gpio,(void *) (GPIO/256),    0x100, PAGE_READWRITE|PAGE_NOCACHE|PAGE_PHYSICAL);
+       if(io)
+               gpio[0xC/4 + (i/32)] = gpio[0xC/4 + (i/32)] | (1<<(i%32));
+       else
+               gpio[0xC/4 + (i/32)] = gpio[0xC/4 + (i/32)] & (~(1<<(i%32)));
+       VirtualFree(gpio,0,MEM_RELEASE);
+}
+
+void SetGPIOalt(int i,int io) // set GPIO as io == 1 output  io == 0 input
+{
+       UINT32 *gpio=(UINT32*)VirtualAlloc((void*)0x0,0x100, MEM_RESERVE,PAGE_READWRITE);
+       VirtualCopy((void*)gpio,(void *) (GPIO/256),    0x100, PAGE_READWRITE|PAGE_NOCACHE|PAGE_PHYSICAL);
+       UINT32 w = gpio[0x54/4 + (i/16)] & (~(3<<((i%16)*2)));
+       gpio[0x54/4 + (i/16)] = w | (io<<((i%16)*2));
+       VirtualFree(gpio,0,MEM_RELEASE);
+}
+
+void writeGPIOConfig(FILE*fd, UINT32 *gpio)
+{
+       for(int i=0;i<81;i++)
+       {
+               UINT32 adr=i/16;
+               fprintf(fd,"GPIO #%d=%c, %d\n",i,(gpio[0xC/4+(adr/2)]>>(i%32))&0x1?'O':'I',(gpio[0x54/4+adr]>>((i%16)*2))&0x3);
+               GPIOalt[i]=(gpio[0x54/4+adr]>>((i%16)*2))&0x3;
+               GPIOio[i]=(gpio[0xC/4+(adr/2)]>>(i%32))&0x1;
+
+       }
+}
+
+inline int readGPIOstate(UINT32 *gpio,int i)
+{
+       return (gpio[(i/32)]>>(i%32))&0x1;
+}
+
+inline int readGPIOalt(UINT32 *gpio,int i)
+{
+       return (gpio[0x54/4+i/16]>>((i%16)*2))&0x3;
+}
+
+void Gpio()
+{
+       SetThreadPriority(GetCurrentThread(),THREAD_PRIORITY_BELOW_NORMAL);
+//     SetThreadPriority(GetCurrentThread(),THREAD_PRIORITY_TIME_CRITICAL);
+       FILE *fd=fopen("\\loggerG.txt","w");
+       SYSTEMTIME time;
+       
+       fprintf(fd,"MCMEM0=0x%x\n",ReadPhysical(0x48000028));
+       fprintf(fd,"MCMEM1=x%x\n",ReadPhysical(0x4800002C));
+       fprintf(fd,"MCATT0=0x%x\n",ReadPhysical(0x48000030));
+       fprintf(fd,"MCATT1=0x%x\n",ReadPhysical(0x48000034));
+       fprintf(fd,"MCIO0=0x%x\n",ReadPhysical(0x48000038));
+       fprintf(fd,"MCIO1=0x%x\n",ReadPhysical(0x4800003C));
+       
+       for(int q=0;q<16;q++)
+               fprintf(fd,"DMA #%d=0x%x\tDCMD=0x%x\tDSADR=0x%x\tDTADR=0x%x\n",q,ReadPhysical(0x40000000+q*4),ReadPhysical(0x40000200+q*0x10+0xC),ReadPhysical(0x40000200+q*0x10+0x4),ReadPhysical(0x40000200+q*0x10+0x8));
+       GetSystemTime(&time);
+       int sec=time.wSecond,quit=0;
+       sec+=4;
+       if(sec>60) sec-=60;
+       UINT32 *gpio=(UINT32*)VirtualAlloc((void*)0x0,0x100, MEM_RESERVE,PAGE_READWRITE);
+       VirtualCopy((void*)gpio,(void *) (GPIO/256),    0x100, PAGE_READWRITE|PAGE_NOCACHE|PAGE_PHYSICAL);
+       UINT32 *gpio1=(UINT32*)VirtualAlloc((void*)0x0,0x1000, MEM_RESERVE,PAGE_READWRITE);
+       VirtualCopy((void*)gpio1,(void *) (GPIO_MEDIAQ/256),    0x1000, PAGE_READWRITE|PAGE_NOCACHE|PAGE_PHYSICAL);
+       writeGPIOConfig(fd,gpio);
+
+       for(int i=0;i<81;i++)
+       {
+               GPIOst[i]=-1;
+       }
+       int state,alt;
+       while(sec>time.wSecond)
+       {
+               GetSystemTime(&time);
+               if(gpio1[MQ_OFF/4]!=(UINT32)mediaq)
+               {
+                       mediaq=gpio1[MQ_OFF/4];
+                       fprintf(fd,"MQ_GPIO=0x%x\n",mediaq);
+               }
+               for(i=0;i<81;i++)
+               {
+/*             if(GPIOio[i]) continue;*/
+               if(GPIOalt[i]) continue;
+//                     if(i==16) continue;
+//                     if(i==28) continue;
+//                     if(i==29) continue;
+//                     if(i==30) continue;
+//                     if(i==31) continue;
+                       state=readGPIOstate(gpio,i);
+                       alt=readGPIOalt(gpio,i);
+                       if(GPIOst[i]==state&&GPIOalt[i]==alt) continue;
+                       GPIOst[i]=state;
+                       if(GPIOalt[i]==alt)
+                               fprintf(fd,"#%d: %d\n",i,state);
+                       else
+                       {
+                               GPIOalt[i]=alt;
+                               fprintf(fd,"#%d: %d\tf=%d\n",i,state,alt);
+                       }
+
+               }
+       }
+       fclose(fd);
+}
diff --git a/graphics.cpp b/graphics.cpp
new file mode 100644 (file)
index 0000000..9a63a0c
--- /dev/null
@@ -0,0 +1,101 @@
+#include "stdafx.h"
+#include "tester1.h"
+#include <commctrl.h>
+//#include <aygshell.h>
+#include <sipapi.h>
+#include "setup.h"
+
+
+/* TO DO: Detect whether we're running on an AXIM or an iPAQ at runtime,
+   and set accordingly. */
+
+#ifdef AXIM
+#  define FB_ADR       0x14042000
+#else
+#  define FB_ADR       0xA0051000
+#endif
+
+
+
+#define SET 0xffffffff
+#define LCD_X_RES 240
+#define LCD_Y_RES 320
+UINT16 *fb;
+
+
+void init_fb()
+{
+       fb=(UINT16*)VirtualAlloc((void*)0x0,LCD_X_RES*LCD_Y_RES*2, MEM_RESERVE,PAGE_READWRITE);
+       VirtualCopy((void*)fb,(void *) (FB_ADR/256),LCD_X_RES*LCD_Y_RES*2, PAGE_READWRITE|PAGE_NOCACHE|PAGE_PHYSICAL);
+}
+
+void try_fb()
+{
+//     fb[1]=SET;
+}
+
+Image ReadBMP(char FileName[30])
+{
+ FILE *stream;
+ char buff[29];
+ UINT32 x,y;
+ unsigned char red,green,blue;
+ unsigned long offset;
+ UINT16 *p,c;
+ Image image={NULL};
+ stream=fopen(FileName,"rb");
+ if(!stream) return image;
+ fread(buff,26,1,stream);
+
+ offset=(unsigned char)buff[13]*16777216+(unsigned char)buff[12]*65536+(unsigned char)buff[11]*256+(unsigned char)buff[10];
+ x=(unsigned char)buff[21]*256*256*256+(unsigned char)buff[20]*256*256+(unsigned char)buff[19]*256+(unsigned char)buff[18];
+ y=(unsigned char)buff[25]*256*256*256+(unsigned char)buff[24]*256*256+(unsigned char)buff[23]*256+(unsigned char)buff[22];
+// offset=54;
+ UINT32 imgx=x,imgy=y;
+ if(x<32) x=32;
+ if(y<32) y=32;
+ p=image.p=(UINT16*)malloc(x*y*2);
+ if(!image.p) return(image);
+ fseek(stream,offset,SEEK_SET);
+ p+=(x*y+x);
+
+for(UINT32 zz=0;zz<y;zz++)
+ {
+ p-=2*x;
+
+ for(UINT32 yy=0;yy<x;yy++)
+  {
+   blue=fgetc(stream);
+   green=fgetc(stream);
+   red=fgetc(stream);
+   c=(red/8)*2048+(green/4)*32+blue/8;
+   *p=c;
+   p++;
+
+  }
+
+}
+//image.p=p;
+image.x=imgx;
+image.y=imgy-1;
+fclose(stream);
+return(image);
+}
+
+// shows picture pointed to by p, with res (x by y), at (x_pos, y_pos)
+void ShowImage(UINT16 *p, int x, int y,int x_pos,int y_pos)
+{
+       UINT16 *fb=::fb;
+       if(!p) return;
+       fb+=y_pos*LCD_X_RES+x_pos;
+       for(int yy=0;yy<y;yy++)
+       {
+               for(int xx=0;xx<x;xx++)
+               {
+                       *fb=*p;
+               fb++;
+               p++;
+               }
+               if(x<LCD_X_RES) fb+=LCD_X_RES-x;
+       }
+}
diff --git a/linexec.vcb b/linexec.vcb
new file mode 100644 (file)
index 0000000..b250bcf
Binary files /dev/null and b/linexec.vcb differ
diff --git a/linexec.vcl b/linexec.vcl
new file mode 100644 (file)
index 0000000..b68826a
--- /dev/null
@@ -0,0 +1,52 @@
+<html>\r
+<body>\r
+<pre>\r
+<h1>Build Log</h1>\r
+<h3>\r
+--------------------Configuration: linexec - Win32 (WCE ARM) Release--------------------\r
+</h3>\r
+<h3>Command Lines</h3>\r
+Creating temporary file "C:\DOCUME~1\YUUSEI~1\LOCALS~1\Temp\RSP3.tmp" with contents\r
+[\r
+/nologo /W3 /D _WIN32_WCE=211 /D "WIN32_PLATFORM_HPCPRO" /D "ARM" /D "_ARM_" /D UNDER_CE=211 /D "UNICODE" /D "_UNICODE" /D "NDEBUG" /FR"ARMRel/" /Fp"ARMRel/linexec.pch" /Yu"stdafx.h" /Fo"ARMRel/" /Oxs /MC /c \r
+"E:\Windows CE Tools\linexec-xda-1.0\boot.cpp"\r
+"E:\Windows CE Tools\linexec-xda-1.0\gpio.cpp"\r
+"E:\Windows CE Tools\linexec-xda-1.0\graphics.cpp"\r
+"E:\Windows CE Tools\linexec-xda-1.0\memory.cpp"\r
+"E:\Windows CE Tools\linexec-xda-1.0\tester1.cpp"\r
+"E:\Windows CE Tools\linexec-xda-1.0\uart.cpp"\r
+]\r
+Creating command line "clarm.exe @C:\DOCUME~1\YUUSEI~1\LOCALS~1\Temp\RSP3.tmp" \r
+Creating temporary file "C:\DOCUME~1\YUUSEI~1\LOCALS~1\Temp\RSP4.tmp" with contents\r
+[\r
+commctrl.lib coredll.lib /nologo /base:"0x00010000" /stack:0x10000,0x1000 /entry:"WinMainCRTStartup" /incremental:no /pdb:"ARMRel/linexec.pdb" /nodefaultlib:"libc.lib /nodefaultlib:libcd.lib /nodefaultlib:libcmt.lib /nodefaultlib:libcmtd.lib /nodefaultlib:msvcrt.lib /nodefaultlib:msvcrtd.lib /nodefaultlib:oldnames.lib" /out:"ARMRel/linexec.exe" /subsystem:windowsce,2.11 /align:"4096" /MACHINE:ARM \r
+".\ARMRel\boot.obj"\r
+".\ARMRel\gpio.obj"\r
+".\ARMRel\graphics.obj"\r
+".\ARMRel\memory.obj"\r
+".\ARMRel\StdAfx.obj"\r
+".\ARMRel\tester1.obj"\r
+".\ARMRel\uart.obj"\r
+".\ARMRel\tester1.res"\r
+".\ARMRel\asm.obj"\r
+".\ARMRel\asmstuff.obj"\r
+]\r
+Creating command line "link.exe @C:\DOCUME~1\YUUSEI~1\LOCALS~1\Temp\RSP4.tmp"\r
+<h3>Output Window</h3>\r
+Compiling...\r
+boot.cpp\r
+gpio.cpp\r
+graphics.cpp\r
+memory.cpp\r
+tester1.cpp\r
+uart.cpp\r
+Generating Code...\r
+Linking...\r
+\r
+\r
+\r
+<h3>Results</h3>\r
+linexec.exe - 0 error(s), 0 warning(s)\r
+</pre>\r
+</body>\r
+</html>\r
diff --git a/linexec.vco b/linexec.vco
new file mode 100644 (file)
index 0000000..569b44c
Binary files /dev/null and b/linexec.vco differ
diff --git a/linexec.vcp b/linexec.vcp
new file mode 100644 (file)
index 0000000..ebaa96d
--- /dev/null
@@ -0,0 +1,278 @@
+# Microsoft eMbedded Visual Tools Project File - Name="linexec" - Package Owner=<4>\r
+# Microsoft eMbedded Visual Tools Generated Build File, Format Version 6.02\r
+# ** DO NOT EDIT **\r
+\r
+# TARGTYPE "Win32 (WCE ARM) Application" 0x8501\r
+\r
+CFG=linexec - Win32 (WCE ARM) Debug\r
+!MESSAGE This is not a valid makefile. To build this project using NMAKE,\r
+!MESSAGE use the Export Makefile command and run\r
+!MESSAGE \r
+!MESSAGE NMAKE /f "linexec.vcn".\r
+!MESSAGE \r
+!MESSAGE You can specify a configuration when running NMAKE\r
+!MESSAGE by defining the macro CFG on the command line. For example:\r
+!MESSAGE \r
+!MESSAGE NMAKE /f "linexec.vcn" CFG="linexec - Win32 (WCE ARM) Debug"\r
+!MESSAGE \r
+!MESSAGE Possible choices for configuration are:\r
+!MESSAGE \r
+!MESSAGE "linexec - Win32 (WCE ARM) Release" (based on "Win32 (WCE ARM) Application")\r
+!MESSAGE "linexec - Win32 (WCE ARM) Debug" (based on "Win32 (WCE ARM) Application")\r
+!MESSAGE \r
+\r
+# Begin Project\r
+# PROP AllowPerConfigDependencies 0\r
+# PROP Scc_ProjName "linexec"\r
+# PROP Scc_LocalPath "."\r
+# PROP ATL_Project 2\r
+CPP=clarm.exe\r
+MTL=midl.exe\r
+RSC=rc.exe\r
+\r
+!IF  "$(CFG)" == "linexec - Win32 (WCE ARM) Release"\r
+\r
+# PROP BASE Use_MFC 0\r
+# PROP BASE Use_Debug_Libraries 0\r
+# PROP BASE Output_Dir "ARMRel"\r
+# PROP BASE Intermediate_Dir "ARMRel"\r
+# PROP BASE CPU_ID "{D6518FFC-710F-11D3-99F2-00105A0DF099}"\r
+# PROP BASE Platform_ID "{8A9A2F80-6887-11D3-842E-005004848CBA}"\r
+# PROP BASE Target_Dir ""\r
+# PROP Use_MFC 0\r
+# PROP Use_Debug_Libraries 0\r
+# PROP Output_Dir "ARMRel"\r
+# PROP Intermediate_Dir "ARMRel"\r
+# PROP CPU_ID "{D6518FFC-710F-11D3-99F2-00105A0DF099}"\r
+# PROP Platform_ID "{8A9A2F80-6887-11D3-842E-005004848CBA}"\r
+# PROP Ignore_Export_Lib 0\r
+# PROP Target_Dir ""\r
+# ADD BASE RSC /l 0x409 /d UNDER_CE=$(CEVersion) /d _WIN32_WCE=$(CEVersion) /d "UNICODE" /d "_UNICODE" /d "NDEBUG" /d "$(CePlatform)" /d "ARM" /d "_ARM_" /r\r
+# ADD RSC /l 0x409 /d UNDER_CE=$(CEVersion) /d _WIN32_WCE=$(CEVersion) /d "UNICODE" /d "_UNICODE" /d "NDEBUG" /d "$(CePlatform)" /d "ARM" /d "_ARM_" /r\r
+# ADD BASE CPP /nologo /W3 /D _WIN32_WCE=$(CEVersion) /D "$(CePlatform)" /D "ARM" /D "_ARM_" /D UNDER_CE=$(CEVersion) /D "UNICODE" /D "_UNICODE" /D "NDEBUG" /Yu"stdafx.h" /Oxs /M$(CECrtMT) /c\r
+# ADD CPP /nologo /W3 /D _WIN32_WCE=$(CEVersion) /D "$(CePlatform)" /D "ARM" /D "_ARM_" /D UNDER_CE=$(CEVersion) /D "UNICODE" /D "_UNICODE" /D "NDEBUG" /FR /Yu"stdafx.h" /Oxs /M$(CECrtMT) /c\r
+# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /o "NUL" /win32\r
+# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /o "NUL" /win32\r
+BSC32=bscmake.exe\r
+# ADD BASE BSC32 /nologo\r
+# ADD BSC32 /nologo\r
+LINK32=link.exe\r
+# ADD BASE LINK32 commctrl.lib coredll.lib aygshell.lib /nologo /base:"0x00010000" /stack:0x10000,0x1000 /entry:"WinMainCRTStartup" /nodefaultlib:"$(CENoDefaultLib)" /subsystem:$(CESubsystem) /align:"4096" /MACHINE:ARM\r
+# ADD LINK32 commctrl.lib coredll.lib /nologo /base:"0x00010000" /stack:0x10000,0x1000 /entry:"WinMainCRTStartup" /nodefaultlib:"$(CENoDefaultLib)" /subsystem:$(CESubsystem) /align:"4096" /MACHINE:ARM\r
+\r
+!ELSEIF  "$(CFG)" == "linexec - Win32 (WCE ARM) Debug"\r
+\r
+# PROP BASE Use_MFC 0\r
+# PROP BASE Use_Debug_Libraries 1\r
+# PROP BASE Output_Dir "ARMDbg"\r
+# PROP BASE Intermediate_Dir "ARMDbg"\r
+# PROP BASE CPU_ID "{D6518FFC-710F-11D3-99F2-00105A0DF099}"\r
+# PROP BASE Platform_ID "{8A9A2F80-6887-11D3-842E-005004848CBA}"\r
+# PROP BASE Target_Dir ""\r
+# PROP Use_MFC 0\r
+# PROP Use_Debug_Libraries 1\r
+# PROP Output_Dir "ARMDbg"\r
+# PROP Intermediate_Dir "ARMDbg"\r
+# PROP CPU_ID "{D6518FFC-710F-11D3-99F2-00105A0DF099}"\r
+# PROP Platform_ID "{8A9A2F80-6887-11D3-842E-005004848CBA}"\r
+# PROP Ignore_Export_Lib 0\r
+# PROP Target_Dir ""\r
+# ADD BASE RSC /l 0x409 /d UNDER_CE=$(CEVersion) /d _WIN32_WCE=$(CEVersion) /d "UNICODE" /d "_UNICODE" /d "DEBUG" /d "$(CePlatform)" /d "ARM" /d "_ARM_" /r\r
+# ADD RSC /l 0x409 /d UNDER_CE=$(CEVersion) /d _WIN32_WCE=$(CEVersion) /d "UNICODE" /d "_UNICODE" /d "DEBUG" /d "$(CePlatform)" /d "ARM" /d "_ARM_" /r\r
+# ADD BASE CPP /nologo /W3 /Zi /Od /D "DEBUG" /D "ARM" /D "_ARM_" /D UNDER_CE=$(CEVersion) /D _WIN32_WCE=$(CEVersion) /D "$(CePlatform)" /D "UNICODE" /D "_UNICODE" /Yu"stdafx.h" /M$(CECrtMTDebug) /c\r
+# ADD CPP /nologo /W4 /Od /D "DEBUG" /D "ARM" /D "_ARM_" /D UNDER_CE=$(CEVersion) /D _WIN32_WCE=$(CEVersion) /D "$(CePlatform)" /D "UNICODE" /D "_UNICODE" /FR /Yu"stdafx.h" /M$(CECrtMTDebug) /c\r
+# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /o "NUL" /win32\r
+# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /o "NUL" /win32\r
+BSC32=bscmake.exe\r
+# ADD BASE BSC32 /nologo\r
+# ADD BSC32 /nologo\r
+LINK32=link.exe\r
+# ADD BASE LINK32 commctrl.lib coredll.lib aygshell.lib /nologo /base:"0x00010000" /stack:0x10000,0x1000 /entry:"WinMainCRTStartup" /debug /nodefaultlib:"$(CENoDefaultLib)" /subsystem:$(CESubsystem) /align:"4096" /MACHINE:ARM\r
+# ADD LINK32 commctrl.lib coredllprof.lib aygshell.lib /nologo /base:"0x00010000" /stack:0x10000,0x1000 /entry:"WinMainCRTStartup" /debug /nodefaultlib:"$(CENoDefaultLib)" /subsystem:$(CESubsystem) /align:"4096" /MACHINE:ARM\r
+\r
+!ENDIF \r
+\r
+# Begin Target\r
+\r
+# Name "linexec - Win32 (WCE ARM) Release"\r
+# Name "linexec - Win32 (WCE ARM) Debug"\r
+# Begin Group "Source Files"\r
+\r
+# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"\r
+# Begin Source File\r
+\r
+SOURCE=.\asm\asm.asm\r
+\r
+!IF  "$(CFG)" == "linexec - Win32 (WCE ARM) Release"\r
+\r
+# Begin Custom Build\r
+OutDir=.\ARMRel\r
+InputPath=.\asm\asm.asm\r
+\r
+"$(OUTDIR)\asm.obj" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"\r
+       armasm.exe $(InputPath) $(OUTDIR)\asm.obj\r
+\r
+# End Custom Build\r
+\r
+!ELSEIF  "$(CFG)" == "linexec - Win32 (WCE ARM) Debug"\r
+\r
+# Begin Custom Build\r
+IntDir=.\ARMDbg\r
+InputPath=.\asm\asm.asm\r
+InputName=asm\r
+\r
+"$(IntDir)\$(InputName).obj" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"\r
+       armasm -I $(InputPath) -list $(IntDir)\$(InputName).lst -CPU StrongARM1 -o $(IntDir)\$(InputName).obj .\asm\$(InputName).asm\r
+\r
+# End Custom Build\r
+\r
+!ENDIF \r
+\r
+# End Source File\r
+# Begin Source File\r
+\r
+SOURCE=.\asm\asmstuff.asm\r
+\r
+!IF  "$(CFG)" == "linexec - Win32 (WCE ARM) Release"\r
+\r
+# Begin Custom Build\r
+OutDir=.\ARMRel\r
+InputPath=.\asm\asmstuff.asm\r
+\r
+"$(OUTDIR)\asmstuff.obj" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"\r
+       armasm.exe $(InputPath) $(OUTDIR)\asmstuff.obj\r
+\r
+# End Custom Build\r
+\r
+!ELSEIF  "$(CFG)" == "linexec - Win32 (WCE ARM) Debug"\r
+\r
+# Begin Custom Build\r
+IntDir=.\ARMDbg\r
+InputPath=.\asm\asmstuff.asm\r
+InputName=asmstuff\r
+\r
+"$(IntDir)\$(InputName).obj" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"\r
+       armasm -I $(InputPath) -list $(IntDir)\$(InputName).lst -CPU StrongARM1 -o $(IntDir)\$(InputName).obj .\asm\$(InputName).asm\r
+\r
+# End Custom Build\r
+\r
+!ENDIF \r
+\r
+# End Source File\r
+# Begin Source File\r
+\r
+SOURCE=.\boot.cpp\r
+DEP_CPP_BOOT_=\\r
+       ".\config.h"\\r
+       ".\setup.h"\\r
+       ".\StdAfx.h"\\r
+       ".\tester1.h"\\r
+       {$(INCLUDE)}"sipapi.h"\\r
+       \r
+# End Source File\r
+# Begin Source File\r
+\r
+SOURCE=.\gpio.cpp\r
+DEP_CPP_GPIO_=\\r
+       ".\config.h"\\r
+       ".\setup.h"\\r
+       ".\StdAfx.h"\\r
+       ".\tester1.h"\\r
+       {$(INCLUDE)}"sipapi.h"\\r
+       \r
+# End Source File\r
+# Begin Source File\r
+\r
+SOURCE=.\graphics.cpp\r
+DEP_CPP_GRAPH=\\r
+       ".\config.h"\\r
+       ".\setup.h"\\r
+       ".\StdAfx.h"\\r
+       ".\tester1.h"\\r
+       {$(INCLUDE)}"sipapi.h"\\r
+       \r
+# End Source File\r
+# Begin Source File\r
+\r
+SOURCE=.\memory.cpp\r
+DEP_CPP_MEMOR=\\r
+       ".\config.h"\\r
+       ".\setup.h"\\r
+       ".\StdAfx.h"\\r
+       ".\tester1.h"\\r
+       {$(INCLUDE)}"sipapi.h"\\r
+       \r
+# End Source File\r
+# Begin Source File\r
+\r
+SOURCE=.\StdAfx.cpp\r
+DEP_CPP_STDAF=\\r
+       ".\StdAfx.h"\\r
+       \r
+# ADD CPP /Yc"stdafx.h"\r
+# End Source File\r
+# Begin Source File\r
+\r
+SOURCE=.\tester1.cpp\r
+DEP_CPP_TESTE=\\r
+       ".\config.h"\\r
+       ".\setup.h"\\r
+       ".\StdAfx.h"\\r
+       ".\tester1.h"\\r
+       {$(INCLUDE)}"sipapi.h"\\r
+       \r
+# End Source File\r
+# Begin Source File\r
+\r
+SOURCE=.\tester1.rc\r
+# End Source File\r
+# Begin Source File\r
+\r
+SOURCE=.\uart.cpp\r
+DEP_CPP_UART_=\\r
+       ".\config.h"\\r
+       ".\setup.h"\\r
+       ".\StdAfx.h"\\r
+       ".\tester1.h"\\r
+       {$(INCLUDE)}"sipapi.h"\\r
+       \r
+# End Source File\r
+# End Group\r
+# Begin Group "Header Files"\r
+\r
+# PROP Default_Filter "h;hpp;hxx;hm;inl"\r
+# Begin Source File\r
+\r
+SOURCE=.\config.h\r
+# End Source File\r
+# Begin Source File\r
+\r
+SOURCE=.\newres.h\r
+# End Source File\r
+# Begin Source File\r
+\r
+SOURCE=.\resource.h\r
+# End Source File\r
+# Begin Source File\r
+\r
+SOURCE=.\StdAfx.h\r
+# End Source File\r
+# Begin Source File\r
+\r
+SOURCE=.\tester1.h\r
+# End Source File\r
+# End Group\r
+# Begin Group "Resource Files"\r
+\r
+# PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe"\r
+# Begin Source File\r
+\r
+SOURCE=.\tester1.ico\r
+# End Source File\r
+# End Group\r
+# Begin Source File\r
+\r
+SOURCE=.\ReadMe.txt\r
+# End Source File\r
+# End Target\r
+# End Project\r
diff --git a/linexec.vcw b/linexec.vcw
new file mode 100644 (file)
index 0000000..28bb66c
--- /dev/null
@@ -0,0 +1,32 @@
+Microsoft eMbedded Visual Tools Workspace File, Format Version 3.00\r
+# WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE!\r
+\r
+###############################################################################\r
+\r
+Project: "linexec"=.\linexec.vcp - Package Owner=<4>\r
+\r
+Package=<5>\r
+{{{\r
+    begin source code control\r
+    tester1\r
+    .\r
+    end source code control\r
+}}}\r
+\r
+Package=<4>\r
+{{{\r
+}}}\r
+\r
+###############################################################################\r
+\r
+Global:\r
+\r
+Package=<5>\r
+{{{\r
+}}}\r
+\r
+Package=<3>\r
+{{{\r
+}}}\r
+\r
+###############################################################################
\ No newline at end of file
diff --git a/memory.cpp b/memory.cpp
new file mode 100644 (file)
index 0000000..96ff433
--- /dev/null
@@ -0,0 +1,106 @@
+#include "stdafx.h"\r
+#include "tester1.h"\r
+#include <commctrl.h>\r
+//#include <aygshell.h>\r
+#include <sipapi.h>\r
+#include "setup.h"\r
+\r
+UINT32 ReadPhysical(UINT32 adr)\r
+{\r
+       UINT32 base=  adr&0xffff0000;\r
+       UINT32 offset=adr&0x0000ffff;\r
+       UINT32 *p=(UINT32*)VirtualAlloc(0,0x10000,MEM_RESERVE,PAGE_READWRITE);\r
+       if(!p) return 0xFFFFFFFF;\r
+       if(!VirtualCopy((void*)p,(void*)(base/256),0x10000,PAGE_READWRITE|PAGE_NOCACHE|PAGE_PHYSICAL)) return 0xFFFFFFFF;\r
+       UINT32 val=p[offset/4];\r
+       VirtualFree(p,0,MEM_RELEASE);\r
+       return val;\r
+}\r
+\r
+void WritePhysical(UINT32 adr,UINT32 val)\r
+{\r
+       UINT32 base=  adr&0xffff0000;\r
+       UINT32 offset=adr&0x0000ffff;\r
+       UINT32 *p=(UINT32*)VirtualAlloc(0,0x10000,MEM_RESERVE,PAGE_READWRITE);\r
+       VirtualCopy((void*)p,(void*)(base/256),0x10000,PAGE_READWRITE|PAGE_NOCACHE|PAGE_PHYSICAL);\r
+       p[offset/4]=val;\r
+       VirtualFree(p,0,MEM_RELEASE);\r
+}\r
+\r
+UINT32 VirtualToPhysical(UINT32 Virtual)\r
+{\r
+       FILE *log=fopen("\\logger1.txt","w");\r
+\r
+       fprintf(log,"virtual: 0x%lx\n",Virtual);\r
+       UINT32 mmu=(UINT32)read_mmu();\r
+//     mmu=0xa0000000;\r
+       fprintf(log,"mmu:  0x%lx \n",mmu);\r
+\r
+       UINT32 AdrFirstLevDesc=(mmu&0xffffc000)+((Virtual>>18)&0xfffffffc);\r
+       fprintf(log,"AdrFirstLevDesc:  0x%lx \n",AdrFirstLevDesc);\r
+\r
+       UINT32 FirstLevDesc=ReadPhysical(AdrFirstLevDesc);\r
+       fprintf(log,"FirstLevDesc:  0x%lx \n",FirstLevDesc);\r
+\r
+       \r
+       if(0)\r
+       {\r
+               fprintf(log,"Page\n");\r
+               UINT32 PhysAddr=(FirstLevDesc&0xfff00000)+(Virtual&0xfffff);\r
+               fprintf(log,"Physical address:  0x%lx \n",PhysAddr);\r
+               fclose(log);\r
+               return PhysAddr;\r
+       }\r
+\r
+       if(FirstLevDesc&0x3==3) // tiny page\r
+       {\r
+               fprintf(log,"Tiny page\n");\r
+               UINT32 AdrSecondLevDesc=(FirstLevDesc&0xfffff000)+((Virtual>>8)&0xffc);\r
+               fprintf(log,"AdrSecondLevDesc:  0x%lx \n",AdrSecondLevDesc);\r
+\r
+               UINT32 SecondLevDesc=ReadPhysical(AdrSecondLevDesc);\r
+               fprintf(log,"SecondLevDesc:  0x%lx \n",SecondLevDesc);\r
+       \r
+               UINT32 PhysAddr=(SecondLevDesc&0xffffc000)+(Virtual&0x3ff);\r
+               fprintf(log,"Physical address:  0x%lx \n",PhysAddr);\r
+               fclose(log);\r
+               return PhysAddr;\r
+       }\r
+//     if(FirstLevDesc&0x3==3) // small page\r
+       {\r
+               fprintf(log,"Else page\n");\r
+               UINT32 AdrSecondLevDesc=(FirstLevDesc&0xfffffc00)+((Virtual>>10)&0x03fc);\r
+               fprintf(log,"AdrSecondLevDesc:  0x%lx \n",AdrSecondLevDesc);\r
+\r
+               UINT32 SecondLevDesc=ReadPhysical(AdrSecondLevDesc);\r
+               fprintf(log,"SecondLevDesc:  0x%lx \n",SecondLevDesc);\r
+\r
+               UINT32 PhysAddr=(SecondLevDesc&0xffff0000)+(Virtual&0xffff);\r
+               fprintf(log,"Physical address:  0x%lx \n",PhysAddr);\r
+               fclose(log);\r
+               return PhysAddr;\r
+\r
+       }\r
+}\r
+\r
+\r
+\r
+\r
+\r
+\r
+void DumpMMU()\r
+{\r
+       void *mmu=(void*)(MEM_START);\r
+\r
+       UINT32 *_mmu=(UINT32*)VirtualAlloc((void*)0x0,sizeof(void*)*0xffff, MEM_RESERVE,PAGE_READWRITE);\r
+       int ret=VirtualCopy(_mmu,(void *) ((UINT32)mmu/256),sizeof(void*)*0xffff        , PAGE_READWRITE|PAGE_NOCACHE|PAGE_PHYSICAL);\r
+\r
+       FILE *log=fopen("\\logger2.txt","w");\r
+       fprintf(log,"mmu_table=0x%lx : \n",_mmu);\r
+       fprintf(log,"mmu=0x%lx : \n",mmu);\r
+       fprintf(log,"ret=0x%x : \n",ret);\r
+       for(UINT32 z=0;z<=0x0100;z++)\r
+               fprintf(log,"mmu_table[0x%x]=0x%lx: \n",z,_mmu[z]);\r
+       fclose(log);\r
+       return;\r
+}\r
diff --git a/newres.h b/newres.h
new file mode 100644 (file)
index 0000000..e6e2a53
--- /dev/null
+++ b/newres.h
@@ -0,0 +1,41 @@
+#ifndef __NEWRES_H__\r\r
+#define __NEWRES_H__\r\r
+\r\r
+#if !defined(UNDER_CE)\r\r
+#define UNDER_CE _WIN32_WCE\r\r
+#endif\r\r
+\r\r
+#if defined(_WIN32_WCE)\r\r
+       #if !defined(WCEOLE_ENABLE_DIALOGEX)\r\r
+               #define DIALOGEX DIALOG DISCARDABLE\r\r
+       #endif\r\r
+       #include <commctrl.h>\r\r
+       #define  SHMENUBAR RCDATA\r\r
+       #if defined(WIN32_PLATFORM_PSPC) && (_WIN32_WCE >= 300)\r\r
+               #include <aygshell.h>\r\r
+               #define AFXCE_IDR_SCRATCH_SHMENU  28700\r\r
+       #else\r\r
+               #define I_IMAGENONE             (-2)\r\r
+               #define NOMENU                  0xFFFF\r\r
+               #define IDS_SHNEW               1\r\r
+\r\r
+               #define IDM_SHAREDNEW        10\r\r
+               #define IDM_SHAREDNEWDEFAULT 11\r\r
+       #endif // _WIN32_WCE_PSPC\r\r
+       #define AFXCE_IDD_SAVEMODIFIEDDLG 28701\r\r
+#endif // _WIN32_WCE\r\r
+\r\r
+#ifdef RC_INVOKED\r\r
+#ifndef _INC_WINDOWS\r\r
+#define _INC_WINDOWS\r\r
+       #include "winuser.h"           // extract from windows header\r\r
+       #include "winver.h"   \r\r
+#endif\r\r
+#endif\r\r
+\r\r
+#ifdef IDC_STATIC\r\r
+#undef IDC_STATIC\r\r
+#endif\r\r
+#define IDC_STATIC      (-1)\r\r
+\r\r
+#endif //__NEWRES_H__\r\r
diff --git a/resource.h b/resource.h
new file mode 100644 (file)
index 0000000..635cd99
--- /dev/null
@@ -0,0 +1,27 @@
+//{{NO_DEPENDENCIES}}\r\r
+// Microsoft eMbedded Visual C++ generated include file.\r\r
+// Used by TESTER1.RC\r\r
+//\r\r
+#define IDS_APP_TITLE                                  1\r\r
+#define IDS_HELLO                                              2\r\r
+#define IDC_TESTER1                            3\r\r
+#define IDI_TESTER1                            101\r\r
+#define IDM_MENU                                               102\r\r
+#define IDD_ABOUTBOX                                   103\r\r
+#define IDS_HELP                                               104\r\r
+\r\r
+#define IDS_COMMAND1                                   301\r\r
+\r\r
+#define IDM_MAIN_COMMAND1                              40001\r\r
+#define IDM_HELP_ABOUT                                 40003\r\r
+\r\r
+// Next default values for new objects\r\r
+// \r\r
+#ifdef APSTUDIO_INVOKED\r\r
+#ifndef APSTUDIO_READONLY_SYMBOLS\r\r
+#define _APS_NEXT_RESOURCE_VALUE        104\r\r
+#define _APS_NEXT_COMMAND_VALUE         40004\r\r
+#define _APS_NEXT_CONTROL_VALUE         1001\r\r
+#define _APS_NEXT_SYMED_VALUE           101\r\r
+#endif\r\r
+#endif\r\r
diff --git a/setup.h b/setup.h
new file mode 100644 (file)
index 0000000..1bc06c8
--- /dev/null
+++ b/setup.h
@@ -0,0 +1,278 @@
+/*\r
+ *  linux/include/asm/setup.h\r
+ *\r
+ *  Copyright (C) 1997-1999 Russell King\r
+ *\r
+ * This program is free software; you can redistribute it and/or modify\r
+ * it under the terms of the GNU General Public License version 2 as\r
+ * published by the Free Software Foundation.\r
+ *\r
+ *  Structure passed to kernel to tell it about the\r
+ *  hardware it's running on.  See linux/Documentation/arm/Setup\r
+ *  for more info.\r
+ *\r
+ * NOTE:\r
+ *  This file contains two ways to pass information from the boot\r
+ *  loader to the kernel. The old struct param_struct is deprecated,\r
+ *  but it will be kept in the kernel for 5 years from now\r
+ *  (2001). This will allow boot loaders to convert to the new struct\r
+ *  tag way.\r
+ */\r
+#ifndef __ASMARM_SETUP_H\r
+#define __ASMARM_SETUP_H\r\r
+\r\r
+#define u32    UINT32\r\r
+#define u16    UINT16\r\r
+#define u8     UINT8\r\r
+\r
+\r
+/*#ifndef CONFIG_ACCEPT_GPL\r
+#error This file covered by GPL but CONFIG_ACCEPT_GPL undefined.\r
+#endif*/\r
+\r
+/*\r
+ * Usage:\r
+ *  - do not go blindly adding fields, add them at the end\r
+ *  - when adding fields, don't rely on the address until\r
+ *    a patch from me has been released\r
+ *  - unused fields should be zero (for future expansion)\r
+ *  - this structure is relatively short-lived - only\r
+ *    guaranteed to contain useful data in setup_arch()\r
+ */\r
+#define COMMAND_LINE_SIZE 1024\r
+\r
+/* This is the old deprecated way to pass parameters to the kernel */\r
+struct param_struct {\r
+    union {\r
+       struct {\r
+           unsigned long page_size;            /*  0 */\r
+           unsigned long nr_pages;             /*  4 */\r
+           unsigned long ramdisk_size;         /*  8 */\r
+           unsigned long flags;                /* 12 */\r
+#define FLAG_READONLY  1\r
+#define FLAG_RDLOAD    4\r
+#define FLAG_RDPROMPT  8\r
+           unsigned long rootdev;              /* 16 */\r
+           unsigned long video_num_cols;       /* 20 */\r
+           unsigned long video_num_rows;       /* 24 */\r
+           unsigned long video_x;              /* 28 */\r
+           unsigned long video_y;              /* 32 */\r
+           unsigned long memc_control_reg;     /* 36 */\r
+           unsigned char sounddefault;         /* 40 */\r
+           unsigned char adfsdrives;           /* 41 */\r
+           unsigned char bytes_per_char_h;     /* 42 */\r
+           unsigned char bytes_per_char_v;     /* 43 */\r
+           unsigned long pages_in_bank[4];     /* 44 */\r
+           unsigned long pages_in_vram;        /* 60 */\r
+           unsigned long initrd_start;         /* 64 */\r
+           unsigned long initrd_size;          /* 68 */\r
+           unsigned long rd_start;             /* 72 */\r
+           unsigned long system_rev;           /* 76 */\r
+           unsigned long system_serial_low;    /* 80 */\r
+           unsigned long system_serial_high;   /* 84 */\r
+           unsigned long mem_fclk_21285;       /* 88 */\r
+       } s;\r
+       char unused[256];\r
+    } u1;\r
+    union {\r
+       char paths[8][128];\r
+       struct {\r
+           unsigned long magic;\r
+           char n[1024 - sizeof(unsigned long)];\r
+       } s;\r
+    } u2;\r
+    char commandline[COMMAND_LINE_SIZE];\r
+};\r
+\r
+\r
+\r
+/*\r
+ * The new way of passing information: a list of tagged entries\r
+ */\r
+\r
+/* The list ends with an ATAG_NONE node. */\r
+#define ATAG_NONE      0x00000000\r
+\r
+struct tag_header {\r
+       u32 size;\r
+       u32 tag;\r
+};\r
+\r
+/* The list must start with an ATAG_CORE node */\r
+#define ATAG_CORE      0x54410001\r
+\r
+struct tag_core {\r
+       u32 flags;              /* bit 0 = read-only */\r
+       u32 pagesize;\r
+       u32 rootdev;\r
+};\r
+\r
+/* it is allowed to have multiple ATAG_MEM nodes */\r
+#define ATAG_MEM       0x54410002\r
+\r
+struct tag_mem32 {\r
+       u32     size;\r
+       u32     start;  /* physical start address */\r
+};\r
+\r
+/* VGA text type displays */\r
+#define ATAG_VIDEOTEXT 0x54410003\r
+\r
+struct tag_videotext {\r
+       u8              x;\r
+       u8              y;\r
+       u16             video_page;\r
+       u8              video_mode;\r
+       u8              video_cols;\r
+       u16             video_ega_bx;\r
+       u8              video_lines;\r
+       u8              video_isvga;\r
+       u16             video_points;\r
+};\r
+\r
+/* describes how the ramdisk will be used in kernel */\r
+#define ATAG_RAMDISK   0x54410004\r
+\r
+struct tag_ramdisk {\r
+       u32 flags;      /* bit 0 = load, bit 1 = prompt */\r
+       u32 size;       /* decompressed ramdisk size in _kilo_ bytes */\r
+       u32 start;      /* starting block of floppy-based RAM disk image */\r
+};\r
+\r
+/* describes where the compressed ramdisk image lives */\r
+#define ATAG_INITRD    0x54410005\r\r
+\r\r
+#define ATAG_INITRD2   0x54420005\r
+\r
+struct tag_initrd {\r
+       u32 start;      /* physical start address */\r
+       u32 size;       /* size of compressed ramdisk image in bytes */\r
+};\r
+\r
+/* board serial number. "64 bits should be enough for everybody" */\r
+#define ATAG_SERIAL    0x54410006\r
+\r
+struct tag_serialnr {\r
+       u32 low;\r
+       u32 high;\r
+};\r
+\r
+/* board revision */\r
+#define ATAG_REVISION  0x54410007\r
+\r
+struct tag_revision {\r
+       u32 rev;\r
+};\r
+\r
+/* initial values for vesafb-type framebuffers. see struct screen_info\r
+ * in include/linux/tty.h\r
+ */\r
+#define ATAG_VIDEOLFB  0x54410008\r
+\r
+struct tag_videolfb {\r
+       u16             lfb_width;\r
+       u16             lfb_height;\r
+       u16             lfb_depth;\r
+       u16             lfb_linelength;\r
+       u32             lfb_base;\r
+       u32             lfb_size;\r
+       u8              red_size;\r
+       u8              red_pos;\r
+       u8              green_size;\r
+       u8              green_pos;\r
+       u8              blue_size;\r
+       u8              blue_pos;\r
+       u8              rsvd_size;\r
+       u8              rsvd_pos;\r
+};\r
+\r
+/* command line: \0 terminated string */\r
+#define ATAG_CMDLINE   0x54410009\r
+\r
+struct tag_cmdline {\r
+       char    cmdline[1];     /* this is the minimum size */\r
+};\r
+\r
+/* acorn RiscPC specific information */\r
+#define ATAG_ACORN     0x41000101\r
+\r
+struct tag_acorn {\r
+       u32 memc_control_reg;\r
+       u32 vram_pages;\r
+       u8 sounddefault;\r
+       u8 adfsdrives;\r
+};\r
+\r
+#define ATAG_PTABLE    0x53410001\r
+\r
+/* footbridge memory clock, see arch/arm/mach-footbridge/arch.c */\r
+#define ATAG_MEMCLK    0x41000402\r
+\r
+struct tag_memclk {\r
+       u32 fmemclk;\r
+};\r
+\r
+struct tag {\r
+       struct tag_header hdr;\r
+       union {\r
+               struct tag_core         core;\r
+               struct tag_mem32        mem;\r
+               struct tag_videotext    videotext;\r
+               struct tag_ramdisk      ramdisk;\r
+               struct tag_initrd       initrd;\r
+               struct tag_serialnr     serialnr;\r
+               struct tag_revision     revision;\r
+               struct tag_videolfb     videolfb;\r
+               struct tag_cmdline      cmdline;\r
+//                struct tag_ptable       ptable;  \r
+\r
+               /*\r
+                * Acorn specific\r
+                */\r
+               struct tag_acorn        acorn;\r
+\r
+               /*\r
+                * DC21285 specific\r
+                */\r
+               struct tag_memclk       memclk;\r
+           \r
+       } u;\r
+};\r
+\r
+struct tagtable {\r
+       u32 tag;\r
+       int (*parse)(const struct tag *);\r
+};\r
+\r
+#define __tag __attribute__((unused, __section__(".taglist")))\r
+#define __tagtable(tag, fn) \\r
+static struct tagtable __tagtable_##fn __tag = { tag, fn }\r
+\r
+#define tag_member_present(tag,member)                         \\r
+       ((unsigned long)(&((struct tag *)0L)->member + 1)       \\r
+               <= (tag)->hdr.size * 4)\r
+\r
+#define tag_next(t)    ((struct tag *)((u32 *)(t) + (t)->hdr.size))\r
+#define tag_size(type) ((sizeof(struct tag_header) + sizeof(struct type)) >> 2)\r
+\r
+#define for_each_tag(t,base)           \\r
+       for (t = base; t->hdr.size; t = tag_next(t))\r
+\r
+/*\r
+ * Memory map description\r
+ */\r
+#define NR_BANKS 8\r
+\r
+struct meminfo {\r
+       int nr_banks;\r
+       unsigned long end;\r
+       struct {\r
+               unsigned long start;\r
+               unsigned long size;\r
+               int           node;\r
+       } bank[NR_BANKS];\r
+};\r
+\r
+extern struct meminfo meminfo;\r
+\r
+#endif\r
diff --git a/tester1.aps b/tester1.aps
new file mode 100644 (file)
index 0000000..24921ad
Binary files /dev/null and b/tester1.aps differ
diff --git a/tester1.cpp b/tester1.cpp
new file mode 100644 (file)
index 0000000..fe629ba
--- /dev/null
@@ -0,0 +1,389 @@
+// tester1.cpp : Defines the entry point for the application.
+//
+
+#include "stdafx.h"
+#include "tester1.h"
+#include <commctrl.h>
+//#include <aygshell.h>
+#include <sipapi.h>
+#include "setup.h"
+
+#define MAX_LOADSTRING 100
+
+// Global Variables:
+HINSTANCE                      hInst;                                  // The current instance
+HWND                           hwndCB;                                 // The command bar handle
+
+//static SHACTIVATEINFO s_sai;
+
+ATOM                           MyRegisterClass (HINSTANCE, LPTSTR);
+BOOL                           InitInstance    (HINSTANCE, int);
+LRESULT CALLBACK       WndProc                 (HWND, UINT, WPARAM, LPARAM);
+LRESULT CALLBACK       About                   (HWND, UINT, WPARAM, LPARAM);
+HWND                           CreateRpCommandBar(HWND);
+
+\r
+#pragma warning(disable: 4100 4710 4189; error: 4701)
+/* who cares?! 
+       4100: whining about parameters not being used.
+       4710: whining about screwing up inlining.
+       4189: initialized but not used. make that an error: later.
+       4701: usage w/o initialization.
+       */
+\r
+int WINAPI WinMain(    HINSTANCE hInstance,
+                                       HINSTANCE hPrevInstance,
+                                       LPTSTR    lpCmdLine,
+                                       int       nCmdShow)
+{
+       MSG msg;
+       HACCEL hAccelTable;
+
+       // Perform application initialization:
+       if (!InitInstance (hInstance, nCmdShow)) 
+       {
+               return FALSE;
+       }
+
+       hAccelTable = LoadAccelerators(hInstance, (LPCTSTR)IDC_TESTER1);
+
+       // Main message loop:
+       while (GetMessage(&msg, NULL, 0, 0)) 
+       {
+               if (!TranslateAccelerator(msg.hwnd, hAccelTable, &msg)) 
+               {
+                       TranslateMessage(&msg);
+                       DispatchMessage(&msg);
+               }
+       }
+
+       return msg.wParam;
+}
+
+//
+//  FUNCTION: MyRegisterClass()
+//
+//  PURPOSE: Registers the window class.
+//
+//  COMMENTS:
+//
+//    It is important to call this function so that the application 
+//    will get 'well formed' small icons associated with it.
+//
+ATOM MyRegisterClass(HINSTANCE hInstance, LPTSTR szWindowClass)
+{
+       WNDCLASS        wc;
+
+    wc.style                   = CS_HREDRAW | CS_VREDRAW;
+    wc.lpfnWndProc             = (WNDPROC) WndProc;
+    wc.cbClsExtra              = 0;
+    wc.cbWndExtra              = 0;
+    wc.hInstance               = hInstance;
+    wc.hIcon                   = LoadIcon(hInstance, MAKEINTRESOURCE(IDI_TESTER1));
+    wc.hCursor                 = 0;
+    wc.hbrBackground   = (HBRUSH) GetStockObject(WHITE_BRUSH);
+    wc.lpszMenuName            = 0;
+    wc.lpszClassName   = szWindowClass;
+
+       return RegisterClass(&wc);
+}
+\r
+HANDLE OpenCOM1() {\r
+\r
+       static HANDLE COM1handle = INVALID_HANDLE_VALUE;\r
+       const char msg[] = "\r\n--------linexec--------\r\n";\r
+       unsigned long wrote;\r
+       int speed = CBR_115200;\r
+       HANDLE h;\r
+\r
+       if (COM1handle != INVALID_HANDLE_VALUE)\r
+               return (COM1handle);\r
+\r
+       h = CreateFile(TEXT("COM1:"),\r
+           GENERIC_READ | GENERIC_WRITE, 0, NULL, OPEN_EXISTING, 0,\r
+           NULL);\r
+       if (h == INVALID_HANDLE_VALUE)\r
+               return (h);\r
+\r
+       DCB dcb;\r
+       if (!GetCommState(h, &dcb))\r
+               goto bad;\r
+\r
+       dcb.BaudRate = speed;\r
+       if (!SetCommState(h, &dcb))\r
+               goto bad;\r
+\r
+       // Print banner on serial console.\r
+       WriteFile(h, msg, sizeof msg, &wrote, 0);\r
+\r
+       COM1handle = h;\r
+\r
+       return (h);\r
+ bad:\r
+       CloseHandle(h);\r
+       return (INVALID_HANDLE_VALUE);\r
+}\r
+
+//
+//  FUNCTION: InitInstance(HANDLE, int)
+//
+//  PURPOSE: Saves instance handle and creates main window
+//
+//  COMMENTS:
+//
+//    In this function, we save the instance handle in a global variable and
+//    create and display the main program window.
+//
+
+BOOL InitInstance(HINSTANCE hInstance, int nCmdShow)
+{
+       HWND    hWnd = NULL;\r
+       TCHAR   szTitle[MAX_LOADSTRING];                        // The title bar text\r
+       TCHAR   szWindowClass[MAX_LOADSTRING];          // The window class name
+\r
+       hInst = hInstance;              // Store instance handle in our global variable\r
+       // Initialize global string\r
+       LoadString(hInstance, IDC_TESTER1, szWindowClass, MAX_LOADSTRING);\r
+       LoadString(hInstance, IDS_APP_TITLE, szTitle, MAX_LOADSTRING);
+\r
+       //If it is already running, then focus on the window
+       hWnd = FindWindow(szWindowClass, szTitle);      
+       if (hWnd) 
+       {
+               SetForegroundWindow ((HWND) (((DWORD)hWnd) | 0x01));    
+               return 0;
+       } 
+
+       MyRegisterClass(hInstance, szWindowClass);
+       
+       RECT    rect;
+       GetClientRect(hWnd, &rect);
+\r
+       OpenCOM1();
+       load_boot("\\My Documents\\params.txt");
+       load_boot("\\Storage Card\\params.txt");
+       load_boot("\\ÒÓØ ¶°ÄÞ\\params.txt");\r
+
+       hWnd = CreateWindow(szWindowClass, szTitle, WS_VISIBLE,
+               CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, NULL, NULL, hInstance, NULL);
+       if (!hWnd)
+       {       
+               return FALSE;
+       }
+
+       
+       
+       //When the main window is created using CW_USEDEFAULT the height of the menubar (if one
+       // is created is not taken into account). So we resize the window after creating it
+       // if a menubar is present
+       {
+               RECT rc;
+               GetWindowRect(hWnd, &rc);
+               rc.bottom -= MENU_HEIGHT;
+               if (hwndCB)
+                       MoveWindow(hWnd, rc.left, rc.top, rc.right, rc.bottom, FALSE);
+       }
+
+
+       ShowWindow(hWnd, nCmdShow);
+       UpdateWindow(hWnd);
+
+       return TRUE;
+}
+
+//
+//  FUNCTION: WndProc(HWND, unsigned, WORD, LONG)
+//
+//  PURPOSE:  Processes messages for the main window.
+//
+//  WM_COMMAND - process the application menu
+//  WM_PAINT   - Paint the main window
+//  WM_DESTROY - post a quit message and return
+//
+//
+LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
+{
+\r
+       HDC hdc;
+\r
+       int wmId, wmEvent;
+\r
+       PAINTSTRUCT ps;
+\r
+       TCHAR szHello[MAX_LOADSTRING];
+\r
+
+\r
+       switch (message) 
+\r
+       {
+\r
+               case WM_COMMAND:
+\r
+                       wmId    = LOWORD(wParam); 
+\r
+                       wmEvent = HIWORD(wParam); 
+\r
+                       // Parse the menu selections:
+\r
+                       switch (wmId)
+\r
+                       {       
+\r
+                               case IDM_HELP_ABOUT:
+\r
+                                       DialogBox(hInst, (LPCTSTR)IDD_ABOUTBOX, hWnd, (DLGPROC)About);
+\r
+                                   break;
+\r
+                               case IDOK:
+\r
+                                       SendMessage(hWnd, WM_ACTIVATE, MAKEWPARAM(WA_INACTIVE, 0), (LPARAM)hWnd);
+\r
+                                       SendMessage (hWnd, WM_CLOSE, 0, 0);
+\r
+                                       break;
+\r
+                               default:
+\r
+                                  return DefWindowProc(hWnd, message, wParam, lParam);
+\r
+                       }
+\r
+                       break;
+\r
+               case WM_CREATE:
+\r
+                       hwndCB = CreateRpCommandBar(hWnd);
+\r
+                       break;
+\r
+               case WM_PAINT:
+\r
+                       RECT rt;
+\r
+                       hdc = BeginPaint(hWnd, &ps);
+\r
+                       GetClientRect(hWnd, &rt);
+\r
+                       LoadString(hInst, IDS_HELLO, szHello, MAX_LOADSTRING);
+\r
+                       DrawText(hdc, szHello, _tcslen(szHello), &rt, 
+\r
+                               DT_SINGLELINE | DT_VCENTER | DT_CENTER);
+\r
+                       EndPaint(hWnd, &ps);
+\r
+                       break; 
+\r
+               case WM_DESTROY:
+\r
+                       CommandBar_Destroy(hwndCB);
+\r
+                       PostQuitMessage(0);
+\r
+                       break;
+\r
+               case WM_SETTINGCHANGE:
+\r
+//                     SHHandleWMSettingChange(hWnd, wParam, lParam, &s_sai);
+\r
+               break;
+\r
+               default:
+\r
+                       return DefWindowProc(hWnd, message, wParam, lParam);
+\r
+   }
+\r
+   return 0;
+\r
+}
+\r
+
+\r
+HWND CreateRpCommandBar(HWND hwnd)
+\r
+{
+/*\r
+       SHMENUBARINFO mbi;
+\r
+
+\r
+       memset(&mbi, 0, sizeof(SHMENUBARINFO));
+\r
+       mbi.cbSize     = sizeof(SHMENUBARINFO);
+\r
+       mbi.hwndParent = hwnd;
+\r
+       mbi.nToolBarId = IDM_MENU;
+\r
+       mbi.hInstRes   = hInst;
+\r
+       mbi.nBmpId     = 0;
+\r
+       mbi.cBmpImages = 0;
+\r
+
+\r
+       if (!SHCreateMenuBar(&mbi)) 
+\r
+               return NULL;
+\r
+
+\r
+       return mbi.hwndMB;
+*/\r
+       return NULL;\r
+}
+\r
+
+\r
+// Mesage handler for the About box.
+\r
+LRESULT CALLBACK About(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
+\r
+{
+\r
+//     SHINITDLGINFO shidi;
+\r
+
+\r
+       switch (message)
+\r
+       {
+\r
+               case WM_INITDIALOG:
+\r
+                       // Create a Done button and size it.  
+\r
+//                     shidi.dwMask = SHIDIM_FLAGS;
+\r
+//                      shidi.dwFlags = SHIDIF_DONEBUTTON | SHIDIF_SIPDOWN | SHIDIF_SIZEDLGFULLSCREEN;
+\r
+//                     shidi.hDlg = hDlg;
+\r
+//                     SHInitDialog(&shidi);
+\r
+                       return TRUE; 
+\r
+
+\r
+               case WM_COMMAND:
+\r
+                       if (LOWORD(wParam) == IDOK) {
+\r
+                               EndDialog(hDlg, LOWORD(wParam));
+\r
+                               return TRUE;
+\r
+                       }
+\r
+                       break;
+\r
+       }
+\r
+    return FALSE;
+\r
+}
+\r
diff --git a/tester1.h b/tester1.h
new file mode 100644 (file)
index 0000000..b793a85
--- /dev/null
+++ b/tester1.h
@@ -0,0 +1,71 @@
+#include "config.h"\r
+\r
+\r\r
+#define BOOT_LOGO\r\r
+//#define BOOT_LOGO_DONE\r\r
+\r\r
+#if !defined(AFX_TESTER1_H__7D4A2D28_4650_475E_A82E_CF6F8E7BA839__INCLUDED_)\r\r
+#define AFX_TESTER1_H__7D4A2D28_4650_475E_A82E_CF6F8E7BA839__INCLUDED_\r\r
+\r\r
+#if _MSC_VER > 1000\r\r
+#pragma once\r\r
+#endif // _MSC_VER > 1000\r\r
+\r\r
+#include "resource.h"\r\r
+\r\r
+//////////////////////////////// Some type definitions /////////////////////\r\r
+struct Image {\r\r
+ UINT16 *p;\r\r
+ long x,y;\r\r
+};\r\r
+\r\r
+/////////////////////////////Functions /////////////////////////////////////\r\r
+Image ReadBMP(char[]);\r\r
+void ShowImage(UINT16*,int,int,int=0,int=0);\r\r
+void Gpio();\r\r
+void UART_setup();\r\r
+void DumpMMU();\r\r
+void UART_puts(char *);\r\r
+void init_fb();\r\r
+void try_fb();\r\r
+void boot_linux(char*,char*);\r\r
+UINT32 ReadPhysical(UINT32);\r\r
+void  WritePhysical(UINT32 addr,UINT32 val);\r\r
+UINT32 VirtualToPhysical(UINT32);\r\r
+void load_boot(char*);\r\r
+void SetGPIOalt(int,int);\r\r
+void SetGPIOio(int,int);\r\r
+\r\r
+\r\r
+////////////////////////////////////////////////////////////////////////////\r\r
+\r\r
+extern "C" BOOL VirtualCopy(LPVOID lpvDestMem, LPVOID lpvSrcMem, \r\r
+                                                       DWORD dwSizeInBytes, DWORD dwProtectFlag);\r\r
+\r\r
+extern void do_it();\r\r
+\r\r
+extern int read_mmu();         // reads where is/are descriptors located\r\r
+\r\r
+extern void IntOff();\r\r
+extern void DRAMloader(UINT32 adr,UINT32 machine_num); // this function turns off MMU and jumps onto physical address given\r\r
+\r\r
+extern "C" DWORD SetProcPermissions(\r\r
+DWORD newperms \r\r
+); \r\r
+\r\r
+extern "C" DWORD GetCurrentPermissions(\r\r
+);\r\r
+\r\r
+extern "C" BOOL SetKMode( \r\r
+BOOL fMode \r\r
+);\r\r
+\r\r
+extern "C" LPVOID CreateStaticMapping(\r\r
+DWORD dwPhysBase,\r\r
+DWORD dwSize\r\r
+);\r\r
+\r\r
+\r\r
+#define MENU_HEIGHT 26\r\r
+\r\r
+#endif // !defined(AFX_TESTER1_H__7D4A2D28_4650_475E_A82E_CF6F8E7BA839__INCLUDED_)\r\r
diff --git a/tester1.ico b/tester1.ico
new file mode 100644 (file)
index 0000000..0130454
Binary files /dev/null and b/tester1.ico differ
diff --git a/tester1.rc b/tester1.rc
new file mode 100644 (file)
index 0000000..7169029
--- /dev/null
@@ -0,0 +1,153 @@
+//Microsoft eMbedded Visual C++ generated resource script.\r\r
+//\r\r
+#include "resource.h"\r\r
+\r\r
+#define APSTUDIO_READONLY_SYMBOLS\r\r
+/////////////////////////////////////////////////////////////////////////////\r\r
+//\r\r
+// Generated from the TEXTINCLUDE 2 resource.\r\r
+//\r\r
+#include "newres.h"\r\r
+/////////////////////////////////////////////////////////////////////////////\r\r
+#undef APSTUDIO_READONLY_SYMBOLS\r\r
+\r\r
+#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU)\r\r
+#ifdef _WIN32\r\r
+LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US\r\r
+#pragma code_page(1252)\r\r
+#endif\r\r
+\r\r
+/////////////////////////////////////////////////////////////////////////////\r\r
+//\r\r
+// Icon\r\r
+//\r\r
+\r\r
+// Icon with lowest ID value placed first to ensure application icon\r\r
+// remains consistent on all systems.\r\r
+IDI_TESTER1       ICON    DISCARDABLE     "tester1.ICO"\r\r
+\r\r
+#ifdef APSTUDIO_INVOKED\r\r
+/////////////////////////////////////////////////////////////////////////////\r\r
+//\r\r
+// TEXTINCLUDE\r\r
+//\r\r
+\r\r
+1 TEXTINCLUDE DISCARDABLE \r\r
+BEGIN\r\r
+    "resource.h\0"\r\r
+END\r\r
+\r\r
+2 TEXTINCLUDE DISCARDABLE \r\r
+BEGIN\r\r
+    "#include ""newres.h""\r\n"\r\r
+    "\0"\r\r
+END\r\r
+\r\r
+3 TEXTINCLUDE DISCARDABLE \r\r
+BEGIN\r\r
+    "\r\n"\r\r
+    "\0"\r\r
+END\r\r
+\r\r
+#endif    // APSTUDIO_INVOKED\r\r
+\r\r
+/////////////////////////////////////////////////////////////////////////////\r\r
+//\r\r
+// Menu\r\r
+//\r\r
+\r\r
+IDM_MENU RCDATA\r\r
+BEGIN\r\r
+    IDM_MENU, 1,\r\r
+    \r\r
+       I_IMAGENONE, IDM_MAIN_COMMAND1, TBSTATE_ENABLED,\r\r
+       TBSTYLE_DROPDOWN | TBSTYLE_AUTOSIZE,\r\r
+       IDS_HELP, 0, 0,\r\r
+\r\r
+END\r\r
+\r\r
+\r\r
+IDM_MENU MENU DISCARDABLE \r\r
+BEGIN\r\r
+    POPUP "Tools"\r\r
+    BEGIN\r\r
+        MENUITEM "About",                       IDM_HELP_ABOUT\r\r
+    END\r\r
+END\r\r
+\r\r
+\r\r
+/////////////////////////////////////////////////////////////////////////////\r\r
+//\r\r
+// Dialog\r\r
+//\r\r
+\r\r
+IDD_ABOUTBOX DIALOGEX 0, 0, 140, 57\r\r
+STYLE WS_POPUP | WS_CAPTION \r\r
+EXSTYLE WS_EX_CAPTIONOKBTN\r\r
+CAPTION "About tester1"\r\r
+FONT 8, "System"\r\r
+\r\r
+BEGIN\r\r
+       ICON            IDI_TESTER1,IDC_STATIC,11,17,20,20\r\r
+       LTEXT           "tester1 Version 1.0",IDC_STATIC,40,10,70,8, SS_NOPREFIX\r\r
+       LTEXT           "Copyright (C) 2003",IDC_STATIC,40,25,70,8\r\r
+END\r\r
+\r\r
+\r\r
+/////////////////////////////////////////////////////////////////////////////\r\r
+//\r\r
+// Accelerator\r\r
+//\r\r
+\r\r
+IDC_TESTER1 ACCELERATORS DISCARDABLE \r\r
+BEGIN\r\r
+    "A",            IDM_HELP_ABOUT,    VIRTKEY, CONTROL, NOINVERT\r\r
+    "Q",            IDOK,                      VIRTKEY, CONTROL, NOINVERT\r\r
+END\r\r
+\r\r
+/////////////////////////////////////////////////////////////////////////////\r\r
+//\r\r
+// DESIGNINFO\r\r
+//\r\r
+\r\r
+#ifdef APSTUDIO_INVOKED\r\r
+GUIDELINES DESIGNINFO DISCARDABLE \r\r
+BEGIN\r\r
+    IDD_ABOUTBOX, DIALOG\r\r
+    BEGIN\r\r
+        LEFTMARGIN, 7\r\r
+        RIGHTMARGIN, 133\r\r
+        TOPMARGIN, 7\r\r
+        BOTTOMMARGIN, 50\r\r
+    END\r\r
+END\r\r
+#endif    // APSTUDIO_INVOKED\r\r
+\r\r
+/////////////////////////////////////////////////////////////////////////////\r\r
+//\r\r
+// String Table\r\r
+//\r\r
+\r\r
+STRINGTABLE DISCARDABLE \r\r
+BEGIN\r\r
+   IDC_TESTER1 "TESTER1"\r\r
+   IDS_APP_TITLE               "tester1"\r\r
+   IDS_HELLO                   "Hello World!"\r\r
+   IDS_HELP                            "Tools"\r\r
+   IDS_COMMAND1                        "Done "\r\r
+END\r\r
+\r\r
+#endif\r\r
+/////////////////////////////////////////////////////////////////////////////\r\r
+\r\r
+\r\r
+\r\r
+#ifndef APSTUDIO_INVOKED\r\r
+/////////////////////////////////////////////////////////////////////////////\r\r
+//\r\r
+// Generated from the TEXTINCLUDE 3 resource.\r\r
+//\r\r
+\r\r
+\r\r
+/////////////////////////////////////////////////////////////////////////////\r\r
+#endif    // not APSTUDIO_INVOKED\r\r
diff --git a/uart.cpp b/uart.cpp
new file mode 100644 (file)
index 0000000..98451fa
--- /dev/null
+++ b/uart.cpp
@@ -0,0 +1,65 @@
+#include "stdafx.h"
+#include "tester1.h"
+#include <commctrl.h>
+//#include <aygshell.h>
+#include <sipapi.h>
+#include "setup.h"
+
+// moved to config.h\r
+//#define FUART 0x40100000
+\r
+
+void UART_puts(char *s)
+{
+       UINT32 *base=(UINT32*)VirtualAlloc((void*)0x0,sizeof(void*)*0xffff, MEM_RESERVE,PAGE_READWRITE);
+       int ret=VirtualCopy(base,(void *) ((UARTBASE)/256),sizeof(void*)*0xffff , PAGE_READWRITE|PAGE_NOCACHE|PAGE_PHYSICAL);
+       int a=0;
+       while(s[a])
+       {
+               while((base[UARTSTATUS/4]&1<<UARTTXRDY) == UARTTXBIT) {}
+               base[UARTDATA/4]=(char)(s[a]);
+               a++;
+       }
+}
+
+void UART_setup()
+{
+       UINT32 *base=(UINT32*)VirtualAlloc((void*)0x0,sizeof(void*)*0xffff, MEM_RESERVE,PAGE_READWRITE);
+       int ret=VirtualCopy(base,(void *) ((UARTBASE)/256),sizeof(void*)*0xffff , PAGE_READWRITE|PAGE_NOCACHE|PAGE_PHYSICAL);
+\r
+#ifdef STRONGARM\r
+// Apparently there is something we don't know. This is needed.\r
+       HANDLE hSerial = CreateFile(L"COM1:", GENERIC_READ | GENERIC_WRITE, FILE_SHARE_READ | FILE_SHARE_WRITE, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, 0);\r
+// disable UART\r
+       base[0x0C/4] = 0;\r
+// clear status\r
+       base[0x1C/4] = 0xFF;\r
+// set 8 bit no parity 1 stopbit\r
+       base[0x00/4] = 9;\r
+// set 115200 bps\r
+       base[0x04/4] = 0;\r
+       base[0x08/4] = 1;\r
+// enable TX/RX\r
+       base[0x0C/4] = 3;\r
+#else
+// set DLAB
+       base[0x0C/4]=128+2+1;
+// set divisor
+       base[0]=8; // 115200 bps
+       base[0x04/4]=0;
+// unset DLAB
+       base[0x0C/4]=2+1;
+// UART enable & no FIFO
+       base[0x04/4]=64;
+       base[0x08/4]=0;
+#endif\r
+
+       char test[]="LinExec: UART Initialized.\n\r";
+       int a=0;
+       while(test[a])
+       {
+               while((base[UARTSTATUS/4]&1<<UARTTXRDY) == UARTTXBIT) {}
+               base[UARTDATA/4]=(char)(test[a]);
+               a++;
+       }
+}
Impressum, Datenschutz