From 724f076f8a717b3d9c606c455ca4d02cc43af3f8 Mon Sep 17 00:00:00 2001 From: evb Date: Thu, 4 Feb 2010 19:49:25 +0000 Subject: [PATCH] - Change NANDFlash again for Versatile support. Now the LLB and OS Loader are created in one binary blob (loaded with -kernel), while the RAMDISK is loaded with -initrd. - 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 | 36 +++++++++++++++++++++++++++++++--- 1 file changed, 33 insertions(+), 3 deletions(-) diff --git a/reactos/tools/nandflash/main.c b/reactos/tools/nandflash/main.c index ae8408e6c2b..012fc54b3db 100644 --- a/reactos/tools/nandflash/main.c +++ b/reactos/tools/nandflash/main.c @@ -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);