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.
Dependencies: MAX44000 PWM_Tone_Library nexpaq_mdk
Fork of LED_Demo by
box_init.c
00001 /* 00002 * Copyright (c) 2016, 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 #include "uvisor-lib/uvisor-lib.h" 00018 #include "mbed_interface.h" 00019 #include "cmsis_os.h" 00020 #include <stdint.h> 00021 #include <string.h> 00022 00023 /* This function is called by uVisor in unprivileged mode. On this OS, we 00024 * create box main threads for the box. */ 00025 void __uvisor_lib_box_init(void * lib_config) 00026 { 00027 osThreadId thread_id; 00028 osThreadDef_t * flash_thread_def = lib_config; 00029 osThreadDef_t thread_def; 00030 00031 /* Copy thread definition from flash to RAM. The thread definition is most 00032 * likely in flash, so we need to copy it to box-local RAM before we can 00033 * modify it. */ 00034 memcpy(&thread_def, flash_thread_def, sizeof(thread_def)); 00035 00036 /* Note that the box main thread stack is separate from the box stack. This 00037 * is because the thread must be created to use a different stack than the 00038 * stack osCreateThread() is called from, as context information is saved 00039 * to the thread stack by the call to osCreateThread(). */ 00040 /* Allocate memory for the main thread from the process heap (which is 00041 * private to the process). This memory is never freed, even if the box's 00042 * main thread exits. */ 00043 thread_def.stack_pointer = malloc_p(thread_def.stacksize); 00044 00045 if (thread_def.stack_pointer == NULL) { 00046 /* No process heap memory available */ 00047 mbed_die(); 00048 } 00049 00050 thread_id = osThreadCreate(&thread_def, NULL); 00051 00052 if (thread_id == NULL) { 00053 /* Failed to create thread */ 00054 mbed_die(); 00055 } 00056 }
Generated on Tue Jul 12 2022 12:28:26 by
1.7.2
