gator: Version 5.18
[firefly-linux-kernel-4.4.55.git] / tools / gator / daemon / DriverSource.h
1 /**
2  * Copyright (C) ARM Limited 2010-2014. All rights reserved.
3  *
4  * This program is free software; you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License version 2 as
6  * published by the Free Software Foundation.
7  */
8
9 #ifndef DRIVERSOURCE_H
10 #define DRIVERSOURCE_H
11
12 #include <semaphore.h>
13 #include <stdint.h>
14
15 #include "Source.h"
16
17 class Fifo;
18
19 class DriverSource : public Source {
20 public:
21         DriverSource(sem_t *senderSem, sem_t *startProfile);
22         ~DriverSource();
23
24         bool prepare();
25         void run();
26         void interrupt();
27
28         bool isDone();
29         void write(Sender *sender);
30
31         static int readIntDriver(const char *fullpath, int *value);
32         static int readInt64Driver(const char *fullpath, int64_t *value);
33         static int writeDriver(const char *fullpath, const char *data);
34         static int writeDriver(const char *path, int value);
35         static int writeDriver(const char *path, int64_t value);
36         static int writeReadDriver(const char *path, int *value);
37         static int writeReadDriver(const char *path, int64_t *value);
38
39 private:
40         Fifo *mFifo;
41         sem_t *const mSenderSem;
42         sem_t *const mStartProfile;
43         int mBufferSize;
44         int mBufferFD;
45         int mLength;
46
47         // Intentionally unimplemented
48         DriverSource(const DriverSource &);
49         DriverSource &operator=(const DriverSource &);
50 };
51
52 #endif // DRIVERSOURCE_H