forked from devicetree-org/lopper
-
Notifications
You must be signed in to change notification settings - Fork 0
/
README.pydoc
4190 lines (4140 loc) · 158 KB
/
README.pydoc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
Help on module __init__:
NAME
__init__
DESCRIPTION
#/*
# * Copyright (c) 2019,2020 Xilinx Inc. All rights reserved.
# *
# * Author:
# * Bruce Ashfield <bruce.ashfield@xilinx.com>
# *
# * SPDX-License-Identifier: BSD-3-Clause
# */
CLASSES
builtins.object
LopperAssist
LopperFile
LopperSDT
class LopperAssist(builtins.object)
| Internal class to contain the details of a lopper assist
|
| Methods defined here:
|
| __init__(self, lop_file, module='', properties_dict={})
| Initialize self. See help(type(self)) for accurate signature.
|
| ----------------------------------------------------------------------
| Data descriptors defined here:
|
| __dict__
| dictionary for instance variables (if defined)
|
| __weakref__
| list of weak references to the object (if defined)
class LopperFile(builtins.object)
| Internal class to contain the details of a lopper file
|
| Attributes:
| - dts: the dts source file path for a lop
| - dtb: the compiled dtb file path for a lop
| - fdt: the loaded FDT representation of the dtb
|
| Methods defined here:
|
| __init__(self, lop_file)
| Initialize self. See help(type(self)) for accurate signature.
|
| ----------------------------------------------------------------------
| Data descriptors defined here:
|
| __dict__
| dictionary for instance variables (if defined)
|
| __weakref__
| list of weak references to the object (if defined)
class LopperSDT(builtins.object)
| The LopperSDT Class represents and manages the full system DTS file
|
| In particular this class:
| - wraps a dts/dtb/fdt containing a system description
| - Has a LopperTree representation of the system device tree
| - manages and applies operations to the tree
| - calls modules and assist functions for processing of that tree
|
| Attributes:
| - dts (string): the source device tree file
| - dtb (blob): the compiled dts
| - FDT (fdt): the primary flattened device tree represention of the dts
| - lops (list): list of loaded lopper operations
| - verbose (int): the verbosity level of operations
| - tree (LopperTree): node/property representation of the system device tree
| - dry_run (bool): whether or not changes should be written to disk
| - output_file (string): default output file for writing
|
| Methods defined here:
|
| __init__(self, sdt_file)
| Initialize self. See help(type(self)) for accurate signature.
|
| assist_autorun_setup(self, module_name, module_args=[])
|
| assist_find(self, assist_name, local_load_paths=[])
| Locates a python module that matches assist_name
|
| This routine searches both system (lopper_directory, lopper_directory +
| "assists", and passed paths (local_load_paths) to locate a matching
| python implementation.
|
| Args:
| assist_name (string): name of the assist to locate
| local_load_paths (list of strings, optional): list of directories to search
| in addition to system dirs
|
| Returns:
| Path: Path object to the located python module, None on failure
|
| assists_setup(self, assists=[])
| assists (list,optional): list of python assist modules to load. Default is []
|
| assists_wrap(self)
| wrap assists that have been added to the device tree
|
| Wraps any command line assists that have been added to the system
| device tree. A standard lop format dtb is generated for any found
| assists, such that they will be loaded in the same manner as
| assists passed directly in lop files.
|
| Note: this is for internal use only
|
| Args:
| None
|
| Returns:
| Nothing
|
| cleanup(self)
| cleanup any temporary or copied files
|
| Either called directly, or registered as an atexit handler. Any
| temporary or copied files are removed, as well as other relevant
| cleanup.
|
| Args:
| None
|
| Returns:
| Nothing
|
| domain_spec(self, tgt_domain, tgt_domain_id='openamp,domain-v1')
| generate a lop for a command line passed domain
|
| When a target domain is passed on the command line, we must generate
| a lop dtb for it, so that it can be processed along with other
| operations
|
| Args:
| tgt_domain (string): path to the node to use as the domain
| tgt_domain_id (string): assist identifier to use for locating a
| registered assist.
|
| Returns:
| Nothing
|
| exec_lop(self, lop_node, lops_tree, options=None)
| Executes a a lopper operation (lop)
|
| Runs a lopper operation against the system device tree.
|
| Details of the lop are in the lops_fdt, with extra parameters and lop
| specific information from the caller being passed in the options
| variable.
|
| Args:
| lops_fdt (FDT): lopper operation flattened device tree
| lop_node_number (int): node number for the operation in lops_fdt
| options (dictionary,optional): lop specific options passed from the caller
|
| Returns:
| boolean
|
| find_compatible_assist(self, cb_node=None, cb_id='', mask='')
| Finds a registered assist that is compatible with a given ID
|
| Searches the registered assists for one that is compatible with an ID.
|
| The is_compat() routine is called for each registered module. If an
| assist is capabable of handling a given ID, it returns True and
| associated actions can then be taken.
|
| I addition to an ID string, a mask can optionally be provided to this
| routine. Any assists that have registered a mask, will have that
| checked, before calling the is_compat() routine. This allows assists to
| be generically registered, but filtered by the caller rather than only
| their is_compat() routines.
|
| Args:
| cb_node (int,optional): node offset to be tested. Default is 0 (root)
| cb_id (string,optional): ID to be tested for compatibility. Default is ""
| mask (string,optional): caller mask for filtering nodes. Default is ""
|
| Returns:
| function reference: the callback routine, or "", if no compatible routine found
|
| perform_lops(self)
| Execute all loaded lops
|
| Iterates and executes all the loaded lopper operations (lops) for the
| System Device tree.
|
| The lops are processed in priority order (priority specified at the file
| level), and the rules processed in order as they appear in the lop file.
|
| lopper operations can immediately process the output of the previous
| operation and hence can be stacked to perform complex operations.
|
| Args:
| None
|
| Returns:
| Nothing
|
| setup(self, sdt_file, input_files, include_paths, force=False, libfdt=True, config=None)
| executes setup and initialization tasks for a system device tree
|
| setup validates the inputs, and calls the appropriate routines to
| preprocess and compile passed input files (.dts).
|
| Args:
| sdt_file (String): system device tree path/file
| input_files (list): list of input files (.dts, or .dtb) in addition to the sdt_file
| include_paths (list): list of paths to search for files
| force (bool,optional): flag indicating if files should be overwritten and compilation
| forced. Default is False.
|
| Returns:
| Nothing
|
| write(self, tree=None, output_filename=None, overwrite=True, enhanced=False)
| Write a system device tree to a file
|
| Write a fdt (or system device tree) to an output file. This routine uses
| the output filename to determine if a module should be used to write the
| output.
|
| If the output format is .dts or .dtb, Lopper takes care of writing the
| output. If it is an unrecognized output type, the available assist
| modules are queried for compatibility. If there is a compatible assist,
| it is called to write the file, otherwise, a warning or error is raised.
|
| Args:
| tree (LopperTree,optional): LopperTree to write
| output_filename (string,optional): name of the output file to create
| overwrite (bool,optional): Should existing files be overwritten. Default is True.
| enhanced(bool,optional): whether enhanced printing should be performed. Default is False
|
| Returns:
| Nothing
|
| ----------------------------------------------------------------------
| Data descriptors defined here:
|
| __dict__
| dictionary for instance variables (if defined)
|
| __weakref__
| list of weak references to the object (if defined)
FUNCTIONS
lopper_type(cls)
stdoutIO(stdout=None)
DATA
lopper_directory = '/home/bruce/git/system-device-tree/lopper'
yaml_support = True
FILE
/home/bruce/git/system-device-tree/lopper/__init__.py
Help on module tree:
NAME
tree
DESCRIPTION
#/*
# * Copyright (c) 2019,2020 Xilinx Inc. All rights reserved.
# *
# * Author:
# * Bruce Ashfield <bruce.ashfield@xilinx.com>
# *
# * SPDX-License-Identifier: BSD-3-Clause
# */
CLASSES
builtins.object
LopperNode
LopperProp
LopperTree
LopperTreePrinter
enum.Enum(builtins.object)
LopperAction
class LopperAction(enum.Enum)
| Enum class to define the actions available in Lopper's node_filter function
|
| Method resolution order:
| LopperAction
| enum.Enum
| builtins.object
|
| Data and other attributes defined here:
|
| BLACKLIST = <LopperAction.BLACKLIST: 4>
|
| DELETE = <LopperAction.DELETE: 1>
|
| NONE = <LopperAction.NONE: 5>
|
| REPORT = <LopperAction.REPORT: 2>
|
| WHITELIST = <LopperAction.WHITELIST: 3>
|
| ----------------------------------------------------------------------
| Data descriptors inherited from enum.Enum:
|
| name
| The name of the Enum member.
|
| value
| The value of the Enum member.
|
| ----------------------------------------------------------------------
| Data descriptors inherited from enum.EnumMeta:
|
| __members__
| Returns a mapping of member name->value.
|
| This mapping lists all enum members, including aliases. Note that this
| is a read-only view of the internal mapping.
class LopperNode(builtins.object)
| Class representing a device tree node
|
| This class implements:
| - a property iterator
| - dictionary access to properties
| - str(): string cast
| - equality check (==): for comparison
| - ref counting: set, get, clear
| - property add, modify, delete (via methods and '-', '+')
| - resolve(): to update/calculate properties against the tree
| - sync(): sync modified node elements (and properties)
| - deep node copy via LopperNode()
|
| Attributes:
| - number: the node number in the backing structure
| - name: the node name in the backing structure (this is not the node path)
| - parent: a link to the parent LopperNode object
| - tree: the tree which contains this node
| - depth: the nodes depth in the backing structure (0 is root, 1 for first level children)
| - child_nodes: the list of child LopperNodes
| - phandle: the phandle in the backing FDT (optional)
| - type: the type of the node (based on 'compatible' property)
| - abs_path: the full/absolute path to this node in the backing FDT
| - _ref: the refcount for this node
| - __props__: ordered dictionary of LopperProp
| - __current_property__: place holder for property iterator
| - __dbg__: debug level for the node
| - __nstate__: the state of the node ("init", "resolved" )
| - __modified__: flag indicating if the node has been modified
|
| Methods defined here:
|
| __add__(self, other)
| magic method for adding a property to a node
|
| Supports adding a property to a node through "+"
|
| node + <LopperProp object>
|
| Args:
| other (LopperProp): property to add
|
| Returns:
| LopperNode: returns self, Exception on invalid input
|
| __call__(self, othernode=None)
| Callable implementation for the node class
|
| When used, this creates a deep copy of the current node, versus
| a reference. This allows a node to be cloned and used in a secondary
| tree, free from changes to the original node.
|
| Two modes are supported:
| A) <LopperNode Object>()
| B) <LopperNode Object>( <other node> )
|
| When no other node is passed (mode A) a copy of the existing node is
| made, including properties with the state is set to "init", this node
| should then be resolved to fill in missing information.
|
| When mode B is used, the current node is updated using copies of the
| values from the other node. This is used on a newly created node, to
| initalize it with values from an existing node.
|
| Args:
| othernode (LopperNode,optional): node to use for initalization values
|
| Returns:
| The copied node, or self (if updating).
|
| __deepcopy__(self, memodict={})
| Create a deep copy of a node
|
| Only certain parts of a node need to be copied, we also have to
| trigger deep copies of properties, since they have references
| to nodes.
|
| We leave most values as the defaults on the new node instance,
| since the copied node needs to be added to a tree, where they'll
| be filled in.
|
| __delitem__(self, key)
| magic method for removing a property from a node dictionary style
|
| ** Not currently implemented **, overridden to prevent use
|
| Supports removing a property from a node through "del"
|
| del <node>[prop]
|
| Args:
| key (LopperProp): property/index to remove
|
| Returns:
| Nothing
|
| __eq__(self, other)
| magic method for node comparision
|
| Support LopperNode comparisons: nodea == nodeb
|
| If the node numbers of two nodes match, we consider them equal.
|
| Args:
| other: LopperNode
|
| Returns:
| LopperNode object: self
|
| __getattribute__(self, name)
| magic method around object attribute access
|
| This method first attempts to access the objects inherent attributes and
| returns the value if one exists matching the passed name.
|
| If one is not found, then the properties dictionary is checked, and that
| value returned.
|
| This allows access like:
|
| <LopperNode Object>.compatible
|
| To get the compatible LopperProperty value.
|
| In practice, this is only of limited use, since many property names are
| not valid python attribute names.
|
| Args:
| name: attribute name
|
| Returns:
| The attribute value, or AttributeError if it doesn't exist.
|
| __getitem__(self, key)
| magic method for accessing LopperNode properties like a dictionary
|
| Allow accessing of properties as a dictionary:
|
| <Lopper Node Object>[<property name>]
|
| This abstracts the storage of the properties and allows direct access
| by name. Either the string name of the property may be used, or a
| LopperProp object itself.
|
| The standard KeyError exception is raised if the property is not valid for
| a node.
|
| For an exception free way of checking for a property, see the propval()
| method.
|
| Args:
| key: string or LopperProp
|
| Returns:
| LopperProp object or KeyError exception
|
| __hash__(self)
| magic method for hasing a node
|
| Used when searching for a node in a list (among other things). We return
| the hash of a nodes absolute path as the identity value.
|
| Args:
| None
|
| Returns:
| Integer hash for the node
|
| __init__(self, number=-1, abspath='', tree=None, phandle=-1, name='', debug=0)
| Initialize self. See help(type(self)) for accurate signature.
|
| __int__(self)
| magic method for int type conversion of LopperNode
|
| If a LopperNode is converted to an int, we use the node number
|
| Args:
| None
|
| Returns:
| int: the node number
|
| __iter__(self)
| magic method to support iteration
|
| For iterating the properties of a LopperNode, we are the iterator.
| This is required by the iterator protocol.
|
| Args:
| None
|
| Returns:
| LopperNode object: self
|
| __next__(self)
| magic method for iteration on a node
|
| This routine uses the __current_property__ attribute to move
| through the properties of a node.
|
| If there are no properties, or we have iterated all properties,
| StopIteration is raised (as is required by the iterator protocol).
|
| Args:
| None
|
| Returns:
| LopperProp object or StopIteration exception
|
| __setattr__(self, name, value)
| magic method to check the setting of a LopperNode attribute
|
| If the attribute being set is the debug level (__dbg__), this wrapper
| chains the setting to any LopperProps of the node.
|
| If the attribute is any other, we set the value and tag the node as
| modified, so it can be sync'd later.
|
| Args:
| name: attribute name
| value: attribute value
|
| Returns:
| Nothing
|
| __setitem__(self, key, val)
| magic method for setting LopperNode properties like a dictionary
|
| Allow setting of properties as a dictionary:
|
| <Lopper Node Object>[<property name>] = <LopperProperty Object>
|
| or
|
| <Lopper Node Object>[<property name>] = [list of property values]
|
|
| This abstracts the storage of the properties and allows direct access
| by name.
|
| If a LopperProp is passed as 'val', it is directly assigned. If a list
| of values is passed, a LopperProp object is created, the values assigned
| and then placed in the property dictionary.
|
| Args:
| key: string
| val: LopperProp or string
|
| Returns:
| Nothing
|
| __str__(self)
| magic method for string type conversion of LopperNode
|
| If a LopperNode is converted to a string, we use the absolute (full) path
|
| Args:
| None
|
| Returns:
| string: the abs path
|
| __sub__(self, other)
| magic method for removing a property from a node
|
| Supports removing a property from a node through "-"
|
| node - <LopperProp object>
|
| Args:
| other (LopperProp): property to remove
|
| Returns:
| LopperNode: returns self
|
| add(self, prop)
| Add a property or subnode to a node
|
| Supports adding a property or node to a node through
|
| node.add( prop )
|
| After adding the new elelent, the node is tagged as modified to it
| can be sync'd in the future.
|
| Args:
| prop (LopperProp or LopperNode): element to add
|
| Returns:
| LopperNode: returns self, raises Exception on invalid parameter
|
| delete(self, prop)
| delete a property from a node
|
| Queues a property for deletion on the next sync of a node.
|
| Takes a property name or LopperProp object as the parameter, and if
| it is a valid property, queues it for deletion.
|
| The node is marked as modified, so on the next sync, it will be remove.
|
| Args:
| prop (string or LopperProp): the property to delete
|
| Returns:
| Nothing. KeyError if property is not found
|
| export(self)
| Export node details as a dictionary
|
| Export the details of a node in a dictionary. The format of the dictionary
| is suitable for loading() into a LopperTree, or syncing() to a flattened
| device tree by lopper.fdt.
|
| Internal / FDT properties are prefixed/suffixed with __.
|
| As part of exporting a node, if paths are detected as changed (a moved
| node, a renamed node, etc), then the are adjusted in the tree and
| exported in the dictionary.
|
| Note: This is not recursive, so child nodes are not exported
|
| Args:
| None
|
| Returns:
| Ordered Dict Describing a node
|
| items(self)
| method to support items() iteration
|
| If the pure Iterators aren't used (__iter__, etc), and instead a dictionary
| style items() is requested for the Node. We can just return the items() from
| __props__ to support that style of access.
|
| Args:
| None
|
| Returns:
| LopperNode object: self
|
| load(self, dct, parent_path=None, clear_children=True, update_props=False)
| load (calculate) node details against a property dictionary
|
| Some attributes of a node are not known at initialization time, or may
| change due to tree operations.
|
| This method calculates those values using information in the node and in
| the passed property dictionary
|
| If clear_children is set to True (the default), children nodes will be
| dropped with the expectation that they will be re-added when the children
| themselves are loaded. When set to False, the children are not modified,
| and this is used when updating a node from a dictionary.
|
| If update_props is set to True (the default is False), then existing
| properties will be updated with the contents of the passed dictionary.
| This is set to true when a dictionary should override all values in
| a node.
|
| Fields resolved (see class for descriptions)
| - name
| - abs_path
| - phandle
| - depth
| - children
| - type
| - __props__
| - __nstate__
| - __modified__
|
| Args:
| Property dictionary: Dictionary with the node details/properties
| parent_path (Optional,string)
| clear_children (Optional,boolean): default is True
| update_props (Optional,boolean): default is False
|
| Returns:
| Nothing
|
| merge(self, other_node)
| merge a secondary node into the target
|
| This routine updates the target node with the properties of secondary.
|
| It is additive/modification only, no properties are removed as part of
| the processing.
|
| Args:
| other_node (LopperNode): The other to merge
|
| Returns:
| Nothing
|
| phandle_or_create(self)
| Access (and generate) a phandle for this node
|
| Invoked the containing tree (if available), ad creates a unique phandle
| for a node. This is basic tracking and is used since
| fdt_find_max_phandle is not fully exposed, and removes a binding to
| libfdt.
|
| Args:
| None
|
| Returns:
| phandle number
|
| print(self, output=None, strict=None)
| print a node
|
| Print a node to the passed output stream. If it isn't passed, then
| the containg tree's output is used. If the tree has no output, stdout
| is the final fallback.
|
| The node will be indented to match the depth of a node
| in a tree.
|
| Args:
| output (optional, output stream).
|
| Returns:
| Nothing
|
| props(self, name)
| Access a property or list of properties described by a name/regex
|
| Looks through the properties of a node and returns any that match
| the name or regex passed to the routine.
|
| Args:
| name (string): property name or property regex
|
| Returns:
| list: list of LopperProp objects that match the name/regex, or [] if none match
|
| propval(self, pname, ptype=None)
| Access the value of a property
|
| This is a safe (no Exception) way to access the value of a named property,
| versus access it through the dictionary accessors.
|
| Args:
| name (string): property name
| ptype(Optional): the format of the returned value
|
| Returns:
| list: list of values for the property, or [""] if the property name is invalid
|
| reset(self)
| reset the iterator of the node
|
| Sets the node iteration index to the starting value.
|
| Args:
| None
|
| Returns:
| None
|
| resolve(self, fdt=None)
| resolve (calculate) node details against a FDT
|
| Some attributes of a node are not known at initialization time, or may
| change due to tree operations.
|
| This method calculates those values using information in the node and in
| the passed FDT. If no FDT is passed only partial resolution is done.
|
| The only value that must be set in the node before resolve() is called
| is the node number. Which simply means it should have been added to the
| FDT first (see LopperTree.add()) and then resolved.
|
| Fields resolved (see class for descriptions)
| - name
| - abs_path
| - phandle
| - depth
| - children
| - type
| - __props__
| - __nstate__
| - __modified__
|
| Args:
| fdt (FDT): flattened device tree to sync to or None if no
| tree is available
|
| Returns:
| Nothing
|
| resolve_all_refs(self, property_mask=[])
| Resolve and Return all references in a node
|
| Finds all the references starting from a given node. This includes:
|
| - The node itself
| - The parent nodes
| - Any phandle referenced nodes, and any nodes they reference, etc
|
| Args:
| property_mask (list of regex): Any properties to exclude from reference
| tracking, "*" to exclude all properties
|
| Returns:
| A list of referenced nodes, or [] if no references are found
|
| subnodes(self, depth=0, max_depth=None, children_only=False)
| Return all the subnodes of this node
|
| Gathers and returns all the reachable subnodes of the current node
| (this includes nodes of children, etc).
|
| Args:
| None
|
| Returns:
| A list of child LopperNodes
|
| sync(self, fdt=None)
| sync a LopperNode to a backing FDT
|
| This routine looks for changes to the LopperNode and writes them back
| to the passed FDT.
|
| For the node itself, this is primarily a write back of a changed name.
|
| As part of the sync process, the node's number in the backing FDT is
| checked and the stored number changed to match as appropriate.
|
| We also check fo modified properties and sync them to the FDT.
|
| Removed properties are deleted from the FDT.
|
| And finally, the __modified__ flag is set to False.
|
| Args:
| fdt (FDT): device tree to sync against
|
| Returns:
| boolean: True if the node was sync'd, False otherwise
|
| ----------------------------------------------------------------------
| Data descriptors defined here:
|
| __dict__
| dictionary for instance variables (if defined)
|
| __weakref__
| list of weak references to the object (if defined)
|
| ref
| Node reference count getter
|
| Args:
| None
|
| Returns:
| int: The node refcount
class LopperProp(builtins.object)
| Class representing a device tree property
|
| This class implements:
| - resolve(): to update information / state against a device tree
| - sync(): to write changes back to the device tree
| - utility routines for easy access and iteration of the values
|
| Attributes:
| - __modified__: Flag to indicate if the property has been changed
| - __pstate__: The state of the property. For internal use only.
| Values can be: "init", "resolved", "syncd" or "deleted"
| - __dbg__: The debug/verbosity level of property operations. 0 is no
| debug, and levels increase from there.
|
| - name: The property name
| - value: The property value (always as a list of values)
| - node: The node that contains this property
| - number: The property offset within the containing node (rarely used)
| - string_val: The enhanced printed string representation of a property
| - type: The type of a property, "comment", "preamble" or "list"
| - abs_path: The absolute device tree path to this property
|
| Methods defined here:
|
| __deepcopy__(self, memodict={})
| Create a deep copy of a property
|
| Properties have links to nodes, so we need to ensure that they are
| cleared as part of a deep copy.
|
| __getitem__(self, key)
| Access a property's value by key
|
| Allows the property's value to be access by 'index', since
| properties are normally lists of value.
|
| If the property is a special type, i.e. a json pclass, then
| the value is expanded and indexed. Otherwise, the value list
| is simply indexed
|
| Non-integer keys return None. Unless "value" is used as a key
| and you get the raw/entire value list.
|
| Normal list exceptions are raised if you index outside of the
| range of the value
|
| Args:
| Key (int or "value")
|
| Returns:
| The item at the specified index
|
| __init__(self, name, number=-1, node=None, value=None, debug_lvl=0)
| Initialize self. See help(type(self)) for accurate signature.
|
| __iter__(self)
| magic method to support iteration
|
| This allows the values of a property to be iterated, which
| isn't very useful. But it is useful that functions like dict()
| take this iterator and create a usable dictionary for the
| caller.
|
| If the property is special, like json, then you get an
| keyed return of 'value' and the loaded value
|
| if the property is standard, you get a keyed return of
| 'value' and the value list
|
| Args:
| None
|
| Returns:
| iterator for use in dict()
|
| __len__(self)
| Get the length of a property
|
| When using the __getitem__ access to property values, knowing
| the length is important.
|
| if the property is a special class (i.e. json), the lenght of
| the loaded list is returned.
|
| if the values are a list, the lenght of that list is returned
|
| if the value is a single item, 0 is returned
|
| Args:
| None
|
| Returns:
| Int: The lenght of the list
|
| __setattr__(self, name, value)
| magic method to check the setting of a LopperProp attribute
|
| If the attribute being set is "value" (i.e. LopperProp.value), this
| method makes sure that it is stored as a list, that the property is
| marked as modified (for future write backs) and triggers a resolve()
| of the property value.
|
| Args:
| name: attribute name
| value: attribute value
|
| Returns:
| Nothing
|
| __str__(self)
| The string representation of the property