from collections import OrderedDict
import os
-import re
import sys
import tools
import command
import elf
from image import Image
+import state
import tout
# List of images we plan to create
# Make this global so that it can be referenced from tests
images = OrderedDict()
-# Records the device-tree files known to binman, keyed by filename (e.g.
-# 'u-boot-spl.dtb')
-fdt_files = {}
-
-# Arguments passed to binman to provide arguments to entries
-entry_args = {}
-
-
def _ReadImageDesc(binman_node):
"""Read the image descriptions from the /binman node
return node
return None
-def GetFdt(fname):
- """Get the Fdt object for a particular device-tree filename
-
- Binman keeps track of at least one device-tree file called u-boot.dtb but
- can also have others (e.g. for SPL). This function looks up the given
- filename and returns the associated Fdt object.
+def WriteEntryDocs(modules, test_missing=None):
+ """Write out documentation for all entries
Args:
- fname: Filename to look up (e.g. 'u-boot.dtb').
-
- Returns:
- Fdt object associated with the filename
+ modules: List of Module objects to get docs for
+ test_missing: Used for testing only, to force an entry's documeentation
+ to show as missing even if it is present. Should be set to None in
+ normal use.
"""
- return fdt_files[fname]
-
-def GetFdtPath(fname):
- return fdt_files[fname]._fname
-
-def SetEntryArgs(args):
- global entry_args
-
- entry_args = {}
- if args:
- for arg in args:
- m = re.match('([^=]*)=(.*)', arg)
- if not m:
- raise ValueError("Invalid entry arguemnt '%s'" % arg)
- entry_args[m.group(1)] = m.group(2)
-
-def GetEntryArg(name):
- return entry_args.get(name)
-
-def WriteEntryDocs(modules, test_missing=None):
from entry import Entry
Entry.WriteDocs(modules, test_missing)
try:
tools.SetInputDirs(options.indir)
tools.PrepareOutputDir(options.outdir, options.preserve)
- SetEntryArgs(options.entry_arg)
+ state.SetEntryArgs(options.entry_arg)
# Get the device tree ready by compiling it and copying the compiled
# output into a file in our output directly. Then scan it for use
dtb = fdt.FdtScan(fname)
# Note the file so that GetFdt() can find it
- fdt_files['u-boot.dtb'] = dtb
+ state.fdt_files['u-boot.dtb'] = dtb
node = _FindBinmanNode(dtb)
if not node:
raise ValueError("Device tree '%s' does not have a 'binman' "
except:
have_importlib = False
-import fdt_util
-import control
import os
import sys
+
+import fdt_util
+import state
import tools
modules = {}
Raises:
ValueError if the argument cannot be converted to in
"""
- value = control.GetEntryArg(name)
+ value = state.GetEntryArg(name)
if value is not None:
if datatype == int:
try:
# Entry-type module for U-Boot device tree with the microcode removed
#
-import control
from entry import Entry
from blob import Entry_blob
+import state
import tools
class Entry_u_boot_dtb_with_ucode(Entry_blob):
# Remove the microcode
fname = self.GetDefaultFilename()
- fdt = control.GetFdt(fname)
+ fdt = state.GetFdt(fname)
self.ucode = fdt.GetNode('/microcode')
if not self.ucode:
raise self.Raise("No /microcode node found in '%s'" % fname)
def ObtainContents(self):
# Call the base class just in case it does something important.
Entry_blob.ObtainContents(self)
- self._pathname = control.GetFdtPath(self._filename)
+ self._pathname = state.GetFdtPath(self._filename)
self.ReadBlobContents()
if self.ucode:
for node in self.ucode.subnodes:
import fdt_util
import fmap_util
import test_util
+import state
import tools
import tout
retcode = self._DoTestFile(fname, map=map, update_dtb=update_dtb,
entry_args=entry_args)
self.assertEqual(0, retcode)
- out_dtb_fname = control.GetFdtPath('u-boot.dtb')
+ out_dtb_fname = state.GetFdtPath('u-boot.dtb')
# Find the (only) image, read it and return its contents
image = control.images['image']
--- /dev/null
+# SPDX-License-Identifier: GPL-2.0+
+# Copyright 2018 Google, Inc
+# Written by Simon Glass <sjg@chromium.org>
+#
+# Holds and modifies the state information held by binman
+#
+
+import re
+from sets import Set
+
+import os
+import tools
+
+# Records the device-tree files known to binman, keyed by filename (e.g.
+# 'u-boot-spl.dtb')
+fdt_files = {}
+
+# Arguments passed to binman to provide arguments to entries
+entry_args = {}
+
+def GetFdt(fname):
+ """Get the Fdt object for a particular device-tree filename
+
+ Binman keeps track of at least one device-tree file called u-boot.dtb but
+ can also have others (e.g. for SPL). This function looks up the given
+ filename and returns the associated Fdt object.
+
+ Args:
+ fname: Filename to look up (e.g. 'u-boot.dtb').
+
+ Returns:
+ Fdt object associated with the filename
+ """
+ return fdt_files[fname]
+
+def GetFdtPath(fname):
+ """Get the full pathname of a particular Fdt object
+
+ Similar to GetFdt() but returns the pathname associated with the Fdt.
+
+ Args:
+ fname: Filename to look up (e.g. 'u-boot.dtb').
+
+ Returns:
+ Full path name to the associated Fdt
+ """
+ return fdt_files[fname]._fname
+
+def SetEntryArgs(args):
+ """Set the value of the entry args
+
+ This sets up the entry_args dict which is used to supply entry arguments to
+ entries.
+
+ Args:
+ args: List of entry arguments, each in the format "name=value"
+ """
+ global entry_args
+
+ entry_args = {}
+ if args:
+ for arg in args:
+ m = re.match('([^=]*)=(.*)', arg)
+ if not m:
+ raise ValueError("Invalid entry arguemnt '%s'" % arg)
+ entry_args[m.group(1)] = m.group(2)
+
+def GetEntryArg(name):
+ """Get the value of an entry argument
+
+ Args:
+ name: Name of argument to retrieve
+
+ Returns:
+ String value of argument
+ """
+ return entry_args.get(name)