From e43c086ee10af04c3e0027460d87408c496c7877 Mon Sep 17 00:00:00 2001 From: Rom Lemarchand Date: Fri, 14 Aug 2015 14:58:21 -0700 Subject: [PATCH 1/3] boot: Add a boot_control HAL The purpose of the boot control HAL is to communicate with the bootloader and set various flags letting the bootloader know which partition to boot Change-Id: I15178abaaf9ca208b1e5300c9207cedbb7950a88 --- include/hardware/boot_control.h | 125 ++++++++++++++++++++++++++++++++ 1 file changed, 125 insertions(+) create mode 100644 include/hardware/boot_control.h diff --git a/include/hardware/boot_control.h b/include/hardware/boot_control.h new file mode 100644 index 00000000..62d6918e --- /dev/null +++ b/include/hardware/boot_control.h @@ -0,0 +1,125 @@ +/* + * Copyright (C) 2015 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef ANDROID_INCLUDE_HARDWARE_BOOT_CONTROL_H +#define ANDROID_INCLUDE_HARDWARE_BOOT_CONTROL_H + +#include + +__BEGIN_DECLS + +#define BOOT_CONTROL_MODULE_API_VERSION_0_1 HARDWARE_MODULE_API_VERSION(0, 1) + +/** + * The id of this module + */ +#define BOOT_CONTROL_HARDWARE_MODULE_ID "bootctrl" + +/* + * The Boot Control HAL is designed to allow for managing sets of redundant + * partitions, called slots, that can be booted from independantly. Slots + * are sets of partitions whose names differ only by a given suffix. + * They are identified here by a 0 indexed number, and associated with their + * suffix, which can be appended to the base name for any particular partition + * to find the one associated with that slot. The bootloader must pass the suffix + * of the currently active slot either through a kernel command line property at + * androidboot.slot_suffix, or the device tree at /firmware/android/slot_suffix. + * The primary use of this set up is to allow for background updates while the + * device is running, and to provide a fallback in the event that the update fails. + */ + + +/** + * Every hardware module must have a data structure named HAL_MODULE_INFO_SYM + * and the fields of this data structure must begin with hw_module_t + * followed by module specific information. + */ +typedef struct boot_control_module { + struct hw_module_t common; + + /* + * (*init)() perform any initialization tasks needed for the HAL. + * This is called only once. + */ + void (*init)(struct boot_control_module *module); + + /* + * (*getNumberSlots)() returns the number of available slots. + * For instance, a system with a single set of partitions would return + * 1, a system with A/B would return 2, A/B/C -> 3... + */ + unsigned (*getNumberSlots)(struct boot_control_module *module); + + /* + * (*getCurrentSlot)() returns the value letting the system know + * whether the current slot is A or B. The meaning of A and B is + * left up to the implementer. It is assumed that if the current slot + * is A, then the block devices underlying B can be accessed directly + * without any risk of corruption. + * The returned value is always guaranteed to be strictly less than the + * value returned by getNumberSlots. Slots start at 0 and + * finish at getNumberSlots() - 1 + */ + unsigned (*getCurrentSlot)(struct boot_control_module *module); + + /* + * (*markBootSuccessful)() marks the current slot + * as having booted successfully + * + * Returns 0 on success, -errno on error. + */ + int (*markBootSuccessful)(struct boot_control_module *module); + + /* + * (*setActiveBootSlot)() marks the slot passed in parameter as + * the active boot slot (see getCurrentSlot for an explanation + * of the "slot" parameter). This overrides any previous call to + * setSlotAsUnbootable. + * Returns 0 on success, -errno on error. + */ + int (*setActiveBootSlot)(struct boot_control_module *module, unsigned slot); + + /* + * (*setSlotAsUnbootable)() marks the slot passed in parameter as + * an unbootable. This can be used while updating the contents of the slot's + * partitions, so that the system will not attempt to boot a known bad set up. + * Returns 0 on success, -errno on error. + */ + int (*setSlotAsUnbootable)(struct boot_control_module *module, unsigned slot); + + /* + * (*isSlotBootable)() returns if the slot passed in parameter has + * booted successfully in the past. + * Returns 1 if the slot has booted successfully, 0 if it has not, + * and -errno on error. + */ + int (*isSlotBootable)(struct boot_control_module *module, unsigned slot); + + /* + * (*getSuffix)() returns the string suffix used by partitions that + * correspond to the slot number passed in parameter. The returned string + * is expected to be statically allocated and not need to be freed. + * Returns NULL if slot does not match an existing slot. + */ + const char* (*getSuffix)(struct boot_control_module *module, unsigned slot); + + void* reserved[32]; +} boot_control_module_t; + + +__END_DECLS + +#endif // ANDROID_INCLUDE_HARDWARE_BOOT_CONTROL_H From 4c690fc64eba65e2a13ece82e6c81367a48a003a Mon Sep 17 00:00:00 2001 From: Jani Suonpera Date: Fri, 9 Oct 2015 12:00:40 +0300 Subject: [PATCH 2/3] DO NOT MERGE ANYWHERE Add new interface for sensor physical data This is spesical solution only for emerald branch. Changes including new const char* value/interface for sensor physical data. Sensor service and manager does not take care of content, structure or other details of string. Sensor HAL is taking care of parsing data from string and setting values to Sensor HW. Change-Id: Iae69e04b71313fbcba46515d6787f3deef4e7346 Signed-off-by: Ben Fennema --- include/hardware/sensors.h | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/include/hardware/sensors.h b/include/hardware/sensors.h index 51bffe11..611fff6f 100644 --- a/include/hardware/sensors.h +++ b/include/hardware/sensors.h @@ -35,7 +35,8 @@ __BEGIN_DECLS #define SENSORS_DEVICE_API_VERSION_1_1 HARDWARE_DEVICE_API_VERSION_2(1, 1, SENSORS_HEADER_VERSION) #define SENSORS_DEVICE_API_VERSION_1_2 HARDWARE_DEVICE_API_VERSION_2(1, 2, SENSORS_HEADER_VERSION) #define SENSORS_DEVICE_API_VERSION_1_3 HARDWARE_DEVICE_API_VERSION_2(1, 3, SENSORS_HEADER_VERSION) -#define SENSORS_DEVICE_API_VERSION_1_4 HARDWARE_DEVICE_API_VERSION_2(1, 4, SENSORS_HEADER_VERSION) +#define SENSORS_DEVICE_API_VERSION_1_3_5 HARDWARE_DEVICE_API_VERSION_2(1, 4, SENSORS_HEADER_VERSION) +#define SENSORS_DEVICE_API_VERSION_1_4 HARDWARE_DEVICE_API_VERSION_2(1, 5, SENSORS_HEADER_VERSION) /** * Please see the Sensors section of source.android.com for an @@ -858,6 +859,13 @@ struct sensors_module_t { * -EPERM if operation is not allowed */ int (*set_operation_mode)(unsigned int mode); + + /** + * Set string to sensor HAL, which includes physical settings. + * Content of string is hardware/vendor specific. + * Availability: SENSORS_DEVICE_API_VERSION_1_3_5 + **/ + int (*set_sensor_physical_data)(const char* physicaldata); }; struct sensor_t { From 8b483596168805d95740b979d21098b25188b6da Mon Sep 17 00:00:00 2001 From: Ben Fennema Date: Wed, 2 Dec 2015 01:04:06 +0000 Subject: [PATCH 3/3] Revert "DO NOT MERGE ANYWHERE Add new interface for sensor physical data" This reverts commit 4c690fc64eba65e2a13ece82e6c81367a48a003a. Change-Id: I1ebf4c866606e004e2120d106f32973700f8bfeb --- include/hardware/sensors.h | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) diff --git a/include/hardware/sensors.h b/include/hardware/sensors.h index 611fff6f..51bffe11 100644 --- a/include/hardware/sensors.h +++ b/include/hardware/sensors.h @@ -35,8 +35,7 @@ __BEGIN_DECLS #define SENSORS_DEVICE_API_VERSION_1_1 HARDWARE_DEVICE_API_VERSION_2(1, 1, SENSORS_HEADER_VERSION) #define SENSORS_DEVICE_API_VERSION_1_2 HARDWARE_DEVICE_API_VERSION_2(1, 2, SENSORS_HEADER_VERSION) #define SENSORS_DEVICE_API_VERSION_1_3 HARDWARE_DEVICE_API_VERSION_2(1, 3, SENSORS_HEADER_VERSION) -#define SENSORS_DEVICE_API_VERSION_1_3_5 HARDWARE_DEVICE_API_VERSION_2(1, 4, SENSORS_HEADER_VERSION) -#define SENSORS_DEVICE_API_VERSION_1_4 HARDWARE_DEVICE_API_VERSION_2(1, 5, SENSORS_HEADER_VERSION) +#define SENSORS_DEVICE_API_VERSION_1_4 HARDWARE_DEVICE_API_VERSION_2(1, 4, SENSORS_HEADER_VERSION) /** * Please see the Sensors section of source.android.com for an @@ -859,13 +858,6 @@ struct sensors_module_t { * -EPERM if operation is not allowed */ int (*set_operation_mode)(unsigned int mode); - - /** - * Set string to sensor HAL, which includes physical settings. - * Content of string is hardware/vendor specific. - * Availability: SENSORS_DEVICE_API_VERSION_1_3_5 - **/ - int (*set_sensor_physical_data)(const char* physicaldata); }; struct sensor_t {