33 lines
780 B
C
33 lines
780 B
C
|
#include "vxBoot/terminal.h"
|
||
|
#include "vxBoot/fs/smemfs.h"
|
||
|
#include "vxBoot/hardware.h"
|
||
|
#include "vxBoot/loader.h"
|
||
|
|
||
|
/* loader_inode: Load a ELF programm (PIE) */
|
||
|
int loader_inode(struct smemfs_inode const * restrict const inode)
|
||
|
{
|
||
|
struct hwinfo hwinfo;
|
||
|
Elf32_Ehdr header;
|
||
|
int err;
|
||
|
|
||
|
if (inode == NULL)
|
||
|
return (-1);
|
||
|
|
||
|
terminal_write("- try to load ELF file \"%s\"\n", inode->name);
|
||
|
|
||
|
terminal_write("- check header information...\n");
|
||
|
err = loader_header_get(inode, &header);
|
||
|
if (err != 0)
|
||
|
return (-2);
|
||
|
|
||
|
terminal_write("- fetch hardware information...\n");
|
||
|
hardware_get_info(&hwinfo);
|
||
|
|
||
|
terminal_write("- load image...\n");
|
||
|
err = loader_image_load(&hwinfo, inode, &header);
|
||
|
if (err != 0)
|
||
|
return (-3);
|
||
|
terminal_write("image successfully loaded !\n");
|
||
|
return (0);
|
||
|
}
|