1# SPDX-License-Identifier: GPL-2.0+ 2# Copyright (c) 2018 Google, Inc 3# Written by Simon Glass <sjg@chromium.org> 4# 5 6from collections import OrderedDict 7 8from entry import Entry, EntryArg 9import fdt_util 10 11 12class Entry_text(Entry): 13 """An entry which contains text 14 15 The text can be provided either in the node itself or by a command-line 16 argument. There is a level of indirection to allow multiple text strings 17 and sharing of text. 18 19 Properties / Entry arguments: 20 text-label: The value of this string indicates the property / entry-arg 21 that contains the string to place in the entry 22 <xxx> (actual name is the value of text-label): contains the string to 23 place in the entry. 24 25 Example node: 26 27 text { 28 size = <50>; 29 text-label = "message"; 30 }; 31 32 You can then use: 33 34 binman -amessage="this is my message" 35 36 and binman will insert that string into the entry. 37 38 It is also possible to put the string directly in the node: 39 40 text { 41 size = <8>; 42 text-label = "message"; 43 message = "a message directly in the node" 44 }; 45 46 The text is not itself nul-terminated. This can be achieved, if required, 47 by setting the size of the entry to something larger than the text. 48 """ 49 def __init__(self, section, etype, node): 50 Entry.__init__(self, section, etype, node) 51 self.text_label, = self.GetEntryArgsOrProps( 52 [EntryArg('text-label', str)]) 53 self.value, = self.GetEntryArgsOrProps([EntryArg(self.text_label, str)]) 54 if not self.value: 55 self.Raise("No value provided for text label '%s'" % 56 self.text_label) 57 58 def ObtainContents(self): 59 self.SetContents(self.value) 60 return True 61