fdthelper.py (13719:74853963ddcf) | fdthelper.py (14151:1c08ca99b7f2) |
---|---|
1# Copyright (c) 2016 ARM Limited | 1# Copyright (c) 2016,2019 ARM Limited |
2# All rights reserved. 3# 4# The license below extends only to copyright in the software and shall 5# not be construed as granting a license to any other intellectual 6# property including but not limited to intellectual property relating 7# to a hardware implementation of the functionality of the software 8# licensed hereunder. You may use the software subject to the license 9# terms below provided that you ensure that this notice is replicated --- 72 unchanged lines hidden (view full) --- 82class FdtState(object): 83 """Class for maintaining state while recursively generating a flattened 84 device tree. The state tracks address, size and CPU address cell sizes, and 85 maintains a dictionary of allocated phandles.""" 86 87 phandle_counter = 0 88 phandles = dict() 89 | 2# All rights reserved. 3# 4# The license below extends only to copyright in the software and shall 5# not be construed as granting a license to any other intellectual 6# property including but not limited to intellectual property relating 7# to a hardware implementation of the functionality of the software 8# licensed hereunder. You may use the software subject to the license 9# terms below provided that you ensure that this notice is replicated --- 72 unchanged lines hidden (view full) --- 82class FdtState(object): 83 """Class for maintaining state while recursively generating a flattened 84 device tree. The state tracks address, size and CPU address cell sizes, and 85 maintains a dictionary of allocated phandles.""" 86 87 phandle_counter = 0 88 phandles = dict() 89 |
90 def __init__(self, addr_cells, size_cells, cpu_cells): | 90 def __init__(self, **kwargs): |
91 """Instantiate values of this state. The state can only be initialized 92 once.""" 93 | 91 """Instantiate values of this state. The state can only be initialized 92 once.""" 93 |
94 self.addr_cells = addr_cells 95 self.size_cells = size_cells 96 self.cpu_cells = cpu_cells | 94 self.addr_cells = kwargs.pop('addr_cells', 0) 95 self.size_cells = kwargs.pop('size_cells', 0) 96 self.cpu_cells = kwargs.pop('cpu_cells', 0) 97 self.interrupt_cells = kwargs.pop('interrupt_cells', 0) |
97 98 def phandle(self, obj): 99 """Return a unique phandle number for a key. The key can be a SimObject 100 or any value that is castable to a string. If the phandle doesn't exist 101 a new one is created, otherwise the existing one is returned.""" 102 103 if isinstance(obj, SimObject): 104 key = str(id(obj)) --- 32 unchanged lines hidden (view full) --- 137 state.""" 138 return self.int_to_cells(addr, self.cpu_cells) 139 140 def sizeCells(self, size): 141 """Format an integer type according to the size_cells value of this 142 state.""" 143 return self.int_to_cells(size, self.size_cells) 144 | 98 99 def phandle(self, obj): 100 """Return a unique phandle number for a key. The key can be a SimObject 101 or any value that is castable to a string. If the phandle doesn't exist 102 a new one is created, otherwise the existing one is returned.""" 103 104 if isinstance(obj, SimObject): 105 key = str(id(obj)) --- 32 unchanged lines hidden (view full) --- 138 state.""" 139 return self.int_to_cells(addr, self.cpu_cells) 140 141 def sizeCells(self, size): 142 """Format an integer type according to the size_cells value of this 143 state.""" 144 return self.int_to_cells(size, self.size_cells) 145 |
146 def interruptCells(self, interrupt): 147 """Format an integer type according to the interrupt_cells value 148 of this state.""" 149 return self.int_to_cells(interrupt, self.interrupt_cells) 150 |
|
145 def addrCellsProperty(self): 146 """Return an #address-cells property with the value of this state.""" 147 return FdtPropertyWords("#address-cells", self.addr_cells) 148 149 def sizeCellsProperty(self): 150 """Return an #size-cells property with the value of this state.""" 151 return FdtPropertyWords("#size-cells", self.size_cells) 152 153 def CPUCellsProperty(self): 154 """Return an #address-cells property for cpu nodes with the value 155 of this state.""" 156 return FdtPropertyWords("#address-cells", self.cpu_cells) 157 | 151 def addrCellsProperty(self): 152 """Return an #address-cells property with the value of this state.""" 153 return FdtPropertyWords("#address-cells", self.addr_cells) 154 155 def sizeCellsProperty(self): 156 """Return an #size-cells property with the value of this state.""" 157 return FdtPropertyWords("#size-cells", self.size_cells) 158 159 def CPUCellsProperty(self): 160 """Return an #address-cells property for cpu nodes with the value 161 of this state.""" 162 return FdtPropertyWords("#address-cells", self.cpu_cells) 163 |
164 def interruptCellsProperty(self): 165 """Return an #interrupt-cells property for cpu nodes with the value 166 of this state.""" 167 return FdtPropertyWords("#interrupt-cells", self.interrupt_cells) 168 169 |
|
158class FdtNop(pyfdt.FdtNop): 159 """Create an empty node.""" 160 pass 161 162class FdtNode(pyfdt.FdtNode): 163 def __init__(self, name, obj=None): 164 """Create a new node and immediately set the phandle property, if obj 165 is supplied""" --- 94 unchanged lines hidden --- | 170class FdtNop(pyfdt.FdtNop): 171 """Create an empty node.""" 172 pass 173 174class FdtNode(pyfdt.FdtNode): 175 def __init__(self, name, obj=None): 176 """Create a new node and immediately set the phandle property, if obj 177 is supplied""" --- 94 unchanged lines hidden --- |