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
09dffd4c
Commit
09dffd4c
authored
Aug 17, 2012
by
Henrik Nordstrom
Browse files
bootinfo: Prefix output with offset
parent
d4a8dd80
Changes
1
Hide whitespace changes
Inline
Side-by-side
bootinfo.c
View file @
09dffd4c
...
...
@@ -23,6 +23,7 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <stdarg.h>
#include "types.h"
...
...
@@ -94,7 +95,7 @@ typedef struct _boot0_private_head_t {
__s32
enable_jtag
;
normal_gpio_cfg
jtag_gpio
[
5
];
normal_gpio_cfg
storage_gpio
[
32
];
char
storage_data
[
256
];
__u8
storage_data
[
256
];
}
boot0_private_head_t
;
typedef
struct
_boot0_file_head_t
{
...
...
@@ -146,54 +147,70 @@ typedef struct _boot_sdcard_info_t {
#define BOOT0_MAGIC "eGON.BT0"
#define BOOT1_MAGIC "eGON.BT1"
union
{
boot_file_head_t
boot
;
boot0_file_head_t
boot0
;
boot1_file_head_t
boot1
;
brom_file_head_t
brom
;
}
boot_hdr
;
void
fail
(
char
*
msg
)
{
perror
(
msg
);
exit
(
1
);
}
void
pprintf
(
void
*
addr
,
const
char
*
fmt
,
...)
{
va_list
ap
;
va_start
(
ap
,
fmt
);
printf
(
"%8x:
\t
"
,
(
unsigned
)((
char
*
)
addr
-
(
char
*
)
&
boot_hdr
));
vprintf
(
fmt
,
ap
);
va_end
(
ap
);
}
void
print_brom_file_head
(
brom_file_head_t
*
hdr
)
{
printf
(
"Magic : %.8s
\n
"
,
hdr
->
magic
);
printf
(
"Length : %u
\n
"
,
hdr
->
length
);
printf
(
"BOOT ver : %.4s
\n
"
,
hdr
->
Boot_vsn
);
printf
(
"eGON ver : %.4s
\n
"
,
hdr
->
eGON_vsn
);
printf
(
"Chip? : %.8s
\n
"
,
hdr
->
platform
);
p
printf
(
&
hdr
->
magic
,
"Magic : %.8s
\n
"
,
hdr
->
magic
);
p
printf
(
&
hdr
->
length
,
"Length : %u
\n
"
,
hdr
->
length
);
p
printf
(
&
hdr
->
Boot_vsn
,
"BOOT ver : %.4s
\n
"
,
hdr
->
Boot_vsn
);
p
printf
(
&
hdr
->
eGON_vsn
,
"eGON ver : %.4s
\n
"
,
hdr
->
eGON_vsn
);
p
printf
(
&
hdr
->
platform
,
"Chip? : %.8s
\n
"
,
hdr
->
platform
);
}
void
print_boot_file_head
(
boot_file_head_t
*
hdr
)
{
printf
(
"Magic : %.8s
\n
"
,
hdr
->
magic
);
printf
(
"Length : %u
\n
"
,
hdr
->
length
);
printf
(
"HSize : %u
\n
"
,
hdr
->
pub_head_size
);
printf
(
"HEAD ver : %.4s
\n
"
,
hdr
->
pub_head_vsn
);
printf
(
"FILE ver : %.4s
\n
"
,
hdr
->
file_head_vsn
);
printf
(
"BOOT ver : %.4s
\n
"
,
hdr
->
Boot_vsn
);
printf
(
"eGON ver : %.4s
\n
"
,
hdr
->
eGON_vsn
);
printf
(
"platform : %c%c%c%c%c%c%c%c
\n
"
,
hdr
->
platform
[
0
],
hdr
->
platform
[
1
],
hdr
->
platform
[
2
],
hdr
->
platform
[
3
],
hdr
->
platform
[
4
],
hdr
->
platform
[
5
],
hdr
->
platform
[
6
],
hdr
->
platform
[
7
]);
p
printf
(
&
hdr
->
magic
,
"Magic : %.8s
\n
"
,
hdr
->
magic
);
p
printf
(
&
hdr
->
length
,
"Length : %u
\n
"
,
hdr
->
length
);
p
printf
(
&
hdr
->
pub_head_size
,
"HSize : %u
\n
"
,
hdr
->
pub_head_size
);
p
printf
(
&
hdr
->
pub_head_vsn
,
"HEAD ver : %.4s
\n
"
,
hdr
->
pub_head_vsn
);
p
printf
(
&
hdr
->
file_head_vsn
,
"FILE ver : %.4s
\n
"
,
hdr
->
file_head_vsn
);
p
printf
(
&
hdr
->
Boot_vsn
,
"BOOT ver : %.4s
\n
"
,
hdr
->
Boot_vsn
);
p
printf
(
&
hdr
->
eGON_vsn
,
"eGON ver : %.4s
\n
"
,
hdr
->
eGON_vsn
);
p
printf
(
&
hdr
->
platform
,
"platform : %c%c%c%c%c%c%c%c
\n
"
,
hdr
->
platform
[
0
],
hdr
->
platform
[
1
],
hdr
->
platform
[
2
],
hdr
->
platform
[
3
],
hdr
->
platform
[
4
],
hdr
->
platform
[
5
],
hdr
->
platform
[
6
],
hdr
->
platform
[
7
]);
}
void
print_boot_dram_para
(
boot_dram_para_t
*
dram
)
{
printf
(
"DRAM base : %p
\n
"
,
(
void
*
)(
long
)
dram
->
dram_baseaddr
);
printf
(
"DRAM clk : %d
\n
"
,
dram
->
dram_clk
);
printf
(
"DRAM type : %d
\n
"
,
dram
->
dram_type
);
printf
(
"DRAM rank : %d
\n
"
,
dram
->
dram_rank_num
);
printf
(
"DRAM den : %d
\n
"
,
dram
->
dram_chip_density
);
printf
(
"DRAM iow : %d
\n
"
,
dram
->
dram_io_width
);
printf
(
"DRAM busw : %d
\n
"
,
dram
->
dram_bus_width
);
printf
(
"DRAM cas : %d
\n
"
,
dram
->
dram_cas
);
printf
(
"DRAM zq : %d
\n
"
,
dram
->
dram_zq
);
printf
(
"DRAM odt : 0x%x
\n
"
,
dram
->
dram_odt_en
);
printf
(
"DRAM size : %d
\n
"
,
dram
->
dram_size
);
printf
(
"DRAM tpr0 : 0x%x
\n
"
,
dram
->
dram_tpr0
);
printf
(
"DRAM tpr1 : 0x%x
\n
"
,
dram
->
dram_tpr1
);
printf
(
"DRAM tpr2 : 0x%x
\n
"
,
dram
->
dram_tpr2
);
printf
(
"DRAM tpr3 : 0x%x
\n
"
,
dram
->
dram_tpr3
);
printf
(
"DRAM tpr4 : 0x%x
\n
"
,
dram
->
dram_tpr4
);
printf
(
"DRAM tpr5 : 0x%x
\n
"
,
dram
->
dram_tpr5
);
printf
(
"DRAM emr1 : 0x%x
\n
"
,
dram
->
dram_emr1
);
printf
(
"DRAM emr2 : 0x%x
\n
"
,
dram
->
dram_emr2
);
printf
(
"DRAM emr3 : 0x%x
\n
"
,
dram
->
dram_emr3
);
p
printf
(
&
dram
->
dram_baseaddr
,
"DRAM base : %p
\n
"
,
(
void
*
)(
long
)
dram
->
dram_baseaddr
);
p
printf
(
&
dram
->
dram_clk
,
"DRAM clk : %d
\n
"
,
dram
->
dram_clk
);
p
printf
(
&
dram
->
dram_type
,
"DRAM type : %d
\n
"
,
dram
->
dram_type
);
p
printf
(
&
dram
->
dram_rank_num
,
"DRAM rank : %d
\n
"
,
dram
->
dram_rank_num
);
p
printf
(
&
dram
->
dram_chip_density
,
"DRAM den : %d
\n
"
,
dram
->
dram_chip_density
);
p
printf
(
&
dram
->
dram_io_width
,
"DRAM iow : %d
\n
"
,
dram
->
dram_io_width
);
p
printf
(
&
dram
->
dram_bus_width
,
"DRAM busw : %d
\n
"
,
dram
->
dram_bus_width
);
p
printf
(
&
dram
->
dram_cas
,
"DRAM cas : %d
\n
"
,
dram
->
dram_cas
);
p
printf
(
&
dram
->
dram_zq
,
"DRAM zq : %d
\n
"
,
dram
->
dram_zq
);
p
printf
(
&
dram
->
dram_odt_en
,
"DRAM odt : 0x%x
\n
"
,
dram
->
dram_odt_en
);
p
printf
(
&
dram
->
dram_size
,
"DRAM size : %d
\n
"
,
dram
->
dram_size
);
p
printf
(
&
dram
->
dram_tpr0
,
"DRAM tpr0 : 0x%x
\n
"
,
dram
->
dram_tpr0
);
p
printf
(
&
dram
->
dram_tpr1
,
"DRAM tpr1 : 0x%x
\n
"
,
dram
->
dram_tpr1
);
p
printf
(
&
dram
->
dram_tpr2
,
"DRAM tpr2 : 0x%x
\n
"
,
dram
->
dram_tpr2
);
p
printf
(
&
dram
->
dram_tpr3
,
"DRAM tpr3 : 0x%x
\n
"
,
dram
->
dram_tpr3
);
p
printf
(
&
dram
->
dram_tpr4
,
"DRAM tpr4 : 0x%x
\n
"
,
dram
->
dram_tpr4
);
p
printf
(
&
dram
->
dram_tpr5
,
"DRAM tpr5 : 0x%x
\n
"
,
dram
->
dram_tpr5
);
p
printf
(
&
dram
->
dram_emr1
,
"DRAM emr1 : 0x%x
\n
"
,
dram
->
dram_emr1
);
p
printf
(
&
dram
->
dram_emr2
,
"DRAM emr2 : 0x%x
\n
"
,
dram
->
dram_emr2
);
p
printf
(
&
dram
->
dram_emr3
,
"DRAM emr3 : 0x%x
\n
"
,
dram
->
dram_emr3
);
}
void
print_normal_gpio_cfg
(
normal_gpio_cfg
*
gpio
,
int
count
)
...
...
@@ -201,19 +218,19 @@ void print_normal_gpio_cfg(normal_gpio_cfg *gpio, int count)
int
i
;
for
(
i
=
0
;
i
<
count
;
i
++
)
{
if
(
gpio
[
i
].
port
)
printf
(
" GPIO %d : port=%c%d, sel=%d, pull=%d, drv=%d, data=%d, reserved=%02x,%02x
\n
"
,
i
,
'A'
+
gpio
[
i
].
port
-
1
,
gpio
[
i
].
port_num
,
gpio
[
i
].
mul_sel
,
gpio
[
i
].
pull
,
gpio
[
i
].
drv_level
,
gpio
[
i
].
data
,
gpio
[
i
].
reserved
[
0
],
gpio
[
i
].
reserved
[
1
]);
p
printf
(
&
gpio
[
i
],
" GPIO %d : port=%c%d, sel=%d, pull=%d, drv=%d, data=%d, reserved=%02x,%02x
\n
"
,
i
,
'A'
+
gpio
[
i
].
port
-
1
,
gpio
[
i
].
port_num
,
gpio
[
i
].
mul_sel
,
gpio
[
i
].
pull
,
gpio
[
i
].
drv_level
,
gpio
[
i
].
data
,
gpio
[
i
].
reserved
[
0
],
gpio
[
i
].
reserved
[
1
]);
}
}
void
print_boot0_private_head
(
boot0_private_head_t
*
hdr
)
{
printf
(
"FHSize : %u
\n
"
,
hdr
->
prvt_head_size
);
printf
(
"FILE ver : %.4s
\n
"
,
hdr
->
prvt_head_vsn
);
p
printf
(
&
hdr
->
prvt_head_size
,
"FHSize : %u
\n
"
,
hdr
->
prvt_head_size
);
p
printf
(
&
hdr
->
prvt_head_vsn
,
"FILE ver : %.4s
\n
"
,
hdr
->
prvt_head_vsn
);
print_boot_dram_para
(
&
hdr
->
dram_para
);
printf
(
"UART port : %d
\n
"
,
hdr
->
uart_port
);
p
printf
(
&
hdr
->
uart_port
,
"UART port : %d
\n
"
,
hdr
->
uart_port
);
print_normal_gpio_cfg
(
hdr
->
uart_ctrl
,
2
);
printf
(
"JTAG en : %d
\n
"
,
hdr
->
enable_jtag
);
p
printf
(
&
hdr
->
enable_jtag
,
"JTAG en : %d
\n
"
,
hdr
->
enable_jtag
);
print_normal_gpio_cfg
(
hdr
->
jtag_gpio
,
5
);
printf
(
"STORAGE :
\n
"
);
p
printf
(
&
hdr
->
storage_gpio
,
"STORAGE :
\n
"
);
print_normal_gpio_cfg
(
hdr
->
storage_gpio
,
2
);
int
i
;
for
(
i
=
0
;
i
<
256
;
i
++
)
{
...
...
@@ -221,9 +238,9 @@ void print_boot0_private_head(boot0_private_head_t *hdr)
if
(
i
)
{
printf
(
"
\n
"
);
}
printf
(
" DATA %02x :"
,
i
);
p
printf
(
&
hdr
->
storage_data
[
i
],
" DATA %02x :"
,
i
);
}
printf
(
" %02x"
,
(
u8
)
hdr
->
storage_data
[
i
]);
printf
(
" %02x"
,
hdr
->
storage_data
[
i
]);
}
printf
(
"
\n
"
);
}
...
...
@@ -234,36 +251,36 @@ void print_script(void *script)
void
print_core_para
(
boot_core_para_t
*
core
)
{
printf
(
"Set Clock : %d
\n
"
,
core
->
user_set_clock
);
printf
(
"Set Core Vol: %d
\n
"
,
core
->
user_set_core_vol
);
printf
(
"Vol Threshold: %d
\n
"
,
core
->
vol_threshold
);
p
printf
(
&
core
->
user_set_clock
,
"Set Clock : %d
\n
"
,
core
->
user_set_clock
);
p
printf
(
&
core
->
user_set_core_vol
,
"Set Core Vol: %d
\n
"
,
core
->
user_set_core_vol
);
p
printf
(
&
core
->
vol_threshold
,
"Vol Threshold: %d
\n
"
,
core
->
vol_threshold
);
}
void
print_boot1_private_head
(
boot1_private_head_t
*
hdr
)
{
printf
(
"FHSize : %u
\n
"
,
hdr
->
prvt_head_size
);
printf
(
"FILE ver : %.4s
\n
"
,
hdr
->
prvt_head_vsn
);
printf
(
"UART port : %d
\n
"
,
hdr
->
uart_port
);
p
printf
(
&
hdr
->
prvt_head_size
,
"FHSize : %u
\n
"
,
hdr
->
prvt_head_size
);
p
printf
(
&
hdr
->
prvt_head_vsn
,
"FILE ver : %.4s
\n
"
,
hdr
->
prvt_head_vsn
);
p
printf
(
&
hdr
->
uart_port
,
"UART port : %d
\n
"
,
hdr
->
uart_port
);
print_normal_gpio_cfg
(
hdr
->
uart_ctrl
,
2
);
print_boot_dram_para
(
&
hdr
->
dram_para
);
print_script
(
&
hdr
->
script_buf
);
print_core_para
(
&
hdr
->
core_para
);
printf
(
"TWI port : %d
\n
"
,
hdr
->
twi_port
);
p
printf
(
&
hdr
->
twi_port
,
"TWI port : %d
\n
"
,
hdr
->
twi_port
);
print_normal_gpio_cfg
(
hdr
->
twi_ctrl
,
2
);
printf
(
"Debug : %d
\n
"
,
hdr
->
debug_enable
);
printf
(
"Hold key min : %d
\n
"
,
hdr
->
hold_key_min
);
printf
(
"Hold key max : %d
\n
"
,
hdr
->
hold_key_max
);
printf
(
"Work mode : %d
\n
"
,
hdr
->
work_mode
);
printf
(
"Storage : %d
\n
"
,
hdr
->
storage_type
);
p
printf
(
&
hdr
->
debug_enable
,
"Debug : %d
\n
"
,
hdr
->
debug_enable
);
p
printf
(
&
hdr
->
hold_key_min
,
"Hold key min : %d
\n
"
,
hdr
->
hold_key_min
);
p
printf
(
&
hdr
->
hold_key_max
,
"Hold key max : %d
\n
"
,
hdr
->
hold_key_max
);
p
printf
(
&
hdr
->
work_mode
,
"Work mode : %d
\n
"
,
hdr
->
work_mode
);
p
printf
(
&
hdr
->
storage_type
,
"Storage : %d
\n
"
,
hdr
->
storage_type
);
int
i
;
for
(
i
=
0
;
i
<
256
;
i
++
)
{
if
(
i
%
16
==
0
)
{
if
(
i
)
{
printf
(
"
\n
"
);
}
printf
(
" DATA %02x :"
,
i
);
p
printf
(
&
hdr
->
storage_data
[
i
],
" DATA %02x :"
,
i
);
}
printf
(
" %02x"
,
(
u8
)
hdr
->
storage_data
[
i
]);
printf
(
" %02x"
,
hdr
->
storage_data
[
i
]);
}
printf
(
"
\n
"
);
}
...
...
@@ -294,23 +311,17 @@ int main(int argc, char * argv[])
if
(
!
in
)
fail
(
"open input: "
);
}
union
{
boot_file_head_t
boot
;
boot0_file_head_t
boot0
;
boot1_file_head_t
boot1
;
brom_file_head_t
brom
;
}
hdr
;
int
len
;
len
=
fread
(
&
hdr
,
1
,
sizeof
(
hdr
),
in
);
len
=
fread
(
&
boot_
hdr
,
1
,
sizeof
(
boot_
hdr
),
in
);
if
(
len
<
(
int
)
sizeof
(
boot_file_head_t
))
fail
(
"Failed to read header:"
);
if
(
strncmp
((
char
*
)
hdr
.
boot
.
magic
,
BOOT0_MAGIC
,
strlen
(
BOOT0_MAGIC
))
==
0
)
{
print_boot0_file_head
(
&
hdr
.
boot0
);
}
else
if
(
strncmp
((
char
*
)
hdr
.
boot
.
magic
,
BOOT1_MAGIC
,
strlen
(
BOOT1_MAGIC
))
==
0
)
{
print_boot1_file_head
(
&
hdr
.
boot1
);
}
else
if
(
strncmp
((
char
*
)
hdr
.
boot
.
magic
,
BROM_MAGIC
,
strlen
(
BROM_MAGIC
))
==
0
)
{
print_brom_file_head
(
&
hdr
.
brom
);
if
(
strncmp
((
char
*
)
boot_
hdr
.
boot
.
magic
,
BOOT0_MAGIC
,
strlen
(
BOOT0_MAGIC
))
==
0
)
{
print_boot0_file_head
(
&
boot_
hdr
.
boot0
);
}
else
if
(
strncmp
((
char
*
)
boot_
hdr
.
boot
.
magic
,
BOOT1_MAGIC
,
strlen
(
BOOT1_MAGIC
))
==
0
)
{
print_boot1_file_head
(
&
boot_
hdr
.
boot1
);
}
else
if
(
strncmp
((
char
*
)
boot_
hdr
.
boot
.
magic
,
BROM_MAGIC
,
strlen
(
BROM_MAGIC
))
==
0
)
{
print_brom_file_head
(
&
boot_
hdr
.
brom
);
}
else
{
fail
(
"Invalid magic
\n
"
);
}
...
...
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