X-Git-Url: http://git.annexia.org/?a=blobdiff_plain;f=lib%2Fvirt_mem_types.mli;h=a95b770e5d8e2158c9aeecfe723c5450df2a82ac;hb=cf4669f31197abcfb14dee874a4b738c9c2e6483;hp=f537664e28d456817b8f288e3acd7ccb3ca4d867;hpb=465c7453654e34513b19172dd56fcfff199f210e;p=virt-mem.git diff --git a/lib/virt_mem_types.mli b/lib/virt_mem_types.mli index f537664..a95b770 100644 --- a/lib/virt_mem_types.mli +++ b/lib/virt_mem_types.mli @@ -41,10 +41,24 @@ module Ksymmap : sig val compare : ('a -> 'a -> int) -> 'a t -> 'a t -> int val equal : ('a -> 'a -> bool) -> 'a t -> 'a t -> bool end - (** A map of kernel symbols to addresses. *) + (** Functions available in the map of kernel symbols to addresses. *) + +type ksymmap = Virt_mem_mmap.addr Ksymmap.t + (** Kernel symbol table (map of kernel symbols to addresses). *) (** {2 Kernel images and associated data} *) +type image = { + dom : Libvirt.ro Libvirt.Domain.t option; (** Domain, if known. *) + domname : string; (** Domain name. *) + 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. *) + type utsname = { kernel_name : string; nodename : string; @@ -55,49 +69,33 @@ type utsname = { } (** Kernel version, from utsname structure in the kernel. *) -type image0 = { - dom : Libvirt.ro Libvirt.Domain.t option; (** Domain, if known. *) - domname : string; (** Domain name. *) - 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. *) +type kdata = { + ksyms : ksymmap option; (** Kernel symbol lookup function. *) + utsname : utsname option; (** Kernel version. *) + tasks : Virt_mem_mmap.addr option; (** Linked list of tasks (processes) + starting at the address of + init_task (swapper). *) } - (** A basic kernel image. *) + (** Optional data derived from the raw kernel image by the main + program and passed to the tools' [~run] functions. -type image1 = - image0 - * Virt_mem_mmap.addr Ksymmap.t (* Kernel symbol map. *) - (** A kernel image, after finding kernel symbols. *) + What fields get filled in is controlled by the [~needs_*] + options passed when tools register themselves, and also of + course by what we are able to find out about the memory image. -type image2 = - image0 - * 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'). *) + Note there is significant cost to filling in some of these + fields. +*) (** {2 Load kernel memory} *) type load_memory_error = - | AddressOutOfRange (** Address not in [kernel_min..kernel_max] *) - | DomIsNull (** image.dom = None *) + | 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 +val load_memory : image -> Virt_mem_mmap.addr -> int -> image (** [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. @@ -108,3 +106,15 @@ val load_memory : image0 -> Virt_mem_mmap.addr -> int -> image0 This function can raise many different sorts of exceptions and the caller is advised to catch any exceptions and deal with them appropriately. *) + +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 -> image + (** [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. *)