Plan 9 from Bell Labs’s /usr/web/sources/xen/xen2/9/xenpc/plan9hif.c

Copyright © 2021 Plan 9 Foundation.
Distributed under the MIT License.
Download the Plan 9 distribution.


/* this file replaces all the inlines that are used on Linux systems */


#include	"u.h"
#include	"../port/lib.h"
#include	"mem.h"
#include	"dat.h"
#include	"fns.h"
#include	"io.h"
#include	"ureg.h"
#include	"pool.h"

#include "../xen/xen.h"

int gcc_call(int op);
int gcc_call_b(int op, unsigned long ebx);
int gcc_call_b_c(int op, unsigned long ebx, unsigned long ecx);
int gcc_call_b_c_d(int op, unsigned long ebx, unsigned long ecx, 
			unsigned long edx);
int gcc_call_b_c_d_S(int op, unsigned long ebx, unsigned long ecx,
			unsigned long edx, unsigned long esi);
int gcc_call_b_c_d_S_D(int op, unsigned long ebx, unsigned long ecx,
			unsigned long edx, unsigned long esi, unsigned long edi);
int gcc_call_b_S(int op, unsigned long ebx, unsigned long esi);

int HYPERVISOR_update_va_mapping(
    unsigned long pte_physical, unsigned long new_val, unsigned long flags)
{
    int ret;
	void panic(char *, ...);
        ret = gcc_call_b_c_d(
        (__HYPERVISOR_update_va_mapping), 
         (pte_physical),  (new_val),  (flags)  );

    if ((ret < 0) )
        panic("Failed update VA mapping: %08ulx, %08ulx, %08ulx, ret %d",
              pte_physical, new_val, flags, ret);
    
    return ret;
}


int HYPERVISOR_physdev_op(void *physdev_op)
{
    int ret;
        ret = gcc_call_b(
        (__HYPERVISOR_physdev_op),
         (unsigned long) (physdev_op)  );

    return ret;
}

#ifdef NOT
int HYPERVISOR_update_va_mapping_otherdomain(
    unsigned long page_nr, unsigned long new_val, 
	unsigned long flags, domid_t domid)
{
    int ret;
        ret = gcc_call_b_c_d_S_D(
        (__HYPERVISOR_update_va_mapping_otherdomain), 
         (page_nr),  ((new_val)),  (flags),
         (domid.lo),  (domid.hi) 
         );

    return ret;
}
#endif


long HYPERVISOR_set_timer_op(uvlong timeout)
{
    int ret;
    unsigned long timeout_hi = (unsigned long)(timeout>>32);
    unsigned long timeout_lo = (unsigned long)timeout;
        ret = gcc_call_b_c(
        (__HYPERVISOR_set_timer_op),
         (timeout_hi),  (timeout_lo)  );

    return ret;
}


int HYPERVISOR_dom0_op(dom0_op_t *dom0_op)
{
    int ret;
    dom0_op->interface_version = DOM0_INTERFACE_VERSION;
        ret = gcc_call_b(
        (__HYPERVISOR_dom0_op),
         (unsigned long) (dom0_op)  );

    return ret;
}

#ifdef OOPSY
int HYPERVISOR_network_op(void *network_op)
{
    int ret;
        ret = gcc_call_b(
        (__HYPERVISOR_network_op),
         (unsigned long) (network_op)  );

    return ret;
}

int HYPERVISOR_block_io_op(void *block_io_op)
{
    int ret;
        ret = gcc_call_b(
        (__HYPERVISOR_block_io_op),
        (unsigned long) (block_io_op)  ); 

    return ret;
}

#endif

int HYPERVISOR_set_trap_table(trap_info_t *table)
{
    int ret;
        ret = gcc_call_b(
        (__HYPERVISOR_set_trap_table),
       (unsigned long)   (table)  );

    return ret;
}

int HYPERVISOR_mmu_update(mmu_update_t *req, 
                                        int count, 
                                        int *success_count)
{
    int ret;
        ret = gcc_call_b_c_d(
        (__HYPERVISOR_mmu_update), 
         (unsigned long) (req),  (count),  (unsigned long) (success_count)  );

    return ret;
}

int HYPERVISOR_set_gdt(unsigned long *frame_list, int entries)
{
    int ret;
        ret = gcc_call_b_c(
        (__HYPERVISOR_set_gdt), 
         (unsigned long) (frame_list),  (entries)  );


    return ret;
}

int HYPERVISOR_stack_switch(unsigned long ss, unsigned long esp)
{
    int ret;
        ret = gcc_call_b_c(
        (__HYPERVISOR_stack_switch),
         (ss),  (esp)  );
	if (ret)
		 dp("stack switch failed !. ret %d\n", ret);

    return ret;
}

int HYPERVISOR_set_callbacks(
    unsigned long event_selector, unsigned long event_address,
    unsigned long failsafe_selector, unsigned long failsafe_address)
{
    int ret;
        ret = gcc_call_b_c_d_S(
        (__HYPERVISOR_set_callbacks),
         (event_selector),  (event_address), 
         (failsafe_selector),  (failsafe_address)  );

    return ret;
}

#ifdef OOPSY
int HYPERVISOR_net_io_op(netop_t *op)
{
    int ret;
        ret = gcc_call_b(
        (__HYPERVISOR_net_io_op),
         (unsigned long) (op)  );

    return ret;
}
#endif
int HYPERVISOR_fpu_taskswitch(void)
{
    int ret;
        ret = gcc_call(
        (__HYPERVISOR_fpu_taskswitch) );

    return ret;
}




int HYPERVISOR_yield(void)
{
    int ret;
        ret = gcc_call_b(
        (__HYPERVISOR_sched_op),
         (SCHEDOP_yield)  );

    return ret;
}

int HYPERVISOR_block(void)
{
    int ret;
        ret = gcc_call_b(
        (__HYPERVISOR_sched_op),
         (SCHEDOP_block)  );

    return ret;
}

int HYPERVISOR_exit(void)
{
    int ret;
        ret = gcc_call_b(
        (__HYPERVISOR_sched_op),
         (SCHEDOP_shutdown)  );

    return ret;
}

int HYPERVISOR_stop(unsigned long srec)
{
    int ret;
    /* NB. On suspend, control software expects a suspend record in %esi. */
        ret = gcc_call_b_S(
        (__HYPERVISOR_sched_op),
         (SCHEDOP_shutdown),  (srec)  );

    return ret;
}

int HYPERVISOR_set_debugreg(int reg, unsigned long value)
{
    int ret;
        ret = gcc_call_b_c(
        (__HYPERVISOR_set_debugreg),
         (reg),  (value)  );

    return ret;
}

unsigned long HYPERVISOR_get_debugreg(int reg)
{
    unsigned long ret;
        ret = gcc_call_b(
        (__HYPERVISOR_get_debugreg),
         (reg)  );

    return ret;
}

int HYPERVISOR_update_descriptor(
    unsigned long pa, unsigned long word1, unsigned long word2)
{
    int ret;
        ret = gcc_call_b_c_d(
        (__HYPERVISOR_update_descriptor), 
         (pa),  (word1),  (word2)  );

    return ret;
}

int HYPERVISOR_set_fast_trap(int idx)
{
    int ret;
        ret = gcc_call_b(
        (__HYPERVISOR_set_fast_trap), 
         (idx)  );

    return ret;
}

int HYPERVISOR_dom_mem_op(int op, 
	unsigned long *extent_list,
	unsigned long num_extents, 
	unsigned int order)
{
    int ret;
/*
	dp("dom_mem_op: op %d, list %p, num %d, order %d\n", 
		op, extent_list, num_extents, order);
 */
        ret = gcc_call_b_c_d_S_D(
        (__HYPERVISOR_dom_mem_op),
	op, 
	(unsigned long) extent_list, 
	num_extents, order, 
	DOMID_SELF );
/*	dp("ret is %d\n", ret);*/

    return ret;
}

int HYPERVISOR_multicall(void *call_list, int nr_calls)
{
    int ret;
        ret = gcc_call_b_c(
        (__HYPERVISOR_multicall),
         (unsigned long) (call_list),  (nr_calls)  );

    return ret;
}

#ifdef OOPSY
long HYPERVISOR_kbd_op(unsigned char op, unsigned char val)
{
    int ret;
        ret = gcc_call_b_c(
        (__HYPERVISOR_kbd_op),
         (op),  (val)  );

    return ret;
}
#endif

int HYPERVISOR_event_channel_op(void *op)
{
    int ret;
//	dp("event channel op\n");
        ret = gcc_call_b(
        (__HYPERVISOR_event_channel_op),
         (unsigned long) (op)  );

//	dp("event channel op ret %d\n", ret);
    return ret;
}

int HYPERVISOR_xen_version(int cmd)
{
    int ret;
        ret = gcc_call_b(
        (__HYPERVISOR_xen_version), 
         (cmd)  );

    return ret;
}

int HYPERVISOR_console_io(int cmd, int count, char *str)
{
    int ret;
        ret = gcc_call_b_c_d(
        (__HYPERVISOR_console_io),
         (cmd),  (count),  (unsigned long)(str)  );

    return ret;
}


Bell Labs OSI certified Powered by Plan 9

(Return to Plan 9 Home Page)

Copyright © 2021 Plan 9 Foundation. All Rights Reserved.
Comments to [email protected].