mbed library sources. Supersedes mbed-src.
Dependents: Nucleo_Hello_Encoder BLE_iBeaconScan AM1805_DEMO DISCO-F429ZI_ExportTemplate1 ... more
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 /* IRQ/Exception compatible thunk entry function */ 00022 typedef void (*CThunkEntry)(void); 00023 00024 class CThunkBase { 00025 protected: 00026 typedef void (*Trampoline)(CThunkBase *); 00027 00028 Trampoline _trampoline; 00029 00030 /* 00031 * Allocate a CThunkEntry which can be called without arguments 00032 * 00033 * Calling the CThunkEntry invokes the _trampoline of the 00034 * given cthunk. This function traps if there are no more 00035 * free thunks. 00036 */ 00037 static CThunkEntry cthunk_alloc(CThunkBase *cthunk); 00038 00039 /* 00040 * Free a cthunk_entry so it can be reused 00041 */ 00042 static void cthunk_free(CThunkEntry cthunk_entry); 00043 00044 private: 00045 typedef void (*CthunkFree)(CThunkEntry cthunk_entry); 00046 00047 /* 00048 * Table of thunk functions 00049 */ 00050 static const CThunkEntry _thunk_table[MBED_CONF_PLATFORM_CTHUNK_COUNT_MAX]; 00051 00052 /* 00053 * Table of active CThunk classes 00054 */ 00055 static CThunkBase *_thunk_storage[MBED_CONF_PLATFORM_CTHUNK_COUNT_MAX]; 00056 00057 /* 00058 * Lazily initialized free function pointer 00059 */ 00060 static CthunkFree _cthunk_free_real; 00061 00062 /* 00063 * Actual free function 00064 */ 00065 static void cthunk_free_real(CThunkEntry cthunk_entry); 00066 00067 /* 00068 * Template function which stored in the _thunk_table 00069 */ 00070 template<int N> 00071 static void thunk_entry() 00072 { 00073 _thunk_storage[N]->_trampoline(_thunk_storage[N]); 00074 } 00075 }; 00076 00077 #endif/*__CTHUNK_BASE_H__*/ 00078
Generated on Tue Jul 12 2022 20:41:14 by 1.7.2