[haiku-commits] r36494 - haiku/trunk/src/system/kernel/device_manager

Author: bonefish
Date: 2010-04-26 17:43:20 +0200 (Mon, 26 Apr 2010)
New Revision: 36494
Changeset: http://dev.haiku-os.org/changeset/36494/haiku

Modified:
   haiku/trunk/src/system/kernel/device_manager/IOCache.cpp
   haiku/trunk/src/system/kernel/device_manager/IOCache.h
Log:
IOCache implements IOScheduler, now.


Modified: haiku/trunk/src/system/kernel/device_manager/IOCache.cpp
===================================================================
--- haiku/trunk/src/system/kernel/device_manager/IOCache.cpp    2010-04-26 
15:42:34 UTC (rev 36493)
+++ haiku/trunk/src/system/kernel/device_manager/IOCache.cpp    2010-04-26 
15:43:20 UTC (rev 36494)
@@ -40,12 +40,10 @@
 
 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 @@
 {
        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);
@@ -122,21 +124,6 @@
 
 
 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)
 {
        TRACE("%p->IOCache::SetDeviceCapacity(%" B_PRIdOFF ")\n", this,
@@ -195,6 +182,13 @@
 
 
 void
+IOCache::AbortRequest(IORequest* request, status_t status)
+{
+       // TODO:...
+}
+
+
+void
 IOCache::OperationCompleted(IOOperation* operation, status_t status,
        size_t transferredBytes)
 {
@@ -207,6 +201,14 @@
 }
 
 
+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)
 {

Modified: haiku/trunk/src/system/kernel/device_manager/IOCache.h
===================================================================
--- haiku/trunk/src/system/kernel/device_manager/IOCache.h      2010-04-26 
15:42:34 UTC (rev 36493)
+++ haiku/trunk/src/system/kernel/device_manager/IOCache.h      2010-04-26 
15:43:20 UTC (rev 36494)
@@ -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 @@
                        size_t                          fLineSize;
                        uint32                          fLineSizeShift;
                        size_t                          fPagesPerLine;
-                       DMAResource*            fDMAResource;
-                       io_callback                     fIOCallback;
-                       void*                           fIOCallbackData;
                        area_id                         fArea;
                        void*                           fAreaBase;
                        vm_page_reservation     fMappingReservation;


Other related posts:

  • » [haiku-commits] r36494 - haiku/trunk/src/system/kernel/device_manager - ingo_weinhold