aboutsummaryrefslogtreecommitdiff
path: root/core/test
diff options
context:
space:
mode:
authorStewart Smith <stewart@linux.vnet.ibm.com>2016-10-25 15:47:47 +1100
committerStewart Smith <stewart@linux.vnet.ibm.com>2016-10-25 15:47:47 +1100
commit26895ba411d5d4d86cbb377862cd2e43fcc07cf8 (patch)
tree6d867fd1601da4afe3d41d6a3d65e147072fd1c5 /core/test
parent1408f6f9baa684f280dfb2c4a66daa4d5db996b2 (diff)
downloadskiboot-26895ba411d5d4d86cbb377862cd2e43fcc07cf8.zip
skiboot-26895ba411d5d4d86cbb377862cd2e43fcc07cf8.tar.gz
skiboot-26895ba411d5d4d86cbb377862cd2e43fcc07cf8.tar.bz2
core/flash: Move subpartition locating logic out into own file, add tests
A unit test for parsing sub-partition info is useful for a number of reasons, one of which showed its head during development of secure/trusted boot. This patch just moves things around, there's no functional changes. Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
Diffstat (limited to 'core/test')
-rw-r--r--core/test/Makefile.check1
-rw-r--r--core/test/run-flash-subpartition.c55
2 files changed, 56 insertions, 0 deletions
diff --git a/core/test/Makefile.check b/core/test/Makefile.check
index fa1b806..d3dd260 100644
--- a/core/test/Makefile.check
+++ b/core/test/Makefile.check
@@ -1,5 +1,6 @@
# -*-Makefile-*-
CORE_TEST := core/test/run-device \
+ core/test/run-flash-subpartition \
core/test/run-mem_region \
core/test/run-malloc \
core/test/run-malloc-speed \
diff --git a/core/test/run-flash-subpartition.c b/core/test/run-flash-subpartition.c
new file mode 100644
index 0000000..169362e
--- /dev/null
+++ b/core/test/run-flash-subpartition.c
@@ -0,0 +1,55 @@
+/* Copyright 2013-2016 IBM Corp.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ * implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <skiboot.h>
+#include <opal-api.h>
+#include <stdlib.h>
+
+#include "../flash-subpartition.c"
+#include <assert.h>
+
+/* This is a straight dump of the CAPP ucode partition header */
+char capp[4096] = {0x43, 0x41, 0x50, 0x50, 0x00, 0x00, 0x00, 0x01,
+ 0x00, 0x01, 0x00, 0xea, 0x00, 0x00, 0x10, 0x00,
+ 0x00, 0x00, 0x8e, 0x50, 0x00, 0x02, 0x00, 0xea,
+ 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x8e, 0x50,
+ 0x00, 0x02, 0x00, 0xef, 0x00, 0x00, 0x10, 0x00,
+ 0x00, 0x00, 0x8e, 0x50, 0x00, 0x02, 0x01, 0xef,
+ 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x8e, 0x50,
+ 0x00, 0x01, 0x00, 0xd3, 0x00, 0x00, 0x10, 0x00,
+ 0x00, 0x00, 0x8e, 0x50, 0x00, 0x00, 0x00, 0x00 };
+
+int main(void)
+{
+ int rc;
+ uint32_t offset;
+ uint32_t size;
+ uint32_t subids[] = { 0x100ea, 0x200ea, 0x200ef, 0x201ef, 0x100d3 };
+
+ for (int i = 0; i < sizeof(subids)/sizeof(uint32_t); i++) {
+ offset = 0;
+ rc = flash_subpart_info(capp, 0x24000, subids[i],
+ &offset, &size);
+ printf("\nsubid %x\n", subids[i]);
+ printf("offset %u\n", offset);
+ printf("size %u\n", size);
+ assert (rc == 0);
+ assert (size == 36432);
+ assert (offset == 4096);
+ }
+
+ return 0;
+}