The issue you have is that with AllocatePages lib function, you are allocating a memory type that self-destructs when an ExitBootServices is called. This is typically called when an OS Loader initializes and transitions to the kernel that it's loading. (Specifics vary per OS as to exactly when/if that transition occurs.) Also depending on how you launch your OS, the memory map that is passed up once ExitBootServices() is complete will show anything you allocated through the aforementioned AllocatePages lib function as available and it wouldn't surprise me if the OS starts to immediately use it.
I'm not certain about what method you're using to launch the kernel, but as a general rule, I'd say you want to allocate a RAM Drive as EfiRuntimeServicesData (that can be done directly through the gBS->AllocatePages() function by specifying that memory type. In addition, you'd certainly want to somehow give your target (kernel) enough data to know what the beginning address and size of the RAM drive is. Whether that's described via a commandline or ACPI table or exposing an EFI_DEVICE_PATH, any of these methods could work. I'll note I'm not a Linux expert, so take that into consideration. ;-) Thanks, Mike Rothman (迈克 罗斯曼 / माइकल रोथ्मेन् / Михаил Ротман / משה רוטמן) רועה עיקרי של חתולים -----Original Message----- From: edk2-devel [mailto:[email protected]] On Behalf Of Foster, Matthew I Sent: Tuesday, May 17, 2016 10:31 AM To: [email protected] Cc: [email protected] Subject: Re: [edk2] Using the Shell to launch a kernel using a RAMDISK Shouldn't passing the address and size to the kernel command line be enough for the kernel not to walk over it? Is there best known method for setting up a ramdisk in the BIOS and allowing the kernel to use it? console=ttyS0,115200n8 loglevel=8 rootwait root=/dev/mtdblock0 mtdparts=RAM0:0x00F42000@0x00000000(RootFileSystem-RAM) phram.phram=RAM0,0x0C235000,0x00F42000 memmap=0x00F42000$0x0C235000 -----Original Message----- From: [email protected] [mailto:[email protected]] Sent: Tuesday, May 17, 2016 10:24 AM To: Foster, Matthew I <[email protected]> Cc: [email protected] Subject: Re: [edk2] Using the Shell to launch a kernel using a RAMDISK > On May 17, 2016, at 10:13 AM, Foster, Matthew I <[email protected]> > wrote: > > I am trying to boot a linux kernel from within the shell that is using a > ramdisk filesystem. I allocate memory in the shell for a ramdisk. I read the > filesystem out of flash memory after allocating memory in the shell: > > KernelRootFS = AllocatePages(((KernelFSSize/FOUR_KB_ALIGNED) +1)); > > I then use that address (KernelRootFS) to pass it to the kernel command line > to tell there kernel where the filesystem is in memory. When it goes to use > the ramdisk at some in the kernel boot, the ramdisk appears to be corrupted > and I get SQUASHFS errors. > > If I do that exact procedure in BdsBoot, I do not see the corruption. Which > leads me to believe the shell might be somehow trampling over the memory. > Does anyone have any ideas on what I might do, or what could be going on here? > The Shell is likely not trampling the memory. It is more likely the OS is trampling the memory. Your library call is allocating EfiBootServicesData. When the OS Boots it calls ExitBootServices() to take over managing the system resources from EFI and at this point EfiBootServicesData is basically freed back for use by the OS. The Shell vs. BDS probably just change the address that gets allocated and moves it a range that shows the conflict. Thanks, Andrew Fish _______________________________________________ edk2-devel mailing list [email protected] https://lists.01.org/mailman/listinfo/edk2-devel _______________________________________________ edk2-devel mailing list [email protected] https://lists.01.org/mailman/listinfo/edk2-devel

