加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
qcdt_v3_motorola_athena.c 2.29 KB
一键复制 编辑 原始数据 按行查看 历史
Pat Erley 提交于 2016-07-28 13:29 . Add motorola v3 qcdt table parsing
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <stdint.h>
#include <stdbool.h>
#include "dtimgextract.h"
typedef struct {
uint32_t platform_id;
uint32_t variant_id;
uint32_t sec_rev;
uint32_t msm_id2;
uint32_t pmic1;
uint32_t pmic2;
uint32_t pmic3;
uint32_t pmic4;
uint32_t offset;
uint32_t len;
char something[30];
} dtb_entry_v3_moto;
void dump_files_v3_moto(FILE *fd, qca_head header, uint32_t headerat) {
int i;
dtb_entry_v3_moto *images = malloc(header.num * sizeof(dtb_entry_v3_moto));
printf("\nPid\tVid\tSrev\tmsm_id2\tpmic1\tpmic2\tpmic3\tpmic4\toffset\tlen\tsomething\n");
for ( i = 0; i < header.num ; i++ ){
fread(&images[i], sizeof(dtb_entry_v3_moto), 1, fd);
printf("%x\t%x\t%x\t%x\t%x\t%x\t%x\t%x\t%x\t%x\t%s\n",
images[i].platform_id, images[i].variant_id,
images[i].sec_rev, images[i].msm_id2,
images[i].pmic1, images[i].pmic2,
images[i].pmic3, images[i].pmic4,
images[i].offset, images[i].len, images[i].something);
printf(" qcom,msm-id=<0x%x 0x%x>;\n",images[i].platform_id, images[i].msm_id2);
printf(" qcom,pmic-id=<0x%x 0x%x 0x%x 0x%x>;\n", images[i].pmic1, images[i].pmic2, images[i].pmic3, images[i].pmic4);
printf(" qcom,board-id=<0x%x 0x%x>;\n", images[i].variant_id, images[i].sec_rev);
}
printf("\n");
fseek(fd, headerat, SEEK_SET);
for ( i = 0; i < header.num; i++ ){
char dtbname[256];
char *dtb;
FILE *out_fd = NULL;
sprintf(dtbname, "%x_%x_%x_%x.dtb", images[i].platform_id, images[i].variant_id,
images[i].sec_rev, images[i].msm_id2);
printf("Writing %s(%x bytes)\n", dtbname, images[i].len);
dtb = malloc(images[i].len);
fseek(fd, images[i].offset + headerat, SEEK_SET);
fread(dtb, images[i].len, 1, fd);
out_fd = fopen(dtbname, "wb");
fwrite(dtb, images[i].len, 1, out_fd);
free(dtb);
fclose(out_fd);
}
free(images);
}
dt_parser v3_parser_moto = {
.dt_file_dumper = &dump_files_v3_moto,
.version = 259,
.extended = 1,
};
int __attribute__((constructor)) register_v3_parser_moto(void) {
add_dt_parser(&v3_parser_moto);
return 0;
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化