summaryrefslogtreecommitdiff
path: root/tools/gator/daemon/ExternalSource.h
blob: c146bfe21d29092d4e18cb8eb2e678def1d701fb (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-2016. 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 EXTERNALSOURCE_H
#define EXTERNALSOURCE_H

#include <semaphore.h>

#include "Buffer.h"
#include "Monitor.h"
#include "OlySocket.h"
#include "Source.h"

// Counters from external sources like graphics drivers and annotations
class ExternalSource : public Source {
public:
	ExternalSource(sem_t *senderSem);
	~ExternalSource();

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

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

private:
	void waitFor(const int bytes);
	void configureConnection(const int fd, const char *const handshake, size_t size);
	bool connectMidgard();
	bool connectMve();
	void connectFtrace();
	bool transfer(const uint64_t currTime, const int fd);

	sem_t mBufferSem;
	Buffer mBuffer;
	Monitor mMonitor;
	OlyServerSocket mMveStartupUds;
	OlyServerSocket mMidgardStartupUds;
	OlyServerSocket mUtgardStartupUds;
	OlyServerSocket mAnnotate;
	OlyServerSocket mAnnotateUds;
	int mInterruptFd;
	int mMidgardUds;
	int mMveUds;

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

#endif // EXTERNALSOURCE_H