ReactOS  0.4.14-dev-606-g14ebc0b
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 204 of file ramdisk.c.

208 {
209  /* Reset the RAMDISK device */
210  if ((RamDiskBase != gInitRamDiskBase) &&
212  (gInitRamDiskSize != 0))
213  {
214  /* This is not the initial Ramdisk, so we can free the allocated memory */
216  }
217  RamDiskBase = NULL;
218  RamDiskFileSize = 0;
219  RamDiskImageLength = 0;
220  RamDiskImageOffset = 0;
221  RamDiskOffset = 0;
222 
223  if (InitRamDisk)
224  {
225  /* We initialize the initial Ramdisk: it should be present in memory */
226  if (!gInitRamDiskBase || gInitRamDiskSize == 0)
227  return ENODEV;
228 
229  // TODO: Handle SDI image.
230 
233  ASSERT(RamDiskFileSize < 0x100000000); // See FIXME about 4GB support in RamDiskLoadVirtualFile().
234  }
235  else
236  {
237  /* We initialize the Ramdisk from the load options */
239  CHAR FileName[MAX_PATH] = "";
240 
241  /* If we don't have any load options, initialize an empty Ramdisk */
242  if (LoadOptions)
243  {
244  PCHAR Option;
245 
246  /* Ramdisk image file name */
247  Option = strstr(LoadOptions, "/RDPATH=");
248  if (Option)
249  {
250  /* Copy the file name - everything until the next separator */
251  Option += 8;
253  Option, strcspn(Option, " \t") * sizeof(CHAR));
254  }
255 
256  /* Ramdisk image length */
257  Option = strstr(LoadOptions, "/RDIMAGELENGTH=");
258  if (Option)
259  {
260  RamDiskImageLength = _atoi64(Option + 15);
261  }
262 
263  /* Ramdisk image offset */
264  Option = strstr(LoadOptions, "/RDIMAGEOFFSET=");
265  if (Option)
266  {
267  RamDiskImageOffset = atol(Option + 15);
268  }
269  }
270 
271  if (*FileName)
272  {
273  Status = RamDiskLoadVirtualFile(FileName, DefaultPath);
274  if (Status != ESUCCESS)
275  return Status;
276  }
277  }
278 
279  /* Adjust the Ramdisk image length if needed */
282 
283  /* Register the RAMDISK device */
285  {
286  FsRegisterDevice("ramdisk(0)", &RamDiskVtbl);
288  }
289 
290  return ESUCCESS;
291 }
signed char * PCHAR
Definition: retypes.h:7
static ULONG RamDiskImageOffset
Definition: ramdisk.c:23
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
#define TRUE
Definition: types.h:120
Definition: arc.h:32
static BOOLEAN RamDiskDeviceRegistered
Definition: ramdisk.c:19
char * strstr(char *String1, char *String2)
Definition: utclib.c:653
_Check_return_ _CRTIMP size_t __cdecl strcspn(_In_z_ const char *_Str, _In_z_ const char *_Control)
char CHAR
Definition: xmlstorage.h:175
ULONG ARC_STATUS
Definition: arc.h:4
static const DEVVTBL RamDiskVtbl
Definition: ramdisk.c:95
static ULONGLONG RamDiskOffset
Definition: ramdisk.c:24
smooth NULL
Definition: ftsmooth.c:416
#define MAX_PATH
Definition: compat.h:26
ULONG gInitRamDiskSize
Definition: ramdisk.c:17
_Check_return_ long __cdecl atol(_In_z_ const char *_Str)
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
VOID FsRegisterDevice(CHAR *Prefix, const DEVVTBL *FuncTable)
Definition: fs.c:383
Status
Definition: gdiplustypes.h:24
VOID MmFreeMemory(PVOID MemoryPointer)
Definition: mm.c:215
static ULONGLONG RamDiskImageLength
Definition: ramdisk.c:22
Definition: arc.h:45
_Check_return_ __MINGW_EXTENSION _CRTIMP __int64 __cdecl _atoi64(_In_z_ const char *_String)
static ULONGLONG RamDiskFileSize
Definition: ramdisk.c:21
static ARC_STATUS RamDiskLoadVirtualFile(IN PCSTR FileName, IN PCSTR DefaultPath OPTIONAL)
Definition: ramdisk.c:105
PVOID gInitRamDiskBase
Definition: ramdisk.c:16
static PVOID RamDiskBase
Definition: ramdisk.c:20

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

Variable Documentation

◆ gInitRamDiskBase

PVOID gInitRamDiskBase

Definition at line 16 of file ramdisk.c.

Referenced by CmdLineParse(), and RamDiskInitialize().

◆ gInitRamDiskSize

ULONG gInitRamDiskSize

Definition at line 17 of file ramdisk.c.

Referenced by CmdLineParse(), and RamDiskInitialize().