aboutsummaryrefslogtreecommitdiff
path: root/write-stm-device/stm_user_api.h
diff options
context:
space:
mode:
authorChunyan Zhang <zhang.chunyan@linaro.org>2016-08-19 17:32:11 +0800
committerChunyan Zhang <zhang.chunyan@linaro.org>2016-08-19 21:05:42 +0800
commit8eb9940ca4591dd6b92788b2aad6d4056cd74ec7 (patch)
treebeca7c252cba467efff8dff25dc977009e581033 /write-stm-device/stm_user_api.h
parentd56178f9af7aa6803e8f6d59084a3a13d4f4c2e5 (diff)
downloadsample-app-8eb9940ca4591dd6b92788b2aad6d4056cd74ec7.tar.gz
stm-write: added a sample of writing STM device
This sample shows how to collect trace via write STM device. This is the first version of this sample. In this patch, before writing STM device we chose to set policy in the program, actually setting a policy before writing STM is not the only one choice, if no policy assigned to the STM device a policy named 'default' will be applied. Signed-off-by: Chunyan Zhang <zhang.chunyan@linaro.org>
Diffstat (limited to 'write-stm-device/stm_user_api.h')
-rw-r--r--write-stm-device/stm_user_api.h58
1 files changed, 58 insertions, 0 deletions
diff --git a/write-stm-device/stm_user_api.h b/write-stm-device/stm_user_api.h
new file mode 100644
index 0000000..0f9299e
--- /dev/null
+++ b/write-stm-device/stm_user_api.h
@@ -0,0 +1,58 @@
+#ifndef __STM_USER_API_H
+#define __STM_USER_API_H
+
+#define BYTES_PER_CHANNEL 256
+#define PAGE_SIZE sysconf(_SC_PAGE_SIZE) //4096
+#define MAP_MASK (PAGE_SIZE - 1)
+#define STM_MAP_SIZE PAGE_SIZE
+
+#define STM_DEVICE_NAME "/dev/20100000.stm"
+#define ETF_SYS_NAME "20010000.etf"
+#define ETR_SYS_NAME "20070000.etr"
+#define STM_SYS_NAME "20100000.stm"
+
+#define STP_POLICY_NAME "test"
+#define TEST_DATA_SIZE 4
+#define POLICY_NAME_LEN 8
+
+#define STP_POLICY_ID_SET _IOWR('%', 0, struct stp_policy_id)
+
+enum stm_flags {
+ STM_FLAG_TIMESTAMPED = 0x08,
+ STM_FLAG_MARKED = 0x10,
+ STM_FLAG_GUARANTEED = 0x80,
+};
+
+enum stm_pkt_type {
+ STM_PKT_TYPE_DATA = 0x98,
+ STM_PKT_TYPE_FLAG = 0xE8,
+ STM_PKT_TYPE_TRIG = 0xF8,
+};
+
+enum error_no {
+ E_COMMON = -1,
+};
+
+struct stp_policy_id {
+ unsigned int size;
+ unsigned short master;
+ unsigned short channel;
+ unsigned short width;
+ /* padding */
+ unsigned short __reserved_0;
+ unsigned int __reserved_1;
+ /* policy name */
+ char id[0];
+};
+
+struct stm_dev {
+ int fd;
+ struct stp_policy_id *policy;
+} g_stm_dev;
+
+int request_stm_resource(struct stm_dev *dev, unsigned int chan,
+ unsigned int width);
+void release_stm_reaource(struct stm_dev *dev);
+unsigned int stm_char_write(int fd, const char *data, unsigned int size);
+
+#endif /* __STM_USER_API_H */