X-Git-Url: http://v3vee.org/palacios/gitweb/gitweb.cgi?a=blobdiff_plain;f=palacios%2Fsrc%2Fgeekos%2Fmem.c;h=7bfb8aaff997ac9f2cb1ef77f98c9a44a21766c7;hb=56f8088296ee4116a4811a2f4f843edd80a7748d;hp=b7054254250e447d34d1b1687860a652a38d5b4c;hpb=57e3d7d1e671a261befef967b4a441e5d7dc2303;p=palacios.git diff --git a/palacios/src/geekos/mem.c b/palacios/src/geekos/mem.c index b705425..7bfb8aa 100644 --- a/palacios/src/geekos/mem.c +++ b/palacios/src/geekos/mem.c @@ -2,7 +2,9 @@ * Physical memory allocation * Copyright (c) 2001,2003,2004 David H. Hovemeyer * Copyright (c) 2003, Jeffrey K. Hollingsworth - * $Revision: 1.9 $ + * Copyright (c) 2008, Jack Lange + * Copyright (c) 2008, The V3VEE Project + * $Revision: 1.13 $ * * This is free software. You are permitted to use, * redistribute, and modify it as specified in the file "COPYING". @@ -32,6 +34,11 @@ */ struct Page* g_pageList; +#ifdef RAMDISK_BOOT +ulong_t g_ramdiskImage; +ulong_t s_ramdiskSize; +#endif + /* * Number of pages currently available on the freelist. */ @@ -135,6 +142,14 @@ void Init_Mem(struct Boot_Info* bootInfo) ulong_t heapEnd; ulong_t vmmMemEnd; + /*Zheng 08/03/2008*/ +#ifdef RAMDISK_BOOT + g_ramdiskImage = bootInfo->ramdisk_image; + s_ramdiskSize = bootInfo->ramdisk_size; + ulong_t initrdAddr; + ulong_t initrdEnd; +#endif + KASSERT(bootInfo->memSizeKB > 0); @@ -163,6 +178,7 @@ void Init_Mem(struct Boot_Info* bootInfo) * Heap (512 Pages) * Page List (variable pages) * Available Memory for VMM (4096 pages) + * Ramdisk //Zheng 08/03/2008 * VM Memory (everything else) */ @@ -188,12 +204,35 @@ void Init_Mem(struct Boot_Info* bootInfo) /* ** */ vmmMemEnd = Round_Up_To_Page(pageListEnd + VMM_AVAIL_MEM_SIZE); +#ifdef RAMDISK_BOOT + /* + * Zheng 08/03/2008 + * copy the ramdisk to this area + */ + initrdAddr = vmmMemEnd; + initrdEnd = Round_Up_To_Page(initrdAddr + s_ramdiskSize); + PrintBoth("mem.c(%d) Move ramdisk(%dB) from %x to %x", __LINE__, s_ramdiskSize, g_ramdiskImage, initrdAddr); + memcpy((ulong_t *)initrdAddr, (ulong_t *)g_ramdiskImage, s_ramdiskSize); + PrintBoth(" done\n"); + PrintBoth("mem.c(%d) Set 0 to unused bytes in the last ramdisk page from %x to %x", __LINE__, initrdAddr+s_ramdiskSize, initrdEnd); + memset((ulong_t *)initrdAddr+s_ramdiskSize, 0, initrdEnd-(initrdAddr+s_ramdiskSize)); + PrintBoth(" done\n"); + /* + * Zheng 08/03/2008 + */ + vm_range_start = initrdEnd; + vm_range_end = endOfMem; +#else + /* * the disgusting way to get at the memory assigned to a VM */ + vm_range_start = vmmMemEnd; vm_range_end = endOfMem; + +#endif Add_Page_Range(0, PAGE_SIZE, PAGE_UNUSED); // BIOS area Add_Page_Range(PAGE_SIZE, PAGE_SIZE * 3, PAGE_ALLOCATED); // Intial kernel thread obj + stack @@ -202,12 +241,20 @@ void Init_Mem(struct Boot_Info* bootInfo) Add_Page_Range(KERNEL_START_ADDR, kernEnd, PAGE_KERN); // VMM Kernel // Add_Page_Range(guest_kernel_start, guestEnd, PAGE_VM); // Guest kernel location Add_Page_Range(heapAddr, heapEnd, PAGE_HEAP); // Heap - Add_Page_Range(pageListAddr, pageListEnd, PAGE_KERN); // Page List - Add_Page_Range(pageListEnd, vmmMemEnd, PAGE_AVAIL); // Available VMM memory - // Add_Page_Range(vmmMemEnd, endOfMem, PAGE_VM); // Memory allocated to the VM - // Until we get a more intelligent memory allocator - Add_Page_Range(vmmMemEnd, endOfMem, PAGE_AVAIL); // Memory allocated to the VM + Add_Page_Range(pageListAddr, pageListEnd, PAGE_KERN); // Page List + Add_Page_Range(pageListEnd, vmmMemEnd, PAGE_AVAIL); // Available VMM memory +#ifdef RAMDISK_BOOT + /* + * Zheng 08/03/2008 + */ + Add_Page_Range(vmmMemEnd, initrdEnd, PAGE_ALLOCATED); //Ramdisk memory area + // Add_Page_Range(vmmMemEnd, endOfMem, PAGE_VM); // Memory allocated to the VM + // Until we get a more intelligent memory allocator + Add_Page_Range(initrdEnd, endOfMem, PAGE_AVAIL); // Memory allocated to the VM +#else + Add_Page_Range(vmmMemEnd, endOfMem, PAGE_AVAIL); // Memory allocated to the VM +#endif /* Initialize the kernel heap */ Init_Heap(heapAddr, KERNEL_HEAP_SIZE); @@ -226,7 +273,17 @@ void Init_Mem(struct Boot_Info* bootInfo) PrintBoth("%x to %x - KERNEL HEAP\n", heapAddr, heapEnd - 1); PrintBoth("%lx to %lx - PAGE LIST\n", pageListAddr, pageListEnd - 1); PrintBoth("%lx to %x - FREE\n", pageListEnd, vmmMemEnd - 1); + +#ifdef RAMDISK_BOOT + /* + * Zheng 08/03/2008 + */ + PrintBoth("%lx to %x - RAMDISK\n", vmmMemEnd, initrdEnd - 1); + + PrintBoth("%lx to %x - GUEST_MEMORY (also free)\n", initrdEnd, endOfMem - 1); +#else PrintBoth("%lx to %x - GUEST_MEMORY (also free)\n", vmmMemEnd, endOfMem - 1); +#endif } /*