Implement load method

git-svn-id: svn://coreboot.org/openbios/trunk/openbios-devel@575 f158a5a8-5612-0410-a976-696ce0be7e32
This commit is contained in:
Laurent Vivier
2009-08-30 23:39:55 +00:00
parent 0ab0524962
commit 95a04cec0e
2 changed files with 44 additions and 0 deletions

View File

@@ -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 )

View File

@@ -243,6 +243,31 @@ files_get_fstype( files_info_t *mi )
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 @@ NODE_METHODS( files ) = {
{ "write", files_write },
{ "seek", files_seek },
{ "tell", files_tell },
{ "load", files_load },
{ "block-size", files_block_size },
/* special */