mirror of
https://github.com/linux-msm/qdl.git
synced 2026-02-25 13:12:25 -08:00
It is possible for a device to request multiple images over the sahara protocol. When the device issues the done response packet, the status field indicates if the device expects to request additional images. If so, the protocol goes back to the start and exchanges hello messages again. Also, some images may be optional. The device may be able to proceed if the host is unable to satisfy the request. To support this, we need several changes. First, we need to use the done response packet status field to decide if we are done with sahara instead of assuming that based on having transfered a single image. Second, we need to reference the image id that the device is requesting and operate on the correct file. This is a field in the read data packet. Since the device could request more than one image, we need a mapping of ids to files. Since different devices could have different mappings, abstract this mapping into the qdl struct. When we get a read request from the device, we need to open the correct file, seek to the required offset, and provide the requested segment. The implementation for this chooses simplicity over performance by avoiding the need to maintain state of what image is currently requested, and if that has been accessed before, thus we have an open fd to use which needs to be cleaned up later. Since the qdl struct is larger with the mapping table, move it off the stack and instead make it a static global. We expect to only need one instance of it, and this gives us the benifit of zero initializing the struct for free. We also move the qdl struct definition into the qdl header so that it can be shared with a similar implementation in a future development. Signed-off-by: Jeffrey Hugo <quic_jhugo@quicinc.com>
36 lines
909 B
C
36 lines
909 B
C
#ifndef __QDL_H__
|
|
#define __QDL_H__
|
|
|
|
#include <stdbool.h>
|
|
|
|
#include "patch.h"
|
|
#include "program.h"
|
|
#include <libxml/tree.h>
|
|
|
|
#define MAPPING_SZ 64
|
|
|
|
struct qdl_device {
|
|
int fd;
|
|
|
|
int in_ep;
|
|
int out_ep;
|
|
|
|
size_t in_maxpktsize;
|
|
size_t out_maxpktsize;
|
|
|
|
char *mappings[MAPPING_SZ]; // array index is the id from the device
|
|
};
|
|
|
|
int qdl_read(struct qdl_device *qdl, void *buf, size_t len, unsigned int timeout);
|
|
int qdl_write(struct qdl_device *qdl, const void *buf, size_t len);
|
|
|
|
int firehose_run(struct qdl_device *qdl, const char *incdir, const char *storage);
|
|
int sahara_run(struct qdl_device *qdl, char *img_arr[]);
|
|
void print_hex_dump(const char *prefix, const void *buf, size_t len);
|
|
unsigned attr_as_unsigned(xmlNode *node, const char *attr, int *errors);
|
|
const char *attr_as_string(xmlNode *node, const char *attr, int *errors);
|
|
|
|
extern bool qdl_debug;
|
|
|
|
#endif
|