1 /*
2  * This file and its contents are supplied under the terms of the
3  * Common Development and Distribution License ("CDDL"), version 1.0.
4  * You may only use this file in accordance with the terms of version
5  * 1.0 of the CDDL.
6  *
7  * A full copy of the text of the CDDL should have accompanied this
8  * source.  A copy of the CDDL is also available via the Internet at
9  * http://www.illumos.org/license/CDDL.
10  */
11 
12 /*
13  * Copyright 2023 Oxide Computer Company
14  */
15 
16 #ifndef _PAYLOAD_UTILS_H_
17 #define	_PAYLOAD_UTILS_H_
18 
19 #include <sys/types.h>
20 #include <stdbool.h>
21 
22 void outb(uint16_t, uint8_t);
23 void outw(uint16_t, uint16_t);
24 void outl(uint16_t, uint32_t);
25 uint8_t inb(uint16_t);
26 uint16_t inw(uint16_t);
27 uint32_t inl(uint16_t);
28 uint64_t rdmsr(uint32_t);
29 void wrmsr(uint32_t, uint64_t);
30 void cpuid(uint32_t, uint32_t, uint32_t *);
31 uint64_t rdtsc(void);
32 void ud2a(void);
33 
34 void test_result_pass(void);
35 void test_result_fail(void);
36 void test_msg(const char *);
37 
38 #define	__STR2(x)	#x
39 #define	__STR(x)	__STR2(x)
40 
41 #define	TEST_ABORT(msg)							\
42 	do {								\
43 		test_msg(__FILE__ ":" __STR(__LINE__) " - " msg);	\
44 		test_result_fail();					\
45 	} while (0)
46 
47 #endif /* _PAYLOAD_UTILS_H_ */
48