Jon Medhurst | 15ce78d | 2014-04-10 09:02:02 +0100 | [diff] [blame] | 1 | /** |
Jon Medhurst | b1d0744 | 2015-05-08 12:04:18 +0100 | [diff] [blame] | 2 | * Copyright (C) ARM Limited 2010-2015. All rights reserved. |
Jon Medhurst | 15ce78d | 2014-04-10 09:02:02 +0100 | [diff] [blame] | 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 | |
Jon Medhurst | e31266f | 2014-08-04 15:47:44 +0100 | [diff] [blame] | 17 | class Buffer; |
Jon Medhurst | 15ce78d | 2014-04-10 09:02:02 +0100 | [diff] [blame] | 18 | class Fifo; |
| 19 | |
| 20 | class DriverSource : public Source { |
| 21 | public: |
| 22 | DriverSource(sem_t *senderSem, sem_t *startProfile); |
| 23 | ~DriverSource(); |
| 24 | |
| 25 | bool prepare(); |
| 26 | void run(); |
| 27 | void interrupt(); |
| 28 | |
| 29 | bool isDone(); |
| 30 | void write(Sender *sender); |
| 31 | |
| 32 | static int readIntDriver(const char *fullpath, int *value); |
| 33 | static int readInt64Driver(const char *fullpath, int64_t *value); |
| 34 | static int writeDriver(const char *fullpath, const char *data); |
| 35 | static int writeDriver(const char *path, int value); |
| 36 | static int writeDriver(const char *path, int64_t value); |
| 37 | static int writeReadDriver(const char *path, int *value); |
| 38 | static int writeReadDriver(const char *path, int64_t *value); |
| 39 | |
| 40 | private: |
Jon Medhurst | e31266f | 2014-08-04 15:47:44 +0100 | [diff] [blame] | 41 | static void *bootstrapThreadStatic(void *arg); |
| 42 | void bootstrapThread(); |
| 43 | |
| 44 | Buffer *mBuffer; |
Jon Medhurst | 15ce78d | 2014-04-10 09:02:02 +0100 | [diff] [blame] | 45 | Fifo *mFifo; |
| 46 | sem_t *const mSenderSem; |
| 47 | sem_t *const mStartProfile; |
| 48 | int mBufferSize; |
| 49 | int mBufferFD; |
| 50 | int mLength; |
| 51 | |
| 52 | // Intentionally unimplemented |
| 53 | DriverSource(const DriverSource &); |
| 54 | DriverSource &operator=(const DriverSource &); |
| 55 | }; |
| 56 | |
| 57 | #endif // DRIVERSOURCE_H |