Lee Kai Xuan / mbed-os

Fork of mbed-os by erkin yucel

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers interrupts.h Source File

interrupts.h

00001 /*
00002  * Copyright (c) 2013-2015, 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 #ifndef __UVISOR_API_INTERRUPTS_H__
00018 #define __UVISOR_API_INTERRUPTS_H__
00019 
00020 #include "api/inc/unvic_exports.h"
00021 #include "api/inc/uvisor_exports.h"
00022 #include <stdint.h>
00023 
00024 UVISOR_EXTERN void vIRQ_SetVector(uint32_t irqn, uint32_t vector);
00025 UVISOR_EXTERN uint32_t vIRQ_GetVector(uint32_t irqn);
00026 UVISOR_EXTERN void vIRQ_EnableIRQ(uint32_t irqn);
00027 UVISOR_EXTERN void vIRQ_DisableIRQ(uint32_t irqn);
00028 UVISOR_EXTERN void vIRQ_ClearPendingIRQ(uint32_t irqn);
00029 UVISOR_EXTERN void vIRQ_SetPendingIRQ(uint32_t irqn);
00030 UVISOR_EXTERN uint32_t vIRQ_GetPendingIRQ(uint32_t irqn);
00031 UVISOR_EXTERN void vIRQ_SetPriority(uint32_t irqn, uint32_t priority);
00032 UVISOR_EXTERN uint32_t vIRQ_GetPriority(uint32_t irqn);
00033 UVISOR_EXTERN int vIRQ_GetLevel(void);
00034 
00035 /** Disable all interrupts for the currently active box.
00036  *
00037  * Calling this function from a box only affects the interrupts of that box.
00038  * System interrupts and interrupts owned by other boxes are left untouched.
00039  *
00040  * Successive calls to this function increase an internal counter that is used
00041  * by uVisor to decide when to re-enable IRQs. The related call
00042  * ::vIRQ_EnableIRQ() decreases this counter. Only when the counter is 0 the
00043  * interrupts are re-enabled for that box.
00044  *
00045  * This guarantees that code that disables IRQs will not accidentally have them
00046  * re-enabled by a nested function that it calls before the expected call to
00047  * ::vIRQ_EnableAll(). Example:
00048  *
00049  * vIRQ_DisableAll();  counter = 1; IRQs are now disabled.
00050  * some_function();    counter = 2, then counter = 1; IRQs are still disabled.
00051  * vIRQ_EnableAll();   counter = 0; IRQs are now re-enabled.
00052  *
00053  * where some_function() also has a disable/enable pair. */
00054 UVISOR_EXTERN void vIRQ_DisableAll(void);
00055 
00056 /** Re-enable all interrupts that were previously disabled for the currently
00057  *  active box.
00058  *
00059  * This function only re-enables interrupt if the uVisor internal counter is set
00060  * to 0, to make sure that nested disabling of IRQs is still effective. See
00061  * ::vIRQ_DisableAll for more information. */
00062 UVISOR_EXTERN void vIRQ_EnableAll(void);
00063 
00064 /** Reset the device.
00065  * @warning Currently only the debug box can reset the device.
00066  * @param reason[in]    Reason for rebooting. Currently not used.
00067  */
00068 UVISOR_EXTERN void vIRQ_SystemReset(TResetReason reason);
00069 
00070 #endif /* __UVISOR_API_INTERRUPTS_H__ */