Milosch Meriac / CThunk

Dependents:   cthunk_example

Committer:
meriac
Date:
Wed Aug 13 07:43:23 2014 +0000
Revision:
0:7de85300ea3a
Initial Commit - F' Yeah.

Who changed what in which revision?

UserRevisionLine numberNew contents of line
meriac 0:7de85300ea3a 1 /* General C++ Object Thunking class
meriac 0:7de85300ea3a 2 *
meriac 0:7de85300ea3a 3 * - allows direct callbacks to non-static C++ class functions
meriac 0:7de85300ea3a 4 * - keeps track for the corresponding class instance
meriac 0:7de85300ea3a 5 * - supports an optional context parameter for the called function
meriac 0:7de85300ea3a 6 * - ideally suited for class object receiving interrupts (NVIC_SetVector)
meriac 0:7de85300ea3a 7 *
meriac 0:7de85300ea3a 8 * Copyright (c) 2014 ARM Limited
meriac 0:7de85300ea3a 9 *
meriac 0:7de85300ea3a 10 * Licensed under the Apache License, Version 2.0 (the "License");
meriac 0:7de85300ea3a 11 * you may not use this file except in compliance with the License.
meriac 0:7de85300ea3a 12 * You may obtain a copy of the License at
meriac 0:7de85300ea3a 13 *
meriac 0:7de85300ea3a 14 * http://www.apache.org/licenses/LICENSE-2.0
meriac 0:7de85300ea3a 15 *
meriac 0:7de85300ea3a 16 * Unless required by applicable law or agreed to in writing, software
meriac 0:7de85300ea3a 17 * distributed under the License is distributed on an "AS IS" BASIS,
meriac 0:7de85300ea3a 18 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
meriac 0:7de85300ea3a 19 * See the License for the specific language governing permissions and
meriac 0:7de85300ea3a 20 * limitations under the License.
meriac 0:7de85300ea3a 21 */
meriac 0:7de85300ea3a 22
meriac 0:7de85300ea3a 23 #include <string.h>
meriac 0:7de85300ea3a 24 #include <stdint.h>
meriac 0:7de85300ea3a 25 #include "CThunk.h"
meriac 0:7de85300ea3a 26
meriac 0:7de85300ea3a 27 #ifdef __thumb__
meriac 0:7de85300ea3a 28 const uint8_t g_cthunk_opcodes[CTHUNK_OPCODES_SIZE] = {
meriac 0:7de85300ea3a 29 /* add r0, pc, CTHUNK_OPCODES_SIZE */
meriac 0:7de85300ea3a 30 CTHUNK_OPCODES_SIZE/4, 0xA0|0,
meriac 0:7de85300ea3a 31 /* LDM R0!, {r0, r1, pc} */
meriac 0:7de85300ea3a 32 0x90, 0xE8, 0x03, 0x80,
meriac 0:7de85300ea3a 33 /* zero padding to multiples of four */
meriac 0:7de85300ea3a 34 0x00, 0x00,
meriac 0:7de85300ea3a 35 };
meriac 0:7de85300ea3a 36 #endif