begin working on adding actual block storage device
FossilOrigin-Name: 3b0ba44bac95ae57bee881409871055ae71b21bb42ce5322bf8c37c186397f97
This commit is contained in:
parent
b83d0f0ea2
commit
5761eaff14
3 changed files with 426 additions and 390 deletions
1
Makefile
1
Makefile
|
@ -50,6 +50,7 @@ ENABLED += -DENABLE_MULTICORE
|
|||
ENABLED += -DENABLE_FFI
|
||||
ENABLED += -DENABLE_UNSIGNED
|
||||
ENABLED += -DENABLE_MALLOC
|
||||
ENABLED += -DENABLE_BLOCKS
|
||||
|
||||
DEVICES ?=
|
||||
DEVICES += interface/floatingpoint.retro
|
||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -136,6 +136,10 @@ struct NgaState {
|
|||
CELL fsp, afsp;
|
||||
#endif
|
||||
|
||||
#ifdef ENABLE_BLOCKS
|
||||
char BlockFile[1025];
|
||||
#endif
|
||||
|
||||
/* Scripting */
|
||||
char **sys_argv;
|
||||
int sys_argc;
|
||||
|
@ -192,6 +196,10 @@ void io_malloc(NgaState *); void query_malloc(NgaState *);
|
|||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef ENABLE_BLOCKS
|
||||
void io_blocks(NgaState *); void query_blocks(NgaState *);
|
||||
#endif
|
||||
|
||||
void io_image(NgaState *); void query_image(NgaState *);
|
||||
|
||||
void load_embedded_image(NgaState *);
|
||||
|
@ -309,6 +317,33 @@ void io_malloc(NgaState *vm) {
|
|||
#endif
|
||||
#endif
|
||||
|
||||
/* Block Storage -------------------------------------------- */
|
||||
#ifdef ENABLE_BLOCKS
|
||||
void io_blocks(NgaState *vm) {
|
||||
CELL op = stack_pop(vm);
|
||||
CELL buffer = stack_pop(vm);
|
||||
CELL block = stack_pop(vm);
|
||||
|
||||
if (op == 0) {
|
||||
int fp = open(vm->BlockFile, O_RDONLY, 0666);
|
||||
lseek(fp, 4096 * block, SEEK_SET);
|
||||
read(fp, vm->memory + buffer, 4096);
|
||||
close(fp);
|
||||
}
|
||||
|
||||
if (op == 1) {
|
||||
int fp = open(vm->BlockFile, O_WRONLY, 0666);
|
||||
lseek(fp, 4096 * block, SEEK_SET);
|
||||
write(fp, vm->memory + buffer, 4096);
|
||||
close(fp);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void query_blocks(NgaState *) {
|
||||
}
|
||||
#endif
|
||||
|
||||
/* Multi Core Support ------------------------------------------------ */
|
||||
#ifdef ENABLE_MULTICORE
|
||||
void init_core(NgaState *vm, CELL x) {
|
||||
|
|
Loading…
Reference in a new issue