slkern/vmrd.h

43 lines
1.5 KiB
C
Raw Normal View History

// This is NEW CODE, a VM ram/disk access driver for use in the VM
// This driver is intended to be very simple to read/write blocks.
#ifndef _VMRD_H
#define _VMRD_H
#include "diskio.h"
// The address of the first register is the same as for virtio disk but
// the interface (to simplify kernel memory maps) but will use a
// different magic number.
#define VMRD_BASEADDRESS 0x0000000010001000UL
#define VMRD_REG_MAGIC 0
#define VMRD_REG_BLKSIZE 4
#define VMRD_REG_MEMADDR 8
#define VMRD_REG_BLKADDR 16
#define VMRD_REG_ACTION 24
// The magic number is BA5DB105
#define VMRD_MAGIC 0xBA5DB105
// These defines work like global variables for accessing the registers.
#define vmrd_magic *((unsigned int*)(VMRD_BASEADDRESS + VMRD_REG_MAGIC))
#define vmrd_blksize *((unsigned int*)(VMRD_BASEADDRESS + VMRD_REG_BLKSIZE))
#define vmrd_memaddr *((unsigned long*)(VMRD_BASEADDRESS + VMRD_REG_MEMADDR))
#define vmrd_blkaddr *((unsigned long*)(VMRD_BASEADDRESS + VMRD_REG_BLKADDR))
#define vmrd_action *((unsigned int*)(VMRD_BASEADDRESS + VMRD_REG_ACTION))
// Returns a major version number >= 1 if the virtual ram/disk device is
// present and 0 otherwise.
int vmrd_present();
// Initialises vmrd, returning a non-zero value on failure (e.g. if not present)
int vmrd_init();
// Performs a read/write of a block.
int vmrd_rw(diskio_buffer_t* buffer, int writing);
// This doesn't really belong here but is used to enable/disable debug
// tracing in the VM.
void vmrd_settracing(int onoroff);
// From ifndef at end of file:
#endif