xref: /rk3399_rockchip-uboot/include/android_avb/avb_ops_user.h (revision 37a7bc39c0a3beca986e8c1c85d1dd6b9921e313)
15b090159SJason Zhu /*
25b090159SJason Zhu  * Copyright (C) 2016 The Android Open Source Project
35b090159SJason Zhu  *
45b090159SJason Zhu  * Permission is hereby granted, free of charge, to any person
55b090159SJason Zhu  * obtaining a copy of this software and associated documentation
65b090159SJason Zhu  * files (the "Software"), to deal in the Software without
75b090159SJason Zhu  * restriction, including without limitation the rights to use, copy,
85b090159SJason Zhu  * modify, merge, publish, distribute, sublicense, and/or sell copies
95b090159SJason Zhu  * of the Software, and to permit persons to whom the Software is
105b090159SJason Zhu  * furnished to do so, subject to the following conditions:
115b090159SJason Zhu  *
125b090159SJason Zhu  * The above copyright notice and this permission notice shall be
135b090159SJason Zhu  * included in all copies or substantial portions of the Software.
145b090159SJason Zhu  *
155b090159SJason Zhu  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
165b090159SJason Zhu  * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
175b090159SJason Zhu  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
185b090159SJason Zhu  * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
195b090159SJason Zhu  * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
205b090159SJason Zhu  * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
215b090159SJason Zhu  * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
225b090159SJason Zhu  * SOFTWARE.
235b090159SJason Zhu  */
245b090159SJason Zhu 
256c551138SJason Zhu #ifndef AVB_OPS_USER_H_
266c551138SJason Zhu #define AVB_OPS_USER_H_
276c551138SJason Zhu 
286c551138SJason Zhu #include <android_avb/libavb.h>
296c551138SJason Zhu #include <android_avb/avb_ab_flow.h>
306c551138SJason Zhu 
31*37a7bc39SJason Zhu #ifdef __cplusplus
32*37a7bc39SJason Zhu extern "C" {
33*37a7bc39SJason Zhu #endif
34f74d184aSJason Zhu 
355b090159SJason Zhu /* Allocates an AvbOps instance suitable for use in Android userspace
365b090159SJason Zhu  * on the device. Returns NULL on OOM.
375b090159SJason Zhu  *
385b090159SJason Zhu  * The returned AvbOps has the following characteristics:
395b090159SJason Zhu  *
405b090159SJason Zhu  * - The read_from_partition(), write_to_partition(), and
415b090159SJason Zhu  *   get_size_of_partition() operations are implemented, however for
425b090159SJason Zhu  *   these operations to work the fstab file on the device must have a
435b090159SJason Zhu  *   /misc entry using a by-name device file scheme and the containing
445b090159SJason Zhu  *   by-name/ subdirectory must have files for other partitions.
455b090159SJason Zhu  *
465b090159SJason Zhu  * - The remaining operations are implemented and never fails and
475b090159SJason Zhu  *   return the following values:
485b090159SJason Zhu  *   - validate_vbmeta_public_key(): always returns |true|.
495b090159SJason Zhu  *   - read_rollback_index(): returns 0 for any roolback index.
505b090159SJason Zhu  *   - write_rollback_index(): no-op.
515b090159SJason Zhu  *   - read_is_device_unlocked(): always returns |true|.
525b090159SJason Zhu  *   - get_unique_guid_for_partition(): always returns the empty string.
535b090159SJason Zhu  *
545b090159SJason Zhu  * - The |ab_ops| member will point to a valid AvbABOps instance
555b090159SJason Zhu  *   implemented via libavb_ab/. This should only be used if the AVB
565b090159SJason Zhu  *   A/B stack is used on the device. This is what is used in
575b090159SJason Zhu  *   bootctrl.avb boot control implementation.
585b090159SJason Zhu  *
595b090159SJason Zhu  * Free with avb_ops_user_free().
605b090159SJason Zhu  */
616c551138SJason Zhu AvbOps* avb_ops_user_new(void);
625b090159SJason Zhu 
635b090159SJason Zhu /* Frees an AvbOps instance previously allocated with avb_ops_device_new(). */
646c551138SJason Zhu void avb_ops_user_free(AvbOps* ops);
655b090159SJason Zhu 
66*37a7bc39SJason Zhu #ifdef __cplusplus
67*37a7bc39SJason Zhu }
686c551138SJason Zhu #endif
69*37a7bc39SJason Zhu 
70*37a7bc39SJason Zhu #endif /* AVB_OPS_USER_H_ */
71