Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/linux-sunxi/sunxi-tools.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHenrik Nordstrom <henrik@henriknordstrom.net>2012-08-18 00:43:56 +0400
committerHenrik Nordstrom <henrik@henriknordstrom.net>2012-08-18 00:43:56 +0400
commit09dffd4cdb2ae5715bd06920f283352ec3e9e524 (patch)
treebd5be3a0e499dda53fc00429775e9b9747dda13c /bootinfo.c
parentd4a8dd80b8c665e790a254028119710a494af2b5 (diff)
bootinfo: Prefix output with offset
Diffstat (limited to 'bootinfo.c')
-rw-r--r--bootinfo.c149
1 files changed, 80 insertions, 69 deletions
diff --git a/bootinfo.c b/bootinfo.c
index 48baad7..9a51c38 100644
--- a/bootinfo.c
+++ b/bootinfo.c
@@ -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);
+ pprintf(&hdr->magic, "Magic : %.8s\n", hdr->magic);
+ pprintf(&hdr->length, "Length : %u\n", hdr->length);
+ pprintf(&hdr->Boot_vsn, "BOOT ver : %.4s\n", hdr->Boot_vsn);
+ pprintf(&hdr->eGON_vsn, "eGON ver : %.4s\n", hdr->eGON_vsn);
+ pprintf(&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]);
+ pprintf(&hdr->magic, "Magic : %.8s\n", hdr->magic);
+ pprintf(&hdr->length, "Length : %u\n", hdr->length);
+ pprintf(&hdr->pub_head_size, "HSize : %u\n", hdr->pub_head_size);
+ pprintf(&hdr->pub_head_vsn, "HEAD ver : %.4s\n", hdr->pub_head_vsn);
+ pprintf(&hdr->file_head_vsn, "FILE ver : %.4s\n", hdr->file_head_vsn);
+ pprintf(&hdr->Boot_vsn, "BOOT ver : %.4s\n", hdr->Boot_vsn);
+ pprintf(&hdr->eGON_vsn, "eGON ver : %.4s\n", hdr->eGON_vsn);
+ pprintf(&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);
+ pprintf(&dram->dram_baseaddr, "DRAM base : %p\n", (void *)(long)dram->dram_baseaddr);
+ pprintf(&dram->dram_clk, "DRAM clk : %d\n", dram->dram_clk);
+ pprintf(&dram->dram_type, "DRAM type : %d\n", dram->dram_type);
+ pprintf(&dram->dram_rank_num, "DRAM rank : %d\n", dram->dram_rank_num);
+ pprintf(&dram->dram_chip_density,"DRAM den : %d\n", dram->dram_chip_density);
+ pprintf(&dram->dram_io_width, "DRAM iow : %d\n", dram->dram_io_width);
+ pprintf(&dram->dram_bus_width, "DRAM busw : %d\n", dram->dram_bus_width);
+ pprintf(&dram->dram_cas, "DRAM cas : %d\n", dram->dram_cas);
+ pprintf(&dram->dram_zq, "DRAM zq : %d\n", dram->dram_zq);
+ pprintf(&dram->dram_odt_en, "DRAM odt : 0x%x\n", dram->dram_odt_en);
+ pprintf(&dram->dram_size, "DRAM size : %d\n", dram->dram_size);
+ pprintf(&dram->dram_tpr0, "DRAM tpr0 : 0x%x\n", dram->dram_tpr0);
+ pprintf(&dram->dram_tpr1, "DRAM tpr1 : 0x%x\n", dram->dram_tpr1);
+ pprintf(&dram->dram_tpr2, "DRAM tpr2 : 0x%x\n", dram->dram_tpr2);
+ pprintf(&dram->dram_tpr3, "DRAM tpr3 : 0x%x\n", dram->dram_tpr3);
+ pprintf(&dram->dram_tpr4, "DRAM tpr4 : 0x%x\n", dram->dram_tpr4);
+ pprintf(&dram->dram_tpr5, "DRAM tpr5 : 0x%x\n", dram->dram_tpr5);
+ pprintf(&dram->dram_emr1, "DRAM emr1 : 0x%x\n", dram->dram_emr1);
+ pprintf(&dram->dram_emr2, "DRAM emr2 : 0x%x\n", dram->dram_emr2);
+ pprintf(&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]);
+ pprintf(&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);
+ pprintf(&hdr->prvt_head_size, "FHSize : %u\n", hdr->prvt_head_size);
+ pprintf(&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);
+ pprintf(&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);
+ pprintf(&hdr->enable_jtag, "JTAG en : %d\n", hdr->enable_jtag);
print_normal_gpio_cfg(hdr->jtag_gpio, 5);
- printf("STORAGE :\n");
+ pprintf(&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);
+ pprintf(&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);
+ pprintf(&core->user_set_clock, "Set Clock : %d\n", core->user_set_clock);
+ pprintf(&core->user_set_core_vol, "Set Core Vol: %d\n", core->user_set_core_vol);
+ pprintf(&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);
+ pprintf(&hdr->prvt_head_size, "FHSize : %u\n", hdr->prvt_head_size);
+ pprintf(&hdr->prvt_head_vsn, "FILE ver : %.4s\n", hdr->prvt_head_vsn);
+ pprintf(&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);
+ pprintf(&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);
+ pprintf(&hdr->debug_enable, "Debug : %d\n", hdr->debug_enable);
+ pprintf(&hdr->hold_key_min, "Hold key min : %d\n", hdr->hold_key_min);
+ pprintf(&hdr->hold_key_max, "Hold key max : %d\n", hdr->hold_key_max);
+ pprintf(&hdr->work_mode, "Work mode : %d\n", hdr->work_mode);
+ pprintf(&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);
+ pprintf(&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");
}