Home | History | Annotate | Download | only in libop
      1 /**
      2  * @file op_interface.h
      3  *
      4  * Module / user space interface for 2.4
      5  *
      6  * @remark Copyright 2002 OProfile authors
      7  * @remark Read the file COPYING
      8  *
      9  * @author John Levon
     10  * @author Philippe Elie
     11  */
     12 
     13 #ifndef OP_INTERFACE_H
     14 #define OP_INTERFACE_H
     15 
     16 #include "op_config.h"
     17 #include "op_types.h"
     18 
     19 /*@{\name notifications types encoded in op_note::type */
     20 /** fork(),vfork(),clone() */
     21 #define OP_FORK 1
     22 /** mapping */
     23 #define OP_MAP 2
     24 /** execve() */
     25 #define OP_EXEC 4
     26 /** init_module() */
     27 #define OP_DROP_MODULES 8
     28 /** exit() */
     29 #define OP_EXIT 16
     30 /*@}*/
     31 
     32 /** Data type to transfer samples counts from the module to the daemon */
     33 struct op_sample {
     34 	unsigned long eip; /**< eip value where occur interrupt */
     35 	u32 counter; /**< counter nr */
     36 	u32 pid; /**< 32 bits can hold any pid */
     37 	u32 tgid; /**< always equal to pid for kernel < 2.4.0 */
     38 };
     39 
     40 /** the current kernel-side profiler state */
     41 enum oprof_state {
     42 	STOPPED = 0,
     43 	STOPPING = 1,
     44 	RUNNING = 2
     45 };
     46 
     47 /**
     48  * The head structure of a kernel sample buffer.
     49  */
     50 struct op_buffer_head {
     51 	int cpu_nr; /**< the CPU number of this buffer */
     52 	size_t count; /**< number of samples in this buffer */
     53 	enum oprof_state state; /**< current profiler state */
     54 	struct op_sample buffer[0]; /**< the sample buffer */
     55 } __attribute__((__packed__));
     56 
     57 /**
     58  * Data type used by the module to notify daemon of fork/exit/mapping etc.
     59  * Meanings of fields depend on the type of notification encoded in the type
     60  * field.
     61  * \sa OP_FORK, OP_EXEC, OP_MAP, OP_DROP_MODULES and OP_EXIT
     62  */
     63 struct op_note {
     64 	unsigned long   addr;
     65 	unsigned long   len;
     66 	unsigned long   offset;
     67 	unsigned int    hash;
     68 	unsigned int	pid;
     69 	unsigned int    tgid;
     70 	unsigned short	type;
     71 };
     72 
     73 /**
     74  * A path component. Directory name are stored as a stack of path components.
     75  * Note than the name index acts also as an unique identifier
     76  */
     77 struct op_hash_index {
     78 	/** index inside the string pool */
     79 	u32 name;
     80 	/** parent component, zero if this component is the root */
     81 	u32 parent;
     82 } __attribute__((__packed__));
     83 
     84 /** size of hash map in bytes */
     85 #define OP_HASH_MAP_SIZE (OP_HASH_MAP_NR * sizeof(struct op_hash_index) + POOL_SIZE)
     86 
     87 #endif /* OP_INTERFACE_H */
     88