blob: 6bc24ddf8ac4b446f2a618b7a748659b3bec6581 [file] [log] [blame]
Simon Glass29aa7362018-09-14 04:57:19 -06001# SPDX-License-Identifier: GPL-2.0+
2# Copyright 2018 Google, Inc
3# Written by Simon Glass <sjg@chromium.org>
4#
5# Holds and modifies the state information held by binman
6#
7
8import re
9from sets import Set
10
11import os
12import tools
13
14# Records the device-tree files known to binman, keyed by filename (e.g.
15# 'u-boot-spl.dtb')
16fdt_files = {}
17
18# Arguments passed to binman to provide arguments to entries
19entry_args = {}
20
21def GetFdt(fname):
22 """Get the Fdt object for a particular device-tree filename
23
24 Binman keeps track of at least one device-tree file called u-boot.dtb but
25 can also have others (e.g. for SPL). This function looks up the given
26 filename and returns the associated Fdt object.
27
28 Args:
29 fname: Filename to look up (e.g. 'u-boot.dtb').
30
31 Returns:
32 Fdt object associated with the filename
33 """
34 return fdt_files[fname]
35
36def GetFdtPath(fname):
37 """Get the full pathname of a particular Fdt object
38
39 Similar to GetFdt() but returns the pathname associated with the Fdt.
40
41 Args:
42 fname: Filename to look up (e.g. 'u-boot.dtb').
43
44 Returns:
45 Full path name to the associated Fdt
46 """
47 return fdt_files[fname]._fname
48
49def SetEntryArgs(args):
50 """Set the value of the entry args
51
52 This sets up the entry_args dict which is used to supply entry arguments to
53 entries.
54
55 Args:
56 args: List of entry arguments, each in the format "name=value"
57 """
58 global entry_args
59
60 entry_args = {}
61 if args:
62 for arg in args:
63 m = re.match('([^=]*)=(.*)', arg)
64 if not m:
65 raise ValueError("Invalid entry arguemnt '%s'" % arg)
66 entry_args[m.group(1)] = m.group(2)
67
68def GetEntryArg(name):
69 """Get the value of an entry argument
70
71 Args:
72 name: Name of argument to retrieve
73
74 Returns:
75 String value of argument
76 """
77 return entry_args.get(name)