1/******************************************************************************
2 * gcov.h
3 *
4 * Coverage structures exported by Xen.
5 * Structure is different from Gcc one.
6 *
7 * Permission is hereby granted, free of charge, to any person obtaining a copy
8 * of this software and associated documentation files (the "Software"), to
9 * deal in the Software without restriction, including without limitation the
10 * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
11 * sell copies of the Software, and to permit persons to whom the Software is
12 * furnished to do so, subject to the following conditions:
13 *
14 * The above copyright notice and this permission notice shall be included in
15 * all copies or substantial portions of the Software.
16 *
17 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
22 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
23 * DEALINGS IN THE SOFTWARE.
24 *
25 * Copyright (c) 2013, Citrix Systems R&D Ltd.
26 */
27
28#ifndef __XEN_PUBLIC_GCOV_H__
29#define __XEN_PUBLIC_GCOV_H__ __XEN_PUBLIC_GCOV_H__
30
31#define XENCOV_COUNTERS         5
32#define XENCOV_TAG_BASE         0x58544300u
33#define XENCOV_TAG_FILE         (XENCOV_TAG_BASE+0x46u)
34#define XENCOV_TAG_FUNC         (XENCOV_TAG_BASE+0x66u)
35#define XENCOV_TAG_COUNTER(n)   (XENCOV_TAG_BASE+0x30u+((n)&0xfu))
36#define XENCOV_TAG_END          (XENCOV_TAG_BASE+0x2eu)
37#define XENCOV_IS_TAG_COUNTER(n) \
38    ((n) >= XENCOV_TAG_COUNTER(0) && (n) < XENCOV_TAG_COUNTER(XENCOV_COUNTERS))
39#define XENCOV_COUNTER_NUM(n) ((n)-XENCOV_TAG_COUNTER(0))
40
41/*
42 * The main structure for the blob is
43 * BLOB := FILE.. END
44 * FILE := TAG_FILE VERSION STAMP FILENAME COUNTERS FUNCTIONS
45 * FILENAME := LEN characters
46 *   characters are padded to 32 bit
47 * LEN := 32 bit value
48 * COUNTERS := TAG_COUNTER(n) NUM COUNTER..
49 * NUM := 32 bit valie
50 * COUNTER := 64 bit value
51 * FUNCTIONS := TAG_FUNC NUM FUNCTION..
52 * FUNCTION := IDENT CHECKSUM NUM_COUNTERS
53 *
54 * All tagged structures are aligned to 8 bytes
55 */
56
57/**
58 * File information
59 * Prefixed with XENCOV_TAG_FILE and a string with filename
60 * Aligned to 8 bytes
61 */
62struct xencov_file
63{
64    uint32_t tag; /* XENCOV_TAG_FILE */
65    uint32_t version;
66    uint32_t stamp;
67    uint32_t fn_len;
68    char filename[1];
69};
70
71
72/**
73 * Counters information
74 * Prefixed with XENCOV_TAG_COUNTER(n) where n is 0..(XENCOV_COUNTERS-1)
75 * Aligned to 8 bytes
76 */
77struct xencov_counter
78{
79    uint32_t tag; /* XENCOV_TAG_COUNTER(n) */
80    uint32_t num;
81    uint64_t values[1];
82};
83
84/**
85 * Information for each function
86 * Number of counter is equal to the number of counter structures got before
87 */
88struct xencov_function
89{
90    uint32_t ident;
91    uint32_t checksum;
92    uint32_t num_counters[1];
93};
94
95/**
96 * Information for all functions
97 * Aligned to 8 bytes
98 */
99struct xencov_functions
100{
101    uint32_t tag; /* XENCOV_TAG_FUNC */
102    uint32_t num;
103    struct xencov_function xencov_function[1];
104};
105
106/**
107 * Terminator
108 */
109struct xencov_end
110{
111    uint32_t tag; /* XENCOV_TAG_END */
112};
113
114#endif /* __XEN_PUBLIC_GCOV_H__ */
115
116