Mayank Gupta / Mbed OS pelion-example-frdm

Dependencies:   FXAS21002 FXOS8700Q

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers arm_uc_pal_linux_openwrt.c Source File

arm_uc_pal_linux_openwrt.c

00001 // ----------------------------------------------------------------------------
00002 // Copyright 2016-2017 ARM Ltd.
00003 //
00004 // SPDX-License-Identifier: Apache-2.0
00005 //
00006 // Licensed under the Apache License, Version 2.0 (the "License");
00007 // you may not use this file except in compliance with the License.
00008 // You may obtain a copy of the License at
00009 //
00010 //     http://www.apache.org/licenses/LICENSE-2.0
00011 //
00012 // Unless required by applicable law or agreed to in writing, software
00013 // distributed under the License is distributed on an "AS IS" BASIS,
00014 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
00015 // See the License for the specific language governing permissions and
00016 // limitations under the License.
00017 // ----------------------------------------------------------------------------
00018 
00019 #include "arm_uc_config.h"
00020 #if defined(ARM_UC_FEATURE_PAL_LINUX) && (ARM_UC_FEATURE_PAL_LINUX == 1)
00021 #if defined(TARGET_IS_PC_LINUX)
00022 
00023 #include "update-client-paal/arm_uc_paal_update_api.h"
00024 #include "update-client-pal-linux/arm_uc_pal_linux_implementation.h"
00025 #include "update-client-pal-linux/arm_uc_pal_linux_implementation_internal.h"
00026 #include <unistd.h>
00027 
00028 /**
00029  * @brief Get a bitmap indicating supported features.
00030  * @details The bitmap is used in conjunction with the firmware and
00031  *          installer details struct to indicate what fields are supported
00032  *          and which values are valid.
00033  *
00034  * @return Capability bitmap.
00035  */
00036 ARM_UC_PAAL_UPDATE_CAPABILITIES ARM_UC_PAL_Linux_GetCapabilities_OpenWRT(void)
00037 {
00038     const ARM_UC_PAAL_UPDATE_CAPABILITIES result = {
00039         .installer_arm_hash = 0,
00040         .installer_oem_hash = 0,
00041         .installer_layout   = 0,
00042         .firmware_hash      = 1,
00043         .firmware_hmac      = 0,
00044         .firmware_campaign  = 0,
00045         .firmware_version   = 1,
00046         .firmware_size      = 1
00047     };
00048 
00049     return result;
00050 }
00051 
00052 arm_ucp_worker_t arm_uc_worker_parameters_active_details = {
00053     .command = "/usr/sbin/arm_update_active_details.sh",
00054     .header   = 1,
00055     .firmware = 0,
00056     .location = 0,
00057     .offset   = 0,
00058     .size     = 0,
00059     .success_event = ARM_UC_PAAL_EVENT_GET_ACTIVE_FIRMWARE_DETAILS_DONE,
00060     .failure_event = ARM_UC_PAAL_EVENT_GET_ACTIVE_FIRMWARE_DETAILS_ERROR,
00061     .post_runner = NULL
00062 };
00063 
00064 arm_ucp_worker_t arm_uc_worker_parameters_activate = {
00065     .command = "/usr/sbin/arm_update_activate.sh",
00066     .header   = 1,
00067     .firmware = 1,
00068     .location = 0,
00069     .offset   = 0,
00070     .size     = 0,
00071     .success_event = ARM_UC_PAAL_EVENT_ACTIVATE_DONE,
00072     .failure_event = ARM_UC_PAAL_EVENT_ACTIVATE_ERROR,
00073     .post_runner = NULL
00074 };
00075 
00076 arm_uc_error_t ARM_UC_PAL_Linux_Initialize_OpenWRT(ARM_UC_PAAL_UPDATE_SignalEvent_t callback)
00077 {
00078     extern arm_ucp_worker_config_t arm_uc_worker_parameters;
00079 
00080     arm_uc_worker_parameters.activate       = &arm_uc_worker_parameters_activate;
00081     arm_uc_worker_parameters.active_details = &arm_uc_worker_parameters_active_details;
00082     arm_uc_worker_parameters.details        = NULL;
00083     arm_uc_worker_parameters.finalize       = NULL;
00084     arm_uc_worker_parameters.initialize     = NULL;
00085     arm_uc_worker_parameters.installer      = NULL;
00086     arm_uc_worker_parameters.prepare        = NULL;
00087     arm_uc_worker_parameters.read           = NULL;
00088     arm_uc_worker_parameters.write          = NULL;
00089 
00090     return ARM_UC_PAL_Linux_Initialize(callback);
00091 }
00092 
00093 const ARM_UC_PAAL_UPDATE ARM_UCP_LINUX_OPENWRT = {
00094     .Initialize                 = ARM_UC_PAL_Linux_Initialize_OpenWRT,
00095     .GetCapabilities            = ARM_UC_PAL_Linux_GetCapabilities_OpenWRT,
00096     .GetMaxID                   = ARM_UC_PAL_Linux_GetMaxID,
00097     .Prepare                    = ARM_UC_PAL_Linux_Prepare,
00098     .Write                      = ARM_UC_PAL_Linux_Write,
00099     .Finalize                   = ARM_UC_PAL_Linux_Finalize,
00100     .Read                       = ARM_UC_PAL_Linux_Read,
00101     .Activate                   = ARM_UC_PAL_Linux_Activate,
00102     .GetActiveFirmwareDetails   = ARM_UC_PAL_Linux_GetActiveFirmwareDetails,
00103     .GetFirmwareDetails         = ARM_UC_PAL_Linux_GetFirmwareDetails,
00104     .GetInstallerDetails        = ARM_UC_PAL_Linux_GetInstallerDetails
00105 };
00106 
00107 #endif /* TARGET_IS_PC_LINUX */
00108 #endif /* ARM_UC_FEATURE_PAL_LINUX */