42 lines
1009 B
C
42 lines
1009 B
C
//---
|
|
// hypervisor:install - Hypervisor installation
|
|
//---
|
|
#include "fxBoot/hypervisor.h"
|
|
|
|
#include <gint/std/stdlib.h>
|
|
#include <gint/drivers.h>
|
|
#include <gint/cpu.h>
|
|
|
|
/* external VBR information */
|
|
extern void *hypervisor_vbr_inth;
|
|
extern void *hypervisor_vbr_exch;
|
|
extern void *hypervisor_vbr_tlbh;
|
|
|
|
/* internal information */
|
|
struct hworld *hypervisor_world_current;
|
|
struct hworld *hypervisor_world;
|
|
void *hypervisor_vbr_redirect;
|
|
void *hypervisor_vbr;
|
|
|
|
//---
|
|
// User API
|
|
//---
|
|
/* hypervisor_install(): Install the hypervisor */
|
|
int hypervisor_install(void)
|
|
{
|
|
/* generate the world context for the interface */
|
|
if (hypervisor_world == NULL) {
|
|
hypervisor_world = hypervisor_wswitch_world_alloc();
|
|
if (hypervisor_world == NULL)
|
|
return (-1);
|
|
hypervisor_world_current = hypervisor_world;
|
|
}
|
|
|
|
/* switch the VBR */
|
|
hypervisor_vbr = (void*)(hypervisor_vbr_exch - 0x100);
|
|
void * tmp = cpu_getVBR();
|
|
if (tmp != hypervisor_vbr)
|
|
hypervisor_vbr_redirect = cpu_setVBR(hypervisor_vbr);
|
|
return (0);
|
|
}
|