khypervisor  v1
Data Structures | Typedefs | Enumerations | Functions
include/vdev.h File Reference
#include <context.h>
#include <hvmm_types.h>
Include dependency graph for vdev.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  vdev_info_t

Typedefs

typedef hvmm_status_t(* vdev_callback_t )(uint32_t wnr, uint32_t offset, uint32_t *pvalue, vdev_access_size_t access_size)

Enumerations

enum  vdev_access_size_t { VDEV_ACCESS_BYTE = 0, VDEV_ACCESS_HWORD = 1, VDEV_ACCESS_WORD = 2, VDEV_ACCESS_RESERVED = 3 }

Functions

void vdev_init (void)
int register_vdev (void)
hvmm_status_t vdev_reg_device (vdev_info_t *new_vdev)
hvmm_status_t vdev_emulate (uint32_t fipa, uint32_t wnr, vdev_access_size_t access_size, uint32_t srt, struct arch_regs *regs)

Typedef Documentation

typedef hvmm_status_t(* vdev_callback_t)(uint32_t wnr, uint32_t offset, uint32_t *pvalue, vdev_access_size_t access_size)

Definition at line 20 of file vdev.h.


Enumeration Type Documentation

Enumerator:
VDEV_ACCESS_BYTE 
VDEV_ACCESS_HWORD 
VDEV_ACCESS_WORD 
VDEV_ACCESS_RESERVED 

Definition at line 7 of file vdev.h.


Function Documentation

int register_vdev ( void  )
hvmm_status_t vdev_emulate ( uint32_t  fipa,
uint32_t  wnr,
vdev_access_size_t  access_size,
uint32_t  srt,
struct arch_regs regs 
)

Definition at line 49 of file vdev.c.

{
    hvmm_status_t result = HVMM_STATUS_NOT_FOUND;
    int i = 0;
    uint32_t offset;
    uint8_t isize = 4;

    HVMM_TRACE_ENTER();
    if ( regs->cpsr & 0x20 ) {
        /* Thumb */
        isize = 2;
    }

    for (i = 0; i < MAX_VDEV; i++){
        if ( vdev_list[i].base == 0 ) break;

        offset = fipa - vdev_list[i].base;
        if ( fipa >= vdev_list[i].base && offset < vdev_list[i].size && vdev_list[i].handler != 0) {
            /* fipa is in the rage: base ~ base + size */
            printh("vdev: found %s for fipa %x srt:%x gpr[srt]:%x write:%d vmid:%d\n", vdev_list[i].name, fipa, srt, regs->gpr[srt], wnr, context_current_vmid() );
            result = vdev_list[i].handler(wnr, offset, &(regs->gpr[srt]), access_size);
            if ( wnr == 0 ) {
                printh("vdev: result:%x\n", regs->gpr[srt] );
            }

            /* Update PC regardless handling result */
            regs->pc += isize;
            break;
        } else {
            printh("vdev: fipa %x base %x not matched\n", fipa, vdev_list[i].base );
        }
    }
    HVMM_TRACE_EXIT();

    return result;
}

Here is the call graph for this function:

void vdev_init ( void  )

Definition at line 11 of file vdev.c.

{
    int i = 0;
    for (i = 0; i < MAX_VDEV; i++) {
        vdev_list[i].name = 0;
        vdev_list[i].base = 0;
        vdev_list[i].size = 0;
        vdev_list[i].handler = 0x0;
    }
}

Definition at line 22 of file vdev.c.

{
    hvmm_status_t result = HVMM_STATUS_BUSY;
    int i = 0;

    HVMM_TRACE_ENTER();
    for (i = 0; i < MAX_VDEV; i++) {
        if (vdev_list[i].handler == 0x0 ) {
            vdev_list[i].name = new_vdev->name;
            vdev_list[i].base = new_vdev->base;
            vdev_list[i].size = new_vdev->size;
            vdev_list[i].handler = new_vdev->handler;
            printh("vdev:Registered vdev '%s' at index %d\n", vdev_list[i].name, i);

            result = HVMM_STATUS_SUCCESS;
            break;
        }
    }

    if ( result != HVMM_STATUS_SUCCESS ) {
        printh("vdev:Failed registering vdev '%s', max %d full \n", new_vdev->name, MAX_VDEV);
    }

    HVMM_TRACE_EXIT();
    return result;
}
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Defines