1 /* 2 * BSD LICENSE 3 * 4 * Copyright (C) Cavium, Inc. 2017. 5 * 6 * Redistribution and use in source and binary forms, with or without 7 * modification, are permitted provided that the following conditions 8 * are met: 9 * 10 * * Redistributions of source code must retain the above copyright 11 * notice, this list of conditions and the following disclaimer. 12 * * Redistributions in binary form must reproduce the above copyright 13 * notice, this list of conditions and the following disclaimer in 14 * the documentation and/or other materials provided with the 15 * distribution. 16 * * Neither the name of Cavium, Inc nor the names of its 17 * 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 21 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 22 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 23 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 24 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 25 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 26 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 27 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 28 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 29 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 30 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 31 */ 32 33 #include <rte_common.h> 34 #include <ctx.h> 35 36 void 37 ctx_switch(struct ctx *new_ctx __rte_unused, struct ctx *curr_ctx __rte_unused) 38 { 39 /* SAVE CURRENT CONTEXT */ 40 asm volatile ( 41 /* Save SP */ 42 "mov x3, sp\n" 43 "str x3, [x1, #0]\n" 44 45 /* Save FP and LR */ 46 "stp x29, x30, [x1, #8]\n" 47 48 /* Save Callee Saved Regs x19 - x28 */ 49 "stp x19, x20, [x1, #24]\n" 50 "stp x21, x22, [x1, #40]\n" 51 "stp x23, x24, [x1, #56]\n" 52 "stp x25, x26, [x1, #72]\n" 53 "stp x27, x28, [x1, #88]\n" 54 55 /* 56 * Save bottom 64-bits of Callee Saved 57 * SIMD Regs v8 - v15 58 */ 59 "stp d8, d9, [x1, #104]\n" 60 "stp d10, d11, [x1, #120]\n" 61 "stp d12, d13, [x1, #136]\n" 62 "stp d14, d15, [x1, #152]\n" 63 ); 64 65 /* RESTORE NEW CONTEXT */ 66 asm volatile ( 67 /* Restore SP */ 68 "ldr x3, [x0, #0]\n" 69 "mov sp, x3\n" 70 71 /* Restore FP and LR */ 72 "ldp x29, x30, [x0, #8]\n" 73 74 /* Restore Callee Saved Regs x19 - x28 */ 75 "ldp x19, x20, [x0, #24]\n" 76 "ldp x21, x22, [x0, #40]\n" 77 "ldp x23, x24, [x0, #56]\n" 78 "ldp x25, x26, [x0, #72]\n" 79 "ldp x27, x28, [x0, #88]\n" 80 81 /* 82 * Restore bottom 64-bits of Callee Saved 83 * SIMD Regs v8 - v15 84 */ 85 "ldp d8, d9, [x0, #104]\n" 86 "ldp d10, d11, [x0, #120]\n" 87 "ldp d12, d13, [x0, #136]\n" 88 "ldp d14, d15, [x0, #152]\n" 89 ); 90 } 91