summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAdriana Kobylak <anoo@us.ibm.com>2017-11-28 14:59:19 -0600
committerAdriana Kobylak <anoo@us.ibm.com>2017-11-30 13:57:28 -0600
commit2ad213288785f40104d1ed03cddde2ae9aee190a (patch)
tree22e81401c79adb64221c69858b5972b6eea7266c
parent0a2cc9550a1e70c035fe829d2ac32dd52322ebd6 (diff)
downloadphosphor-mboxd-2ad213288785f40104d1ed03cddde2ae9aee190a.tar.gz
phosphor-mboxd-2ad213288785f40104d1ed03cddde2ae9aee190a.zip
vpnor table: Set base address to actual offset
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>
-rw-r--r--pnor_partition_table.cpp5
-rw-r--r--pnor_partition_table.hpp3
-rw-r--r--test/create_pnor_partition_table.cpp4
-rw-r--r--test/create_read_window_vpnor.cpp6
-rw-r--r--test/write_flash_vpnor.cpp6
5 files changed, 10 insertions, 14 deletions
diff --git a/pnor_partition_table.cpp b/pnor_partition_table.cpp
index 3e3f1d1..eafdca5 100644
--- a/pnor_partition_table.cpp
+++ b/pnor_partition_table.cpp
@@ -28,7 +28,6 @@ Table::Table(size_t blockSize, size_t pnorSize):
Table::Table(fs::path&& directory,
size_t blockSize, size_t pnorSize):
szBlocks(0),
- imgBlocks(0),
directory(std::move(directory)),
numParts(0),
blockSize(blockSize),
@@ -76,16 +75,14 @@ inline void Table::allocateMemory(const fs::path& tocFile)
(num * sizeof(pnor_partition));
size_t totalSizeAligned = align_up(totalSizeBytes, blockSize);
szBlocks = totalSizeAligned / blockSize;
- imgBlocks = szBlocks;
tbl.resize(totalSizeAligned);
}
inline void Table::writeSizes(pnor_partition& part, size_t start, size_t end)
{
size_t size = end - start;
- part.data.base = imgBlocks;
+ part.data.base = align_up(start, blockSize) / blockSize;
size_t sizeInBlocks = align_up(size, blockSize) / blockSize;
- imgBlocks += sizeInBlocks;
part.data.size = sizeInBlocks;
// If a a patch partition file exists, populate actual size with its file
diff --git a/pnor_partition_table.hpp b/pnor_partition_table.hpp
index 1cabe23..2d0d007 100644
--- a/pnor_partition_table.hpp
+++ b/pnor_partition_table.hpp
@@ -218,9 +218,6 @@ class Table
*/
size_t szBlocks;
- /** @brief Size of virtual PNOR image, measured in erase-blocks */
- size_t imgBlocks;
-
/** @brief Partition table */
PartitionTable tbl;
diff --git a/test/create_pnor_partition_table.cpp b/test/create_pnor_partition_table.cpp
index bfc4471..d542299 100644
--- a/test/create_pnor_partition_table.cpp
+++ b/test/create_pnor_partition_table.cpp
@@ -47,7 +47,7 @@ int main()
pnor_partition expectedPartition{};
strcpy(expectedPartition.data.name, partitionName);
- expectedPartition.data.base = 1; // starts after 1 block
+ expectedPartition.data.base = 0; // starts at offset 0
expectedPartition.data.size = 1; // 1 block
expectedPartition.data.actual = 0x400; // 1024 bytes
expectedPartition.data.id = 1;
@@ -71,7 +71,7 @@ int main()
sizeof(pnor_partition));
assert(rc == 0);
- const pnor_partition& first = table.partition(4096);
+ const pnor_partition& first = table.partition(0); // Partition at offset 0
rc = memcmp(&first, &result.partitions[0], sizeof(pnor_partition));
assert(rc == 0);
diff --git a/test/create_read_window_vpnor.cpp b/test/create_read_window_vpnor.cpp
index d9bcccc..7c344f7 100644
--- a/test/create_read_window_vpnor.cpp
+++ b/test/create_read_window_vpnor.cpp
@@ -13,7 +13,9 @@ extern "C" {
#include <fstream>
#include <experimental/filesystem>
-constexpr auto line = "partition01=HBB,00000000,0001000,ECC,PRESERVED";
+// A read window assumes that the toc is located at offset 0,
+// so create dummy partition at arbitrary offset 0x100.
+constexpr auto line = "partition01=HBB,00000100,0001000,ECC,PRESERVED";
constexpr auto partition = "HBB";
char tmplt[] = "/tmp/create_read_test.XXXXXX";
uint8_t data[8] = { 0xaa, 0x55, 0xaa, 0x66, 0x77, 0x88, 0x99, 0xab };
@@ -28,7 +30,7 @@ static const uint8_t get_info[] = {
0x02, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
};
-// offset 1 and size 6
+// offset 0x100 and size 6
static const uint8_t create_read_window[] = {
0x04, 0x01, 0x01, 0x00, 0x06, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
diff --git a/test/write_flash_vpnor.cpp b/test/write_flash_vpnor.cpp
index ceb24aa..b9ba7ec 100644
--- a/test/write_flash_vpnor.cpp
+++ b/test/write_flash_vpnor.cpp
@@ -54,9 +54,9 @@ void init(struct mbox_context* ctx)
namespace fs = std::experimental::filesystem;
using namespace std::string_literals;
- std::string tocData = "partition01=TEST1,00000000,00000400,ECC,READONLY\n"s
- + "partition02=TEST2,00000000,00000008,ECC,READWRITE\n"s
- + "partition03=TEST3,00000000,00000400,ECC,PRESERVED"s;
+ std::string tocData = "partition01=TEST1,00001000,00001400,ECC,READONLY\n"s
+ + "partition02=TEST2,00002000,00002008,ECC,READWRITE\n"s
+ + "partition03=TEST3,00003000,00003400,ECC,PRESERVED"s;
std::vector<std::string> templatePaths = { "/tmp/ro.XXXXXX",
"/tmp/rw.XXXXXX" ,
OpenPOWER on IntegriCloud