Home | History | Annotate | Download | only in updater
      1 /*
      2  * Copyright (C) 2015 The Android Open Source Project
      3  *
      4  * Licensed under the Apache License, Version 2.0 (the "License");
      5  * you may not use this file except in compliance with the License.
      6  * You may obtain a copy of the License at
      7  *
      8  *      http://www.apache.org/licenses/LICENSE-2.0
      9  *
     10  * Unless required by applicable law or agreed to in writing, software
     11  * distributed under the License is distributed on an "AS IS" BASIS,
     12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     13  * See the License for the specific language governing permissions and
     14  * limitations under the License.
     15  */
     16 #ifdef __cplusplus
     17 extern "C" {
     18 #endif /* __cplusplus */
     19 
     20 #ifndef _RECOVERY_FLASH_DEVICE_H_
     21 #define _RECOVERY_FLASH_DEVICE_H_
     22 
     23 #include <stdint.h>
     24 
     25 struct flash_device_ops {
     26 	char * const name;
     27 	void *(*open)(const void *params);
     28 	void (*close)(void *hnd);
     29 	int (*read)(void *hnd, off_t offset, void *buffer, size_t count);
     30 	int (*write)(void *hnd, off_t offset, void *buffer, size_t count);
     31 	int (*erase)(void *hnd, off_t offset, size_t count);
     32 	size_t (*get_size)(void *hnd);
     33 	size_t (*get_write_size)(void *hnd);
     34 	size_t (*get_erase_size)(void *hnd);
     35 	off_t (*get_fmap_offset)(void *hnd);
     36 	int (*cmd)(void *hnd, int cmd, int ver, const void *odata, int osize,
     37 		   void *idata, int isize);
     38 };
     39 
     40 struct flash_device;
     41 
     42 struct flash_device *flash_open(const char *name, const void *params);
     43 void flash_close(struct flash_device *dev);
     44 int flash_read(struct flash_device *dev, off_t off, void *buff, size_t len);
     45 int flash_write(struct flash_device *dev, off_t off, void *buff, size_t len);
     46 int flash_erase(struct flash_device *dev, off_t off, size_t len);
     47 size_t flash_get_size(struct flash_device *dev);
     48 int flash_cmd(struct flash_device *dev, int cmd, int ver,
     49 	      const void *odata, int osize, void *idata, int isize);
     50 
     51 struct fmap *flash_get_fmap(struct flash_device *dev);
     52 uint8_t *flash_get_gbb(struct flash_device *dev, size_t *size);
     53 
     54 /* Available flash devices */
     55 extern const struct flash_device_ops flash_mtd_ops;
     56 extern const struct flash_device_ops flash_ec_ops;
     57 extern const struct flash_device_ops flash_file_ops;
     58 
     59 #endif /* _RECOVERY_FLASH_DEVICE_H_ */
     60 
     61 #ifdef __cplusplus
     62 } /* extern "C" */
     63 #endif /* __cplusplus */
     64