vfs: check userland buffers before reading them.
[haiku.git] / src / system / kernel / device_manager / IOScheduler.h
blob7cfe27a68d44a6ebfe884f1ba6753e485401358a
1 /*
2 * Copyright 2010, Ingo Weinhold, ingo_weinhold@gmx.de.
3 * Distributed under the terms of the MIT License.
4 */
5 #ifndef IO_SCHEDULER_H
6 #define IO_SCHEDULER_H
9 #include <KernelExport.h>
11 #include <util/DoublyLinkedList.h>
13 #include "IOCallback.h"
14 #include "IORequest.h"
17 struct IORequestOwner : DoublyLinkedListLinkImpl<IORequestOwner> {
18 team_id team;
19 thread_id thread;
20 int32 priority;
21 IORequestList requests;
22 IORequestList completed_requests;
23 IOOperationList operations;
24 IORequestOwner* hash_link;
26 bool IsActive() const
27 { return !requests.IsEmpty()
28 || !completed_requests.IsEmpty()
29 || !operations.IsEmpty(); }
31 void Dump() const;
35 class IOScheduler : public DoublyLinkedListLinkImpl<IOScheduler> {
36 public:
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,
56 status_t status,
57 generic_size_t transferredBytes) = 0;
58 // called by the driver when the operation
59 // has been completed successfully or failed
60 // for some reason
62 virtual void Dump() const = 0;
64 protected:
65 DMAResource* fDMAResource;
66 char* fName;
67 int32 fID;
68 io_callback fIOCallback;
69 void* fIOCallbackData;
70 bool fSchedulerRegistered;
74 #endif // IO_SCHEDULER_H