X-Git-Url: http://git.annexia.org/?p=virt-mem.git;a=blobdiff_plain;f=lib%2Fvirt_mem_types.mli;h=f537664e28d456817b8f288e3acd7ccb3ca4d867;hp=24ce3e747ed93192da5fa8501efe4dc02d79d3db;hb=b8aef502747b039b20877f99f3d8986b6a9329d2;hpb=e7fad361d3dbf1689a22fdd1ae5f5579d6ef5fb0 diff --git a/lib/virt_mem_types.mli b/lib/virt_mem_types.mli index 24ce3e7..f537664 100644 --- a/lib/virt_mem_types.mli +++ b/lib/virt_mem_types.mli @@ -20,6 +20,8 @@ Common types. *) +(** {2 Kernel symbols} *) + type ksym = string (** A kernel symbol. *) @@ -41,6 +43,8 @@ module Ksymmap : sig end (** A map of kernel symbols to addresses. *) +(** {2 Kernel images and associated data} *) + type utsname = { kernel_name : string; nodename : string; @@ -57,6 +61,8 @@ type image0 = { arch : Virt_mem_utils.architecture; (** Architecture, eg. i386. *) mem : ([`Wordsize], [`Endian], [`HasMapping]) Virt_mem_mmap.t; (** Memory map. *) + kernel_min : Virt_mem_mmap.addr; (** Minimum addr of kernel pointers. *) + kernel_max : Virt_mem_mmap.addr; (** Maximum addr of kernel pointers. *) } (** A basic kernel image. *) @@ -70,3 +76,35 @@ type image2 = * Virt_mem_mmap.addr Ksymmap.t (* Kernel symbol map. *) * utsname option (* Kernel version, etc., if found. *) (** A kernel image, after finding kernel version (like 'uname'). *) + +(** {2 Load kernel memory} *) + +type load_memory_error = + | AddressOutOfRange (** Address not in [kernel_min..kernel_max] *) + | DomIsNull (** image.dom = None *) + +exception LoadMemoryError of load_memory_error * string + +val load_static_memory : dom:Libvirt.ro Libvirt.Domain.t -> + domname:string -> + arch:Virt_mem_utils.architecture -> + wordsize:Virt_mem_utils.wordsize -> endian:Bitstring.endian -> + kernel_min:Virt_mem_mmap.addr -> kernel_max:Virt_mem_mmap.addr -> + Virt_mem_mmap.addr -> int -> image0 + (** [load_static_memory ~dom (*...*) start size] creates an [image0] + object, and initializes it with static kernel memory loaded + from the [start] address and [size] of [dom]. + + See also {!load_memory} for exceptions this can raise. *) + +val load_memory : image0 -> Virt_mem_mmap.addr -> int -> image0 + (** [load_memory img start size] tries to load [size] bytes from + the start address into the memory map. If the memory was loaded + previously, then it is not requested again. + + Note that the memory map may be updated by this, so a modified + image structure is returned. + + This function can raise many different sorts of exceptions and + the caller is advised to catch any exceptions and deal with them + appropriately. *)