X-Git-Url: http://git.annexia.org/?a=blobdiff_plain;f=extract%2Fcodegen%2Fcode_generation.mli;h=b803e71280f50df8e9043daaf1024c31d605a9c6;hb=6d60df50895e83763a20c4ec62ef0ec334cd7676;hp=efe282fe9be21e8bb2a639c10842cefd08678a75;hpb=9a4e42524fac9afd50fca18f2124f6df91716d4c;p=virt-mem.git diff --git a/extract/codegen/code_generation.mli b/extract/codegen/code_generation.mli index efe282f..b803e71 100644 --- a/extract/codegen/code_generation.mli +++ b/extract/codegen/code_generation.mli @@ -26,25 +26,99 @@ to the kernel structures, and [kernel.ml] is the implementation. *) -(** {2 Generate types} *) +type code = + Camlp4.PreCast.Syntax.Ast.str_item * Camlp4.PreCast.Syntax.Ast.sig_item + +(** {2 Generate types} + + Our internal types, representing kernel structures. +*) val generate_types : (string - * Struct_classify.shape_field_struct list - * Struct_classify.content_field_struct list) list -> - Camlp4.PreCast.Syntax.Ast.str_item * Camlp4.PreCast.Syntax.Ast.sig_item - (** [generate_types structures] generates the internal - types used to store variants of each structure, including: - - shape field structures - - content field structures + * (string * (Pahole_parser.f_type * bool)) list) list -> + code + (** [generate_types structures] generates the + types used to store each structure. + *) + +(** {2 Generate offset functions} + + [offset_of__ kernel_version] functions. + + These actually play a very minor role: We just use them when + adjusting [list_head] pointers which cross between structure + types, so we only generate functions for those right now. +*) + +val generate_offsets : + (string * ((Pahole_parser.info * Pahole_parser.structure) list + * (string * (Pahole_parser.f_type * bool)) list)) list -> + code + (** [generate_offsets] generates the offset functions. *) + +(** {2 Generate parsers} + + Functions which parse the different structures from bitstrings + into our internal types. +*) + +val generate_parsers : + (string * ((string * (Pahole_parser.f_type * bool)) list + * Minimizer.parser_ list)) list -> + code * (string, string) Hashtbl.t + (** [generate_parsers] generates the parser functions. + + We cannot generate the complete code here because we + don't want camlp4 parsing this file to substitute bitmatch + code yet. So we only generate labels, which get substituted + by the contents of the returned hash table in {!output_implem}. *) +(** {2 Generate version maps} + + The version maps are functions such as [size_of_ kernel_version] + which return some aspects of the structures and fields that + depend at runtime on the kernel version. +*) + +val generate_version_maps : + (string * ((Pahole_parser.info * Pahole_parser.structure) list + * (string, Minimizer.parser_) Hashtbl.t)) list -> + code + +(** {2 Generate followers} + + The "followers" are functions which recursively follow every + structure in the kernel, starting out at known root structures + such as [init_task] and [init_net]. Their job is to (a) find + every kernel structure, (b) ensure it is loaded into our + memory map, (c) produce a map of address -> structure. +*) + +val generate_followers : + string list -> + (string * (string * (Pahole_parser.f_type * bool)) list) list -> + code + (** [generate_followers] generates the follower functions. *) + (** {2 Output final files} *) val output_interf : output_file:string -> - Camlp4.PreCast.Syntax.Ast.sig_item -> unit + Camlp4.PreCast.Syntax.Ast.sig_item -> + Camlp4.PreCast.Syntax.Ast.sig_item -> + Camlp4.PreCast.Syntax.Ast.sig_item -> + Camlp4.PreCast.Syntax.Ast.sig_item -> + Camlp4.PreCast.Syntax.Ast.sig_item -> + unit (** Output the interface file. *) val output_implem : output_file:string -> - Camlp4.PreCast.Syntax.Ast.str_item -> unit + Camlp4.PreCast.Syntax.Ast.str_item -> + Camlp4.PreCast.Syntax.Ast.str_item -> + Camlp4.PreCast.Syntax.Ast.str_item -> + (string, string) Hashtbl.t -> + Camlp4.PreCast.Syntax.Ast.str_item -> + Camlp4.PreCast.Syntax.Ast.str_item -> + unit (** Output the implementation file. *)