aboutsummaryrefslogtreecommitdiff
path: root/write-stm-device/stm_user_api.h
blob: 0f9299eb984c705c0fd03ded14afc78cbfcf2da7 (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
#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 */