From: michael Date: Sun, 24 Jul 2005 17:24:33 +0000 (+0000) Subject: Initial import of xdadeveloper linexec sources X-Git-Url: https://git.zerfleddert.de/cgi-bin/gitweb.cgi/linexec-j720/commitdiff_plain/77a37381836de85306ad128def744d879c38f95a?ds=sidebyside Initial import of xdadeveloper linexec sources --- 77a37381836de85306ad128def744d879c38f95a diff --git a/Makefile b/Makefile new file mode 100644 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 index 0000000..c25460b --- /dev/null +++ b/Makefile.project @@ -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 index 0000000..c5d3c57 --- /dev/null +++ b/ReadMe.txt @@ -0,0 +1,77 @@ +Linux loader for Pocket PC + + +How to compile: + +1. Two asm files from asm directory has to be compiled with armasm.exe. This will create two +obj files, that should be copied into lib directory(and will be included in the project) +2. Compile & link project + +The c++ source file also contains some routines to read physical memory and to translate virtual mem to phys. +However, the translation is limited and not fully implemented. + +The booting of Linux begins IMMEDIATELLY after program is started. +zImage filename is "image2" (without "") +initrd filename is "initrd" + +If it for some reason freezes try removing pieces of code that write into Frame buffer on Axim +(this fb is beyond limits of physical memory and should not cause problems on IPAQ. adr=0x14042000) + +Limitations: There are some limitations of file sizes. + +If a screen with Hello World appears, there was a problem in booting. Check filenames. + +To make it work for SA11x0 you will have to change these lines in asm.asm: + ldr r5, =0xa0000100 + + ldr r7, =0xa0400000 + +with proper adresses and limits of memory( just change the "a" with "8" I think) +Also KERNELCOPY and INITRD macros have to be changed. + + +author: Demo; cooldemo@inmail.sk + + +================================================================================ + +Amendment by Pigeon: + +linexec has been changed a lot and therefore some stuff in the above readme +might not be true anymore. But anyway, here is how you use linexec: + + +To use linexec, you need 4 files. + +linexec config file: params + +Create a file called "params", and put it under either "\My Documents\", or +"\CF Card\". If you really care where and what this file is called, edit +tester1.cpp and look for load_boot() call. + +This params file specifies three lines of config for: +kernel image +initrd image +kernel args + +For example, my params looks like this: +\My Documents\zimage +\My Documents\initrd.gz +init=/linuxrc keepinitrd root=/dev/rd/0 + + +(This is what I actually have in my params file, but remember this might not +work for your kernel/device) + +(Also a note for the params file, seems that the code is only happy if the +file is in unix format, i.e. newline as \r, but not dos format) + + +And yes, if you see "Hello World", you've got something wrong. + + +Pigeon. + + + + diff --git a/ReadMe.wine b/ReadMe.wine new file mode 100644 index 0000000..32409f5 --- /dev/null +++ b/ReadMe.wine @@ -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 index 0000000..e7b4a61 --- /dev/null +++ b/StdAfx.cpp @@ -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 index 0000000..fbbf3ee --- /dev/null +++ b/StdAfx.h @@ -0,0 +1,49 @@ +// stdafx.h : include file for standard system include files, + +// or project specific include files that are used frequently, but + +// are changed infrequently + +// + + + +#if !defined(AFX_STDAFX_H__E553AB80_24B1_4900_9879_D30DA5DD7F8A__INCLUDED_) + +#define AFX_STDAFX_H__E553AB80_24B1_4900_9879_D30DA5DD7F8A__INCLUDED_ + + + +#if _MSC_VER > 1000 + +#pragma once + +#endif // _MSC_VER > 1000 + + + +#define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers + + + +// Windows Header Files: + +#include + + +// Local Header Files + + + +// TODO: reference additional headers your program requires here + + + +//{{AFX_INSERT_LOCATION}} + +// Microsoft eMbedded Visual C++ will insert additional declarations immediately before the previous line. + + + +#endif // !defined(AFX_STDAFX_H__E553AB80_24B1_4900_9879_D30DA5DD7F8A__INCLUDED_) + diff --git a/WhatsNew.txt b/WhatsNew.txt new file mode 100644 index 0000000..a5e940a --- /dev/null +++ b/WhatsNew.txt @@ -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 index 0000000..a34be6e --- /dev/null +++ b/asm/asm-wince.asm @@ -0,0 +1,99 @@ + TTL C:\pocket\test\asm.cpp + + AREA |.drectve|, DRECTVE + DCB "-defaultlib:coredll.lib " + DCB "-defaultlib:corelibc.lib " + + EXPORT |?do_it@@YAXXZ| ; do_it + AREA |.pdata|, PDATA +|$T222| DCD |?do_it@@YAXXZ| + DCD 0x40000100 + AREA |.text|, CODE +|?do_it@@YAXXZ| PROC ; do_it +|$M220| + + mcr p15, 0, r0, c7, c5, 0 ;/* invalidate i cache & BTB */ + ; CPWAIT r0 + mrc p15, 0, r0, c2, c0, 0 + mov r0, r0 + sub pc, pc, #4 + ; ldr r9, =0xa1300100 + + mov r9, r1 ; add r9, r1, #0x100 + ldr r5, =0xa0000100 ; ldr r5, =0xa0000100 + ldr r7, =0xa0100000 +label ldr r8, [r9] + str r8, [r5] + add r9, r9, #4 + add r5, r5, #4 + cmp r5, r7 + blt label + +crash b crash + + MOV r4, #0xA0000000 + add r2,r4,#0x8000 + + mov r11,r2 + ldr r10,=337 + +; mcr p15, 0, r0, c7, c10, 4 ;/* drain the write buffer*/ + +; CPWAIT r0 +; mrc p15, 0, r0, c2, c0, 0 +; mov r0, r0 +; sub pc, pc, #4 + + + mcr p15, 0, r0, c8, c7, 0x00 ;/* invalidate I+D TLB */ +; CPWAIT r0 + mrc p15, 0, r0, c2, c0, 0 + mov r0, r0 + sub pc, pc, #4 + +; //; they skipped this, unnecessary? seems like we need to do this + mcr p15, 0, r0, c7, c5, 0 ;/* invalidate i cache & BTB */ + +; S bit set, p and d bit set (no 26 bit mode) +; mov r3, #0x120 ; xscale says p needs to be 0 ??? +; mcr p15, 0, r3, c1, c0, 0 ;/* disable the MMU */ + +; CPWAIT r0 +; mrc p15, 0, r0, c2, c0, 0 +; mov r0, r0 +; sub pc, pc, #4 + + +; /*; make sure the pipeline is emptied*/ + mov r0,#0 + mov r0,r0 + mov r0,r0 + mov r0,r0 + +; /* zero PID in Process ID Virtual Address Map register. */ +; mov r0, #0 + mcr p15, 0, r0, c13, c0, 0 + + +; CPWAIT r0 + mrc p15, 0, r0, c2, c0, 0 + mov r0, r0 + sub pc, pc, #4 + +; ldr r5, =0xA00512F5 +; ldr r8, =0xefef0000 +; str r8, [r5] + + + mov r0, #0 + mov r1, r10 + ldr r2, [r2, #0] + mov r2, #0 + mov pc, r11 + + +|$M221| + + ENDP ; |?do_it@@YAXXZ|, do_it + + END diff --git a/asm/asm-wince.asm.bz2 b/asm/asm-wince.asm.bz2 new file mode 100644 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 index 0000000..fa9a15c --- /dev/null +++ b/asm/asm.asm @@ -0,0 +1,103 @@ + TTL C:\pocket\test\asm.cpp + + AREA |.drectve|, DRECTVE + DCB "-defaultlib:coredll.lib " + DCB "-defaultlib:corelibc.lib " + + EXPORT |?do_it@@YAXXZ| ; do_it + AREA |.pdata|, PDATA +|$T222| DCD |?do_it@@YAXXZ| + DCD 0x40000100 + AREA |.text|, CODE +|?do_it@@YAXXZ| PROC ; do_it +|$M220| + + + mcr p15, 0, r0, c7, c5, 0 ;/* invalidate i cache & BTB */ + mrc p15, 0, r0, c2, c0, 0 + mov r0, r0 + sub pc, pc, #4 + + +; turn off LCD controller... +; I couldn't figure out how to use armasm.exe conditional with variables +; #if xscale +; ldr r9, =0x44000000 +; ldr r8, [r9] +; orr r8, r8, #0x400 +; str r8, [r9] + +; #elif strongarm + ldr r9, =0xb0100000 + ldr r8, [r9] + bic r8, r8, #1 + str r8, [r9] + +; turn off unused serial ports + + mov r8, #0 + ldr r9, =0x80010000 + str r8, [r9, #0xC] + ldr r9, =0x80050000 + str r8, [r9, #0xC] + +; #endif + + add r9, r1, #0x100 + +; #if xscale +; ldr r5, =0xa0000100 +; ldr r7, =0xa0400000 + +; #elif strongarm + ldr r5, =0xc0000100 + ldr r7, =0xc0400000 +; #endif + + +label ldr r8, [r9] + str r8, [r5] + add r9, r9, #4 + add r5, r5, #4 + cmp r5, r7 + blt label + +; #if xscale +; MOV r4, #0xA0000000 + +; #elif strongarm + MOV r4, #0xc0000000 +; #endif + + add r11,r4,#0x8000 + + mov r10,r2 ;machine number passed from DRAMloader + + mcr p15, 0, r0, c8, c7, 0x00 ;/* invalidate I+D TLB */ + mrc p15, 0, r0, c2, c0, 0 + mov r0, r0 + sub pc, pc, #4 + +; they skipped this, unnecessary? seems like we need to do this + + mcr p15, 0, r0, c7, c5, 0 ;/* invalidate i cache & BTB */ + + mov r0, #0 + mcr p15, 0, r0, c13, c0, 0 + mrc p15, 0, r0, c2, c0, 0 + mov r0, r0 + sub pc, pc, #4 + + mov r0, #0 + mov r1, r10 + ldr r2, [r2, #0] + mov r2, #0 + +; Jump into the kernel: + mov pc, r11 + + +|$M221| + ENDP ; |?do_it@@YAXXZ|, do_it + END + diff --git a/asm/asm.asm.bz2 b/asm/asm.asm.bz2 new file mode 100644 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 index 0000000..76095e1 --- /dev/null +++ b/asm/asmstuff-wince.asm @@ -0,0 +1,70 @@ + TTL C:\pocket\asmstuff\asmstuff.cpp + + AREA |.drectve|, DRECTVE + DCB "-defaultlib:coredll.lib " + DCB "-defaultlib:corelibc.lib " + + EXPORT |?read_mmu@@YAHXZ| ; read_mmu + AREA |.pdata|, PDATA +|$T229| DCD |?read_mmu@@YAHXZ| + DCD 0x40000200 + AREA |.text|, CODE +|?read_mmu@@YAHXZ| PROC ; read_mmu +|$M227| + mov r0, #0x33 ; 0x33 = 51 + mrc p15, 0, r0, c2, c0, 0 + mov pc, lr +|$M228| + ENDP ; |?read_mmu@@YAHXZ|, read_mmu + + EXPORT |?IntOff@@YAXXZ| ; IntOff + AREA |.pdata|, PDATA +|$T233| DCD |?IntOff@@YAXXZ| + DCD 0x40000100 + AREA |.text|, CODE +|?IntOff@@YAXXZ| PROC ; IntOff +; Line 9 + mrs r4,cpsr + orr r1,r4,#0xef + msr cpsr_c,r1 + mov pc, lr +|$M231| + mov pc, lr +|$M232| + ENDP ; |?IntOff@@YAXXZ|, IntOff + + + EXPORT |?DRAMloader@@YAXI@Z| ; DRAMloader + AREA |.pdata|, PDATA +|$T237| DCD |?DRAMloader@@YAXI@Z| + DCD 0x40000b04 + AREA |.text|, CODE +|?DRAMloader@@YAXI@Z| PROC ; DRAMloader + mov r12, sp + stmdb sp!, {r0} ; stmfd + stmdb sp!, {r12, lr} ; stmfd + sub sp, sp, #4 +|$M235| + ldr r3, [sp, #0xC] ; 0xC = 12 + str r3, [sp] + ldr r1, [sp] + ldr r0, =0x3fff + mcr p15, 0, r0, c7, c10, 4 ; Enable access + mrc p15, 0, r0, c2, c0, 0 + mov r0, r0 + mrc p15, 0, r3, c1, c0, 0 ;/* disable the MMU */ + and r3, r3, #0xfffffffe ; xscale says p needs to be 0 ??? + mov r3, #0x120 + mcr p15, 0, r3, c1, c0, 0 ;/* disable the MMU */ + ; CPWAIT r0 + mrc p15, 0, r0, c2, c0, 0 + mov r0, r0 + + mov pc,r1 ; GO GO GO GO GO + ; can't get here ??? -- jw, 20030517 + add sp, sp, #4 + ldmia sp, {sp, pc} ; ldmfd +|$M236| + ENDP ; |?DRAMloader@@YAXI@Z|, DRAMloader + + 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 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 index 0000000..e737feb --- /dev/null +++ b/asm/asmstuff.asm @@ -0,0 +1,78 @@ + TTL C:\pocket\asmstuff\asmstuff.cpp + + AREA |.drectve|, DRECTVE + DCB "-defaultlib:coredll.lib " + DCB "-defaultlib:corelibc.lib " + + 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| + + mrc p15, 0, r0, c2, c0, 0 + mov pc, lr + +|$M230| + ENDP ; |?read_mmu@@YAHXZ|, read_mmu + + EXPORT |?IntOff@@YAXXZ| ; IntOff + AREA |.pdata|, PDATA +|$T235| DCD |?IntOff@@YAXXZ| + DCD 0x40000100 + AREA |.text|, CODE +|?IntOff@@YAXXZ| PROC ; IntOff +|$M233| + + mrs r4,cpsr + orr r1,r4,#0xef + msr cpsr_c,r1 + mov pc, lr + +|$M234| + ENDP ; |?IntOff@@YAXXZ|, IntOff + + + EXPORT |?DRAMloader@@YAXII@Z| ; DRAMloader + AREA |.pdata|, PDATA +|$T239| DCD |?DRAMloader@@YAXII@Z| + DCD 0x40001004 + AREA |.text|, CODE +|?DRAMloader@@YAXII@Z| PROC ; DRAMloader + + mov r12, sp + stmdb sp!, {r0, r1} ; stmfd + stmdb sp!, {r12, lr} ; stmfd + sub sp, sp, #8 + +|$M237| + + ldr r3, [sp, #0x10] ; 0x10 = 16 + str r3, [sp] + ldr r2, [sp, #0x14] ; 0x14 = 20 + str r2, [sp, #4] + + ldr r1, [sp] ; jump address + ldr r2, [sp, #4] ; machine number + + ldr r0, =0x3fff + mcr p15, 0, r0, c7, c10, 4 ;Enable access + mrc p15, 0, r0, c2, c0, 0 + mov r0, r0 + + mrc p15, 0, r3, c1, c0, 0 ;/* disable the MMU */ + and r3, r3, #0xfffffffe ; xscale says p needs to be 0 ??? + mov r3, #0x120 + 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 + mov pc,r1 ; machine number is in register r2 + +|$M238| + ENDP ; |?DRAMloader@@YAXII@Z|, DRAMloader + END + diff --git a/asm/asmstuff.asm.bz2 b/asm/asmstuff.asm.bz2 new file mode 100644 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 index 0000000..2559552 --- /dev/null +++ b/asm/test123.asm @@ -0,0 +1,7 @@ +loopl ldr r5, =0xA0051000 ; right before we jump in + ldr r6, =0xA0051100 + ldr r8, =0xFE00FE00 + str r8, [r5] + add r5, r5, #0x04 + cmp r5,r6 + blt loopl \ No newline at end of file diff --git a/asm/test123.asm.bz2 b/asm/test123.asm.bz2 new file mode 100644 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 index 0000000..1d3706a --- /dev/null +++ b/boot.cpp @@ -0,0 +1,321 @@ +#include "stdafx.h" +#include "tester1.h" +#include +//#include +#include +#include "setup.h" + + +#define BOOT_LOGO_PATH "\\My Documents\\booting.bmp" +#define BOOT_LOGO_PATH_CF "\\CF Card\\booting.bmp" +#define BOOT_LOGO_DONE_PATH "\\My Documents\\done.bmp" +#define BOOT_LOGO_DONE_PATH_CF "\\CF Card\\done.bmp" +#define DONE1_X 100 +#define DONE1_Y 100 +#define DONE2_X 100 +#define DONE2_Y 130 + + +void setup_linux_params(long bootimg_dest, UINT32 initrd,UINT32 initrdl, long dram_size, const char *cmdline, char*base) +{ + int rootdev = 0x00ff; + struct tag *tag; + int newcmdlinelen = 0; + char *newcmdline = NULL; + + + tag = (struct tag *)(base+0x100); + + tag->hdr.tag = ATAG_CORE; + tag->hdr.size = tag_size(tag_core); + tag->u.core.flags =0; + tag->u.core.pagesize = 0x00001000; + tag->u.core.rootdev = rootdev; + tag = tag_next(tag); + + // now the cmdline tag + tag->hdr.tag = ATAG_CMDLINE; + // must be at least +3!! 1 for the null and 2 for the ??? + tag->hdr.size = (strlen(cmdline) + 3 + sizeof(struct tag_header)) >> 2; + //tag->hdr.size = (strlen(cmdline) + 10 + sizeof(struct tag_header)) >> 2; + strcpy(tag->u.cmdline.cmdline,cmdline); + tag = tag_next(tag); + + + // now the mem32 tag + tag->hdr.tag = ATAG_MEM; + tag->hdr.size = tag_size(tag_mem32); + tag->u.mem.size = dram_size; + tag->u.mem.start = MEM_START; + tag = tag_next(tag); + + + /* and now the initrd tag */ + if (initrdl) { + tag->hdr.tag = INITRD_TAG; + tag->hdr.size = tag_size(tag_initrd); + tag->u.initrd.start = initrd; + tag->u.initrd.size = initrdl; + tag = tag_next(tag); + } + + tag->hdr.tag = ATAG_VIDEOTEXT; + tag->hdr.size = tag_size(tag_videotext); + tag->u.videotext.video_lines = 40; + tag->u.videotext.video_cols = 30; + tag = tag_next(tag); + + // now the NULL tag + tag->hdr.tag = ATAG_NONE; + tag->hdr.size = 0; +} + + + + + +/* loading process: +function do_it is loaded onto address KERNELCOPY along with parameters(offset=0x100) and +kernel image(offset=0x8000). Afterwards DRAMloader is called; it disables MMU and +jumps onto KERNELCOPY. Function do_it then copies kernel image to its proper address(0xA0008000) +and calls it. +Initrd is loaded onto address INITRD and the address is passed to kernel via ATAG +*/ + + +// This resets some devices +void ResetDevices() +{ +#ifndef STRONGARM + WritePhysical(0x4050000C,0); // Reset AC97 + WritePhysical(0x48000014,0); // Reset PCMCIA + for(int i=0;i<0x3C;i+=4) + WritePhysical(0x40000000,8); // Set DMAs to Stop state + WritePhysical(0x400000F0,0); // DMA do not gen interrupt + SetGPIOio(28,0); // AC97 + SetGPIOio(29,0); // AC97/I2S + SetGPIOio(30,0); // I2S/AC97 + SetGPIOio(31,0); // I2S/AC97 + SetGPIOio(32,0); // AC97/I2S + SetGPIOalt(28,0); + SetGPIOalt(29,0); + SetGPIOalt(30,0); + SetGPIOalt(31,0); + SetGPIOalt(32,0); +#endif +} + + + + +void mymemcpy(char* a, char* b, int size); + +void boot_linux(char *filename,char* initrd,char *param) +{ + FILE *fd=fopen(filename,"rb"); + int ret; + + FILE* fd1; + + long initrdl; + long len; + +#ifndef STRONGARM + Image image; + Image image_done; +#endif + + + + if(!fd) + { + FILE *logfd=fopen("\\bootlog.txt","a"); + fprintf(logfd, "Booting: ***FAILED TO OPEN %s***\n",filename); + fclose(logfd); + return; + } + + fseek(fd,0,SEEK_END); + len=ftell(fd); + fseek(fd,0,SEEK_SET); + + fd1=fopen(initrd,"rb"); + initrdl=0; + if(fd1) + { + fseek(fd1,0,SEEK_END); + initrdl=ftell(fd1); + fseek(fd1,0,SEEK_SET); + } + FILE *logfd=fopen("\\bootlog.txt","a"); + fprintf(logfd, "Booting: Images."); + fclose(logfd); + + +#ifndef STRONGARM + /* i haven't ported this to strongarm, hope this is not important to + * anyone */ + init_fb(); + try_fb(); + + image=ReadBMP(BOOT_LOGO_PATH); + if (!image.p) image=ReadBMP(BOOT_LOGO_PATH_CF); + image_done=ReadBMP(BOOT_LOGO_DONE_PATH); + if (!image_done.p) image_done = ReadBMP(BOOT_LOGO_DONE_PATH_CF); + if (image.p) ShowImage(image.p,image.x,image.y); +#endif + + logfd=fopen("\\bootlog.txt","a"); + fprintf(logfd, "Booting: entering supervisor mode."); + fclose(logfd); + + /* now becoming supervisor. */ + SetThreadPriority(GetCurrentThread(),THREAD_PRIORITY_TIME_CRITICAL); +// CeSetThreadQuantum(GetCurrentThread(),0); + SetKMode(1); + SetProcPermissions(0xffffffff); + /* rooooooooot has landed! */ + + logfd=fopen("\\bootlog.txt","a"); + fprintf(logfd, "Booting: supervisor mode."); + fclose(logfd); + + void *mmu=(void*)read_mmu(); + UINT32 *data=NULL,*lcd=NULL,*intr=NULL,*_mmu=NULL; + char *watch=NULL,*krnl=NULL; + + + IntOff(); + + + char *kernel_copy2=(char*)VirtualAlloc((void*)0x0,0x8000+len, MEM_RESERVE|MEM_TOP_DOWN,PAGE_READWRITE); + ret=VirtualCopy((void*)kernel_copy2,(void *) (KERNELCOPY/256), 0x8000+len, PAGE_READWRITE|PAGE_NOCACHE|PAGE_PHYSICAL); + + char *initrd_copy2; + + + if(fd1) + { + initrd_copy2=(char*)VirtualAlloc((void*)0x0,initrdl, MEM_RESERVE|MEM_TOP_DOWN,PAGE_READWRITE); + ret=VirtualCopy((void*)initrd_copy2,(void *) (INITRD/256), initrdl, PAGE_READWRITE|PAGE_NOCACHE|PAGE_PHYSICAL); + } + + void(*relmemcpy)(char*,char*,int); + relmemcpy=(void (__cdecl *)(char *,char *,int))VirtualAlloc((void*)0x0, 1024, MEM_RESERVE|MEM_TOP_DOWN,PAGE_READWRITE); + + /* ask joshua */ +#ifndef STRONGARM + ret=VirtualCopy((void*)relmemcpy,(void *) (0xa0001000/256), 1024, PAGE_READWRITE|PAGE_NOCACHE|PAGE_PHYSICAL); +#else + ret=VirtualCopy((void*)relmemcpy,(void *) (0xc0001000/256), 1024, PAGE_READWRITE|PAGE_NOCACHE|PAGE_PHYSICAL); +#endif + + if(!kernel_copy2) return; + + + UINT32 phys_addr; + phys_addr=KERNELCOPY; + + + char *data1,*data2; + + data1=(char*)malloc(len); + + char *initrd1=NULL; + + if(fd1) initrd1=(char*)malloc(initrdl); + + if(!data1) return; + + if(!ret) return; + + data2= (char*)do_it; + + + fread(data1,len,1,fd); + fclose(fd); + + + if(fd1) + { + fread(initrd1,initrdl,1,fd1); + fclose(fd1); + } + + // Do not block interrupts before they are needed anymore + // Like reading the SD card. + intr=(UINT32*)VirtualAlloc((void*)0x0,0x100, MEM_RESERVE,PAGE_READWRITE); + + // Interrupt control registers + ret=VirtualCopy((void*)intr,(void *) (ICIP/256), 0x100, PAGE_READWRITE|PAGE_NOCACHE|PAGE_PHYSICAL); + + intr[1]=0; + +// ResetDevices(); + + UART_puts("LinExec: Passing the point of no return.. Now.\r\n"); + + UINT32 crc=0; + + setup_linux_params(BOOTIMG, INITRD,initrdl, MEM_SIZE*1024*1024 , param,kernel_copy2); + + memcpy(relmemcpy,mymemcpy,1024); + relmemcpy(kernel_copy2,data2,0x100); + + if(fd1) + relmemcpy(initrd_copy2,initrd1,initrdl); + + relmemcpy(kernel_copy2+0x8000,data1,len); + + UART_puts("LinExec: Entering DRAMloader...\r\n"); + + DRAMloader(phys_addr, MACH_TYPE); +} + +void mymemcpy(char* a, char* b, int size) +{ + while (size) + { + *a=*b; + size--; + a++; b++; + }; +}; + +/* + Loads parameters from file given. + The file has to be: + kernel image + initrd + kernel cmdline +*/ + +void load_boot(char *ParamFile) +{ + FILE *stream; + + UART_setup(); + + stream=fopen(ParamFile,"r"); + if(!stream) { + FILE *logfd=fopen("\\bootlog.txt","a"); + fprintf(logfd, "Booting: ***FAILED TO OPEN %s***\n",ParamFile); + fclose(logfd); + return; + } + char cmd[200],image[50],initrd[50]; + + fgets(image,50,stream); + image[strlen(image)-1]=0; // remove \n from the end + + fgets(initrd,50,stream); + initrd[strlen(initrd)-1]=0; + + fgets(cmd,200,stream); + cmd[strlen(cmd)-1]=0; + + fclose(stream); + + UART_puts("LinExec: Beginning boot_linux.\r\n"); + boot_linux(image,initrd,cmd); +} diff --git a/booting.bmp b/booting.bmp new file mode 100644 index 0000000..ec4c57a Binary files /dev/null and b/booting.bmp differ diff --git a/config.h b/config.h new file mode 100644 index 0000000..e2f6029 --- /dev/null +++ b/config.h @@ -0,0 +1,72 @@ +#define STRONGARM 1 + +#ifndef STRONGARM + +/* xscale */ + +#define MEM_START 0xa0000000 + +/* Memory in MByte */ +#define MEM_SIZE 64 + +#define KERNELCOPY 0xa0a00000 +//#define KERNELCOPY 0xa0800000 + +#define INITRD 0xa0d00000 +#define INITRD_TAG ATAG_INITRD2 + +/* Interrupt controller */ +#define ICIP 0x40D00000 + +#define UARTBASE 0x40100000 +#define UARTDATA 0x00 +#define UARTSTATUS 0x14 +#define UARTTXRDY 5 +#define UARTTXBIT 0 + +/* Not used */ +#define BOOTIMG 0xa0008000 + +/* MACH_TYPE_H1900 */ +#define MACH_TYPE_JORNADA720 48 +#define MACH_TYPE 48 + +#else + +/* strongarm */ + +#define MEM_START 0xc0000000 + +/* Memory in MByte */ +#define MEM_SIZE 32 + +#define KERNELCOPY 0xc0a00000 + +#define INITRD 0xc0d00000 +#define INITRD_TAG ATAG_INITRD + +/* Interrupt controller */ +#define ICIP 0x90050000 + +#define UARTBASE 0x80030000 +#define UARTDATA 0x14 +#define UARTSTATUS 0x20 +#define UARTTXRDY 2 +#define UARTTXBIT 0 + +/* Not used */ +#define BOOTIMG 0xc0008000 + +/* MACH_TYPE_H3600 */ +//#define MACH_TYPE 22 + +/* MACH_TYPE_H3800 */ +//#define MACH_TYPE 137 + +/* MACH_TYPE_XDA */ +#define MACH_TYPE_JORNADA720 48 +#define MACH_TYPE 48 + +#endif + + diff --git a/gpio.cpp b/gpio.cpp new file mode 100644 index 0000000..d1d6f65 --- /dev/null +++ b/gpio.cpp @@ -0,0 +1,119 @@ +#include "stdafx.h" +#include "tester1.h" +#include +//#include +#include +#include "setup.h" + +#define GPIO 0x40E00000 +#define GPIO_MEDIAQ 0x14040000 +#define MQ_OFF 0x008 + +int GPIOalt[81],GPIOio[81],GPIOst[81],mediaq; + +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 index 0000000..9a63a0c --- /dev/null +++ b/graphics.cpp @@ -0,0 +1,101 @@ +#include "stdafx.h" +#include "tester1.h" +#include +//#include +#include +#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 + +
+

Build Log

+

+--------------------Configuration: linexec - Win32 (WCE ARM) Release-------------------- +

+

Command Lines

+Creating temporary file "C:\DOCUME~1\YUUSEI~1\LOCALS~1\Temp\RSP3.tmp" with contents +[ +/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 +"E:\Windows CE Tools\linexec-xda-1.0\boot.cpp" +"E:\Windows CE Tools\linexec-xda-1.0\gpio.cpp" +"E:\Windows CE Tools\linexec-xda-1.0\graphics.cpp" +"E:\Windows CE Tools\linexec-xda-1.0\memory.cpp" +"E:\Windows CE Tools\linexec-xda-1.0\tester1.cpp" +"E:\Windows CE Tools\linexec-xda-1.0\uart.cpp" +] +Creating command line "clarm.exe @C:\DOCUME~1\YUUSEI~1\LOCALS~1\Temp\RSP3.tmp" +Creating temporary file "C:\DOCUME~1\YUUSEI~1\LOCALS~1\Temp\RSP4.tmp" with contents +[ +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 +".\ARMRel\boot.obj" +".\ARMRel\gpio.obj" +".\ARMRel\graphics.obj" +".\ARMRel\memory.obj" +".\ARMRel\StdAfx.obj" +".\ARMRel\tester1.obj" +".\ARMRel\uart.obj" +".\ARMRel\tester1.res" +".\ARMRel\asm.obj" +".\ARMRel\asmstuff.obj" +] +Creating command line "link.exe @C:\DOCUME~1\YUUSEI~1\LOCALS~1\Temp\RSP4.tmp" +

Output Window

+Compiling... +boot.cpp +gpio.cpp +graphics.cpp +memory.cpp +tester1.cpp +uart.cpp +Generating Code... +Linking... + + + +

Results

+linexec.exe - 0 error(s), 0 warning(s) +
+ + diff --git a/linexec.vco b/linexec.vco new file mode 100644 index 0000000..569b44c Binary files /dev/null and b/linexec.vco differ diff --git a/linexec.vcp b/linexec.vcp new file mode 100644 index 0000000..ebaa96d --- /dev/null +++ b/linexec.vcp @@ -0,0 +1,278 @@ +# Microsoft eMbedded Visual Tools Project File - Name="linexec" - Package Owner=<4> +# Microsoft eMbedded Visual Tools Generated Build File, Format Version 6.02 +# ** DO NOT EDIT ** + +# TARGTYPE "Win32 (WCE ARM) Application" 0x8501 + +CFG=linexec - Win32 (WCE ARM) Debug +!MESSAGE This is not a valid makefile. To build this project using NMAKE, +!MESSAGE use the Export Makefile command and run +!MESSAGE +!MESSAGE NMAKE /f "linexec.vcn". +!MESSAGE +!MESSAGE You can specify a configuration when running NMAKE +!MESSAGE by defining the macro CFG on the command line. For example: +!MESSAGE +!MESSAGE NMAKE /f "linexec.vcn" CFG="linexec - Win32 (WCE ARM) Debug" +!MESSAGE +!MESSAGE Possible choices for configuration are: +!MESSAGE +!MESSAGE "linexec - Win32 (WCE ARM) Release" (based on "Win32 (WCE ARM) Application") +!MESSAGE "linexec - Win32 (WCE ARM) Debug" (based on "Win32 (WCE ARM) Application") +!MESSAGE + +# Begin Project +# PROP AllowPerConfigDependencies 0 +# PROP Scc_ProjName "linexec" +# PROP Scc_LocalPath "." +# PROP ATL_Project 2 +CPP=clarm.exe +MTL=midl.exe +RSC=rc.exe + +!IF "$(CFG)" == "linexec - Win32 (WCE ARM) Release" + +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 0 +# PROP BASE Output_Dir "ARMRel" +# PROP BASE Intermediate_Dir "ARMRel" +# PROP BASE CPU_ID "{D6518FFC-710F-11D3-99F2-00105A0DF099}" +# PROP BASE Platform_ID "{8A9A2F80-6887-11D3-842E-005004848CBA}" +# PROP BASE Target_Dir "" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 0 +# PROP Output_Dir "ARMRel" +# PROP Intermediate_Dir "ARMRel" +# PROP CPU_ID "{D6518FFC-710F-11D3-99F2-00105A0DF099}" +# PROP Platform_ID "{8A9A2F80-6887-11D3-842E-005004848CBA}" +# PROP Ignore_Export_Lib 0 +# PROP Target_Dir "" +# 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 +# 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 +# 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 +# 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 +# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /o "NUL" /win32 +# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /o "NUL" /win32 +BSC32=bscmake.exe +# ADD BASE BSC32 /nologo +# ADD BSC32 /nologo +LINK32=link.exe +# 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 +# ADD LINK32 commctrl.lib coredll.lib /nologo /base:"0x00010000" /stack:0x10000,0x1000 /entry:"WinMainCRTStartup" /nodefaultlib:"$(CENoDefaultLib)" /subsystem:$(CESubsystem) /align:"4096" /MACHINE:ARM + +!ELSEIF "$(CFG)" == "linexec - Win32 (WCE ARM) Debug" + +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 1 +# PROP BASE Output_Dir "ARMDbg" +# PROP BASE Intermediate_Dir "ARMDbg" +# PROP BASE CPU_ID "{D6518FFC-710F-11D3-99F2-00105A0DF099}" +# PROP BASE Platform_ID "{8A9A2F80-6887-11D3-842E-005004848CBA}" +# PROP BASE Target_Dir "" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 1 +# PROP Output_Dir "ARMDbg" +# PROP Intermediate_Dir "ARMDbg" +# PROP CPU_ID "{D6518FFC-710F-11D3-99F2-00105A0DF099}" +# PROP Platform_ID "{8A9A2F80-6887-11D3-842E-005004848CBA}" +# PROP Ignore_Export_Lib 0 +# PROP Target_Dir "" +# 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 +# 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 +# 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 +# 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 +# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /o "NUL" /win32 +# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /o "NUL" /win32 +BSC32=bscmake.exe +# ADD BASE BSC32 /nologo +# ADD BSC32 /nologo +LINK32=link.exe +# 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 +# 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 + +!ENDIF + +# Begin Target + +# Name "linexec - Win32 (WCE ARM) Release" +# Name "linexec - Win32 (WCE ARM) Debug" +# Begin Group "Source Files" + +# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat" +# Begin Source File + +SOURCE=.\asm\asm.asm + +!IF "$(CFG)" == "linexec - Win32 (WCE ARM) Release" + +# Begin Custom Build +OutDir=.\ARMRel +InputPath=.\asm\asm.asm + +"$(OUTDIR)\asm.obj" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)" + armasm.exe $(InputPath) $(OUTDIR)\asm.obj + +# End Custom Build + +!ELSEIF "$(CFG)" == "linexec - Win32 (WCE ARM) Debug" + +# Begin Custom Build +IntDir=.\ARMDbg +InputPath=.\asm\asm.asm +InputName=asm + +"$(IntDir)\$(InputName).obj" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)" + armasm -I $(InputPath) -list $(IntDir)\$(InputName).lst -CPU StrongARM1 -o $(IntDir)\$(InputName).obj .\asm\$(InputName).asm + +# End Custom Build + +!ENDIF + +# End Source File +# Begin Source File + +SOURCE=.\asm\asmstuff.asm + +!IF "$(CFG)" == "linexec - Win32 (WCE ARM) Release" + +# Begin Custom Build +OutDir=.\ARMRel +InputPath=.\asm\asmstuff.asm + +"$(OUTDIR)\asmstuff.obj" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)" + armasm.exe $(InputPath) $(OUTDIR)\asmstuff.obj + +# End Custom Build + +!ELSEIF "$(CFG)" == "linexec - Win32 (WCE ARM) Debug" + +# Begin Custom Build +IntDir=.\ARMDbg +InputPath=.\asm\asmstuff.asm +InputName=asmstuff + +"$(IntDir)\$(InputName).obj" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)" + armasm -I $(InputPath) -list $(IntDir)\$(InputName).lst -CPU StrongARM1 -o $(IntDir)\$(InputName).obj .\asm\$(InputName).asm + +# End Custom Build + +!ENDIF + +# End Source File +# Begin Source File + +SOURCE=.\boot.cpp +DEP_CPP_BOOT_=\ + ".\config.h"\ + ".\setup.h"\ + ".\StdAfx.h"\ + ".\tester1.h"\ + {$(INCLUDE)}"sipapi.h"\ + +# End Source File +# Begin Source File + +SOURCE=.\gpio.cpp +DEP_CPP_GPIO_=\ + ".\config.h"\ + ".\setup.h"\ + ".\StdAfx.h"\ + ".\tester1.h"\ + {$(INCLUDE)}"sipapi.h"\ + +# End Source File +# Begin Source File + +SOURCE=.\graphics.cpp +DEP_CPP_GRAPH=\ + ".\config.h"\ + ".\setup.h"\ + ".\StdAfx.h"\ + ".\tester1.h"\ + {$(INCLUDE)}"sipapi.h"\ + +# End Source File +# Begin Source File + +SOURCE=.\memory.cpp +DEP_CPP_MEMOR=\ + ".\config.h"\ + ".\setup.h"\ + ".\StdAfx.h"\ + ".\tester1.h"\ + {$(INCLUDE)}"sipapi.h"\ + +# End Source File +# Begin Source File + +SOURCE=.\StdAfx.cpp +DEP_CPP_STDAF=\ + ".\StdAfx.h"\ + +# ADD CPP /Yc"stdafx.h" +# End Source File +# Begin Source File + +SOURCE=.\tester1.cpp +DEP_CPP_TESTE=\ + ".\config.h"\ + ".\setup.h"\ + ".\StdAfx.h"\ + ".\tester1.h"\ + {$(INCLUDE)}"sipapi.h"\ + +# End Source File +# Begin Source File + +SOURCE=.\tester1.rc +# End Source File +# Begin Source File + +SOURCE=.\uart.cpp +DEP_CPP_UART_=\ + ".\config.h"\ + ".\setup.h"\ + ".\StdAfx.h"\ + ".\tester1.h"\ + {$(INCLUDE)}"sipapi.h"\ + +# End Source File +# End Group +# Begin Group "Header Files" + +# PROP Default_Filter "h;hpp;hxx;hm;inl" +# Begin Source File + +SOURCE=.\config.h +# End Source File +# Begin Source File + +SOURCE=.\newres.h +# End Source File +# Begin Source File + +SOURCE=.\resource.h +# End Source File +# Begin Source File + +SOURCE=.\StdAfx.h +# End Source File +# Begin Source File + +SOURCE=.\tester1.h +# End Source File +# End Group +# Begin Group "Resource Files" + +# PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe" +# Begin Source File + +SOURCE=.\tester1.ico +# End Source File +# End Group +# Begin Source File + +SOURCE=.\ReadMe.txt +# End Source File +# End Target +# End Project diff --git a/linexec.vcw b/linexec.vcw new file mode 100644 index 0000000..28bb66c --- /dev/null +++ b/linexec.vcw @@ -0,0 +1,32 @@ +Microsoft eMbedded Visual Tools Workspace File, Format Version 3.00 +# WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE! + +############################################################################### + +Project: "linexec"=.\linexec.vcp - Package Owner=<4> + +Package=<5> +{{{ + begin source code control + tester1 + . + end source code control +}}} + +Package=<4> +{{{ +}}} + +############################################################################### + +Global: + +Package=<5> +{{{ +}}} + +Package=<3> +{{{ +}}} + +############################################################################### \ No newline at end of file diff --git a/memory.cpp b/memory.cpp new file mode 100644 index 0000000..96ff433 --- /dev/null +++ b/memory.cpp @@ -0,0 +1,106 @@ +#include "stdafx.h" +#include "tester1.h" +#include +//#include +#include +#include "setup.h" + +UINT32 ReadPhysical(UINT32 adr) +{ + UINT32 base= adr&0xffff0000; + UINT32 offset=adr&0x0000ffff; + UINT32 *p=(UINT32*)VirtualAlloc(0,0x10000,MEM_RESERVE,PAGE_READWRITE); + if(!p) return 0xFFFFFFFF; + if(!VirtualCopy((void*)p,(void*)(base/256),0x10000,PAGE_READWRITE|PAGE_NOCACHE|PAGE_PHYSICAL)) return 0xFFFFFFFF; + UINT32 val=p[offset/4]; + VirtualFree(p,0,MEM_RELEASE); + return val; +} + +void WritePhysical(UINT32 adr,UINT32 val) +{ + UINT32 base= adr&0xffff0000; + UINT32 offset=adr&0x0000ffff; + UINT32 *p=(UINT32*)VirtualAlloc(0,0x10000,MEM_RESERVE,PAGE_READWRITE); + VirtualCopy((void*)p,(void*)(base/256),0x10000,PAGE_READWRITE|PAGE_NOCACHE|PAGE_PHYSICAL); + p[offset/4]=val; + VirtualFree(p,0,MEM_RELEASE); +} + +UINT32 VirtualToPhysical(UINT32 Virtual) +{ + FILE *log=fopen("\\logger1.txt","w"); + + fprintf(log,"virtual: 0x%lx\n",Virtual); + UINT32 mmu=(UINT32)read_mmu(); +// mmu=0xa0000000; + fprintf(log,"mmu: 0x%lx \n",mmu); + + UINT32 AdrFirstLevDesc=(mmu&0xffffc000)+((Virtual>>18)&0xfffffffc); + fprintf(log,"AdrFirstLevDesc: 0x%lx \n",AdrFirstLevDesc); + + UINT32 FirstLevDesc=ReadPhysical(AdrFirstLevDesc); + fprintf(log,"FirstLevDesc: 0x%lx \n",FirstLevDesc); + + + if(0) + { + fprintf(log,"Page\n"); + UINT32 PhysAddr=(FirstLevDesc&0xfff00000)+(Virtual&0xfffff); + fprintf(log,"Physical address: 0x%lx \n",PhysAddr); + fclose(log); + return PhysAddr; + } + + if(FirstLevDesc&0x3==3) // tiny page + { + fprintf(log,"Tiny page\n"); + UINT32 AdrSecondLevDesc=(FirstLevDesc&0xfffff000)+((Virtual>>8)&0xffc); + fprintf(log,"AdrSecondLevDesc: 0x%lx \n",AdrSecondLevDesc); + + UINT32 SecondLevDesc=ReadPhysical(AdrSecondLevDesc); + fprintf(log,"SecondLevDesc: 0x%lx \n",SecondLevDesc); + + UINT32 PhysAddr=(SecondLevDesc&0xffffc000)+(Virtual&0x3ff); + fprintf(log,"Physical address: 0x%lx \n",PhysAddr); + fclose(log); + return PhysAddr; + } +// if(FirstLevDesc&0x3==3) // small page + { + fprintf(log,"Else page\n"); + UINT32 AdrSecondLevDesc=(FirstLevDesc&0xfffffc00)+((Virtual>>10)&0x03fc); + fprintf(log,"AdrSecondLevDesc: 0x%lx \n",AdrSecondLevDesc); + + UINT32 SecondLevDesc=ReadPhysical(AdrSecondLevDesc); + fprintf(log,"SecondLevDesc: 0x%lx \n",SecondLevDesc); + + UINT32 PhysAddr=(SecondLevDesc&0xffff0000)+(Virtual&0xffff); + fprintf(log,"Physical address: 0x%lx \n",PhysAddr); + fclose(log); + return PhysAddr; + + } +} + + + + + + +void DumpMMU() +{ + void *mmu=(void*)(MEM_START); + + UINT32 *_mmu=(UINT32*)VirtualAlloc((void*)0x0,sizeof(void*)*0xffff, MEM_RESERVE,PAGE_READWRITE); + int ret=VirtualCopy(_mmu,(void *) ((UINT32)mmu/256),sizeof(void*)*0xffff , PAGE_READWRITE|PAGE_NOCACHE|PAGE_PHYSICAL); + + FILE *log=fopen("\\logger2.txt","w"); + fprintf(log,"mmu_table=0x%lx : \n",_mmu); + fprintf(log,"mmu=0x%lx : \n",mmu); + fprintf(log,"ret=0x%x : \n",ret); + for(UINT32 z=0;z<=0x0100;z++) + fprintf(log,"mmu_table[0x%x]=0x%lx: \n",z,_mmu[z]); + fclose(log); + return; +} diff --git a/newres.h b/newres.h new file mode 100644 index 0000000..e6e2a53 --- /dev/null +++ b/newres.h @@ -0,0 +1,41 @@ +#ifndef __NEWRES_H__ +#define __NEWRES_H__ + +#if !defined(UNDER_CE) +#define UNDER_CE _WIN32_WCE +#endif + +#if defined(_WIN32_WCE) + #if !defined(WCEOLE_ENABLE_DIALOGEX) + #define DIALOGEX DIALOG DISCARDABLE + #endif + #include + #define SHMENUBAR RCDATA + #if defined(WIN32_PLATFORM_PSPC) && (_WIN32_WCE >= 300) + #include + #define AFXCE_IDR_SCRATCH_SHMENU 28700 + #else + #define I_IMAGENONE (-2) + #define NOMENU 0xFFFF + #define IDS_SHNEW 1 + + #define IDM_SHAREDNEW 10 + #define IDM_SHAREDNEWDEFAULT 11 + #endif // _WIN32_WCE_PSPC + #define AFXCE_IDD_SAVEMODIFIEDDLG 28701 +#endif // _WIN32_WCE + +#ifdef RC_INVOKED +#ifndef _INC_WINDOWS +#define _INC_WINDOWS + #include "winuser.h" // extract from windows header + #include "winver.h" +#endif +#endif + +#ifdef IDC_STATIC +#undef IDC_STATIC +#endif +#define IDC_STATIC (-1) + +#endif //__NEWRES_H__ diff --git a/resource.h b/resource.h new file mode 100644 index 0000000..635cd99 --- /dev/null +++ b/resource.h @@ -0,0 +1,27 @@ +//{{NO_DEPENDENCIES}} +// Microsoft eMbedded Visual C++ generated include file. +// Used by TESTER1.RC +// +#define IDS_APP_TITLE 1 +#define IDS_HELLO 2 +#define IDC_TESTER1 3 +#define IDI_TESTER1 101 +#define IDM_MENU 102 +#define IDD_ABOUTBOX 103 +#define IDS_HELP 104 + +#define IDS_COMMAND1 301 + +#define IDM_MAIN_COMMAND1 40001 +#define IDM_HELP_ABOUT 40003 + +// Next default values for new objects +// +#ifdef APSTUDIO_INVOKED +#ifndef APSTUDIO_READONLY_SYMBOLS +#define _APS_NEXT_RESOURCE_VALUE 104 +#define _APS_NEXT_COMMAND_VALUE 40004 +#define _APS_NEXT_CONTROL_VALUE 1001 +#define _APS_NEXT_SYMED_VALUE 101 +#endif +#endif diff --git a/setup.h b/setup.h new file mode 100644 index 0000000..1bc06c8 --- /dev/null +++ b/setup.h @@ -0,0 +1,278 @@ +/* + * linux/include/asm/setup.h + * + * Copyright (C) 1997-1999 Russell King + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + * + * Structure passed to kernel to tell it about the + * hardware it's running on. See linux/Documentation/arm/Setup + * for more info. + * + * NOTE: + * This file contains two ways to pass information from the boot + * loader to the kernel. The old struct param_struct is deprecated, + * but it will be kept in the kernel for 5 years from now + * (2001). This will allow boot loaders to convert to the new struct + * tag way. + */ +#ifndef __ASMARM_SETUP_H +#define __ASMARM_SETUP_H + +#define u32 UINT32 +#define u16 UINT16 +#define u8 UINT8 + + +/*#ifndef CONFIG_ACCEPT_GPL +#error This file covered by GPL but CONFIG_ACCEPT_GPL undefined. +#endif*/ + +/* + * Usage: + * - do not go blindly adding fields, add them at the end + * - when adding fields, don't rely on the address until + * a patch from me has been released + * - unused fields should be zero (for future expansion) + * - this structure is relatively short-lived - only + * guaranteed to contain useful data in setup_arch() + */ +#define COMMAND_LINE_SIZE 1024 + +/* This is the old deprecated way to pass parameters to the kernel */ +struct param_struct { + union { + struct { + unsigned long page_size; /* 0 */ + unsigned long nr_pages; /* 4 */ + unsigned long ramdisk_size; /* 8 */ + unsigned long flags; /* 12 */ +#define FLAG_READONLY 1 +#define FLAG_RDLOAD 4 +#define FLAG_RDPROMPT 8 + unsigned long rootdev; /* 16 */ + unsigned long video_num_cols; /* 20 */ + unsigned long video_num_rows; /* 24 */ + unsigned long video_x; /* 28 */ + unsigned long video_y; /* 32 */ + unsigned long memc_control_reg; /* 36 */ + unsigned char sounddefault; /* 40 */ + unsigned char adfsdrives; /* 41 */ + unsigned char bytes_per_char_h; /* 42 */ + unsigned char bytes_per_char_v; /* 43 */ + unsigned long pages_in_bank[4]; /* 44 */ + unsigned long pages_in_vram; /* 60 */ + unsigned long initrd_start; /* 64 */ + unsigned long initrd_size; /* 68 */ + unsigned long rd_start; /* 72 */ + unsigned long system_rev; /* 76 */ + unsigned long system_serial_low; /* 80 */ + unsigned long system_serial_high; /* 84 */ + unsigned long mem_fclk_21285; /* 88 */ + } s; + char unused[256]; + } u1; + union { + char paths[8][128]; + struct { + unsigned long magic; + char n[1024 - sizeof(unsigned long)]; + } s; + } u2; + char commandline[COMMAND_LINE_SIZE]; +}; + + + +/* + * The new way of passing information: a list of tagged entries + */ + +/* The list ends with an ATAG_NONE node. */ +#define ATAG_NONE 0x00000000 + +struct tag_header { + u32 size; + u32 tag; +}; + +/* The list must start with an ATAG_CORE node */ +#define ATAG_CORE 0x54410001 + +struct tag_core { + u32 flags; /* bit 0 = read-only */ + u32 pagesize; + u32 rootdev; +}; + +/* it is allowed to have multiple ATAG_MEM nodes */ +#define ATAG_MEM 0x54410002 + +struct tag_mem32 { + u32 size; + u32 start; /* physical start address */ +}; + +/* VGA text type displays */ +#define ATAG_VIDEOTEXT 0x54410003 + +struct tag_videotext { + u8 x; + u8 y; + u16 video_page; + u8 video_mode; + u8 video_cols; + u16 video_ega_bx; + u8 video_lines; + u8 video_isvga; + u16 video_points; +}; + +/* describes how the ramdisk will be used in kernel */ +#define ATAG_RAMDISK 0x54410004 + +struct tag_ramdisk { + u32 flags; /* bit 0 = load, bit 1 = prompt */ + u32 size; /* decompressed ramdisk size in _kilo_ bytes */ + u32 start; /* starting block of floppy-based RAM disk image */ +}; + +/* describes where the compressed ramdisk image lives */ +#define ATAG_INITRD 0x54410005 + +#define ATAG_INITRD2 0x54420005 + +struct tag_initrd { + u32 start; /* physical start address */ + u32 size; /* size of compressed ramdisk image in bytes */ +}; + +/* board serial number. "64 bits should be enough for everybody" */ +#define ATAG_SERIAL 0x54410006 + +struct tag_serialnr { + u32 low; + u32 high; +}; + +/* board revision */ +#define ATAG_REVISION 0x54410007 + +struct tag_revision { + u32 rev; +}; + +/* initial values for vesafb-type framebuffers. see struct screen_info + * in include/linux/tty.h + */ +#define ATAG_VIDEOLFB 0x54410008 + +struct tag_videolfb { + u16 lfb_width; + u16 lfb_height; + u16 lfb_depth; + u16 lfb_linelength; + u32 lfb_base; + u32 lfb_size; + u8 red_size; + u8 red_pos; + u8 green_size; + u8 green_pos; + u8 blue_size; + u8 blue_pos; + u8 rsvd_size; + u8 rsvd_pos; +}; + +/* command line: \0 terminated string */ +#define ATAG_CMDLINE 0x54410009 + +struct tag_cmdline { + char cmdline[1]; /* this is the minimum size */ +}; + +/* acorn RiscPC specific information */ +#define ATAG_ACORN 0x41000101 + +struct tag_acorn { + u32 memc_control_reg; + u32 vram_pages; + u8 sounddefault; + u8 adfsdrives; +}; + +#define ATAG_PTABLE 0x53410001 + +/* footbridge memory clock, see arch/arm/mach-footbridge/arch.c */ +#define ATAG_MEMCLK 0x41000402 + +struct tag_memclk { + u32 fmemclk; +}; + +struct tag { + struct tag_header hdr; + union { + struct tag_core core; + struct tag_mem32 mem; + struct tag_videotext videotext; + struct tag_ramdisk ramdisk; + struct tag_initrd initrd; + struct tag_serialnr serialnr; + struct tag_revision revision; + struct tag_videolfb videolfb; + struct tag_cmdline cmdline; +// struct tag_ptable ptable; + + /* + * Acorn specific + */ + struct tag_acorn acorn; + + /* + * DC21285 specific + */ + struct tag_memclk memclk; + + } u; +}; + +struct tagtable { + u32 tag; + int (*parse)(const struct tag *); +}; + +#define __tag __attribute__((unused, __section__(".taglist"))) +#define __tagtable(tag, fn) \ +static struct tagtable __tagtable_##fn __tag = { tag, fn } + +#define tag_member_present(tag,member) \ + ((unsigned long)(&((struct tag *)0L)->member + 1) \ + <= (tag)->hdr.size * 4) + +#define tag_next(t) ((struct tag *)((u32 *)(t) + (t)->hdr.size)) +#define tag_size(type) ((sizeof(struct tag_header) + sizeof(struct type)) >> 2) + +#define for_each_tag(t,base) \ + for (t = base; t->hdr.size; t = tag_next(t)) + +/* + * Memory map description + */ +#define NR_BANKS 8 + +struct meminfo { + int nr_banks; + unsigned long end; + struct { + unsigned long start; + unsigned long size; + int node; + } bank[NR_BANKS]; +}; + +extern struct meminfo meminfo; + +#endif diff --git a/tester1.aps b/tester1.aps new file mode 100644 index 0000000..24921ad Binary files /dev/null and b/tester1.aps differ diff --git a/tester1.cpp b/tester1.cpp new file mode 100644 index 0000000..fe629ba --- /dev/null +++ b/tester1.cpp @@ -0,0 +1,389 @@ +// tester1.cpp : Defines the entry point for the application. +// + +#include "stdafx.h" +#include "tester1.h" +#include +//#include +#include +#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); + + +#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. + */ + +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); +} + +HANDLE OpenCOM1() { + + static HANDLE COM1handle = INVALID_HANDLE_VALUE; + const char msg[] = "\r\n--------linexec--------\r\n"; + unsigned long wrote; + int speed = CBR_115200; + HANDLE h; + + if (COM1handle != INVALID_HANDLE_VALUE) + return (COM1handle); + + h = CreateFile(TEXT("COM1:"), + GENERIC_READ | GENERIC_WRITE, 0, NULL, OPEN_EXISTING, 0, + NULL); + if (h == INVALID_HANDLE_VALUE) + return (h); + + DCB dcb; + if (!GetCommState(h, &dcb)) + goto bad; + + dcb.BaudRate = speed; + if (!SetCommState(h, &dcb)) + goto bad; + + // Print banner on serial console. + WriteFile(h, msg, sizeof msg, &wrote, 0); + + COM1handle = h; + + return (h); + bad: + CloseHandle(h); + return (INVALID_HANDLE_VALUE); +} + +// +// 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; + TCHAR szTitle[MAX_LOADSTRING]; // The title bar text + TCHAR szWindowClass[MAX_LOADSTRING]; // The window class name + + hInst = hInstance; // Store instance handle in our global variable + // Initialize global string + LoadString(hInstance, IDC_TESTER1, szWindowClass, MAX_LOADSTRING); + LoadString(hInstance, IDS_APP_TITLE, szTitle, MAX_LOADSTRING); + + //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); + + OpenCOM1(); + load_boot("\\My Documents\\params.txt"); + load_boot("\\Storage Card\\params.txt"); + load_boot("\\ÒÓØ ¶°ÄÞ\\params.txt"); + + 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) +{ + + HDC hdc; + + int wmId, wmEvent; + + PAINTSTRUCT ps; + + TCHAR szHello[MAX_LOADSTRING]; + + + + switch (message) + + { + + case WM_COMMAND: + + wmId = LOWORD(wParam); + + wmEvent = HIWORD(wParam); + + // Parse the menu selections: + + switch (wmId) + + { + + case IDM_HELP_ABOUT: + + DialogBox(hInst, (LPCTSTR)IDD_ABOUTBOX, hWnd, (DLGPROC)About); + + break; + + case IDOK: + + SendMessage(hWnd, WM_ACTIVATE, MAKEWPARAM(WA_INACTIVE, 0), (LPARAM)hWnd); + + SendMessage (hWnd, WM_CLOSE, 0, 0); + + break; + + default: + + return DefWindowProc(hWnd, message, wParam, lParam); + + } + + break; + + case WM_CREATE: + + hwndCB = CreateRpCommandBar(hWnd); + + break; + + case WM_PAINT: + + RECT rt; + + hdc = BeginPaint(hWnd, &ps); + + GetClientRect(hWnd, &rt); + + LoadString(hInst, IDS_HELLO, szHello, MAX_LOADSTRING); + + DrawText(hdc, szHello, _tcslen(szHello), &rt, + + DT_SINGLELINE | DT_VCENTER | DT_CENTER); + + EndPaint(hWnd, &ps); + + break; + + case WM_DESTROY: + + CommandBar_Destroy(hwndCB); + + PostQuitMessage(0); + + break; + + case WM_SETTINGCHANGE: + +// SHHandleWMSettingChange(hWnd, wParam, lParam, &s_sai); + + break; + + default: + + return DefWindowProc(hWnd, message, wParam, lParam); + + } + + return 0; + +} + + + +HWND CreateRpCommandBar(HWND hwnd) + +{ +/* + SHMENUBARINFO mbi; + + + + memset(&mbi, 0, sizeof(SHMENUBARINFO)); + + mbi.cbSize = sizeof(SHMENUBARINFO); + + mbi.hwndParent = hwnd; + + mbi.nToolBarId = IDM_MENU; + + mbi.hInstRes = hInst; + + mbi.nBmpId = 0; + + mbi.cBmpImages = 0; + + + + if (!SHCreateMenuBar(&mbi)) + + return NULL; + + + + return mbi.hwndMB; +*/ + return NULL; +} + + + +// Mesage handler for the About box. + +LRESULT CALLBACK About(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam) + +{ + +// SHINITDLGINFO shidi; + + + + switch (message) + + { + + case WM_INITDIALOG: + + // Create a Done button and size it. + +// shidi.dwMask = SHIDIM_FLAGS; + +// shidi.dwFlags = SHIDIF_DONEBUTTON | SHIDIF_SIPDOWN | SHIDIF_SIZEDLGFULLSCREEN; + +// shidi.hDlg = hDlg; + +// SHInitDialog(&shidi); + + return TRUE; + + + + case WM_COMMAND: + + if (LOWORD(wParam) == IDOK) { + + EndDialog(hDlg, LOWORD(wParam)); + + return TRUE; + + } + + break; + + } + + return FALSE; + +} + diff --git a/tester1.h b/tester1.h new file mode 100644 index 0000000..b793a85 --- /dev/null +++ b/tester1.h @@ -0,0 +1,71 @@ +#include "config.h" + + +#define BOOT_LOGO +//#define BOOT_LOGO_DONE + +#if !defined(AFX_TESTER1_H__7D4A2D28_4650_475E_A82E_CF6F8E7BA839__INCLUDED_) +#define AFX_TESTER1_H__7D4A2D28_4650_475E_A82E_CF6F8E7BA839__INCLUDED_ + +#if _MSC_VER > 1000 +#pragma once +#endif // _MSC_VER > 1000 + +#include "resource.h" + +//////////////////////////////// Some type definitions ///////////////////// +struct Image { + UINT16 *p; + long x,y; +}; + +/////////////////////////////Functions ///////////////////////////////////// +Image ReadBMP(char[]); +void ShowImage(UINT16*,int,int,int=0,int=0); +void Gpio(); +void UART_setup(); +void DumpMMU(); +void UART_puts(char *); +void init_fb(); +void try_fb(); +void boot_linux(char*,char*); +UINT32 ReadPhysical(UINT32); +void WritePhysical(UINT32 addr,UINT32 val); +UINT32 VirtualToPhysical(UINT32); +void load_boot(char*); +void SetGPIOalt(int,int); +void SetGPIOio(int,int); + + +//////////////////////////////////////////////////////////////////////////// + +extern "C" BOOL VirtualCopy(LPVOID lpvDestMem, LPVOID lpvSrcMem, + DWORD dwSizeInBytes, DWORD dwProtectFlag); + +extern void do_it(); + +extern int read_mmu(); // reads where is/are descriptors located + +extern void IntOff(); +extern void DRAMloader(UINT32 adr,UINT32 machine_num); // this function turns off MMU and jumps onto physical address given + +extern "C" DWORD SetProcPermissions( +DWORD newperms +); + +extern "C" DWORD GetCurrentPermissions( +); + +extern "C" BOOL SetKMode( +BOOL fMode +); + +extern "C" LPVOID CreateStaticMapping( +DWORD dwPhysBase, +DWORD dwSize +); + + +#define MENU_HEIGHT 26 + +#endif // !defined(AFX_TESTER1_H__7D4A2D28_4650_475E_A82E_CF6F8E7BA839__INCLUDED_) diff --git a/tester1.ico b/tester1.ico new file mode 100644 index 0000000..0130454 Binary files /dev/null and b/tester1.ico differ diff --git a/tester1.rc b/tester1.rc new file mode 100644 index 0000000..7169029 --- /dev/null +++ b/tester1.rc @@ -0,0 +1,153 @@ +//Microsoft eMbedded Visual C++ generated resource script. +// +#include "resource.h" + +#define APSTUDIO_READONLY_SYMBOLS +///////////////////////////////////////////////////////////////////////////// +// +// Generated from the TEXTINCLUDE 2 resource. +// +#include "newres.h" +///////////////////////////////////////////////////////////////////////////// +#undef APSTUDIO_READONLY_SYMBOLS + +#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU) +#ifdef _WIN32 +LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US +#pragma code_page(1252) +#endif + +///////////////////////////////////////////////////////////////////////////// +// +// Icon +// + +// Icon with lowest ID value placed first to ensure application icon +// remains consistent on all systems. +IDI_TESTER1 ICON DISCARDABLE "tester1.ICO" + +#ifdef APSTUDIO_INVOKED +///////////////////////////////////////////////////////////////////////////// +// +// TEXTINCLUDE +// + +1 TEXTINCLUDE DISCARDABLE +BEGIN + "resource.h\0" +END + +2 TEXTINCLUDE DISCARDABLE +BEGIN + "#include ""newres.h""\r\n" + "\0" +END + +3 TEXTINCLUDE DISCARDABLE +BEGIN + "\r\n" + "\0" +END + +#endif // APSTUDIO_INVOKED + +///////////////////////////////////////////////////////////////////////////// +// +// Menu +// + +IDM_MENU RCDATA +BEGIN + IDM_MENU, 1, + + I_IMAGENONE, IDM_MAIN_COMMAND1, TBSTATE_ENABLED, + TBSTYLE_DROPDOWN | TBSTYLE_AUTOSIZE, + IDS_HELP, 0, 0, + +END + + +IDM_MENU MENU DISCARDABLE +BEGIN + POPUP "Tools" + BEGIN + MENUITEM "About", IDM_HELP_ABOUT + END +END + + +///////////////////////////////////////////////////////////////////////////// +// +// Dialog +// + +IDD_ABOUTBOX DIALOGEX 0, 0, 140, 57 +STYLE WS_POPUP | WS_CAPTION +EXSTYLE WS_EX_CAPTIONOKBTN +CAPTION "About tester1" +FONT 8, "System" + +BEGIN + ICON IDI_TESTER1,IDC_STATIC,11,17,20,20 + LTEXT "tester1 Version 1.0",IDC_STATIC,40,10,70,8, SS_NOPREFIX + LTEXT "Copyright (C) 2003",IDC_STATIC,40,25,70,8 +END + + +///////////////////////////////////////////////////////////////////////////// +// +// Accelerator +// + +IDC_TESTER1 ACCELERATORS DISCARDABLE +BEGIN + "A", IDM_HELP_ABOUT, VIRTKEY, CONTROL, NOINVERT + "Q", IDOK, VIRTKEY, CONTROL, NOINVERT +END + +///////////////////////////////////////////////////////////////////////////// +// +// DESIGNINFO +// + +#ifdef APSTUDIO_INVOKED +GUIDELINES DESIGNINFO DISCARDABLE +BEGIN + IDD_ABOUTBOX, DIALOG + BEGIN + LEFTMARGIN, 7 + RIGHTMARGIN, 133 + TOPMARGIN, 7 + BOTTOMMARGIN, 50 + END +END +#endif // APSTUDIO_INVOKED + +///////////////////////////////////////////////////////////////////////////// +// +// String Table +// + +STRINGTABLE DISCARDABLE +BEGIN + IDC_TESTER1 "TESTER1" + IDS_APP_TITLE "tester1" + IDS_HELLO "Hello World!" + IDS_HELP "Tools" + IDS_COMMAND1 "Done " +END + +#endif +///////////////////////////////////////////////////////////////////////////// + + + +#ifndef APSTUDIO_INVOKED +///////////////////////////////////////////////////////////////////////////// +// +// Generated from the TEXTINCLUDE 3 resource. +// + + +///////////////////////////////////////////////////////////////////////////// +#endif // not APSTUDIO_INVOKED diff --git a/uart.cpp b/uart.cpp new file mode 100644 index 0000000..98451fa --- /dev/null +++ b/uart.cpp @@ -0,0 +1,65 @@ +#include "stdafx.h" +#include "tester1.h" +#include +//#include +#include +#include "setup.h" + +// moved to config.h +//#define FUART 0x40100000 + + +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<