Commit 23c1a1da authored by topjohnwu's avatar topjohnwu

Some code reorganizing

parent f5d054b9
This diff is collapsed.
...@@ -192,6 +192,10 @@ struct dyn_img_hdr { ...@@ -192,6 +192,10 @@ struct dyn_img_hdr {
return img_hdr; return img_hdr;
} }
void print();
void dump_hdr_file();
void load_hdr_file();
protected: protected:
union { union {
/* Main header could be either AOSP or PXA, /* Main header could be either AOSP or PXA,
...@@ -298,11 +302,11 @@ struct boot_img { ...@@ -298,11 +302,11 @@ struct boot_img {
uint8_t *map_addr; uint8_t *map_addr;
size_t map_size; size_t map_size;
// Headers // Android image header
dyn_img_hdr *hdr; /* Android image header */ dyn_img_hdr *hdr;
// Flags to indicate the state of current boot image // Flags to indicate the state of current boot image
uint16_t flags; uint16_t flags = 0;
// The format of kernel and ramdisk // The format of kernel and ramdisk
format_t k_fmt; format_t k_fmt;
...@@ -312,16 +316,17 @@ struct boot_img { ...@@ -312,16 +316,17 @@ struct boot_img {
* Following pointers points within the mmap region * Following pointers points within the mmap region
***************************************************/ ***************************************************/
mtk_hdr *k_hdr; /* MTK kernel header */ // MTK headers
mtk_hdr *r_hdr; /* MTK ramdisk header */ mtk_hdr *k_hdr;
mtk_hdr *r_hdr;
// Pointer to dtb that is appended after kernel // Pointer to dtb that is appended after kernel
uint8_t *kernel_dtb; uint8_t *kernel_dtb;
uint32_t kernel_dt_size; uint32_t kernel_dt_size = 0;
// Pointer to end of image // Pointer to end of image
uint8_t *tail; uint8_t *tail;
size_t tail_size; size_t tail_size = 0;
// Pointers to blocks defined in header // Pointers to blocks defined in header
uint8_t *img_start; uint8_t *img_start;
...@@ -332,10 +337,9 @@ struct boot_img { ...@@ -332,10 +337,9 @@ struct boot_img {
uint8_t *recovery_dtbo; uint8_t *recovery_dtbo;
uint8_t *dtb; uint8_t *dtb;
boot_img(const char *);
~boot_img(); ~boot_img();
void parse_file(const char *);
void parse_image(uint8_t *addr); void parse_image(uint8_t *addr);
void find_kernel_dtb(); void find_kernel_dtb();
void print_hdr();
}; };
...@@ -13,7 +13,7 @@ ...@@ -13,7 +13,7 @@
#define NEW_BOOT "new-boot.img" #define NEW_BOOT "new-boot.img"
int unpack(const char *image, bool hdr = false); int unpack(const char *image, bool hdr = false);
void repack(const char* orig_image, const char* out_image, bool nocomp = false); void repack(const char* src_img, const char* out_img, bool nocomp = false);
int hexpatch(const char *image, const char *from, const char *to); int hexpatch(const char *image, const char *from, const char *to);
int cpio_commands(int argc, char *argv[]); int cpio_commands(int argc, char *argv[]);
int dtb_commands(int argc, char *argv[]); int dtb_commands(int argc, char *argv[]);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment