summaryrefslogtreecommitdiff
path: root/debug.h
blob: 2880ce14f05645af0debe54a824237d95e9788e0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
/* SPDX-License-Identifier: GPL-2.0 */

/*
 * This file is part of the QM35 UCI stack for linux.
 *
 * Copyright (c) 2022 Qorvo US, Inc.
 *
 * This software is provided under the GNU General Public License, version 2
 * (GPLv2), as well as under a Qorvo commercial license.
 *
 * You may choose to use this software under the terms of the GPLv2 License,
 * version 2 ("GPLv2"), as published by the Free Software Foundation.
 * You should have received a copy of the GPLv2 along with this program.  If
 * not, see <http://www.gnu.org/licenses/>.
 *
 * This program is distributed under the GPLv2 in the hope that it will be
 * useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GPLv2 for more
 * details.
 *
 * If you cannot meet the requirements of the GPLv2, you may not use this
 * software for any purpose without first obtaining a commercial license from
 * Qorvo.
 * Please contact Qorvo to inquire about licensing terms.
 *
 * QM35 LOG layer HSSPI Protocol
 */

#ifndef __DEBUG_H__
#define __DEBUG_H__

#include <linux/fs.h>
#include <linux/mutex.h>
#include "qm35_rb.h"

struct debug;
struct log_module;

struct debug_trace_ops {
	void (*enable_set)(struct debug *dbg, int enable);
	int (*enable_get)(struct debug *dbg);
	void (*level_set)(struct debug *dbg, struct log_module *log_module,
			  int lvl);
	int (*level_get)(struct debug *dbg, struct log_module *log_module);
	char *(*trace_get_next)(struct debug *dbg, rb_entry_size_t *len);
	rb_entry_size_t (*trace_get_next_size)(struct debug *dbg);
	bool (*trace_next_avail)(struct debug *dbg);
	void (*trace_reset)(struct debug *dbg);
	int (*get_soc_id)(struct debug *dbg, uint8_t *soc_id);
};

struct debug_coredump_ops {
	char *(*coredump_get)(struct debug *dbg, size_t *len);
	int (*coredump_force)(struct debug *dbg);
};

struct debug {
	struct dentry *root_dir;
	struct dentry *fw_dir;
	const struct debug_trace_ops *trace_ops;
	const struct debug_coredump_ops *coredump_ops;
	struct wait_queue_head wq;
	struct file *pv_filp;
	struct mutex pv_filp_lock;
	struct binary_chunk *certificate;
};

// TODO move this from here to a commom place for both log layer and debug
struct log_module {
	uint8_t id;
	uint8_t lvl;
	char name[64];
	struct completion *read_done;
	struct debug *debug;
};

int debug_init(struct debug *debug, struct dentry *root);
void debug_deinit(struct debug *debug);

int debug_create_module_entry(struct debug *debug,
			      struct log_module *log_module);

void debug_new_trace_available(struct debug *debug);

#endif // __DEBUG_H__