# HG changeset patch
# User Jerone Young <[EMAIL PROTECTED]>
# Date 1205296680 18000
# Branch merge
# Node ID 8b1dd3609551efefbd6633ac6fe4caa3a6cbe5e9
# Parent  3a891d8fada96166089b5796f3241087d4aae50f
Add ability to specify ram on command line for bamboo board model

This patch adds the ability to now specify ram sizes on the command line.
Due to the nature of the code there are restictions on exactly how
much ram and the multiple that the size must match.

Signed-off-by: Jerone Young <[EMAIL PROTECTED]>

diff --git a/qemu/hw/ppc440_bamboo.c b/qemu/hw/ppc440_bamboo.c
--- a/qemu/hw/ppc440_bamboo.c
+++ b/qemu/hw/ppc440_bamboo.c
@@ -40,32 +40,71 @@ void bamboo_init(ram_addr_t ram_size, in
        target_ulong dt_base=0;
        void *fdt;
        int ret;
+       int holdr;
+       unsigned long ram_size1; /* Value will be in bytes */
+       unsigned long ram_size2; /* Value will be in bytes */
+
 
        uint32_t cpu_freq;
        uint32_t timebase_freq;
 
        printf("%s: START\n", __func__);
 
-       /* Setup Memory */
-       if (ram_size) {
-               printf("Ram size specified on command line is %i bytes\n",
-                                                               (int)ram_size);
-               printf("WARNING: RAM is hard coded to 144MB\n");
-       }
-       else {
-               printf("Using defualt ram size of %iMB\n",
-                                               ((int)ram_size/1024)/1024);
-       }
-
-       /* Each bank can only have memory in configurations of
-        *   16MB, 32MB, 64MB, 128MB, or 256MB
-        */
-       ram_bases[0] = 0x0;
-       ram_sizes[0] = 0x08000000;
-       ram_bases[1] = 0x0;
-       ram_sizes[1] = 0x01000000;
-
-       printf("Ram size of domain is %d bytes\n", (int)ram_size);
+       /* Setup Memory */
+       printf("Ram size is set to: %i MB\n",
+                               ((int)ram_size/1024)/1024);             
+ 
+       /* Check that total ram is at least 8 MB 
+        * but less than 512 MB 
+        * and is a multiple of 4
+        */
+ 
+       if (ram_size < (8 * 1024 * 1024)) {
+               printf("Ram size specified on cmd line must at least be 8 
MB\n");
+               exit(1);
+       }
+ 
+       if (ram_size > (512 * 1024 * 1024)) {
+               printf("Ram size specified on cmd line is greater than 512 
MB\n");
+               exit(1);
+       }
+ 
+       if ((((int)ram_size/1024)/1024) % 4) {
+               printf("Ram size specified on cmd line must be multiple of 
4\n");
+               exit(1);
+       }
+ 
+       /* split ram into two slots */
+       holdr = (ram_size/(1024*1024))/4;       
+ 
+       /* ram_size2 has to at least have 4MB in it*/
+       ram_size2 = 4 * 1024 * 1024; /* Add 4MB */
+       holdr = holdr - 1;
+ 
+       
+       if ((4 * holdr) <= 256) {
+               /* if what remains is 256MB or less put in first slot */
+               ram_size1 = (4 * holdr) * (1024 * 1024);
+       }
+       else {
+               /* place first 256MB or less in first slot */
+               ram_size1 = 256 * 1024 * 1024;
+               holdr = holdr - (256/4);
+               
+               /* place remainder in slot 2 */
+               ram_size2 += (4 * holdr) * (1024 * 1024);
+       }
+ 
+       /* Each bank can only have memory in configurations of
+        *   4MB, 8MB, 16MB, 32MB, 64MB, 128MB, or 256MB
+        *   why? see sdram_bcr()
+        *   
+        *   Max of 512MB
+        */
+       ram_bases[0] = 0x0;
+       ram_sizes[0] = ram_size1;
+       ram_bases[1] = 0x0;
+       ram_sizes[1] = ram_size2;       
 
        /* Setup CPU */
        env = cpu_ppc_init("440");

-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
kvm-devel mailing list
kvm-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/kvm-devel

Reply via email to