Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Menu
Open sidebar
adam.huang
Sunxi Tools
Commits
2534af5d
Commit
2534af5d
authored
Sep 29, 2012
by
Alejandro Mery
Browse files
fexc: change uboot output to generate a .c
parent
987a169b
Changes
1
Hide whitespace changes
Inline
Side-by-side
script_uboot.c
View file @
2534af5d
...
...
@@ -32,11 +32,10 @@
#define pr_debug(...)
#endif
static
inline
void
out_
dram
_member
(
FILE
*
out
,
const
char
*
key
,
uint32_t
val
)
static
inline
void
out_
u32
_member
(
FILE
*
out
,
const
char
*
key
,
int
hexa
,
uint32_t
val
)
{
const
char
*
fmt
;
if
(
strncmp
(
key
,
"tpr"
,
3
)
==
0
||
strncmp
(
key
,
"emr"
,
3
)
==
0
)
if
(
hexa
)
fmt
=
"
\t
.%s = %#x,
\n
"
;
else
fmt
=
"
\t
.%s = %u,
\n
"
;
...
...
@@ -44,15 +43,18 @@ static inline void out_dram_member(FILE *out, const char *key, uint32_t val)
fprintf
(
out
,
fmt
,
key
,
val
);
}
/*
* DRAM
*/
static
int
generate_dram_struct
(
FILE
*
out
,
struct
script_section
*
sp
)
{
struct
list_entry
*
le
;
struct
script_entry
*
ep
;
struct
script_single_entry
*
val
;
const
char
*
key
;
int
ret
=
1
;
int
ret
=
1
,
hexa
;
fprintf
(
out
,
"struct dram_para para = {
\n
"
);
fprintf
(
out
,
"
static
struct dram_para
dram_
para = {
\n
"
);
for
(
le
=
list_first
(
&
sp
->
entries
);
le
;
le
=
list_next
(
&
sp
->
entries
,
le
))
{
ep
=
container_of
(
le
,
struct
script_entry
,
entries
);
...
...
@@ -68,11 +70,17 @@ static int generate_dram_struct(FILE *out, struct script_section *sp)
else
if
(
strcmp
(
key
,
"clk"
)
==
0
)
key
=
"clock"
;
if
(
strncmp
(
key
,
"tpr"
,
3
)
==
0
||
strncmp
(
key
,
"emr"
,
3
)
==
0
)
hexa
=
1
;
else
hexa
=
0
;
switch
(
ep
->
type
)
{
case
SCRIPT_VALUE_TYPE_SINGLE_WORD
:
val
=
container_of
(
ep
,
struct
script_single_entry
,
entry
);
if
(
val
->
value
>
0
)
out_
dram
_member
(
out
,
key
,
val
->
value
);
out_
u32
_member
(
out
,
key
,
hexa
,
val
->
value
);
/* pass through */
case
SCRIPT_VALUE_TYPE_NULL
:
continue
;
...
...
@@ -93,7 +101,10 @@ int script_generate_uboot(FILE *out, const char *UNUSED(filename),
struct
script_section
*
section
;
const
char
*
section_name
;
fprintf
(
out
,
"/* this file is generated, don't edit it yourself */
\n\n
"
);
fputs
(
"/* this file is generated, don't edit it yourself */
\n\n
"
"#include <common.h>
\n
"
"#include <asm/arch/dram.h>
\n\n
"
,
out
);
section_name
=
"dram_para"
;
section
=
script_find_section
(
script
,
section_name
);
...
...
@@ -101,6 +112,10 @@ int script_generate_uboot(FILE *out, const char *UNUSED(filename),
goto
missing_section
;
generate_dram_struct
(
out
,
section
);
fputs
(
"
\n
int sunxi_dram_init(void)
\n
"
"{
\n\t
return DRAMC_init(&dram_para);
\n
}
\n
"
,
out
);
return
1
;
missing_section:
pr_err
(
"%s: critical section missing"
,
section_name
);
...
...
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