From owner-svn-src-head@FreeBSD.ORG Tue Mar 17 21:15:26 2015 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 6116177E; Tue, 17 Mar 2015 21:15:26 +0000 (UTC) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::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 32B1DD18; Tue, 17 Mar 2015 21:15:26 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.9/8.14.9) with ESMTP id t2HLFQvo018205; Tue, 17 Mar 2015 21:15:26 GMT (envelope-from ian@FreeBSD.org) Received: (from ian@localhost) by svn.freebsd.org (8.14.9/8.14.9/Submit) id t2HLFPtU018203; Tue, 17 Mar 2015 21:15:25 GMT (envelope-from ian@FreeBSD.org) Message-Id: <201503172115.t2HLFPtU018203@svn.freebsd.org> X-Authentication-Warning: svn.freebsd.org: ian set sender to ian@FreeBSD.org using -f From: Ian Lepore Date: Tue, 17 Mar 2015 21:15:25 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r280194 - in head/sys/boot/uboot: fdt lib 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.18-1 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: Tue, 17 Mar 2015 21:15:26 -0000 Author: ian Date: Tue Mar 17 21:15:24 2015 New Revision: 280194 URL: https://svnweb.freebsd.org/changeset/base/280194 Log: Fix fdt_platform_fixups() mem region handling. It turns out u-boot puts several types of data into the mem-info array (DRAM, SRAM, flash). We need to extract just the DRAM entries for translation into fdt memory properties. Also, increase the number of regions we can handle from 5 to 16. Submitted by: Michal Meloun Modified: head/sys/boot/uboot/fdt/uboot_fdt.c head/sys/boot/uboot/lib/glue.h Modified: head/sys/boot/uboot/fdt/uboot_fdt.c ============================================================================== --- head/sys/boot/uboot/fdt/uboot_fdt.c Tue Mar 17 21:00:31 2015 (r280193) +++ head/sys/boot/uboot/fdt/uboot_fdt.c Tue Mar 17 21:15:24 2015 (r280194) @@ -88,7 +88,7 @@ fdt_platform_load_dtb(void) void fdt_platform_fixups(void) { - struct fdt_mem_region regions[3]; + static struct fdt_mem_region regions[UB_MAX_MR]; const char *env, *str; char *end, *ethstr; int eth_no, i, len, n; @@ -165,17 +165,15 @@ fdt_platform_fixups(void) /* Modify cpu(s) and bus clock frequenties in /cpus node [Hz] */ fdt_fixup_cpubusfreqs(si->clk_cpu, si->clk_bus); - /* Copy the data into a useful form */ - for (i = 0; i < si->mr_no; i++) { - if (i > nitems(regions)) { - i = nitems(regions); - break; + /* Extract the DRAM regions into fdt_mem_region format. */ + for (i = 0, n = 0; i < si->mr_no && n < nitems(regions); i++) { + if (si->mr[i].flags == MR_ATTR_DRAM) { + regions[n].start = si->mr[i].start; + regions[n].size = si->mr[i].size; + n++; } - - regions[i].start = si->mr[i].start; - regions[i].size = si->mr[i].size; } /* Fixup memory regions */ - fdt_fixup_memory(regions, i); + fdt_fixup_memory(regions, n); } Modified: head/sys/boot/uboot/lib/glue.h ============================================================================== --- head/sys/boot/uboot/lib/glue.h Tue Mar 17 21:00:31 2015 (r280193) +++ head/sys/boot/uboot/lib/glue.h Tue Mar 17 21:15:24 2015 (r280194) @@ -40,7 +40,7 @@ void *syscall_ptr; int api_search_sig(struct api_signature **sig); -#define UB_MAX_MR 5 /* max mem regions number */ +#define UB_MAX_MR 16 /* max mem regions number */ #define UB_MAX_DEV 6 /* max devices number */ /*