The Pedigree Project  0.1
CdiDisk.h
1 /*
2  * Copyright (c) 2008-2014, Pedigree Developers
3  *
4  * Please see the CONTRIB file in the root of the source tree for a full
5  * list of contributors.
6  *
7  * Permission to use, copy, modify, and distribute this software for any
8  * purpose with or without fee is hereby granted, provided that the above
9  * copyright notice and this permission notice appear in all copies.
10  *
11  * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
12  * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
13  * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
14  * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
15  * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
16  * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
17  * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
18  */
19 
20 #ifndef CDI_CPP_DISK_H
21 #define CDI_CPP_DISK_H
22 
23 #include <stdbool.h>
24 #include "cdi.h"
25 #include "cdi/storage.h"
26 #include "pedigree/kernel/machine/Disk.h"
27 #include "pedigree/kernel/processor/types.h"
28 #include "pedigree/kernel/utilities/Cache.h"
29 #include "pedigree/kernel/utilities/String.h"
30 
32 class CdiDisk : public Disk
33 {
34  public:
35  CdiDisk(struct cdi_storage_device *device);
36  CdiDisk(Disk* pDev, struct cdi_storage_device* device);
37  virtual ~CdiDisk();
38 
39  virtual void getName(String &str)
40  {
41  if((!m_Device) || (!m_Device->dev.name))
42  str = "cdi-disk";
43  else
44  {
45  str = m_Device->dev.name;
46  }
47  }
48 
51  bool initialise();
52 
53  // These are the functions that others call - they add a request to the parent controller's queue.
54  virtual uintptr_t read(uint64_t location);
55  virtual void write(uint64_t location);
56 
58  virtual bool cacheIsCritical()
59  {
60  return false;
61  }
62 
65  virtual void flush(uint64_t location)
66  {
67  return;
68  }
69 
70  private:
71  CdiDisk(const CdiDisk&);
72  const CdiDisk & operator = (const CdiDisk&);
73 
74  struct cdi_storage_device* m_Device;
75  Cache m_Cache;
76 };
77 
78 #endif
virtual void getName(String &str)
Definition: CdiDisk.h:39
virtual void write(uint64_t location)
Definition: CdiDisk.cc:108
Definition: String.h:49
Definition: Disk.h:32
Definition: Cache.h:118
virtual bool cacheIsCritical()
Assume CDI-provided disks are never read-only.
Definition: CdiDisk.h:58
virtual void flush(uint64_t location)
Definition: CdiDisk.h:65
bool initialise()
Definition: CdiDisk.cc:54
virtual uintptr_t read(uint64_t location)
Definition: CdiDisk.cc:93