MCPcopy
hub / github.com/AsahiLinux/m1n1 / parse_one

Function parse_one

tools/reg2json.py:18–127  ·  view source on GitHub ↗
(regs, xml)

Source from the content-addressed store, hash-verified

16 return int(s.replace("0b", ""), 2)
17
18def parse_one(regs, xml):
19 t = ElementTree.parse(xml)
20
21 for reg in t.findall('registers/register'):
22 data = {}
23
24 name = reg.find('reg_short_name').text
25 fullname = reg.find('reg_long_name').text
26
27 if name.startswith("S3_") or name.startswith("SYS S1_"):
28 continue
29
30 array = reg.find('reg_array')
31
32 start = end = 0
33
34 if array:
35 start = int(array.find("reg_array_start").text)
36 end = int(array.find("reg_array_end").text)
37
38 encs = {}
39 accessors = {}
40
41 for am in reg.findall('access_mechanisms/access_mechanism'):
42 accessor = am.attrib["accessor"]
43 if accessor.startswith("MSRimmediate"):
44 continue
45 ins = am.find("encoding/access_instruction").text.split(" ")[0]
46 regname = accessor.split(" ", 1)[1]
47 enc = {}
48 for e in am.findall("encoding/enc"):
49 enc[e.attrib["n"]] = e.attrib["v"]
50
51 enc = enc["op0"], enc["op1"], enc["CRn"], enc["CRm"], enc["op2"]
52 if regname in encs:
53 assert encs[regname] == enc
54 encs[regname] = enc
55 accessors.setdefault(regname, set()).add(ins)
56
57 if not encs:
58 continue
59
60 fieldsets = []
61
62 width = None
63
64 for fields_elem in reg.findall('reg_fieldsets/fields'):
65
66 fieldset = {}
67
68 if (instance_elem := fields_elem.find('fields_instance')) is not None:
69 fieldset["instance"] = instance_elem.text
70
71 fields = []
72
73 set_width = int(fields_elem.attrib["length"])
74
75 if width is None:

Callers 1

reg2json.pyFile · 0.85

Calls 7

insert_nFunction · 0.85
getMethod · 0.80
appendMethod · 0.80
replaceMethod · 0.80
parseMethod · 0.45
addMethod · 0.45
itemsMethod · 0.45

Tested by

no test coverage detected