From owner-svn-src-head@freebsd.org Sat Nov 21 00:22:49 2015 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 22DD0A2E5D9; Sat, 21 Nov 2015 00:22:49 +0000 (UTC) (envelope-from adrian@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id F1E2D1CB1; Sat, 21 Nov 2015 00:22:48 +0000 (UTC) (envelope-from adrian@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id tAL0MmcT080336; Sat, 21 Nov 2015 00:22:48 GMT (envelope-from adrian@FreeBSD.org) Received: (from adrian@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id tAL0MmIF080335; Sat, 21 Nov 2015 00:22:48 GMT (envelope-from adrian@FreeBSD.org) Message-Id: <201511210022.tAL0MmIF080335@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: adrian set sender to adrian@FreeBSD.org using -f From: Adrian Chadd Date: Sat, 21 Nov 2015 00:22:48 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r291118 - head/sys/mips/malta X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 21 Nov 2015 00:22:49 -0000 Author: adrian Date: Sat Nov 21 00:22:47 2015 New Revision: 291118 URL: https://svnweb.freebsd.org/changeset/base/291118 Log: mips: teach the malta platform about extended memory. Extended memory here is "physical memory above 256MB". "memsize" in the environment only grows to 256MB; "ememsize" is the entire memory range. Extended memory shows up at physical address 0x90000000. This allows for malta64 VMs to be created with > 256MB RAM, all the way up to 2GB RAM. Tested: * qemu-devel package; qemu-system-mips64 -m 2048 (and -m 256 to test the no-ememsize case.) TODO: * testing mips32 with > 256MB RAM. Reviewed by: imp Modified: head/sys/mips/malta/malta_machdep.c Modified: head/sys/mips/malta/malta_machdep.c ============================================================================== --- head/sys/mips/malta/malta_machdep.c Sat Nov 21 00:15:41 2015 (r291117) +++ head/sys/mips/malta/malta_machdep.c Sat Nov 21 00:22:47 2015 (r291118) @@ -173,7 +173,7 @@ writertc(uint8_t addr, uint8_t val) #endif static void -mips_init(void) +mips_init(unsigned long memsize, uint64_t ememsize) { int i; @@ -181,13 +181,28 @@ mips_init(void) phys_avail[i] = 0; } + /* + * memsize is the amount of RAM available below 256MB. + * ememsize is the total amount of RAM available. + * + * The second bank starts at 0x90000000. + */ + /* phys_avail regions are in bytes */ phys_avail[0] = MIPS_KSEG0_TO_PHYS(kernel_kseg0_end); - phys_avail[1] = ctob(realmem); - + phys_avail[1] = memsize; dump_avail[0] = phys_avail[0]; dump_avail[1] = phys_avail[1]; + /* Only specify the extended region if it's set */ + if (ememsize > memsize) { + phys_avail[2] = 0x90000000; + phys_avail[3] = 0x90000000 + (ememsize - memsize); + dump_avail[2] = phys_avail[2]; + dump_avail[3] = phys_avail[3]; + } + + /* XXX realmem assigned in the caller of mips_init() */ physmem = realmem; init_param1(); @@ -272,6 +287,7 @@ platform_start(__register_t a0, __regist int32_t *argv = (int32_t*)a1; int32_t *envp = (int32_t*)a2; unsigned int memsize = a3; + uint64_t ememsize = 0; int i; /* clear the BSS and SBSS segments */ @@ -289,26 +305,54 @@ platform_start(__register_t a0, __regist printf("entry: platform_start()\n"); bootverbose = 1; + /* * YAMON uses 32bit pointers to strings so * convert them to proper type manually */ + if (bootverbose) { printf("cmd line: "); for (i = 0; i < argc; i++) printf("%s ", (char*)(intptr_t)argv[i]); printf("\n"); + } + if (bootverbose) printf("envp:\n"); - for (i = 0; envp[i]; i += 2) - printf("\t%s = %s\n", (char*)(intptr_t)envp[i], - (char*)(intptr_t)envp[i+1]); - printf("memsize = %08x\n", memsize); + /* + * Parse the environment for things like ememsize. + */ + for (i = 0; envp[i]; i += 2) { + const char *a, *v; + + a = (char *)(intptr_t)envp[i]; + v = (char *)(intptr_t)envp[i+1]; + + if (bootverbose) + printf("\t%s = %s\n", a, v); + + if (strcmp(a, "ememsize") == 0) { + ememsize = strtoul(v, NULL, 0); + } } - realmem = btoc(memsize); - mips_init(); + if (bootverbose) { + printf("memsize = %llu (0x%08x)\n", + (unsigned long long) memsize, memsize); + printf("ememsize = %llu\n", (unsigned long long) ememsize); + } + + /* + * For <= 256MB RAM amounts, ememsize should equal memsize. + * For > 256MB RAM amounts it's the total RAM available; + * split between two banks. + * + * XXX TODO: just push realmem assignment into mips_init() ? + */ + realmem = btoc(ememsize); + mips_init(memsize, ememsize); mips_timer_init_params(platform_counter_freq, 0); }