Updated kernel structures & kerneldb.
[virt-mem.git] / lib / virt_mem_list_head.mli
1 (** Handle struct list_head linked lists. *)
2 (* Memory info command for virtual domains.
3    (C) Copyright 2008 Richard W.M. Jones, Red Hat Inc.
4    http://libvirt.org/
5
6    This program is free software; you can redistribute it and/or modify
7    it under the terms of the GNU General Public License as published by
8    the Free Software Foundation; either version 2 of the License, or
9    (at your option) any later version.
10
11    This program is distributed in the hope that it will be useful,
12    but WITHOUT ANY WARRANTY; without even the implied warranty of
13    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14    GNU General Public License for more details.
15
16    You should have received a copy of the GNU General Public License
17    along with this program; if not, write to the Free Software
18    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
19  *)
20
21 type t
22
23 val create : Virt_mem_types.image -> Virt_mem_mmap.addr -> int -> t
24   (** [create image head offset] creates a list_head handle.
25
26       [head] is the address of the base [list_head] in kernel memory.
27
28       [offset] is the offset of the [list_head] within the whole
29       structure.
30
31       Note that [head] may be an isolated [struct list_head] or
32       it may be a member of a structure.  In the case where the
33       head is in a structure, the head structure is ignored (as is
34       generally the case in kernel code too).
35
36       If the memory might not have been loaded yet, you should
37       call {!load} or {!load_all} immediately after this.
38   *)
39
40 val create_base : Virt_mem_types.image -> Virt_mem_mmap.addr -> int -> t
41   (** Same as {!create} but the address passed in is the base address
42       of the head structure {i not} the address of the list_head
43       within that structure.
44   *)
45
46 val load : t ->
47   (Virt_mem_types.image -> Virt_mem_mmap.addr -> Virt_mem_types.image) ->
48   Virt_mem_types.image * t
49   (** This call allows you to load the kernel memory for each
50       structure in the list.
51
52       You supply a function to do the loading, given the
53       address of each structure in turn.  This returns an
54       updated memory map and {!t}.
55   *)
56
57 val load_all : t -> int -> Virt_mem_types.image * t
58   (** More convenient version of {!load} where you specify the
59       structure size, and this function does all the rest.
60   *)
61
62 val iter : t -> (Virt_mem_mmap.addr -> unit) -> unit
63   (** [iter t f] applies function [f] to every element of the list [t]. *)
64
65 val map : t -> (Virt_mem_mmap.addr -> 'a) -> 'a list
66   (** [map t f] applies function [f] to every element of the list [t] and
67       returns a list of the results.
68   *)
69
70 val fold : t -> 'a -> ('a -> Virt_mem_mmap.addr -> 'a) -> 'a
71   (** [fold t b f] folds function [f] over every element of the list [t]
72       with [b] as the base case.
73   *)