The Pedigree Project  0.1
LoDisk.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 LODISK_H
21 #define LODISK_H
22 
23 #include "modules/system/vfs/File.h"
24 #include "pedigree/kernel/compiler.h"
25 #include "pedigree/kernel/machine/Disk.h"
26 #include "pedigree/kernel/process/Mutex.h"
27 #include "pedigree/kernel/processor/MemoryRegion.h"
28 #include "pedigree/kernel/processor/types.h"
29 #include "pedigree/kernel/utilities/Cache.h"
30 #include "pedigree/kernel/utilities/String.h"
31 
34 
37 #define FILEDISK_PAGE_SIZE 4096
38 
47 {
48  public:
50  {
54  RamOnly = 0,
55 
57  Standard
58  };
59 
60  FileDisk() = delete;
61  FileDisk(String file, AccessType mode = Standard);
62  virtual ~FileDisk();
63 
64  virtual void getName(String &str)
65  {
66  if (m_pFile)
67  str = m_pFile->getName();
68  else
69  str = String("FileDisk");
70  }
71 
72  bool initialise();
73 
74  virtual uintptr_t read(uint64_t location);
75  virtual void write(uint64_t location);
76  virtual void align(uint64_t location);
77 
83  virtual bool cacheIsCritical()
84  {
85  return true;
86  }
87 
88  private:
89  FileDisk(const FileDisk &);
90  FileDisk &operator=(const FileDisk &);
91 
94 
97 
98  Cache m_Cache;
99 
100  // Our region of memory
101  MemoryRegion m_MemRegion;
102 
103  // Mutex to ensure only one request runs at a time
104  Mutex m_ReqMutex;
105 
106  uint64_t m_AlignPoints[8];
107  size_t m_nAlignPoints;
108 };
109 
110 #endif
Definition: Mutex.h:58
Definition: String.h:49
AccessType
Definition: LoDisk.h:49
Definition: Disk.h:32
Definition: Cache.h:118
virtual bool cacheIsCritical()
Definition: LoDisk.h:83
virtual uintptr_t read(uint64_t location)
Definition: Disk.cc:56
virtual void getName(String &str)
Definition: LoDisk.h:64
Special memory entity in the kernel's virtual address space.
Definition: MemoryRegion.h:35
AccessType m_Mode
Access mode.
Definition: LoDisk.h:96
File * m_pFile
File we're using as a disk.
Definition: LoDisk.h:93
virtual void write(uint64_t location)
Definition: Disk.cc:61
Definition: File.h:66
virtual void align(uint64_t location)
Sets the page boundary alignment after a specific location on the disk.
Definition: Disk.cc:65