From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932108AbdBVFiv (ORCPT ); Wed, 22 Feb 2017 00:38:51 -0500 Received: from mail-qt0-f179.google.com ([209.85.216.179]:34390 "EHLO mail-qt0-f179.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750921AbdBVFin (ORCPT ); Wed, 22 Feb 2017 00:38:43 -0500 MIME-Version: 1.0 In-Reply-To: <20170222051201.GB29755@obsidianresearch.com> References: <20170218023010.GA8244@live.com> <1CC272501B5BC543A05DB90AA509DED50AF5EC@fmsmsx122.amr.corp.intel.com> <20170218204509.GA32544@live.com> <1CC272501B5BC543A05DB90AA509DED50B005A@fmsmsx122.amr.corp.intel.com> <20170222051201.GB29755@obsidianresearch.com> From: Moritz Fischer Date: Tue, 21 Feb 2017 21:38:41 -0800 Message-ID: Subject: Re: [RFC 7/8] fpga-region: add sysfs interface To: Jason Gunthorpe Cc: "Nadathur, Sundar" , Alan Tull , Yves Vandervennet , "matthew.gerlach@linux.intel.com" , linux-kernel , "linux-fpga@vger.kernel.org" , "Marek Va??ut" Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi all, On Tue, Feb 21, 2017 at 9:12 PM, Jason Gunthorpe wrote: > On Tue, Feb 21, 2017 at 07:49:19PM -0800, Moritz Fischer wrote: > >> fdt does this out of the box, too. So far I've seen nothing fdt >> couldn't do (or doesn't do let's rather say). > > tlv/fdt/http headers are all essentially exactly the same > thing. Key/value pairs with various encoding schemes. > > I don't think we don't need a tree of data, so fdt is overkill. > > tlv is not substantially easier to parse correctly than the > structured plain text headers.. It is just in binary so it can > represent binary-ish things better. TLV Seems easy enough. To give an update, I played with fdt a bit to see how far I get in half an hour. I got bool / int / strings to work quite fast (~30mins). Please disregard the horrible hackyness of this ... For simplicity I stuck the header on top of my bitfile with: /dts-v1/; /{ description = "Test"; compressed = <0>; encrypted = <1>; }; $ dtc -o header.dtb header.dts $ cat header.dtb mybitfile.bin > /lib/firmware/bitfile_header.bin + static int __fpga_mgr_blob_to_image_info(const void *blob, + struct fpga_image_info *info) + { + int root_offset; + const char *desc; + const uint32_t *_compressed, *_encrypted; + int compressed, encrypted; + + if (fdt_check_header(blob)) { + pr_err("Invalid device tree blob header\n"); + return -EINVAL; + } + + root_offset = fdt_path_offset(blob, "/"); + if (root_offset < 0) { + pr_err("Invalid root offset\n"); + return -EINVAL; + } + + desc = fdt_getprop(blob, root_offset, "description", NULL); + + _compressed = fdt_getprop(blob, root_offset, "compressed", NULL); + if (_compressed) + compressed = fdt32_to_cpu(*_compressed); + + _encrypted = fdt_getprop(blob, root_offset, "encrypted", NULL); + if (_encrypted) + encrypted = fdt32_to_cpu(*_encrypted); + + if (desc) + pr_info("%s: description=%s\n", __func__, desc); + + if (_encrypted && _compressed) + pr_info("%s: compressed? %s encrypted? %s\n", __func__, + compressed ? "Yes" : "No", encrypted ? "Yes" : "No"); + + return 0; + } Which gave me: [ 19.325182] fpga_manager fpga0: writing bitfile_header.bin to Xilinx Zynq FPGA Manager [ 20.091222] __fpga_mgr_blob_to_image_info: description=Test [ 20.096730] __fpga_mgr_blob_to_image_info: compressed? No encrypted? Yes So I'm fairly convinced I can make this work, TVLs seem like it could work, too. > So far the only thing we know we need is a 'bool' for encrypted and a > stringish guid thing for partial reconfiguration. Yeah, shouldn't be hard to implement either way. Cheers, Moritz