ReactOS 0.4.15-dev-7907-g95bf896
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 }
220 RamDiskFileSize = 0;
223 RamDiskOffset = 0;
224
225 if (InitRamDisk)
226 {
227 /* We initialize the initial Ramdisk: it should be present in memory */
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}
#define ENODEV
Definition: acclib.h:89
__int64 CDECL _atoi64(const char *nptr)
Definition: atoi64.c:18
static BOOLEAN RamDiskDeviceRegistered
Definition: ramdisk.c:20
static ULONGLONG RamDiskFileSize
Definition: ramdisk.c:22
static PVOID RamDiskBase
Definition: ramdisk.c:21
static ULONG RamDiskImageOffset
Definition: ramdisk.c:24
static ARC_STATUS RamDiskLoadVirtualFile(IN PCSTR FileName, IN PCSTR DefaultPath OPTIONAL)
Definition: ramdisk.c:106
static const DEVVTBL RamDiskVtbl
Definition: ramdisk.c:96
PVOID gInitRamDiskBase
Definition: ramdisk.c:17
static ULONGLONG RamDiskOffset
Definition: ramdisk.c:25
static ULONGLONG RamDiskImageLength
Definition: ramdisk.c:23
ULONG gInitRamDiskSize
Definition: ramdisk.c:18
VOID FsRegisterDevice(CHAR *Prefix, const DEVVTBL *FuncTable)
Definition: fs.c:385
VOID MmFreeMemory(PVOID MemoryPointer)
Definition: mm.c:215
#define NULL
Definition: types.h:112
#define TRUE
Definition: types.h:120
#define MAX_PATH
Definition: compat.h:34
_Must_inspect_result_ _In_ PFILE_OBJECT _In_opt_ HANDLE _In_ ULONG FileNameLength
Definition: fltkernel.h:1129
Status
Definition: gdiplustypes.h:25
_Check_return_ long __cdecl atol(_In_z_ const char *_Str)
#define ASSERT(a)
Definition: mode.c:44
PCSTR NtLdrGetOption(IN PCSTR Options, IN PCSTR OptionName)
Definition: ntldropts.c:128
PCSTR NtLdrGetOptionEx(IN PCSTR Options, IN PCSTR OptionName, OUT PULONG OptionLength OPTIONAL)
Definition: ntldropts.c:117
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
@ ESUCCESS
Definition: arc.h:32
ULONG ARC_STATUS
Definition: arc.h:4
const char * PCSTR
Definition: typedefs.h:52
uint32_t ULONG
Definition: typedefs.h:59
char CHAR
Definition: xmlstorage.h:175

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

Variable Documentation

◆ gInitRamDiskBase

PVOID gInitRamDiskBase
extern

Definition at line 17 of file ramdisk.c.

Referenced by CmdLineParse(), and RamDiskInitialize().

◆ gInitRamDiskSize

ULONG gInitRamDiskSize
extern

Definition at line 18 of file ramdisk.c.

Referenced by CmdLineParse(), and RamDiskInitialize().