Author: quozl
Date: Sat Jul 17 04:43:16 2010
New Revision: 1884
URL: http://tracker.coreboot.org/trac/openfirmware/changeset/1884
Log:
test commit access to repository
add period to end of comment in version file
Modified:
cpu/x86/pc/olpc/via/fw-version.fth
Modified: cpu/x86/pc/olpc/via/fw-version.fth
==============================================================================
--- cpu/x86/pc/olpc/via/fw-version.fth Sat Jul 17 02:36:20 2010 (r1883)
+++ cpu/x86/pc/olpc/via/fw-version.fth Sat Jul 17 04:43:16 2010 (r1884)
@@ -1,3 +1,3 @@
-\ The overall firmware revision
+\ The overall firmware revision.
macro: FW_MAJOR A
macro: FW_MINOR 43
Author: wmb
Date: Fri Jul 16 21:44:16 2010
New Revision: 1882
URL: http://tracker.coreboot.org/trac/openfirmware/changeset/1882
Log:
OLPC trac 10236 - in "test /audio" on XO-1.5, make the recorded sound play back on both speakers.
Modified:
dev/geode/ac97/selftest.fth
Modified: dev/geode/ac97/selftest.fth
==============================================================================
--- dev/geode/ac97/selftest.fth Thu Jul 15 20:38:18 2010 (r1881)
+++ dev/geode/ac97/selftest.fth Fri Jul 16 21:44:16 2010 (r1882)
@@ -18,14 +18,19 @@
d# 250 ms \ Settling time for DC offset filter
;
+\ We record in stereo even thought there is probably only one mic.
+\ For some systems (e.g. AD1888 AC97 CODEC on XO-1), the data from the one
+\ mic appears in both left and right channels. For others (e.g.
+\ Conexant HDaudio CODEC on XO-1.5), the mic data appears in only the
+\ left channel. We take care of that later in "mic-test".
: record ( -- )
- open-in establish-level
+ open-in stereo establish-level
record-base record-len audio-in drop
close-in
;
: play ( -- )
- open-out
+ open-out stereo
record-base record-len audio-out drop write-done
;
@@ -169,11 +174,22 @@
d# -9 set-volume stereo play
;
+\ Duplicate left channel data into the right channel
+: copy-left-to-right ( adr len -- )
+ bounds ?do i w@ i wa1+ w! /l +loop
+;
+
+\ The recording data format is stereo, but usually there is only one mic.
+\ Depending on the CODEC used, the right channel of the recording is either
+\ the same as the left or quiet. In this test, we use copy-left-to-right
+\ to propagate the left input into both channels for playback.
+
: mic-test ( -- )
." Recording ..." cr
- mono record
+ record
+ record-base record-len copy-left-to-right
." Playing ..." cr
- d# -3 set-volume mono play
+ d# -3 set-volume play
;
: selftest ( -- error? )
Author: wmb
Date: Thu Jul 15 20:27:57 2010
New Revision: 1880
URL: http://tracker.coreboot.org/trac/openfirmware/changeset/1880
Log:
Added sparse.c and sparseosfile.fth to svn. They are tools that can be loaded as needed to work on large but sparsely-populated disk images without using up huge amounts of disk space on the host.
Added:
ofw/core/sparse.c
ofw/core/sparseosfile.fth
Added: ofw/core/sparse.c
==============================================================================
--- /dev/null 00:00:00 1970 (empty, because file is newly added)
+++ ofw/core/sparse.c Thu Jul 15 20:27:57 2010 (r1880)
@@ -0,0 +1,47 @@
+// Create a sparse disk image file that can be accessed from OFW
+// running under Linux using /sparseosfile, after loading sparseosfile.fth
+#include <unistd.h>
+#include <sys/stat.h>
+#include <fcntl.h>
+
+#define BLKLEN 4096
+char buf[BLKLEN];
+int blen = BLKLEN;
+
+int allzero(char *buf, size_t len)
+{
+ long *p = (long *)buf;
+ len /= sizeof(long);
+ while (len--)
+ if(*p++)
+ return 0;
+ return 1;
+}
+
+int blockmap[10000];
+
+main(int argc, char **argv)
+{
+ int abs_blockno = 0;
+ int rel_blockno = 0;
+ int outfile;
+
+ outfile = creat("outfile", 0666);
+ if (outfile < 0) {
+ perror("sparse");
+ (void)exit(1);
+ }
+
+ while(read(0, buf, BLKLEN) == BLKLEN) {
+ if (!allzero(buf, BLKLEN)) {
+ write(outfile, buf, BLKLEN);
+ blockmap[rel_blockno++] = abs_blockno;
+ }
+ abs_blockno++;
+ }
+ write(outfile, blockmap, rel_blockno*sizeof(int));
+ write(outfile, &rel_blockno, sizeof(int));
+ write(outfile, &abs_blockno, sizeof(int));
+ write(outfile, &blen, sizeof(int));
+ close(outfile);
+}
Added: ofw/core/sparseosfile.fth
==============================================================================
--- /dev/null 00:00:00 1970 (empty, because file is newly added)
+++ ofw/core/sparseosfile.fth Thu Jul 15 20:27:57 2010 (r1880)
@@ -0,0 +1,313 @@
+purpose: Device tree node that accesses a host system file
+\ See license at end of file
+
+\ Creates a device node named "/sparsefile", of device-type "block", which
+\ accesses an operating system file named by its first argument. That
+\ file contains a verbatim disk image in the following sparse format:
+\
+\ Images: N block images
+\ Map: N integers indicating the block number of the corresponding block image
+\ N: integer denoting N
+\ Max: integer denoting the maximum block number for the virtual disk
+\ BlockSize: integer denoting the length of each block image
+
+\ Backslash (\) characters in the file name are translated to
+\ the underlying operating system's directory delimiter.
+\ Example: dir /osfile:\dev\rfd0,\boot\test.fth
+\ Example: dir /osfile:\home\wmb\fs.img,\boot\test.fth
+\ As an alternative to supplying the disk image filename in the device
+\ specifier, you can set "osfile$" to return the name. This is
+\ helpful for cases where the image filename would interfere with
+\ the parsing of later parts of the device specifier.
+\ Example:
+\ dev /osfile
+\ : disk-image$ " /tmp/disk.img" ;
+\ ' disk-image$ to osfile$
+\ dend
+\ dir /osfile:\boot\test.fth
+\ When using the "osfile$" method, you can use either backslash (\) or
+\ the system's native delimiter in the disk image filename. When using
+\ the device specifier argument method, you must use backslash, because
+\ forward slash delimits major device tree components in a device specifier.
+
+dev /
+\ : open true ; : close ;
+
+new-device
+" sparsefile" device-name
+also
+defer sparsefile$ ' null$ to sparsefile$
+0 value file#
+
+\ The deblocker converts a block/record-oriented interface to a byte-oriented
+\ interface, using internal buffering. Disk and tape devices are usually
+\ block or record oriented, but the Open Firmware external interface is
+\ byte-oriented, in order to be independent of particular device block sizes.
+
+0 value deblocker
+: init-deblocker ( -- okay? )
+ " " " deblocker" $open-package is deblocker
+ deblocker if
+ true
+ else
+ ." Can't open deblocker package" cr false
+ then
+;
+
+0 instance value label-package
+0 instance value offset-low
+0 instance value offset-high
+
+: init-label-package ( adr len -- okay? )
+ 0 is offset-high 0 is offset-low
+\ iso9660-file-system
+ " disk-label" $open-package is label-package
+ label-package if
+ 0 0 " offset" label-package $call-method is offset-high is offset-low
+ true
+ else
+ ." Can't open disk label package" cr false
+ then
+;
+: convert/ ( filename$ -- )
+ bounds ?do
+ i c@ [char] \ = if [char] / i c! then
+ loop
+;
+: $fopen ( adr len -- fd ) $cstr 2 swap 8 syscall 2drop retval ;
+: do-seek ( offset whence -- error? ) swap file# _lseek nip ;
+: do-write ( adr len -- error? )
+ file# ['] _fwrite catch if 3drop true else drop false then
+;
+: do-read ( adr len -- error? )
+ file# ['] _fread catch if 3drop true else drop false then
+;
+
+0 value #block-map
+0 value block-map
+0 value #blocks
+0 value #active-blocks
+0 value block-size
+d# 12 buffer: params
+: parse-sparse ( -- error? )
+ 3 /n* negate 2 do-seek if true exit then
+ params 3 /n* do-read if true exit then
+ params @ to #active-blocks
+ params na1+ @ to #blocks
+ params 2 na+ @ to block-size
+ #active-blocks d# 1024 + to #block-map
+ #block-map /n* alloc-mem to block-map
+ #active-blocks /n* negate 3 /n* - 2 do-seek if true exit then
+ block-map #active-blocks /n* do-read if true exit then
+ false
+;
+: save-block-map ( -- )
+ #active-blocks block-size * 0 do-seek if exit then ( )
+ block-map #active-blocks /n* do-write if exit then ( )
+ #active-blocks params !
+ #blocks params na1+ !
+ block-size params 2 na+ !
+ params 3 /n* do-write drop
+;
+
+0 value open-count
+: open ( -- flag )
+ my-args ( arg$ )
+ sparsefile$ dup 0= if ( arg$ null$ )
+ 2drop ( arg$ )
+ ascii , left-parse-string ( arg$' img-filename$ )
+ then ( arg$ img-filename$ )
+
+ open-count if ( arg$ img-filename$ )
+ 2drop ( arg$ )
+ else ( arg$ img-filename$ )
+ 2dup convert/ ( arg$ img-filename$ )
+ $fopen to file# ( arg$ )
+ file# 0< if 2drop false exit then ( arg$ )
+
+ parse-sparse if 2drop false exit then ( arg$ )
+
+ init-deblocker 0= if false exit then ( arg$ )
+ then ( arg$ )
+
+ init-label-package dup 0= if ( flag )
+ open-count 0= if ( flag )
+ deblocker close-package ( false )
+ file# d# 16 syscall drop ( false )
+ then ( flag )
+ then ( flag )
+
+ dup if ( flag )
+ open-count 1+ to open-count ( flag )
+ then ( flag )
+;
+[ifndef] lfind
+[ifdef] 386-assembler
+ code lfind ( sought adr len -- false | index true )
+ cx pop ( cx: len )
+ bx pop ( bx: adr )
+ dx pop ( dx: sought )
+ si push
+ bx si mov ( si: adr )
+ 2 # cx shr ( cx: longword count )
+ begin
+ ax lods
+ ax dx cmp = if
+ bx si sub
+ 2 # si shr
+ si dec
+ si 0 [sp] xchg
+
+ ax ax xor
+ ax dec
+ ax push
+ next
+ then
+ loopa
+ si pop \ Restore si
+ ax ax xor
+ ax push
+ c;
+[then]
+[ifndef] lfind
+ : lfind ( sought adr len -- false | index true )
+ over >r ( sought adr len r: adr )
+ over + search if ( loc r: adr )
+ r> - /n / true ( index true )
+ else ( r: adr )
+ r> drop false ( false )
+ then ( false | index true )
+ ;
+[then]
+[then]
+: >block-index ( block# -- )
+ block-map #active-blocks /n* lfind
+;
+: read-stored-block ( adr index -- error? )
+ block-size * 0 do-seek if drop true exit then ( adr )
+ block-size do-read if true exit then ( )
+ false
+;
+
+: read-block ( adr block# -- error? )
+." R " dup .x
+ dup #blocks >= if 2drop true exit then
+
+ >block-index if ( adr index )
+." I " dup . cr
+ read-stored-block ( error? )
+ else ( adr )
+." Z" cr
+ block-size erase ( )
+ false ( error? )
+ then
+;
+
+: read-blocks ( adr block# #blocks -- actual#blocks )
+ -rot 2 pick ( #blocks adr block# )
+ 0 do ( #blocks adr block# )
+ 2dup read-block if ( #blocks adr block# )
+ 3drop i unloop exit ( -- actual#blocks )
+ then ( #blocks adr block# )
+ swap block-size + swap 1+ ( #blocks adr' block#' )
+ loop ( #blocks adr block# )
+ 2drop ( actual#blocks )
+;
+
+: resize-block-map ( -- error? )
+ block-map #block-map d# 1024 + /n* resize if ( buf-adr )
+ drop true exit ( -- error? )
+ then ( buf-adr )
+ to block-map ( )
+ #block-map d# 1024 + to #block-map ( )
+ false ( error? )
+;
+: write-stored-block ( adr index -- error? )
+ block-size * 0 do-seek if drop true exit then ( adr )
+ block-size do-write if true exit then ( )
+ false
+;
+
+: write-new-block ( adr block# -- error? )
+ #active-blocks #block-map >= if ( adr block# )
+ resize-block-map if 2drop true exit then ( adr block# )
+ then ( adr block# )
+ swap #active-blocks write-stored-block if ( block# )
+ drop true exit ( -- error? )
+ then ( block# )
+ block-map #active-blocks na+ ! ( )
+ #active-blocks 1+ to #active-blocks ( )
+ false ( error? )
+;
+
+: write-block ( adr block# -- error? )
+." W " dup .x
+ dup #blocks >= if ( adr block# )
+ 2drop true exit ( -- error? )
+ then ( adr block# )
+
+ dup >block-index if ( adr block# index )
+." I " dup .x cr
+ nip write-stored-block ( error? )
+ else ( adr block# )
+." N" cr
+ write-new-block ( error? )
+ then ( error? )
+;
+
+: write-blocks ( adr block# #blocks -- actual#blocks )
+ -rot 2 pick ( #blocks adr block# )
+ 0 do ( #blocks adr block# )
+ 2dup write-block if ( #blocks adr block# )
+ 3drop i unloop exit ( -- actual#blocks )
+ then ( #blocks adr block# )
+ swap block-size + swap 1+ ( #blocks adr' block#' )
+ loop ( #blocks adr block# )
+ 2drop ( actual#blocks )
+;
+
+: close ( -- )
+ open-count dup 1- 0 max to open-count ( prev-open-count )
+ label-package close-package ( prev-open-count )
+ 1 = if ( )
+ deblocker close-package ( )
+ save-block-map ( )
+ file# d# 16 syscall drop ( )
+ then ( )
+;
+
+: dma-alloc ( size -- adr ) alloc-mem ;
+: dma-free ( adr size -- ) free-mem ;
+: max-transfer ( -- n ) block-size ;
+
+: seek ( offset.low offset.high -- okay? )
+ offset-low offset-high d+ " seek" deblocker $call-method
+;
+: read ( addr len -- actual-len ) " read" deblocker $call-method ;
+: write ( addr len -- actual-len ) " write" deblocker $call-method ;
+finish-device
+device-end
+
+\ LICENSE_BEGIN
+\ Copyright (c) 2007 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