2 * Copyright 2010, Ingo Weinhold, ingo_weinhold@gmx.de.
3 * Distributed under the terms of the MIT License.
10 #include <vm/vm_page.h>
12 #include "dma_resources.h"
13 #include "IOScheduler.h"
20 class IOCache
: public IOScheduler
{
22 IOCache(DMAResource
* resource
,
23 size_t cacheLineSize
);
26 virtual status_t
Init(const char* name
);
28 virtual void SetDeviceCapacity(off_t deviceCapacity
);
29 virtual void MediaChanged();
31 virtual status_t
ScheduleRequest(IORequest
* request
);
33 virtual void AbortRequest(IORequest
* request
,
34 status_t status
= B_CANCELED
);
35 virtual void OperationCompleted(IOOperation
* operation
,
37 generic_size_t transferredBytes
);
39 virtual void Dump() const;
45 status_t
_DoRequest(IORequest
* request
,
46 generic_size_t
& _bytesTransferred
);
47 status_t
_TransferRequestLine(IORequest
* request
,
48 off_t lineOffset
, size_t lineSize
,
49 off_t requestOffset
, size_t requestLength
);
50 status_t
_TransferRequestLineUncached(IORequest
* request
,
51 off_t lineOffset
, off_t requestOffset
,
52 size_t requestLength
);
53 status_t
_DoOperation(Operation
& operation
);
55 status_t
_TransferPages(size_t firstPage
,
56 size_t pageCount
, bool isWrite
, bool isVIP
);
57 void _DiscardPages(size_t firstPage
,
59 void _CachePages(size_t firstPage
, size_t pageCount
);
61 status_t
_CopyPages(IORequest
* request
,
62 size_t pagesRelativeOffset
,
63 off_t requestOffset
, size_t requestLength
,
66 status_t
_MapPages(size_t firstPage
, size_t endPage
);
67 void _UnmapPages(size_t firstPage
, size_t endPage
);
70 mutex fSerializationLock
;
71 off_t fDeviceCapacity
;
73 uint32 fLineSizeShift
;
77 vm_page_reservation fMappingReservation
;
80 generic_io_vec
* fVecs
;