1 /* 2 * Copyright (c) 2017-2019, Texas Instruments Incorporated 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 9 * * Redistributions of source code must retain the above copyright 10 * notice, this list of conditions and the following disclaimer. 11 * 12 * * Redistributions in binary form must reproduce the above copyright 13 * notice, this list of conditions and the following disclaimer in the 14 * documentation and/or other materials provided with the distribution. 15 * 16 * * Neither the name of Texas Instruments Incorporated nor the names of 17 * its contributors may be used to endorse or promote products derived 18 * from this software without specific prior written permission. 19 * 20 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 21 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, 22 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 23 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR 24 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 25 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 26 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; 27 * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 28 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR 29 * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, 30 * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 31 */ 32 /* 33 * ======== SysCall.xdc ======== 34 */ 35 36 package ti.sysbios.family.arm.v7m; 37 38 import xdc.runtime.Error; 39 40 import ti.sysbios.interfaces.ISysCall; 41 42 /*! 43 * ======== SysCall ======== 44 * System Call Manager 45 */ 46 47 @ModuleStartup /* generate a call to startup function */ 48 49 /* REQ_TAG(SYSBIOS-1078) */ 50 module SysCall inherits ti.sysbios.interfaces.ISysCall 51 { 52 // -------- Module Constants -------- 53 54 const UInt16 NUM_SYSCALLS = 3; 55 56 // -------- Module Types -------- 57 58 /*! Callback function type definition. */ 59 typedef Void (*FuncPtr)(UArg); 60 61 // -------- Module Errors -------- 62 63 /*! 64 * Error raised when a User Task attempts to switch privilege mode. 65 * 66 * This error is raised by the system call handler if the caller's 67 * PC does not fall within the kernel wrapper function section. This 68 * typically happens if a User Task attempts to directly invoke a 69 * system call to switch the CPU's privileged mode. 70 */ 71 config Error.Id E_requestFailed = { 72 msg: "E_requestFailed: Request (Svc #%d) to switch CPU privilege denied." 73 }; 74 75 // -------- Module Config -------- 76 77 /*! 78 * ======== requestFailedFunc ======== 79 * Callback function for when a system call request is denied. 80 * Default is set to an internal function that raises an error. 81 * 82 * If the validation check performed by the system call handler fails, 83 * the request is denied and this function is called. 84 */ 85 config FuncPtr requestFailedFunc; 86 87 // -------- Module Functions -------- 88 89 @Macro 90 override Void enterPrivMode(); 91 92 @Macro 93 override Void enterUnprivMode(); 94 95 @Macro 96 override Void restorePrivMode(); 97 98 internal: 99 100 typedef Void (*SysCallFunc)(Void); 101 102 /* 103 * ======== requestFailed ======== 104 */ 105 Void requestFailed(UArg svcNum); 106 107 /* 108 * ======== enterPrivModeI ======== 109 */ 110 Void enterPrivModeI(); 111 112 /* 113 * ======== enterUnprivModeI ======== 114 */ 115 Void enterUnprivModeI(); 116 117 /* 118 * ======== restorePrivModeI ======== 119 */ 120 Void restorePrivModeI(); 121 122 /* 123 * ======== svcHandler ======== 124 */ 125 Void svcHandler(); 126 127 /*! Module state */ 128 struct Module_State { 129 SysCallFunc sysCallTable[]; // System call function table 130 } 131 }