1 /*
2  * Copyright 2018 The Hafnium Authors.
3  *
4  * Use of this source code is governed by a BSD-style
5  * license that can be found in the LICENSE file or at
6  * https://opensource.org/licenses/BSD-3-Clause.
7  */
8 
9 #pragma once
10 
11 /* Define the standard types for the platform. */
12 #if defined(__linux__) && defined(__KERNEL__)
13 
14 #include <linux/types.h>
15 
16 typedef phys_addr_t hf_ipaddr_t;
17 
18 #endif
19 
20 #if defined(__ASSEMBLER__) || (defined(__linux__) && defined(__KERNEL__))
21 
22 #define INT32_C(c) c
23 #define UINT32_C(c) c##U
24 #define UINT64_C(c) c##ULL
25 
26 #else
27 
28 #include <stdbool.h>
29 #include <stddef.h>
30 #include <stdint.h>
31 
32 #include "hf/arch/vmid_base.h"
33 
34 #include "hf/vm_ids.h"
35 
36 typedef uintptr_t hf_ipaddr_t;
37 
38 #endif
39 
40 /** Sleep value for an indefinite period of time. */
41 #define HF_SLEEP_INDEFINITE 0xffffffffffffffff
42 
43 /** The amount of data that can be sent to a mailbox. */
44 #define HF_MAILBOX_SIZE 4096
45 
46 /** Interrupt ID returned when there is no interrupt pending. */
47 #define HF_INVALID_INTID 0xffffffff
48 
49 /** Interrupt ID indicating the mailbox is readable. */
50 #define HF_MAILBOX_READABLE_INTID 1
51 
52 /** Interrupt ID indicating a mailbox is writable. */
53 #define HF_MAILBOX_WRITABLE_INTID 2
54 
55 /** The virtual interrupt ID used for the virtual timer. */
56 #define HF_VIRTUAL_TIMER_INTID 3
57 
58 /** The virtual interrupt ID used for managed exit. */
59 #define HF_MANAGED_EXIT_INTID 4
60 
61 /** The virtual interrupt ID used for notification pending interrupt. */
62 #define HF_NOTIFICATION_PENDING_INTID 5
63 
64 /** The physical interrupt ID use for the schedule receiver interrupt. */
65 #define HF_SCHEDULE_RECEIVER_INTID 8
66