summaryrefslogtreecommitdiffstats
path: root/pnor_partition_table.hpp
Commit message (Collapse)AuthorAgeFilesLines
* pnor_partition_table: Refactor to allow tests to specify patch locationAndrew Jeffery2018-04-041-7/+6
| | | | | | | | | | | | | | | | | | | | | | | | | The Table class was unhelpful for testing in a couple of ways: 1. It attempted to access files on the filesystem whilst parsing ToC entries 2. It incorrectly assumed the location of the files it was accessing Both of these issues come down to handling of patch files and the configuration of the 'actual' member of the partition struct. Hoist the handling of the partition entry's data size out of the ToC parser, and rework the Table constructor to only require a struct mbox_context pointer. We can then use the paths member of mbox_context to find the patch location rather than hard-code the value generated by the configure script. This prompts a rework and rename of the wrapper functions in mboxd_pnor_partition_table.{cpp,h} to better align with the new behaviour of the Table constructor. Reworking the wrappers has knock-on effects in the tests, but the changes are straight-forward. Change-Id: I87e63daf0d28b93566f7e5cb565cbf0790428479 Signed-off-by: Andrew Jeffery <andrew@aj.id.au>
* pnor_partition_table: Raise exception for unmapped offsetsAndrew Jeffery2018-03-241-0/+33
| | | | | | | | | | | | | | | Allow reads and writes of offsets that don't map onto partitions defined in the ToC. Do so by ignoring the mapping failure and filling a window with 0xff in the hole from the requested offset to the following partition. This change also removes the reliance on InternalFailure as the exception of choice for communicating failures. We can do better without the teeth-pulling required by phosphor-logging by translating custom exceptions into phosphor-logging exceptions at the edges. Change-Id: Ibfa961a66b0b979354c6dc226ccbe7e9fbafc16d Signed-off-by: Andrew Jeffery <andrew@aj.id.au>
* pnor_partition_table: Move struct vpnor_partition_table to headerAndrew Jeffery2018-03-241-0/+5
| | | | | | | Allow use of the definition in other parts of the codebase. Change-Id: I5f4f23c909a09f12fd16728183aadbf36b565dba Signed-off-by: Andrew Jeffery <andrew@aj.id.au>
* misc: Replace license blurb with kernel-style SPDX markersAndrew Jeffery2018-03-241-18/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | This was roughly achieved by the following shell script: $ git ls-files | grep '\.[ch]p*$' | while read F; do EXT=${F##*.}; cat spdx.$EXT <(sed '/^\/\*$/,/^ \*\/$/d' $F) > ${F}.tmp; mv ${F}.tmp $F; done With the following context: $ cat spdx.c // SPDX-License-Identifier: Apache-2.0 // Copyright (C) 2018 IBM Corp. $ cat spdx.h /* SPDX-License-Identifier: Apache-2.0 */ /* Copyright (C) 2018 IBM Corp. */ $ ls -l spdx.* -rw-r--r-- 1 andrew andrew 71 Feb 27 12:02 spdx.c lrwxrwxrwx 1 andrew andrew 6 Feb 27 12:02 spdx.cpp -> spdx.c -rw-r--r-- 1 andrew andrew 77 Feb 27 12:02 spdx.h lrwxrwxrwx 1 andrew andrew 6 Feb 27 12:02 spdx.hpp -> spdx.h The `sed` invocation catches a lot of function documentation, so the hunks were manually added to avoid removing information that we want to keep. Change-Id: I63e49ca2593aa0db0568c7a63bfdead388642e76 Signed-off-by: Andrew Jeffery <andrew@aj.id.au>
* misc: Add license blurb to unlicensed filesAndrew Jeffery2018-03-241-0/+18
| | | | | | | | | | | | | | | This was roughly achieved with: $ git ls-files | grep '.[ch]p*$' | while read F; do head -n 1 $F | fgrep -v '/*' > /dev/null && echo $F; done | while read L; do cat apache $L > ${L}.tmp; mv ${L}.tmp ${L}; done Some fixups performed by hand to eliminate modifications to files that were hit which should not have been. Change-Id: I9fa5af4644687d8b595a6cf70d6f7575a767d11a Signed-off-by: Andrew Jeffery <andrew@aj.id.au>
* pnor_partition_table: Rework semantics of Table::size()Andrew Jeffery2018-03-241-5/+26
| | | | | | | | | | | | | | | | | Table::size() now returns the exact table size in bytes, Table::capacity() returns the block-aligned size in bytes (capacity in terms of how much the table could grow before expanding to another block), and Table::blocks() returns the size in blocks. This helps out with code clarity around the codebase and enables the introduction of ToC-related integration tests. The one wrinkle is vpnor_get_partition_table_size(), which is modified to call Table::blocks() but retains 'size' in its name. This is largely unimportant as the function will go away shortly. Change-Id: I3becf47f2201df5fe0bed86fcb92d7b94d06ab11 Signed-off-by: Andrew Jeffery <andrew@aj.id.au>
* pnor_partition_table: Make parseTocLine throw exceptionsAndrew Jeffery2018-03-241-3/+83
| | | | | Change-Id: I66dc8af4fede36c3c952df596040356e11a72644 Signed-off-by: Andrew Jeffery <andrew@aj.id.au>
* pnor_partition_table: Drop Table ctor with default locationAndrew Jeffery2018-03-241-7/+0
| | | | | | | | Make the caller be explicit about what they want. Also, rearrange calls in mboxd_pnor_partition_table.cpp to remove noise there as well. Change-Id: I8e36101b84b1b24cf0edbedb744f8edca15a834a Signed-off-by: Andrew Jeffery <andrew@aj.id.au>
* pnor_partition_table: Move parseTocLine() out of Table classAndrew Jeffery2018-03-241-11/+13
| | | | | | | | This is the final patch in the ongoing effort to extract parseTocLine() from the Table class, enabling re-use in setup for test cases. Change-Id: I62bbcbba39fbd337e370dcc78aec6ef3cf337caa Signed-off-by: Andrew Jeffery <andrew@aj.id.au>
* pnor_partition_table: Make writeSizes() private to namespaceAndrew Jeffery2018-03-241-9/+0
| | | | | | | | This is part of the ongoing effort to extract parseTocLine() from the Table class, enabling reuse in setup for test cases. Change-Id: I1817023347575843e5518343c83a7f2eae6302a4 Signed-off-by: Andrew Jeffery <andrew@aj.id.au>
* pnor_partition_table: Hoist partition existence check from parseTocLine()Andrew Jeffery2018-03-241-4/+1
| | | | | | | | | | | | | | | | | | Enforce some separation of concerns: Parsing the text of a ToC entry is an operation independent of testing whether context derived from the parsed data is valid. Specifically, testing whether a file at a path derived from the ToC entry is valid inside the parser is unhelpful when we try to reuse the parser for test code, where we want to set up an environment as described by the ToC entry. Under this condition the file is of course not going to exist - we're parsing the ToC entry in order to create it. So, lets hoist the test out to the caller, enabling re-use of the parser in the test code. Change-Id: Ibc9b62c00b95b8296b48ccf45630cb5344347bd7 Signed-off-by: Andrew Jeffery <andrew@aj.id.au>
* pnor_partition_table: Make writeUserdata() private to namespaceAndrew Jeffery2018-03-241-12/+0
| | | | | | | | This is part of the ongoing effort to extract parseTocLine() from the Table class, enabling reuse in setup for test cases. Change-Id: I846e67b728df7bf57fd132b21438a13248d426fc Signed-off-by: Andrew Jeffery <andrew@aj.id.au>
* pnor_partition_table: Make writeDefaults() private to namespaceAndrew Jeffery2018-03-241-7/+0
| | | | | | | | This is part of the ongoing effort to extract parseTocLine() from the Table class, enabling reuse in setup for test cases. Change-Id: I0b888c028c61db2a555fa99a5abcbe339e657f95 Signed-off-by: Andrew Jeffery <andrew@aj.id.au>
* pnor_partition_table: Make writeNameAndId() private to namespaceAndrew Jeffery2018-03-241-10/+0
| | | | | | | | This is part of the ongoing effort to extract parseTocLine() from the Table class, enabling reuse in setup for test cases. Change-Id: I676e536e651dff1b27d0e53ecbb96d8e5ae8f025 Signed-off-by: Andrew Jeffery <andrew@aj.id.au>
* pnor_partition_table: Extract preparePartitions() loop bodyAndrew Jeffery2018-03-241-0/+14
| | | | | | | | | | | Create a new private method, parseTocLine(), to handle the function of the loop body. The eventual goal is to extract the function from the class completely and simply have parseTocLine() as a public function in the openpower::virtual_pnor namespace. This will facilitate testing of the virtual PNOR parts of the codebase. Change-Id: Ib8c3b39eb9390cfc088a54abd45aab6f551775d3 Signed-off-by: Andrew Jeffery <andrew@aj.id.au>
* Format C++ files according to OpenBMC style guideAndrew Jeffery2018-03-191-167/+162
| | | | | | | We don't touch the C yet as upstream hasn't got such a change in place. Change-Id: Ie6cab4bf99df520bb6655b9b00ae31e762e3c57b Signed-off-by: Andrew Jeffery <andrew@aj.id.au>
* vpnor table: Set base address to actual offsetAdriana Kobylak2017-11-301-3/+0
| | | | | | | | | | | | | | | | | | | | | The base address for the partitions is used by mboxd to find requested partitions, and for simplicity it's just a continous number sequence. But this data is used by the host as the partition offsets, which are expected to match to the offsets in the openpower xml: https://github.com/open-power/pnor/blob/21d66daff697f8c13fb067340ca621e9208ab1ea/p9Layouts/defaultPnorLayout_64.xml This xml pnor layout has empty spaces in between the partitions, ex: part ends at address 0x2000 and the next partition HBEL starts at 0x8000. Need to set base address to the actual offset that corresponds to the xml file, so that the host traces that display the partition offsets match the data in documented in the xml. This doesn't affect the memory address allocation. Part of openbmc/openbmc#2677 Change-Id: Ica142129aabd195655018a84f9a993596c333457 Signed-off-by: Adriana Kobylak <anoo@us.ibm.com>
* Fix for mboxd segfault during flash readJayanth Othayoth2017-10-311-2/+2
| | | | | | | | | | | | | | mboxd segfaults during flash read when there is no partition associated to the given offset within the flash size. Proposed fix is to generate elog instead of returning reference to zeroed out pnor_partition structure. Resolves openbmc/openbmc#2365 Change-Id: I98bed1c09588c386d9ea2510618bb27eaa6dfbe0 Signed-off-by: Jayanth Othayoth <ojayanth@in.ibm.com>
* vpnor: add partition version check to the TOCDeepak Kodihalli2017-07-191-1/+4
| | | | | Change-Id: If5497476f03484334396e483e251b1e9434137f3 Signed-off-by: Deepak Kodihalli <dkodihal@in.ibm.com>
* vpnor: add API to get partition entry by nameDeepak Kodihalli2017-07-191-0/+9
| | | | | Change-Id: I1f86c646c6629a6a42788821e469d36f55c92264 Signed-off-by: Deepak Kodihalli <dkodihal@in.ibm.com>
* vpnor: make PNOR block size configurableDeepak Kodihalli2017-07-191-2/+21
| | | | | | | | The vpnor code would assume a PNOR FFS block size of 4K. Make it possible to supply this value, since it needn't always be 4K. Change-Id: I21463b05f1047e93705ba82d46f746056568dcc5 Signed-off-by: Deepak Kodihalli <dkodihal@in.ibm.com>
* pnor : generate partition tableDeepak Kodihalli2017-06-271-0/+214
Implement a class that, upon construction, generates the virtual PNOR partition table. The virtual PNOR is typically a subset of the full PNOR image, by choosing partitions of interest. The generation is based on upon information read from the PNOR partition files and table of contents (toc) file. Provide an interface to the virtual PNOR partition table. Change-Id: I7a68e3833b8cf66e92eb6ca274f6a3c376ce0add Signed-off-by: Deepak Kodihalli <dkodihal@in.ibm.com>
OpenPOWER on IntegriCloud