j
: Next unread message k
: Previous unread message j a
: Jump to all threads
j l
: Jump to MailingList overview
Author: laurent Date: 2009-08-31 01:39:55 +0200 (Mon, 31 Aug 2009) New Revision: 575
Modified: trunk/openbios-devel/forth/debugging/client.fs trunk/openbios-devel/modules/filesystems.c Log: Implement load method
Modified: trunk/openbios-devel/forth/debugging/client.fs =================================================================== --- trunk/openbios-devel/forth/debugging/client.fs 2009-08-30 23:37:42 UTC (rev 574) +++ trunk/openbios-devel/forth/debugging/client.fs 2009-08-30 23:39:55 UTC (rev 575) @@ -17,10 +17,28 @@
\ 7.6.2 Program download and execute
+variable file-size + +: !load-size file-size ! ; + +: load-size file-size @ ; + : load ( "{params}<cr>" -- ) + linefeed parse ( str len ) + open-dev ( ihandle ) + dup 0= if + drop + exit + then + dup >r + " load-base" evaluate swap ( load-base ihandle ) + dup ihandle>phandle " load" rot find-method ( xt 0|1 ) + if swap call-package !load-size else cr ." Cannot find load for this package" 2drop then + r> close-dev ;
: go ( -- ) + ." go is not yet implemented" ;
: state-valid ( -- a-addr )
Modified: trunk/openbios-devel/modules/filesystems.c =================================================================== --- trunk/openbios-devel/modules/filesystems.c 2009-08-30 23:37:42 UTC (rev 574) +++ trunk/openbios-devel/modules/filesystems.c 2009-08-30 23:39:55 UTC (rev 575) @@ -243,6 +243,31 @@ PUSH( (ucell)"unspecified"); }
+/* ( addr -- size ) */ + +static void +files_load( files_info_t *mi) +{ + char *buf = (char*)POP(); + int ret, size; + + if (!mi->file) { + PUSH(0); + return; + } + + size = 0; + while(1) { + ret = mi->fs->read( mi->file, buf, 512 ); + if (ret != 512) + break; + buf += ret; + mi->filepos += ret; + size += ret; + } + PUSH( size ); +} + /* static method, ( ih -- flag? ) */ static void files_probe( files_info_t *dummy ) @@ -279,6 +304,7 @@ { "write", files_write }, { "seek", files_seek }, { "tell", files_tell }, + { "load", files_load }, { "block-size", files_block_size },
/* special */