]> git.sur5r.net Git - u-boot/commitdiff
binman: Add add test for SPL with a microcode pointer
authorSimon Glass <sjg@chromium.org>
Mon, 13 Nov 2017 04:52:27 +0000 (21:52 -0700)
committerSimon Glass <sjg@chromium.org>
Thu, 23 Nov 2017 01:05:38 +0000 (18:05 -0700)
Add a test for this feature. It allows SPL to hold a pointer to the
microcode block. This is used for 64-bit U-Boot on x86.

Signed-off-by: Simon Glass <sjg@chromium.org>
tools/binman/etype/u_boot_spl_with_ucode_ptr.py
tools/binman/ftest.py
tools/binman/test/49_x86_ucode_spl.dts [new file with mode: 0644]

index 1c6706df6db3cff2edae7d55b45ffcbea3418aca..7b25ccb04887e42c37560e46691e6acbbed9210b 100644 (file)
@@ -25,4 +25,4 @@ class Entry_u_boot_spl_with_ucode_ptr(Entry_u_boot_with_ucode_ptr):
         self.elf_fname = 'spl/u-boot-spl'
 
     def GetDefaultFilename(self):
-        return 'spl/u-boot-spl.bin'
+        return 'spl/u-boot-spl-nodtb.bin'
index c381a7003111e09cda76feaf35d7d7d0257452e1..dff7448f08f31926081e6cf46e45c81e378f356b 100644 (file)
@@ -26,19 +26,20 @@ import tools
 import tout
 
 # Contents of test files, corresponding to different entry types
-U_BOOT_DATA         = '1234'
-U_BOOT_IMG_DATA     = 'img'
-U_BOOT_SPL_DATA     = '567'
-BLOB_DATA           = '89'
-ME_DATA             = '0abcd'
-VGA_DATA            = 'vga'
-U_BOOT_DTB_DATA     = 'udtb'
-X86_START16_DATA    = 'start16'
-X86_START16_SPL_DATA = 'start16spl'
-U_BOOT_NODTB_DATA   = 'nodtb with microcode pointer somewhere in here'
-FSP_DATA            = 'fsp'
-CMC_DATA            = 'cmc'
-VBT_DATA            = 'vbt'
+U_BOOT_DATA           = '1234'
+U_BOOT_IMG_DATA       = 'img'
+U_BOOT_SPL_DATA       = '567'
+BLOB_DATA             = '89'
+ME_DATA               = '0abcd'
+VGA_DATA              = 'vga'
+U_BOOT_DTB_DATA       = 'udtb'
+X86_START16_DATA      = 'start16'
+X86_START16_SPL_DATA  = 'start16spl'
+U_BOOT_NODTB_DATA     = 'nodtb with microcode pointer somewhere in here'
+U_BOOT_SPL_NODTB_DATA = 'splnodtb with microcode pointer somewhere in here'
+FSP_DATA              = 'fsp'
+CMC_DATA              = 'cmc'
+VBT_DATA              = 'vbt'
 
 class TestFunctional(unittest.TestCase):
     """Functional tests for binman
@@ -78,6 +79,8 @@ class TestFunctional(unittest.TestCase):
         TestFunctional._MakeInputFile('spl/u-boot-x86-16bit-spl.bin',
                                       X86_START16_SPL_DATA)
         TestFunctional._MakeInputFile('u-boot-nodtb.bin', U_BOOT_NODTB_DATA)
+        TestFunctional._MakeInputFile('spl/u-boot-spl-nodtb.bin',
+                                      U_BOOT_SPL_NODTB_DATA)
         TestFunctional._MakeInputFile('fsp.bin', FSP_DATA)
         TestFunctional._MakeInputFile('cmc.bin', CMC_DATA)
         TestFunctional._MakeInputFile('vbt.bin', VBT_DATA)
@@ -91,10 +94,6 @@ class TestFunctional(unittest.TestCase):
         with open(self.TestFile('descriptor.bin')) as fd:
             TestFunctional._MakeInputFile('descriptor.bin', fd.read())
 
-        # ELF file with a '__bss_size' symbol
-        with open(self.TestFile('bss_data')) as fd:
-            TestFunctional._MakeInputFile('spl/u-boot-spl', fd.read())
-
     @classmethod
     def tearDownClass(self):
         """Remove the temporary input directory and its contents"""
@@ -653,19 +652,11 @@ class TestFunctional(unittest.TestCase):
         data = self._DoReadFile('33_x86-start16.dts')
         self.assertEqual(X86_START16_DATA, data[:len(X86_START16_DATA)])
 
-    def testPackUbootMicrocode(self):
-        """Test that x86 microcode can be handled correctly
-
-        We expect to see the following in the image, in order:
-            u-boot-nodtb.bin with a microcode pointer inserted at the correct
-                place
-            u-boot.dtb with the microcode removed
-            the microcode
-        """
-        data = self._DoReadFile('34_x86_ucode.dts', True)
+    def _RunMicrocodeTest(self, dts_fname, nodtb_data):
+        data = self._DoReadFile(dts_fname, True)
 
         # Now check the device tree has no microcode
-        second = data[len(U_BOOT_NODTB_DATA):]
+        second = data[len(nodtb_data):]
         fname = tools.GetOutputFilename('test.dtb')
         with open(fname, 'wb') as fd:
             fd.write(second)
@@ -684,13 +675,26 @@ class TestFunctional(unittest.TestCase):
         ucode_data = struct.pack('>4L', 0x12345678, 0x12345679, 0xabcd0000,
                                  0x78235609)
         self.assertEqual(ucode_data, third[:len(ucode_data)])
-        ucode_pos = len(U_BOOT_NODTB_DATA) + fdt_len
+        ucode_pos = len(nodtb_data) + fdt_len
 
         # Check that the microcode pointer was inserted. It should match the
         # expected position and size
         pos_and_size = struct.pack('<2L', 0xfffffe00 + ucode_pos,
                                    len(ucode_data))
-        first = data[:len(U_BOOT_NODTB_DATA)]
+        first = data[:len(nodtb_data)]
+        return first, pos_and_size
+
+    def testPackUbootMicrocode(self):
+        """Test that x86 microcode can be handled correctly
+
+        We expect to see the following in the image, in order:
+            u-boot-nodtb.bin with a microcode pointer inserted at the correct
+                place
+            u-boot.dtb with the microcode removed
+            the microcode
+        """
+        first, pos_and_size = self._RunMicrocodeTest('34_x86_ucode.dts',
+                                                     U_BOOT_NODTB_DATA)
         self.assertEqual('nodtb with microcode' + pos_and_size +
                          ' somewhere in here', first)
 
@@ -823,6 +827,9 @@ class TestFunctional(unittest.TestCase):
 
     def testSplBssPad(self):
         """Test that we can pad SPL's BSS with zeros"""
+        # ELF file with a '__bss_size' symbol
+        with open(self.TestFile('bss_data')) as fd:
+            TestFunctional._MakeInputFile('spl/u-boot-spl', fd.read())
         data = self._DoReadFile('47_spl_bss_pad.dts')
         self.assertEqual(U_BOOT_SPL_DATA + (chr(0) * 10) + U_BOOT_DATA, data)
 
@@ -831,6 +838,23 @@ class TestFunctional(unittest.TestCase):
         data = self._DoReadFile('48_x86-start16-spl.dts')
         self.assertEqual(X86_START16_SPL_DATA, data[:len(X86_START16_SPL_DATA)])
 
+    def testPackUbootSplMicrocode(self):
+        """Test that x86 microcode can be handled correctly in SPL
+
+        We expect to see the following in the image, in order:
+            u-boot-spl-nodtb.bin with a microcode pointer inserted at the
+                correct place
+            u-boot.dtb with the microcode removed
+            the microcode
+        """
+        # ELF file with a '_dt_ucode_base_size' symbol
+        with open(self.TestFile('u_boot_ucode_ptr')) as fd:
+            TestFunctional._MakeInputFile('spl/u-boot-spl', fd.read())
+        first, pos_and_size = self._RunMicrocodeTest('49_x86_ucode_spl.dts',
+                                                     U_BOOT_SPL_NODTB_DATA)
+        self.assertEqual('splnodtb with microc' + pos_and_size +
+                         'ter somewhere in here', first)
+
 
 if __name__ == "__main__":
     unittest.main()
diff --git a/tools/binman/test/49_x86_ucode_spl.dts b/tools/binman/test/49_x86_ucode_spl.dts
new file mode 100644 (file)
index 0000000..67db93a
--- /dev/null
@@ -0,0 +1,29 @@
+/dts-v1/;
+
+/ {
+       #address-cells = <1>;
+       #size-cells = <1>;
+
+       binman {
+               sort-by-pos;
+               end-at-4gb;
+               size = <0x200>;
+               u-boot-spl-with-ucode-ptr {
+               };
+
+               u-boot-dtb-with-ucode {
+               };
+
+               u-boot-ucode {
+               };
+       };
+
+       microcode {
+               update@0 {
+                       data = <0x12345678 0x12345679>;
+               };
+               update@1 {
+                       data = <0xabcd0000 0x78235609>;
+               };
+       };
+};