2 * Copyright 2013, Jérôme Duval, korli@users.berlios.de.
3 * Distributed under the terms of the MIT License.
5 #ifndef VIRTIO_RNG_PRIVATE_H
6 #define VIRTIO_RNG_PRIVATE_H
9 #include <condition_variable.h>
15 //#define TRACE_VIRTIO_RNG
16 #ifdef TRACE_VIRTIO_RNG
17 # define TRACE(x...) dprintf("virtio_rng: " x)
19 # define TRACE(x...) ;
21 #define ERROR(x...) dprintf("\33[33mvirtio_rng:\33[0m " x)
22 #define CALLED() TRACE("CALLED %s\n", __PRETTY_FUNCTION__)
25 extern device_manager_info
* gDeviceManager
;
26 extern random_for_controller_interface
*gRandom
;
29 #define BUFFER_SIZE 16
32 class VirtioRNGDevice
{
34 VirtioRNGDevice(device_node
* node
);
39 status_t
Read(void* buffer
, size_t* numBytes
);
43 static void _RequestCallback(void* driverCookie
,
45 void _RequestInterrupt();
49 virtio_device_interface
* fVirtio
;
50 virtio_device
* fVirtioDevice
;
54 ::virtio_queue fVirtioQueue
;
56 physical_entry fEntry
;
57 uint8 fBuffer
[BUFFER_SIZE
];
60 spinlock fInterruptLock
;
61 ConditionVariable fInterruptCondition
;
62 ConditionVariableEntry fInterruptConditionEntry
;
63 bool fExpectsInterrupt
;
67 #endif // VIRTIO_RNG_PRIVATE_H