Patrick Delaunay | 2111e3c | 2019-10-14 09:28:06 +0200 | [diff] [blame] | 1 | // SPDX-License-Identifier: GPL-2.0+ OR BSD-3-Clause |
| 2 | /* |
| 3 | * Copyright (C) 2019, STMicroelectronics - All Rights Reserved |
| 4 | */ |
Patrick Delaunay | 2111e3c | 2019-10-14 09:28:06 +0200 | [diff] [blame] | 5 | #include <dfu.h> |
| 6 | #include <errno.h> |
Simon Glass | 0f2af88 | 2020-05-10 11:40:05 -0600 | [diff] [blame] | 7 | #include <log.h> |
Patrick Delaunay | 2111e3c | 2019-10-14 09:28:06 +0200 | [diff] [blame] | 8 | #include <malloc.h> |
| 9 | |
| 10 | int __weak dfu_write_medium_virt(struct dfu_entity *dfu, u64 offset, |
| 11 | void *buf, long *len) |
| 12 | { |
| 13 | debug("%s: off=0x%llx, len=0x%x\n", __func__, offset, (u32)*len); |
| 14 | |
| 15 | return 0; |
| 16 | } |
| 17 | |
| 18 | int __weak dfu_get_medium_size_virt(struct dfu_entity *dfu, u64 *size) |
| 19 | { |
| 20 | *size = 0; |
| 21 | |
| 22 | return 0; |
| 23 | } |
| 24 | |
| 25 | int __weak dfu_read_medium_virt(struct dfu_entity *dfu, u64 offset, |
| 26 | void *buf, long *len) |
| 27 | { |
| 28 | debug("%s: off=0x%llx, len=0x%x\n", __func__, offset, (u32)*len); |
| 29 | *len = 0; |
| 30 | |
| 31 | return 0; |
| 32 | } |
| 33 | |
Masami Hiramatsu | fa4282a | 2022-01-31 11:52:37 +0900 | [diff] [blame] | 34 | int dfu_fill_entity_virt(struct dfu_entity *dfu, char *devstr, char **argv, int argc) |
Patrick Delaunay | 2111e3c | 2019-10-14 09:28:06 +0200 | [diff] [blame] | 35 | { |
| 36 | debug("%s: devstr = %s\n", __func__, devstr); |
| 37 | |
Masami Hiramatsu | fa4282a | 2022-01-31 11:52:37 +0900 | [diff] [blame] | 38 | if (argc != 0) |
| 39 | return -EINVAL; |
| 40 | |
Patrick Delaunay | 2111e3c | 2019-10-14 09:28:06 +0200 | [diff] [blame] | 41 | dfu->dev_type = DFU_DEV_VIRT; |
| 42 | dfu->layout = DFU_RAW_ADDR; |
Simon Glass | ff9b903 | 2021-07-24 09:03:30 -0600 | [diff] [blame] | 43 | dfu->data.virt.dev_num = dectoul(devstr, NULL); |
Patrick Delaunay | 2111e3c | 2019-10-14 09:28:06 +0200 | [diff] [blame] | 44 | |
| 45 | dfu->write_medium = dfu_write_medium_virt; |
| 46 | dfu->get_medium_size = dfu_get_medium_size_virt; |
| 47 | dfu->read_medium = dfu_read_medium_virt; |
| 48 | |
| 49 | dfu->inited = 0; |
| 50 | |
| 51 | return 0; |
| 52 | } |