fxBoot/include/fxBoot/hypervisor.h

108 lines
2.5 KiB
C

#ifndef __FXBOOT_LOADER_H__
# define __FXBOOT_LOADER_H__
#include <stddef.h>
#include <stdint.h>
/* define smemfs_*() pirmitive */
#include "fxBoot/fs/smemfs.h"
#define HYPERVISOR_BSS __attribute__((section(".hypervisor.bss")))
//---
// World switch structure
// TODO: move me !
//--
/* Define the SuperH CPU hardware context */
struct cpuctx {
uint32_t reg[16];
uint32_t gbr;
uint32_t macl;
uint32_t mach;
uint32_t ssr;
uint32_t spc;
uint32_t pr;
};
struct hworld {
/* hardware context */
struct {
struct cpuctx cpu;
} context;
/* memory information */
struct {
struct {
void *start;
size_t size;
} program;
} memory;
/* private information (used by the hypeviseur) */
struct {
struct smemfs_inode *inode;
struct worldctx *next;
} private;
};
struct himage {
const char *name;
void *private;
struct himage *next;
};
//---
// Loader interface
//---
/* hypervisor_loader(): Load the IMAGE into memory.
The loader will relocalise the IMAGE that is an ELF program compiled in PIE.
The fact that if the image use Gint as a shared librarie then the loader
will automatically resolve missing symbols.
Note that the hypervisor does not support shared libraries "on-calc" because
GCC cannot generate shared libraries for the SuperH archtiecture. Gint is
only possible because the hypervisor known where is located the kernel and
all of these symbols name is hardcoded to allow symbols resolving.
@params
(in) image hypervisor image that can be get using the
"hypervisor_loader_list()" function
@return
0 if successfully loaded
negative if error occur */
extern int hypervisor_loader(struct himage *image);
/* hypervisor_loader_list(): Generate the list all loadable image
The hypervisor will scan all files into the SMEM storage memory and will
check if the file is an ELF format with PIE encoding.
Note that the generated list should be destroyed using the
"hypervisor_loader_list_destroy()" function.
@param
(out) list list that will be generated
@return
possitive The number of valid file
0 No file can be loadable
negative if error occur */
extern int hypervisor_loader_list(struct himage **list);
/* hypervisor_loader_list_destroy(): Destroy the image list
This function will destroy the list generates by the
"hypervisor_loader_list()" function.
@params
(out) list List that will be destroyed and set to NULL */
extern void hypervisor_loader_list_destroy(struct himage **list);
#endif /*__FXBOOT_LOADER_H__*/