Files
qdl/firehose.h
T
Igor Opaniuk 7a7e02aac8 firehose: carry sha256 digest in op; print from qdl.c
firehose.c is the firehose protocol layer; deciding what to do with a
digest (print it for the user, compare it to a locally-computed one)
is qdl policy. Move the result back onto struct firehose_op so the
parser can fill it directly, drop the local intermediate result struct,
and let firehose_run() return without emitting anything to stdout.

For the `sha256` subcommand, format and print each filled digest in
qdl_flash() once firehose_run() succeeds. The visible output for the
subcommand is unchanged.

Signed-off-by: Igor Opaniuk <igor.opaniuk@oss.qualcomm.com>
2026-05-16 16:35:15 -05:00

72 lines
1.3 KiB
C

/* SPDX-License-Identifier: BSD-3-Clause */
#ifndef __FIREHOSE_H__
#define __FIREHOSE_H__
#include <stdbool.h>
#include <stdint.h>
#include <sys/stat.h>
#include "list.h"
#include "qdl.h"
#include "sha2.h"
enum firehose_op_type {
FIREHOSE_OP_NONE,
FIREHOSE_OP_CONFIGURE,
FIREHOSE_OP_PROGRAM,
FIREHOSE_OP_ERASE,
FIREHOSE_OP_READ,
FIREHOSE_OP_PATCH,
FIREHOSE_OP_SET_BOOTABLE,
FIREHOSE_OP_RESET,
FIREHOSE_OP_GET_SHA256_DIGEST,
};
struct firehose_op {
enum firehose_op_type type;
struct list_head node;
/* program, read, patch, set_bootable */
int partition;
/* program, read, patch */
unsigned int sector_size;
struct qdl_zip *zip;
const char *filename;
const char *start_sector;
/* program, read */
unsigned int num_sectors;
const char *gpt_partition;
/* program, erase */
unsigned int pages_per_block;
unsigned int file_offset;
const char *label;
bool sparse;
unsigned int last_sector;
bool is_nand;
unsigned int sparse_chunk_type;
uint32_t sparse_fill_value;
off_t sparse_offset;
/* patch */
unsigned int byte_offset;
unsigned int size_in_bytes;
const char *value;
const char *what;
/* configure */
enum qdl_storage_type storage_type;
/* getsha256digest */
uint8_t digest[SHA256_DIGEST_LENGTH];
bool digest_valid;
};
struct firehose_op *firehose_alloc_op(int type);
void firehose_free_ops(struct list_head *ops);
#endif