From c5f1f439f689ac322fc715b979e343c93e8b8ec3 Mon Sep 17 00:00:00 2001 From: michael Date: Sun, 24 Jul 2005 17:30:28 +0000 Subject: [PATCH] fix linebreaks --- ReadMe.txt | 154 +++++----- StdAfx.h | 50 ++-- asm/asm-wince.asm | 198 ++++++------- asm/asm.asm | 206 ++++++------- asm/asmstuff-wince.asm | 140 ++++----- asm/asmstuff.asm | 44 +-- asm/test123.asm | 14 +- boot.cpp | 642 ++++++++++++++++++++--------------------- config.h | 52 ++-- gpio.cpp | 4 +- memory.cpp | 212 +++++++------- newres.h | 82 +++--- resource.h | 54 ++-- setup.h | 556 +++++++++++++++++------------------ tester1.cpp | 280 +++++++++--------- tester1.h | 142 ++++----- uart.cpp | 36 +-- 17 files changed, 1433 insertions(+), 1433 deletions(-) diff --git a/ReadMe.txt b/ReadMe.txt index c5d3c57..037b2f7 100644 --- a/ReadMe.txt +++ b/ReadMe.txt @@ -1,77 +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. - - - - +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/StdAfx.h b/StdAfx.h index fbbf3ee..6a85852 100644 --- a/StdAfx.h +++ b/StdAfx.h @@ -1,49 +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/asm/asm-wince.asm b/asm/asm-wince.asm index a34be6e..0cf3fad 100644 --- a/asm/asm-wince.asm +++ b/asm/asm-wince.asm @@ -1,99 +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 + 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.asm b/asm/asm.asm index fa9a15c..ddc6ef5 100644 --- a/asm/asm.asm +++ b/asm/asm.asm @@ -1,103 +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 - + 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/asmstuff-wince.asm b/asm/asmstuff-wince.asm index 76095e1..dd0abce 100644 --- a/asm/asmstuff-wince.asm +++ b/asm/asmstuff-wince.asm @@ -1,70 +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 + 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 diff --git a/asm/asmstuff.asm b/asm/asmstuff.asm index e737feb..05bdac6 100644 --- a/asm/asmstuff.asm +++ b/asm/asmstuff.asm @@ -1,9 +1,9 @@ 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| @@ -11,13 +11,13 @@ 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| @@ -25,54 +25,54 @@ 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 + 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 + + 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 +; 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/test123.asm b/asm/test123.asm index 2559552..de4fe71 100644 --- a/asm/test123.asm +++ b/asm/test123.asm @@ -1,7 +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 +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 diff --git a/boot.cpp b/boot.cpp index 1d3706a..1204c79 100644 --- a/boot.cpp +++ b/boot.cpp @@ -1,321 +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); -} +#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/config.h b/config.h index e2f6029..f7c1b58 100644 --- a/config.h +++ b/config.h @@ -1,13 +1,13 @@ -#define STRONGARM 1 +#define STRONGARM 1 #ifndef STRONGARM /* xscale */ #define MEM_START 0xa0000000 - -/* Memory in MByte */ -#define MEM_SIZE 64 + +/* Memory in MByte */ +#define MEM_SIZE 64 #define KERNELCOPY 0xa0a00000 //#define KERNELCOPY 0xa0800000 @@ -18,17 +18,17 @@ /* Interrupt controller */ #define ICIP 0x40D00000 -#define UARTBASE 0x40100000 -#define UARTDATA 0x00 -#define UARTSTATUS 0x14 -#define UARTTXRDY 5 -#define UARTTXBIT 0 - +#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_JORNADA720 48 #define MACH_TYPE 48 #else @@ -37,9 +37,9 @@ #define MEM_START 0xc0000000 -/* Memory in MByte */ -#define MEM_SIZE 32 - +/* Memory in MByte */ +#define MEM_SIZE 32 + #define KERNELCOPY 0xc0a00000 #define INITRD 0xc0d00000 @@ -48,24 +48,24 @@ /* Interrupt controller */ #define ICIP 0x90050000 -#define UARTBASE 0x80030000 -#define UARTDATA 0x14 -#define UARTSTATUS 0x20 -#define UARTTXRDY 2 -#define UARTTXBIT 0 - +#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 + +/* MACH_TYPE_XDA */ +#define MACH_TYPE_JORNADA720 48 +#define MACH_TYPE 48 #endif diff --git a/gpio.cpp b/gpio.cpp index d1d6f65..4e43c84 100644 --- a/gpio.cpp +++ b/gpio.cpp @@ -8,9 +8,9 @@ #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); diff --git a/memory.cpp b/memory.cpp index 96ff433..563e6ad 100644 --- a/memory.cpp +++ b/memory.cpp @@ -1,106 +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; -} +#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 index e6e2a53..8289ebe 100644 --- a/newres.h +++ b/newres.h @@ -1,41 +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__ +#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 index 635cd99..726a0d5 100644 --- a/resource.h +++ b/resource.h @@ -1,27 +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 +//{{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 index 1bc06c8..46ca483 100644 --- a/setup.h +++ b/setup.h @@ -1,278 +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 +/* + * 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.cpp b/tester1.cpp index fe629ba..ed74c41 100644 --- a/tester1.cpp +++ b/tester1.cpp @@ -22,7 +22,7 @@ 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. @@ -30,7 +30,7 @@ HWND CreateRpCommandBar(HWND); 4189: initialized but not used. make that an error: later. 4701: usage w/o initialization. */ - + int WINAPI WinMain( HINSTANCE hInstance, HINSTANCE hPrevInstance, LPTSTR lpCmdLine, @@ -87,42 +87,42 @@ ATOM MyRegisterClass(HINSTANCE hInstance, LPTSTR 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); -} + +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) @@ -137,15 +137,15 @@ HANDLE OpenCOM1() { BOOL InitInstance(HINSTANCE hInstance, int nCmdShow) { - HWND hWnd = NULL; - TCHAR szTitle[MAX_LOADSTRING]; // The title bar text + 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); + + 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) @@ -158,11 +158,11 @@ BOOL InitInstance(HINSTANCE hInstance, int nCmdShow) RECT rect; GetClientRect(hWnd, &rect); - + OpenCOM1(); load_boot("\\My Documents\\params.txt"); load_boot("\\Storage Card\\params.txt"); - load_boot("\\ÒÓØ ¶°ÄÞ\\params.txt"); + load_boot("\\ÒÓØ ¶°ÄÞ\\params.txt"); hWnd = CreateWindow(szWindowClass, szTitle, WS_VISIBLE, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, NULL, NULL, hInstance, NULL); @@ -203,187 +203,187 @@ BOOL InitInstance(HINSTANCE hInstance, int nCmdShow) // 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; +*/ + 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 index b793a85..7a949cd 100644 --- a/tester1.h +++ b/tester1.h @@ -1,71 +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_) +#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/uart.cpp b/uart.cpp index 98451fa..020852f 100644 --- a/uart.cpp +++ b/uart.cpp @@ -5,9 +5,9 @@ #include #include "setup.h" -// moved to config.h +// moved to config.h //#define FUART 0x40100000 - + void UART_puts(char *s) { @@ -26,21 +26,21 @@ 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); - -#ifdef STRONGARM -// Apparently there is something we don't know. This is needed. - HANDLE hSerial = CreateFile(L"COM1:", GENERIC_READ | GENERIC_WRITE, FILE_SHARE_READ | FILE_SHARE_WRITE, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, 0); -// disable UART - base[0x0C/4] = 0; -// clear status - base[0x1C/4] = 0xFF; -// set 8 bit no parity 1 stopbit - base[0x00/4] = 9; -// set 115200 bps - base[0x04/4] = 0; - base[0x08/4] = 1; -// enable TX/RX - base[0x0C/4] = 3; + +#ifdef STRONGARM +// Apparently there is something we don't know. This is needed. + HANDLE hSerial = CreateFile(L"COM1:", GENERIC_READ | GENERIC_WRITE, FILE_SHARE_READ | FILE_SHARE_WRITE, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, 0); +// disable UART + base[0x0C/4] = 0; +// clear status + base[0x1C/4] = 0xFF; +// set 8 bit no parity 1 stopbit + base[0x00/4] = 9; +// set 115200 bps + base[0x04/4] = 0; + base[0x08/4] = 1; +// enable TX/RX + base[0x0C/4] = 3; #else // set DLAB base[0x0C/4]=128+2+1; @@ -52,7 +52,7 @@ void UART_setup() // UART enable & no FIFO base[0x04/4]=64; base[0x08/4]=0; -#endif +#endif char test[]="LinExec: UART Initialized.\n\r"; int a=0; -- 2.39.5