Squash commits for public release
This commit is contained in:
39
utils/compilers/DevTreeCompiler/ABI/Structs.py
Normal file
39
utils/compilers/DevTreeCompiler/ABI/Structs.py
Normal file
@@ -0,0 +1,39 @@
|
||||
from construct import *
|
||||
|
||||
DEVTREE_HEADER_SIGNATURE = "odtr3"
|
||||
|
||||
DEVTREE_HEADER = Struct(
|
||||
"signature" / PaddedString(8, "ascii"),
|
||||
"revision" / Int32ul,
|
||||
"flags" / Int32ul,
|
||||
"entries_count" / Int32ul,
|
||||
"name_list_offset" / Int32ul
|
||||
)
|
||||
|
||||
DEVTREE_ENTRY_FLAGS_MMIO = (1 << 0)
|
||||
DEVTREE_ENTRY_TYPE_IO = 0
|
||||
DEVTREE_ENTRY_TYPE_FB = 1
|
||||
DEVTREE_ENTRY_TYPE_UART = 2
|
||||
DEVTREE_ENTRY_TYPE_RAM = 3
|
||||
DEVTREE_ENTRY_TYPE_STORAGE = 4
|
||||
DEVTREE_ENTRY_TYPE_BUS_CONTROLLER = 5
|
||||
DEVTREE_ENTRY_TYPE_RTC = 6
|
||||
|
||||
# Currently flags maps to irq_flags_t in the kernel.
|
||||
# Later we might need to enhance irq_flags_from_devtree() to use as translator.
|
||||
DEVTREE_IRQ_FLAGS_EDGE_TRIGGER = (1 << 0)
|
||||
|
||||
DEVTREE_ENTRY = Struct(
|
||||
"type" / Int32ul,
|
||||
"flags" / Int32ul,
|
||||
"region_base" / Int64ul,
|
||||
"region_size" / Int64ul,
|
||||
"irq_lane" / Int32ul,
|
||||
"irq_flags" / Int32ul,
|
||||
"irq_priority" / Int32ul,
|
||||
"rel_name_offset" / Int32ul,
|
||||
"aux1" / Int64ul,
|
||||
"aux2" / Int64ul,
|
||||
"aux3" / Int64ul,
|
||||
"aux4" / Int64ul,
|
||||
)
|
||||
47
utils/compilers/DevTreeCompiler/ABI/Translation.py
Normal file
47
utils/compilers/DevTreeCompiler/ABI/Translation.py
Normal file
@@ -0,0 +1,47 @@
|
||||
from ABI.Structs import *
|
||||
|
||||
|
||||
class Translator():
|
||||
|
||||
@staticmethod
|
||||
def entry_flag_translator(s):
|
||||
translation = {
|
||||
"MMIO": DEVTREE_ENTRY_FLAGS_MMIO,
|
||||
}
|
||||
return translation.get(s, 0)
|
||||
|
||||
@staticmethod
|
||||
def irq_flag_translator(s):
|
||||
translation = {
|
||||
"EDGE_TRIGGER": DEVTREE_IRQ_FLAGS_EDGE_TRIGGER,
|
||||
}
|
||||
return translation.get(s, 0)
|
||||
|
||||
@staticmethod
|
||||
def entry_type(s):
|
||||
translation = {
|
||||
"IO": DEVTREE_ENTRY_TYPE_IO,
|
||||
"FB": DEVTREE_ENTRY_TYPE_FB,
|
||||
"UART": DEVTREE_ENTRY_TYPE_UART,
|
||||
"RAM": DEVTREE_ENTRY_TYPE_RAM,
|
||||
"STORAGE": DEVTREE_ENTRY_TYPE_STORAGE,
|
||||
"BUS_CONTROLLER": DEVTREE_ENTRY_TYPE_BUS_CONTROLLER,
|
||||
"RTC": DEVTREE_ENTRY_TYPE_RTC
|
||||
}
|
||||
return translation.get(s, DEVTREE_ENTRY_TYPE_IO)
|
||||
|
||||
@staticmethod
|
||||
def number(s):
|
||||
return int(s, base=0)
|
||||
|
||||
@staticmethod
|
||||
def flags(s, flagcb):
|
||||
flags = 0x0
|
||||
ents = s.split(" ")
|
||||
|
||||
for ent in ents:
|
||||
t = flagcb(s)
|
||||
if t != None:
|
||||
flags |= t
|
||||
|
||||
return flags
|
||||
Reference in New Issue
Block a user