1 /* 2 * Copyright 2013, Jérôme Duval, korli@users.berlios.de. 3 * Distributed under the terms of the MIT License. 4 */ 5 #ifndef VIRTIO_RNG_PRIVATE_H 6 #define VIRTIO_RNG_PRIVATE_H 7 8 9 #include <condition_variable.h> 10 #include <dpc.h> 11 #include <lock.h> 12 #include "random.h" 13 #include <virtio.h> 14 15 16 //#define TRACE_VIRTIO_RNG 17 #ifdef TRACE_VIRTIO_RNG 18 # define TRACE(x...) dprintf("virtio_rng: " x) 19 #else 20 # define TRACE(x...) ; 21 #endif 22 #define ERROR(x...) dprintf("\33[33mvirtio_rng:\33[0m " x) 23 #define CALLED() TRACE("CALLED %s\n", __PRETTY_FUNCTION__) 24 25 26 extern device_manager_info* gDeviceManager; 27 extern random_for_controller_interface *gRandom; 28 extern dpc_module_info *gDPC; 29 30 31 class VirtioRNGDevice { 32 public: 33 VirtioRNGDevice(device_node* node); 34 ~VirtioRNGDevice(); 35 36 status_t InitCheck(); 37 38 protected: 39 static int32 HandleTimerHook(struct timer* timer); 40 static void HandleDPC(void* arg); 41 42 private: 43 static void _RequestCallback(void* driverCookie, 44 void *cookie); 45 void _RequestInterrupt(); 46 status_t _Enqueue(); 47 48 virtio_device_interface* fVirtio; 49 virtio_device* fVirtioDevice; 50 51 status_t fStatus; 52 uint64 fFeatures; 53 ::virtio_queue fVirtioQueue; 54 55 spinlock fInterruptLock; 56 ConditionVariable fInterruptCondition; 57 bool fExpectsInterrupt; 58 59 timer fTimer; 60 void* fDPCHandle; 61 }; 62 63 64 #endif // VIRTIO_RNG_PRIVATE_H 65