- Change NANDFlash again for Versatile support. Now the LLB and OS Loader are created...
authorevb <evb@svn.reactos.org>
Thu, 4 Feb 2010 19:49:25 +0000 (19:49 +0000)
committerevb <evb@svn.reactos.org>
Thu, 4 Feb 2010 19:49:25 +0000 (19:49 +0000)
- Now the only complication is that RAMDISK loaded at 0x80000 which will conflict with the 0x800000 range where kernel loads. Could move RAMDISK in code through LLB, but that would be very expensive (shift by 16MB up). Instead, NANDflash creates ramdisk image starting at offset 16MB. This way, emulator thinks it's loading at 0x80000, but actually loads at 0x1800000. Would be better if QEMU not hardcoded the INITRD_LOAD_ADDR...

svn path=/trunk/; revision=45423

reactos/tools/nandflash/main.c

index ae8408e..012fc54 100644 (file)
@@ -16,7 +16,8 @@
 PCHAR NandImageName       = "reactos.bin";
 PCHAR LlbImageName        = "./output-arm/boot/armllb/armllb.bin";
 PCHAR BootLdrImageName    = "./output-arm/boot/freeldr/freeldr/freeldr.sys";
-PCHAR FsImageName         = "ReactOS.img";
+PCHAR FsImageName         = "ramdisk.img";
+PCHAR RamImageName        = "ramdisk.bin";
 
 /* NAND On-Disk Memory Map */
 ULONG LlbStart     = 0x00000000,     LlbEnd = 0x00010000;   // 64  KB
@@ -135,11 +136,23 @@ WriteFileSystem(IN INT NandImageFile)
     close(FileDescriptor);
 }
 
+VOID
+NTAPI
+WriteRamDisk(IN INT RamDiskFile)
+{
+    INT FileDescriptor;
+
+    /* Open FS image and write it 16MB later */
+    FileDescriptor = open(FsImageName, O_RDWR);
+    WriteToFlash(RamDiskFile, FileDescriptor, 16 * 1024 * 1024, (32 + 16) * 1024 * 1024);
+    close(FileDescriptor);
+}
+
 int
 main(ULONG argc,
      char **argv)
 {
-    INT NandImageFile;
+    INT NandImageFile, RamDiskFile;
     
     /* Flat NAND, no OOB */
     if (argc == 2) NeedsOob = FALSE;
@@ -151,7 +164,24 @@ main(ULONG argc,
     /* Write components */
     WriteLlb(NandImageFile);
     WriteBootLdr(NandImageFile);
-    WriteFileSystem(NandImageFile);
+    if (NeedsOob)
+    {
+        /* Write the ramdisk normaly */
+        WriteFileSystem(NandImageFile);
+    }
+    else
+    {
+        /* Open a new file for the ramdisk */
+        RamDiskFile = open(RamImageName, O_RDWR | O_CREAT);
+        if (!RamDiskFile) exit(-1);
+
+        /* Write it */
+        WriteRamDisk(RamDiskFile);
+        
+        /* Close */
+        close(RamDiskFile);
+    }
+
 
     /* Close and return */
     close(NandImageFile);