xref: /netbsd-src/sys/arch/usermode/include/types.h (revision 28b83fe374ae25c1268a59dff56f55c3a4f859c8)
1 /* $NetBSD: types.h,v 1.17 2021/04/01 04:35:47 simonb Exp $ */
2 
3 /*-
4  * Copyright (c) 2007 Jared D. McNeill <jmcneill@invisible.ca>
5  * All rights reserved.
6  *
7  * Redistribution and use in source and binary forms, with or without
8  * modification, are permitted provided that the following conditions
9  * are met:
10  * 1. Redistributions of source code must retain the above copyright
11  *    notice, this list of conditions and the following disclaimer.
12  * 2. Redistributions in binary form must reproduce the above copyright
13  *    notice, this list of conditions and the following disclaimer in the
14  *    documentation and/or other materials provided with the distribution.
15  *
16  * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
17  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
18  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
19  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
20  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
21  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
22  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
23  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
24  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
25  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
26  * POSSIBILITY OF SUCH DAMAGE.
27  */
28 
29 #ifndef _USERMODE_TYPES_H_
30 #define	_USERMODE_TYPES_H_
31 
32 #include <sys/cdefs.h>
33 #include <sys/featuretest.h>
34 #include <machine/int_types.h>
35 
36 #if defined(_KERNEL)
37 typedef struct label_t {
38 	long val[8];
39 } label_t;
40 #endif
41 
42 #if defined(_KERNEL) || defined(_KMEMUSER) || defined(_KERNTYPES) || defined(_STANDALONE)
43 #if defined(__i386__) || defined(__arm__)
44 typedef unsigned long	paddr_t;
45 typedef unsigned long	psize_t;
46 typedef unsigned long	__vaddr_t;
47 typedef unsigned long	vsize_t;
48 typedef int		register_t;
49 
50 #ifndef __x86_64__
51 // XXX hack to allow for amd64->i386 crosscompile, why?
52 #define	PRIxPADDR	"lx"
53 #define	PRIxPSIZE	"lx"
54 #define	PRIuPSIZE	"lu"
55 #else
56 #define	PRIxPADDR	"llx"
57 #define	PRIxPSIZE	"llx"
58 #define	PRIuPSIZE	"llu"
59 #endif
60 #define	PRIxVADDR	"lx"
61 #define	PRIxVSIZE	"lx"
62 #define	PRIuVSIZE	"lu"
63 #define	PRIxREGISTER	"lx"
64 #elif defined(__x86_64__)
65 typedef unsigned long	paddr_t;
66 typedef unsigned long	psize_t;
67 typedef unsigned long	__vaddr_t;
68 typedef unsigned long	vsize_t;
69 typedef long int	register_t;
70 #define	PRIxPADDR	"lx"
71 #define	PRIxPSIZE	"lx"
72 #define	PRIuPSIZE	"lu"
73 #define	PRIxVADDR	"lx"
74 #define	PRIxVSIZE	"lx"
75 #define	PRIuVSIZE	"lu"
76 #define	PRIxREGISTER	"lx"
77 #endif
78 #endif
79 
80 typedef __vaddr_t	vaddr_t;
81 typedef unsigned char	__cpu_simple_lock_nv_t;
82 typedef register_t	__register_t;
83 
84 #define	__CPU_SIMPLE_LOCK_PAD
85 
86 #define	__SIMPLELOCK_LOCKED	1
87 #define	__SIMPLELOCK_UNLOCKED	0
88 
89 #if defined(__i386__)
90 #define	__HAVE_OLD_DISKLABEL
91 #endif
92 
93 #define	__HAVE_CPU_DATA_FIRST
94 #define	__HAVE_CPU_LWP_SETPRIVATE
95 #define	__HAVE_MM_MD_KERNACC
96 #define	__HAVE_COMPAT_NETBSD32
97 
98 #endif /* !_USERMODE_TYPES_H_ */
99