Files
qdl/program.h
Bjorn Andersson 739b1ad4db sparse: Handle larger-than-32bit sparse images
When the sparse image parser finds a RAW chunk, it queries the current
file offset in the sparse image and store this for the programming
phase. But the offset is stored in a 32-bit unsigned int, so when the
sparse image passes 4GB the program entries start to refer to the wrong
data.

Split the fill_value and offset into dedicated fields and give them both
their specific type, to avoid any confusion related to the size of these
data types.

Fixes: 02c008adfd ("add support sparse attribute")
Signed-off-by: Bjorn Andersson <bjorn.andersson@oss.qualcomm.com>
2025-08-28 10:42:08 -05:00

42 lines
1.0 KiB
C

/* SPDX-License-Identifier: BSD-3-Clause */
#ifndef __PROGRAM_H__
#define __PROGRAM_H__
#include <sys/types.h>
#include <stdbool.h>
#include <stdint.h>
#include "qdl.h"
struct program {
unsigned int pages_per_block;
unsigned int sector_size;
unsigned int file_offset;
const char *filename;
const char *label;
unsigned int num_sectors;
unsigned int partition;
bool sparse;
const char *start_sector;
unsigned int last_sector;
bool is_nand;
bool is_erase;
unsigned int sparse_chunk_type;
uint32_t sparse_fill_value;
off_t sparse_offset;
struct program *next;
};
int program_load(const char *program_file, bool is_nand);
int program_execute(struct qdl_device *qdl, int (*apply)(struct qdl_device *qdl, struct program *program, int fd),
const char *incdir, bool allow_missing);
int erase_execute(struct qdl_device *qdl, int (*apply)(struct qdl_device *qdl, struct program *program));
int program_find_bootable_partition(bool *multiple_found);
int program_is_sec_partition_flashed(void);
void free_programs(void);
#endif