Andrew Walbran | 474c439 | 2019-09-11 13:57:17 +0100 | [diff] [blame] | 1 | // SPDX-License-Identifier: Apache-2.0 |
| 2 | /* |
| 3 | * Copyright 2019 The Hafnium Authors. |
| 4 | * |
| 5 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 6 | * you may not use this file except in compliance with the License. |
| 7 | * You may obtain a copy of the License at |
| 8 | * |
| 9 | * https://www.apache.org/licenses/LICENSE-2.0 |
| 10 | * |
| 11 | * Unless required by applicable law or agreed to in writing, software |
| 12 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 14 | * See the License for the specific language governing permissions and |
| 15 | * limitations under the License. |
| 16 | */ |
| 17 | |
| 18 | #include "hf/call.h" |
| 19 | #include "hf/types.h" |
| 20 | |
| 21 | int64_t hf_call(uint64_t arg0, uint64_t arg1, uint64_t arg2, uint64_t arg3) |
| 22 | { |
| 23 | register uint64_t r0 __asm__("x0") = arg0; |
| 24 | register uint64_t r1 __asm__("x1") = arg1; |
| 25 | register uint64_t r2 __asm__("x2") = arg2; |
| 26 | register uint64_t r3 __asm__("x3") = arg3; |
| 27 | |
Andrew Walbran | 474c439 | 2019-09-11 13:57:17 +0100 | [diff] [blame] | 28 | __asm__ volatile( |
| 29 | "hvc #0" |
| 30 | : /* Output registers, also used as inputs ('+' constraint). */ |
Andrew Walbran | a989330 | 2019-09-12 16:36:05 +0100 | [diff] [blame^] | 31 | "+r"(r0), "+r"(r1), "+r"(r2), "+r"(r3) |
| 32 | : |
| 33 | : /* Clobber registers. */ |
| 34 | "x4", "x5", "x6", "x7"); |
Andrew Walbran | 474c439 | 2019-09-11 13:57:17 +0100 | [diff] [blame] | 35 | |
| 36 | return r0; |
| 37 | } |