mirror of
https://gitlab.com/qemu-project/openbios.git
synced 2024-02-13 08:34:06 +08:00
Implement load method
git-svn-id: svn://coreboot.org/openbios/trunk/openbios-devel@575 f158a5a8-5612-0410-a976-696ce0be7e32
This commit is contained in:
@@ -17,10 +17,28 @@
|
|||||||
|
|
||||||
\ 7.6.2 Program download and execute
|
\ 7.6.2 Program download and execute
|
||||||
|
|
||||||
|
variable file-size
|
||||||
|
|
||||||
|
: !load-size file-size ! ;
|
||||||
|
|
||||||
|
: load-size file-size @ ;
|
||||||
|
|
||||||
: load ( "{params}<cr>" -- )
|
: 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 ( -- )
|
||||||
|
." go is not yet implemented"
|
||||||
;
|
;
|
||||||
|
|
||||||
: state-valid ( -- a-addr )
|
: state-valid ( -- a-addr )
|
||||||
|
|||||||
@@ -243,6 +243,31 @@ files_get_fstype( files_info_t *mi )
|
|||||||
PUSH( (ucell)"unspecified");
|
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 method, ( ih -- flag? ) */
|
||||||
static void
|
static void
|
||||||
files_probe( files_info_t *dummy )
|
files_probe( files_info_t *dummy )
|
||||||
@@ -279,6 +304,7 @@ NODE_METHODS( files ) = {
|
|||||||
{ "write", files_write },
|
{ "write", files_write },
|
||||||
{ "seek", files_seek },
|
{ "seek", files_seek },
|
||||||
{ "tell", files_tell },
|
{ "tell", files_tell },
|
||||||
|
{ "load", files_load },
|
||||||
{ "block-size", files_block_size },
|
{ "block-size", files_block_size },
|
||||||
|
|
||||||
/* special */
|
/* special */
|
||||||
|
|||||||
Reference in New Issue
Block a user