lib: avb: change the prefix of some functions to make them coincident
Change-Id: Id876e6e49fb614e43d9f15cd9d24cee29aead223 Signed-off-by: Jason Zhu <jason.zhu@rock-chips.com>
This commit is contained in:
parent
e13fd25b91
commit
5b09015999
|
|
@ -438,7 +438,7 @@ static void cb_getvar(struct usb_ep *ep, struct usb_request *req)
|
|||
char temp;
|
||||
|
||||
slot_count[1] = '\0';
|
||||
read_slot_count(&temp);
|
||||
avb_read_slot_count(&temp);
|
||||
slot_count[0] = temp + 0x30;
|
||||
strncat(response, slot_count, chars_left);
|
||||
#else
|
||||
|
|
@ -449,7 +449,7 @@ static void cb_getvar(struct usb_ep *ep, struct usb_request *req)
|
|||
#ifdef CONFIG_AVB_LIBAVB_USER
|
||||
char slot_surrent[8] = {0};
|
||||
|
||||
if (!get_current_slot(slot_surrent))
|
||||
if (!avb_get_current_slot(slot_surrent))
|
||||
strncat(response, slot_surrent, chars_left);
|
||||
else
|
||||
strcpy(response, "FAILgeterror");
|
||||
|
|
@ -465,7 +465,7 @@ static void cb_getvar(struct usb_ep *ep, struct usb_request *req)
|
|||
|
||||
memset(slot_suffixes_temp, 0, 4);
|
||||
memset(slot_suffixes, 0, 9);
|
||||
read_slot_suffixes(slot_suffixes_temp);
|
||||
avb_read_slot_suffixes(slot_suffixes_temp);
|
||||
while (slot_suffixes_temp[slot_cnt] != '\0') {
|
||||
slot_suffixes[slot_cnt * 2]
|
||||
= slot_suffixes_temp[slot_cnt];
|
||||
|
|
@ -754,10 +754,10 @@ static void cb_set_active(struct usb_ep *ep, struct usb_request *req)
|
|||
unsigned int slot_number;
|
||||
if (strncmp("a", cmd, 1) == 0) {
|
||||
slot_number = 0;
|
||||
set_slot_active(&slot_number);
|
||||
avb_set_slot_active(&slot_number);
|
||||
} else if (strncmp("b", cmd, 1) == 0) {
|
||||
slot_number = 1;
|
||||
set_slot_active(&slot_number);
|
||||
avb_set_slot_active(&slot_number);
|
||||
} else {
|
||||
fastboot_tx_write_str("FAIL: unkown slot name");
|
||||
return;
|
||||
|
|
@ -779,7 +779,7 @@ static void cb_flash(struct usb_ep *ep, struct usb_request *req)
|
|||
#ifdef CONFIG_AVB_LIBAVB_USER
|
||||
uint8_t flash_lock_state;
|
||||
|
||||
if (read_flash_lock_state(&flash_lock_state))
|
||||
if (avb_read_flash_lock_state(&flash_lock_state))
|
||||
fastboot_tx_write_str("FAIL");
|
||||
return;
|
||||
if (flash_lock_state == 0) {
|
||||
|
|
@ -816,7 +816,7 @@ static void cb_flashing(struct usb_ep *ep, struct usb_request *req)
|
|||
#ifdef CONFIG_AVB_LIBAVB_USER
|
||||
uint8_t flash_lock_state;
|
||||
flash_lock_state = 0;
|
||||
if (write_flash_lock_state(flash_lock_state))
|
||||
if (avb_write_flash_lock_state(flash_lock_state))
|
||||
fastboot_tx_write_str("FAIL");
|
||||
else
|
||||
fastboot_tx_write_str("OKAY");
|
||||
|
|
@ -827,7 +827,7 @@ static void cb_flashing(struct usb_ep *ep, struct usb_request *req)
|
|||
#ifdef CONFIG_AVB_LIBAVB_USER
|
||||
uint8_t flash_lock_state;
|
||||
flash_lock_state = 1;
|
||||
if (write_flash_lock_state(flash_lock_state))
|
||||
if (avb_write_flash_lock_state(flash_lock_state))
|
||||
fastboot_tx_write_str("FAIL");
|
||||
else
|
||||
fastboot_tx_write_str("OKAY");
|
||||
|
|
@ -876,7 +876,7 @@ static void cb_oem(struct usb_ep *ep, struct usb_request *req)
|
|||
#ifdef CONFIG_AVB_LIBAVB_USER
|
||||
uint8_t lock_state;
|
||||
lock_state = 0;
|
||||
if (write_lock_state(lock_state))
|
||||
if (avb_write_lock_state(lock_state))
|
||||
fastboot_tx_write_str("FAIL");
|
||||
else
|
||||
fastboot_tx_write_str("OKAY");
|
||||
|
|
@ -886,13 +886,13 @@ static void cb_oem(struct usb_ep *ep, struct usb_request *req)
|
|||
} else if (strncmp("at-unlock-vboot", cmd + 4, 15) == 0) {
|
||||
#ifdef CONFIG_AVB_LIBAVB_USER
|
||||
uint8_t lock_state;
|
||||
if (read_lock_state(&lock_state))
|
||||
if (avb_read_lock_state(&lock_state))
|
||||
fastboot_tx_write_str("FAIL");
|
||||
if (lock_state >> 1 == 1) {
|
||||
fastboot_tx_write_str("FAILThe vboot is disable!");
|
||||
} else {
|
||||
lock_state = 1;
|
||||
if (write_lock_state(lock_state))
|
||||
if (avb_write_lock_state(lock_state))
|
||||
fastboot_tx_write_str("FAIL");
|
||||
else
|
||||
fastboot_tx_write_str("OKAY");
|
||||
|
|
@ -904,7 +904,7 @@ static void cb_oem(struct usb_ep *ep, struct usb_request *req)
|
|||
#ifdef CONFIG_AVB_LIBAVB_USER
|
||||
uint8_t lock_state;
|
||||
lock_state = 2;
|
||||
if (write_lock_state(lock_state))
|
||||
if (avb_write_lock_state(lock_state))
|
||||
fastboot_tx_write_str("FAIL");
|
||||
else
|
||||
fastboot_tx_write_str("OKAY");
|
||||
|
|
@ -913,7 +913,7 @@ static void cb_oem(struct usb_ep *ep, struct usb_request *req)
|
|||
#endif
|
||||
} else if (strncmp("fuse at-perm-attr", cmd + 4, 16) == 0) {
|
||||
#ifdef CONFIG_AVB_LIBAVB_USER
|
||||
if (write_permanent_attributes((uint8_t *)
|
||||
if (avb_write_permanent_attributes((uint8_t *)
|
||||
CONFIG_FASTBOOT_BUF_ADDR,
|
||||
download_bytes))
|
||||
fastboot_tx_write_str("FAIL");
|
||||
|
|
|
|||
|
|
@ -1,22 +1,165 @@
|
|||
/*
|
||||
* Copyright (C) 2016 The Android Open Source Project
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person
|
||||
* obtaining a copy of this software and associated documentation
|
||||
* files (the "Software"), to deal in the Software without
|
||||
* restriction, including without limitation the rights to use, copy,
|
||||
* modify, merge, publish, distribute, sublicense, and/or sell copies
|
||||
* of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be
|
||||
* included in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
|
||||
* BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
|
||||
* ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
#ifndef AVB_OPS_USER_H_
|
||||
#define AVB_OPS_USER_H_
|
||||
|
||||
#include <android_avb/libavb.h>
|
||||
#include <android_avb/avb_ab_flow.h>
|
||||
|
||||
|
||||
|
||||
/* Allocates an AvbOps instance suitable for use in Android userspace
|
||||
* on the device. Returns NULL on OOM.
|
||||
*
|
||||
* The returned AvbOps has the following characteristics:
|
||||
*
|
||||
* - The read_from_partition(), write_to_partition(), and
|
||||
* get_size_of_partition() operations are implemented, however for
|
||||
* these operations to work the fstab file on the device must have a
|
||||
* /misc entry using a by-name device file scheme and the containing
|
||||
* by-name/ subdirectory must have files for other partitions.
|
||||
*
|
||||
* - The remaining operations are implemented and never fails and
|
||||
* return the following values:
|
||||
* - validate_vbmeta_public_key(): always returns |true|.
|
||||
* - read_rollback_index(): returns 0 for any roolback index.
|
||||
* - write_rollback_index(): no-op.
|
||||
* - read_is_device_unlocked(): always returns |true|.
|
||||
* - get_unique_guid_for_partition(): always returns the empty string.
|
||||
*
|
||||
* - The |ab_ops| member will point to a valid AvbABOps instance
|
||||
* implemented via libavb_ab/. This should only be used if the AVB
|
||||
* A/B stack is used on the device. This is what is used in
|
||||
* bootctrl.avb boot control implementation.
|
||||
*
|
||||
* Free with avb_ops_user_free().
|
||||
*/
|
||||
AvbOps* avb_ops_user_new(void);
|
||||
|
||||
/* Frees an AvbOps instance previously allocated with avb_ops_device_new(). */
|
||||
void avb_ops_user_free(AvbOps* ops);
|
||||
int read_slot_count(char *slot_count);
|
||||
int read_slot_suffixes(char *slot_suffixes);
|
||||
int set_slot_active(unsigned int *slot_number);
|
||||
int get_current_slot(char *select_slot);
|
||||
int read_permanent_attributes(uint8_t *attributes, uint32_t size);
|
||||
int write_permanent_attributes(uint8_t *attributes, uint32_t size);
|
||||
int read_flash_lock_state(uint8_t *flash_lock_state);
|
||||
int write_flash_lock_state(uint8_t flash_lock_state);
|
||||
int read_lock_state(uint8_t *lock_state);
|
||||
int write_lock_state(uint8_t lock_state);
|
||||
|
||||
/**
|
||||
* Provided to fastboot to read how many slot in this system.
|
||||
*
|
||||
* @param slot_count We use parameter slot_count to obtain
|
||||
* how many slots in the system.
|
||||
*
|
||||
* @return 0 if the command succeeded, -1 if it failed
|
||||
*/
|
||||
int avb_read_slot_count(char *slot_count);
|
||||
|
||||
/**
|
||||
* The android things supply many slots, their name like '_a', '_b'.
|
||||
* We can use this function to read current slot is '_a' or '_b'.
|
||||
*
|
||||
* @slot_suffixes read value '_a' or '_b'.
|
||||
*
|
||||
* @return 0 if the command succeeded, -1 if it failed
|
||||
*/
|
||||
int avb_read_slot_suffixes(char *slot_suffixes);
|
||||
|
||||
/**
|
||||
* Use this function to set which slot boot first.
|
||||
*
|
||||
* @param slot_number set '0' or '1'
|
||||
*
|
||||
* @return 0 if the command succeeded, -1 if it failed
|
||||
*/
|
||||
int avb_set_slot_active(unsigned int *slot_number);
|
||||
|
||||
/**
|
||||
* Get current slot: '_a' or '_b'.
|
||||
*
|
||||
* @param select_slot obtain current slot.
|
||||
*
|
||||
* @return 0 if the command succeeded, -1 if it failed
|
||||
*/
|
||||
int avb_get_current_slot(char *select_slot);
|
||||
|
||||
/**
|
||||
* The android things defines permanent attributes to
|
||||
* store PSK_public, product id. We can use this function
|
||||
* to read them.
|
||||
*
|
||||
* @param attributes PSK_public, product id....
|
||||
*
|
||||
* @param size The size of attributes.
|
||||
*
|
||||
* @return 0 if the command succeeded, -1 if it failed
|
||||
*/
|
||||
int avb_read_permanent_attributes(uint8_t *attributes, uint32_t size);
|
||||
|
||||
/**
|
||||
* The android things defines permanent attributes to
|
||||
* store PSK_public, product id. We can use this function
|
||||
* to write them.
|
||||
*
|
||||
* @param attributes PSK_public, product id....
|
||||
*
|
||||
* @param size The size of attributes.
|
||||
*
|
||||
* @return 0 if the command succeeded, -1 if it failed
|
||||
*/
|
||||
int avb_write_permanent_attributes(uint8_t *attributes, uint32_t size);
|
||||
|
||||
/**
|
||||
* The funtion can be use to read the device state to judge
|
||||
* whether the device can be flash.
|
||||
*
|
||||
* @param flash_lock_state A flag indicate the device flash state.
|
||||
*
|
||||
* @return 0 if the command succeeded, -1 if it failed
|
||||
*/
|
||||
int avb_read_flash_lock_state(uint8_t *flash_lock_state);
|
||||
|
||||
/**
|
||||
* The function is provided to write device flash state.
|
||||
*
|
||||
* @param flash_lock_state A flag indicate the device flash state.
|
||||
*
|
||||
* @return 0 if the command succeeded, -1 if it failed
|
||||
*/
|
||||
int avb_write_flash_lock_state(uint8_t flash_lock_state);
|
||||
|
||||
/**
|
||||
* The android things use the flag of lock state to indicate
|
||||
* whether the device can be booted when verified error.
|
||||
*
|
||||
* @param lock_state A flag indicate the device lock state.
|
||||
*
|
||||
* @return 0 if the command succeeded, -1 if it failed
|
||||
*/
|
||||
int avb_read_lock_state(uint8_t *lock_state);
|
||||
|
||||
/**
|
||||
* The android things use the flag of lock state to indicate
|
||||
* whether the device can be booted when verified error.
|
||||
*
|
||||
* @param lock_state A flag indicate the device lock state.
|
||||
*
|
||||
* @return 0 if the command succeeded, -1 if it failed
|
||||
*/
|
||||
int avb_write_lock_state(uint8_t lock_state);
|
||||
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -305,7 +305,7 @@ void avb_ops_user_free(AvbOps *ops)
|
|||
}
|
||||
|
||||
|
||||
int read_slot_count(char *slot_count)
|
||||
int avb_read_slot_count(char *slot_count)
|
||||
{
|
||||
AvbOps* ops;
|
||||
AvbABData ab_data;
|
||||
|
|
@ -326,7 +326,7 @@ int read_slot_count(char *slot_count)
|
|||
return 0;
|
||||
}
|
||||
|
||||
int read_slot_suffixes(char *slot_suffixes)
|
||||
int avb_read_slot_suffixes(char *slot_suffixes)
|
||||
{
|
||||
AvbOps* ops;
|
||||
AvbABData ab_data;
|
||||
|
|
@ -347,7 +347,7 @@ int read_slot_suffixes(char *slot_suffixes)
|
|||
return 0;
|
||||
}
|
||||
|
||||
int set_slot_active(unsigned int *slot_number)
|
||||
int avb_set_slot_active(unsigned int *slot_number)
|
||||
{
|
||||
AvbOps* ops;
|
||||
ops = avb_ops_user_new();
|
||||
|
|
@ -366,7 +366,7 @@ int set_slot_active(unsigned int *slot_number)
|
|||
return 0;
|
||||
}
|
||||
|
||||
int get_current_slot(char *select_slot)
|
||||
int avb_get_current_slot(char *select_slot)
|
||||
{
|
||||
AvbOps* ops;
|
||||
ops = avb_ops_user_new();
|
||||
|
|
@ -384,7 +384,7 @@ int get_current_slot(char *select_slot)
|
|||
return 0;
|
||||
}
|
||||
|
||||
int read_permanent_attributes(uint8_t *attributes, uint32_t size)
|
||||
int avb_read_permanent_attributes(uint8_t *attributes, uint32_t size)
|
||||
{
|
||||
if(trusty_read_permanent_attributes(attributes, size) != 0) {
|
||||
return -1;
|
||||
|
|
@ -393,7 +393,7 @@ int read_permanent_attributes(uint8_t *attributes, uint32_t size)
|
|||
return 0;
|
||||
}
|
||||
|
||||
int write_permanent_attributes(uint8_t *attributes, uint32_t size)
|
||||
int avb_write_permanent_attributes(uint8_t *attributes, uint32_t size)
|
||||
{
|
||||
if(trusty_write_permanent_attributes(attributes, size) != 0) {
|
||||
return -1;
|
||||
|
|
@ -402,28 +402,28 @@ int write_permanent_attributes(uint8_t *attributes, uint32_t size)
|
|||
return 0;
|
||||
}
|
||||
|
||||
int read_flash_lock_state(uint8_t *flash_lock_state)
|
||||
int avb_read_flash_lock_state(uint8_t *flash_lock_state)
|
||||
{
|
||||
if (trusty_read_flash_lock_state(flash_lock_state))
|
||||
return -1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
int write_flash_lock_state(uint8_t flash_lock_state)
|
||||
int avb_write_flash_lock_state(uint8_t flash_lock_state)
|
||||
{
|
||||
if (trusty_write_flash_lock_state(flash_lock_state))
|
||||
return -1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
int read_lock_state(uint8_t *lock_state)
|
||||
int avb_read_lock_state(uint8_t *lock_state)
|
||||
{
|
||||
if (trusty_read_lock_state(lock_state))
|
||||
return -1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
int write_lock_state(uint8_t lock_state)
|
||||
int avb_write_lock_state(uint8_t lock_state)
|
||||
{
|
||||
if (trusty_write_lock_state(lock_state))
|
||||
return -1;
|
||||
|
|
|
|||
Loading…
Reference in New Issue