Blame view

include/image-sparse.h 894 Bytes
83d290c56   Tom Rini   SPDX: Convert all...
1
  /* SPDX-License-Identifier: GPL-2.0+ */
e6ca1ad60   Steve Rae   implement the And...
2
3
  /*
   * Copyright 2014 Broadcom Corporation.
e6ca1ad60   Steve Rae   implement the And...
4
5
6
7
8
9
   */
  
  #include <part.h>
  #include <sparse_format.h>
  
  #define ROUNDUP(x, y)	(((x) + ((y) - 1)) & ~((y) - 1))
cc0f08cd3   Steve Rae   fastboot: sparse:...
10
11
12
13
14
15
16
17
18
19
  struct sparse_storage {
  	lbaint_t	blksz;
  	lbaint_t	start;
  	lbaint_t	size;
  	void		*priv;
  
  	lbaint_t	(*write)(struct sparse_storage *info,
  				 lbaint_t blk,
  				 lbaint_t blkcnt,
  				 const void *buffer);
2c7240468   Steve Rae   fastboot: sparse:...
20
21
22
23
  
  	lbaint_t	(*reserve)(struct sparse_storage *info,
  				 lbaint_t blk,
  				 lbaint_t blkcnt);
2f83f219b   Jassi Brar   fastboot: sparse:...
24

c4ded03ef   Alex Kiernan   fastboot: Refacto...
25
  	void		(*mssg)(const char *str, char *response);
cc0f08cd3   Steve Rae   fastboot: sparse:...
26
  };
a5d1e04a5   Maxime Ripard   sparse: Implement...
27

e6ca1ad60   Steve Rae   implement the And...
28
29
30
31
32
33
34
35
36
37
  static inline int is_sparse_image(void *buf)
  {
  	sparse_header_t *s_header = (sparse_header_t *)buf;
  
  	if ((le32_to_cpu(s_header->magic) == SPARSE_HEADER_MAGIC) &&
  	    (le16_to_cpu(s_header->major_version) == 1))
  		return 1;
  
  	return 0;
  }
2f83f219b   Jassi Brar   fastboot: sparse:...
38
  int write_sparse_image(struct sparse_storage *info, const char *part_name,
c4ded03ef   Alex Kiernan   fastboot: Refacto...
39
  		       void *data, char *response);