Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependents: TYBLE16_simple_data_logger TYBLE16_MP3_Air
CThunkBase.h
00001 /* mbed Microcontroller Library 00002 * Copyright (c) 2018-2018 ARM Limited 00003 * SPDX-License-Identifier: Apache-2.0 00004 * 00005 * Licensed under the Apache License, Version 2.0 (the "License"); 00006 * you may 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, 00013 * WITHOUT 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 __CTHUNK_BASE_H__ 00019 #define __CTHUNK_BASE_H__ 00020 00021 /** \defgroup platform-internal-api Platform 00022 * \ingroup mbed-os-internal 00023 */ 00024 00025 /* IRQ/Exception compatible thunk entry function */ 00026 typedef void (*CThunkEntry)(void); 00027 00028 /** 00029 * \defgroup platform_CThunkBase CThunkBase class 00030 * \ingroup platform-internal-api 00031 * @{ 00032 */ 00033 class CThunkBase { 00034 protected: 00035 typedef void (*Trampoline)(CThunkBase *); 00036 00037 Trampoline _trampoline; 00038 00039 /* 00040 * Allocate a CThunkEntry which can be called without arguments 00041 * 00042 * Calling the CThunkEntry invokes the _trampoline of the 00043 * given cthunk. This function traps if there are no more 00044 * free thunks. 00045 */ 00046 static CThunkEntry cthunk_alloc(CThunkBase *cthunk); 00047 00048 /* 00049 * Free a cthunk_entry so it can be reused 00050 */ 00051 static void cthunk_free(CThunkEntry cthunk_entry); 00052 00053 private: 00054 typedef void (*CthunkFree)(CThunkEntry cthunk_entry); 00055 00056 /* 00057 * Table of thunk functions 00058 */ 00059 static const CThunkEntry _thunk_table[MBED_CONF_PLATFORM_CTHUNK_COUNT_MAX]; 00060 00061 /* 00062 * Table of active CThunk classes 00063 */ 00064 static CThunkBase *_thunk_storage[MBED_CONF_PLATFORM_CTHUNK_COUNT_MAX]; 00065 00066 /* 00067 * Lazily initialized free function pointer 00068 */ 00069 static CthunkFree _cthunk_free_real; 00070 00071 /* 00072 * Actual free function 00073 */ 00074 static void cthunk_free_real(CThunkEntry cthunk_entry); 00075 00076 /* 00077 * Template function which stored in the _thunk_table 00078 */ 00079 template<int N> 00080 static void thunk_entry() 00081 { 00082 _thunk_storage[N]->_trampoline(_thunk_storage[N]); 00083 } 00084 }; 00085 00086 /**@}*/ 00087 00088 #endif/*__CTHUNK_BASE_H__*/
Generated on Tue Jul 12 2022 13:54:16 by
