]> xenbits.xensource.com Git - unikraft/unikraft.git/commitdiff
arch: Define regular function calling convention register arguments
authorSergiu Moga <sergiu@unikraft.io>
Mon, 24 Mar 2025 16:34:28 +0000 (18:34 +0200)
committerUnikraft Bot <monkey@unikraft.io>
Thu, 17 Apr 2025 12:33:46 +0000 (12:33 +0000)
Define the macros that one could use to access the registers within
`struct __regs` that represent the ABI/calling convention specific
that contain the arguments (and the return value).

Signed-off-by: Sergiu Moga <sergiu@unikraft.io>
Approved-by: Michalis Pappas <michalis@unikraft.io>
Reviewed-by: Michalis Pappas <michalis@unikraft.io>
Reviewed-by: Andrei Tatar <andrei@unikraft.io>
GitHub-Closes: #1618

arch/arm/arm64/include/uk/asm/lcpu.h
arch/x86/x86_64/include/uk/asm/lcpu.h

index e1126f8d4db7c6fd95631688da0c3a046a3ff4d8..dc574119fb7ed465cfb8f0f189e727d8f159834b 100644 (file)
@@ -194,6 +194,25 @@ unsigned char tcr_ips_bits[] = {32, 36, 40, 42, 44, 48, 52};
 
 #include <uk/arch/types.h>
 
+/*
+ * Mappings of `struct __regs` register fields
+ * according to AAPCS64 definition for function calls
+ *  rargX    - Arguments 0..7
+ *  rretX    - Function call return value
+ */
+
+#define __fn_rarg0             x[0]
+#define __fn_rarg1             x[1]
+#define __fn_rarg2             x[2]
+#define __fn_rarg3             x[3]
+#define __fn_rarg4             x[4]
+#define __fn_rarg5             x[5]
+#define __fn_rarg6             x[6]
+#define __fn_rarg7             x[7]
+
+#define __fn_rret0             x[0]
+#define __fn_rret1             x[1]
+
 /*
  * Change this structure must update TRAP_STACK_SIZE at the same time.
  * This data structure must be 16-byte alignment.
index e9e727281be73e198eb2a2207d190b49f6bc410d..8946b0fc42bb7023f162cc2c20a6cb9330d2a04c 100644 (file)
 #include <uk/arch/types.h>
 #include <uk/essentials.h>
 
+/*
+ * Mappings of `struct __regs` register fields
+ * according to AMD64 SysV ABI definition for function calls
+ *  rargX    - Arguments 0..5
+ *  rretX    - Function call return value
+ */
+
+#define __fn_rarg0             rdi
+#define __fn_rarg1             rsi
+#define __fn_rarg2             rdx
+#define __fn_rarg3             rcx
+#define __fn_rarg4             r8
+#define __fn_rarg5             r9
+
+#define __fn_rret0             rax
+#define __fn_rret1             rdx
+
 struct __regs {
        unsigned long pad; /* 8 bytes to make struct size multiple of 16 */
        unsigned long r15;