aboutsummaryrefslogtreecommitdiff
path: root/tools/gator/daemon/DriverSource.h
blob: 32d983d6d0362d43a176e9d50559c2511a16b2b4 (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
/**
 * Copyright (C) ARM Limited 2010-2015. All rights reserved.
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License version 2 as
 * published by the Free Software Foundation.
 */

#ifndef DRIVERSOURCE_H
#define DRIVERSOURCE_H

#include <semaphore.h>
#include <stdint.h>

#include "Source.h"

class Buffer;
class Fifo;

class DriverSource : public Source {
public:
	DriverSource(sem_t *senderSem, sem_t *startProfile);
	~DriverSource();

	bool prepare();
	void run();
	void interrupt();

	bool isDone();
	void write(Sender *sender);

	static int readIntDriver(const char *fullpath, int *value);
	static int readInt64Driver(const char *fullpath, int64_t *value);
	static int writeDriver(const char *fullpath, const char *data);
	static int writeDriver(const char *path, int value);
	static int writeDriver(const char *path, int64_t value);
	static int writeReadDriver(const char *path, int *value);
	static int writeReadDriver(const char *path, int64_t *value);

private:
	static void *bootstrapThreadStatic(void *arg);
	void bootstrapThread();

	Buffer *mBuffer;
	Fifo *mFifo;
	sem_t *const mSenderSem;
	sem_t *const mStartProfile;
	int mBufferSize;
	int mBufferFD;
	int mLength;

	// Intentionally unimplemented
	DriverSource(const DriverSource &);
	DriverSource &operator=(const DriverSource &);
};

#endif // DRIVERSOURCE_H