1// Automatically generated. Do not modify.
2//
3// © 2021 Qualcomm Innovation Center, Inc. All rights reserved.
4//
5// SPDX-License-Identifier: BSD-3-Clause
6#extends hypercall_api
7#implements respond
8#def prefix: $public_prefix
9
10// Hypervisor Call C Types
11\#include <guest_types.h>
12// Hypervisor Call definitions
13\#include <guest_interface.h>
14
15#for hypcall_num in sorted($hypcall_dict.keys())
16    #set $hypcall = $hypcall_dict[$hypcall_num]
17    $type_signature($hypcall) {
18    #set has_pointer = False
19    #set outregs=[]
20    #for $out_reg, _ in $hypcall.outputs
21        #set outregs+=[$out_reg]
22    #end for
23    #for $in_reg, $input in $hypcall.inputs
24        #if in_reg in outregs
25        const
26        #end if
27#slurp
28        register uint${input.size * 8}_t#slurp
29        in_${in_reg}_ __asm__("$in_reg") = #slurp
30        #if $input.ignore
31        ${hex(input.default)}U;
32        #else
33        (uint${input.size * 8}_t)($register_expr($input));
34        #end if
35        #if $input.pointer
36            #set $has_pointer = True
37        #end if
38    #end for
39    #for $out_reg, $output in $hypcall.outputs
40        register uint${output.size * 8}_t#slurp
41        out_${out_reg}_ __asm__("$out_reg");
42        #if $output.pointer
43            #set $has_pointer = True
44        #end if
45    #end for
46
47    __asm__ volatile( #slurp
48    "hvc $hypcall.hvc_num" : #slurp
49    #set sep = ''
50    #for $out_reg, _ in $hypcall.outputs
51        $sep"=r"(out_${out_reg}_) #slurp
52        #set sep = ', '
53    #end for
54    #for $in_reg, _ in $hypcall.inputs
55	#if in_reg not in outregs
56        ${sep}"+r"(in_${in_reg}_) #slurp
57        #set sep = ', '
58        #end if
59    #end for
60        : #slurp
61    #set sep = ''
62    #for $in_reg, _ in $hypcall.inputs
63	#if in_reg in outregs
64        ${sep}"r"(in_${in_reg}_) #slurp
65        #set sep = ', '
66        #end if
67    #end for
68    : ${', '.join('"{:s}"'.format(c) for c in sorted($hypcall.clobbers, key=lambda x: int(x[1:])))}
69#if $has_pointer
70    , "memory"
71#end if
72    );
73
74    #if $hypcall.outputs
75    return #slurp
76    #if len($hypcall.outputs) < 2
77        $register_init($output, 'out_' + $out_reg + '_');
78    #else
79    ($return_type($hypcall)){
80    #for $out_reg, $output in $hypcall.outputs
81        .${output.name} = $register_init($output, 'out_' + $out_reg + '_'),
82    #end for
83    };
84    #end if
85    #end if
86}
87
88#end for
89