52 lines
1.3 KiB
C
52 lines
1.3 KiB
C
#include "vxBoot/loader.h"
|
|
#include "vxBoot/terminal.h"
|
|
#include "vxBoot/fs/smemfs.h"
|
|
|
|
#include <gint/bfile.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
|
|
/* internal kernel image list */
|
|
extern struct ldimg *kernel_img_list;
|
|
|
|
/* hypervisor_get_image_list(): Dump all ELF file stored into the SMEM
|
|
*
|
|
* @note:
|
|
* on real calculator, all file transfered using USB are concidered to be
|
|
* 'archived', but on emulator they are concidered like file. */
|
|
static int loader_list_img(struct ldimg **image, struct smemfs_inode *inode)
|
|
{
|
|
if (inode == NULL)
|
|
return (0);
|
|
|
|
int counter = 0;
|
|
if (inode->type != BFile_Type_Archived
|
|
&& inode->type != BFile_Type_File) {
|
|
counter += loader_list_img(image, inode->child);
|
|
goto anchor;
|
|
}
|
|
if (loader_header_get(inode, NULL) == ld_header_valid) {
|
|
(*image) = calloc(1, sizeof(struct ldimg));
|
|
if ((*image) == NULL) {
|
|
terminal_write("hypervisor: out of memory :(\n");
|
|
goto anchor;
|
|
}
|
|
(*image)->inode = inode;
|
|
image = &((*image)->next);
|
|
}
|
|
anchor:
|
|
return (loader_list_img(image, inode->sibling) + counter);
|
|
}
|
|
|
|
/* loader_scan() : scan the storage memroy */
|
|
int loader_scan(void)
|
|
{
|
|
extern struct smemfs_superblock smemfs_superblock;
|
|
|
|
// bad way to check if the smemfs is mounted :(
|
|
if (smemfs_superblock.fake_root_inode != SMEMFS_FAKE_ROOT_INODE)
|
|
return (-1);
|
|
return (loader_list_img(&kernel_img_list, smemfs_superblock.root_inode));
|
|
}
|