2 * Copyright 2010, Ingo Weinhold, ingo_weinhold@gmx.de.
3 * Distributed under the terms of the MIT License.
9 #include <KernelExport.h>
11 #include <util/DoublyLinkedList.h>
13 #include "IOCallback.h"
14 #include "IORequest.h"
17 struct IORequestOwner
: DoublyLinkedListLinkImpl
<IORequestOwner
> {
21 IORequestList requests
;
22 IORequestList completed_requests
;
23 IOOperationList operations
;
24 IORequestOwner
* hash_link
;
27 { return !requests
.IsEmpty()
28 || !completed_requests
.IsEmpty()
29 || !operations
.IsEmpty(); }
35 class IOScheduler
: public DoublyLinkedListLinkImpl
<IOScheduler
> {
37 IOScheduler(DMAResource
* resource
);
38 virtual ~IOScheduler();
40 virtual status_t
Init(const char* name
);
42 const char* Name() const { return fName
; }
43 int32
ID() const { return fID
; }
45 virtual void SetCallback(IOCallback
& callback
);
46 virtual void SetCallback(io_callback callback
, void* data
);
48 virtual void SetDeviceCapacity(off_t deviceCapacity
);
49 virtual void MediaChanged();
51 virtual status_t
ScheduleRequest(IORequest
* request
) = 0;
53 virtual void AbortRequest(IORequest
* request
,
54 status_t status
= B_CANCELED
) = 0;
55 virtual void OperationCompleted(IOOperation
* operation
,
57 generic_size_t transferredBytes
) = 0;
58 // called by the driver when the operation
59 // has been completed successfully or failed
62 virtual void Dump() const = 0;
65 DMAResource
* fDMAResource
;
68 io_callback fIOCallback
;
69 void* fIOCallbackData
;
70 bool fSchedulerRegistered
;
74 #endif // IO_SCHEDULER_H