Milosch Meriac / CThunk

Dependents:   cthunk_example

CThunk.cpp

Committer:
meriac
Date:
2014-08-13
Revision:
0:7de85300ea3a

File content as of revision 0:7de85300ea3a:

/* General C++ Object Thunking class
 *
 * - allows direct callbacks to non-static C++ class functions
 * - keeps track for the corresponding class instance
 * - supports an optional context parameter for the called function
 * - ideally suited for class object receiving interrupts (NVIC_SetVector)
 *
 * Copyright (c) 2014 ARM Limited
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

#include <string.h>
#include <stdint.h>
#include "CThunk.h"

#ifdef __thumb__
const uint8_t g_cthunk_opcodes[CTHUNK_OPCODES_SIZE] = {
    /* add r0, pc, CTHUNK_OPCODES_SIZE   */
    CTHUNK_OPCODES_SIZE/4, 0xA0|0,
    /* LDM R0!, {r0, r1, pc}             */
    0x90, 0xE8, 0x03, 0x80,
    /* zero padding to multiples of four */
    0x00, 0x00,
};
#endif