From patchwork Thu Dec 19 20:58:54 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Leif Lindholm X-Patchwork-Id: 22654 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-vb0-f71.google.com (mail-vb0-f71.google.com [209.85.212.71]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 5752123FC4 for ; Thu, 19 Dec 2013 20:59:06 +0000 (UTC) Received: by mail-vb0-f71.google.com with SMTP id p6sf1746023vbe.6 for ; Thu, 19 Dec 2013 12:59:05 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:delivered-to:from:to:cc:subject :date:message-id:x-original-sender:x-original-authentication-results :precedence:mailing-list:list-id:list-post:list-help:list-archive :list-unsubscribe; bh=KNRETwlYfTQCiK4qeXTsxbwaA5Yj22vyKfNKS9rPPVs=; b=KCMjm6LNFJGU0sIBnuDV8ThGJk0tpl0r7j/4mf9m6u3ydrOby8qm6fiuVfbNJpVqQT Lyb0CXdiBEjdVaFcm0RbNPLoXy+anpI0yhHlaS8K4KuDaDdcwtBGmwjQ6aNmcsjjeSxJ /rweIAEt8+DCBXGAJlPVtrhWIoIshLKO+9NVAM+XlFffbhwQasUcZ38RG3XcgI8s7KON xILRl8dNMhkwjuEjm2HCQTkh082U6ZRA01oil5HmHOKfWNAC02FMimLvwmK/qlTtM9WG 1b3Fwju8qU2iy/g/6yLlwzQLHwpaAZwdf3F+qZ/dz8GQ2MRfLyPppAs2Y9yyYPI4V7SC fOTA== X-Gm-Message-State: ALoCoQl4Nd/pkVasOrgFK83xBe3wPRFLiXLgqF4GfAVy4dRV7d3E8cyTX37TARh38AvQ60ywZB5E X-Received: by 10.58.128.33 with SMTP id nl1mr1877312veb.28.1387486745524; Thu, 19 Dec 2013 12:59:05 -0800 (PST) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.49.39.102 with SMTP id o6ls470696qek.28.gmail; Thu, 19 Dec 2013 12:59:05 -0800 (PST) X-Received: by 10.220.199.5 with SMTP id eq5mr2499206vcb.16.1387486745416; Thu, 19 Dec 2013 12:59:05 -0800 (PST) Received: from mail-vb0-f42.google.com (mail-vb0-f42.google.com [209.85.212.42]) by mx.google.com with ESMTPS id v5si942034ves.80.2013.12.19.12.59.05 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 19 Dec 2013 12:59:05 -0800 (PST) Received-SPF: neutral (google.com: 209.85.212.42 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) client-ip=209.85.212.42; Received: by mail-vb0-f42.google.com with SMTP id w5so993120vbf.1 for ; Thu, 19 Dec 2013 12:59:05 -0800 (PST) X-Received: by 10.52.103.35 with SMTP id ft3mr2040000vdb.5.1387486745336; Thu, 19 Dec 2013 12:59:05 -0800 (PST) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patches@linaro.org Received: by 10.59.13.131 with SMTP id ey3csp13869ved; Thu, 19 Dec 2013 12:59:04 -0800 (PST) X-Received: by 10.180.19.195 with SMTP id h3mr4173435wie.11.1387486744495; Thu, 19 Dec 2013 12:59:04 -0800 (PST) Received: from mail-we0-f180.google.com (mail-we0-f180.google.com [74.125.82.180]) by mx.google.com with ESMTPS id gy5si2056147wjc.122.2013.12.19.12.59.04 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 19 Dec 2013 12:59:04 -0800 (PST) Received-SPF: neutral (google.com: 74.125.82.180 is neither permitted nor denied by best guess record for domain of leif.lindholm@linaro.org) client-ip=74.125.82.180; Received: by mail-we0-f180.google.com with SMTP id t61so1670060wes.11 for ; Thu, 19 Dec 2013 12:59:04 -0800 (PST) X-Received: by 10.194.93.193 with SMTP id cw1mr3617962wjb.38.1387486743949; Thu, 19 Dec 2013 12:59:03 -0800 (PST) Received: from mohikan.mushroom.smurfnet.nu (cpc4-cmbg17-2-0-cust71.5-4.cable.virginm.net. [86.14.224.72]) by mx.google.com with ESMTPSA id pl7sm931190wjc.16.2013.12.19.12.59.02 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 19 Dec 2013 12:59:02 -0800 (PST) From: Leif Lindholm To: grub-devel@gnu.org Cc: patches@linaro.org, Leif Lindholm Subject: [PATCH v2 1/2] fdt: additions required for arm64 Linux loader Date: Thu, 19 Dec 2013 20:58:54 +0000 Message-Id: <1387486735-13461-1-git-send-email-leif.lindholm@linaro.org> X-Mailer: git-send-email 1.7.10.4 X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: leif.lindholm@linaro.org X-Original-Authentication-Results: mx.google.com; spf=neutral (google.com: 209.85.212.42 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Precedence: list Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org List-ID: X-Google-Group-Id: 836684582541 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , - Add grub_fdt_create_empty_tree() function. - Add 64-bit setprop. --- grub-core/lib/fdt.c | 29 +++++++++++++++++++++++++++++ include/grub/fdt.h | 20 ++++++++++++++++++++ 2 files changed, 49 insertions(+) diff --git a/grub-core/lib/fdt.c b/grub-core/lib/fdt.c index 9f34dc7..57d6f30 100644 --- a/grub-core/lib/fdt.c +++ b/grub-core/lib/fdt.c @@ -423,3 +423,32 @@ int grub_fdt_set_prop (void *fdt, unsigned int nodeoffset, const char *name, grub_memcpy (prop + 3, val, len); return 0; } + +int +grub_fdt_create_empty_tree (void *fdt, unsigned int size) +{ + struct grub_fdt_empty_tree *et; + + if (size < GRUB_FDT_EMPTY_TREE_SZ) + return -1; + + grub_memset (fdt, 0, size); + et = fdt; + + et->empty_node.tree_end = grub_cpu_to_be32_compile_time (FDT_END); + et->empty_node.node_end = grub_cpu_to_be32_compile_time (FDT_END_NODE); + et->empty_node.node_start = grub_cpu_to_be32_compile_time (FDT_BEGIN_NODE); + ((struct grub_fdt_empty_tree *) fdt)->header.off_mem_rsvmap = + grub_cpu_to_be32 (ALIGN_UP (sizeof (grub_fdt_header_t), 8)); + + grub_fdt_set_off_dt_strings (fdt, sizeof (*et)); + grub_fdt_set_off_dt_struct (fdt, + sizeof (et->header) + sizeof (et->empty_rsvmap)); + grub_fdt_set_version (fdt, FDT_SUPPORTED_VERSION); + grub_fdt_set_last_comp_version (fdt, FDT_SUPPORTED_VERSION); + grub_fdt_set_size_dt_struct (fdt, sizeof (et->empty_node)); + grub_fdt_set_totalsize (fdt, size); + grub_fdt_set_magic (fdt, FDT_MAGIC); + + return 0; +} diff --git a/include/grub/fdt.h b/include/grub/fdt.h index 2ad0536..fae322e 100644 --- a/include/grub/fdt.h +++ b/include/grub/fdt.h @@ -36,6 +36,19 @@ typedef struct { grub_uint32_t size_dt_struct; } grub_fdt_header_t; +struct grub_fdt_empty_tree { + grub_fdt_header_t header; + grub_uint64_t empty_rsvmap[2]; + struct { + grub_uint32_t node_start; + grub_uint8_t name[1]; + grub_uint32_t node_end; + grub_uint32_t tree_end; + } empty_node; +}; + +#define GRUB_FDT_EMPTY_TREE_SZ sizeof (struct grub_fdt_empty_tree) + #define grub_fdt_get_header(fdt, field) \ grub_be_to_cpu32(((const grub_fdt_header_t *)(fdt))->field) #define grub_fdt_set_header(fdt, field, value) \ @@ -82,6 +95,7 @@ typedef struct { #define grub_fdt_set_size_dt_struct(fdt, value) \ grub_fdt_set_header(fdt, size_dt_struct, value) +int grub_fdt_create_empty_tree (void *fdt, unsigned int size); int grub_fdt_check_header (void *fdt, unsigned int size); int grub_fdt_find_subnode (const void *fdt, unsigned int parentoffset, const char *name); @@ -96,4 +110,10 @@ int grub_fdt_set_prop (void *fdt, unsigned int nodeoffset, const char *name, grub_fdt_set_prop ((fdt), (nodeoffset), (name), &_val, 4); \ }) +#define grub_fdt_set_prop64(fdt, nodeoffset, name, val) \ +({ \ + grub_uint64_t _val = grub_cpu_to_be64(val); \ + grub_fdt_set_prop ((fdt), (nodeoffset), (name), &_val, 8); \ +}) + #endif /* ! GRUB_FDT_HEADER */