ReactOS  0.4.15-dev-1392-g3014417
ramdisk.h File Reference
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

ARC_STATUS RamDiskInitialize (IN BOOLEAN InitRamDisk, IN PCSTR LoadOptions OPTIONAL, IN PCSTR DefaultPath OPTIONAL)
 

Variables

PVOID gInitRamDiskBase
 
ULONG gInitRamDiskSize
 

Function Documentation

◆ RamDiskInitialize()

ARC_STATUS RamDiskInitialize ( IN BOOLEAN  InitRamDisk,
IN PCSTR LoadOptions  OPTIONAL,
IN PCSTR DefaultPath  OPTIONAL 
)

Definition at line 205 of file ramdisk.c.

209 {
210  /* Reset the RAMDISK device */
211  if ((RamDiskBase != gInitRamDiskBase) &&
213  (gInitRamDiskSize != 0))
214  {
215  /* This is not the initial Ramdisk, so we can free the allocated memory */
217  }
218  RamDiskBase = NULL;
219  RamDiskFileSize = 0;
220  RamDiskImageLength = 0;
221  RamDiskImageOffset = 0;
222  RamDiskOffset = 0;
223 
224  if (InitRamDisk)
225  {
226  /* We initialize the initial Ramdisk: it should be present in memory */
227  if (!gInitRamDiskBase || gInitRamDiskSize == 0)
228  return ENODEV;
229 
230  // TODO: Handle SDI image.
231 
234  ASSERT(RamDiskFileSize < 0x100000000); // See FIXME about 4GB support in RamDiskLoadVirtualFile().
235  }
236  else
237  {
238  /* We initialize the Ramdisk from the load options */
240  CHAR FileName[MAX_PATH] = "";
241 
242  /* If we don't have any load options, initialize an empty Ramdisk */
243  if (LoadOptions)
244  {
245  PCSTR Option;
247 
248  /* Ramdisk image file name */
249  Option = NtLdrGetOptionEx(LoadOptions, "RDPATH=", &FileNameLength);
250  if (Option && (FileNameLength > 7))
251  {
252  /* Copy the file name */
253  Option += 7; FileNameLength -= 7;
255  Option, FileNameLength * sizeof(CHAR));
256  }
257 
258  /* Ramdisk image length */
259  Option = NtLdrGetOption(LoadOptions, "RDIMAGELENGTH=");
260  if (Option)
261  {
262  RamDiskImageLength = _atoi64(Option + 14);
263  }
264 
265  /* Ramdisk image offset */
266  Option = NtLdrGetOption(LoadOptions, "RDIMAGEOFFSET=");
267  if (Option)
268  {
269  RamDiskImageOffset = atol(Option + 14);
270  }
271  }
272 
273  if (*FileName)
274  {
275  Status = RamDiskLoadVirtualFile(FileName, DefaultPath);
276  if (Status != ESUCCESS)
277  return Status;
278  }
279  }
280 
281  /* Adjust the Ramdisk image length if needed */
284 
285  /* Register the RAMDISK device */
287  {
288  FsRegisterDevice("ramdisk(0)", &RamDiskVtbl);
290  }
291 
292  return ESUCCESS;
293 }
static ULONG RamDiskImageOffset
Definition: ramdisk.c:24
NTSTRSAFEAPI RtlStringCbCopyNA(_Out_writes_bytes_(cbDest) NTSTRSAFE_PSTR pszDest, _In_ size_t cbDest, _In_reads_bytes_(cbToCopy) STRSAFE_LPCSTR pszSrc, _In_ size_t cbToCopy)
Definition: ntstrsafe.h:395
Definition: arc.h:32
static BOOLEAN RamDiskDeviceRegistered
Definition: ramdisk.c:20
#define TRUE
Definition: types.h:120
char CHAR
Definition: xmlstorage.h:175
ULONG ARC_STATUS
Definition: arc.h:4
static const DEVVTBL RamDiskVtbl
Definition: ramdisk.c:96
static ULONGLONG RamDiskOffset
Definition: ramdisk.c:25
Status
Definition: gdiplustypes.h:24
#define ASSERT(a)
Definition: mode.c:45
#define MAX_PATH
Definition: compat.h:34
ULONG gInitRamDiskSize
Definition: ramdisk.c:18
_Check_return_ long __cdecl atol(_In_z_ const char *_Str)
VOID FsRegisterDevice(CHAR *Prefix, const DEVVTBL *FuncTable)
Definition: fs.c:383
_Must_inspect_result_ _In_ PFILE_OBJECT _In_opt_ HANDLE _In_ ULONG FileNameLength
Definition: fltkernel.h:1129
VOID MmFreeMemory(PVOID MemoryPointer)
Definition: mm.c:215
static ULONGLONG RamDiskImageLength
Definition: ramdisk.c:23
Definition: arc.h:45
PCSTR NtLdrGetOption(IN PCSTR Options, IN PCSTR OptionName)
Definition: ntldropts.c:128
_Check_return_ __MINGW_EXTENSION _CRTIMP __int64 __cdecl _atoi64(_In_z_ const char *_String)
#define NULL
Definition: types.h:112
static ULONGLONG RamDiskFileSize
Definition: ramdisk.c:22
unsigned int ULONG
Definition: retypes.h:1
static ARC_STATUS RamDiskLoadVirtualFile(IN PCSTR FileName, IN PCSTR DefaultPath OPTIONAL)
Definition: ramdisk.c:106
const char * PCSTR
Definition: typedefs.h:52
PVOID gInitRamDiskBase
Definition: ramdisk.c:17
PCSTR NtLdrGetOptionEx(IN PCSTR Options, IN PCSTR OptionName, OUT PULONG OptionLength OPTIONAL)
Definition: ntldropts.c:117
static PVOID RamDiskBase
Definition: ramdisk.c:21

Referenced by ArmHwDetect(), LoadAndBootWindows(), and LoadReactOSSetup().

Variable Documentation

◆ gInitRamDiskBase

PVOID gInitRamDiskBase

Definition at line 17 of file ramdisk.c.

Referenced by CmdLineParse(), and RamDiskInitialize().

◆ gInitRamDiskSize

ULONG gInitRamDiskSize

Definition at line 18 of file ramdisk.c.

Referenced by CmdLineParse(), and RamDiskInitialize().