Author: wmb Date: Tue Jul 13 09:24:52 2010 New Revision: 1865 URL: http://tracker.coreboot.org/trac/openfirmware/changeset/1865
Log: ARM MMP2 port - checkpoint of a lot of work to bring the build in line with the OLPC setup.
Added: cpu/arm/crc32.fth cpu/arm/linux.fth cpu/arm/loadarea.fth cpu/arm/mmp2/boot.fth cpu/arm/mmp2/config.fth cpu/arm/mmp2/devices.fth cpu/arm/mmp2/fw.bth cpu/arm/mmp2/mmuon.fth cpu/arm/mmp2/watchdog.fth cpu/arm/mmusetup.fth ofw/core/initdict.fth ofw/core/reboot.fth ofw/core/reenter.fth Modified: cpu/arm/basefw.bth cpu/arm/fb8-ops.fth cpu/arm/kerncode.fth cpu/arm/mmp2/addrs.fth cpu/arm/mmp2/dsi.fth cpu/arm/mmp2/lcd.fth cpu/arm/mmp2/lcdcfg.fth cpu/arm/mmp2/mmp2.bth cpu/arm/mmp2/probemem.fth cpu/arm/mmp2/rootnode.fth cpu/arm/saverom.fth cpu/arm/tools.bth cpu/arm/traps.fth forth/kernel/kernel.fth ofw/core/countdwn.fth ofw/core/muxdev.fth ofw/gui/iconmenu.fth ofw/termemu/fb8.fth ofw/wifi/loadpkg.fth
Modified: cpu/arm/basefw.bth ============================================================================== --- cpu/arm/basefw.bth Fri Jul 9 06:25:07 2010 (r1864) +++ cpu/arm/basefw.bth Tue Jul 13 09:24:52 2010 (r1865) @@ -90,6 +90,7 @@
tag-file @ fclose tag-file off
+h# 10.0000 dictionary-size ! .( --- Saving basefw.dic --- ) cr " basefw.dic" $save-forth [then]
Added: cpu/arm/crc32.fth ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ cpu/arm/crc32.fth Tue Jul 13 09:24:52 2010 (r1865) @@ -0,0 +1,54 @@ +\ See license at end of file +purpose: CRC-32 calculation + +\ Load this before forth/lib/crc32.fth + +[ifdef] notdef +code crcstep ( crc b table-adr -- crc' ) + \ tos: table-adr, r1:b, r2:crc + ldmia sp!,{r1,r2} + eor r1,r1,r2 \ r1: crc ^ byte + and r1,r1,#0xff \ index + ldr tos,[tos,r1,lsl #2] \ Table data + eor tos,tos,r2,lsr #8 \ Return crc'=table_data^(crc>>8) +c; +[then] + +code ($crc) ( crc table-adr adr len -- crc' ) + movs r3,tos + ldmia sp!,{r1,r2,tos} \ r1:adr, r2:table-adr, r3:len, tos:crc + nxteq \ Bail out if len is 0 + + begin + ldrb r4,[r1],#1 \ Get next byte + eor r4,r4,tos \ r4: crc^byte + and r4,r4,#0xff \ r4: index + ldr r4,[r2,r4,lsl #2] \ lookup in table + decs r2,1 \ Decrement len + eor tos,r4,tos,lsr #8 \ crc' = table_data ^ (crc >> 8) + 0= until +c; + +\ LICENSE_BEGIN +\ Copyright (c) 2010 FirmWorks +\ +\ Permission is hereby granted, free of charge, to any person obtaining +\ a copy of this software and associated documentation files (the +\ "Software"), to deal in the Software without restriction, including +\ without limitation the rights to use, copy, modify, merge, publish, +\ distribute, sublicense, and/or sell copies of the Software, and to +\ permit persons to whom the Software is furnished to do so, subject to +\ the following conditions: +\ +\ The above copyright notice and this permission notice shall be +\ included in all copies or substantial portions of the Software. +\ +\ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +\ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +\ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +\ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +\ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +\ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +\ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +\ +\ LICENSE_END
Modified: cpu/arm/fb8-ops.fth ============================================================================== --- cpu/arm/fb8-ops.fth Fri Jul 9 06:25:07 2010 (r1864) +++ cpu/arm/fb8-ops.fth Tue Jul 13 09:24:52 2010 (r1865) @@ -62,6 +62,56 @@ repeat c;
+\ Within the rectangular region, replace 3-byte pixels whose current value +\ is the same as fg-color with bg-color, and vice versa, leaving bytes that +\ match neither value unchanged. +code fb24-invert ( adr width height bytes/line fg-color bg-color -- ) + ldmia sp!,{r1,r2,r3,r4,r5} + \ r0:scratch r1:fg-colour r2:bytes/line r3:height r4:width r5:adr + \ r6 bytes/line, r7 scratch, r8 scratch, tos bg-color + + add r4,r4,r4, lsl #1 \ Multiply width by 4 to get bytes + begin + cmp r3,#0 + > while + mov r6,#0 + begin + cmp r4,r6 \ more pixels/line? + > while + add r0,r5,r6 \ r0 points to the pixel + ldrb r7,[r0] \ Start reading a 3-byte pixel + ldrb r8,[r0,#1] + orr r7, r7, r8, lsl #8 + ldrb r8,[r0,#2] + orr r7, r7, r8, lsl #16 + + cmp r7,tos \ Is it the background color? + 0= if + \ If so, replace with the foreground color + strb r1,[r0] + mov r8,r1,lsr #8 + strb r8,[r0,#1] + mov r8,r1,lsr #16 + strb r8,[r0,#2] + then + + cmp r7,r1 \ Is it the foreground color? + 0= if + \ If so, replace with the background color + strb tos,[r0] + mov r8,tos,lsr #8 + strb r8,[r0,#1] + mov r8,tos,lsr #16 + strb r8,[r0,#2] + then + inc r6,#3 \ Advance offset to the next pixel + repeat + add r5,r5,r2 \ Advance to next scan line + dec r3,#1 \ Decrease the remaining line count + repeat + pop tos,sp +c; + \ Within the rectangular region, replace halfwords whose current value is \ the same as fg-color with bg-color, and vice versa, leaving bytes that \ match neither value unchanged. @@ -158,6 +208,55 @@ ldmia sp!,{r9,tos} c;
+\ Draws a character from a 1-bit-deep font into a 24bpp frame buffer +\ Font bits are stored 1-bit-per-pixel, with the most-significant-bit of +\ the font byte corresponding to the leftmost pixel in the group for that +\ byte. "font-width" is the distance in bytes from the first font byte for +\ a scan line of the character to the first font byte for its next scan line. +code fb24-paint + ( fontadr fontbytes width height screenadr bytes/line fg-color bg-color -- ) + ldmia sp!,{r1,r2,r3,r4,r5,r6,r7} + psh r9,sp +\ tos:bg-col r1:fg-col r2:bytes/line r3: screenadr r4:height r5:width +\ r6:font-width r7:fontadr +\ free: r8 r9 r0 + begin + cmp r4,#0 + > while + mov r8,#0 \ r8: pixel-offset + begin + cmp r5,r8 \ one more pixel? + > while + ldrb r9,[r7,r8,lsr #3] \ r9 fontdatabyte + and r0,r8,#7 \ r9 bit offset 0-7 + rsb r0,r0,#8 \ r0 bit offset 8-1 + movs r0,r9,asr r0 \ Test font bit + add r9,r3,r8,lsl #1 \ r9 = r3 = r8*2 - Partial address computation + add r9,r9,r8 \ r9 = r3 + r8*3 + u< if + \ Background + strb tos,[r9] \ store first byte of pixel + mov r0,tos,lsr #8 + strb r0,[r9,#1] \ store second byte of pixel + mov r0,tos,lsr #16 + strb r0,[r9,#2] \ store third byte of pixel + else + \ Foreground + strb r1,[r9] \ store first byte of pixel + mov r0,r1,lsr #8 + strb r0,[r9,#1] \ store second byte of pixel + mov r0,r1,lsr #16 + strb r0,[r9,#2] \ store third byte of pixel + then + inc r8,#1 + repeat + add r7,r7,r6 \ new font-line + add r3,r3,r2 \ new screen-line + dec r4,#1 + repeat + ldmia sp!,{r9,tos} +c; + \ Draws a character from a 1-bit-deep font into an 8-bit-deep frame buffer \ Font bits are stored 1-bit-per-pixel, with the most-significant-bit of \ the font byte corresponding to the leftmost pixel in the group for that @@ -181,9 +280,9 @@ and r0,r8,#7 rsb r0,r0,#8 movs r0,r9,asr r0 - strcs r1,[r3,r8] - strcc tos,[r3,r8] - inc r8,#4 + strcs r1,[r3,r8,lsl #2] + strcc tos,[r3,r8,lsl #2] + inc r8,#1 repeat add r7,r7,r6 \ new font-line add r3,r3,r2 \ new screen-line
Modified: cpu/arm/kerncode.fth ============================================================================== --- cpu/arm/kerncode.fth Fri Jul 9 06:25:07 2010 (r1864) +++ cpu/arm/kerncode.fth Tue Jul 13 09:24:52 2010 (r1865) @@ -689,6 +689,23 @@ strb r4,[r5],#1 c;
+code t! ( n adr -- ) + mov r5,tos \ r5: adr + ldmia sp!,{r4,tos} + strb r4,[r5],#1 + mov r4,r4,ror #8 + strb r4,[r5],#1 + mov r4,r4,ror #8 + strb r4,[r5],#1 +c; +code t@ ( adr -- w ) + ldrb r0,[tos] + ldrb tos,[tos,#1] + orr r0,r0,tos,lsl #8 + ldrb tos,[tos,#2] + orr tos,r0,tos,lsl #16 +c; + code unaligned-w@ ( adr -- w ) ldrb r0,[tos] ldrb tos,[tos,#1] @@ -852,6 +869,21 @@ < until c;
+\ tfill fills with a 3-byte value. It's useful for 24bpp frame buffers +code tfill ( adr cnt t -- ) + mov r2,tos + ldmia sp!,{r0,r1,tos} \ r0-cnt r1-adr r2-data + mov r3,r2,lsr #8 + mov r4,r2,lsr #16 + begin + decs r0,3 + strgeb r2,[r1],#1 + strgeb r3,[r1],#1 + strgeb r4,[r1],#1 + < until +c; + + code lfill ( adr cnt l -- ) mov r2,tos ldmia sp!,{r0,r1,tos} \ r0-cnt r1-adr r2-data @@ -861,6 +893,36 @@ < until c;
+\ Skip initial occurrences of bvalue, returning the residual length +code bskip ( adr len bvalue -- residue ) + ldmia sp!,{r0,r1} \ r0-len r1-adr tos-bvalue + mov r2,tos \ r2-bvalue + movs tos,r0 \ tos-len + nxteq \ Bail out if len=0 + + begin + ldrb r0,[r1],#1 + cmp r0,r2 + nxtne + decs tos,1 + = until +c; + +\ Skip initial occurrences of lvalue, returning the residual length +code lskip ( adr len lvalue -- residue ) + ldmia sp!,{r0,r1} \ r0-len r1-adr tos-lvalue + mov r2,tos \ r2-lvalue + movs tos,r0 \ tos-len + nxteq \ Bail out if len=0 + + begin + ldr r0,[r1],#4 + cmp r0,r2 + nxtne + decs tos,4 + = until +c; + \ code /link ( -- /link ) psh tos,sp mov tos,/link c;
code /char ( -- 1 ) psh tos,sp mov tos,#1 c; @@ -903,6 +965,9 @@ code /l* ( n1 -- n2 ) mov tos,tos,lsl #2 c; code /n* ( n1 -- n2 ) mov tos,tos,lsl #2 c;
+code /t* ( n1 -- n2 ) add tos,tos,tos,lsl #1 c; +code 3* ( n1 -- n2 ) add tos,tos,tos,lsl #1 c; + 8 equ nvocs \ Number of slots in the search order
code upc ( char -- upper-case-char )
Added: cpu/arm/linux.fth ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ cpu/arm/linux.fth Tue Jul 13 09:24:52 2010 (r1865) @@ -0,0 +1,204 @@ +\ See license at end of file +purpose: ARM Linux zImage program loading + +defer linux-hook ' noop to linux-hook + +0 value ramdisk-adr +0 value /ramdisk + +0 value linux-memtop + +\ Find the end of the largest piece of memory +: memory-limit ( -- limit ) + \ If we have already loaded a RAMdisk in high memory, its base is the memory limit + ramdisk-adr ?dup if exit then + + " /memory" find-package 0= abort" No /memory node" ( phandle ) + " available" rot get-package-property abort" No memory node available property" ( $ ) + \ Find the memory piece that starts at 0 + begin dup 8 >= while ( $ ) + decode-int 0= if ( $ ) \ Found the one we want + decode-int ( $ limit ) + nip nip exit + then ( $ ) + decode-int drop ( $ ) + repeat ( $ ) + 2drop true abort" No suitable memory piece" +; + +: add-root-dev ( cmdline$ -- cmdline$' ) + /ramdisk if ( cmdline$ ) + " root=/dev/ram0" $cat2 ( cmdline$' ) + then ( cmdline$ ) +; + +\ see http://www.simtec.co.uk/products/SWLINUX/files/booting_article.html + +0 value arm-linux-machine-type \ Set this after loading this file +h# 100 value linux-params \ The location recommended by the above article +def-load-base value linux-base +0 value rootdev# \ Set externally + +0 value tag-adr +: tag-w, ( w -- ) tag-adr w! tag-adr wa1+ to tag-adr ; +: tag-b, ( b -- ) tag-adr c! tag-adr ca1+ to tag-adr ; +: tag-l, ( n -- ) tag-adr l! tag-adr la1+ to tag-adr ; + +defer fb-tag, ' noop to fb-tag, \ Define externally if appropriate + +: set-parameters ( cmdline$ -- ) + linux-params to tag-adr + + 5 tag-l, \ size + h# 54410001 tag-l, \ ATAG_CORE + 0 tag-l, \ Flags (1 for read-only) + pagesize tag-l, + rootdev# tag-l, + + 4 tag-l, + h# 54410002 tag-l, \ ATAG_MEM + linux-memtop tag-l, \ size + 0 tag-l, \ start_address + + /ramdisk if + 5 tag-l, \ size + h# 54410004 tag-l, \ ATAG_RAMDISK + 0 tag-l, \ load flag == 0 + d# 4096 tag-l, \ 4k kilobytes = 4 megabytes (calculate dynamically?) + 0 tag-l, \ unused floppy block number + + 4 tag-l, + h# 54420005 tag-l, \ ATAG_RAMDISK2 + ramdisk-adr >physical tag-l, \ physical starting address + /ramdisk tag-l, \ size of compressed ramdisk in bytes + then + + \ Command line + ( cmdline$ ) add-root-dev + ( cmdline$ ) ( adr len ) + dup if ( adr len ) + 1+ 4 round-up ( adr len+null_rounded ) + dup 2 rshift 2 + tag-l, ( adr len+null_rounded ) \ tag size + h# 54410009 tag-l, ( adr len+null_rounded ) \ ATAG_CMDLINE + tuck tag-adr swap move ( len+null_rounded ) \ copy in cmdline + tag-adr + to tag-adr ( ) + else ( adr len ) + 2drop ( ) + then + + fb-tag, + + 0 tag-l, \ size of ATAG_NONE is really 2 but must be written as 0 + 0 tag-l, \ ATAG_NONE +; + + +: linux-fixup ( -- ) +[ifdef] linux-logo linux-logo [then] + args-buf cscount set-parameters ( ) + disable-interrupts + + linux-base linux-base (init-program) \ Starting address, SP + 0 to r0 + arm-linux-machine-type to r1 + linux-params to r2 + linux-hook +; + +d# 256 buffer: ramdisk-buf +' ramdisk-buf " ramdisk" chosen-string + +defer load-ramdisk +defer place-ramdisk +: linux-place-ramdisk ( adr len -- ) + to /ramdisk ( adr ) + + memory-limit umin /ramdisk - ( adr new-ramdisk-adr ) + tuck /ramdisk move ( new-ramdisk-adr ) +\ dup to linux-memtop + to ramdisk-adr +; +: $load-ramdisk ( name$ -- ) + 0 to /ramdisk ( name$ ) + + ['] load-path behavior >r ( name$ r: xt ) + ['] ramdisk-buf to load-path ( name$ r: xt ) + + ." Loading ramdisk image from " 2dup type ." ..." ( name$ r: xt ) + ['] boot-read catch ( throw-code r: xt ) + cr ( throw-code r: xt ) + r> to load-path ( throw-code ) + throw + + loaded place-ramdisk +; +: cv-load-ramdisk ( -- ) + " ramdisk" eval dup 0= if 2drop exit then ( name$ ) + $load-ramdisk +; +' cv-load-ramdisk to load-ramdisk + +0 value linux-loaded? + +: init-zimage? ( -- flag ) + loaded ( adr len ) + h# 30 < if drop false exit then ( adr ) + dup h# 24 + l@ h# 016f2818 <> if drop false exit then ( adr ) + >r + r@ h# 28 + l@ r@ + ( start r: adr ) + r@ h# 2c + l@ r@ + ( start end r: adr ) + r> drop ( start end ) + over - ( start len ) + + linux-base swap move ( ) + + true to linux-loaded? ( ) + + true ( flag ) +; + +warning @ warning off +: init-program ( -- ) + init-zimage? if exit then + init-program +; +warning ! + +warning @ warning off +: init-program ( -- ) + false to linux-loaded? + init-program + linux-loaded? if + ['] linux-place-ramdisk to place-ramdisk + memory-limit to linux-memtop \ load-ramdisk may change this + ['] load-ramdisk guarded + linux-fixup + then +; +warning ! + +: mcr ( -- ) cr exit? throw ; + +\ LICENSE_BEGIN +\ Copyright (c) 2010 FirmWorks +\ +\ Permission is hereby granted, free of charge, to any person obtaining +\ a copy of this software and associated documentation files (the +\ "Software"), to deal in the Software without restriction, including +\ without limitation the rights to use, copy, modify, merge, publish, +\ distribute, sublicense, and/or sell copies of the Software, and to +\ permit persons to whom the Software is furnished to do so, subject to +\ the following conditions: +\ +\ The above copyright notice and this permission notice shall be +\ included in all copies or substantial portions of the Software. +\ +\ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +\ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +\ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +\ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +\ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +\ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +\ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +\ +\ LICENSE_END
Added: cpu/arm/loadarea.fth ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ cpu/arm/loadarea.fth Tue Jul 13 09:24:52 2010 (r1865) @@ -0,0 +1,79 @@ +\ See license at end of file +purpose: Manage the allocation and mapping of the program load area (load-base) + +h# f000.0000 constant def-load-base +def-load-base to load-limit + +h# 10.0000 constant /load-piece +h# 8.0000 constant /reserved +h# 8.0000 constant /dma-reserved + +\ Frees virtual address space and physical memory behind it +: release-all ( virt len -- ) + >r dup mmu-translate if ( virt phys mode r: len ) + drop r@ mem-release ( virt r: len ) + dup r@ mmu-unmap ( virt r: len ) + then ( virt r: len ) + r> mmu-release +; + +\ Release-load-area depends on the way that map-load-area populates +\ the load area in piecewise-contiguous section-sized units +: release-load-area ( boundary-adr -- ) + pagesize round-up ( unused-base ) + + dup /load-piece round-up load-limit umin ( unused next-boundary ) + 2dup u< if ( unused next-boundary ) + 2dup over - release-all ( unused next-boundary ) + then ( unused next-boundary ) + + load-limit swap ?do i /load-piece release-all /load-piece +loop + ( unused ) + to load-limit +; + +: map-load-area ( -- ) + \ Reserve some DMA memory and some ordinary memory + /dma-reserved " /" " dma-alloc" execute-device-method drop >r + /reserved dup mem-claim >r + + \ Allocate and map the load region + def-load-base begin ( top ) + /load-piece /load-piece ['] mem-claim catch 0= while ( top phys ) + over /load-piece 0 mmu-claim ( top phys virt ) + /load-piece -1 mmu-map ( top ) + /load-piece + ( top' ) + repeat ( top x x ) + 2drop to load-limit ( ) + + r> /reserved mem-release \ Put the reserved piece back + r> /dma-reserved " /" " dma-free" execute-device-method drop +; + +stand-init: Load area + map-load-area +; + +\ LICENSE_BEGIN +\ Copyright (c) 2010 FirmWorks +\ +\ Permission is hereby granted, free of charge, to any person obtaining +\ a copy of this software and associated documentation files (the +\ "Software"), to deal in the Software without restriction, including +\ without limitation the rights to use, copy, modify, merge, publish, +\ distribute, sublicense, and/or sell copies of the Software, and to +\ permit persons to whom the Software is furnished to do so, subject to +\ the following conditions: +\ +\ The above copyright notice and this permission notice shall be +\ included in all copies or substantial portions of the Software. +\ +\ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +\ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +\ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +\ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +\ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +\ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +\ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +\ +\ LICENSE_END
Modified: cpu/arm/mmp2/addrs.fth ============================================================================== --- cpu/arm/mmp2/addrs.fth Fri Jul 9 06:25:07 2010 (r1864) +++ cpu/arm/mmp2/addrs.fth Tue Jul 13 09:24:52 2010 (r1865) @@ -1,3 +1,49 @@ +\ Platform design choices +h# 2000.0000 constant total-ram-size + +h# 1fc0.0000 constant fb-pa +h# 40.0000 constant fb-size + +fb-pa constant available-ram-size + + +: (memory?) ( phys -- flag ) total-ram-size u< ; +' (memory?) to memory? + +\ OFW implementation choices +h# 0040.0000 constant fw-pa + +[ifdef] virtual-mode +h# f700.0000 constant fw-virt-base +h# 0100.0000 constant fw-virt-size \ 16 megs of mapping space +[else] +fw-pa value fw-virt-base +0 value fw-virt-size +[then] + +h# 0010.0000 constant /fw-ram + +h# 0110.0000 constant def-load-base + +\ The heap starts at RAMtop, which on this system is "fw-pa /fw-ram +" + +\ We leave some memory in the /memory available list above the heap +\ for DMA allocation by the sound and USB driver. OFW's normal memory +\ usage thus fits in one 4M page-directory mapping region. + +h# 18.0000 constant heap-size +heap-size constant initial-heap-size + +h# 4000 constant page-table-pa + + +\ Defined by CPU core +h# 1000 to pagesize +d# 12 to pageshift +h# 10.0000 constant /section +h# 4000 constant /page-table + +\ Defined by MMP2 hardware h# d401.9000 constant gpio-base h# d405.1024 constant acgr-pa h# d401.5000 constant clock-unit-pa @@ -8,6 +54,3 @@ h# d420.b000 constant lcd-pa h# d401.4000 constant timer-pa
- -h# 08.0000 constant fb-pa -
Added: cpu/arm/mmp2/boot.fth ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ cpu/arm/mmp2/boot.fth Tue Jul 13 09:24:52 2010 (r1865) @@ -0,0 +1,22 @@ +\ This is some glue code to convert the machine setup that QEMU gives us +\ to the setup that start-forth (see arm/boot.fth) wants. +\ We get here via a call instruction at origin+8, which is inserted below + +code stand-cold-code ( r0: 0 r1: board-id r2: &kernel-args lr: &aif_header+8c ) + here origin 8 + put-call \ Insert call instruction + + \ Put the arguments in safe registers + sub r6,lr,#0x8c \ r6 points to header (lr set by code at origin) + mov r7,#0 \ r7: functions + add r8,r6,0x200000 \ r8: memtop - 2MiB above load address + \ r9 is up + mov r10,#0 \ r10: argc + mov r11,r2 \ r11: argv (kernel args) + mov r12,`initial-heap-size` \ r12: initial-heap-size + mov r3,#0 + str r0,[r3],#4 + str r1,[r3],#4 + str r2,[r3],#4 + + b 'code start-forth \ Branch to the generic startup code +end-code
Added: cpu/arm/mmp2/config.fth ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ cpu/arm/mmp2/config.fth Tue Jul 13 09:24:52 2010 (r1865) @@ -0,0 +1,3 @@ +create debug-startup + +fload ${BP}/cpu/arm/mmp2/addrs.fth
Added: cpu/arm/mmp2/devices.fth ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ cpu/arm/mmp2/devices.fth Tue Jul 13 09:24:52 2010 (r1865) @@ -0,0 +1,108 @@ +fload ${BP}/dev/omap/diaguart.fth \ OMAP UART +h# d4018000 to uart-base \ UART# base address on MMP2 + +fload ${BP}/forth/lib/sysuart.fth \ Set console I/O vectors to UART + +0 value keyboard-ih +0 value screen-ih + +fload ${BP}/ofw/core/muxdev.fth \ I/O collection/distribution device + +\ Install the simple UART driver from the standalone I/O init chain +warning off +: stand-init-io ( -- ) + stand-init-io + inituarts install-uart-io +; +warning on + +fload ${BP}/cpu/arm/mmp2/twsi.fth +fload ${BP}/cpu/arm/mmp2/timer.fth +fload ${BP}/cpu/arm/mmp2/mfpr.fth +: init-stuff + set-camera-domain-voltage + acgr-clocks-on + init-mfprs + set-gpio-directions + init-timers + init-twsi + power-on-dsi +; +stand-init: + init-stuff +; + +fload ${BP}/cpu/arm/mmp2/gpio.fth + +fload ${BP}/cpu/arm/mmp2/watchdog.fth \ reset-all using watchdog timer + +0 0 " d4018000" " /" begin-package + " uart" name + h# d4018000 h# 20 reg + + : write ( adr len -- actual ) + 0 max tuck ( actual adr actual ) + bounds ?do i c@ uemit loop ( actual ) + ; + : read ( adr len -- actual ) + 0= if drop 0 exit then + ukey? if ( adr ) + ukey swap c! 1 ( actual ) + else ( adr ) + drop -2 ( -2 ) + then + ; + : open ( -- okay? ) true ; + : close ( -- ) ; + : install-abort ; + : remove-abort ; +end-package +devalias com1 /uart +: com1 " com1" ; +' com1 is fallback-device + +0 0 " d420b000" " /" begin-package + " screen" name + fload ${BP}/cpu/arm/mmp2/lcdcfg.fth + fload ${BP}/cpu/arm/mmp2/dsi.fth + + fload ${BP}/cpu/arm/mmp2/lcd.fth + : display-on + init-lcd + fb-pa hdisp vdisp * >bytes h# ff fill + ; + : map-frame-buffer ( -- ) + fb-pa to frame-buffer-adr + ; + " display" device-type + " ISO8859-1" encode-string " character-set" property + 0 0 encode-bytes " iso6429-1983-colors" property + + : display-install ( -- ) + display-on + default-font set-font + map-frame-buffer + width height ( width height ) + over char-width / over char-height / ( width height rows cols ) + /scanline depth fb-install ( ) + ; + + : display-remove ( -- ) ; + : display-selftest ( -- failed? ) false ; + + ' display-install is-install + ' display-remove is-remove + ' display-selftest is-selftest +end-package +devalias screen /screen + +devalias keyboard /keyboard + +fload ${BP}/ofw/termemu/cp881-16.fth + +d# 3000 to ms-factor + +fload ${BP}/cpu/arm/mmp2/sdhcimmp2.fth + +devalias ext /sd/disk@1 +
Modified: cpu/arm/mmp2/dsi.fth ============================================================================== --- cpu/arm/mmp2/dsi.fth Fri Jul 9 06:25:07 2010 (r1864) +++ cpu/arm/mmp2/dsi.fth Tue Jul 13 09:24:52 2010 (r1865) @@ -1,8 +1,6 @@ -h# 004c constant pmua_display1_clk_res_ctrl_offset \ DISPLAY1 Clock/Reset Control Register -h# 0110 constant pmua_display2_clk_res_ctrl_offset \ DISPLAY2 Clock/Reset Control Register -h# 0050 constant pmua_ccic_clk_res_ctrl_offset \ CCIC Clock/Reset Control Register - - +h# 004c constant pmua_display1_clk_res_ctrl_offset \ DISPLAY1 Clock/Reset Control Register +h# 0110 constant pmua_display2_clk_res_ctrl_offset \ DISPLAY2 Clock/Reset Control Register +h# 0050 constant pmua_ccic_clk_res_ctrl_offset \ CCIC Clock/Reset Control Register
: pmua@ ( offset -- n ) pmua-pa + l@ ; : pmua! ( n offset -- ) pmua-pa + l! ; @@ -15,6 +13,7 @@ ; : dsi-twsi@ ( reg# -- l ) wbsplit 2 4 twsi-get bljoin ; : dsi-twsi-w@ ( reg# -- w ) wbsplit 2 2 twsi-get bwjoin ; + : dsi1! ( n offset -- ) dsi1-pa + l! ; : dsi1@ ( n offset -- ) dsi1-pa + l@ ; : dsi2! ( n offset -- ) dsi2-pa + l! ; @@ -41,9 +40,9 @@ \ Disable DSI 0 h# 00 dsi1! \ Stop the interface h# c000.0000 dsi1-pa h# 00 + bitset - 1 ms + 2 ms h# c000.0000 dsi1-pa h# 00 + bitclr - 1 ms + 2 ms d# 83 gpio-clr 1 ms d# 83 gpio-set 1 ms \ LCD_RST_N line resets DSI bridge
5 set-address h# 16 set-slave \ TWSI address of TC358762 MIPI DSI bridge @@ -138,6 +137,8 @@ vdisp 2- wljoin h# 118 dsi1! \ DSI_LCD1_TIMING_2 ; + +[ifdef] debug-dsi : .dsi ( index -- ) dup 3 u.r space dsi-twsi@ 8 u.r cr ; : .dsiw ( index -- ) dup 3 u.r space dsi-twsi-w@ 8 u.r cr ; : dump-dsi ( -- ) @@ -168,6 +169,8 @@ 430 .dsiw 432 .dsiw ; +[then] + [ifdef] support-low-speed-dsi : parity ( n -- 0|1 ) dup d# 16 rshift xor @@ -232,6 +235,7 @@ ;
[then] + [ifdef] use-dsi2 : set-dsi-data ( l index -- ) swap h# 30 dsi! ( index ) \ Data register @@ -345,6 +349,7 @@
; : dsi-read ( -- n ) h# 64 dsi2@ ; + : dsi-lcd ( enable? -- ) 0 dsi1@ 7 invert and 0 dsi1! \ Disable all panels h# 4c pmua@ 2 invert and h# 4c pmua! \ stop clock?
Added: cpu/arm/mmp2/fw.bth ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ cpu/arm/mmp2/fw.bth Tue Jul 13 09:24:52 2010 (r1865) @@ -0,0 +1,524 @@ +purpose: Build Open Firmware for Marvell MMP2 +\ See license at end of file + +dictionary: ${BP}/cpu/arm/build/basefw.dic +command: &armforth &dictionary &this +build-now + +" fw.tag" r/w create-file drop tag-file ! + +hex +\ ' $report-name is include-hook +' noop is include-hook + +fload ${BP}/cpu/arm/mmp2/config.fth + +: headerless ; : headers ; : headerless0 ; + +' (quit) to quit + +: \Tags [compile] \ ; immediate +: \NotTags [compile] \ ; immediate + +: RAMbase ( -- adr ) fw-virt-base ; +: RAMtop ( -- adr ) RAMbase /fw-ram + ; + +def-load-base ' load-base set-config-int-default + +use-movable-vector-base \ Marvell CPU core has a movable vector base + +true ' fcode-debug? set-config-int-default +\ false ' auto-boot? set-config-int-default + + + +[ifdef] serial-console +" com1" ' output-device set-config-string-default +" com1" ' input-device set-config-string-default +[then] + + +fload ${BP}/cpu/arm/mmp2/rootnode.fth \ Root node mapping - physical mode +dev / + " Marvell,Bonnell" model + " Marvell,Armada 610" encode-string " architecture" property +\ The clock frequency of the root bus may be irrelevant, since the bus is internal to the SOC +\ d# 1,000,000,000 " clock-frequency" integer-property +device-end + +: (cpu-arch ( -- adr len ) + " architecture" ['] root-node get-package-property drop + get-encoded-string +; +' (cpu-arch to cpu-arch + +\ Memory management services +[ifdef] virtual-mode +fload ${BP}/ofw/core/clntmem1.fth \ client services for memory +[else] +fload ${BP}/ofw/core/clntphy1.fth \ client services for memory +: >physical ( va -- pa ) + dup fw-virt-base - fw-virt-size u< if ( va ) + fw-virt-base - fw-pa + + then +; +[then] +fload ${BP}/ofw/core/memlist.fth \ Resource list common routines +fload ${BP}/ofw/core/showlist.fth \ Linked list display tool +fload ${BP}/ofw/core/allocph1.fth \ S Physical memory allocator +fload ${BP}/ofw/core/availpm.fth \ Available memory list + +fload ${BP}/cpu/arm/mmp2/probemem.fth \ Memory probing + +stand-init: Probing memory + " probe" memory-node @ $call-method +; + +[ifdef] virtual-mode +fload ${BP}/cpu/arm/loadvmem.fth \ /mmu node +stand-init: MMU + " /mmu" open-dev mmu-node ! +; +fload ${BP}/ofw/core/initdict.fth \ Dynamic dictionary allocation +fload ${BP}/arch/arm/loadarea.fth \ Allocate and map program load area +[else] +fload ${BP}/cpu/arm/mmp2/mmuon.fth +[then] + +\ XXX should be elsewhere +dev /client-services +: chain ( len args entry size virt -- ) + release ( len args entry ) + h# 8000 alloc-mem h# 8000 + (init-program) ( len args ) + to r1 to r2 + go +; +device-end + +fload ${BP}/cpu/arm/crc32.fth \ Assembly language Zip CRC calculation +fload ${BP}/forth/lib/crc32.fth \ High-level portion of CRC calculation + +[ifdef] resident-packages + +\needs unix-seconds> fload ${BP}/ofw/fs/unixtime.fth \ Unix time calculation +support-package: ext2-file-system + fload ${BP}/ofw/fs/ext2fs/ext2fs.fth \ Linux file system +end-support-package + +[ifdef] jffs2-support +\needs unix-seconds> fload ${BP}/ofw/fs/unixtime.fth \ Unix time calculation +support-package: jffs2-file-system + fload ${BP}/ofw/fs/jffs2/jffs2.fth \ Journaling flash file system 2 +end-support-package +[then] + +support-package: zip-file-system + fload ${BP}/ofw/fs/zipfs.fth \ Zip file system +end-support-package + +support-package: dropin-file-system + fload ${BP}/ofw/fs/dropinfs.fth \ Dropin file system +end-support-package +[then] + +fload ${BP}/ofw/core/osfile.fth \ For testing + +\ Load file format handlers + +: call32 ; + +fload ${BP}/ofw/core/allocsym.fth \ Allocate memory for symbol table +fload ${BP}/ofw/core/symcif.fth +fload ${BP}/ofw/core/symdebug.fth +: release-load-area ( boundary-adr -- ) drop ; + +[ifdef] use-elf +fload ${BP}/ofw/elf/elf.fth +fload ${BP}/ofw/elf/elfdebug.fth +[ifdef] virtual-mode +\ Depends on the assumption that physical memory is mapped 1:1 already +: (elf-map-in) ( va size -- ) 0 mem-claim drop ; +[else] +: (elf-map-in) ( va size -- ) 2drop ; +[then] +' (elf-map-in) is elf-map-in +[then] + +\ Reboot and re-entry code +fload ${BP}/ofw/core/reboot.fth \ Restart the client program +fload ${BP}/ofw/core/reenter.fth \ Various entries into Forth + +headerless +[ifdef] virtual-mode +: (initial-heap) ( -- adr len ) sp0 @ ps-size - dict-limit tuck - ; +[else] +: (initial-heap) ( -- adr len ) RAMtop heap-size ; +[then] +' (initial-heap) is initial-heap +headers + +" /openprom" find-device + " FirmWorks,3.0" encode-string " model" property +device-end + +[ifdef] virtual-mode +fload ${BP}/cpu/arm/mmusetup.fth \ Initial values for MMU lists +[then] + +: background-rgb ( -- r g b ) h# ff h# ff h# ff ; + +fload ${BP}/cpu/arm/mmp2/devices.fth + +[ifndef] virtual-mode +warning off +: stand-init-io + stand-init-io + go-fast \ From mmuon.fth +; +warning on +[then] + +true ' local-mac-address? set-config-int-default +[ifdef] resident-packages +support-package: nfs + fload ${BP}/ofw/fs/nfs/loadpkg.fth +end-support-package + +[then] +devalias nfs net//obp-tftp:last//nfs + +fload ${BP}/cpu/arm/linux.fth +d# 2382 to arm-linux-machine-type \ Marvell Jasper + +\ Add a tag describing the linear frame buffer +: mmp-fb-tag, ( -- ) + 8 tag-l, + h# 54410008 tag-l, \ ATAG_VIDEOLFB + d# 800 tag-w, \ Width + d# 480 tag-w, \ Height + d# 24 tag-w, \ Depth + d# 800 3 * tag-w, \ Pitch + fb-pa tag-l, \ Base address + d# 800 3 * d# 480 * tag-l, \ Total size - perhaps could be larger + 8 tag-b, \ Red size + d# 0 tag-b, \ Red position + 8 tag-b, \ Green size + d# 8 tag-b, \ Green position + 8 tag-b, \ Blue size + d# 16 tag-b, \ Blue position + 0 tag-b, \ Rsvd size + d# 24 tag-b, \ Rsvd position +; +\ ' mmp-fb-tag, to fb-tag, + +\ fload ${BP}/cpu/arm/mmp2/usb.fth + +false to stand-init-debug? +\ true to stand-init-debug? + +: protect-fw ( -- ) ; +: usb-power-on ( -- ) ; + +hex +: i-key-wait ( ms -- pressed? ) + cr ." Type 'i' to interrupt stand-init sequence" cr ( ms ) + 0 do + ukey? if + ukey upc ascii I = if true unloop exit then + then + 1 ms + loop + false +; + +warning @ warning off +: init +\ initial-heap add-memory + init + + standalone? if + disable-interrupts +[ifdef] notdef + d# 1000 + i-key-wait if +\ protect-fw + ." Interacting" cr hex interact + then + \ Turn on USB power here to overlap the time with other startup actions + usb-power-on +[then] + then +; +warning ! +[then] + +: (.firmware) ( -- ) + ." Open Firmware " .built cr + ." Copyright 2010 FirmWorks All Rights Reserved" cr +; +' (.firmware) to .firmware + +fload ${BP}/ofw/gui/bmptools.fth +fload ${BP}/dev/null.fth +fload ${BP}/ofw/core/bailout.fth + +\ GUI +false value gui-safeboot? + +: 2tuck ( d1 d2 -- d2 d1 d2 ) 2swap 2over ; +: user-ok "ok" ; \ This is supposed to check for authorization +true value user-mode? + +fload ${BP}/ofw/gui/loadmenu.fth +\ fload ${BP}/ofw/gui/insticon.fth + +\ Uninstall the diag menu from the general user interface vector +\ so exiting from emacs doesn't invoke the diag menu. +' quit to user-interface + +: screen-#lines ( -- n ) + screen-ih 0= if default-#lines exit then + screen-ih package( #lines )package +; +' screen-#lines to lines/page + +true value text-on? +: text-off ( -- ) + text-on? if + screen-ih remove-output + false to text-on? + then +; +: text-on ( -- ) + text-on? 0= if + screen-ih add-output + cursor-on + true to text-on? + then +; + +fload ${BP}/cpu/x86/pc/olpc/help.fth + +[ifdef] notyet +fload ${BP}/cpu/x86/pc/olpc/gamekeys.fth + +: emacs ( -- ) + false to already-go? + boot-getline to boot-file " rom:emacs" $boot +; + +fload ${BP}/ofw/gui/ofpong.fth +fload ${BP}/cpu/x86/pc/olpc/life.fth +[then] + +" u:\boot\olpc.fth ext:\boot\olpc.fth int:\boot\olpc.fth ext:\zimage /prober /usb/ethernet /usb/wlan" + ' boot-device set-config-string-default + +\needs ramdisk " " d# 128 config-string ramdisk +" " ' boot-file set-config-string-default \ Let the boot script set the cmdline + +\ Eliminate 4 second delay in install console for the case where +\ there is no keyboard. The delay is unnecessary because the screen +\ does not go blank when the device is closed. +patch drop ms install-console + +alias reboot bye + +alias crcgen drop ( crc byte -- crc' ) + +\ Dictionary growth size for the ARM Image Format header +\ 1 section before origin section table +h# 10.0000 h# 8000 - h# 4000 - dictionary-size ! + +fload ${BP}/cpu/arm/saverom.fth \ Save the dictionary for standalone startup + +fload ${BP}/forth/lib/selstr.fth + +fload ${BP}/ofw/inet/loadtcp.fth + +support-package: http + fload ${BP}/ofw/inet/http.fth \ HTTP client +end-support-package + +[ifdef] notyet +fload ${BP}/cpu/x86/pc/olpc/memtest.fth +[then] + +[ifdef] notyet +fload ${BP}/ofw/wifi/wifi-cfg.fth +support-package: supplicant +fload ${BP}/ofw/wifi/loadpkg.fth +end-support-package + +: ofw-ssids ( -- $ ) " OFWSSID" ; +' ofw-ssids to default-ssids +[then] + +fload ${BP}/ofw/inet/sntp.fth +: olpc-ntp-servers ( -- ) + " DHCP time 172.18.0.1 0.pool.ntp.org 1.pool.ntp.org 2.pool.ntp.org" +; +' olpc-ntp-servers to ntp-servers +: ntp-time&date ( -- s m h d m y ) + ntp-timestamp abort" Can't contact NTP server" + ntp>time&date +; +: .clock ( -- ) + time&date .date space .time ." UTC" cr +; +: ntp-set-clock ( -- ) + ntp-time&date " set-time" clock-node @ $call-method + .clock +; + +[ifdef] use-ppp +fload ${BP}/ofw/ppp/loadppp.fth +[then] + +" dhcp" ' ip-address set-config-string-default + +[ifdef] notyet +: c1-idle ( -- ) interrupts-enabled? if halt then ; +' c1-idle to stdin-idle +[then] + +fload ${BP}/ofw/core/countdwn.fth \ Startup countdown + +: console-start ( -- ) + install-mux-io +\ cursor-off + true to text-on? + + " //null" open-dev to null-ih \ For text-off state +; + +: interpreter-init ( -- ) + hex + warning on + only forth also definitions + +\ install-alarm + + page-mode + #line off + +\ .built cr +; + +[ifdef] notyet +: ?games ( -- ) + rocker-right game-key? if + protect-fw + time&date 5drop 1 and if + ['] pong guarded + else + ['] life-demo guarded + then + power-off + then +; +: ?diags ( -- ) + rocker-left game-key? if + protect-fw + text-on " test-all" ['] eval guarded + ." Tests complete - powering off" cr d# 5000 ms power-off + then +; + +: ?scan-nand ( -- ) + rocker-up game-key? if + protect-fw text-on ['] scan-nand guarded + then +; +: ?fs-update ( -- ) + button-check button-x or button-o or button-square or ( mask ) + game-key-mask = if protect-fw try-fs-update then +; +[then] + +: startup ( -- ) + standalone? 0= if exit then + +\ block-exceptions + no-page + + console-start + +[ifdef] notyet + read-game-keys +[then] + +\ text-off + + " probe-" do-drop-in + +[ifdef] notyet + sound + ?games +[then] + + ['] false to interrupt-auto-boot? +[ifdef] probe-usb + probe-usb + report-disk + report-keyboard +[then] + " probe+" do-drop-in + + interpreter-init +[ifdef] notyet + ?scan-nand + ?diags + ?fs-update +[then] +\ unblock-exceptions + ['] (interrupt-auto-boot?) to interrupt-auto-boot? +\ ?usb-keyboard + auto-banner? if banner then + + auto-boot + + cr cr + + quit +; + +\ This helps with TeraTerm, which sends ESC-O as the arrow key prefix +also hidden also keys-forth definitions +warning @ warning off +: esc-o key lastchar ! [""] esc-[ do-command ; +warning ! +previous previous definitions + +tag-file @ fclose tag-file off + +.( --- Saving fw.dic ...) +" fw.dic" $save-forth cr + +fload ${BP}/cpu/arm/mmp2/boot.fth + +.( --- Saving ofw.rom --- ) cr " ofw.rom" $save-rom + +\ LICENSE_BEGIN +\ Copyright (c) 2010 FirmWorks +\ +\ Permission is hereby granted, free of charge, to any person obtaining +\ a copy of this software and associated documentation files (the +\ "Software"), to deal in the Software without restriction, including +\ without limitation the rights to use, copy, modify, merge, publish, +\ distribute, sublicense, and/or sell copies of the Software, and to +\ permit persons to whom the Software is furnished to do so, subject to +\ the following conditions: +\ +\ The above copyright notice and this permission notice shall be +\ included in all copies or substantial portions of the Software. +\ +\ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +\ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +\ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +\ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +\ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +\ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +\ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +\ +\ LICENSE_END
Modified: cpu/arm/mmp2/lcd.fth ============================================================================== --- cpu/arm/mmp2/lcd.fth Fri Jul 9 06:25:07 2010 (r1864) +++ cpu/arm/mmp2/lcd.fth Tue Jul 13 09:24:52 2010 (r1865) @@ -1,3 +1,4 @@ + : lcd@ ( offset -- l ) lcd-pa + l@ ; : lcd! ( l offset -- ) lcd-pa + l! ;
@@ -52,9 +53,9 @@ ;
: init-lcd ( -- ) - 0 h# 190 lcd! \ Disable LCD DMA controller - fb-pa h# f4 lcd! \ Frame buffer area 0 - 0 h# f8 lcd! \ Frame buffer area 1 + 0 h# 190 lcd! \ Disable LCD DMA controller + fb-pa h# f4 lcd! \ Frame buffer area 0 + 0 h# f8 lcd! \ Frame buffer area 1 hdisp bytes/pixel * h# fc lcd! \ Pitch in bytes
hdisp vdisp wljoin dup h# 104 lcd! dup h# 108 lcd! h# 118 lcd! \ size, size after zoom, disp @@ -65,8 +66,8 @@ hbp >chunks wljoin h# 11c lcd!
vfp vbp wljoin h# 120 lcd! - h# 2000FF00 h# 194 lcd! \ DMA CTRL 1 - h# d h# 1b8 lcd! \ Dumb panel controller + h# 2000FF00 h# 194 lcd! \ DMA CTRL 1 + h# d h# 1b8 lcd! \ Dumb panel controller h# 01330133 h# 13c lcd! \ Panel VSYNC Pulse Pixel Edge Control h# 40001108 h# 1a8 lcd! \ Clock divider h# 00021100 h# 190 lcd! \ DMA CTRL 0 - enable DMA, 24 bpp mode
Modified: cpu/arm/mmp2/lcdcfg.fth ============================================================================== --- cpu/arm/mmp2/lcdcfg.fth Fri Jul 9 06:25:07 2010 (r1864) +++ cpu/arm/mmp2/lcdcfg.fth Tue Jul 13 09:24:52 2010 (r1865) @@ -17,3 +17,8 @@
: >bytes ( pixels -- chunks ) bytes/pixel * ; : >chunks ( pixels -- chunks ) >bytes #lanes / ; + +alias width hdisp +alias height vdisp +alias depth bpp +width >bytes constant /scanline
Modified: cpu/arm/mmp2/mmp2.bth ============================================================================== --- cpu/arm/mmp2/mmp2.bth Fri Jul 9 06:25:07 2010 (r1864) +++ cpu/arm/mmp2/mmp2.bth Tue Jul 13 09:24:52 2010 (r1865) @@ -21,6 +21,10 @@
fload ${BP}/forth/lib/sysuart.fth \ Set console I/O vectors to UART
+0 value keyboard-ih +0 value screen-ih + +fload ${BP}/ofw/core/muxdev.fth \ I/O collection/distribution device
\ Install the simple UART driver from the standalone I/O init chain : stand-init-io ( -- ) @@ -38,6 +42,9 @@ fload ${BP}/cpu/arm/mmp2/virtaddr.fth \ Virtual addresses for the firmware
fload ${BP}/cpu/arm/mmp2/addrs.fth + +fload ${BP}/cpu/arm/mmp2/mmuon.fth + fload ${BP}/cpu/arm/mmp2/twsi.fth fload ${BP}/cpu/arm/mmp2/timer.fth fload ${BP}/cpu/arm/mmp2/mfpr.fth @@ -50,16 +57,11 @@ init-twsi power-on-dsi ; -fload ${BP}/cpu/arm/mmp2/gpio.fth -fload ${BP}/cpu/arm/mmp2/lcdcfg.fth -fload ${BP}/cpu/arm/mmp2/dsi.fth -fload ${BP}/cpu/arm/mmp2/lcd.fth -: display-on +stand-init: init-stuff - init-lcd - fb-pa hdisp vdisp * >bytes h# ff fill ;
+fload ${BP}/cpu/arm/mmp2/gpio.fth
\ fload ${BP}/cpu/arm/rootnode.fth \ Root node mapping fload ${BP}/cpu/arm/mmp2/rootnode.fth \ Root node mapping - physical mode @@ -100,15 +102,50 @@ " FirmWorks,3.0" encode-string " model" property device-end
+fload ${BP}/cpu/arm/mmp2/watchdog.fth \ reset-all using watchdog timer + +0 0 " d420b000" " /" begin-package + " screen" name + fload ${BP}/cpu/arm/mmp2/lcdcfg.fth + fload ${BP}/cpu/arm/mmp2/dsi.fth + + fload ${BP}/cpu/arm/mmp2/lcd.fth + : display-on + init-lcd + fb-pa hdisp vdisp * >bytes h# ff fill + ; + : map-frame-buffer ( -- ) + fb-pa to frame-buffer-adr + ; + " display" device-type + " ISO8859-1" encode-string " character-set" property + 0 0 encode-bytes " iso6429-1983-colors" property + + : display-install ( -- ) + display-on + default-font set-font + map-frame-buffer + width height ( width height ) + over char-width / over char-height / ( width height rows cols ) + /scanline depth fb-install ( ) + ; + + : display-remove ( -- ) ; + : display-selftest ( -- failed? ) false ; + + ' display-install is-install + ' display-remove is-remove + ' display-selftest is-selftest +end-package + +fload ${BP}/ofw/termemu/cp881-16.fth + \ fload ${BP}/arch/dna/mmusetup.fth \ Initial values for MMU lists
\ fload ${BP}/arch/dna/boot.fth
\ false ' auto-boot? set-config-int-default
-\ 1 section before origin section table -h# 10.0000 h# 8000 - h# 4000 - dictionary-size ! - \ dev /mmu \ patch instruction! l! section! \ device-end @@ -128,6 +165,10 @@
tag-file @ fclose tag-file off
+\ Dictionary growth size for the ARM Image Format header +\ 1 section before origin section table +h# 10.0000 h# 8000 - h# 4000 - dictionary-size ! + fload ${BP}/cpu/arm/saverom.fth \ Save the dictionary for standalone startup
.( --- Saving mmp2.dic --- ) cr " mmp2.dic" $save-forth
Added: cpu/arm/mmp2/mmuon.fth ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ cpu/arm/mmp2/mmuon.fth Tue Jul 13 09:24:52 2010 (r1865) @@ -0,0 +1,67 @@ +code page-table! ( padr -- ) + mcr p15,0,tos,2,0,0 + pop tos,sp +c; +code page-table@ ( -- padr ) + psh tos,sp + mrc p15,0,tos,2,0,0 + mov tos,tos,lsr #14 \ Clear low bits which read unpredictably + mov tos,tos,lsl #14 +c; + + +: map-section ( pa+mode va -- ) + d# 18 rshift page-table@ + l! +; +: map-sections ( pa mode va size -- ) + 2>r + 2 or 2r> ( pa+mode va size ) + bounds ?do ( pa+mode ) + dup i map-section ( pa+mode ) + /section + ( pa+mode' ) + /section +loop ( pa+mode ) + drop +; + +: setup-sections + page-table-pa page-table! + page-table-pa /page-table erase + + h# 0000.0000 h# c0e 0 fb-pa map-sections \ Cache and write bufferable + fb-pa h# c06 fb-pa fb-size map-sections \ Write bufferable + h# d400.0000 h# c02 h# d400.0000 h# 0100.0000 map-sections \ I/O - no caching or buffering +; +\ Do we need to map SRAM and DDRC ? + +code start-mmu + set r2, 0xFFFFFFFF \ Set domains for Manager access + mcr p15,0,r2,3,0,0 \ Update register 3 in CP15 + + \ Enable the MMU + mrc p15, 0, r2, 1, 0, 0 \ Read current settings in control reg + mov r2, r2, LSL #18 \ Upper 18-bits must be written as zero, + mov r2, r2, LSR #18 \ ... clear them now. + + orr r2, r2, 0x200 \ Set the ROM Protection bit + bic r2, r2, 0x100 \ Clear the System Protection bit + orr r2, r2, 0x001 \ Set the MMU bit + + ahead + forth + begin here h# 1f and while 0 c, repeat + assembler + then + + mcr p15, 0, r2, 1, 0, 0 \ Go Virtual - Wheeeeeee! + mrc p15, 0, r2, 2, 0, 0 \ Insure that the write completes + mov r2, r2 \ before continuing + sub pc, pc, #4 +c; + +: go-fast + setup-sections + start-mmu + dcache-on + icache-on + d# 400,000 to ms-factor + d# 400 to us-factor +;
Modified: cpu/arm/mmp2/probemem.fth ============================================================================== --- cpu/arm/mmp2/probemem.fth Fri Jul 9 06:25:07 2010 (r1864) +++ cpu/arm/mmp2/probemem.fth Tue Jul 13 09:24:52 2010 (r1865) @@ -16,7 +16,7 @@
headers : probe ( -- ) - 0 sdram-size log&release + 0 available-ram-size log&release
0 0 encode-bytes ( adr 0 ) physavail ['] make-phys-memlist find-node ( adr len prev 0 )
Modified: cpu/arm/mmp2/rootnode.fth ============================================================================== --- cpu/arm/mmp2/rootnode.fth Fri Jul 9 06:25:07 2010 (r1864) +++ cpu/arm/mmp2/rootnode.fth Tue Jul 13 09:24:52 2010 (r1865) @@ -12,6 +12,7 @@ extend-package
1 encode-int " #address-cells" property +1 encode-int " #size-cells" property
hex
Added: cpu/arm/mmp2/watchdog.fth ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ cpu/arm/mmp2/watchdog.fth Tue Jul 13 09:24:52 2010 (r1865) @@ -0,0 +1,61 @@ +\ See license at end of file +purpose: System reset using the watchdog timer + +: enable-wdt-clock + main-pmu-pa h# 1020 + dup l@ h# 10 or swap l! \ enable wdt 2 clock PMUM_PRR_PJ + 7 main-pmu-pa h# 200 + l! + 3 main-pmu-pa h# 200 + l! +; + +h# d4080000 value wdt-pa +: (wdt!) ( value offset -- ) wdt-pa + l! ; +: wdt! ( value offset -- ) + h# baba h# 9c (wdt!) h# eb10 h# a0 (wdt!) ( value offset ) + (wdt!) +; +: wdt@ ( offset -- value ) wdt-pa + l@ ; +: (reset-all) ( -- ) + enable-wdt-clock + 2 h# 68 wdt! \ set match register + 3 h# 64 wdt! \ match enable: just interrupt, no reset yet + 1 h# 98 wdt! \ Reset counter + begin again +; +' (reset-all) to reset-all + +stand-init: + ['] reset-all to bye +; + +0 [if] +: test-wdt ( -- ) + enable-wdt-clock + h# 100 h# 68 wdt! \ set match register + 1 h# 64 wdt! \ match enable: just interrupt, no reset yet + h# 6c wdt@ . d# 100 ms h# 6c wdt@ . +; +[then] + +\ LICENSE_BEGIN +\ Copyright (c) 2010 FirmWorks +\ +\ Permission is hereby granted, free of charge, to any person obtaining +\ a copy of this software and associated documentation files (the +\ "Software"), to deal in the Software without restriction, including +\ without limitation the rights to use, copy, modify, merge, publish, +\ distribute, sublicense, and/or sell copies of the Software, and to +\ permit persons to whom the Software is furnished to do so, subject to +\ the following conditions: +\ +\ The above copyright notice and this permission notice shall be +\ included in all copies or substantial portions of the Software. +\ +\ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +\ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +\ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +\ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +\ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +\ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +\ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +\ +\ LICENSE_END
Added: cpu/arm/mmusetup.fth ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ cpu/arm/mmusetup.fth Tue Jul 13 09:24:52 2010 (r1865) @@ -0,0 +1,87 @@ +\ See license at end of file +purpose: Establish the initial values for the MMU and virtual lists + +\ The code in this file depends in detail on the initial MMU setup +\ established by initmmu.fth + +dev /mmu +: st-section ( -- va ) st-va /section round-down ; + +: st-end ( -- ) st-va h# 4000 + ; + +: >p ( va -- pa ) + dup section@ h# fff0.0000 and ( va pa-base ) + swap h# f.f000 and or +; + +: (initial-mmu-setup) ( -- ) \ Locate the section table + fw-virt-base h# 1f.c000 + to st-va +\ fw-virt-base h# ef.c000 + to st-va +; +' (initial-mmu-setup) to initial-mmu-setup + +: (initial-claim) ( -- ) + 0 pagesize claim-virtual drop \ Trap table + fw-virt-base memtop @ over - claim-virtual drop \ Firmware region + st-va st-end over - claim-virtual drop \ Section table +; +' (initial-claim) to initial-claim + +: (initial-map) ( -- ) + 0 >p 0 pagesize h# c map \ Trap vectors R/O +\ fw-virt-base >p fw-virt-base memtop @ over - -1 map \ Firmware + fw-virt-base >p fw-virt-base /section -1 map \ Firmware + + \ Formally establish the pre-existing mapping so it can be released later + st-va >p st-section /section h# c00 map \ section table + + \ Move the section table virtual address to the pocket just above the + \ Forth stacks; typically f70f.c000. + st-section ( old-st-va-bas ) + st-va >p memtop @ h# 4000 h# c00 map \ section table + memtop @ to st-va ( old-st-va-bas ) + ( old-st-va ) /section unmap \ Release old mapping + +[ifdef] io-base + io-base io-base /section -1 map +[then] +; +' (initial-map) to initial-map + +: vectors-rw ( -- ) 0 >p 0 pagesize h# c0c modify ; +: vectors-ro ( -- ) 0 >p 0 pagesize h# c modify ; +: mmu-install-handler ( handler trap# -- ) + vectors-rw hw-install-handler vectors-ro +; + +also forth definitions +: unmap-temp-io ( virt -- ) + dup io-base = if drop else /section unmap then +; +previous definitions +device-end + + +\ LICENSE_BEGIN +\ Copyright (c) 2010 FirmWorks +\ +\ Permission is hereby granted, free of charge, to any person obtaining +\ a copy of this software and associated documentation files (the +\ "Software"), to deal in the Software without restriction, including +\ without limitation the rights to use, copy, modify, merge, publish, +\ distribute, sublicense, and/or sell copies of the Software, and to +\ permit persons to whom the Software is furnished to do so, subject to +\ the following conditions: +\ +\ The above copyright notice and this permission notice shall be +\ included in all copies or substantial portions of the Software. +\ +\ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +\ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +\ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +\ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +\ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +\ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +\ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +\ +\ LICENSE_END
Modified: cpu/arm/saverom.fth ============================================================================== --- cpu/arm/saverom.fth Fri Jul 9 06:25:07 2010 (r1864) +++ cpu/arm/saverom.fth Tue Jul 13 09:24:52 2010 (r1865) @@ -13,6 +13,7 @@
" stand-init-io" $find-name is init-io " stand-init" init-save + " startup" $find drop is cold-hook
aif-header h# 80 2r> $save-image ;
Modified: cpu/arm/tools.bth ============================================================================== --- cpu/arm/tools.bth Fri Jul 9 06:25:07 2010 (r1864) +++ cpu/arm/tools.bth Tue Jul 13 09:24:52 2010 (r1865) @@ -27,6 +27,7 @@
tag-file @ fclose tag-file off
+h# 10.0000 dictionary-size ! .( --- Saving tools.dic --- ) " tools.dic" $save-forth cr [then]
Modified: cpu/arm/traps.fth ============================================================================== --- cpu/arm/traps.fth Fri Jul 9 06:25:07 2010 (r1864) +++ cpu/arm/traps.fth Tue Jul 13 09:24:52 2010 (r1865) @@ -65,8 +65,7 @@ pop tos,sp c;
-h# 80 buffer: ram-vector-base-buf -: move-vector-base ( -- ) ram-vector-base-buf h# 20 round-up vector-base! ; +: move-vector-base ( -- ) h# 80 alloc-mem h# 20 round-up vector-base! ;
\ Execute this at compile time for processors that need it. \ Ideally we would detect the vector base register at run time @@ -76,7 +75,7 @@ ['] move-vector-base to init-vector-base ;
-: stand-init-io ( -- ) +: stand-init-io \ Exception handlers stand-init-io ['] (restart is restart ['] hw-install-handler is install-handler
Modified: forth/kernel/kernel.fth ============================================================================== --- forth/kernel/kernel.fth Fri Jul 9 06:25:07 2010 (r1864) +++ forth/kernel/kernel.fth Tue Jul 13 09:24:52 2010 (r1865) @@ -225,7 +225,7 @@ [ifndef] run-time 0 value "temp headerless -d# 1024 1+ /n-t + constant /stringbuf \ 1024 bytes + /n for length + 1 for null +d# 1024 1+ /n-t + aligned-t constant /stringbuf \ 1024 bytes + /n for length + 1 for null 0 value stringbuf 0 value $buf : init ( -- )
Modified: ofw/core/countdwn.fth ============================================================================== --- ofw/core/countdwn.fth Fri Jul 9 06:25:07 2010 (r1864) +++ ofw/core/countdwn.fth Tue Jul 13 09:24:52 2010 (r1865) @@ -20,6 +20,7 @@ key? if key drop true unloop unloop exit then +[ifndef] install-mux-io [ifdef] ukey ukey? if ukey drop @@ -27,6 +28,7 @@ true unloop unloop exit then [then] +[then]
loop -1 +loop
Added: ofw/core/initdict.fth ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ ofw/core/initdict.fth Tue Jul 13 09:24:52 2010 (r1865) @@ -0,0 +1,86 @@ +\ See license at end of file +purpose: Dynamic allocation of dictionary space + +\ For use in virtual-memory systems in which the Forth dictionary does +\ not have memory preallocated to it, this file establishes a mechanism +\ for allocating physical memory to the dictionary "on demand". + +headerless + +0 value hard-limit \ Absolute maximum top of dictionary (virtual) + +\ Called when ALLOT can't satisfy the request. Allocates some more +\ physical memory for the dictionary, maps it in, and updates limit +\ to include the new memory. + +: extend-dictionary ( size -- size ) + dup pad + d# 100 + ( size top-adr ) + dup hard-limit > if allot-abort then ( size top-adr ) + pagesize round-up limit - >r ( size r: size' ) + r@ pagesize mem-claim ( size phys.. r: size' ) + limit r@ mem-mode mmu-map ( size r: size' ) + limit r> + hard-limit min is limit ( size ) +; + +\ Initially, the dictionary growth space extends from here to limit, +\ and "plenty" of space is available there. After we have initialized +\ the memory allocators and the MMU, we give back anything we're not +\ using, by setting hard-limit to the old limit and setting limit to +\ the next page boundary above here. Later, if we need more dictionary +\ space, allot (via allot-error which we set to execute extend-dictionary) +\ will dynamically allocate additional physical pages as needed. + +: reclaim ( virt len -- ) + >r ( virt r: len ) + dup mmu-translate if ( virt phys.. mode r: len ) + drop ( virt phys.. r: len ) + r@ mem-release ( virt r: len ) + r> mmu-unmap ( ) + else ( virt r: len ) + r> 2drop + then ( ) +; +: init-dictionary ( -- ) + limit pagesize round-down to hard-limit + + \ Put the non-page-aligned fragment above hard-limit in the heap + hard-limit limit over - ( adr len ) + dup if add-memory else 2drop then + + here pagesize round-up to limit + + \ Put the page-aligned unused growth space in the page pool + limit hard-limit over - reclaim + + \ Unmap the page that is below the dictionary + fw-virt-base origin pagesize round-down over - mmu-unmap + + ['] extend-dictionary is allot-error +; +stand-init: Reclaim dictionary + init-dictionary +; +headers +\ LICENSE_BEGIN +\ Copyright (c) 2006 FirmWorks +\ +\ Permission is hereby granted, free of charge, to any person obtaining +\ a copy of this software and associated documentation files (the +\ "Software"), to deal in the Software without restriction, including +\ without limitation the rights to use, copy, modify, merge, publish, +\ distribute, sublicense, and/or sell copies of the Software, and to +\ permit persons to whom the Software is furnished to do so, subject to +\ the following conditions: +\ +\ The above copyright notice and this permission notice shall be +\ included in all copies or substantial portions of the Software. +\ +\ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +\ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +\ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +\ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +\ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +\ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +\ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +\ +\ LICENSE_END
Modified: ofw/core/muxdev.fth ============================================================================== --- ofw/core/muxdev.fth Fri Jul 9 06:25:07 2010 (r1864) +++ ofw/core/muxdev.fth Tue Jul 13 09:24:52 2010 (r1865) @@ -68,6 +68,8 @@ ;
: add-device ( ihandle -- ) + ?dup 0= if exit then ( ihandle ) + /list-node alloc-mem >r ( ihandle r: listnode )
dup r@ >ihandle ! ( ihandle r: listnode ) @@ -112,6 +114,8 @@ ;
: remove-device ( ihandle -- ) + ?dup 0= if exit then ( ihandle ) + >r first-device ( prev r: ihandle )
begin dup >link @ dup while ( prev this r: ihandle )
Added: ofw/core/reboot.fth ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ ofw/core/reboot.fth Tue Jul 13 09:24:52 2010 (r1865) @@ -0,0 +1,62 @@ +\ See license at end of file +purpose: Reboot system: save reboot info in nvram configuration variables + +headerless +: put-env-number ( n name$ -- ) hex rot (.) 2swap (put-ge-var) drop ; +: get-env-number ( name$ -- n ) + hex $getenv if 0 else $number if 0 then then +; + +0 value reboot-info +: +rb ( offset -- adr ) reboot-info + ; +: copy-reboot-info ( -- ) + " reboot-command" $getenv if false to reboot? exit then + + d# 140 alloc-mem to reboot-info + " reboot-command" $getenv if " " then d# 0 +rb place + " reboot-line#" get-env-number d# 132 +rb ! + " reboot-column#" get-env-number d# 136 +rb ! + + " reboot-command" $unsetenv + " reboot-line#" $unsetenv + " reboot-column#" $unsetenv + + true to reboot? +; + +: (save-reboot-info) ( cmd$ line# column# -- ) + " reboot-column#" put-env-number + " reboot-line#" put-env-number + " reboot-command" (put-ge-var) drop +; +' (save-reboot-info) to save-reboot-info + +: (get-reboot-info) ( -- cmd$ line# column# ) + 0 +rb count d# 132 +rb @ d# 136 +rb @ +; +' (get-reboot-info) to get-reboot-info +headers + +\ LICENSE_BEGIN +\ Copyright (c) 2006 FirmWorks +\ +\ Permission is hereby granted, free of charge, to any person obtaining +\ a copy of this software and associated documentation files (the +\ "Software"), to deal in the Software without restriction, including +\ without limitation the rights to use, copy, modify, merge, publish, +\ distribute, sublicense, and/or sell copies of the Software, and to +\ permit persons to whom the Software is furnished to do so, subject to +\ the following conditions: +\ +\ The above copyright notice and this permission notice shall be +\ included in all copies or substantial portions of the Software. +\ +\ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +\ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +\ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +\ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +\ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +\ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +\ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +\ +\ LICENSE_END
Added: ofw/core/reenter.fth ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ ofw/core/reenter.fth Tue Jul 13 09:24:52 2010 (r1865) @@ -0,0 +1,71 @@ +\ See license at end of file +purpose: Handle various kinds of entries into Forth from traps, etc. + +headerless +: .go-message ( -- ) + \ Restarting is only possible if the state that was first saved + \ is from a restartable exception. + state-valid @ -1 = already-go? and if + restartable? on + ." Type 'go' to resume" cr + then +; + +: .entry ( -- ) + talign \ ... in case dp is misaligned + + aborted? @ if + aborted? off hex cr ." Keyboard interrupt" cr .go-message exit + then + + [ also hidden ] (.exception) [ previous ] +; + +headers +stand-init: + ['] .entry is .exception +; + +\ Temporary hacks until we implement these functions correctly + +0 value client-rerun? + +defer user-interface ' quit to user-interface +also client-services definitions +\ " reenter.fth: Implement 'exit' client service correctly" ?reminder +: exit ( -- ) + [ also hidden ] breakpoints-installed off [ previous ] + [ifdef] vector vector off [then] + + " restore" stdout @ ['] $call-method catch if 3drop then + " restore" stdin @ ['] $call-method catch if 3drop then + + client-rerun? 0= to already-go? + user-interface +; +: enter ( -- ) interact ; +previous definitions + +\ LICENSE_BEGIN +\ Copyright (c) 2006 FirmWorks +\ +\ Permission is hereby granted, free of charge, to any person obtaining +\ a copy of this software and associated documentation files (the +\ "Software"), to deal in the Software without restriction, including +\ without limitation the rights to use, copy, modify, merge, publish, +\ distribute, sublicense, and/or sell copies of the Software, and to +\ permit persons to whom the Software is furnished to do so, subject to +\ the following conditions: +\ +\ The above copyright notice and this permission notice shall be +\ included in all copies or substantial portions of the Software. +\ +\ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +\ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +\ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +\ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +\ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +\ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +\ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +\ +\ LICENSE_END
Modified: ofw/gui/iconmenu.fth ============================================================================== --- ofw/gui/iconmenu.fth Fri Jul 9 06:25:07 2010 (r1864) +++ ofw/gui/iconmenu.fth Tue Jul 13 09:24:52 2010 (r1865) @@ -155,6 +155,7 @@ current-sq sq >help 2@ show-description ;
+[ifdef] x86-assembler code expand-rect ( src dst w h --- ) dx pop \ Height of source image in pixels 4 [sp] edi xchg @@ -175,6 +176,7 @@ edi pop \ Restore EDI esi pop \ Restore ESI c; +[then]
: expand-icon ( adr - eadr ) /icon alloc-mem tuck ( eadr adr eadr )
Modified: ofw/termemu/fb8.fth ============================================================================== --- ofw/termemu/fb8.fth Fri Jul 9 06:25:07 2010 (r1864) +++ ofw/termemu/fb8.fth Tue Jul 13 09:24:52 2010 (r1865) @@ -260,6 +260,17 @@ /w +loop ( color mask ) 2drop ( ) ; +[ifdef] t! +: fb24-merge ( color bits dst-adr width -- ) + 3* bounds ?do ( color mask ) + dup h# 80000000 and if ( color mask ) + over i t! ( color mask ) + then ( color mask ) + 3* ( color mask' ) + 3 +loop ( color mask ) + 2drop ( ) +; +[then] : fb32-merge ( color bits dst-adr width -- ) /l* bounds ?do ( color mask ) dup h# 80000000 and if ( color mask ) @@ -329,6 +340,17 @@ ['] colors-565 to fb-16map endof
+[ifdef] fb24-invert + d# 24 of + ['] /t* to pix* + ['] fb24-invert to fb-invert + ['] tfill to fb-fill + ['] fb24-paint to fb-paint + ['] fb24-merge to fb-merge + ['] colors-32bpp to fb-16map + endof +[then] + d# 32 of ['] /l* to pix* ['] fb32-invert to fb-invert
Modified: ofw/wifi/loadpkg.fth ============================================================================== --- ofw/wifi/loadpkg.fth Fri Jul 9 06:25:07 2010 (r1864) +++ ofw/wifi/loadpkg.fth Tue Jul 13 09:24:52 2010 (r1865) @@ -1,7 +1,9 @@ purpose: Load file for supplicant support package
\ Encryption/decryption +[ifdef] 386-assembler fload ${BP}/ofw/wifi/sha1.fth +[then] fload ${BP}/ofw/wifi/aes.fth fload ${BP}/ofw/wifi/md5.fth fload ${BP}/ofw/wifi/rc4.fth