blob: 29f7a08f6728f09f56246136ca02cc496a89af0a [file] [log] [blame]
Patrick Delaunay2111e3c2019-10-14 09:28:06 +02001// SPDX-License-Identifier: GPL-2.0+ OR BSD-3-Clause
2/*
3 * Copyright (C) 2019, STMicroelectronics - All Rights Reserved
4 */
5#include <common.h>
6#include <dfu.h>
7#include <errno.h>
Simon Glass0f2af882020-05-10 11:40:05 -06008#include <log.h>
Patrick Delaunay2111e3c2019-10-14 09:28:06 +02009#include <malloc.h>
10
11int __weak dfu_write_medium_virt(struct dfu_entity *dfu, u64 offset,
12 void *buf, long *len)
13{
14 debug("%s: off=0x%llx, len=0x%x\n", __func__, offset, (u32)*len);
15
16 return 0;
17}
18
19int __weak dfu_get_medium_size_virt(struct dfu_entity *dfu, u64 *size)
20{
21 *size = 0;
22
23 return 0;
24}
25
26int __weak dfu_read_medium_virt(struct dfu_entity *dfu, u64 offset,
27 void *buf, long *len)
28{
29 debug("%s: off=0x%llx, len=0x%x\n", __func__, offset, (u32)*len);
30 *len = 0;
31
32 return 0;
33}
34
Masami Hiramatsufa4282a2022-01-31 11:52:37 +090035int dfu_fill_entity_virt(struct dfu_entity *dfu, char *devstr, char **argv, int argc)
Patrick Delaunay2111e3c2019-10-14 09:28:06 +020036{
37 debug("%s: devstr = %s\n", __func__, devstr);
38
Masami Hiramatsufa4282a2022-01-31 11:52:37 +090039 if (argc != 0)
40 return -EINVAL;
41
Patrick Delaunay2111e3c2019-10-14 09:28:06 +020042 dfu->dev_type = DFU_DEV_VIRT;
43 dfu->layout = DFU_RAW_ADDR;
Simon Glassff9b9032021-07-24 09:03:30 -060044 dfu->data.virt.dev_num = dectoul(devstr, NULL);
Patrick Delaunay2111e3c2019-10-14 09:28:06 +020045
46 dfu->write_medium = dfu_write_medium_virt;
47 dfu->get_medium_size = dfu_get_medium_size_virt;
48 dfu->read_medium = dfu_read_medium_virt;
49
50 dfu->inited = 0;
51
52 return 0;
53}