ReactOS  0.4.15-dev-5137-g826bd41
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 206 of file ramdisk.c.

210 {
211  /* Reset the RAMDISK device */
212  if ((RamDiskBase != gInitRamDiskBase) &&
214  (gInitRamDiskSize != 0))
215  {
216  /* This is not the initial Ramdisk, so we can free the allocated memory */
218  }
219  RamDiskBase = NULL;
220  RamDiskFileSize = 0;
221  RamDiskImageLength = 0;
222  RamDiskImageOffset = 0;
223  RamDiskOffset = 0;
224 
225  if (InitRamDisk)
226  {
227  /* We initialize the initial Ramdisk: it should be present in memory */
228  if (!gInitRamDiskBase || gInitRamDiskSize == 0)
229  return ENODEV;
230 
231  // TODO: Handle SDI image.
232 
235  ASSERT(RamDiskFileSize < 0x100000000); // See FIXME about 4GB support in RamDiskLoadVirtualFile().
236  }
237  else
238  {
239  /* We initialize the Ramdisk from the load options */
241  CHAR FileName[MAX_PATH] = "";
242 
243  /* If we don't have any load options, initialize an empty Ramdisk */
244  if (LoadOptions)
245  {
246  PCSTR Option;
248 
249  /* Ramdisk image file name */
250  Option = NtLdrGetOptionEx(LoadOptions, "RDPATH=", &FileNameLength);
251  if (Option && (FileNameLength > 7))
252  {
253  /* Copy the file name */
254  Option += 7; FileNameLength -= 7;
256  Option, FileNameLength * sizeof(CHAR));
257  }
258 
259  /* Ramdisk image length */
260  Option = NtLdrGetOption(LoadOptions, "RDIMAGELENGTH=");
261  if (Option)
262  {
263  RamDiskImageLength = _atoi64(Option + 14);
264  }
265 
266  /* Ramdisk image offset */
267  Option = NtLdrGetOption(LoadOptions, "RDIMAGEOFFSET=");
268  if (Option)
269  {
270  RamDiskImageOffset = atol(Option + 14);
271  }
272  }
273 
274  if (*FileName)
275  {
276  Status = RamDiskLoadVirtualFile(FileName, DefaultPath);
277  if (Status != ESUCCESS)
278  return Status;
279  }
280  }
281 
282  /* Adjust the Ramdisk image length if needed */
285 
286  /* Register the RAMDISK device */
288  {
289  FsRegisterDevice("ramdisk(0)", &RamDiskVtbl);
291  }
292 
293  return ESUCCESS;
294 }
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
__MINGW_EXTENSION _Check_return_ _CRTIMP __int64 __cdecl _atoi64(_In_z_ const char *_String)
#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:44
#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
#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().