2 * Copyright (c) 2018-2020 Ruslan Bukin <br@bsdpad.com>
5 * This software was developed by SRI International and the University of
6 * Cambridge Computer Laboratory under DARPA/AFRL contract FA8750-10-C-0237
7 * ("CTSRD"), as part of the DARPA CRASH research programme.
9 * Redistribution and use in source and binary forms, with or without
10 * modification, are permitted provided that the following conditions
12 * 1. Redistributions of source code must retain the above copyright
13 * notice, this list of conditions and the following disclaimer.
14 * 2. Redistributions in binary form must reproduce the above copyright
15 * notice, this list of conditions and the following disclaimer in the
16 * documentation and/or other materials provided with the distribution.
18 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
19 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
20 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
21 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
22 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
23 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
24 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
25 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
26 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
27 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
33 #ifndef _ARM64_CORESIGHT_CORESIGHT_H_
34 #define _ARM64_CORESIGHT_CORESIGHT_H_
37 #include "opt_platform.h"
42 #include <dev/ofw/openfirm.h>
46 #include <contrib/dev/acpica/include/acpi.h>
47 #include <dev/acpica/acpivar.h>
50 #define CORESIGHT_ITCTRL 0xf00
51 #define CORESIGHT_CLAIMSET 0xfa0
52 #define CORESIGHT_CLAIMCLR 0xfa4
53 #define CORESIGHT_LAR 0xfb0
54 #define CORESIGHT_UNLOCK 0xc5acce55
55 #define CORESIGHT_LSR 0xfb4
56 #define CORESIGHT_AUTHSTATUS 0xfb8
57 #define CORESIGHT_DEVID 0xfc8
58 #define CORESIGHT_DEVTYPE 0xfcc
63 CORESIGHT_DYNAMIC_REPLICATOR,
73 struct coresight_device {
74 TAILQ_ENTRY(coresight_device) link;
76 enum cs_dev_type dev_type;
77 struct coresight_platform_data *pdata;
81 TAILQ_ENTRY(endpoint) link;
88 ACPI_HANDLE their_handle;
89 ACPI_HANDLE my_handle;
93 struct coresight_device *cs_dev;
94 LIST_ENTRY(endpoint) endplink;
97 struct coresight_platform_data {
102 TAILQ_HEAD(endpoint_list, endpoint) endpoints;
103 enum cs_bus_type bus_type;
106 struct coresight_desc {
107 struct coresight_platform_data *pdata;
109 enum cs_dev_type dev_type;
112 TAILQ_HEAD(coresight_device_list, coresight_device);
114 #define ETM_N_COMPRATOR 16
128 #define ETR_FLAG_ALLOCATE (1 << 0)
129 #define ETR_FLAG_RELEASE (1 << 1)
132 struct coresight_event {
133 LIST_HEAD(, endpoint) endplist;
135 uint64_t addr[ETM_N_COMPRATOR];
138 enum cs_dev_type src;
139 enum cs_dev_type sink;
141 struct etr_state etr;
142 struct etm_state etm;
146 uint64_t addr[ETM_N_COMPRATOR];
151 static MALLOC_DEFINE(M_CORESIGHT, "coresight", "ARM Coresight");
153 struct coresight_platform_data *coresight_fdt_get_platform_data(device_t dev);
154 struct coresight_platform_data *coresight_acpi_get_platform_data(device_t dev);
155 struct endpoint * coresight_get_output_endpoint(struct coresight_platform_data *pdata);
156 struct coresight_device * coresight_get_output_device(struct endpoint *endp, struct endpoint **);
157 int coresight_register(struct coresight_desc *desc);
158 int coresight_init_event(int cpu, struct coresight_event *event);
159 void coresight_enable(int cpu, struct coresight_event *event);
160 void coresight_disable(int cpu, struct coresight_event *event);
161 void coresight_read(int cpu, struct coresight_event *event);
163 #endif /* !_ARM64_CORESIGHT_CORESIGHT_H_ */