From 7a558dd1c1e537682bbf494d53ee3f19ef45e736 Mon Sep 17 00:00:00 2001 From: Chunyan Zhang Date: Wed, 20 Apr 2016 13:36:51 +0800 Subject: [PATCH 1/7] cs-stm: mmap: add low-level userspace API and example program The trace data in this example can be decoded successfully. Signed-off-by: Chunyan Zhang --- mmap-wrapper/Makefile | 15 +++ mmap-wrapper/example.c | 39 +++++++ mmap-wrapper/stm_user_api.c | 219 ++++++++++++++++++++++++++++++++++++ mmap-wrapper/stm_user_api.h | 64 +++++++++++ 4 files changed, 337 insertions(+) create mode 100644 mmap-wrapper/Makefile create mode 100644 mmap-wrapper/example.c create mode 100644 mmap-wrapper/stm_user_api.c create mode 100644 mmap-wrapper/stm_user_api.h diff --git a/mmap-wrapper/Makefile b/mmap-wrapper/Makefile new file mode 100644 index 0000000..63b5578 --- /dev/null +++ b/mmap-wrapper/Makefile @@ -0,0 +1,15 @@ +CROSS_COMPILE := /home/zcy/tools/gcc-linaro-aarch64-linux-gnu-4.9-2014.09_linux/bin/aarch64-linux-gnu- +CC := $(CROSS_COMPILE)gcc +CFLAGS := --static + +STM_USER = stm_user_example + +OBJS_STM_USER_API= example.o stm_user_api.o + +all: $(STM_USER) + +$(STM_USER):$(OBJS_STM_USER_API) + $(CC) $(CFLAGS) -o $@ $^ + +clean: + rm *.o $(STM_USER) diff --git a/mmap-wrapper/example.c b/mmap-wrapper/example.c new file mode 100644 index 0000000..cb3894d --- /dev/null +++ b/mmap-wrapper/example.c @@ -0,0 +1,39 @@ +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include "stm_user_api.h" + +extern struct stm_dev g_stm_dev; + +void main() +{ + int i; + unsigned int chan_start = 0; + unsigned width = PAGE_SIZE / BYTES_PER_CHANNEL; + unsigned int flags = STM_FLAG_TIMESTAMPED; + unsigned int dsize; + char *offset, *data; + unsigned int wrbytes = sizeof(unsigned int) * TEST_DATA_SIZE; + unsigned int real_wrbytes; + unsigned int trace_data[TEST_DATA_SIZE] = {0x5555aaaa, 0xaaaa5555, 0x66666666, 0x99999999}; + + if (request_stm_resource(&g_stm_dev, chan_start, width)) + return; + + /* + * You can use any channel between [g_stm_dev.policy->channel ... + * (g_stm_dev.policy->channel + g_stm_dev.policy->width)] + */ + real_wrbytes = stm_trace_data(&g_stm_dev, chan_start, flags, wrbytes, trace_data); + if (real_wrbytes != wrbytes) + printf("write %d bytes and left % bytes data\n", real_wrbytes, wrbytes - real_wrbytes); + + release_stm_reaource(&g_stm_dev); +} diff --git a/mmap-wrapper/stm_user_api.c b/mmap-wrapper/stm_user_api.c new file mode 100644 index 0000000..30732f1 --- /dev/null +++ b/mmap-wrapper/stm_user_api.c @@ -0,0 +1,219 @@ +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include "stm_user_api.h" + +static void enable_sink(const char *dev_name) +{ + char buf[256] = {0}; + sprintf(buf, "echo 1 > /sys/bus/coresight/devices/%s/enable_sink", + dev_name); + system(buf); +} + +static int set_policy(int fd, struct stp_policy_id *policy, + unsigned int chan, unsigned int width) +{ + unsigned int chan_perpage = PAGE_SIZE / BYTES_PER_CHANNEL; + + if(width % chan_perpage || chan % chan_perpage) { + chan = chan / chan_perpage; + width = (width / chan_perpage + 1) * BYTES_PER_CHANNEL; + } + + policy->channel = chan; + policy->__reserved_0 = 0; + policy->__reserved_1 = 0; + policy->width = width; + policy->size = sizeof(struct stp_policy_id) + POLICY_NAME_LEN; + memcpy(policy->id, STP_POLICY_NAME, POLICY_NAME_LEN); + + if (ioctl(fd, STP_POLICY_ID_SET, policy) == -1) { + printf("STP_POLICY_ID_SET failed %s %d\n", + strerror(errno), errno); + return -1; + } + + return 0; +} + +/* + * dev - storing the information of stimulus resources and STM device + * chan - the start index of channels + * width- the number of channels for request + */ +int request_stm_resource(struct stm_dev *dev, unsigned int chan, + unsigned int width) +{ + int fd; + int ret = 0; + char *map; + struct stp_policy_id *policy; + unsigned int length = STM_MAP_SIZE; + unsigned long offset = STM_MAP_OFFSET; + + if ((fd = open(STM_DEVICE_NAME, O_RDWR | O_SYNC)) == -1) { + printf("Failed to open %s %s\n", STM_DEVICE_NAME, + strerror(errno)); + return -1; + } + dev->fd = fd; + + /* + * Before allocating a policy for STM, the sink connected with STM must + * be enabled. + */ + enable_sink(TMC_SYS_NAME); + + /* set a master/channel policy for this STM device, this + * is because that kernel have to know how many channels + * would be mapped, and the size of mapped memory must be + * a multiple of page size. + */ + dev->policy = malloc(sizeof(struct stp_policy_id) + POLICY_NAME_LEN); + if (!dev->policy) { + ret = -1; + printf("Failed to malloc policy.\n"); + goto out; + } + + if (set_policy(fd, dev->policy, chan, width)) { + ret = -1; + printf("Failed to set policy.\n"); + goto out; + } + + map = (char *)mmap(0, length, PROT_READ|PROT_WRITE, + MAP_SHARED, fd, offset); + if (map == MAP_FAILED) { + ret = -1; + printf("Failed to map %s\n", strerror(errno)); + goto out; + } + + dev->mmap.map = map; + dev->mmap.start = 0; + dev->mmap.length = length; + printf("Success to map channel(%u~%u) to 0x%lx\n", + dev->policy->channel, + (dev->policy->width + dev->policy->channel - 1), + (unsigned long)map); + + return ret; + +out: + release_stm_reaource(dev); + return ret; +} + +void release_stm_reaource(struct stm_dev *dev) +{ + /* unmap the area & error checking */ + if (dev->mmap.map) { + if (munmap(dev->mmap.map, dev->mmap.length) == -1) + perror("user: Error un-mmapping the file"); + dev->mmap.map = NULL; + } + if (dev->policy) { + free(dev->policy); + dev->policy = NULL; + } + if (dev->fd) { + close(dev->fd); + dev->fd = 0; + } +} + +static char *stm_channel_addr(struct stm_dev *dev, unsigned int chan, + unsigned int flags, unsigned int type) +{ + if (chan < dev->policy->channel || + chan >= dev->policy->channel + dev->policy->width) { + printf("Channel index should be in [%u...%u]\n", + dev->policy->channel, + dev->policy->channel + dev->policy->width); + return NULL; + } + + chan -= dev->policy->channel; + + return (char *)(((unsigned long)dev->mmap.map + + chan * BYTES_PER_CHANNEL) | + ((~flags) & type)); +} + +static unsigned int stm_dsize(const char *dev_name) +{ + FILE *file; + unsigned int size = 0; + char buf[128] = {0}; + char spfeat2r[16] = {0}; + int dsize = 0; + + sprintf(buf, "/sys/bus/coresight/devices/%s/mgmt/spfeat2r", dev_name); + file = fopen(buf, "r"); + /* + * the first two characters in file are '0x', like: + * # cat /sys/bus/coresight/devices/10006000.stm/mgmt/spfeat2r + * 0x104f2 + */ + fseek(file, 2, SEEK_END); + size = ftell (file); + fseek(file, 2, SEEK_SET); + if (fgets(spfeat2r, size, file)) + dsize = strtol(spfeat2r, NULL, 16); + fclose(file); + + return (dsize >> 12) & 0xf; +} + +unsigned int stm_wrbytes(const char *dev_name) +{ + /* + * Fundamental data size: + * 0b0001 - 64-bit data. + */ + return stm_dsize(dev_name) ? 8: 4; +} + +static unsigned int stm_write(char *addr, void *data, unsigned int size) +{ + unsigned int wrbytes = stm_wrbytes(STM_SYS_NAME); + if (size > wrbytes) + size = wrbytes; + + memcpy(addr, (char *)data, size); + return size; +} + +int stm_trace_data(struct stm_dev *dev, unsigned int chan, int flags, + unsigned int size, void *data) +{ + int i = 0; + char *addr = stm_channel_addr(dev, chan, flags, STM_PKT_TYPE_DATA); + unsigned int real_wrbytes, len = size; + char *pdata = data, nil = 0; + + if (!addr) + return -1; + + do { + real_wrbytes = stm_write(addr, pdata, len); + pdata += real_wrbytes; + len -= real_wrbytes; + if (++i == 1) + addr = stm_channel_addr(dev, chan, 0, STM_PKT_TYPE_DATA); + } while(len); + + addr = stm_channel_addr(dev, chan, 0, STM_PKT_TYPE_FLAG); + stm_write(addr, &nil, 1); + + return size; +} diff --git a/mmap-wrapper/stm_user_api.h b/mmap-wrapper/stm_user_api.h new file mode 100644 index 0000000..47973b4 --- /dev/null +++ b/mmap-wrapper/stm_user_api.h @@ -0,0 +1,64 @@ +#ifndef __STM_USER_API_H +#define __STM_USER_API_H + +#define BYTES_PER_CHANNEL 256 +#define PAGE_SIZE sysconf(_SC_PAGE_SIZE) +#define STM_MAP_OFFSET 0x0 +#define STM_MAP_SIZE PAGE_SIZE +#define STM_DEVICE_NAME "/dev/10006000.stm" +#define TMC_SYS_NAME "10003000.etf" +#define STM_SYS_NAME "10006000.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 mem_map { + unsigned long start; + unsigned long length; + char *map; +}; + +struct stm_dev { + int fd; + struct stp_policy_id *policy; + struct mem_map mmap; +} g_stm_dev; + +unsigned int stm_wrbytes(const char *dev_name); +int request_stm_resource(struct stm_dev *dev, unsigned int chan, + unsigned int width); +void release_stm_reaource(struct stm_dev *dev); +int stm_trace_data(struct stm_dev *dev, unsigned int chan, + int flags, unsigned int size, void *data); + +#endif /* __STM_USER_API_H */ From bd01e26f2df3ba440bf9166ec78ac243208c0504 Mon Sep 17 00:00:00 2001 From: Chunyan Zhang Date: Wed, 20 Apr 2016 14:01:25 +0800 Subject: [PATCH 2/7] mmap-wrapper: add readme Signed-off-by: Chunyan Zhang --- mmap-wrapper/readme | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 mmap-wrapper/readme diff --git a/mmap-wrapper/readme b/mmap-wrapper/readme new file mode 100644 index 0000000..fa19ef7 --- /dev/null +++ b/mmap-wrapper/readme @@ -0,0 +1,5 @@ +Before compiling the program, you must change the items below accroding to your environment: + +- 'CROSS_COMPILE' in Makefile +- STM device name in stm_user_api.h +- TMC device name in stm_user_api.h From 9ff72664491eadc03e28e011a246c4d3becbaf6d Mon Sep 17 00:00:00 2001 From: Chunyan Zhang Date: Wed, 1 Jun 2016 14:10:04 +0800 Subject: [PATCH 3/7] stm_user_api: fix a typo Signed-off-by: Chunyan Zhang --- mmap-wrapper/example.c | 2 +- mmap-wrapper/stm_user_api.c | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/mmap-wrapper/example.c b/mmap-wrapper/example.c index cb3894d..c44ede0 100644 --- a/mmap-wrapper/example.c +++ b/mmap-wrapper/example.c @@ -35,5 +35,5 @@ void main() if (real_wrbytes != wrbytes) printf("write %d bytes and left % bytes data\n", real_wrbytes, wrbytes - real_wrbytes); - release_stm_reaource(&g_stm_dev); + release_stm_resource(&g_stm_dev); } diff --git a/mmap-wrapper/stm_user_api.c b/mmap-wrapper/stm_user_api.c index 30732f1..878f3a0 100644 --- a/mmap-wrapper/stm_user_api.c +++ b/mmap-wrapper/stm_user_api.c @@ -109,11 +109,11 @@ int request_stm_resource(struct stm_dev *dev, unsigned int chan, return ret; out: - release_stm_reaource(dev); + release_stm_resource(dev); return ret; } -void release_stm_reaource(struct stm_dev *dev) +void release_stm_resource(struct stm_dev *dev) { /* unmap the area & error checking */ if (dev->mmap.map) { From 67032699247b3fca6e868e44dfcac715125a06fe Mon Sep 17 00:00:00 2001 From: Chunyan Zhang Date: Tue, 12 Jul 2016 19:44:43 +0800 Subject: [PATCH 4/7] readme: added information on operation of configfs Signed-off-by: Chunyan Zhang --- mmap-wrapper/readme | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/mmap-wrapper/readme b/mmap-wrapper/readme index fa19ef7..b3d111e 100644 --- a/mmap-wrapper/readme +++ b/mmap-wrapper/readme @@ -3,3 +3,15 @@ Before compiling the program, you must change the items below accroding to your - 'CROSS_COMPILE' in Makefile - STM device name in stm_user_api.h - TMC device name in stm_user_api.h + +And then you may need to mount configfs manually: +mount -t configfs none /config + +Create policy directory for STM: +mkdir /config/stp-policy/10006000.stm.abc + +NOTE: +The STM directory name consists of the device name to which it applies and the actual policy name, +separated by a dot. +The device name (say 10006000.stm) have to be matched the name of STM device under /dev. +The suffix is a random string without any dot From 4b26b529017da424efc1d62eade1230583dd1808 Mon Sep 17 00:00:00 2001 From: Chunyan Zhang Date: Fri, 15 Jul 2016 15:54:51 +0800 Subject: [PATCH 5/7] stm_user_api: changed to support Juno-r0 The channels 0~15 on Juno-r0 seem not permitted to be writen, this patch also change the start channel of mmap from 0 to 32768. The STM channel management policy will allocate the channels automatically from all unused channels. So if we want to mmap from a non-zero channel, we have to config the channel range manually, like below: / # mkdir /config/stp-policy/20100000.stm.abc / # mkdir /config/stp-policy/20100000.stm.abc/test / # echo 32768 65535 > config/stp-policy/20100000.stm.abc/test/channels Here '32768' is just the channel number from which we want to mmap STM stimulus space; 'test' is the policy name which we will use to mmap channel area. Signed-off-by: Chunyan Zhang --- mmap-wrapper/example.c | 8 ++++++-- mmap-wrapper/stm_user_api.c | 24 +++++++++++++++++++----- mmap-wrapper/stm_user_api.h | 13 ++++++++----- 3 files changed, 33 insertions(+), 12 deletions(-) diff --git a/mmap-wrapper/example.c b/mmap-wrapper/example.c index c44ede0..8e85d8e 100644 --- a/mmap-wrapper/example.c +++ b/mmap-wrapper/example.c @@ -15,7 +15,7 @@ extern struct stm_dev g_stm_dev; void main() { int i; - unsigned int chan_start = 0; + unsigned int chan_start = 32768; unsigned width = PAGE_SIZE / BYTES_PER_CHANNEL; unsigned int flags = STM_FLAG_TIMESTAMPED; unsigned int dsize; @@ -29,11 +29,15 @@ void main() /* * You can use any channel between [g_stm_dev.policy->channel ... - * (g_stm_dev.policy->channel + g_stm_dev.policy->width)] + * (g_stm_dev.policy->channel + g_stm_dev.policy->width)] + * and width must <= (PAGE_SIZE / BYTES_PER_CHANNEL) + * http://lxr.free-electrons.com/source/drivers/hwtracing/stm/core.c?v=4.6#L542 */ real_wrbytes = stm_trace_data(&g_stm_dev, chan_start, flags, wrbytes, trace_data); if (real_wrbytes != wrbytes) printf("write %d bytes and left % bytes data\n", real_wrbytes, wrbytes - real_wrbytes); + + printf("Success to write %d bytes\n", real_wrbytes); release_stm_resource(&g_stm_dev); } diff --git a/mmap-wrapper/stm_user_api.c b/mmap-wrapper/stm_user_api.c index 878f3a0..296d5eb 100644 --- a/mmap-wrapper/stm_user_api.c +++ b/mmap-wrapper/stm_user_api.c @@ -10,11 +10,21 @@ #include #include "stm_user_api.h" -static void enable_sink(const char *dev_name) +void release_stm_resource(struct stm_dev *dev); + +static void enable_sink(const char *dev_name, unsigned int enable) { char buf[256] = {0}; - sprintf(buf, "echo 1 > /sys/bus/coresight/devices/%s/enable_sink", - dev_name); + sprintf(buf, "echo %u > /sys/bus/coresight/devices/%s/enable_sink", + enable, dev_name); + system(buf); +} + +static void enable_source(const char *dev_name, unsigned int enable) +{ + char buf[256] = {0}; + sprintf(buf, "echo %u > /sys/bus/coresight/devices/%s/enable_source", + enable, dev_name); system(buf); } @@ -57,7 +67,7 @@ int request_stm_resource(struct stm_dev *dev, unsigned int chan, char *map; struct stp_policy_id *policy; unsigned int length = STM_MAP_SIZE; - unsigned long offset = STM_MAP_OFFSET; + unsigned long offset = 0; if ((fd = open(STM_DEVICE_NAME, O_RDWR | O_SYNC)) == -1) { printf("Failed to open %s %s\n", STM_DEVICE_NAME, @@ -70,7 +80,8 @@ int request_stm_resource(struct stm_dev *dev, unsigned int chan, * Before allocating a policy for STM, the sink connected with STM must * be enabled. */ - enable_sink(TMC_SYS_NAME); + enable_sink(ETF_SYS_NAME, 1); + enable_sink(ETR_SYS_NAME, 1); /* set a master/channel policy for this STM device, this * is because that kernel have to know how many channels @@ -129,6 +140,8 @@ void release_stm_resource(struct stm_dev *dev) close(dev->fd); dev->fd = 0; } + + enable_source(STM_SYS_NAME, 0); } static char *stm_channel_addr(struct stm_dev *dev, unsigned int chan, @@ -190,6 +203,7 @@ static unsigned int stm_write(char *addr, void *data, unsigned int size) size = wrbytes; memcpy(addr, (char *)data, size); + printf("memcpy %u bytes data to the address %p\n", size ,addr); return size; } diff --git a/mmap-wrapper/stm_user_api.h b/mmap-wrapper/stm_user_api.h index 47973b4..d13428d 100644 --- a/mmap-wrapper/stm_user_api.h +++ b/mmap-wrapper/stm_user_api.h @@ -2,12 +2,15 @@ #define __STM_USER_API_H #define BYTES_PER_CHANNEL 256 -#define PAGE_SIZE sysconf(_SC_PAGE_SIZE) -#define STM_MAP_OFFSET 0x0 +#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/10006000.stm" -#define TMC_SYS_NAME "10003000.etf" -#define STM_SYS_NAME "10006000.stm" + +#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 From d5ccbe9ce567f0bbe3ac908e402f95759df26482 Mon Sep 17 00:00:00 2001 From: Chunyan Zhang Date: Fri, 15 Jul 2016 16:14:23 +0800 Subject: [PATCH 6/7] readme: added the explanation of how to create channel management policy Signed-off-by: Chunyan Zhang --- mmap-wrapper/readme | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/mmap-wrapper/readme b/mmap-wrapper/readme index b3d111e..74d492a 100644 --- a/mmap-wrapper/readme +++ b/mmap-wrapper/readme @@ -4,14 +4,25 @@ Before compiling the program, you must change the items below accroding to your - STM device name in stm_user_api.h - TMC device name in stm_user_api.h + And then you may need to mount configfs manually: -mount -t configfs none /config +/ # mount -t configfs none /config + Create policy directory for STM: -mkdir /config/stp-policy/10006000.stm.abc +/ # mkdir /config/stp-policy/10006000.stm.abc NOTE: The STM directory name consists of the device name to which it applies and the actual policy name, separated by a dot. The device name (say 10006000.stm) have to be matched the name of STM device under /dev. The suffix is a random string without any dot + + +Create policy: +/ # mkdir /config/stp-policy/20100000.stm.abc/test +/ # echo 32768 65535 > /config/stp-policy/20100000.stm.abc/test/channels + +'chan_start' (here is 32768) must be same with the corresponding value in example.c + + From c2ea0fa84470e684f00ac954d88638925a1ebde6 Mon Sep 17 00:00:00 2001 From: Chunyan Zhang Date: Fri, 17 Mar 2017 15:53:18 +0800 Subject: [PATCH 7/7] Switch to support SC9836 This patch also removed enable_source, since closing the STM device will turn off it automatically, so don't need to disable STM via sysfs command. Signed-off-by: Chunyan Zhang --- mmap-wrapper/example.c | 8 +++++--- mmap-wrapper/readme | 4 ++-- mmap-wrapper/stm_user_api.c | 12 +----------- mmap-wrapper/stm_user_api.h | 9 +++++---- 4 files changed, 13 insertions(+), 20 deletions(-) diff --git a/mmap-wrapper/example.c b/mmap-wrapper/example.c index 8e85d8e..bbeaec1 100644 --- a/mmap-wrapper/example.c +++ b/mmap-wrapper/example.c @@ -33,10 +33,12 @@ void main() * and width must <= (PAGE_SIZE / BYTES_PER_CHANNEL) * http://lxr.free-electrons.com/source/drivers/hwtracing/stm/core.c?v=4.6#L542 */ - real_wrbytes = stm_trace_data(&g_stm_dev, chan_start, flags, wrbytes, trace_data); + real_wrbytes = stm_trace_data(&g_stm_dev, chan_start, flags, + wrbytes, trace_data); if (real_wrbytes != wrbytes) - printf("write %d bytes and left % bytes data\n", real_wrbytes, wrbytes - real_wrbytes); - + printf("write %d bytes and left % bytes data\n", + real_wrbytes, wrbytes - real_wrbytes); + printf("Success to write %d bytes\n", real_wrbytes); release_stm_resource(&g_stm_dev); diff --git a/mmap-wrapper/readme b/mmap-wrapper/readme index 74d492a..1e04291 100644 --- a/mmap-wrapper/readme +++ b/mmap-wrapper/readme @@ -20,8 +20,8 @@ The suffix is a random string without any dot Create policy: -/ # mkdir /config/stp-policy/20100000.stm.abc/test -/ # echo 32768 65535 > /config/stp-policy/20100000.stm.abc/test/channels +/ # mkdir /config/stp-policy/10006000.stm.abc/test +/ # echo 32768 65535 > /config/stp-policy/10006000.stm.abc/test/channels 'chan_start' (here is 32768) must be same with the corresponding value in example.c diff --git a/mmap-wrapper/stm_user_api.c b/mmap-wrapper/stm_user_api.c index 296d5eb..79e3cce 100644 --- a/mmap-wrapper/stm_user_api.c +++ b/mmap-wrapper/stm_user_api.c @@ -20,14 +20,6 @@ static void enable_sink(const char *dev_name, unsigned int enable) system(buf); } -static void enable_source(const char *dev_name, unsigned int enable) -{ - char buf[256] = {0}; - sprintf(buf, "echo %u > /sys/bus/coresight/devices/%s/enable_source", - enable, dev_name); - system(buf); -} - static int set_policy(int fd, struct stp_policy_id *policy, unsigned int chan, unsigned int width) { @@ -81,7 +73,7 @@ int request_stm_resource(struct stm_dev *dev, unsigned int chan, * be enabled. */ enable_sink(ETF_SYS_NAME, 1); - enable_sink(ETR_SYS_NAME, 1); + /* enable_sink(ETR_SYS_NAME, 1); */ /* set a master/channel policy for this STM device, this * is because that kernel have to know how many channels @@ -140,8 +132,6 @@ void release_stm_resource(struct stm_dev *dev) close(dev->fd); dev->fd = 0; } - - enable_source(STM_SYS_NAME, 0); } static char *stm_channel_addr(struct stm_dev *dev, unsigned int chan, diff --git a/mmap-wrapper/stm_user_api.h b/mmap-wrapper/stm_user_api.h index d13428d..39c6f0d 100644 --- a/mmap-wrapper/stm_user_api.h +++ b/mmap-wrapper/stm_user_api.h @@ -6,10 +6,11 @@ #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 STM_DEVICE_NAME "/dev/10006000.stm" +#define ETF_SYS_NAME "10003000.etf" +/* Juno ETR */ +/*#define ETR_SYS_NAME "20070000.etr"*/ +#define STM_SYS_NAME "10006000.stm" #define STP_POLICY_NAME "test" #define TEST_DATA_SIZE 4