Rtos API example

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers support_funcs.h Source File

support_funcs.h

00001 /*
00002  * Copyright (c) 2006-2016, ARM Limited, All Rights Reserved
00003  * SPDX-License-Identifier: Apache-2.0
00004  *
00005  * Licensed under the Apache License, Version 2.0 (the "License"); you may
00006  * not use this file except in compliance with the License.
00007  * You may obtain a copy of the License at
00008  *
00009  * http://www.apache.org/licenses/LICENSE-2.0
00010  *
00011  * Unless required by applicable law or agreed to in writing, software
00012  * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
00013  * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
00014  * See the License for the specific language governing permissions and
00015  * limitations under the License.
00016  */
00017 
00018 #ifndef __FLASH_JOURNAL_SEQUENTIAL_STRATEGY_SUPPORT_FUNCTIONS_H__
00019 #define __FLASH_JOURNAL_SEQUENTIAL_STRATEGY_SUPPORT_FUNCTIONS_H__
00020 
00021 #include "flash-journal-strategy-sequential/flash_journal_private.h"
00022 #include "flash-journal-strategy-sequential/flash_journal_strategy_sequential.h"
00023 
00024 /* The following singleton captures the state of the format machine. Format is
00025  * handled differently because it executes even before a journal exists (or a
00026  * Journal_t can be initialized. */
00027 extern struct FormatInfo_t {
00028     ARM_DRIVER_STORAGE             *mtd;
00029     SequentialFlashJournalHeader_t  header;
00030     FlashJournal_Callback_t         callback;
00031     uint64_t                        mtdAddr;
00032     uint32_t                        mtdProgramUnit;
00033 } formatInfoSingleton;
00034 
00035 extern SequentialFlashJournal_t *activeJournal;
00036 
00037 /**
00038  * Check the sanity of a given slot
00039  * @param       journal
00040  * @param       slotOffset
00041  * @param [out] headSequenceNumberP
00042  *                  sequence number of the slot as read from the header.
00043  * @param [out] tailP
00044  *                  the tail of the slot
00045  * @return 1 if the slot is valid; i.e. if head and tail match, and if CRC32 agrees.
00046  */
00047 int32_t slotIsSane(SequentialFlashJournal_t        *journal,
00048                    uint64_t                         slotOffset,
00049                    uint32_t                        *headSequenceNumberP,
00050                    SequentialFlashJournalLogTail_t *tailP);
00051 
00052 int32_t mtdGetStartAddr(ARM_DRIVER_STORAGE *mtd, uint64_t *startAddrP);
00053 int32_t setupSequentialJournalHeader(SequentialFlashJournalHeader_t *headerP, ARM_DRIVER_STORAGE *mtd, uint64_t totalSize, uint32_t numSlots);
00054 int32_t discoverLatestLoggedBlob(SequentialFlashJournal_t *journal);
00055 
00056 /**
00057  * Progress the state machine for the 'format' operation. This method can also be called from an interrupt handler.
00058  * @return  < JOURNAL_STATUS_OK for error
00059  *          = JOURNAL_STATUS_OK to signal pending asynchronous activity
00060  *          > JOURNAL_STATUS_OK for completion
00061  */
00062 int32_t flashJournalStrategySequential_format_progress(int32_t status, ARM_STORAGE_OPERATION operationWhichJustFinshed);
00063 
00064 /**
00065  * Progress the state machine for the 'log' operation. This method can also be called from an interrupt handler.
00066  * @return  < JOURNAL_STATUS_OK for error
00067  *          = JOURNAL_STATUS_OK to signal pending asynchronous activity
00068  *          > JOURNAL_STATUS_OK for completion
00069  */
00070 int32_t flashJournalStrategySequential_log_progress(void);
00071 
00072 int32_t flashJournalStrategySequential_reset_progress(void);
00073 int32_t flashJournalStrategySequential_read_progress(void);
00074 
00075 void    mtdHandler(int32_t status, ARM_STORAGE_OPERATION operation);
00076 void    formatHandler(int32_t status, ARM_STORAGE_OPERATION operation);
00077 
00078 #endif /*__FLASH_JOURNAL_SEQUENTIAL_STRATEGY_SUPPORT_FUNCTIONS_H__*/