IOCache implements IOScheduler, now.

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@36494 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Ingo Weinhold 2010-04-26 15:43:20 +00:00
parent 2eab54201c
commit 5060d7980f
2 changed files with 31 additions and 32 deletions

View File

@ -40,12 +40,10 @@ struct IOCache::Operation : IOOperation {
IOCache::IOCache(DMAResource* resource, size_t cacheLineSize)
:
IOScheduler(resource),
fDeviceCapacity(0),
fLineSize(cacheLineSize),
fPagesPerLine(cacheLineSize / B_PAGE_SIZE),
fDMAResource(resource),
fIOCallback(NULL),
fIOCallbackData(NULL),
fArea(-1),
fCache(NULL),
fPages(NULL),
@ -89,6 +87,10 @@ IOCache::Init(const char* name)
{
TRACE("%p->IOCache::Init(\"%s\")\n", this, name);
status_t error = IOScheduler::Init(name);
if (error != B_OK)
return error;
// create the area for mapping cache lines
fArea = vm_create_null_area(B_SYSTEM_TEAM, "I/O cache line", &fAreaBase,
B_ANY_KERNEL_ADDRESS, fLineSize, 0);
@ -121,21 +123,6 @@ IOCache::Init(const char* name)
}
void
IOCache::SetCallback(IOCallback& callback)
{
SetCallback(&IOCallback::WrapperFunction, &callback);
}
void
IOCache::SetCallback(io_callback callback, void* data)
{
fIOCallback = callback;
fIOCallbackData = data;
}
void
IOCache::SetDeviceCapacity(off_t deviceCapacity)
{
@ -194,6 +181,13 @@ IOCache::ScheduleRequest(IORequest* request)
}
void
IOCache::AbortRequest(IORequest* request, status_t status)
{
// TODO:...
}
void
IOCache::OperationCompleted(IOOperation* operation, status_t status,
size_t transferredBytes)
@ -207,6 +201,14 @@ IOCache::OperationCompleted(IOOperation* operation, status_t status,
}
void
IOCache::Dump() const
{
kprintf("IOCache at %p\n", this);
kprintf(" DMA resource: %p\n", fDMAResource);
}
status_t
IOCache::_DoRequest(IORequest* request, size_t& _bytesTransferred)
{

View File

@ -10,32 +10,32 @@
#include <vm/vm_page.h>
#include "dma_resources.h"
#include "IOCallback.h"
#include "IORequest.h"
#include "IOScheduler.h"
struct VMCache;
struct vm_page;
class IOCache {
class IOCache : public IOScheduler {
public:
IOCache(DMAResource* resource,
size_t cacheLineSize);
~IOCache();
virtual ~IOCache();
status_t Init(const char* name);
virtual status_t Init(const char* name);
void SetCallback(IOCallback& callback);
void SetCallback(io_callback callback, void* data);
virtual void SetDeviceCapacity(off_t deviceCapacity);
void SetDeviceCapacity(off_t deviceCapacity);
virtual status_t ScheduleRequest(IORequest* request);
status_t ScheduleRequest(IORequest* request);
void OperationCompleted(IOOperation* operation,
virtual void AbortRequest(IORequest* request,
status_t status = B_CANCELED);
virtual void OperationCompleted(IOOperation* operation,
status_t status, size_t transferredBytes);
virtual void Dump() const;
private:
struct Operation;
@ -70,9 +70,6 @@ private:
size_t fLineSize;
uint32 fLineSizeShift;
size_t fPagesPerLine;
DMAResource* fDMAResource;
io_callback fIOCallback;
void* fIOCallbackData;
area_id fArea;
void* fAreaBase;
vm_page_reservation fMappingReservation;