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 <stddef.h>
29 #include <stdint.h>
30 
31 #include "hf/arch/vmid_base.h"
32 
33 #include "hf/vm_ids.h"
34 
35 typedef uintptr_t hf_ipaddr_t;
36 
37 #endif
38 
39 /** Sleep value for an indefinite period of time. */
40 #define HF_SLEEP_INDEFINITE 0xffffffffffffffff
41 
42 /** The amount of data that can be sent to a mailbox. */
43 #define HF_MAILBOX_SIZE ((size_t)4096)
44 
45 /** Interrupt ID returned when there is no interrupt pending. */
46 #define HF_INVALID_INTID UINT32_C(0xffffffff)
47 
48 /** Interrupt ID indicating the mailbox is readable. */
49 #define HF_MAILBOX_READABLE_INTID 1
50 
51 /** Interrupt ID indicating a mailbox is writable. */
52 #define HF_MAILBOX_WRITABLE_INTID 2
53 
54 /** The virtual interrupt ID used for the virtual timer. */
55 #define HF_VIRTUAL_TIMER_INTID 3
56 
57 /** The virtual interrupt ID used for managed exit. */
58 #define HF_MANAGED_EXIT_INTID 4
59 
60 /** The virtual interrupt ID used for notification pending interrupt. */
61 #define HF_NOTIFICATION_PENDING_INTID 5
62 
63 /**
64  * The interrupt ID (for both physical and virtual) used for
65  * the inter-processor interrupt.
66  */
67 #define HF_IPI_INTID 9
68 
69 /** The physical interrupt ID use for the schedule receiver interrupt. */
70 #define HF_SCHEDULE_RECEIVER_INTID 8
71