Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
X
x393
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Commits
Open sidebar
Elphel
x393
Commits
7b053ece
Commit
7b053ece
authored
Mar 29, 2016
by
Andrey Filippov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
added exyta union field to all unions/structures
parent
a821207d
Changes
3
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
1151 additions
and
717 deletions
+1151
-717
x393.c
py393/generated/x393.c
+292
-292
x393_types.h
py393/generated/x393_types.h
+817
-382
x393_export_c.py
py393/x393_export_c.py
+42
-43
No files found.
py393/generated/x393.c
View file @
7b053ece
This source diff could not be displayed because it is too large. You can
view the blob
instead.
py393/generated/x393_types.h
View file @
7b053ece
This diff is collapsed.
Click to expand it.
py393/x393_export_c.py
View file @
7b053ece
...
@@ -61,6 +61,7 @@ class X393ExportC(object):
...
@@ -61,6 +61,7 @@ class X393ExportC(object):
'showType'
:
True
,
'showType'
:
True
,
'showRange'
:
True
,
'showRange'
:
True
,
'nameMembers'
:
True
,
#name each struct in a union
'nameMembers'
:
True
,
#name each struct in a union
'data32'
:
'd32'
,
#union branch that is always u32 ("" to disable)
# 'declare':(26,48,0, 80), #function name, arguments, (body), comments
# 'declare':(26,48,0, 80), #function name, arguments, (body), comments
# 'define': (26,48,72,106), #function name, arguments, body, comments
# 'define': (26,48,72,106), #function name, arguments, body, comments
# 'declare':(29,59,0, 91), #function name, arguments, (body), comments
# 'declare':(29,59,0, 91), #function name, arguments, (body), comments
...
@@ -85,35 +86,12 @@ class X393ExportC(object):
...
@@ -85,35 +86,12 @@ class X393ExportC(object):
self
.
func_def
=
[]
self
.
func_def
=
[]
self
.
save_typedefs
(
self
.
gen_dir
,
self
.
typdefs_file
)
self
.
save_typedefs
(
self
.
gen_dir
,
self
.
typdefs_file
)
# print(self.get_typedefs(frmt_spcs = None))
# for k in self.typedefs:
# print (k+": " + self.typedefs[k]['comment'])
self
.
save_header_file
(
self
.
gen_dir
,
self
.
header_file
)
self
.
save_header_file
(
self
.
gen_dir
,
self
.
header_file
)
self
.
save_func_def_file
(
self
.
gen_dir
,
self
.
func_def_file
)
self
.
save_func_def_file
(
self
.
gen_dir
,
self
.
func_def_file
)
self
.
save_defines_file
(
self
.
gen_dir
,
self
.
defs_file
)
self
.
save_defines_file
(
self
.
gen_dir
,
self
.
defs_file
)
self
.
save_harware_map_file
(
self
.
gen_dir
,
self
.
map_file
)
self
.
save_harware_map_file
(
self
.
gen_dir
,
self
.
map_file
)
# ld= self.define_macros()
# ld+=self.define_other_macros()
# print('\n\n//======== using defines ========')
# for d in ld:
# print(self.expand_define_maxi0(d, mode = "defines",frmt_spcs = None))
# print('\n\n//======== function declarations ========')
# for d in ld:
# fd=self.expand_define_maxi0(d, mode = "func_decl",frmt_spcs = None)
# if fd:
# print(fd)
# print('\n\n//======== function definitions ========')
# for d in ld:
# fd=self.expand_define_maxi0(d, mode = "func_def",frmt_spcs = None)
# if fd:
# print(fd)
# print("\n\n// ===== Sorted address map =====\n")
# sam = self.expand_define_parameters(ld)
# print("sam=",sam)
# for d in sam:
# print(self.expand_define_maxi0(d, mode = "defines", frmt_spcs = None))
def
make_generated
(
self
,
path
):
def
make_generated
(
self
,
path
):
try
:
try
:
os
.
makedirs
(
path
)
os
.
makedirs
(
path
)
...
@@ -1283,18 +1261,26 @@ class X393ExportC(object):
...
@@ -1283,18 +1261,26 @@ class X393ExportC(object):
s
+=
"(
%
s)"
%
(
args
)
s
+=
"(
%
s)"
%
(
args
)
s
=
self
.
str_tab_stop
(
s
,
stops
[
2
])
s
=
self
.
str_tab_stop
(
s
,
stops
[
2
])
if
isDefine
:
if
isDefine
:
s
+=
'{'
if
self
.
typedefs
[
data_type
][
'code'
]:
# not just u32
td
=
'd.
%
s'
%
(
frmt_spcs
[
'data32'
])
else
:
td
=
'd'
# s+='{ %s d; %s = readl(0x%08x'%(data_type, td,address)
s
+=
'{
%
s d;
%
s = readl((void*) '
%
(
data_type
,
td
)
if
address_inc
:
if
address_inc
:
s
+=
'(0x
%08
x'
%
(
address
)
if
multivar
:
if
multivar
:
s
+=
'return (
%
s) readl(0x
%08
x)'
%
(
data_type
,
address
)
for
vn
,
vi
in
zip
(
var_name
,
address_inc
):
for
vn
,
vi
in
zip
(
var_name
,
address_inc
):
s
+=
' + 0x
%
x *
%
s'
%
(
vi
,
vn
.
lower
())
s
+=
' + 0x
%
x *
%
s'
%
(
vi
,
vn
.
lower
())
s
+=
")"
else
:
else
:
s
+=
'return (
%
s) readl(0x
%08
x + 0x
%
x *
%
s)'
%
(
data_type
,
address
,
address_inc
,
arg
)
s
+=
' + 0x
%
x *
%
s'
%
(
address_inc
,
arg
)
s
+=
')'
# s+='return (%s) readl(0x%08x + 0x%x * %s)'%(data_type, address, address_inc, arg)
else
:
else
:
s
+=
'return (
%
s) readl(0x
%08
x)'
%
(
data_type
,
address
)
s
+=
'0x
%08
x'
%
(
address
)
s
+=
';}'
# s+='return (%s) readl(0x%08x)'%(data_type, address)
s
+=
'); return d; }'
else
:
else
:
s
+=
';'
s
+=
';'
if
comment
:
if
comment
:
...
@@ -1312,6 +1298,7 @@ class X393ExportC(object):
...
@@ -1312,6 +1298,7 @@ class X393ExportC(object):
stops
=
frmt_spcs
[(
'declare'
,
'define'
)[
isDefine
]]
stops
=
frmt_spcs
[(
'declare'
,
'define'
)[
isDefine
]]
#TODO: add optional argument range check?
#TODO: add optional argument range check?
data_type
=
self
.
fix_data_type
(
data_type
)
data_type
=
self
.
fix_data_type
(
data_type
)
# self.typedefs['u32']= {'comment':'unsigned 32-bit', 'code':'', 'size':32, 'type':''}
sz
=
self
.
typedefs
[
data_type
][
'size'
]
# check it exists
sz
=
self
.
typedefs
[
data_type
][
'size'
]
# check it exists
if
(
sz
>
32
):
if
(
sz
>
32
):
print
(
"***** Only 32-bit data is supported,
%
s used for
%
s is
%
d bit"
%
(
data_type
,
name
,
sz
))
print
(
"***** Only 32-bit data is supported,
%
s used for
%
s is
%
d bit"
%
(
data_type
,
name
,
sz
))
...
@@ -1333,18 +1320,22 @@ class X393ExportC(object):
...
@@ -1333,18 +1320,22 @@ class X393ExportC(object):
s
+=
"(
%
s)"
%
(
args
)
s
+=
"(
%
s)"
%
(
args
)
s
=
self
.
str_tab_stop
(
s
,
stops
[
2
])
s
=
self
.
str_tab_stop
(
s
,
stops
[
2
])
if
isDefine
:
if
isDefine
:
s
+=
'{'
if
self
.
typedefs
[
data_type
][
'code'
]:
# not just u32
td
=
'd.
%
s'
%
(
frmt_spcs
[
'data32'
])
else
:
td
=
'd'
s
+=
'{writel(
%
s, (void *) '
%
(
td
)
if
address_inc
:
if
address_inc
:
s
+=
'(0x
%08
x'
%
(
address
)
if
multivar
:
if
multivar
:
s
+=
'writel(0x
%08
x'
%
(
address
)
for
vn
,
vi
in
zip
(
var_name
,
address_inc
):
for
vn
,
vi
in
zip
(
var_name
,
address_inc
):
s
+=
' + 0x
%
x *
%
s'
%
(
vi
,
vn
.
lower
())
s
+=
' + 0x
%
x *
%
s'
%
(
vi
,
vn
.
lower
())
s
+=
', (u32) d)'
else
:
else
:
s
+=
'writel(0x
%08
x + 0x
%
x *
%
s, (u32) d)'
%
(
address
,
address_inc
,
arg
)
s
+=
' + 0x
%
x *
%
s'
%
(
address_inc
,
arg
)
s
+=
')'
else
:
else
:
s
+=
'
writel(0x
%08
x, (u32) d)
'
%
(
address
)
s
+=
'
0x
%08
x
'
%
(
address
)
s
+=
';}'
s
+=
'
)
;}'
else
:
else
:
s
+=
';'
s
+=
';'
if
comment
:
if
comment
:
...
@@ -1378,18 +1369,19 @@ class X393ExportC(object):
...
@@ -1378,18 +1369,19 @@ class X393ExportC(object):
s
+=
"(
%
s)"
%
(
args
)
s
+=
"(
%
s)"
%
(
args
)
s
=
self
.
str_tab_stop
(
s
,
stops
[
2
])
s
=
self
.
str_tab_stop
(
s
,
stops
[
2
])
if
isDefine
:
if
isDefine
:
s
+=
'{'
# s+='{'
s
+=
'{writel(0, (void *) '
if
address_inc
:
if
address_inc
:
s
+=
'(0x
%08
x'
%
(
address
)
if
multivar
:
if
multivar
:
s
+=
'writel(0x
%08
x'
%
(
address
)
for
vn
,
vi
in
zip
(
var_name
,
address_inc
):
for
vn
,
vi
in
zip
(
var_name
,
address_inc
):
s
+=
' + 0x
%
x *
%
s'
%
(
vi
,
vn
.
lower
())
s
+=
' + 0x
%
x *
%
s'
%
(
vi
,
vn
.
lower
())
s
+=
', 0)'
else
:
else
:
s
+=
'writel(0x
%08
x + 0x
%
x *
%
s, 0)'
%
(
address
,
address_inc
,
arg
)
s
+=
' + 0x
%
x *
%
s'
%
(
address_inc
,
arg
)
s
+=
')'
else
:
else
:
s
+=
'
writel(0x
%08
x, 0)
'
%
(
address
)
s
+=
'
0x
%08
x
'
%
(
address
)
s
+=
';}'
s
+=
'
)
;}'
else
:
else
:
s
+=
';'
s
+=
';'
if
comment
:
if
comment
:
...
@@ -2274,7 +2266,7 @@ class X393ExportC(object):
...
@@ -2274,7 +2266,7 @@ class X393ExportC(object):
return
dw
return
dw
def
_enc_logger_data
(
self
):
def
_enc_logger_data
(
self
):
dw
=
[]
dw
=
[]
dw
.
append
((
"data
32"
,
0
,
32
,
0
,
"Other logger register data (context-dependent)"
))
dw
.
append
((
"data
"
,
0
,
32
,
0
,
"Other logger register data (context-dependent)"
))
return
dw
return
dw
def
_enc_mult_saxi_addr
(
self
):
def
_enc_mult_saxi_addr
(
self
):
...
@@ -2342,8 +2334,15 @@ class X393ExportC(object):
...
@@ -2342,8 +2334,15 @@ class X393ExportC(object):
"""
"""
TODO: add alternative to bit fields
TODO: add alternative to bit fields
"""
"""
isUnion
=
isinstance
(
data
[
0
],
list
)
frmt_spcs
=
self
.
fix_frmt_spcs
(
frmt_spcs
)
frmt_spcs
=
self
.
fix_frmt_spcs
(
frmt_spcs
)
# print("data=",data)
# print("1.data[0]=",data[0])
if
frmt_spcs
[
'data32'
]:
if
not
isinstance
(
data
[
0
],
list
):
data
=
[
data
]
data
.
append
([(
frmt_spcs
[
'data32'
],
0
,
32
,
0
,
"cast to "
+
frmt_spcs
[
'ftype'
])])
isUnion
=
isinstance
(
data
[
0
],
list
)
# print("2.data[0]=",data[0])
s
=
""
s
=
""
# s = "\n"
# s = "\n"
# if comment:
# if comment:
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment