···300300 return 0;
301301}
302302303303-void* mach_task_self_;
303303+struct task_t
304304+{
305305+ pid_t pid;
306306+};
307307+308308+static task_t mach_task_self_static = { getpid(); };
309309+task_t* mach_task_self_ = &mach_task_self_static;
304310305311// From /usr/include/mach/host_info.h
306312struct __darwin_host_basic_info {
···364370 //abort();
365371 return NULL;
366372}
367367-368373int mach_port_deallocate() {
369374 // TODO(hamaji): leak
370375 //abort();
371371- return 0;
372372-}
373373-374374-/* FIXME implement vm_function corectly.
375375- * OznOg Obviosly, all this remain completelly wrong because completely void.
376376- * This functions allow programs to start correctly and usually to run (almost)
377377- * correctly, but the memory managment remains wrong. I do not really have good ideas
378378- * to handle all this without reimplementing the whole memory managment now. Feel free
379379- * to give me some good ideas.
380380- * I do not think implementing vm_allocate vm_deallocate and vm_msync is a priority
381381- * but I guess some programs really need them to work correctly.
382382- */
383383-int vm_msync(int target_task, void** addr, size_t size, int flags) {
384384- return 0;
385385-}
386386-387387-int vm_allocate(int target_task, void** addr, size_t size, int flags) {
388388- *addr = calloc(size, 1);
389389- return 0;
390390-}
391391-392392-int vm_deallocate() {
393393- // TODO(hamaji): munmap, maybe
394376 return 0;
395377}
396378
+125
libmac/xnu/bsd/i386/_types.h
···11+/*
22+ * Copyright (c) 2000-2003 Apple Computer, Inc. All rights reserved.
33+ *
44+ * @APPLE_OSREFERENCE_LICENSE_HEADER_START@
55+ *
66+ * This file contains Original Code and/or Modifications of Original Code
77+ * as defined in and that are subject to the Apple Public Source License
88+ * Version 2.0 (the 'License'). You may not use this file except in
99+ * compliance with the License. The rights granted to you under the License
1010+ * may not be used to create, or enable the creation or redistribution of,
1111+ * unlawful or unlicensed copies of an Apple operating system, or to
1212+ * circumvent, violate, or enable the circumvention or violation of, any
1313+ * terms of an Apple operating system software license agreement.
1414+ *
1515+ * Please obtain a copy of the License at
1616+ * http://www.opensource.apple.com/apsl/ and read it before using this file.
1717+ *
1818+ * The Original Code and all software distributed under the License are
1919+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
2020+ * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
2121+ * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
2222+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
2323+ * Please see the License for the specific language governing rights and
2424+ * limitations under the License.
2525+ *
2626+ * @APPLE_OSREFERENCE_LICENSE_HEADER_END@
2727+ */
2828+#ifndef _BSD_I386__TYPES_H_
2929+#define _BSD_I386__TYPES_H_
3030+3131+/*
3232+ * This header file contains integer types. It's intended to also contain
3333+ * flotaing point and other arithmetic types, as needed, later.
3434+ */
3535+3636+/* Some of these are provided by standard Linux headers */
3737+3838+#ifdef __GNUC__
3939+typedef __signed char __int8_t;
4040+#else
4141+typedef char __int8_t;
4242+#endif
4343+typedef unsigned char __uint8_t;
4444+typedef short __int16_t;
4545+typedef unsigned short __uint16_t;
4646+typedef int __int32_t;
4747+typedef unsigned int __uint32_t;
4848+/*
4949+typedef long long __int64_t;
5050+typedef unsigned long long __uint64_t;
5151+*/
5252+typedef long __darwin_intptr_t;
5353+typedef unsigned int __darwin_natural_t;
5454+5555+/*
5656+ * The rune type below is declared to be an ``int'' instead of the more natural
5757+ * ``unsigned long'' or ``long''. Two things are happening here. It is not
5858+ * unsigned so that EOF (-1) can be naturally assigned to it and used. Also,
5959+ * it looks like 10646 will be a 31 bit standard. This means that if your
6060+ * ints cannot hold 32 bits, you will be in trouble. The reason an int was
6161+ * chosen over a long is that the is*() and to*() routines take ints (says
6262+ * ANSI C), but they use __darwin_ct_rune_t instead of int. By changing it
6363+ * here, you lose a bit of ANSI conformance, but your programs will still
6464+ * work.
6565+ *
6666+ * NOTE: rune_t is not covered by ANSI nor other standards, and should not
6767+ * be instantiated outside of lib/libc/locale. Use wchar_t. wchar_t and
6868+ * rune_t must be the same type. Also wint_t must be no narrower than
6969+ * wchar_t, and should also be able to hold all members of the largest
7070+ * character set plus one extra value (WEOF). wint_t must be at least 16 bits.
7171+ */
7272+7373+typedef int __darwin_ct_rune_t; /* ct_rune_t */
7474+7575+/*
7676+ * mbstate_t is an opaque object to keep conversion state, during multibyte
7777+ * stream conversions. The content must not be referenced by user programs.
7878+ */
7979+8080+typedef union {
8181+ char __mbstate8[128];
8282+ long long _mbstateL; /* for alignment */
8383+} __darwin_mbstate_t;
8484+8585+8686+/*typedef __mbstate_t __darwin_mbstate_t;*/
8787+8888+#if defined(__GNUC__) && defined(__PTRDIFF_TYPE__)
8989+typedef __PTRDIFF_TYPE__ __darwin_ptrdiff_t; /* ptr1 - ptr2 */
9090+#else
9191+typedef int __darwin_ptrdiff_t; /* ptr1 - ptr2 */
9292+#endif /* __GNUC__ */
9393+9494+#if defined(__GNUC__) && defined(__SIZE_TYPE__)
9595+typedef __SIZE_TYPE__ __darwin_size_t; /* sizeof() */
9696+#else
9797+typedef unsigned long __darwin_size_t; /* sizeof() */
9898+#endif
9999+100100+#if (__GNUC__ > 2)
101101+typedef __builtin_va_list __darwin_va_list; /* va_list */
102102+#else
103103+typedef void * __darwin_va_list; /* va_list */
104104+#endif
105105+106106+#if defined(__GNUC__) && defined(__WCHAR_TYPE__)
107107+typedef __WCHAR_TYPE__ __darwin_wchar_t; /* wchar_t */
108108+#else
109109+typedef __darwin_ct_rune_t __darwin_wchar_t; /* wchar_t */
110110+#endif
111111+112112+typedef __darwin_wchar_t __darwin_rune_t; /* rune_t */
113113+114114+#if defined(__GNUC__) && defined(__WINT_TYPE__)
115115+typedef __WINT_TYPE__ __darwin_wint_t; /* wint_t */
116116+#else
117117+typedef __darwin_ct_rune_t __darwin_wint_t; /* wint_t */
118118+#endif
119119+120120+typedef unsigned long __darwin_clock_t; /* clock() */
121121+typedef __uint32_t __darwin_socklen_t; /* socklen_t (duh) */
122122+typedef long __darwin_ssize_t; /* byte count or error */
123123+typedef long __darwin_time_t; /* time() */
124124+125125+#endif /* _BSD_I386__TYPES_H_ */
+62
libmac/xnu/bsd/sys/appleapiopts.h
···11+/*
22+ * Copyright (c) 2002 Apple Computer, Inc. All rights reserved.
33+ *
44+ * @APPLE_OSREFERENCE_LICENSE_HEADER_START@
55+ *
66+ * This file contains Original Code and/or Modifications of Original Code
77+ * as defined in and that are subject to the Apple Public Source License
88+ * Version 2.0 (the 'License'). You may not use this file except in
99+ * compliance with the License. The rights granted to you under the License
1010+ * may not be used to create, or enable the creation or redistribution of,
1111+ * unlawful or unlicensed copies of an Apple operating system, or to
1212+ * circumvent, violate, or enable the circumvention or violation of, any
1313+ * terms of an Apple operating system software license agreement.
1414+ *
1515+ * Please obtain a copy of the License at
1616+ * http://www.opensource.apple.com/apsl/ and read it before using this file.
1717+ *
1818+ * The Original Code and all software distributed under the License are
1919+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
2020+ * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
2121+ * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
2222+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
2323+ * Please see the License for the specific language governing rights and
2424+ * limitations under the License.
2525+ *
2626+ * @APPLE_OSREFERENCE_LICENSE_HEADER_END@
2727+ */
2828+2929+#ifndef __SYS_APPLEAPIOPTS_H__
3030+#define __SYS_APPLEAPIOPTS_H__
3131+3232+3333+#ifndef __APPLE_API_STANDARD
3434+#define __APPLE_API_STANDARD
3535+#endif /* __APPLE_API_STANDARD */
3636+3737+#ifndef __APPLE_API_STABLE
3838+#define __APPLE_API_STABLE
3939+#endif /* __APPLE_API_STABLE */
4040+4141+#ifndef __APPLE_API_STRICT_CONFORMANCE
4242+4343+#ifndef __APPLE_API_EVOLVING
4444+#define __APPLE_API_EVOLVING
4545+#endif /* __APPLE_API_EVOLVING */
4646+4747+#ifndef __APPLE_API_UNSTABLE
4848+#define __APPLE_API_UNSTABLE
4949+#endif /* __APPLE_API_UNSTABLE */
5050+5151+#ifndef __APPLE_API_PRIVATE
5252+#define __APPLE_API_PRIVATE
5353+#endif /* __APPLE_API_PRIVATE */
5454+5555+#ifndef __APPLE_API_OBSOLETE
5656+#define __APPLE_API_OBSOLETE
5757+#endif /* __APPLE_API_OBSOLETE */
5858+5959+#endif /* __APPLE_API_STRICT_CONFORMANCE */
6060+6161+#endif /* __SYS_APPLEAPIOPTS_H__ */
6262+
+88
libmac/xnu/mach/boolean.h
···11+/*
22+ * Copyright (c) 2000 Apple Computer, Inc. All rights reserved.
33+ *
44+ * @APPLE_OSREFERENCE_LICENSE_HEADER_START@
55+ *
66+ * This file contains Original Code and/or Modifications of Original Code
77+ * as defined in and that are subject to the Apple Public Source License
88+ * Version 2.0 (the 'License'). You may not use this file except in
99+ * compliance with the License. The rights granted to you under the License
1010+ * may not be used to create, or enable the creation or redistribution of,
1111+ * unlawful or unlicensed copies of an Apple operating system, or to
1212+ * circumvent, violate, or enable the circumvention or violation of, any
1313+ * terms of an Apple operating system software license agreement.
1414+ *
1515+ * Please obtain a copy of the License at
1616+ * http://www.opensource.apple.com/apsl/ and read it before using this file.
1717+ *
1818+ * The Original Code and all software distributed under the License are
1919+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
2020+ * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
2121+ * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
2222+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
2323+ * Please see the License for the specific language governing rights and
2424+ * limitations under the License.
2525+ *
2626+ * @APPLE_OSREFERENCE_LICENSE_HEADER_END@
2727+ */
2828+/*
2929+ * @OSF_COPYRIGHT@
3030+ */
3131+/*
3232+ * Mach Operating System
3333+ * Copyright (c) 1991,1990,1989,1988,1987 Carnegie Mellon University
3434+ * All Rights Reserved.
3535+ *
3636+ * Permission to use, copy, modify and distribute this software and its
3737+ * documentation is hereby granted, provided that both the copyright
3838+ * notice and this permission notice appear in all copies of the
3939+ * software, derivative works or modified versions, and any portions
4040+ * thereof, and that both notices appear in supporting documentation.
4141+ *
4242+ * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
4343+ * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR
4444+ * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
4545+ *
4646+ * Carnegie Mellon requests users of this software to return to
4747+ *
4848+ * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU
4949+ * School of Computer Science
5050+ * Carnegie Mellon University
5151+ * Pittsburgh PA 15213-3890
5252+ *
5353+ * any improvements or extensions that they make and grant Carnegie Mellon
5454+ * the rights to redistribute these changes.
5555+ */
5656+/*
5757+ */
5858+/*
5959+ * File: mach/boolean.h
6060+ *
6161+ * Boolean data type.
6262+ *
6363+ */
6464+6565+#ifndef _MACH_BOOLEAN_H_
6666+#define _MACH_BOOLEAN_H_
6767+6868+/*
6969+ * Pick up "boolean_t" type definition
7070+ */
7171+7272+#ifndef ASSEMBLER
7373+#include <mach/machine/boolean.h>
7474+#endif /* ASSEMBLER */
7575+7676+/*
7777+ * Define TRUE and FALSE if not defined.
7878+ */
7979+8080+#ifndef TRUE
8181+#define TRUE 1
8282+#endif /* TRUE */
8383+8484+#ifndef FALSE
8585+#define FALSE 0
8686+#endif /* FALSE */
8787+8888+#endif /* _MACH_BOOLEAN_H_ */
+74
libmac/xnu/mach/i386/boolean.h
···11+/*
22+ * Copyright (c) 2000-2006 Apple Computer, Inc. All rights reserved.
33+ *
44+ * @APPLE_OSREFERENCE_LICENSE_HEADER_START@
55+ *
66+ * This file contains Original Code and/or Modifications of Original Code
77+ * as defined in and that are subject to the Apple Public Source License
88+ * Version 2.0 (the 'License'). You may not use this file except in
99+ * compliance with the License. The rights granted to you under the License
1010+ * may not be used to create, or enable the creation or redistribution of,
1111+ * unlawful or unlicensed copies of an Apple operating system, or to
1212+ * circumvent, violate, or enable the circumvention or violation of, any
1313+ * terms of an Apple operating system software license agreement.
1414+ *
1515+ * Please obtain a copy of the License at
1616+ * http://www.opensource.apple.com/apsl/ and read it before using this file.
1717+ *
1818+ * The Original Code and all software distributed under the License are
1919+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
2020+ * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
2121+ * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
2222+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
2323+ * Please see the License for the specific language governing rights and
2424+ * limitations under the License.
2525+ *
2626+ * @APPLE_OSREFERENCE_LICENSE_HEADER_END@
2727+ */
2828+/*
2929+ * @OSF_COPYRIGHT@
3030+ */
3131+/*
3232+ * Mach Operating System
3333+ * Copyright (c) 1991,1990,1989 Carnegie Mellon University
3434+ * All Rights Reserved.
3535+ *
3636+ * Permission to use, copy, modify and distribute this software and its
3737+ * documentation is hereby granted, provided that both the copyright
3838+ * notice and this permission notice appear in all copies of the
3939+ * software, derivative works or modified versions, and any portions
4040+ * thereof, and that both notices appear in supporting documentation.
4141+ *
4242+ * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
4343+ * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR
4444+ * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
4545+ *
4646+ * Carnegie Mellon requests users of this software to return to
4747+ *
4848+ * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU
4949+ * School of Computer Science
5050+ * Carnegie Mellon University
5151+ * Pittsburgh PA 15213-3890
5252+ *
5353+ * any improvements or extensions that they make and grant Carnegie Mellon
5454+ * the rights to redistribute these changes.
5555+ */
5656+/*
5757+ */
5858+5959+/*
6060+ * File: boolean.h
6161+ *
6262+ * Boolean type, for I386.
6363+ */
6464+6565+#ifndef _MACH_I386_BOOLEAN_H_
6666+#define _MACH_I386_BOOLEAN_H_
6767+6868+#if defined(__x86_64__) && !defined(KERNEL)
6969+typedef unsigned int boolean_t;
7070+#else
7171+typedef int boolean_t;
7272+#endif
7373+7474+#endif /* _MACH_I386_BOOLEAN_H_ */
+74
libmac/xnu/mach/i386/kern_return.h
···11+/*
22+ * Copyright (c) 2000 Apple Computer, Inc. All rights reserved.
33+ *
44+ * @APPLE_OSREFERENCE_LICENSE_HEADER_START@
55+ *
66+ * This file contains Original Code and/or Modifications of Original Code
77+ * as defined in and that are subject to the Apple Public Source License
88+ * Version 2.0 (the 'License'). You may not use this file except in
99+ * compliance with the License. The rights granted to you under the License
1010+ * may not be used to create, or enable the creation or redistribution of,
1111+ * unlawful or unlicensed copies of an Apple operating system, or to
1212+ * circumvent, violate, or enable the circumvention or violation of, any
1313+ * terms of an Apple operating system software license agreement.
1414+ *
1515+ * Please obtain a copy of the License at
1616+ * http://www.opensource.apple.com/apsl/ and read it before using this file.
1717+ *
1818+ * The Original Code and all software distributed under the License are
1919+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
2020+ * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
2121+ * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
2222+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
2323+ * Please see the License for the specific language governing rights and
2424+ * limitations under the License.
2525+ *
2626+ * @APPLE_OSREFERENCE_LICENSE_HEADER_END@
2727+ */
2828+/*
2929+ * @OSF_COPYRIGHT@
3030+ */
3131+/*
3232+ * Mach Operating System
3333+ * Copyright (c) 1991,1990,1989 Carnegie Mellon University
3434+ * All Rights Reserved.
3535+ *
3636+ * Permission to use, copy, modify and distribute this software and its
3737+ * documentation is hereby granted, provided that both the copyright
3838+ * notice and this permission notice appear in all copies of the
3939+ * software, derivative works or modified versions, and any portions
4040+ * thereof, and that both notices appear in supporting documentation.
4141+ *
4242+ * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
4343+ * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR
4444+ * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
4545+ *
4646+ * Carnegie Mellon requests users of this software to return to
4747+ *
4848+ * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU
4949+ * School of Computer Science
5050+ * Carnegie Mellon University
5151+ * Pittsburgh PA 15213-3890
5252+ *
5353+ * any improvements or extensions that they make and grant Carnegie Mellon
5454+ * the rights to redistribute these changes.
5555+ */
5656+/*
5757+ */
5858+5959+/*
6060+ * File: kern_return.h
6161+ * Author: Avadis Tevanian, Jr., Michael Wayne Young
6262+ * Date: 1985
6363+ *
6464+ * Machine-dependent kernel return definitions.
6565+ */
6666+6767+#ifndef _MACH_I386_KERN_RETURN_H_
6868+#define _MACH_I386_KERN_RETURN_H_
6969+7070+#ifndef ASSEMBLER
7171+typedef int kern_return_t;
7272+#endif /* ASSEMBLER */
7373+7474+#endif /* _MACH_I386_KERN_RETURN_H_ */
+298
libmac/xnu/mach/i386/vm_param.h
···11+/*
22+ * Copyright (c) 2000-2006 Apple Computer, Inc. All rights reserved.
33+ *
44+ * @APPLE_OSREFERENCE_LICENSE_HEADER_START@
55+ *
66+ * This file contains Original Code and/or Modifications of Original Code
77+ * as defined in and that are subject to the Apple Public Source License
88+ * Version 2.0 (the 'License'). You may not use this file except in
99+ * compliance with the License. The rights granted to you under the License
1010+ * may not be used to create, or enable the creation or redistribution of,
1111+ * unlawful or unlicensed copies of an Apple operating system, or to
1212+ * circumvent, violate, or enable the circumvention or violation of, any
1313+ * terms of an Apple operating system software license agreement.
1414+ *
1515+ * Please obtain a copy of the License at
1616+ * http://www.opensource.apple.com/apsl/ and read it before using this file.
1717+ *
1818+ * The Original Code and all software distributed under the License are
1919+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
2020+ * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
2121+ * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
2222+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
2323+ * Please see the License for the specific language governing rights and
2424+ * limitations under the License.
2525+ *
2626+ * @APPLE_OSREFERENCE_LICENSE_HEADER_END@
2727+ */
2828+/*
2929+ * @OSF_COPYRIGHT@
3030+ */
3131+/*
3232+ * Mach Operating System
3333+ * Copyright (c) 1991,1990,1989,1988 Carnegie Mellon University
3434+ * All Rights Reserved.
3535+ *
3636+ * Permission to use, copy, modify and distribute this software and its
3737+ * documentation is hereby granted, provided that both the copyright
3838+ * notice and this permission notice appear in all copies of the
3939+ * software, derivative works or modified versions, and any portions
4040+ * thereof, and that both notices appear in supporting documentation.
4141+ *
4242+ * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
4343+ * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR
4444+ * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
4545+ *
4646+ * Carnegie Mellon requests users of this software to return to
4747+ *
4848+ * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU
4949+ * School of Computer Science
5050+ * Carnegie Mellon University
5151+ * Pittsburgh PA 15213-3890
5252+ *
5353+ * any improvements or extensions that they make and grant Carnegie Mellon
5454+ * the rights to redistribute these changes.
5555+ */
5656+5757+/*
5858+ * Copyright (c) 1994 The University of Utah and
5959+ * the Computer Systems Laboratory at the University of Utah (CSL).
6060+ * All rights reserved.
6161+ *
6262+ * Permission to use, copy, modify and distribute this software is hereby
6363+ * granted provided that (1) source code retains these copyright, permission,
6464+ * and disclaimer notices, and (2) redistributions including binaries
6565+ * reproduce the notices in supporting documentation, and (3) all advertising
6666+ * materials mentioning features or use of this software display the following
6767+ * acknowledgement: ``This product includes software developed by the
6868+ * Computer Systems Laboratory at the University of Utah.''
6969+ *
7070+ * THE UNIVERSITY OF UTAH AND CSL ALLOW FREE USE OF THIS SOFTWARE IN ITS "AS
7171+ * IS" CONDITION. THE UNIVERSITY OF UTAH AND CSL DISCLAIM ANY LIABILITY OF
7272+ * ANY KIND FOR ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
7373+ *
7474+ * CSL requests users of this software to return to csl-dist@cs.utah.edu any
7575+ * improvements that they make and grant CSL redistribution rights.
7676+ *
7777+ */
7878+7979+/*
8080+ * File: vm_param.h
8181+ * Author: Avadis Tevanian, Jr.
8282+ * Date: 1985
8383+ *
8484+ * I386 machine dependent virtual memory parameters.
8585+ * Most of the declarations are preceeded by I386_ (or i386_)
8686+ * which is OK because only I386 specific code will be using
8787+ * them.
8888+ */
8989+9090+#ifndef _MACH_I386_VM_PARAM_H_
9191+#define _MACH_I386_VM_PARAM_H_
9292+9393+#define BYTE_SIZE 8 /* byte size in bits */
9494+9595+#define I386_PGBYTES 4096 /* bytes per 80386 page */
9696+#define I386_PGSHIFT 12 /* bitshift for pages */
9797+9898+#define PAGE_SIZE I386_PGBYTES
9999+#define PAGE_SHIFT I386_PGSHIFT
100100+#define PAGE_MASK (PAGE_SIZE - 1)
101101+102102+#define I386_LPGBYTES 2*1024*1024 /* bytes per large page */
103103+#define I386_LPGSHIFT 21 /* bitshift for large pages */
104104+#define I386_LPGMASK (I386_LPGBYTES-1)
105105+106106+/*
107107+ * Convert bytes to pages and convert pages to bytes.
108108+ * No rounding is used.
109109+ */
110110+111111+#define i386_btop(x) ((ppnum_t)((x) >> I386_PGSHIFT))
112112+#define machine_btop(x) i386_btop(x)
113113+#define i386_ptob(x) (((pmap_paddr_t)(x)) << I386_PGSHIFT)
114114+#define machine_ptob(x) i386_ptob(x)
115115+116116+/*
117117+ * Round off or truncate to the nearest page. These will work
118118+ * for either addresses or counts. (i.e. 1 byte rounds to 1 page
119119+ * bytes.
120120+ */
121121+122122+#define i386_round_page(x) ((((pmap_paddr_t)(x)) + I386_PGBYTES - 1) & \
123123+ ~(I386_PGBYTES-1))
124124+#define i386_trunc_page(x) (((pmap_paddr_t)(x)) & ~(I386_PGBYTES-1))
125125+126126+127127+128128+#define VM_MIN_ADDRESS64 ((user_addr_t) 0x0000000000000000ULL)
129129+/*
130130+ * default top of user stack... it grows down from here
131131+ */
132132+#define VM_USRSTACK64 ((user_addr_t) 0x00007FFF5FC00000ULL)
133133+#define VM_DYLD64 ((user_addr_t) 0x00007FFF5FC00000ULL)
134134+#define VM_LIB64_SHR_DATA ((user_addr_t) 0x00007FFF60000000ULL)
135135+#define VM_LIB64_SHR_TEXT ((user_addr_t) 0x00007FFF80000000ULL)
136136+/*
137137+ * the end of the usable user address space , for now about 47 bits.
138138+ * the 64 bit commpage is past the end of this
139139+ */
140140+#define VM_MAX_PAGE_ADDRESS ((user_addr_t) 0x00007FFFFFE00000ULL)
141141+/*
142142+ * canonical end of user address space for limits checking
143143+ */
144144+#define VM_MAX_USER_PAGE_ADDRESS ((user_addr_t)0x00007FFFFFFFF000ULL)
145145+146146+147147+/* system-wide values */
148148+#define MACH_VM_MIN_ADDRESS ((mach_vm_offset_t) 0)
149149+#define MACH_VM_MAX_ADDRESS ((mach_vm_offset_t) VM_MAX_PAGE_ADDRESS)
150150+151151+/* process-relative values (all 32-bit legacy only for now) */
152152+#define VM_MIN_ADDRESS ((vm_offset_t) 0)
153153+#define VM_USRSTACK32 ((vm_offset_t) 0xC0000000) /* ASLR slides stack down by up to 1 MB */
154154+#define VM_MAX_ADDRESS ((vm_offset_t) 0xFFE00000)
155155+156156+157157+#ifdef KERNEL_PRIVATE
158158+159159+/* Kernel-wide values */
160160+161161+#define KB (1024ULL)
162162+#define MB (1024*KB)
163163+#define GB (1024*MB)
164164+165165+/*
166166+ * Maximum physical memory supported.
167167+ */
168168+#define K32_MAXMEM (32*GB)
169169+#define K64_MAXMEM (96*GB)
170170+#if defined(__i386__)
171171+#define KERNEL_MAXMEM K32_MAXMEM
172172+#else
173173+#define KERNEL_MAXMEM K64_MAXMEM
174174+#endif
175175+176176+/*
177177+ * XXX
178178+ * The kernel max VM address is limited to 0xFF3FFFFF for now because
179179+ * some data structures are explicitly allocated at 0xFF400000 without
180180+ * VM's knowledge (see osfmk/i386/locore.s for the allocation of PTmap and co.).
181181+ * We can't let VM allocate memory from there.
182182+ */
183183+184184+#if defined(__i386__)
185185+186186+#define KERNEL_IMAGE_TO_PHYS(x) (x)
187187+#define VM_MIN_KERNEL_ADDRESS ((vm_offset_t) 0x00001000U)
188188+#define VM_MIN_KERNEL_AND_KEXT_ADDRESS VM_MIN_KERNEL_ADDRESS
189189+#define VM_MAX_KERNEL_ADDRESS ((vm_offset_t) 0xFE7FFFFFU)
190190+191191+#elif defined(__x86_64__)
192192+193193+#define KERNEL_IMAGE_TO_PHYS(x) (x)
194194+#define VM_MIN_KERNEL_ADDRESS ((vm_offset_t) 0xFFFFFF8000000000UL)
195195+#define VM_MIN_KERNEL_PAGE ((ppnum_t)0)
196196+#define VM_MIN_KERNEL_AND_KEXT_ADDRESS (VM_MIN_KERNEL_ADDRESS - 0x80000000ULL)
197197+#define VM_MAX_KERNEL_ADDRESS ((vm_offset_t) 0xFFFFFFFFFFFFEFFFUL)
198198+#define VM_MAX_KERNEL_ADDRESS_EFI32 ((vm_offset_t) 0xFFFFFF80FFFFEFFFUL)
199199+#define KEXT_ALLOC_MAX_OFFSET (2 * 1024 * 1024 * 1024UL)
200200+#define KEXT_ALLOC_BASE(x) ((x) - KEXT_ALLOC_MAX_OFFSET)
201201+#define KEXT_ALLOC_SIZE(x) (KEXT_ALLOC_MAX_OFFSET - (x))
202202+203203+#define VM_KERNEL_IS_KEXT(_o) \
204204+ (((vm_offset_t)(_o) >= VM_MIN_KERNEL_AND_KEXT_ADDRESS) && \
205205+ ((vm_offset_t)(_o) < VM_MIN_KERNEL_ADDRESS))
206206+207207+#else
208208+#error unsupported architecture
209209+#endif
210210+211211+#define KERNEL_STACK_SIZE (I386_PGBYTES*4)
212212+213213+#define VM_MAP_MIN_ADDRESS MACH_VM_MIN_ADDRESS
214214+#define VM_MAP_MAX_ADDRESS MACH_VM_MAX_ADDRESS
215215+216216+/* FIXME - always leave like this? */
217217+#define INTSTACK_SIZE (I386_PGBYTES*4)
218218+219219+#ifdef MACH_KERNEL_PRIVATE
220220+221221+/* For implementing legacy 32-bit interfaces */
222222+#define VM32_SUPPORT 1
223223+#define VM32_MIN_ADDRESS ((vm32_offset_t) 0)
224224+#define VM32_MAX_ADDRESS ((vm32_offset_t) (VM_MAX_PAGE_ADDRESS & 0xFFFFFFFF))
225225+226226+/*
227227+ * kalloc() parameters:
228228+ *
229229+ * Historically kalloc's underlying zones were power-of-2 sizes, with a
230230+ * KALLOC_MINSIZE of 16 bytes. The allocator ensured that
231231+ * (sizeof == alignof) >= 16 for all kalloc allocations.
232232+ *
233233+ * Today kalloc may use zones with intermediate sizes, constrained by
234234+ * KALLOC_MINSIZE and a minimum alignment, expressed by KALLOC_LOG2_MINALIGN.
235235+ *
236236+ * The common alignment for LP64 is for longs and pointers i.e. 8 bytes.
237237+ */
238238+239239+#if defined(__i386__)
240240+241241+#define KALLOC_MINSIZE 16 /* minimum allocation size */
242242+#define KALLOC_LOG2_MINALIGN 4 /* log2 minimum alignment */
243243+244244+#define LINEAR_KERNEL_ADDRESS ((vm_offset_t) 0x00000000)
245245+246246+#define VM_MIN_KERNEL_LOADED_ADDRESS ((vm_offset_t) 0x00000000U)
247247+#define VM_MAX_KERNEL_LOADED_ADDRESS ((vm_offset_t) 0x1FFFFFFFU)
248248+249249+#define NCOPY_WINDOWS 4
250250+251251+#elif defined(__x86_64__)
252252+253253+#define KALLOC_MINSIZE 16 /* minimum allocation size */
254254+#define KALLOC_LOG2_MINALIGN 4 /* log2 minimum alignment */
255255+256256+#define LINEAR_KERNEL_ADDRESS ((vm_offset_t) 0x00000000)
257257+258258+#define VM_MIN_KERNEL_LOADED_ADDRESS ((vm_offset_t) 0xFFFFFF8000000000UL)
259259+#define VM_MAX_KERNEL_LOADED_ADDRESS ((vm_offset_t) 0xFFFFFF801FFFFFFFUL)
260260+261261+#define NCOPY_WINDOWS 0
262262+263263+264264+#else
265265+#error unsupported architecture
266266+#endif
267267+268268+/*
269269+ * Conversion between 80386 pages and VM pages
270270+ */
271271+272272+#define trunc_i386_to_vm(p) (atop(trunc_page(i386_ptob(p))))
273273+#define round_i386_to_vm(p) (atop(round_page(i386_ptob(p))))
274274+#define vm_to_i386(p) (i386_btop(ptoa(p)))
275275+276276+277277+#define PMAP_SET_CACHE_ATTR(mem, object, cache_attr, batch_pmap_op) \
278278+ MACRO_BEGIN \
279279+ pmap_set_cache_attributes((mem)->phys_page, (cache_attr)); \
280280+ (object)->set_cache_attr = TRUE; \
281281+ (void) batch_pmap_op; \
282282+ MACRO_END
283283+284284+#define PMAP_BATCH_SET_CACHE_ATTR(object, user_page_list, cache_attr, num_pages, batch_pmap_op)\
285285+ MACRO_BEGIN \
286286+ (void) user_page_list; \
287287+ (void) num_pages; \
288288+ (void) batch_pmap_op; \
289289+ MACRO_END
290290+291291+#define IS_USERADDR64_CANONICAL(addr) \
292292+ ((addr) < (VM_MAX_USER_PAGE_ADDRESS + PAGE_SIZE))
293293+294294+#endif /* MACH_KERNEL_PRIVATE */
295295+296296+#endif /* KERNEL_PRIVATE */
297297+298298+#endif /* _MACH_I386_VM_PARAM_H_ */
+157
libmac/xnu/mach/i386/vm_types.h
···11+/*
22+ * Copyright (c) 2000-2006 Apple Computer, Inc. All rights reserved.
33+ *
44+ * @APPLE_OSREFERENCE_LICENSE_HEADER_START@
55+ *
66+ * This file contains Original Code and/or Modifications of Original Code
77+ * as defined in and that are subject to the Apple Public Source License
88+ * Version 2.0 (the 'License'). You may not use this file except in
99+ * compliance with the License. The rights granted to you under the License
1010+ * may not be used to create, or enable the creation or redistribution of,
1111+ * unlawful or unlicensed copies of an Apple operating system, or to
1212+ * circumvent, violate, or enable the circumvention or violation of, any
1313+ * terms of an Apple operating system software license agreement.
1414+ *
1515+ * Please obtain a copy of the License at
1616+ * http://www.opensource.apple.com/apsl/ and read it before using this file.
1717+ *
1818+ * The Original Code and all software distributed under the License are
1919+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
2020+ * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
2121+ * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
2222+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
2323+ * Please see the License for the specific language governing rights and
2424+ * limitations under the License.
2525+ *
2626+ * @APPLE_OSREFERENCE_LICENSE_HEADER_END@
2727+ */
2828+/*
2929+ * @OSF_COPYRIGHT@
3030+ */
3131+/*
3232+ * Mach Operating System
3333+ * Copyright (c) 1991,1990,1989,1988 Carnegie Mellon University
3434+ * All Rights Reserved.
3535+ *
3636+ * Permission to use, copy, modify and distribute this software and its
3737+ * documentation is hereby granted, provided that both the copyright
3838+ * notice and this permission notice appear in all copies of the
3939+ * software, derivative works or modified versions, and any portions
4040+ * thereof, and that both notices appear in supporting documentation.
4141+ *
4242+ * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
4343+ * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR
4444+ * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
4545+ *
4646+ * Carnegie Mellon requests users of this software to return to
4747+ *
4848+ * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU
4949+ * School of Computer Science
5050+ * Carnegie Mellon University
5151+ * Pittsburgh PA 15213-3890
5252+ *
5353+ * any improvements or extensions that they make and grant Carnegie Mellon
5454+ * the rights to redistribute these changes.
5555+ */
5656+/*
5757+ */
5858+5959+/*
6060+ * File: vm_types.h
6161+ * Author: Avadis Tevanian, Jr.
6262+ * Date: 1985
6363+ *
6464+ * Header file for VM data types. I386 version.
6565+ */
6666+6767+#ifndef _MACH_I386_VM_TYPES_H_
6868+#define _MACH_I386_VM_TYPES_H_
6969+7070+#ifndef ASSEMBLER
7171+7272+#include <i386/_types.h>
7373+#include <mach/i386/vm_param.h>
7474+#include <stdint.h>
7575+7676+/*
7777+ * natural_t and integer_t are Mach's legacy types for machine-
7878+ * independent integer types (unsigned, and signed, respectively).
7979+ * Their original purpose was to define other types in a machine/
8080+ * compiler independent way.
8181+ *
8282+ * They also had an implicit "same size as pointer" characteristic
8383+ * to them (i.e. Mach's traditional types are very ILP32 or ILP64
8484+ * centric). We support x86 ABIs that do not follow either of
8585+ * these models (specifically LP64). Therefore, we had to make a
8686+ * choice between making these types scale with pointers or stay
8787+ * tied to integers. Because their use is predominantly tied to
8888+ * to the size of an integer, we are keeping that association and
8989+ * breaking free from pointer size guarantees.
9090+ *
9191+ * New use of these types is discouraged.
9292+ */
9393+typedef __darwin_natural_t natural_t;
9494+typedef int integer_t;
9595+9696+/*
9797+ * A vm_offset_t is a type-neutral pointer,
9898+ * e.g. an offset into a virtual memory space.
9999+ */
100100+#ifdef __LP64__
101101+typedef uintptr_t vm_offset_t;
102102+#else /* __LP64__ */
103103+typedef natural_t vm_offset_t;
104104+#endif /* __LP64__ */
105105+106106+/*
107107+ * A vm_size_t is the proper type for e.g.
108108+ * expressing the difference between two
109109+ * vm_offset_t entities.
110110+ */
111111+#ifdef __LP64__
112112+typedef uintptr_t vm_size_t;
113113+#else /* __LP64__ */
114114+typedef natural_t vm_size_t;
115115+#endif /* __LP64__ */
116116+117117+/*
118118+ * This new type is independent of a particular vm map's
119119+ * implementation size - and represents appropriate types
120120+ * for all possible maps. This is used for interfaces
121121+ * where the size of the map is not known - or we don't
122122+ * want to have to distinguish.
123123+ */
124124+typedef uint64_t mach_vm_address_t;
125125+typedef uint64_t mach_vm_offset_t;
126126+typedef uint64_t mach_vm_size_t;
127127+128128+typedef uint64_t vm_map_offset_t;
129129+typedef uint64_t vm_map_address_t;
130130+typedef uint64_t vm_map_size_t;
131131+132132+typedef mach_vm_address_t mach_port_context_t;
133133+134134+#ifdef MACH_KERNEL_PRIVATE
135135+136136+#if VM32_SUPPORT
137137+138138+/*
139139+ * These are types used internal to Mach to implement the
140140+ * legacy 32-bit VM APIs published by the kernel.
141141+ */
142142+typedef uint32_t vm32_address_t;
143143+typedef uint32_t vm32_offset_t;
144144+typedef uint32_t vm32_size_t;
145145+146146+#endif /* VM32_SUPPORT */
147147+148148+#endif /* MACH_KERNEL_PRIVATE */
149149+150150+#endif /* ASSEMBLER */
151151+152152+/*
153153+ * If composing messages by hand (please do not)
154154+ */
155155+#define MACH_MSG_TYPE_INTEGER_T MACH_MSG_TYPE_INTEGER_32
156156+157157+#endif /* _MACH_I386_VM_TYPES_H_ */
+322
libmac/xnu/mach/kern_return.h
···11+/*
22+ * Copyright (c) 2000 Apple Computer, Inc. All rights reserved.
33+ *
44+ * @APPLE_OSREFERENCE_LICENSE_HEADER_START@
55+ *
66+ * This file contains Original Code and/or Modifications of Original Code
77+ * as defined in and that are subject to the Apple Public Source License
88+ * Version 2.0 (the 'License'). You may not use this file except in
99+ * compliance with the License. The rights granted to you under the License
1010+ * may not be used to create, or enable the creation or redistribution of,
1111+ * unlawful or unlicensed copies of an Apple operating system, or to
1212+ * circumvent, violate, or enable the circumvention or violation of, any
1313+ * terms of an Apple operating system software license agreement.
1414+ *
1515+ * Please obtain a copy of the License at
1616+ * http://www.opensource.apple.com/apsl/ and read it before using this file.
1717+ *
1818+ * The Original Code and all software distributed under the License are
1919+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
2020+ * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
2121+ * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
2222+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
2323+ * Please see the License for the specific language governing rights and
2424+ * limitations under the License.
2525+ *
2626+ * @APPLE_OSREFERENCE_LICENSE_HEADER_END@
2727+ */
2828+/*
2929+ * @OSF_COPYRIGHT@
3030+ */
3131+/*
3232+ * Mach Operating System
3333+ * Copyright (c) 1991,1990,1989,1988,1987 Carnegie Mellon University
3434+ * All Rights Reserved.
3535+ *
3636+ * Permission to use, copy, modify and distribute this software and its
3737+ * documentation is hereby granted, provided that both the copyright
3838+ * notice and this permission notice appear in all copies of the
3939+ * software, derivative works or modified versions, and any portions
4040+ * thereof, and that both notices appear in supporting documentation.
4141+ *
4242+ * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
4343+ * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR
4444+ * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
4545+ *
4646+ * Carnegie Mellon requests users of this software to return to
4747+ *
4848+ * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU
4949+ * School of Computer Science
5050+ * Carnegie Mellon University
5151+ * Pittsburgh PA 15213-3890
5252+ *
5353+ * any improvements or extensions that they make and grant Carnegie Mellon
5454+ * the rights to redistribute these changes.
5555+ */
5656+/*
5757+ */
5858+/*
5959+ * File: h/kern_return.h
6060+ * Author: Avadis Tevanian, Jr.
6161+ * Date: 1985
6262+ *
6363+ * Kernel return codes.
6464+ *
6565+ */
6666+6767+#ifndef _MACH_KERN_RETURN_H_
6868+#define _MACH_KERN_RETURN_H_
6969+7070+#include <mach/machine/kern_return.h>
7171+7272+#define KERN_SUCCESS 0
7373+7474+#define KERN_INVALID_ADDRESS 1
7575+ /* Specified address is not currently valid.
7676+ */
7777+7878+#define KERN_PROTECTION_FAILURE 2
7979+ /* Specified memory is valid, but does not permit the
8080+ * required forms of access.
8181+ */
8282+8383+#define KERN_NO_SPACE 3
8484+ /* The address range specified is already in use, or
8585+ * no address range of the size specified could be
8686+ * found.
8787+ */
8888+8989+#define KERN_INVALID_ARGUMENT 4
9090+ /* The function requested was not applicable to this
9191+ * type of argument, or an argument is invalid
9292+ */
9393+9494+#define KERN_FAILURE 5
9595+ /* The function could not be performed. A catch-all.
9696+ */
9797+9898+#define KERN_RESOURCE_SHORTAGE 6
9999+ /* A system resource could not be allocated to fulfill
100100+ * this request. This failure may not be permanent.
101101+ */
102102+103103+#define KERN_NOT_RECEIVER 7
104104+ /* The task in question does not hold receive rights
105105+ * for the port argument.
106106+ */
107107+108108+#define KERN_NO_ACCESS 8
109109+ /* Bogus access restriction.
110110+ */
111111+112112+#define KERN_MEMORY_FAILURE 9
113113+ /* During a page fault, the target address refers to a
114114+ * memory object that has been destroyed. This
115115+ * failure is permanent.
116116+ */
117117+118118+#define KERN_MEMORY_ERROR 10
119119+ /* During a page fault, the memory object indicated
120120+ * that the data could not be returned. This failure
121121+ * may be temporary; future attempts to access this
122122+ * same data may succeed, as defined by the memory
123123+ * object.
124124+ */
125125+126126+#define KERN_ALREADY_IN_SET 11
127127+ /* The receive right is already a member of the portset.
128128+ */
129129+130130+#define KERN_NOT_IN_SET 12
131131+ /* The receive right is not a member of a port set.
132132+ */
133133+134134+#define KERN_NAME_EXISTS 13
135135+ /* The name already denotes a right in the task.
136136+ */
137137+138138+#define KERN_ABORTED 14
139139+ /* The operation was aborted. Ipc code will
140140+ * catch this and reflect it as a message error.
141141+ */
142142+143143+#define KERN_INVALID_NAME 15
144144+ /* The name doesn't denote a right in the task.
145145+ */
146146+147147+#define KERN_INVALID_TASK 16
148148+ /* Target task isn't an active task.
149149+ */
150150+151151+#define KERN_INVALID_RIGHT 17
152152+ /* The name denotes a right, but not an appropriate right.
153153+ */
154154+155155+#define KERN_INVALID_VALUE 18
156156+ /* A blatant range error.
157157+ */
158158+159159+#define KERN_UREFS_OVERFLOW 19
160160+ /* Operation would overflow limit on user-references.
161161+ */
162162+163163+#define KERN_INVALID_CAPABILITY 20
164164+ /* The supplied (port) capability is improper.
165165+ */
166166+167167+#define KERN_RIGHT_EXISTS 21
168168+ /* The task already has send or receive rights
169169+ * for the port under another name.
170170+ */
171171+172172+#define KERN_INVALID_HOST 22
173173+ /* Target host isn't actually a host.
174174+ */
175175+176176+#define KERN_MEMORY_PRESENT 23
177177+ /* An attempt was made to supply "precious" data
178178+ * for memory that is already present in a
179179+ * memory object.
180180+ */
181181+182182+#define KERN_MEMORY_DATA_MOVED 24
183183+ /* A page was requested of a memory manager via
184184+ * memory_object_data_request for an object using
185185+ * a MEMORY_OBJECT_COPY_CALL strategy, with the
186186+ * VM_PROT_WANTS_COPY flag being used to specify
187187+ * that the page desired is for a copy of the
188188+ * object, and the memory manager has detected
189189+ * the page was pushed into a copy of the object
190190+ * while the kernel was walking the shadow chain
191191+ * from the copy to the object. This error code
192192+ * is delivered via memory_object_data_error
193193+ * and is handled by the kernel (it forces the
194194+ * kernel to restart the fault). It will not be
195195+ * seen by users.
196196+ */
197197+198198+#define KERN_MEMORY_RESTART_COPY 25
199199+ /* A strategic copy was attempted of an object
200200+ * upon which a quicker copy is now possible.
201201+ * The caller should retry the copy using
202202+ * vm_object_copy_quickly. This error code
203203+ * is seen only by the kernel.
204204+ */
205205+206206+#define KERN_INVALID_PROCESSOR_SET 26
207207+ /* An argument applied to assert processor set privilege
208208+ * was not a processor set control port.
209209+ */
210210+211211+#define KERN_POLICY_LIMIT 27
212212+ /* The specified scheduling attributes exceed the thread's
213213+ * limits.
214214+ */
215215+216216+#define KERN_INVALID_POLICY 28
217217+ /* The specified scheduling policy is not currently
218218+ * enabled for the processor set.
219219+ */
220220+221221+#define KERN_INVALID_OBJECT 29
222222+ /* The external memory manager failed to initialize the
223223+ * memory object.
224224+ */
225225+226226+#define KERN_ALREADY_WAITING 30
227227+ /* A thread is attempting to wait for an event for which
228228+ * there is already a waiting thread.
229229+ */
230230+231231+#define KERN_DEFAULT_SET 31
232232+ /* An attempt was made to destroy the default processor
233233+ * set.
234234+ */
235235+236236+#define KERN_EXCEPTION_PROTECTED 32
237237+ /* An attempt was made to fetch an exception port that is
238238+ * protected, or to abort a thread while processing a
239239+ * protected exception.
240240+ */
241241+242242+#define KERN_INVALID_LEDGER 33
243243+ /* A ledger was required but not supplied.
244244+ */
245245+246246+#define KERN_INVALID_MEMORY_CONTROL 34
247247+ /* The port was not a memory cache control port.
248248+ */
249249+250250+#define KERN_INVALID_SECURITY 35
251251+ /* An argument supplied to assert security privilege
252252+ * was not a host security port.
253253+ */
254254+255255+#define KERN_NOT_DEPRESSED 36
256256+ /* thread_depress_abort was called on a thread which
257257+ * was not currently depressed.
258258+ */
259259+260260+#define KERN_TERMINATED 37
261261+ /* Object has been terminated and is no longer available
262262+ */
263263+264264+#define KERN_LOCK_SET_DESTROYED 38
265265+ /* Lock set has been destroyed and is no longer available.
266266+ */
267267+268268+#define KERN_LOCK_UNSTABLE 39
269269+ /* The thread holding the lock terminated before releasing
270270+ * the lock
271271+ */
272272+273273+#define KERN_LOCK_OWNED 40
274274+ /* The lock is already owned by another thread
275275+ */
276276+277277+#define KERN_LOCK_OWNED_SELF 41
278278+ /* The lock is already owned by the calling thread
279279+ */
280280+281281+#define KERN_SEMAPHORE_DESTROYED 42
282282+ /* Semaphore has been destroyed and is no longer available.
283283+ */
284284+285285+#define KERN_RPC_SERVER_TERMINATED 43
286286+ /* Return from RPC indicating the target server was
287287+ * terminated before it successfully replied
288288+ */
289289+290290+#define KERN_RPC_TERMINATE_ORPHAN 44
291291+ /* Terminate an orphaned activation.
292292+ */
293293+294294+#define KERN_RPC_CONTINUE_ORPHAN 45
295295+ /* Allow an orphaned activation to continue executing.
296296+ */
297297+298298+#define KERN_NOT_SUPPORTED 46
299299+ /* Empty thread activation (No thread linked to it)
300300+ */
301301+302302+#define KERN_NODE_DOWN 47
303303+ /* Remote node down or inaccessible.
304304+ */
305305+306306+#define KERN_NOT_WAITING 48
307307+ /* A signalled thread was not actually waiting. */
308308+309309+#define KERN_OPERATION_TIMED_OUT 49
310310+ /* Some thread-oriented operation (semaphore_wait) timed out
311311+ */
312312+313313+#define KERN_CODESIGN_ERROR 50
314314+ /* During a page fault, indicates that the page was rejected
315315+ * as a result of a signature check.
316316+ */
317317+318318+#define KERN_RETURN_MAX 0x100
319319+ /* Maximum return value allowable
320320+ */
321321+322322+#endif /* _MACH_KERN_RETURN_H_ */
+38
libmac/xnu/mach/machine/boolean.h
···11+/*
22+ * Copyright (c) 2000-2007 Apple Inc. All rights reserved.
33+ *
44+ * @APPLE_OSREFERENCE_LICENSE_HEADER_START@
55+ *
66+ * This file contains Original Code and/or Modifications of Original Code
77+ * as defined in and that are subject to the Apple Public Source License
88+ * Version 2.0 (the 'License'). You may not use this file except in
99+ * compliance with the License. The rights granted to you under the License
1010+ * may not be used to create, or enable the creation or redistribution of,
1111+ * unlawful or unlicensed copies of an Apple operating system, or to
1212+ * circumvent, violate, or enable the circumvention or violation of, any
1313+ * terms of an Apple operating system software license agreement.
1414+ *
1515+ * Please obtain a copy of the License at
1616+ * http://www.opensource.apple.com/apsl/ and read it before using this file.
1717+ *
1818+ * The Original Code and all software distributed under the License are
1919+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
2020+ * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
2121+ * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
2222+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
2323+ * Please see the License for the specific language governing rights and
2424+ * limitations under the License.
2525+ *
2626+ * @APPLE_OSREFERENCE_LICENSE_HEADER_END@
2727+ */
2828+2929+#ifndef _MACH_MACHINE_BOOLEAN_H_
3030+#define _MACH_MACHINE_BOOLEAN_H_
3131+3232+#if defined (__i386__) || defined(__x86_64__)
3333+#include "mach/i386/boolean.h"
3434+#else
3535+#error architecture not supported
3636+#endif
3737+3838+#endif /* _MACH_MACHINE_BOOLEAN_H_ */
+38
libmac/xnu/mach/machine/kern_return.h
···11+/*
22+ * Copyright (c) 2000-2007 Apple Inc. All rights reserved.
33+ *
44+ * @APPLE_OSREFERENCE_LICENSE_HEADER_START@
55+ *
66+ * This file contains Original Code and/or Modifications of Original Code
77+ * as defined in and that are subject to the Apple Public Source License
88+ * Version 2.0 (the 'License'). You may not use this file except in
99+ * compliance with the License. The rights granted to you under the License
1010+ * may not be used to create, or enable the creation or redistribution of,
1111+ * unlawful or unlicensed copies of an Apple operating system, or to
1212+ * circumvent, violate, or enable the circumvention or violation of, any
1313+ * terms of an Apple operating system software license agreement.
1414+ *
1515+ * Please obtain a copy of the License at
1616+ * http://www.opensource.apple.com/apsl/ and read it before using this file.
1717+ *
1818+ * The Original Code and all software distributed under the License are
1919+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
2020+ * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
2121+ * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
2222+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
2323+ * Please see the License for the specific language governing rights and
2424+ * limitations under the License.
2525+ *
2626+ * @APPLE_OSREFERENCE_LICENSE_HEADER_END@
2727+ */
2828+2929+#ifndef _MACH_MACHINE_KERN_RETURN_H_
3030+#define _MACH_MACHINE_KERN_RETURN_H_
3131+3232+#if defined (__i386__) || defined(__x86_64__)
3333+#include "mach/i386/kern_return.h"
3434+#else
3535+#error architecture not supported
3636+#endif
3737+3838+#endif /* _MACH_MACHINE_KERN_RETURN_H_ */
+38
libmac/xnu/mach/machine/vm_param.h
···11+/*
22+ * Copyright (c) 2000-2007 Apple Inc. All rights reserved.
33+ *
44+ * @APPLE_OSREFERENCE_LICENSE_HEADER_START@
55+ *
66+ * This file contains Original Code and/or Modifications of Original Code
77+ * as defined in and that are subject to the Apple Public Source License
88+ * Version 2.0 (the 'License'). You may not use this file except in
99+ * compliance with the License. The rights granted to you under the License
1010+ * may not be used to create, or enable the creation or redistribution of,
1111+ * unlawful or unlicensed copies of an Apple operating system, or to
1212+ * circumvent, violate, or enable the circumvention or violation of, any
1313+ * terms of an Apple operating system software license agreement.
1414+ *
1515+ * Please obtain a copy of the License at
1616+ * http://www.opensource.apple.com/apsl/ and read it before using this file.
1717+ *
1818+ * The Original Code and all software distributed under the License are
1919+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
2020+ * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
2121+ * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
2222+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
2323+ * Please see the License for the specific language governing rights and
2424+ * limitations under the License.
2525+ *
2626+ * @APPLE_OSREFERENCE_LICENSE_HEADER_END@
2727+ */
2828+2929+#ifndef _MACH_MACHINE_VM_PARAM_H_
3030+#define _MACH_MACHINE_VM_PARAM_H_
3131+3232+#if defined (__i386__) || defined(__x86_64__)
3333+#include "mach/i386/vm_param.h"
3434+#else
3535+#error architecture not supported
3636+#endif
3737+3838+#endif /* _MACH_MACHINE_VM_PARAM_H_ */
+38
libmac/xnu/mach/machine/vm_types.h
···11+/*
22+ * Copyright (c) 2000-2007 Apple Inc. All rights reserved.
33+ *
44+ * @APPLE_OSREFERENCE_LICENSE_HEADER_START@
55+ *
66+ * This file contains Original Code and/or Modifications of Original Code
77+ * as defined in and that are subject to the Apple Public Source License
88+ * Version 2.0 (the 'License'). You may not use this file except in
99+ * compliance with the License. The rights granted to you under the License
1010+ * may not be used to create, or enable the creation or redistribution of,
1111+ * unlawful or unlicensed copies of an Apple operating system, or to
1212+ * circumvent, violate, or enable the circumvention or violation of, any
1313+ * terms of an Apple operating system software license agreement.
1414+ *
1515+ * Please obtain a copy of the License at
1616+ * http://www.opensource.apple.com/apsl/ and read it before using this file.
1717+ *
1818+ * The Original Code and all software distributed under the License are
1919+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
2020+ * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
2121+ * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
2222+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
2323+ * Please see the License for the specific language governing rights and
2424+ * limitations under the License.
2525+ *
2626+ * @APPLE_OSREFERENCE_LICENSE_HEADER_END@
2727+ */
2828+2929+#ifndef _MACH_MACHINE_VM_TYPES_H_
3030+#define _MACH_MACHINE_VM_TYPES_H_
3131+3232+#if defined (__i386__) || defined(__x86_64__)
3333+#include "mach/i386/vm_types.h"
3434+#else
3535+#error architecture not supported
3636+#endif
3737+3838+#endif /* _MACH_MACHINE_VM_TYPES_H_ */
+228
libmac/xnu/mach/memory_object.h
···11+/*
22+ * Copyright (c) 2000-2005 Apple Computer, Inc. All rights reserved.
33+ *
44+ * @APPLE_OSREFERENCE_LICENSE_HEADER_START@
55+ *
66+ * This file contains Original Code and/or Modifications of Original Code
77+ * as defined in and that are subject to the Apple Public Source License
88+ * Version 2.0 (the 'License'). You may not use this file except in
99+ * compliance with the License. The rights granted to you under the License
1010+ * may not be used to create, or enable the creation or redistribution of,
1111+ * unlawful or unlicensed copies of an Apple operating system, or to
1212+ * circumvent, violate, or enable the circumvention or violation of, any
1313+ * terms of an Apple operating system software license agreement.
1414+ *
1515+ * Please obtain a copy of the License at
1616+ * http://www.opensource.apple.com/apsl/ and read it before using this file.
1717+ *
1818+ * The Original Code and all software distributed under the License are
1919+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
2020+ * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
2121+ * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
2222+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
2323+ * Please see the License for the specific language governing rights and
2424+ * limitations under the License.
2525+ *
2626+ * @APPLE_OSREFERENCE_LICENSE_HEADER_END@
2727+ */
2828+/*
2929+ * @OSF_COPYRIGHT@
3030+ */
3131+/*
3232+ * Mach Operating System
3333+ * Copyright (c) 1991,1990,1989,1988 Carnegie Mellon University
3434+ * All Rights Reserved.
3535+ *
3636+ * Permission to use, copy, modify and distribute this software and its
3737+ * documentation is hereby granted, provided that both the copyright
3838+ * notice and this permission notice appear in all copies of the
3939+ * software, derivative works or modified versions, and any portions
4040+ * thereof, and that both notices appear in supporting documentation.
4141+ *
4242+ * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
4343+ * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR
4444+ * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
4545+ *
4646+ * Carnegie Mellon requests users of this software to return to
4747+ *
4848+ * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU
4949+ * School of Computer Science
5050+ * Carnegie Mellon University
5151+ * Pittsburgh PA 15213-3890
5252+ *
5353+ * any improvements or extensions that they make and grant Carnegie Mellon
5454+ * the rights to redistribute these changes.
5555+ */
5656+/*
5757+ */
5858+/*
5959+ * File: memory_object.h
6060+ * Author: Michael Wayne Young
6161+ *
6262+ * External memory management interface definition.
6363+ */
6464+6565+#ifndef _MACH_MEMORY_OBJECT_H_
6666+#define _MACH_MEMORY_OBJECT_H_
6767+6868+/*
6969+ * User-visible types used in the external memory
7070+ * management interface:
7171+ */
7272+7373+#include <mach/port.h>
7474+#include <mach/message.h>
7575+#include <mach/machine/vm_types.h>
7676+7777+typedef mach_port_t memory_object_t;
7878+ /* A memory object ... */
7979+ /* Used by the kernel to retrieve */
8080+ /* or store data */
8181+8282+typedef mach_port_t memory_object_control_t;
8383+ /* Provided to a memory manager; ... */
8484+ /* used to control a memory object */
8585+8686+typedef mach_port_t memory_object_name_t;
8787+ /* Used to describe the memory ... */
8888+ /* object in vm_regions() calls */
8989+9090+typedef mach_port_t memory_object_rep_t;
9191+ /* Per-client handle for mem object */
9292+ /* Used by user programs to specify */
9393+ /* the object to map */
9494+9595+typedef int memory_object_copy_strategy_t;
9696+ /* How memory manager handles copy: */
9797+#define MEMORY_OBJECT_COPY_NONE 0
9898+ /* ... No special support */
9999+#define MEMORY_OBJECT_COPY_CALL 1
100100+ /* ... Make call on memory manager */
101101+#define MEMORY_OBJECT_COPY_DELAY 2
102102+ /* ... Memory manager doesn't
103103+ * change data externally.
104104+ */
105105+#define MEMORY_OBJECT_COPY_TEMPORARY 3
106106+ /* ... Memory manager doesn't
107107+ * change data externally, and
108108+ * doesn't need to see changes.
109109+ */
110110+#define MEMORY_OBJECT_COPY_SYMMETRIC 4
111111+ /* ... Memory manager doesn't
112112+ * change data externally,
113113+ * doesn't need to see changes,
114114+ * and object will not be
115115+ * multiply mapped.
116116+ *
117117+ * XXX
118118+ * Not yet safe for non-kernel use.
119119+ */
120120+121121+#define MEMORY_OBJECT_COPY_INVALID 5
122122+ /* ... An invalid copy strategy,
123123+ * for external objects which
124124+ * have not been initialized.
125125+ * Allows copy_strategy to be
126126+ * examined without also
127127+ * examining pager_ready and
128128+ * internal.
129129+ */
130130+131131+typedef int memory_object_return_t;
132132+ /* Which pages to return to manager
133133+ this time (lock_request) */
134134+#define MEMORY_OBJECT_RETURN_NONE 0
135135+ /* ... don't return any. */
136136+#define MEMORY_OBJECT_RETURN_DIRTY 1
137137+ /* ... only dirty pages. */
138138+#define MEMORY_OBJECT_RETURN_ALL 2
139139+ /* ... dirty and precious pages. */
140140+#define MEMORY_OBJECT_RETURN_ANYTHING 3
141141+ /* ... any resident page. */
142142+143143+#define MEMORY_OBJECT_NULL MACH_PORT_NULL
144144+145145+146146+/*
147147+ * Types for the memory object flavor interfaces
148148+ */
149149+150150+#define MEMORY_OBJECT_INFO_MAX (1024)
151151+typedef int *memory_object_info_t;
152152+typedef int memory_object_flavor_t;
153153+typedef int memory_object_info_data_t[MEMORY_OBJECT_INFO_MAX];
154154+155155+156156+#define OLD_MEMORY_OBJECT_BEHAVIOR_INFO 10
157157+#define MEMORY_OBJECT_PERFORMANCE_INFO 11
158158+#define OLD_MEMORY_OBJECT_ATTRIBUTE_INFO 12
159159+#define MEMORY_OBJECT_ATTRIBUTE_INFO 14
160160+#define MEMORY_OBJECT_BEHAVIOR_INFO 15
161161+162162+163163+struct old_memory_object_behave_info {
164164+ memory_object_copy_strategy_t copy_strategy;
165165+ boolean_t temporary;
166166+ boolean_t invalidate;
167167+};
168168+169169+struct memory_object_perf_info {
170170+ memory_object_cluster_size_t cluster_size;
171171+ boolean_t may_cache;
172172+};
173173+174174+struct old_memory_object_attr_info { /* old attr list */
175175+ boolean_t object_ready;
176176+ boolean_t may_cache;
177177+ memory_object_copy_strategy_t copy_strategy;
178178+};
179179+180180+struct memory_object_attr_info {
181181+ memory_object_copy_strategy_t copy_strategy;
182182+ memory_object_cluster_size_t cluster_size;
183183+ boolean_t may_cache_object;
184184+ boolean_t temporary;
185185+};
186186+187187+struct memory_object_behave_info {
188188+ memory_object_copy_strategy_t copy_strategy;
189189+ boolean_t temporary;
190190+ boolean_t invalidate;
191191+ boolean_t silent_overwrite;
192192+ boolean_t advisory_pageout;
193193+};
194194+195195+typedef struct old_memory_object_behave_info *old_memory_object_behave_info_t;
196196+typedef struct old_memory_object_behave_info old_memory_object_behave_info_data_t;
197197+198198+typedef struct memory_object_behave_info *memory_object_behave_info_t;
199199+typedef struct memory_object_behave_info memory_object_behave_info_data_t;
200200+201201+typedef struct memory_object_perf_info *memory_object_perf_info_t;
202202+typedef struct memory_object_perf_info memory_object_perf_info_data_t;
203203+204204+typedef struct old_memory_object_attr_info *old_memory_object_attr_info_t;
205205+typedef struct old_memory_object_attr_info old_memory_object_attr_info_data_t;
206206+207207+typedef struct memory_object_attr_info *memory_object_attr_info_t;
208208+typedef struct memory_object_attr_info memory_object_attr_info_data_t;
209209+210210+#define OLD_MEMORY_OBJECT_BEHAVE_INFO_COUNT ((mach_msg_type_number_t) \
211211+ (sizeof(old_memory_object_behave_info_data_t)/sizeof(int)))
212212+#define MEMORY_OBJECT_BEHAVE_INFO_COUNT ((mach_msg_type_number_t) \
213213+ (sizeof(memory_object_behave_info_data_t)/sizeof(int)))
214214+#define MEMORY_OBJECT_PERF_INFO_COUNT ((mach_msg_type_number_t) \
215215+ (sizeof(memory_object_perf_info_data_t)/sizeof(int)))
216216+#define OLD_MEMORY_OBJECT_ATTR_INFO_COUNT ((mach_msg_type_number_t) \
217217+ (sizeof(old_memory_object_attr_info_data_t)/sizeof(int)))
218218+#define MEMORY_OBJECT_ATTR_INFO_COUNT ((mach_msg_type_number_t) \
219219+ (sizeof(memory_object_attr_info_data_t)/sizeof(int)))
220220+221221+#define invalid_memory_object_flavor(f) \
222222+ (f != MEMORY_OBJECT_ATTRIBUTE_INFO && \
223223+ f != MEMORY_OBJECT_PERFORMANCE_INFO && \
224224+ f != OLD_MEMORY_OBJECT_BEHAVIOR_INFO && \
225225+ f != MEMORY_OBJECT_BEHAVIOR_INFO && \
226226+ f != OLD_MEMORY_OBJECT_ATTRIBUTE_INFO)
227227+228228+#endif /* _MACH_MEMORY_OBJECT_H_ */
+707
libmac/xnu/mach/memory_object_types.h
···11+/*
22+ * Copyright (c) 2000-2006 Apple Computer, Inc. All rights reserved.
33+ *
44+ * @APPLE_OSREFERENCE_LICENSE_HEADER_START@
55+ *
66+ * This file contains Original Code and/or Modifications of Original Code
77+ * as defined in and that are subject to the Apple Public Source License
88+ * Version 2.0 (the 'License'). You may not use this file except in
99+ * compliance with the License. The rights granted to you under the License
1010+ * may not be used to create, or enable the creation or redistribution of,
1111+ * unlawful or unlicensed copies of an Apple operating system, or to
1212+ * circumvent, violate, or enable the circumvention or violation of, any
1313+ * terms of an Apple operating system software license agreement.
1414+ *
1515+ * Please obtain a copy of the License at
1616+ * http://www.opensource.apple.com/apsl/ and read it before using this file.
1717+ *
1818+ * The Original Code and all software distributed under the License are
1919+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
2020+ * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
2121+ * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
2222+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
2323+ * Please see the License for the specific language governing rights and
2424+ * limitations under the License.
2525+ *
2626+ * @APPLE_OSREFERENCE_LICENSE_HEADER_END@
2727+ */
2828+/*
2929+ * @OSF_COPYRIGHT@
3030+ */
3131+/*
3232+ * Mach Operating System
3333+ * Copyright (c) 1991,1990,1989,1988 Carnegie Mellon University
3434+ * All Rights Reserved.
3535+ *
3636+ * Permission to use, copy, modify and distribute this software and its
3737+ * documentation is hereby granted, provided that both the copyright
3838+ * notice and this permission notice appear in all copies of the
3939+ * software, derivative works or modified versions, and any portions
4040+ * thereof, and that both notices appear in supporting documentation.
4141+ *
4242+ * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
4343+ * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR
4444+ * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
4545+ *
4646+ * Carnegie Mellon requests users of this software to return to
4747+ *
4848+ * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU
4949+ * School of Computer Science
5050+ * Carnegie Mellon University
5151+ * Pittsburgh PA 15213-3890
5252+ *
5353+ * any improvements or extensions that they make and grant Carnegie Mellon
5454+ * the rights to redistribute these changes.
5555+ */
5656+/*
5757+ */
5858+/*
5959+ * File: memory_object.h
6060+ * Author: Michael Wayne Young
6161+ *
6262+ * External memory management interface definition.
6363+ */
6464+6565+#ifndef _MACH_MEMORY_OBJECT_TYPES_H_
6666+#define _MACH_MEMORY_OBJECT_TYPES_H_
6767+6868+/*
6969+ * User-visible types used in the external memory
7070+ * management interface:
7171+ */
7272+7373+#include <mach/port.h>
7474+#include <mach/message.h>
7575+#include <mach/vm_prot.h>
7676+#include <mach/vm_sync.h>
7777+#include <mach/vm_types.h>
7878+#include <mach/machine/vm_types.h>
7979+8080+#include <sys/cdefs.h>
8181+8282+#define VM_64_BIT_DATA_OBJECTS
8383+8484+typedef unsigned long long memory_object_offset_t;
8585+typedef unsigned long long memory_object_size_t;
8686+typedef natural_t memory_object_cluster_size_t;
8787+typedef natural_t * memory_object_fault_info_t;
8888+8989+typedef unsigned long long vm_object_id_t;
9090+9191+9292+/*
9393+ * Temporary until real EMMI version gets re-implemented
9494+ */
9595+9696+#ifdef KERNEL_PRIVATE
9797+9898+struct memory_object_pager_ops; /* forward declaration */
9999+100100+typedef struct memory_object {
101101+ unsigned int _pad1; /* struct ipc_object_header */
102102+#ifdef __LP64__
103103+ unsigned int _pad2; /* pad to natural boundary */
104104+#endif
105105+ const struct memory_object_pager_ops *mo_pager_ops;
106106+} *memory_object_t;
107107+108108+typedef struct memory_object_control {
109109+ unsigned int moc_ikot; /* struct ipc_object_header */
110110+#ifdef __LP64__
111111+ unsigned int _pad; /* pad to natural boundary */
112112+#endif
113113+ struct vm_object *moc_object;
114114+} *memory_object_control_t;
115115+116116+typedef const struct memory_object_pager_ops {
117117+ void (*memory_object_reference)(
118118+ memory_object_t mem_obj);
119119+ void (*memory_object_deallocate)(
120120+ memory_object_t mem_obj);
121121+ kern_return_t (*memory_object_init)(
122122+ memory_object_t mem_obj,
123123+ memory_object_control_t mem_control,
124124+ memory_object_cluster_size_t size);
125125+ kern_return_t (*memory_object_terminate)(
126126+ memory_object_t mem_obj);
127127+ kern_return_t (*memory_object_data_request)(
128128+ memory_object_t mem_obj,
129129+ memory_object_offset_t offset,
130130+ memory_object_cluster_size_t length,
131131+ vm_prot_t desired_access,
132132+ memory_object_fault_info_t fault_info);
133133+ kern_return_t (*memory_object_data_return)(
134134+ memory_object_t mem_obj,
135135+ memory_object_offset_t offset,
136136+ memory_object_cluster_size_t size,
137137+ memory_object_offset_t *resid_offset,
138138+ int *io_error,
139139+ boolean_t dirty,
140140+ boolean_t kernel_copy,
141141+ int upl_flags);
142142+ kern_return_t (*memory_object_data_initialize)(
143143+ memory_object_t mem_obj,
144144+ memory_object_offset_t offset,
145145+ memory_object_cluster_size_t size);
146146+ kern_return_t (*memory_object_data_unlock)(
147147+ memory_object_t mem_obj,
148148+ memory_object_offset_t offset,
149149+ memory_object_size_t size,
150150+ vm_prot_t desired_access);
151151+ kern_return_t (*memory_object_synchronize)(
152152+ memory_object_t mem_obj,
153153+ memory_object_offset_t offset,
154154+ memory_object_size_t size,
155155+ vm_sync_t sync_flags);
156156+ kern_return_t (*memory_object_map)(
157157+ memory_object_t mem_obj,
158158+ vm_prot_t prot);
159159+ kern_return_t (*memory_object_last_unmap)(
160160+ memory_object_t mem_obj);
161161+ kern_return_t (*memory_object_data_reclaim)(
162162+ memory_object_t mem_obj,
163163+ boolean_t reclaim_backing_store);
164164+ const char *memory_object_pager_name;
165165+} * memory_object_pager_ops_t;
166166+167167+#else /* KERNEL_PRIVATE */
168168+169169+typedef mach_port_t memory_object_t;
170170+typedef mach_port_t memory_object_control_t;
171171+172172+#endif /* KERNEL_PRIVATE */
173173+174174+typedef memory_object_t *memory_object_array_t;
175175+ /* A memory object ... */
176176+ /* Used by the kernel to retrieve */
177177+ /* or store data */
178178+179179+typedef mach_port_t memory_object_name_t;
180180+ /* Used to describe the memory ... */
181181+ /* object in vm_regions() calls */
182182+183183+typedef mach_port_t memory_object_default_t;
184184+ /* Registered with the host ... */
185185+ /* for creating new internal objects */
186186+187187+#define MEMORY_OBJECT_NULL ((memory_object_t) 0)
188188+#define MEMORY_OBJECT_CONTROL_NULL ((memory_object_control_t) 0)
189189+#define MEMORY_OBJECT_NAME_NULL ((memory_object_name_t) 0)
190190+#define MEMORY_OBJECT_DEFAULT_NULL ((memory_object_default_t) 0)
191191+192192+193193+typedef int memory_object_copy_strategy_t;
194194+ /* How memory manager handles copy: */
195195+#define MEMORY_OBJECT_COPY_NONE 0
196196+ /* ... No special support */
197197+#define MEMORY_OBJECT_COPY_CALL 1
198198+ /* ... Make call on memory manager */
199199+#define MEMORY_OBJECT_COPY_DELAY 2
200200+ /* ... Memory manager doesn't
201201+ * change data externally.
202202+ */
203203+#define MEMORY_OBJECT_COPY_TEMPORARY 3
204204+ /* ... Memory manager doesn't
205205+ * change data externally, and
206206+ * doesn't need to see changes.
207207+ */
208208+#define MEMORY_OBJECT_COPY_SYMMETRIC 4
209209+ /* ... Memory manager doesn't
210210+ * change data externally,
211211+ * doesn't need to see changes,
212212+ * and object will not be
213213+ * multiply mapped.
214214+ *
215215+ * XXX
216216+ * Not yet safe for non-kernel use.
217217+ */
218218+219219+#define MEMORY_OBJECT_COPY_INVALID 5
220220+ /* ... An invalid copy strategy,
221221+ * for external objects which
222222+ * have not been initialized.
223223+ * Allows copy_strategy to be
224224+ * examined without also
225225+ * examining pager_ready and
226226+ * internal.
227227+ */
228228+229229+typedef int memory_object_return_t;
230230+ /* Which pages to return to manager
231231+ this time (lock_request) */
232232+#define MEMORY_OBJECT_RETURN_NONE 0
233233+ /* ... don't return any. */
234234+#define MEMORY_OBJECT_RETURN_DIRTY 1
235235+ /* ... only dirty pages. */
236236+#define MEMORY_OBJECT_RETURN_ALL 2
237237+ /* ... dirty and precious pages. */
238238+#define MEMORY_OBJECT_RETURN_ANYTHING 3
239239+ /* ... any resident page. */
240240+241241+/*
242242+ * Data lock request flags
243243+ */
244244+245245+#define MEMORY_OBJECT_DATA_FLUSH 0x1
246246+#define MEMORY_OBJECT_DATA_NO_CHANGE 0x2
247247+#define MEMORY_OBJECT_DATA_PURGE 0x4
248248+#define MEMORY_OBJECT_COPY_SYNC 0x8
249249+#define MEMORY_OBJECT_DATA_SYNC 0x10
250250+#define MEMORY_OBJECT_IO_SYNC 0x20
251251+#define MEMORY_OBJECT_DATA_FLUSH_ALL 0x40
252252+253253+/*
254254+ * Types for the memory object flavor interfaces
255255+ */
256256+257257+#define MEMORY_OBJECT_INFO_MAX (1024)
258258+typedef int *memory_object_info_t;
259259+typedef int memory_object_flavor_t;
260260+typedef int memory_object_info_data_t[MEMORY_OBJECT_INFO_MAX];
261261+262262+263263+#define MEMORY_OBJECT_PERFORMANCE_INFO 11
264264+#define MEMORY_OBJECT_ATTRIBUTE_INFO 14
265265+#define MEMORY_OBJECT_BEHAVIOR_INFO 15
266266+267267+#ifdef PRIVATE
268268+269269+#define OLD_MEMORY_OBJECT_BEHAVIOR_INFO 10
270270+#define OLD_MEMORY_OBJECT_ATTRIBUTE_INFO 12
271271+272272+struct old_memory_object_behave_info {
273273+ memory_object_copy_strategy_t copy_strategy;
274274+ boolean_t temporary;
275275+ boolean_t invalidate;
276276+};
277277+278278+struct old_memory_object_attr_info { /* old attr list */
279279+ boolean_t object_ready;
280280+ boolean_t may_cache;
281281+ memory_object_copy_strategy_t copy_strategy;
282282+};
283283+284284+typedef struct old_memory_object_behave_info *old_memory_object_behave_info_t;
285285+typedef struct old_memory_object_behave_info old_memory_object_behave_info_data_t;
286286+typedef struct old_memory_object_attr_info *old_memory_object_attr_info_t;
287287+typedef struct old_memory_object_attr_info old_memory_object_attr_info_data_t;
288288+289289+#define OLD_MEMORY_OBJECT_BEHAVE_INFO_COUNT ((mach_msg_type_number_t) \
290290+ (sizeof(old_memory_object_behave_info_data_t)/sizeof(int)))
291291+#define OLD_MEMORY_OBJECT_ATTR_INFO_COUNT ((mach_msg_type_number_t) \
292292+ (sizeof(old_memory_object_attr_info_data_t)/sizeof(int)))
293293+294294+#ifdef KERNEL
295295+296296+__BEGIN_DECLS
297297+extern void memory_object_reference(memory_object_t object);
298298+extern void memory_object_deallocate(memory_object_t object);
299299+300300+extern void memory_object_default_reference(memory_object_default_t);
301301+extern void memory_object_default_deallocate(memory_object_default_t);
302302+303303+extern void memory_object_control_reference(memory_object_control_t control);
304304+extern void memory_object_control_deallocate(memory_object_control_t control);
305305+extern int memory_object_control_uiomove(memory_object_control_t, memory_object_offset_t, void *, int, int, int, int);
306306+__END_DECLS
307307+308308+#endif /* KERNEL */
309309+310310+#endif /* PRIVATE */
311311+312312+struct memory_object_perf_info {
313313+ memory_object_cluster_size_t cluster_size;
314314+ boolean_t may_cache;
315315+};
316316+317317+struct memory_object_attr_info {
318318+ memory_object_copy_strategy_t copy_strategy;
319319+ memory_object_cluster_size_t cluster_size;
320320+ boolean_t may_cache_object;
321321+ boolean_t temporary;
322322+};
323323+324324+struct memory_object_behave_info {
325325+ memory_object_copy_strategy_t copy_strategy;
326326+ boolean_t temporary;
327327+ boolean_t invalidate;
328328+ boolean_t silent_overwrite;
329329+ boolean_t advisory_pageout;
330330+};
331331+332332+333333+typedef struct memory_object_behave_info *memory_object_behave_info_t;
334334+typedef struct memory_object_behave_info memory_object_behave_info_data_t;
335335+336336+typedef struct memory_object_perf_info *memory_object_perf_info_t;
337337+typedef struct memory_object_perf_info memory_object_perf_info_data_t;
338338+339339+typedef struct memory_object_attr_info *memory_object_attr_info_t;
340340+typedef struct memory_object_attr_info memory_object_attr_info_data_t;
341341+342342+#define MEMORY_OBJECT_BEHAVE_INFO_COUNT ((mach_msg_type_number_t) \
343343+ (sizeof(memory_object_behave_info_data_t)/sizeof(int)))
344344+#define MEMORY_OBJECT_PERF_INFO_COUNT ((mach_msg_type_number_t) \
345345+ (sizeof(memory_object_perf_info_data_t)/sizeof(int)))
346346+#define MEMORY_OBJECT_ATTR_INFO_COUNT ((mach_msg_type_number_t) \
347347+ (sizeof(memory_object_attr_info_data_t)/sizeof(int)))
348348+349349+#define invalid_memory_object_flavor(f) \
350350+ (f != MEMORY_OBJECT_ATTRIBUTE_INFO && \
351351+ f != MEMORY_OBJECT_PERFORMANCE_INFO && \
352352+ f != OLD_MEMORY_OBJECT_BEHAVIOR_INFO && \
353353+ f != MEMORY_OBJECT_BEHAVIOR_INFO && \
354354+ f != OLD_MEMORY_OBJECT_ATTRIBUTE_INFO)
355355+356356+357357+/*
358358+ * Used to support options on memory_object_release_name call
359359+ */
360360+#define MEMORY_OBJECT_TERMINATE_IDLE 0x1
361361+#define MEMORY_OBJECT_RESPECT_CACHE 0x2
362362+#define MEMORY_OBJECT_RELEASE_NO_OP 0x4
363363+364364+365365+/* named entry processor mapping options */
366366+/* enumerated */
367367+#define MAP_MEM_NOOP 0
368368+#define MAP_MEM_COPYBACK 1
369369+#define MAP_MEM_IO 2
370370+#define MAP_MEM_WTHRU 3
371371+#define MAP_MEM_WCOMB 4 /* Write combining mode */
372372+ /* aka store gather */
373373+#define MAP_MEM_INNERWBACK 5
374374+375375+#define GET_MAP_MEM(flags) \
376376+ ((((unsigned int)(flags)) >> 24) & 0xFF)
377377+378378+#define SET_MAP_MEM(caching, flags) \
379379+ ((flags) = ((((unsigned int)(caching)) << 24) \
380380+ & 0xFF000000) | ((flags) & 0xFFFFFF));
381381+382382+/* leave room for vm_prot bits */
383383+#define MAP_MEM_ONLY 0x010000 /* change processor caching */
384384+#define MAP_MEM_NAMED_CREATE 0x020000 /* create extant object */
385385+#define MAP_MEM_PURGABLE 0x040000 /* create a purgable VM object */
386386+#define MAP_MEM_NAMED_REUSE 0x080000 /* reuse provided entry if identical */
387387+388388+#ifdef KERNEL
389389+390390+/*
391391+ * Universal Page List data structures
392392+ *
393393+ * A UPL describes a bounded set of physical pages
394394+ * associated with some range of an object or map
395395+ * and a snapshot of the attributes associated with
396396+ * each of those pages.
397397+ */
398398+#ifdef PRIVATE
399399+#define MAX_UPL_TRANSFER 256
400400+#define MAX_UPL_SIZE 8192
401401+402402+struct upl_page_info {
403403+ ppnum_t phys_addr; /* physical page index number */
404404+ unsigned int
405405+#ifdef XNU_KERNEL_PRIVATE
406406+ pageout:1, /* page is to be removed on commit */
407407+ absent:1, /* No valid data in this page */
408408+ dirty:1, /* Page must be cleaned (O) */
409409+ precious:1, /* must be cleaned, we have only copy */
410410+ device:1, /* no page data, mapped dev memory */
411411+ speculative:1, /* page is valid, but not yet accessed */
412412+ cs_validated:1, /* CODE SIGNING: page was validated */
413413+ cs_tainted:1, /* CODE SIGNING: page is tainted */
414414+ needed:1, /* page should be left in cache on abort */
415415+ :0; /* force to long boundary */
416416+#else
417417+ opaque; /* use upl_page_xxx() accessor funcs */
418418+#endif /* XNU_KERNEL_PRIVATE */
419419+};
420420+421421+#else
422422+423423+struct upl_page_info {
424424+ unsigned int opaque[2]; /* use upl_page_xxx() accessor funcs */
425425+};
426426+427427+#endif /* PRIVATE */
428428+429429+typedef struct upl_page_info upl_page_info_t;
430430+typedef upl_page_info_t *upl_page_info_array_t;
431431+typedef upl_page_info_array_t upl_page_list_ptr_t;
432432+433433+typedef uint32_t upl_offset_t; /* page-aligned byte offset */
434434+typedef uint32_t upl_size_t; /* page-aligned byte size */
435435+436436+/* upl invocation flags */
437437+/* top nibble is used by super upl */
438438+439439+#define UPL_FLAGS_NONE 0x00000000
440440+#define UPL_COPYOUT_FROM 0x00000001
441441+#define UPL_PRECIOUS 0x00000002
442442+#define UPL_NO_SYNC 0x00000004
443443+#define UPL_CLEAN_IN_PLACE 0x00000008
444444+#define UPL_NOBLOCK 0x00000010
445445+#define UPL_RET_ONLY_DIRTY 0x00000020
446446+#define UPL_SET_INTERNAL 0x00000040
447447+#define UPL_QUERY_OBJECT_TYPE 0x00000080
448448+#define UPL_RET_ONLY_ABSENT 0x00000100 /* used only for COPY_FROM = FALSE */
449449+#define UPL_FILE_IO 0x00000200
450450+#define UPL_SET_LITE 0x00000400
451451+#define UPL_SET_INTERRUPTIBLE 0x00000800
452452+#define UPL_SET_IO_WIRE 0x00001000
453453+#define UPL_FOR_PAGEOUT 0x00002000
454454+#define UPL_WILL_BE_DUMPED 0x00004000
455455+#define UPL_FORCE_DATA_SYNC 0x00008000
456456+/* continued after the ticket bits... */
457457+458458+#define UPL_PAGE_TICKET_MASK 0x000F0000
459459+#define UPL_PAGE_TICKET_SHIFT 16
460460+461461+/* ... flags resume here */
462462+#define UPL_BLOCK_ACCESS 0x00100000
463463+#define UPL_ENCRYPT 0x00200000
464464+#define UPL_NOZEROFILL 0x00400000
465465+#define UPL_WILL_MODIFY 0x00800000 /* caller will modify the pages */
466466+467467+#define UPL_NEED_32BIT_ADDR 0x01000000
468468+#define UPL_UBC_MSYNC 0x02000000
469469+#define UPL_UBC_PAGEOUT 0x04000000
470470+#define UPL_UBC_PAGEIN 0x08000000
471471+#define UPL_REQUEST_SET_DIRTY 0x10000000
472472+473473+/* UPL flags known by this kernel */
474474+#define UPL_VALID_FLAGS 0x1FFFFFFF
475475+476476+477477+/* upl abort error flags */
478478+#define UPL_ABORT_RESTART 0x1
479479+#define UPL_ABORT_UNAVAILABLE 0x2
480480+#define UPL_ABORT_ERROR 0x4
481481+#define UPL_ABORT_FREE_ON_EMPTY 0x8 /* only implemented in wrappers */
482482+#define UPL_ABORT_DUMP_PAGES 0x10
483483+#define UPL_ABORT_NOTIFY_EMPTY 0x20
484484+/* deprecated: #define UPL_ABORT_ALLOW_ACCESS 0x40 */
485485+#define UPL_ABORT_REFERENCE 0x80
486486+487487+/* upl pages check flags */
488488+#define UPL_CHECK_DIRTY 0x1
489489+490490+491491+/*
492492+ * upl pagein/pageout flags
493493+ *
494494+ *
495495+ * when I/O is issued from this UPL it should be done synchronously
496496+ */
497497+#define UPL_IOSYNC 0x1
498498+499499+/*
500500+ * the passed in UPL should not have either a commit or abort
501501+ * applied to it by the underlying layers... the site that
502502+ * created the UPL is responsible for cleaning it up.
503503+ */
504504+#define UPL_NOCOMMIT 0x2
505505+506506+/*
507507+ * turn off any speculative read-ahead applied at the I/O layer
508508+ */
509509+#define UPL_NORDAHEAD 0x4
510510+511511+/*
512512+ * pageout request is targeting a real file
513513+ * as opposed to a swap file.
514514+ */
515515+516516+#define UPL_VNODE_PAGER 0x8
517517+/*
518518+ * this pageout is being originated as part of an explicit
519519+ * memory synchronization operation... no speculative clustering
520520+ * should be applied, only the range specified should be pushed.
521521+ */
522522+#define UPL_MSYNC 0x10
523523+524524+/*
525525+ *
526526+ */
527527+#define UPL_PAGING_ENCRYPTED 0x20
528528+529529+/*
530530+ * this pageout is being originated as part of an explicit
531531+ * memory synchronization operation that is checking for I/O
532532+ * errors and taking it's own action... if an error occurs,
533533+ * just abort the pages back into the cache unchanged
534534+ */
535535+#define UPL_KEEPCACHED 0x40
536536+537537+/*
538538+ * this pageout originated from within cluster_io to deal
539539+ * with a dirty page that hasn't yet been seen by the FS
540540+ * that backs it... tag it so that the FS can take the
541541+ * appropriate action w/r to its locking model since the
542542+ * pageout will reenter the FS for the same file currently
543543+ * being handled in this context.
544544+ */
545545+#define UPL_NESTED_PAGEOUT 0x80
546546+547547+/*
548548+ * we've detected a sequential access pattern and
549549+ * we are speculatively and aggressively pulling
550550+ * pages in... do not count these as real PAGEINs
551551+ * w/r to our hard throttle maintenance
552552+ */
553553+#define UPL_IOSTREAMING 0x100
554554+555555+556556+557557+558558+/* upl commit flags */
559559+#define UPL_COMMIT_FREE_ON_EMPTY 0x1 /* only implemented in wrappers */
560560+#define UPL_COMMIT_CLEAR_DIRTY 0x2
561561+#define UPL_COMMIT_SET_DIRTY 0x4
562562+#define UPL_COMMIT_INACTIVATE 0x8
563563+#define UPL_COMMIT_NOTIFY_EMPTY 0x10
564564+/* deprecated: #define UPL_COMMIT_ALLOW_ACCESS 0x20 */
565565+#define UPL_COMMIT_CS_VALIDATED 0x40
566566+#define UPL_COMMIT_CLEAR_PRECIOUS 0x80
567567+#define UPL_COMMIT_SPECULATE 0x100
568568+#define UPL_COMMIT_FREE_ABSENT 0x200
569569+570570+#define UPL_COMMIT_KERNEL_ONLY_FLAGS (UPL_COMMIT_CS_VALIDATED | UPL_COMMIT_FREE_ABSENT)
571571+572572+/* flags for return of state from vm_map_get_upl, vm_upl address space */
573573+/* based call */
574574+#define UPL_DEV_MEMORY 0x1
575575+#define UPL_PHYS_CONTIG 0x2
576576+577577+578578+/*
579579+ * Flags for the UPL page ops routine. This routine is not exported
580580+ * out of the kernel at the moment and so the defs live here.
581581+ */
582582+#define UPL_POP_DIRTY 0x1
583583+#define UPL_POP_PAGEOUT 0x2
584584+#define UPL_POP_PRECIOUS 0x4
585585+#define UPL_POP_ABSENT 0x8
586586+#define UPL_POP_BUSY 0x10
587587+588588+#define UPL_POP_PHYSICAL 0x10000000
589589+#define UPL_POP_DUMP 0x20000000
590590+#define UPL_POP_SET 0x40000000
591591+#define UPL_POP_CLR 0x80000000
592592+593593+/*
594594+ * Flags for the UPL range op routine. This routine is not exported
595595+ * out of the kernel at the moemet and so the defs live here.
596596+ */
597597+/*
598598+ * UPL_ROP_ABSENT: Returns the extent of the range presented which
599599+ * is absent, starting with the start address presented
600600+ */
601601+#define UPL_ROP_ABSENT 0x01
602602+/*
603603+ * UPL_ROP_PRESENT: Returns the extent of the range presented which
604604+ * is present (i.e. resident), starting with the start address presented
605605+ */
606606+#define UPL_ROP_PRESENT 0x02
607607+/*
608608+ * UPL_ROP_DUMP: Dump the pages which are found in the target object
609609+ * for the target range.
610610+ */
611611+#define UPL_ROP_DUMP 0x04
612612+613613+#ifdef PRIVATE
614614+615615+/* access macros for upl_t */
616616+617617+#define UPL_DEVICE_PAGE(upl) \
618618+ (((upl)[0].phys_addr != 0) ? ((upl)[0].device) : FALSE)
619619+620620+#define UPL_PAGE_PRESENT(upl, index) \
621621+ ((upl)[(index)].phys_addr != 0)
622622+623623+#define UPL_PHYS_PAGE(upl, index) \
624624+ ((upl)[(index)].phys_addr)
625625+626626+#define UPL_SPECULATIVE_PAGE(upl, index) \
627627+ (((upl)[(index)].phys_addr != 0) ? ((upl)[(index)].speculative) : FALSE)
628628+629629+#define UPL_DIRTY_PAGE(upl, index) \
630630+ (((upl)[(index)].phys_addr != 0) ? ((upl)[(index)].dirty) : FALSE)
631631+632632+#define UPL_PRECIOUS_PAGE(upl, index) \
633633+ (((upl)[(index)].phys_addr != 0) ? ((upl)[(index)].precious) : FALSE)
634634+635635+#define UPL_VALID_PAGE(upl, index) \
636636+ (((upl)[(index)].phys_addr != 0) ? (!((upl)[(index)].absent)) : FALSE)
637637+638638+#define UPL_PAGEOUT_PAGE(upl, index) \
639639+ (((upl)[(index)].phys_addr != 0) ? ((upl)[(index)].pageout) : FALSE)
640640+641641+#define UPL_SET_PAGE_FREE_ON_COMMIT(upl, index) \
642642+ (((upl)[(index)].phys_addr != 0) ? \
643643+ ((upl)[(index)].pageout = TRUE) : FALSE)
644644+645645+#define UPL_CLR_PAGE_FREE_ON_COMMIT(upl, index) \
646646+ (((upl)[(index)].phys_addr != 0) ? \
647647+ ((upl)[(index)].pageout = FALSE) : FALSE)
648648+649649+/* modifier macros for upl_t */
650650+651651+#define UPL_SET_CS_VALIDATED(upl, index, value) \
652652+ ((upl)[(index)].cs_validated = ((value) ? TRUE : FALSE))
653653+654654+#define UPL_SET_CS_TAINTED(upl, index, value) \
655655+ ((upl)[(index)].cs_tainted = ((value) ? TRUE : FALSE))
656656+657657+/* The call prototyped below is used strictly by UPL_GET_INTERNAL_PAGE_LIST */
658658+659659+extern vm_size_t upl_offset_to_pagelist;
660660+extern vm_size_t upl_get_internal_pagelist_offset(void);
661661+extern void* upl_get_internal_vectorupl(upl_t);
662662+extern upl_page_info_t* upl_get_internal_vectorupl_pagelist(upl_t);
663663+664664+/*Use this variant to get the UPL's page list iff:*/
665665+/*- the upl being passed in is already part of a vector UPL*/
666666+/*- the page list you want is that of this "sub-upl" and not that of the entire vector-upl*/
667667+668668+#define UPL_GET_INTERNAL_PAGE_LIST_SIMPLE(upl) \
669669+ ((upl_page_info_t *)((upl_offset_to_pagelist == 0) ? \
670670+ (uintptr_t)upl + (unsigned int)(upl_offset_to_pagelist = upl_get_internal_pagelist_offset()): \
671671+ (uintptr_t)upl + (unsigned int)upl_offset_to_pagelist))
672672+673673+/* UPL_GET_INTERNAL_PAGE_LIST is only valid on internal objects where the */
674674+/* list request was made with the UPL_INTERNAL flag */
675675+676676+677677+#define UPL_GET_INTERNAL_PAGE_LIST(upl) \
678678+ ((upl_get_internal_vectorupl(upl) != NULL ) ? (upl_get_internal_vectorupl_pagelist(upl)) : \
679679+ ((upl_page_info_t *)((upl_offset_to_pagelist == 0) ? \
680680+ (uintptr_t)upl + (unsigned int)(upl_offset_to_pagelist = upl_get_internal_pagelist_offset()): \
681681+ (uintptr_t)upl + (unsigned int)upl_offset_to_pagelist)))
682682+683683+__BEGIN_DECLS
684684+685685+extern ppnum_t upl_phys_page(upl_page_info_t *upl, int index);
686686+extern boolean_t upl_device_page(upl_page_info_t *upl);
687687+extern boolean_t upl_speculative_page(upl_page_info_t *upl, int index);
688688+extern void upl_clear_dirty(upl_t upl, boolean_t value);
689689+extern void upl_set_referenced(upl_t upl, boolean_t value);
690690+extern void upl_range_needed(upl_t upl, int index, int count);
691691+692692+__END_DECLS
693693+694694+#endif /* PRIVATE */
695695+696696+__BEGIN_DECLS
697697+698698+extern boolean_t upl_page_present(upl_page_info_t *upl, int index);
699699+extern boolean_t upl_dirty_page(upl_page_info_t *upl, int index);
700700+extern boolean_t upl_valid_page(upl_page_info_t *upl, int index);
701701+extern void upl_deallocate(upl_t upl);
702702+703703+__END_DECLS
704704+705705+#endif /* KERNEL */
706706+707707+#endif /* _MACH_MEMORY_OBJECT_TYPES_H_ */
+812
libmac/xnu/mach/message.h
···11+/*
22+ * Copyright (c) 2000-2005 Apple Computer, Inc. All rights reserved.
33+ *
44+ * @APPLE_OSREFERENCE_LICENSE_HEADER_START@
55+ *
66+ * This file contains Original Code and/or Modifications of Original Code
77+ * as defined in and that are subject to the Apple Public Source License
88+ * Version 2.0 (the 'License'). You may not use this file except in
99+ * compliance with the License. The rights granted to you under the License
1010+ * may not be used to create, or enable the creation or redistribution of,
1111+ * unlawful or unlicensed copies of an Apple operating system, or to
1212+ * circumvent, violate, or enable the circumvention or violation of, any
1313+ * terms of an Apple operating system software license agreement.
1414+ *
1515+ * Please obtain a copy of the License at
1616+ * http://www.opensource.apple.com/apsl/ and read it before using this file.
1717+ *
1818+ * The Original Code and all software distributed under the License are
1919+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
2020+ * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
2121+ * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
2222+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
2323+ * Please see the License for the specific language governing rights and
2424+ * limitations under the License.
2525+ *
2626+ * @APPLE_OSREFERENCE_LICENSE_HEADER_END@
2727+ */
2828+/*
2929+ * @OSF_COPYRIGHT@
3030+ */
3131+/*
3232+ * Mach Operating System
3333+ * Copyright (c) 1991,1990,1989,1988,1987 Carnegie Mellon University
3434+ * All Rights Reserved.
3535+ *
3636+ * Permission to use, copy, modify and distribute this software and its
3737+ * documentation is hereby granted, provided that both the copyright
3838+ * notice and this permission notice appear in all copies of the
3939+ * software, derivative works or modified versions, and any portions
4040+ * thereof, and that both notices appear in supporting documentation.
4141+ *
4242+ * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
4343+ * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR
4444+ * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
4545+ *
4646+ * Carnegie Mellon requests users of this software to return to
4747+ *
4848+ * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU
4949+ * School of Computer Science
5050+ * Carnegie Mellon University
5151+ * Pittsburgh PA 15213-3890
5252+ *
5353+ * any improvements or extensions that they make and grant Carnegie Mellon
5454+ * the rights to redistribute these changes.
5555+ */
5656+/*
5757+ * NOTICE: This file was modified by McAfee Research in 2004 to introduce
5858+ * support for mandatory and extensible security protections. This notice
5959+ * is included in support of clause 2.2 (b) of the Apple Public License,
6060+ * Version 2.0.
6161+ * Copyright (c) 2005 SPARTA, Inc.
6262+ */
6363+/*
6464+ */
6565+/*
6666+ * File: mach/message.h
6767+ *
6868+ * Mach IPC message and primitive function definitions.
6969+ */
7070+7171+#ifndef _MACH_MESSAGE_H_
7272+#define _MACH_MESSAGE_H_
7373+7474+#include <stdint.h>
7575+#include <mach/port.h>
7676+#include <mach/boolean.h>
7777+#include <mach/kern_return.h>
7878+#include <mach/machine/vm_types.h>
7979+8080+#include <sys/cdefs.h>
8181+#include <sys/appleapiopts.h>
8282+8383+/*
8484+ * The timeout mechanism uses mach_msg_timeout_t values,
8585+ * passed by value. The timeout units are milliseconds.
8686+ * It is controlled with the MACH_SEND_TIMEOUT
8787+ * and MACH_RCV_TIMEOUT options.
8888+ */
8989+9090+typedef natural_t mach_msg_timeout_t;
9191+9292+/*
9393+ * The value to be used when there is no timeout.
9494+ * (No MACH_SEND_TIMEOUT/MACH_RCV_TIMEOUT option.)
9595+ */
9696+9797+#define MACH_MSG_TIMEOUT_NONE ((mach_msg_timeout_t) 0)
9898+9999+/*
100100+ * The kernel uses MACH_MSGH_BITS_COMPLEX as a hint. If it isn't on, it
101101+ * assumes the body of the message doesn't contain port rights or OOL
102102+ * data. The field is set in received messages. A user task must
103103+ * use caution in interpreting the body of a message if the bit isn't
104104+ * on, because the mach_msg_type's in the body might "lie" about the
105105+ * contents. If the bit isn't on, but the mach_msg_types
106106+ * in the body specify rights or OOL data, the behavior is undefined.
107107+ * (Ie, an error may or may not be produced.)
108108+ *
109109+ * The value of MACH_MSGH_BITS_REMOTE determines the interpretation
110110+ * of the msgh_remote_port field. It is handled like a msgt_name.
111111+ *
112112+ * The value of MACH_MSGH_BITS_LOCAL determines the interpretation
113113+ * of the msgh_local_port field. It is handled like a msgt_name.
114114+ *
115115+ * MACH_MSGH_BITS() combines two MACH_MSG_TYPE_* values, for the remote
116116+ * and local fields, into a single value suitable for msgh_bits.
117117+ *
118118+ * MACH_MSGH_BITS_CIRCULAR should be zero; is is used internally.
119119+ *
120120+ * The unused bits should be zero and are reserved for the kernel
121121+ * or for future interface expansion.
122122+ */
123123+124124+#define MACH_MSGH_BITS_ZERO 0x00000000
125125+#define MACH_MSGH_BITS_REMOTE_MASK 0x000000ff
126126+#define MACH_MSGH_BITS_LOCAL_MASK 0x0000ff00
127127+#define MACH_MSGH_BITS_COMPLEX 0x80000000U
128128+#define MACH_MSGH_BITS_USER 0x8000ffffU
129129+130130+#define MACH_MSGH_BITS_CIRCULAR 0x40000000 /* internal use only */
131131+#define MACH_MSGH_BITS_USED 0xc000ffffU
132132+133133+#define MACH_MSGH_BITS_PORTS_MASK \
134134+ (MACH_MSGH_BITS_REMOTE_MASK|MACH_MSGH_BITS_LOCAL_MASK)
135135+136136+#define MACH_MSGH_BITS(remote, local) \
137137+ ((remote) | ((local) << 8))
138138+#define MACH_MSGH_BITS_REMOTE(bits) \
139139+ ((bits) & MACH_MSGH_BITS_REMOTE_MASK)
140140+#define MACH_MSGH_BITS_LOCAL(bits) \
141141+ (((bits) & MACH_MSGH_BITS_LOCAL_MASK) >> 8)
142142+#define MACH_MSGH_BITS_PORTS(bits) \
143143+ ((bits) & MACH_MSGH_BITS_PORTS_MASK)
144144+#define MACH_MSGH_BITS_OTHER(bits) \
145145+ ((bits) &~ MACH_MSGH_BITS_PORTS_MASK)
146146+147147+/*
148148+ * Every message starts with a message header.
149149+ * Following the message header, if the message is complex, are a count
150150+ * of type descriptors and the type descriptors themselves
151151+ * (mach_msg_descriptor_t). The size of the message must be specified in
152152+ * bytes, and includes the message header, descriptor count, descriptors,
153153+ * and inline data.
154154+ *
155155+ * The msgh_remote_port field specifies the destination of the message.
156156+ * It must specify a valid send or send-once right for a port.
157157+ *
158158+ * The msgh_local_port field specifies a "reply port". Normally,
159159+ * This field carries a send-once right that the receiver will use
160160+ * to reply to the message. It may carry the values MACH_PORT_NULL,
161161+ * MACH_PORT_DEAD, a send-once right, or a send right.
162162+ *
163163+ * The msgh_seqno field carries a sequence number associated with the
164164+ * received-from port. A port's sequence number is incremented every
165165+ * time a message is received from it. In sent messages, the field's
166166+ * value is ignored.
167167+ *
168168+ * The msgh_id field is uninterpreted by the message primitives.
169169+ * It normally carries information specifying the format
170170+ * or meaning of the message.
171171+ */
172172+173173+typedef unsigned int mach_msg_bits_t;
174174+typedef natural_t mach_msg_size_t;
175175+typedef integer_t mach_msg_id_t;
176176+177177+178178+#define MACH_MSG_SIZE_NULL (mach_msg_size_t *) 0
179179+180180+typedef unsigned int mach_msg_type_name_t;
181181+182182+#define MACH_MSG_TYPE_MOVE_RECEIVE 16 /* Must hold receive rights */
183183+#define MACH_MSG_TYPE_MOVE_SEND 17 /* Must hold send rights */
184184+#define MACH_MSG_TYPE_MOVE_SEND_ONCE 18 /* Must hold sendonce rights */
185185+#define MACH_MSG_TYPE_COPY_SEND 19 /* Must hold send rights */
186186+#define MACH_MSG_TYPE_MAKE_SEND 20 /* Must hold receive rights */
187187+#define MACH_MSG_TYPE_MAKE_SEND_ONCE 21 /* Must hold receive rights */
188188+#define MACH_MSG_TYPE_COPY_RECEIVE 22 /* Must hold receive rights */
189189+190190+typedef unsigned int mach_msg_copy_options_t;
191191+192192+#define MACH_MSG_PHYSICAL_COPY 0
193193+#define MACH_MSG_VIRTUAL_COPY 1
194194+#define MACH_MSG_ALLOCATE 2
195195+#define MACH_MSG_OVERWRITE 3
196196+#ifdef MACH_KERNEL
197197+#define MACH_MSG_KALLOC_COPY_T 4
198198+#endif /* MACH_KERNEL */
199199+200200+/*
201201+ * In a complex mach message, the mach_msg_header_t is followed by
202202+ * a descriptor count, then an array of that number of descriptors
203203+ * (mach_msg_*_descriptor_t). The type field of mach_msg_type_descriptor_t
204204+ * (which any descriptor can be cast to) indicates the flavor of the
205205+ * descriptor.
206206+ *
207207+ * Note that in LP64, the various types of descriptors are no longer all
208208+ * the same size as mach_msg_descriptor_t, so the array cannot be indexed
209209+ * as expected.
210210+ */
211211+212212+typedef unsigned int mach_msg_descriptor_type_t;
213213+214214+#define MACH_MSG_PORT_DESCRIPTOR 0
215215+#define MACH_MSG_OOL_DESCRIPTOR 1
216216+#define MACH_MSG_OOL_PORTS_DESCRIPTOR 2
217217+#define MACH_MSG_OOL_VOLATILE_DESCRIPTOR 3
218218+219219+#pragma pack(4)
220220+221221+typedef struct
222222+{
223223+ natural_t pad1;
224224+ mach_msg_size_t pad2;
225225+ unsigned int pad3 : 24;
226226+ mach_msg_descriptor_type_t type : 8;
227227+} mach_msg_type_descriptor_t;
228228+229229+typedef struct
230230+{
231231+ mach_port_t name;
232232+#if !(defined(KERNEL) && defined(__LP64__))
233233+// Pad to 8 bytes everywhere except the K64 kernel where mach_port_t is 8 bytes
234234+ mach_msg_size_t pad1;
235235+#endif
236236+ unsigned int pad2 : 16;
237237+ mach_msg_type_name_t disposition : 8;
238238+ mach_msg_descriptor_type_t type : 8;
239239+#if defined(KERNEL)
240240+ uint32_t pad_end;
241241+#endif
242242+} mach_msg_port_descriptor_t;
243243+244244+typedef struct
245245+{
246246+ uint32_t address;
247247+ mach_msg_size_t size;
248248+ boolean_t deallocate: 8;
249249+ mach_msg_copy_options_t copy: 8;
250250+ unsigned int pad1: 8;
251251+ mach_msg_descriptor_type_t type: 8;
252252+} mach_msg_ool_descriptor32_t;
253253+254254+typedef struct
255255+{
256256+ uint64_t address;
257257+ boolean_t deallocate: 8;
258258+ mach_msg_copy_options_t copy: 8;
259259+ unsigned int pad1: 8;
260260+ mach_msg_descriptor_type_t type: 8;
261261+ mach_msg_size_t size;
262262+} mach_msg_ool_descriptor64_t;
263263+264264+typedef struct
265265+{
266266+ void* address;
267267+#if !defined(__LP64__)
268268+ mach_msg_size_t size;
269269+#endif
270270+ boolean_t deallocate: 8;
271271+ mach_msg_copy_options_t copy: 8;
272272+ unsigned int pad1: 8;
273273+ mach_msg_descriptor_type_t type: 8;
274274+#if defined(__LP64__)
275275+ mach_msg_size_t size;
276276+#endif
277277+#if defined(KERNEL) && !defined(__LP64__)
278278+ uint32_t pad_end;
279279+#endif
280280+} mach_msg_ool_descriptor_t;
281281+282282+typedef struct
283283+{
284284+ uint32_t address;
285285+ mach_msg_size_t count;
286286+ boolean_t deallocate: 8;
287287+ mach_msg_copy_options_t copy: 8;
288288+ mach_msg_type_name_t disposition : 8;
289289+ mach_msg_descriptor_type_t type : 8;
290290+} mach_msg_ool_ports_descriptor32_t;
291291+292292+typedef struct
293293+{
294294+ uint64_t address;
295295+ boolean_t deallocate: 8;
296296+ mach_msg_copy_options_t copy: 8;
297297+ mach_msg_type_name_t disposition : 8;
298298+ mach_msg_descriptor_type_t type : 8;
299299+ mach_msg_size_t count;
300300+} mach_msg_ool_ports_descriptor64_t;
301301+302302+typedef struct
303303+{
304304+ void* address;
305305+#if !defined(__LP64__)
306306+ mach_msg_size_t count;
307307+#endif
308308+ boolean_t deallocate: 8;
309309+ mach_msg_copy_options_t copy: 8;
310310+ mach_msg_type_name_t disposition : 8;
311311+ mach_msg_descriptor_type_t type : 8;
312312+#if defined(__LP64__)
313313+ mach_msg_size_t count;
314314+#endif
315315+#if defined(KERNEL) && !defined(__LP64__)
316316+ uint32_t pad_end;
317317+#endif
318318+} mach_msg_ool_ports_descriptor_t;
319319+320320+/*
321321+ * LP64support - This union definition is not really
322322+ * appropriate in LP64 mode because not all descriptors
323323+ * are of the same size in that environment.
324324+ */
325325+#if defined(__LP64__) && defined(KERNEL)
326326+typedef union
327327+{
328328+ mach_msg_port_descriptor_t port;
329329+ mach_msg_ool_descriptor32_t out_of_line;
330330+ mach_msg_ool_ports_descriptor32_t ool_ports;
331331+ mach_msg_type_descriptor_t type;
332332+} mach_msg_descriptor_t;
333333+#else
334334+typedef union
335335+{
336336+ mach_msg_port_descriptor_t port;
337337+ mach_msg_ool_descriptor_t out_of_line;
338338+ mach_msg_ool_ports_descriptor_t ool_ports;
339339+ mach_msg_type_descriptor_t type;
340340+} mach_msg_descriptor_t;
341341+#endif
342342+343343+typedef struct
344344+{
345345+ mach_msg_size_t msgh_descriptor_count;
346346+} mach_msg_body_t;
347347+348348+#define MACH_MSG_BODY_NULL (mach_msg_body_t *) 0
349349+#define MACH_MSG_DESCRIPTOR_NULL (mach_msg_descriptor_t *) 0
350350+351351+typedef struct
352352+{
353353+ mach_msg_bits_t msgh_bits;
354354+ mach_msg_size_t msgh_size;
355355+ mach_port_t msgh_remote_port;
356356+ mach_port_t msgh_local_port;
357357+ mach_msg_size_t msgh_reserved;
358358+ mach_msg_id_t msgh_id;
359359+} mach_msg_header_t;
360360+361361+#define MACH_MSG_NULL (mach_msg_header_t *) 0
362362+363363+typedef struct
364364+{
365365+ mach_msg_header_t header;
366366+ mach_msg_body_t body;
367367+} mach_msg_base_t;
368368+369369+typedef unsigned int mach_msg_trailer_type_t;
370370+371371+#define MACH_MSG_TRAILER_FORMAT_0 0
372372+373373+typedef unsigned int mach_msg_trailer_size_t;
374374+375375+typedef struct
376376+{
377377+ mach_msg_trailer_type_t msgh_trailer_type;
378378+ mach_msg_trailer_size_t msgh_trailer_size;
379379+} mach_msg_trailer_t;
380380+381381+typedef struct
382382+{
383383+ mach_msg_trailer_type_t msgh_trailer_type;
384384+ mach_msg_trailer_size_t msgh_trailer_size;
385385+ mach_port_seqno_t msgh_seqno;
386386+} mach_msg_seqno_trailer_t;
387387+388388+typedef struct
389389+{
390390+ unsigned int val[2];
391391+} security_token_t;
392392+393393+typedef struct
394394+{
395395+ mach_msg_trailer_type_t msgh_trailer_type;
396396+ mach_msg_trailer_size_t msgh_trailer_size;
397397+ mach_port_seqno_t msgh_seqno;
398398+ security_token_t msgh_sender;
399399+} mach_msg_security_trailer_t;
400400+401401+/*
402402+ * The audit token is an opaque token which identifies
403403+ * Mach tasks and senders of Mach messages as subjects
404404+ * to the BSM audit system. Only the appropriate BSM
405405+ * library routines should be used to interpret the
406406+ * contents of the audit token as the representation
407407+ * of the subject identity within the token may change
408408+ * over time.
409409+ */
410410+typedef struct
411411+{
412412+ unsigned int val[8];
413413+} audit_token_t;
414414+415415+typedef struct
416416+{
417417+ mach_msg_trailer_type_t msgh_trailer_type;
418418+ mach_msg_trailer_size_t msgh_trailer_size;
419419+ mach_port_seqno_t msgh_seqno;
420420+ security_token_t msgh_sender;
421421+ audit_token_t msgh_audit;
422422+} mach_msg_audit_trailer_t;
423423+424424+typedef struct
425425+{
426426+ mach_msg_trailer_type_t msgh_trailer_type;
427427+ mach_msg_trailer_size_t msgh_trailer_size;
428428+ mach_port_seqno_t msgh_seqno;
429429+ security_token_t msgh_sender;
430430+ audit_token_t msgh_audit;
431431+ mach_port_context_t msgh_context;
432432+} mach_msg_context_trailer_t;
433433+434434+typedef struct
435435+{
436436+ mach_port_name_t sender;
437437+} msg_labels_t;
438438+439439+/*
440440+ Trailer type to pass MAC policy label info as a mach message trailer.
441441+442442+*/
443443+444444+typedef struct
445445+{
446446+ mach_msg_trailer_type_t msgh_trailer_type;
447447+ mach_msg_trailer_size_t msgh_trailer_size;
448448+ mach_port_seqno_t msgh_seqno;
449449+ security_token_t msgh_sender;
450450+ audit_token_t msgh_audit;
451451+ mach_port_context_t msgh_context;
452452+ int msgh_ad;
453453+ msg_labels_t msgh_labels;
454454+} mach_msg_mac_trailer_t;
455455+456456+#define MACH_MSG_TRAILER_MINIMUM_SIZE sizeof(mach_msg_trailer_t)
457457+458458+/*
459459+ * These values can change from release to release - but clearly
460460+ * code cannot request additional trailer elements one was not
461461+ * compiled to understand. Therefore, it is safe to use this
462462+ * constant when the same module specified the receive options.
463463+ * Otherwise, you run the risk that the options requested by
464464+ * another module may exceed the local modules notion of
465465+ * MAX_TRAILER_SIZE.
466466+ */
467467+typedef mach_msg_mac_trailer_t mach_msg_max_trailer_t;
468468+#define MAX_TRAILER_SIZE ((mach_msg_size_t)sizeof(mach_msg_max_trailer_t))
469469+470470+/*
471471+ * Legacy requirements keep us from ever updating these defines (even
472472+ * when the format_0 trailers gain new option data fields in the future).
473473+ * Therefore, they shouldn't be used going forward. Instead, the sizes
474474+ * should be compared against the specific element size requested using
475475+ * REQUESTED_TRAILER_SIZE.
476476+ */
477477+typedef mach_msg_security_trailer_t mach_msg_format_0_trailer_t;
478478+479479+/*typedef mach_msg_mac_trailer_t mach_msg_format_0_trailer_t;
480480+*/
481481+482482+#define MACH_MSG_TRAILER_FORMAT_0_SIZE sizeof(mach_msg_format_0_trailer_t)
483483+484484+#define KERNEL_SECURITY_TOKEN_VALUE { {0, 1} }
485485+extern security_token_t KERNEL_SECURITY_TOKEN;
486486+487487+#define KERNEL_AUDIT_TOKEN_VALUE { {0, 0, 0, 0, 0, 0, 0, 0} }
488488+extern audit_token_t KERNEL_AUDIT_TOKEN;
489489+490490+typedef integer_t mach_msg_options_t;
491491+492492+typedef struct
493493+{
494494+ mach_msg_header_t header;
495495+} mach_msg_empty_send_t;
496496+497497+typedef struct
498498+{
499499+ mach_msg_header_t header;
500500+ mach_msg_trailer_t trailer;
501501+} mach_msg_empty_rcv_t;
502502+503503+typedef union
504504+{
505505+ mach_msg_empty_send_t send;
506506+ mach_msg_empty_rcv_t rcv;
507507+} mach_msg_empty_t;
508508+509509+#pragma pack()
510510+511511+/* utility to round the message size - will become machine dependent */
512512+#define round_msg(x) (((mach_msg_size_t)(x) + sizeof (natural_t) - 1) & \
513513+ ~(sizeof (natural_t) - 1))
514514+515515+/*
516516+ * There is no fixed upper bound to the size of Mach messages.
517517+ */
518518+#define MACH_MSG_SIZE_MAX ((mach_msg_size_t) ~0)
519519+520520+#if defined(__APPLE_API_PRIVATE)
521521+/*
522522+ * But architectural limits of a given implementation, or
523523+ * temporal conditions may cause unpredictable send failures
524524+ * for messages larger than MACH_MSG_SIZE_RELIABLE.
525525+ *
526526+ * In either case, waiting for memory is [currently] outside
527527+ * the scope of send timeout values provided to IPC.
528528+ */
529529+#define MACH_MSG_SIZE_RELIABLE ((mach_msg_size_t) 256 * 1024)
530530+#endif
531531+/*
532532+ * Compatibility definitions, for code written
533533+ * when there was a msgh_kind instead of msgh_seqno.
534534+ */
535535+#define MACH_MSGH_KIND_NORMAL 0x00000000
536536+#define MACH_MSGH_KIND_NOTIFICATION 0x00000001
537537+#define msgh_kind msgh_seqno
538538+#define mach_msg_kind_t mach_port_seqno_t
539539+540540+typedef natural_t mach_msg_type_size_t;
541541+typedef natural_t mach_msg_type_number_t;
542542+543543+/*
544544+ * Values received/carried in messages. Tells the receiver what
545545+ * sort of port right he now has.
546546+ *
547547+ * MACH_MSG_TYPE_PORT_NAME is used to transfer a port name
548548+ * which should remain uninterpreted by the kernel. (Port rights
549549+ * are not transferred, just the port name.)
550550+ */
551551+552552+#define MACH_MSG_TYPE_PORT_NONE 0
553553+554554+#define MACH_MSG_TYPE_PORT_NAME 15
555555+#define MACH_MSG_TYPE_PORT_RECEIVE MACH_MSG_TYPE_MOVE_RECEIVE
556556+#define MACH_MSG_TYPE_PORT_SEND MACH_MSG_TYPE_MOVE_SEND
557557+#define MACH_MSG_TYPE_PORT_SEND_ONCE MACH_MSG_TYPE_MOVE_SEND_ONCE
558558+559559+#define MACH_MSG_TYPE_LAST 22 /* Last assigned */
560560+561561+/*
562562+ * A dummy value. Mostly used to indicate that the actual value
563563+ * will be filled in later, dynamically.
564564+ */
565565+566566+#define MACH_MSG_TYPE_POLYMORPHIC ((mach_msg_type_name_t) -1)
567567+568568+/*
569569+ * Is a given item a port type?
570570+ */
571571+572572+#define MACH_MSG_TYPE_PORT_ANY(x) \
573573+ (((x) >= MACH_MSG_TYPE_MOVE_RECEIVE) && \
574574+ ((x) <= MACH_MSG_TYPE_MAKE_SEND_ONCE))
575575+576576+#define MACH_MSG_TYPE_PORT_ANY_SEND(x) \
577577+ (((x) >= MACH_MSG_TYPE_MOVE_SEND) && \
578578+ ((x) <= MACH_MSG_TYPE_MAKE_SEND_ONCE))
579579+580580+#define MACH_MSG_TYPE_PORT_ANY_RIGHT(x) \
581581+ (((x) >= MACH_MSG_TYPE_MOVE_RECEIVE) && \
582582+ ((x) <= MACH_MSG_TYPE_MOVE_SEND_ONCE))
583583+584584+typedef integer_t mach_msg_option_t;
585585+586586+#define MACH_MSG_OPTION_NONE 0x00000000
587587+588588+#define MACH_SEND_MSG 0x00000001
589589+#define MACH_RCV_MSG 0x00000002
590590+#define MACH_RCV_LARGE 0x00000004
591591+592592+#define MACH_SEND_TIMEOUT 0x00000010
593593+#define MACH_SEND_INTERRUPT 0x00000040 /* libmach implements */
594594+#define MACH_SEND_NOTIFY 0x00000080 /* arm send-possible notify */
595595+#define MACH_SEND_ALWAYS 0x00010000 /* internal use only */
596596+#define MACH_SEND_TRAILER 0x00020000
597597+598598+#define MACH_RCV_TIMEOUT 0x00000100
599599+#define MACH_RCV_NOTIFY 0x00000200 /* reserved - legacy */
600600+#define MACH_RCV_INTERRUPT 0x00000400 /* libmach implements */
601601+#define MACH_RCV_OVERWRITE 0x00001000
602602+603603+/*
604604+ * NOTE: a 0x00------ RCV mask implies to ask for
605605+ * a MACH_MSG_TRAILER_FORMAT_0 with 0 Elements,
606606+ * which is equivalent to a mach_msg_trailer_t.
607607+ *
608608+ * XXXMAC: unlike the rest of the MACH_RCV_* flags, MACH_RCV_TRAILER_LABELS
609609+ * needs its own private bit since we only calculate its fields when absolutely
610610+ * required.
611611+ */
612612+#define MACH_RCV_TRAILER_NULL 0
613613+#define MACH_RCV_TRAILER_SEQNO 1
614614+#define MACH_RCV_TRAILER_SENDER 2
615615+#define MACH_RCV_TRAILER_AUDIT 3
616616+#define MACH_RCV_TRAILER_CTX 4
617617+#define MACH_RCV_TRAILER_AV 7
618618+#define MACH_RCV_TRAILER_LABELS 8
619619+620620+#define MACH_RCV_TRAILER_TYPE(x) (((x) & 0xf) << 28)
621621+#define MACH_RCV_TRAILER_ELEMENTS(x) (((x) & 0xf) << 24)
622622+#define MACH_RCV_TRAILER_MASK ((0xff << 24))
623623+624624+#define GET_RCV_ELEMENTS(y) (((y) >> 24) & 0xf)
625625+626626+/*
627627+ * XXXMAC: note that in the case of MACH_RCV_TRAILER_LABELS,
628628+ * we just fall through to mach_msg_max_trailer_t.
629629+ * This is correct behavior since mach_msg_max_trailer_t is defined as
630630+ * mac_msg_mac_trailer_t which is used for the LABELS trailer.
631631+ * It also makes things work properly if MACH_RCV_TRAILER_LABELS is ORed
632632+ * with one of the other options.
633633+ */
634634+635635+#define REQUESTED_TRAILER_SIZE_NATIVE(y) \
636636+ ((mach_msg_trailer_size_t) \
637637+ ((GET_RCV_ELEMENTS(y) == MACH_RCV_TRAILER_NULL) ? \
638638+ sizeof(mach_msg_trailer_t) : \
639639+ ((GET_RCV_ELEMENTS(y) == MACH_RCV_TRAILER_SEQNO) ? \
640640+ sizeof(mach_msg_seqno_trailer_t) : \
641641+ ((GET_RCV_ELEMENTS(y) == MACH_RCV_TRAILER_SENDER) ? \
642642+ sizeof(mach_msg_security_trailer_t) : \
643643+ ((GET_RCV_ELEMENTS(y) == MACH_RCV_TRAILER_AUDIT) ? \
644644+ sizeof(mach_msg_audit_trailer_t) : \
645645+ ((GET_RCV_ELEMENTS(y) == MACH_RCV_TRAILER_CTX) ? \
646646+ sizeof(mach_msg_context_trailer_t) : \
647647+ ((GET_RCV_ELEMENTS(y) == MACH_RCV_TRAILER_AV) ? \
648648+ sizeof(mach_msg_mac_trailer_t) : \
649649+ sizeof(mach_msg_max_trailer_t))))))))
650650+651651+652652+#ifdef XNU_KERNEL_PRIVATE
653653+654654+#define REQUESTED_TRAILER_SIZE(is64, y) REQUESTED_TRAILER_SIZE_NATIVE(y)
655655+656656+#else /* XNU_KERNEL_PRIVATE */
657657+#define REQUESTED_TRAILER_SIZE(y) REQUESTED_TRAILER_SIZE_NATIVE(y)
658658+#endif /* XNU_KERNEL_PRIVATE */
659659+660660+/*
661661+ * Much code assumes that mach_msg_return_t == kern_return_t.
662662+ * This definition is useful for descriptive purposes.
663663+ *
664664+ * See <mach/error.h> for the format of error codes.
665665+ * IPC errors are system 4. Send errors are subsystem 0;
666666+ * receive errors are subsystem 1. The code field is always non-zero.
667667+ * The high bits of the code field communicate extra information
668668+ * for some error codes. MACH_MSG_MASK masks off these special bits.
669669+ */
670670+671671+typedef kern_return_t mach_msg_return_t;
672672+673673+#define MACH_MSG_SUCCESS 0x00000000
674674+675675+676676+#define MACH_MSG_MASK 0x00003e00
677677+ /* All special error code bits defined below. */
678678+#define MACH_MSG_IPC_SPACE 0x00002000
679679+ /* No room in IPC name space for another capability name. */
680680+#define MACH_MSG_VM_SPACE 0x00001000
681681+ /* No room in VM address space for out-of-line memory. */
682682+#define MACH_MSG_IPC_KERNEL 0x00000800
683683+ /* Kernel resource shortage handling an IPC capability. */
684684+#define MACH_MSG_VM_KERNEL 0x00000400
685685+ /* Kernel resource shortage handling out-of-line memory. */
686686+687687+#define MACH_SEND_IN_PROGRESS 0x10000001
688688+ /* Thread is waiting to send. (Internal use only.) */
689689+#define MACH_SEND_INVALID_DATA 0x10000002
690690+ /* Bogus in-line data. */
691691+#define MACH_SEND_INVALID_DEST 0x10000003
692692+ /* Bogus destination port. */
693693+#define MACH_SEND_TIMED_OUT 0x10000004
694694+ /* Message not sent before timeout expired. */
695695+#define MACH_SEND_INTERRUPTED 0x10000007
696696+ /* Software interrupt. */
697697+#define MACH_SEND_MSG_TOO_SMALL 0x10000008
698698+ /* Data doesn't contain a complete message. */
699699+#define MACH_SEND_INVALID_REPLY 0x10000009
700700+ /* Bogus reply port. */
701701+#define MACH_SEND_INVALID_RIGHT 0x1000000a
702702+ /* Bogus port rights in the message body. */
703703+#define MACH_SEND_INVALID_NOTIFY 0x1000000b
704704+ /* Bogus notify port argument. */
705705+#define MACH_SEND_INVALID_MEMORY 0x1000000c
706706+ /* Invalid out-of-line memory pointer. */
707707+#define MACH_SEND_NO_BUFFER 0x1000000d
708708+ /* No message buffer is available. */
709709+#define MACH_SEND_TOO_LARGE 0x1000000e
710710+ /* Send is too large for port */
711711+#define MACH_SEND_INVALID_TYPE 0x1000000f
712712+ /* Invalid msg-type specification. */
713713+#define MACH_SEND_INVALID_HEADER 0x10000010
714714+ /* A field in the header had a bad value. */
715715+#define MACH_SEND_INVALID_TRAILER 0x10000011
716716+ /* The trailer to be sent does not match kernel format. */
717717+#define MACH_SEND_INVALID_RT_OOL_SIZE 0x10000015
718718+ /* compatibility: no longer a returned error */
719719+720720+#define MACH_RCV_IN_PROGRESS 0x10004001
721721+ /* Thread is waiting for receive. (Internal use only.) */
722722+#define MACH_RCV_INVALID_NAME 0x10004002
723723+ /* Bogus name for receive port/port-set. */
724724+#define MACH_RCV_TIMED_OUT 0x10004003
725725+ /* Didn't get a message within the timeout value. */
726726+#define MACH_RCV_TOO_LARGE 0x10004004
727727+ /* Message buffer is not large enough for inline data. */
728728+#define MACH_RCV_INTERRUPTED 0x10004005
729729+ /* Software interrupt. */
730730+#define MACH_RCV_PORT_CHANGED 0x10004006
731731+ /* compatibility: no longer a returned error */
732732+#define MACH_RCV_INVALID_NOTIFY 0x10004007
733733+ /* Bogus notify port argument. */
734734+#define MACH_RCV_INVALID_DATA 0x10004008
735735+ /* Bogus message buffer for inline data. */
736736+#define MACH_RCV_PORT_DIED 0x10004009
737737+ /* Port/set was sent away/died during receive. */
738738+#define MACH_RCV_IN_SET 0x1000400a
739739+ /* compatibility: no longer a returned error */
740740+#define MACH_RCV_HEADER_ERROR 0x1000400b
741741+ /* Error receiving message header. See special bits. */
742742+#define MACH_RCV_BODY_ERROR 0x1000400c
743743+ /* Error receiving message body. See special bits. */
744744+#define MACH_RCV_INVALID_TYPE 0x1000400d
745745+ /* Invalid msg-type specification in scatter list. */
746746+#define MACH_RCV_SCATTER_SMALL 0x1000400e
747747+ /* Out-of-line overwrite region is not large enough */
748748+#define MACH_RCV_INVALID_TRAILER 0x1000400f
749749+ /* trailer type or number of trailer elements not supported */
750750+#define MACH_RCV_IN_PROGRESS_TIMED 0x10004011
751751+ /* Waiting for receive with timeout. (Internal use only.) */
752752+753753+754754+__BEGIN_DECLS
755755+756756+/*
757757+ * Routine: mach_msg_overwrite
758758+ * Purpose:
759759+ * Send and/or receive a message. If the message operation
760760+ * is interrupted, and the user did not request an indication
761761+ * of that fact, then restart the appropriate parts of the
762762+ * operation silently (trap version does not restart).
763763+ *
764764+ * Distinct send and receive buffers may be specified. If
765765+ * no separate receive buffer is specified, the msg parameter
766766+ * will be used for both send and receive operations.
767767+ *
768768+ * In addition to a distinct receive buffer, that buffer may
769769+ * already contain scatter control information to direct the
770770+ * receiving of the message.
771771+ */
772772+773773+extern mach_msg_return_t mach_msg_overwrite(
774774+ mach_msg_header_t *msg,
775775+ mach_msg_option_t option,
776776+ mach_msg_size_t send_size,
777777+ mach_msg_size_t rcv_size,
778778+ mach_port_name_t rcv_name,
779779+ mach_msg_timeout_t timeout,
780780+ mach_port_name_t notify,
781781+ mach_msg_header_t *rcv_msg,
782782+ mach_msg_size_t rcv_limit);
783783+784784+#ifndef KERNEL
785785+786786+/*
787787+ * Routine: mach_msg
788788+ * Purpose:
789789+ * Send and/or receive a message. If the message operation
790790+ * is interrupted, and the user did not request an indication
791791+ * of that fact, then restart the appropriate parts of the
792792+ * operation silently (trap version does not restart).
793793+ */
794794+extern mach_msg_return_t mach_msg(
795795+ mach_msg_header_t *msg,
796796+ mach_msg_option_t option,
797797+ mach_msg_size_t send_size,
798798+ mach_msg_size_t rcv_size,
799799+ mach_port_name_t rcv_name,
800800+ mach_msg_timeout_t timeout,
801801+ mach_port_name_t notify);
802802+803803+#elif defined(MACH_KERNEL_PRIVATE)
804804+805805+extern mach_msg_return_t mach_msg_receive_results(void);
806806+807807+#endif /* KERNEL */
808808+809809+__END_DECLS
810810+811811+#endif /* _MACH_MESSAGE_H_ */
812812+
+372
libmac/xnu/mach/port.h
···11+/*
22+ * Copyright (c) 2000-2006 Apple Computer, Inc. All rights reserved.
33+ *
44+ * @APPLE_OSREFERENCE_LICENSE_HEADER_START@
55+ *
66+ * This file contains Original Code and/or Modifications of Original Code
77+ * as defined in and that are subject to the Apple Public Source License
88+ * Version 2.0 (the 'License'). You may not use this file except in
99+ * compliance with the License. The rights granted to you under the License
1010+ * may not be used to create, or enable the creation or redistribution of,
1111+ * unlawful or unlicensed copies of an Apple operating system, or to
1212+ * circumvent, violate, or enable the circumvention or violation of, any
1313+ * terms of an Apple operating system software license agreement.
1414+ *
1515+ * Please obtain a copy of the License at
1616+ * http://www.opensource.apple.com/apsl/ and read it before using this file.
1717+ *
1818+ * The Original Code and all software distributed under the License are
1919+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
2020+ * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
2121+ * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
2222+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
2323+ * Please see the License for the specific language governing rights and
2424+ * limitations under the License.
2525+ *
2626+ * @APPLE_OSREFERENCE_LICENSE_HEADER_END@
2727+ */
2828+/*
2929+ * @OSF_COPYRIGHT@
3030+ */
3131+/*
3232+ * Mach Operating System
3333+ * Copyright (c) 1991,1990,1989,1988,1987 Carnegie Mellon University
3434+ * All Rights Reserved.
3535+ *
3636+ * Permission to use, copy, modify and distribute this software and its
3737+ * documentation is hereby granted, provided that both the copyright
3838+ * notice and this permission notice appear in all copies of the
3939+ * software, derivative works or modified versions, and any portions
4040+ * thereof, and that both notices appear in supporting documentation.
4141+ *
4242+ * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
4343+ * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR
4444+ * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
4545+ *
4646+ * Carnegie Mellon requests users of this software to return to
4747+ *
4848+ * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU
4949+ * School of Computer Science
5050+ * Carnegie Mellon University
5151+ * Pittsburgh PA 15213-3890
5252+ *
5353+ * any improvements or extensions that they make and grant Carnegie Mellon
5454+ * the rights to redistribute these changes.
5555+ */
5656+/*
5757+ * NOTICE: This file was modified by McAfee Research in 2004 to introduce
5858+ * support for mandatory and extensible security protections. This notice
5959+ * is included in support of clause 2.2 (b) of the Apple Public License,
6060+ * Version 2.0.
6161+ */
6262+/*
6363+ */
6464+/*
6565+ * File: mach/port.h
6666+ *
6767+ * Definition of a Mach port
6868+ *
6969+ * Mach ports are the endpoints to Mach-implemented communications
7070+ * channels (usually uni-directional message queues, but other types
7171+ * also exist).
7272+ *
7373+ * Unique collections of these endpoints are maintained for each
7474+ * Mach task. Each Mach port in the task's collection is given a
7575+ * [task-local] name to identify it - and the the various "rights"
7676+ * held by the task for that specific endpoint.
7777+ *
7878+ * This header defines the types used to identify these Mach ports
7979+ * and the various rights associated with them. For more info see:
8080+ *
8181+ * <mach/mach_port.h> - manipulation of port rights in a given space
8282+ * <mach/message.h> - message queue [and port right passing] mechanism
8383+ *
8484+ */
8585+8686+#ifndef _MACH_PORT_H_
8787+#define _MACH_PORT_H_
8888+8989+#include <sys/cdefs.h>
9090+#include <stdint.h>
9191+#include <mach/boolean.h>
9292+#include <mach/machine/vm_types.h>
9393+9494+/*
9595+ * mach_port_name_t - the local identity for a Mach port
9696+ *
9797+ * The name is Mach port namespace specific. It is used to
9898+ * identify the rights held for that port by the task whose
9999+ * namespace is implied [or specifically provided].
100100+ *
101101+ * Use of this type usually implies just a name - no rights.
102102+ * See mach_port_t for a type that implies a "named right."
103103+ *
104104+ */
105105+106106+typedef natural_t mach_port_name_t;
107107+typedef mach_port_name_t *mach_port_name_array_t;
108108+109109+#ifdef KERNEL
110110+111111+/*
112112+ * mach_port_t - a named port right
113113+ *
114114+ * In the kernel, "rights" are represented [named] by pointers to
115115+ * the ipc port object in question. There is no port namespace for the
116116+ * rights to be collected.
117117+ *
118118+ * Actually, there is namespace for the kernel task. But most kernel
119119+ * code - including, but not limited to, Mach IPC code - lives in the
120120+ * limbo between the current user-level task and the "next" task. Very
121121+ * little of the kernel code runs in full kernel task context. So very
122122+ * little of it gets to use the kernel task's port name space.
123123+ *
124124+ * Because of this implementation approach, all in-kernel rights for
125125+ * a given port coalesce [have the same name/pointer]. The actual
126126+ * references are counted in the port itself. It is up to the kernel
127127+ * code in question to "just remember" how many [and what type of]
128128+ * rights it holds and handle them appropriately.
129129+ *
130130+ */
131131+132132+#ifndef MACH_KERNEL_PRIVATE
133133+/*
134134+ * For kernel code that resides outside of Mach proper, we opaque the
135135+ * port structure definition.
136136+ */
137137+struct ipc_port ;
138138+139139+#endif /* MACH_KERNEL_PRIVATE */
140140+141141+typedef struct ipc_port *ipc_port_t;
142142+143143+#define IPC_PORT_NULL ((ipc_port_t) 0UL)
144144+#define IPC_PORT_DEAD ((ipc_port_t)~0UL)
145145+#define IPC_PORT_VALID(port) \
146146+ ((port) != IPC_PORT_NULL && (port) != IPC_PORT_DEAD)
147147+148148+typedef ipc_port_t mach_port_t;
149149+150150+/*
151151+ * Since the 32-bit and 64-bit representations of ~0 are different,
152152+ * explicitly handle MACH_PORT_DEAD
153153+ */
154154+155155+#define CAST_MACH_PORT_TO_NAME(x) ((mach_port_name_t)(uintptr_t)(x))
156156+#define CAST_MACH_NAME_TO_PORT(x) ((x) == MACH_PORT_DEAD ? (mach_port_t)IPC_PORT_DEAD : (mach_port_t)(uintptr_t)(x))
157157+158158+#else /* KERNEL */
159159+160160+/*
161161+ * mach_port_t - a named port right
162162+ *
163163+ * In user-space, "rights" are represented by the name of the
164164+ * right in the Mach port namespace. Even so, this type is
165165+ * presented as a unique one to more clearly denote the presence
166166+ * of a right coming along with the name.
167167+ *
168168+ * Often, various rights for a port held in a single name space
169169+ * will coalesce and are, therefore, be identified by a single name
170170+ * [this is the case for send and receive rights]. But not
171171+ * always [send-once rights currently get a unique name for
172172+ * each right].
173173+ *
174174+ */
175175+176176+#ifndef _MACH_PORT_T
177177+#define _MACH_PORT_T
178178+typedef mach_port_name_t mach_port_t;
179179+#endif
180180+181181+#endif /* KERNEL */
182182+183183+typedef mach_port_t *mach_port_array_t;
184184+185185+/*
186186+ * MACH_PORT_NULL is a legal value that can be carried in messages.
187187+ * It indicates the absence of any port or port rights. (A port
188188+ * argument keeps the message from being "simple", even if the
189189+ * value is MACH_PORT_NULL.) The value MACH_PORT_DEAD is also a legal
190190+ * value that can be carried in messages. It indicates
191191+ * that a port right was present, but it died.
192192+ */
193193+194194+#define MACH_PORT_NULL 0 /* intentional loose typing */
195195+#define MACH_PORT_DEAD ((mach_port_name_t) ~0)
196196+#define MACH_PORT_VALID(name) \
197197+ (((name) != MACH_PORT_NULL) && \
198198+ ((name) != MACH_PORT_DEAD))
199199+200200+201201+/*
202202+ * For kernel-selected [assigned] port names, the name is
203203+ * comprised of two parts: a generation number and an index.
204204+ * This approach keeps the exact same name from being generated
205205+ * and reused too quickly [to catch right/reference counting bugs].
206206+ * The dividing line between the constituent parts is exposed so
207207+ * that efficient "mach_port_name_t to data structure pointer"
208208+ * conversion implementation can be made. But it is possible
209209+ * for user-level code to assign their own names to Mach ports.
210210+ * These are not required to participate in this algorithm. So
211211+ * care should be taken before "assuming" this model.
212212+ *
213213+ */
214214+215215+#ifndef NO_PORT_GEN
216216+217217+#define MACH_PORT_INDEX(name) ((name) >> 8)
218218+#define MACH_PORT_GEN(name) (((name) & 0xff) << 24)
219219+#define MACH_PORT_MAKE(index, gen) \
220220+ (((index) << 8) | (gen) >> 24)
221221+222222+#else /* NO_PORT_GEN */
223223+224224+#define MACH_PORT_INDEX(name) (name)
225225+#define MACH_PORT_GEN(name) (0)
226226+#define MACH_PORT_MAKE(index, gen) (index)
227227+228228+#endif /* NO_PORT_GEN */
229229+230230+231231+/*
232232+ * These are the different rights a task may have for a port.
233233+ * The MACH_PORT_RIGHT_* definitions are used as arguments
234234+ * to mach_port_allocate, mach_port_get_refs, etc, to specify
235235+ * a particular right to act upon. The mach_port_names and
236236+ * mach_port_type calls return bitmasks using the MACH_PORT_TYPE_*
237237+ * definitions. This is because a single name may denote
238238+ * multiple rights.
239239+ */
240240+241241+typedef natural_t mach_port_right_t;
242242+243243+#define MACH_PORT_RIGHT_SEND ((mach_port_right_t) 0)
244244+#define MACH_PORT_RIGHT_RECEIVE ((mach_port_right_t) 1)
245245+#define MACH_PORT_RIGHT_SEND_ONCE ((mach_port_right_t) 2)
246246+#define MACH_PORT_RIGHT_PORT_SET ((mach_port_right_t) 3)
247247+#define MACH_PORT_RIGHT_DEAD_NAME ((mach_port_right_t) 4)
248248+#define MACH_PORT_RIGHT_LABELH ((mach_port_right_t) 5)
249249+#define MACH_PORT_RIGHT_NUMBER ((mach_port_right_t) 6)
250250+251251+typedef natural_t mach_port_type_t;
252252+typedef mach_port_type_t *mach_port_type_array_t;
253253+254254+#define MACH_PORT_TYPE(right) \
255255+ ((mach_port_type_t)(((mach_port_type_t) 1) \
256256+ << ((right) + ((mach_port_right_t) 16))))
257257+#define MACH_PORT_TYPE_NONE ((mach_port_type_t) 0L)
258258+#define MACH_PORT_TYPE_SEND MACH_PORT_TYPE(MACH_PORT_RIGHT_SEND)
259259+#define MACH_PORT_TYPE_RECEIVE MACH_PORT_TYPE(MACH_PORT_RIGHT_RECEIVE)
260260+#define MACH_PORT_TYPE_SEND_ONCE MACH_PORT_TYPE(MACH_PORT_RIGHT_SEND_ONCE)
261261+#define MACH_PORT_TYPE_PORT_SET MACH_PORT_TYPE(MACH_PORT_RIGHT_PORT_SET)
262262+#define MACH_PORT_TYPE_DEAD_NAME MACH_PORT_TYPE(MACH_PORT_RIGHT_DEAD_NAME)
263263+#define MACH_PORT_TYPE_LABELH MACH_PORT_TYPE(MACH_PORT_RIGHT_LABELH)
264264+265265+/* Convenient combinations. */
266266+267267+#define MACH_PORT_TYPE_SEND_RECEIVE \
268268+ (MACH_PORT_TYPE_SEND|MACH_PORT_TYPE_RECEIVE)
269269+#define MACH_PORT_TYPE_SEND_RIGHTS \
270270+ (MACH_PORT_TYPE_SEND|MACH_PORT_TYPE_SEND_ONCE)
271271+#define MACH_PORT_TYPE_PORT_RIGHTS \
272272+ (MACH_PORT_TYPE_SEND_RIGHTS|MACH_PORT_TYPE_RECEIVE)
273273+#define MACH_PORT_TYPE_PORT_OR_DEAD \
274274+ (MACH_PORT_TYPE_PORT_RIGHTS|MACH_PORT_TYPE_DEAD_NAME)
275275+#define MACH_PORT_TYPE_ALL_RIGHTS \
276276+ (MACH_PORT_TYPE_PORT_OR_DEAD|MACH_PORT_TYPE_PORT_SET)
277277+278278+/* Dummy type bits that mach_port_type/mach_port_names can return. */
279279+280280+#define MACH_PORT_TYPE_DNREQUEST 0x80000000
281281+#define MACH_PORT_TYPE_SPREQUEST 0x40000000
282282+#define MACH_PORT_TYPE_SPREQUEST_DELAYED 0x20000000
283283+284284+/* User-references for capabilities. */
285285+286286+typedef natural_t mach_port_urefs_t;
287287+typedef integer_t mach_port_delta_t; /* change in urefs */
288288+289289+/* Attributes of ports. (See mach_port_get_receive_status.) */
290290+291291+typedef natural_t mach_port_seqno_t; /* sequence number */
292292+typedef natural_t mach_port_mscount_t; /* make-send count */
293293+typedef natural_t mach_port_msgcount_t; /* number of msgs */
294294+typedef natural_t mach_port_rights_t; /* number of rights */
295295+296296+/*
297297+ * Are there outstanding send rights for a given port?
298298+ */
299299+#define MACH_PORT_SRIGHTS_NONE 0 /* no srights */
300300+#define MACH_PORT_SRIGHTS_PRESENT 1 /* srights */
301301+typedef unsigned int mach_port_srights_t; /* status of send rights */
302302+303303+typedef struct mach_port_status {
304304+ mach_port_rights_t mps_pset; /* count of containing port sets */
305305+ mach_port_seqno_t mps_seqno; /* sequence number */
306306+ mach_port_mscount_t mps_mscount; /* make-send count */
307307+ mach_port_msgcount_t mps_qlimit; /* queue limit */
308308+ mach_port_msgcount_t mps_msgcount; /* number in the queue */
309309+ mach_port_rights_t mps_sorights; /* how many send-once rights */
310310+ boolean_t mps_srights; /* do send rights exist? */
311311+ boolean_t mps_pdrequest; /* port-deleted requested? */
312312+ boolean_t mps_nsrequest; /* no-senders requested? */
313313+ natural_t mps_flags; /* port flags */
314314+} mach_port_status_t;
315315+316316+/* System-wide values for setting queue limits on a port */
317317+#define MACH_PORT_QLIMIT_ZERO ((mach_port_msgcount_t) 0)
318318+#define MACH_PORT_QLIMIT_BASIC ((mach_port_msgcount_t) 5)
319319+#define MACH_PORT_QLIMIT_SMALL ((mach_port_msgcount_t) 16)
320320+#define MACH_PORT_QLIMIT_LARGE ((mach_port_msgcount_t) 1024)
321321+#define MACH_PORT_QLIMIT_KERNEL ((mach_port_msgcount_t) 65536)
322322+#define MACH_PORT_QLIMIT_MIN MACH_PORT_QLIMIT_ZERO
323323+#define MACH_PORT_QLIMIT_DEFAULT MACH_PORT_QLIMIT_BASIC
324324+#define MACH_PORT_QLIMIT_MAX MACH_PORT_QLIMIT_LARGE
325325+326326+typedef struct mach_port_limits {
327327+ mach_port_msgcount_t mpl_qlimit; /* number of msgs */
328328+} mach_port_limits_t;
329329+330330+typedef integer_t *mach_port_info_t; /* varying array of natural_t */
331331+332332+/* Flavors for mach_port_get/set_attributes() */
333333+typedef int mach_port_flavor_t;
334334+#define MACH_PORT_LIMITS_INFO 1 /* uses mach_port_status_t */
335335+#define MACH_PORT_RECEIVE_STATUS 2 /* uses mach_port_limits_t */
336336+#define MACH_PORT_DNREQUESTS_SIZE 3 /* info is int */
337337+338338+#define MACH_PORT_LIMITS_INFO_COUNT ((natural_t) \
339339+ (sizeof(mach_port_limits_t)/sizeof(natural_t)))
340340+#define MACH_PORT_RECEIVE_STATUS_COUNT ((natural_t) \
341341+ (sizeof(mach_port_status_t)/sizeof(natural_t)))
342342+#define MACH_PORT_DNREQUESTS_SIZE_COUNT 1
343343+344344+/*
345345+ * Structure used to pass information about port allocation requests.
346346+ * Must be padded to 64-bits total length.
347347+ */
348348+typedef struct mach_port_qos {
349349+ unsigned int name:1; /* name given */
350350+ unsigned int prealloc:1; /* prealloced message */
351351+ boolean_t pad1:30;
352352+ natural_t len;
353353+} mach_port_qos_t;
354354+355355+#if !__DARWIN_UNIX03 && !defined(_NO_PORT_T_FROM_MACH)
356356+/*
357357+ * Mach 3.0 renamed everything to have mach_ in front of it.
358358+ * These types and macros are provided for backward compatibility
359359+ * but are deprecated.
360360+ */
361361+typedef mach_port_t port_t;
362362+typedef mach_port_name_t port_name_t;
363363+typedef mach_port_name_t *port_name_array_t;
364364+365365+#define PORT_NULL ((port_t) 0)
366366+#define PORT_DEAD ((port_t) ~0)
367367+#define PORT_VALID(name) \
368368+ ((port_t)(name) != PORT_NULL && (port_t)(name) != PORT_DEAD)
369369+370370+#endif /* !__DARWIN_UNIX03 && !_NO_PORT_T_FROM_MACH */
371371+372372+#endif /* _MACH_PORT_H_ */
+99
libmac/xnu/mach/vm_attributes.h
···11+/*
22+ * Copyright (c) 2000-2002 Apple Computer, Inc. All rights reserved.
33+ *
44+ * @APPLE_OSREFERENCE_LICENSE_HEADER_START@
55+ *
66+ * This file contains Original Code and/or Modifications of Original Code
77+ * as defined in and that are subject to the Apple Public Source License
88+ * Version 2.0 (the 'License'). You may not use this file except in
99+ * compliance with the License. The rights granted to you under the License
1010+ * may not be used to create, or enable the creation or redistribution of,
1111+ * unlawful or unlicensed copies of an Apple operating system, or to
1212+ * circumvent, violate, or enable the circumvention or violation of, any
1313+ * terms of an Apple operating system software license agreement.
1414+ *
1515+ * Please obtain a copy of the License at
1616+ * http://www.opensource.apple.com/apsl/ and read it before using this file.
1717+ *
1818+ * The Original Code and all software distributed under the License are
1919+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
2020+ * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
2121+ * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
2222+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
2323+ * Please see the License for the specific language governing rights and
2424+ * limitations under the License.
2525+ *
2626+ * @APPLE_OSREFERENCE_LICENSE_HEADER_END@
2727+ */
2828+/*
2929+ * @OSF_COPYRIGHT@
3030+ */
3131+/*
3232+ * Mach Operating System
3333+ * Copyright (c) 1991,1990,1989,1988,1987 Carnegie Mellon University
3434+ * All Rights Reserved.
3535+ *
3636+ * Permission to use, copy, modify and distribute this software and its
3737+ * documentation is hereby granted, provided that both the copyright
3838+ * notice and this permission notice appear in all copies of the
3939+ * software, derivative works or modified versions, and any portions
4040+ * thereof, and that both notices appear in supporting documentation.
4141+ *
4242+ * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
4343+ * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR
4444+ * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
4545+ *
4646+ * Carnegie Mellon requests users of this software to return to
4747+ *
4848+ * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU
4949+ * School of Computer Science
5050+ * Carnegie Mellon University
5151+ * Pittsburgh PA 15213-3890
5252+ *
5353+ * any improvements or extensions that they make and grant Carnegie Mellon
5454+ * the rights to redistribute these changes.
5555+ */
5656+/*
5757+ */
5858+/*
5959+ * File: mach/vm_attributes.h
6060+ * Author: Alessandro Forin
6161+ *
6262+ * Virtual memory attributes definitions.
6363+ *
6464+ * These definitions are in addition to the machine-independent
6565+ * ones (e.g. protection), and are only selectively supported
6666+ * on specific machine architectures.
6767+ *
6868+ */
6969+7070+#ifndef _MACH_VM_ATTRIBUTES_H_
7171+#define _MACH_VM_ATTRIBUTES_H_
7272+7373+/*
7474+ * Types of machine-dependent attributes
7575+ */
7676+typedef unsigned int vm_machine_attribute_t;
7777+7878+#define MATTR_CACHE 1 /* cachability */
7979+#define MATTR_MIGRATE 2 /* migrability */
8080+#define MATTR_REPLICATE 4 /* replicability */
8181+8282+/*
8383+ * Values for the above, e.g. operations on attribute
8484+ */
8585+typedef int vm_machine_attribute_val_t;
8686+8787+#define MATTR_VAL_OFF 0 /* (generic) turn attribute off */
8888+#define MATTR_VAL_ON 1 /* (generic) turn attribute on */
8989+#define MATTR_VAL_GET 2 /* (generic) return current value */
9090+9191+#define MATTR_VAL_CACHE_FLUSH 6 /* flush from all caches */
9292+#define MATTR_VAL_DCACHE_FLUSH 7 /* flush from data caches */
9393+#define MATTR_VAL_ICACHE_FLUSH 8 /* flush from instruction caches */
9494+#define MATTR_VAL_CACHE_SYNC 9 /* sync I+D caches */
9595+#define MATTR_VAL_CACHE_SYNC 9 /* sync I+D caches */
9696+9797+#define MATTR_VAL_GET_INFO 10 /* get page info (stats) */
9898+9999+#endif /* _MACH_VM_ATTRIBUTES_H_ */
+78
libmac/xnu/mach/vm_behavior.h
···11+/*
22+ * Copyright (c) 2000-2002 Apple Computer, Inc. All rights reserved.
33+ *
44+ * @APPLE_OSREFERENCE_LICENSE_HEADER_START@
55+ *
66+ * This file contains Original Code and/or Modifications of Original Code
77+ * as defined in and that are subject to the Apple Public Source License
88+ * Version 2.0 (the 'License'). You may not use this file except in
99+ * compliance with the License. The rights granted to you under the License
1010+ * may not be used to create, or enable the creation or redistribution of,
1111+ * unlawful or unlicensed copies of an Apple operating system, or to
1212+ * circumvent, violate, or enable the circumvention or violation of, any
1313+ * terms of an Apple operating system software license agreement.
1414+ *
1515+ * Please obtain a copy of the License at
1616+ * http://www.opensource.apple.com/apsl/ and read it before using this file.
1717+ *
1818+ * The Original Code and all software distributed under the License are
1919+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
2020+ * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
2121+ * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
2222+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
2323+ * Please see the License for the specific language governing rights and
2424+ * limitations under the License.
2525+ *
2626+ * @APPLE_OSREFERENCE_LICENSE_HEADER_END@
2727+ */
2828+/*
2929+ * @OSF_COPYRIGHT@
3030+ */
3131+/*
3232+ * File: mach/vm_behavior.h
3333+ *
3434+ * Virtual memory map behavior definitions.
3535+ *
3636+ */
3737+3838+#ifndef _MACH_VM_BEHAVIOR_H_
3939+#define _MACH_VM_BEHAVIOR_H_
4040+4141+/*
4242+ * Types defined:
4343+ *
4444+ * vm_behavior_t behavior codes.
4545+ */
4646+4747+typedef int vm_behavior_t;
4848+4949+/*
5050+ * Enumeration of valid values for vm_behavior_t.
5151+ * These describe expected page reference behavior for
5252+ * for a given range of virtual memory. For implementation
5353+ * details see vm/vm_fault.c
5454+ */
5555+5656+5757+/*
5858+ * The following behaviors affect the memory region's future behavior
5959+ * and are stored in the VM map entry data structure.
6060+ */
6161+#define VM_BEHAVIOR_DEFAULT ((vm_behavior_t) 0) /* default */
6262+#define VM_BEHAVIOR_RANDOM ((vm_behavior_t) 1) /* random */
6363+#define VM_BEHAVIOR_SEQUENTIAL ((vm_behavior_t) 2) /* forward sequential */
6464+#define VM_BEHAVIOR_RSEQNTL ((vm_behavior_t) 3) /* reverse sequential */
6565+6666+/*
6767+ * The following "behaviors" affect the memory region only at the time of the
6868+ * call and are not stored in the VM map entry.
6969+ */
7070+#define VM_BEHAVIOR_WILLNEED ((vm_behavior_t) 4) /* will need in near future */
7171+#define VM_BEHAVIOR_DONTNEED ((vm_behavior_t) 5) /* dont need in near future */
7272+#define VM_BEHAVIOR_FREE ((vm_behavior_t) 6) /* free memory without write-back */
7373+#define VM_BEHAVIOR_ZERO_WIRED_PAGES ((vm_behavior_t) 7) /* zero out the wired pages of an entry if it is being deleted without unwiring them first */
7474+#define VM_BEHAVIOR_REUSABLE ((vm_behavior_t) 8)
7575+#define VM_BEHAVIOR_REUSE ((vm_behavior_t) 9)
7676+#define VM_BEHAVIOR_CAN_REUSE ((vm_behavior_t) 10)
7777+7878+#endif /*_MACH_VM_BEHAVIOR_H_*/
+89
libmac/xnu/mach/vm_inherit.h
···11+/*
22+ * Copyright (c) 2000-2002 Apple Computer, Inc. All rights reserved.
33+ *
44+ * @APPLE_OSREFERENCE_LICENSE_HEADER_START@
55+ *
66+ * This file contains Original Code and/or Modifications of Original Code
77+ * as defined in and that are subject to the Apple Public Source License
88+ * Version 2.0 (the 'License'). You may not use this file except in
99+ * compliance with the License. The rights granted to you under the License
1010+ * may not be used to create, or enable the creation or redistribution of,
1111+ * unlawful or unlicensed copies of an Apple operating system, or to
1212+ * circumvent, violate, or enable the circumvention or violation of, any
1313+ * terms of an Apple operating system software license agreement.
1414+ *
1515+ * Please obtain a copy of the License at
1616+ * http://www.opensource.apple.com/apsl/ and read it before using this file.
1717+ *
1818+ * The Original Code and all software distributed under the License are
1919+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
2020+ * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
2121+ * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
2222+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
2323+ * Please see the License for the specific language governing rights and
2424+ * limitations under the License.
2525+ *
2626+ * @APPLE_OSREFERENCE_LICENSE_HEADER_END@
2727+ */
2828+/*
2929+ * @OSF_COPYRIGHT@
3030+ */
3131+/*
3232+ * Mach Operating System
3333+ * Copyright (c) 1991,1990,1989,1988,1987 Carnegie Mellon University
3434+ * All Rights Reserved.
3535+ *
3636+ * Permission to use, copy, modify and distribute this software and its
3737+ * documentation is hereby granted, provided that both the copyright
3838+ * notice and this permission notice appear in all copies of the
3939+ * software, derivative works or modified versions, and any portions
4040+ * thereof, and that both notices appear in supporting documentation.
4141+ *
4242+ * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
4343+ * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR
4444+ * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
4545+ *
4646+ * Carnegie Mellon requests users of this software to return to
4747+ *
4848+ * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU
4949+ * School of Computer Science
5050+ * Carnegie Mellon University
5151+ * Pittsburgh PA 15213-3890
5252+ *
5353+ * any improvements or extensions that they make and grant Carnegie Mellon
5454+ * the rights to redistribute these changes.
5555+ */
5656+/*
5757+ */
5858+/*
5959+ * File: mach/vm_inherit.h
6060+ * Author: Avadis Tevanian, Jr., Michael Wayne Young
6161+ *
6262+ * Virtual memory map inheritance definitions.
6363+ *
6464+ */
6565+6666+#ifndef _MACH_VM_INHERIT_H_
6767+#define _MACH_VM_INHERIT_H_
6868+6969+/*
7070+ * Types defined:
7171+ *
7272+ * vm_inherit_t inheritance codes.
7373+ */
7474+7575+typedef unsigned int vm_inherit_t; /* might want to change this */
7676+7777+/*
7878+ * Enumeration of valid values for vm_inherit_t.
7979+ */
8080+8181+#define VM_INHERIT_SHARE ((vm_inherit_t) 0) /* share with child */
8282+#define VM_INHERIT_COPY ((vm_inherit_t) 1) /* copy into child */
8383+#define VM_INHERIT_NONE ((vm_inherit_t) 2) /* absent from child */
8484+#define VM_INHERIT_DONATE_COPY ((vm_inherit_t) 3) /* copy and delete */
8585+8686+#define VM_INHERIT_DEFAULT VM_INHERIT_COPY
8787+#define VM_INHERIT_LAST_VALID VM_INHERIT_NONE
8888+8989+#endif /* _MACH_VM_INHERIT_H_ */
+148
libmac/xnu/mach/vm_prot.h
···11+/*
22+ * Copyright (c) 2000-2002 Apple Computer, Inc. All rights reserved.
33+ *
44+ * @APPLE_OSREFERENCE_LICENSE_HEADER_START@
55+ *
66+ * This file contains Original Code and/or Modifications of Original Code
77+ * as defined in and that are subject to the Apple Public Source License
88+ * Version 2.0 (the 'License'). You may not use this file except in
99+ * compliance with the License. The rights granted to you under the License
1010+ * may not be used to create, or enable the creation or redistribution of,
1111+ * unlawful or unlicensed copies of an Apple operating system, or to
1212+ * circumvent, violate, or enable the circumvention or violation of, any
1313+ * terms of an Apple operating system software license agreement.
1414+ *
1515+ * Please obtain a copy of the License at
1616+ * http://www.opensource.apple.com/apsl/ and read it before using this file.
1717+ *
1818+ * The Original Code and all software distributed under the License are
1919+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
2020+ * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
2121+ * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
2222+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
2323+ * Please see the License for the specific language governing rights and
2424+ * limitations under the License.
2525+ *
2626+ * @APPLE_OSREFERENCE_LICENSE_HEADER_END@
2727+ */
2828+/*
2929+ * @OSF_COPYRIGHT@
3030+ */
3131+/*
3232+ * Mach Operating System
3333+ * Copyright (c) 1991,1990,1989,1988,1987 Carnegie Mellon University
3434+ * All Rights Reserved.
3535+ *
3636+ * Permission to use, copy, modify and distribute this software and its
3737+ * documentation is hereby granted, provided that both the copyright
3838+ * notice and this permission notice appear in all copies of the
3939+ * software, derivative works or modified versions, and any portions
4040+ * thereof, and that both notices appear in supporting documentation.
4141+ *
4242+ * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
4343+ * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR
4444+ * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
4545+ *
4646+ * Carnegie Mellon requests users of this software to return to
4747+ *
4848+ * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU
4949+ * School of Computer Science
5050+ * Carnegie Mellon University
5151+ * Pittsburgh PA 15213-3890
5252+ *
5353+ * any improvements or extensions that they make and grant Carnegie Mellon
5454+ * the rights to redistribute these changes.
5555+ */
5656+/*
5757+ */
5858+/*
5959+ * File: mach/vm_prot.h
6060+ * Author: Avadis Tevanian, Jr., Michael Wayne Young
6161+ *
6262+ * Virtual memory protection definitions.
6363+ *
6464+ */
6565+6666+#ifndef _MACH_VM_PROT_H_
6767+#define _MACH_VM_PROT_H_
6868+6969+/*
7070+ * Types defined:
7171+ *
7272+ * vm_prot_t VM protection values.
7373+ */
7474+7575+typedef int vm_prot_t;
7676+7777+/*
7878+ * Protection values, defined as bits within the vm_prot_t type
7979+ */
8080+8181+#define VM_PROT_NONE ((vm_prot_t) 0x00)
8282+8383+#define VM_PROT_READ ((vm_prot_t) 0x01) /* read permission */
8484+#define VM_PROT_WRITE ((vm_prot_t) 0x02) /* write permission */
8585+#define VM_PROT_EXECUTE ((vm_prot_t) 0x04) /* execute permission */
8686+8787+/*
8888+ * The default protection for newly-created virtual memory
8989+ */
9090+9191+#define VM_PROT_DEFAULT (VM_PROT_READ|VM_PROT_WRITE)
9292+9393+/*
9494+ * The maximum privileges possible, for parameter checking.
9595+ */
9696+9797+#define VM_PROT_ALL (VM_PROT_READ|VM_PROT_WRITE|VM_PROT_EXECUTE)
9898+9999+/*
100100+ * An invalid protection value.
101101+ * Used only by memory_object_lock_request to indicate no change
102102+ * to page locks. Using -1 here is a bad idea because it
103103+ * looks like VM_PROT_ALL and then some.
104104+ */
105105+106106+#define VM_PROT_NO_CHANGE ((vm_prot_t) 0x08)
107107+108108+/*
109109+ * When a caller finds that he cannot obtain write permission on a
110110+ * mapped entry, the following flag can be used. The entry will
111111+ * be made "needs copy" effectively copying the object (using COW),
112112+ * and write permission will be added to the maximum protections
113113+ * for the associated entry.
114114+ */
115115+116116+#define VM_PROT_COPY ((vm_prot_t) 0x10)
117117+118118+119119+/*
120120+ * Another invalid protection value.
121121+ * Used only by memory_object_data_request upon an object
122122+ * which has specified a copy_call copy strategy. It is used
123123+ * when the kernel wants a page belonging to a copy of the
124124+ * object, and is only asking the object as a result of
125125+ * following a shadow chain. This solves the race between pages
126126+ * being pushed up by the memory manager and the kernel
127127+ * walking down the shadow chain.
128128+ */
129129+130130+#define VM_PROT_WANTS_COPY ((vm_prot_t) 0x10)
131131+132132+#ifdef PRIVATE
133133+/*
134134+ * The caller wants this memory region treated as if it had a valid
135135+ * code signature.
136136+ */
137137+138138+#define VM_PROT_TRUSTED ((vm_prot_t) 0x20)
139139+#endif /* PRIVATE */
140140+141141+/*
142142+ * Another invalid protection value.
143143+ * Indicates that the other protection bits are to be applied as a mask
144144+ * against the actual protection bits of the map entry.
145145+ */
146146+#define VM_PROT_IS_MASK ((vm_prot_t) 0x40)
147147+148148+#endif /* _MACH_VM_PROT_H_ */
+322
libmac/xnu/mach/vm_region.h
···11+/*
22+ * Copyright (c) 2000-2006 Apple Computer, Inc. All rights reserved.
33+ *
44+ * @APPLE_OSREFERENCE_LICENSE_HEADER_START@
55+ *
66+ * This file contains Original Code and/or Modifications of Original Code
77+ * as defined in and that are subject to the Apple Public Source License
88+ * Version 2.0 (the 'License'). You may not use this file except in
99+ * compliance with the License. The rights granted to you under the License
1010+ * may not be used to create, or enable the creation or redistribution of,
1111+ * unlawful or unlicensed copies of an Apple operating system, or to
1212+ * circumvent, violate, or enable the circumvention or violation of, any
1313+ * terms of an Apple operating system software license agreement.
1414+ *
1515+ * Please obtain a copy of the License at
1616+ * http://www.opensource.apple.com/apsl/ and read it before using this file.
1717+ *
1818+ * The Original Code and all software distributed under the License are
1919+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
2020+ * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
2121+ * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
2222+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
2323+ * Please see the License for the specific language governing rights and
2424+ * limitations under the License.
2525+ *
2626+ * @APPLE_OSREFERENCE_LICENSE_HEADER_END@
2727+ */
2828+/*
2929+ * @OSF_COPYRIGHT@
3030+ */
3131+/*
3232+ * File: mach/vm_region.h
3333+ *
3434+ * Define the attributes of a task's memory region
3535+ *
3636+ */
3737+3838+#ifndef _MACH_VM_REGION_H_
3939+#define _MACH_VM_REGION_H_
4040+4141+#include <mach/boolean.h>
4242+#include <mach/vm_prot.h>
4343+#include <mach/vm_inherit.h>
4444+#include <mach/vm_behavior.h>
4545+#include <mach/vm_types.h>
4646+#include <mach/message.h>
4747+#include <mach/machine/vm_param.h>
4848+#include <mach/machine/vm_types.h>
4949+#include <mach/memory_object_types.h>
5050+5151+#include <sys/cdefs.h>
5252+5353+#pragma pack(4)
5454+5555+// LP64todo: all the current tools are 32bit, obviously never worked for 64b
5656+// so probably should be a real 32b ID vs. ptr.
5757+// Current users just check for equality
5858+typedef uint32_t vm32_object_id_t;
5959+6060+/*
6161+ * Types defined:
6262+ *
6363+ * vm_region_info_t memory region attributes
6464+ */
6565+6666+#define VM_REGION_INFO_MAX (1024)
6767+typedef int *vm_region_info_t;
6868+typedef int *vm_region_info_64_t;
6969+typedef int *vm_region_recurse_info_t;
7070+typedef int *vm_region_recurse_info_64_t;
7171+typedef int vm_region_flavor_t;
7272+typedef int vm_region_info_data_t[VM_REGION_INFO_MAX];
7373+7474+#define VM_REGION_BASIC_INFO_64 9
7575+struct vm_region_basic_info_64 {
7676+ vm_prot_t protection;
7777+ vm_prot_t max_protection;
7878+ vm_inherit_t inheritance;
7979+ boolean_t shared;
8080+ boolean_t reserved;
8181+ memory_object_offset_t offset;
8282+ vm_behavior_t behavior;
8383+ unsigned short user_wired_count;
8484+};
8585+typedef struct vm_region_basic_info_64 *vm_region_basic_info_64_t;
8686+typedef struct vm_region_basic_info_64 vm_region_basic_info_data_64_t;
8787+8888+#define VM_REGION_BASIC_INFO_COUNT_64 ((mach_msg_type_number_t) \
8989+ (sizeof(vm_region_basic_info_data_64_t)/sizeof(int)))
9090+9191+/*
9292+ * Passing VM_REGION_BASIC_INFO to vm_region_64
9393+ * automatically converts it to a VM_REGION_BASIC_INFO_64.
9494+ * Please use that explicitly instead.
9595+ */
9696+#define VM_REGION_BASIC_INFO 10
9797+9898+/*
9999+ * This is the legacy basic info structure. It is
100100+ * deprecated because it passes only a 32-bit memory object
101101+ * offset back - too small for many larger objects (e.g. files).
102102+ */
103103+struct vm_region_basic_info {
104104+ vm_prot_t protection;
105105+ vm_prot_t max_protection;
106106+ vm_inherit_t inheritance;
107107+ boolean_t shared;
108108+ boolean_t reserved;
109109+ uint32_t offset; /* too small for a real offset */
110110+ vm_behavior_t behavior;
111111+ unsigned short user_wired_count;
112112+};
113113+114114+typedef struct vm_region_basic_info *vm_region_basic_info_t;
115115+typedef struct vm_region_basic_info vm_region_basic_info_data_t;
116116+117117+#define VM_REGION_BASIC_INFO_COUNT ((mach_msg_type_number_t) \
118118+ (sizeof(vm_region_basic_info_data_t)/sizeof(int)))
119119+120120+#define VM_REGION_EXTENDED_INFO 11
121121+122122+#define SM_COW 1
123123+#define SM_PRIVATE 2
124124+#define SM_EMPTY 3
125125+#define SM_SHARED 4
126126+#define SM_TRUESHARED 5
127127+#define SM_PRIVATE_ALIASED 6
128128+#define SM_SHARED_ALIASED 7
129129+#define SM_LARGE_PAGE 8
130130+131131+/*
132132+ * For submap info, the SM flags above are overlayed when a submap
133133+ * is encountered. The field denotes whether or not machine level mapping
134134+ * information is being shared. PTE's etc. When such sharing is taking
135135+ * place the value returned is SM_TRUESHARED otherwise SM_PRIVATE is passed
136136+ * back.
137137+ */
138138+139139+struct vm_region_extended_info {
140140+ vm_prot_t protection;
141141+ unsigned int user_tag;
142142+ unsigned int pages_resident;
143143+ unsigned int pages_shared_now_private;
144144+ unsigned int pages_swapped_out;
145145+ unsigned int pages_dirtied;
146146+ unsigned int ref_count;
147147+ unsigned short shadow_depth;
148148+ unsigned char external_pager;
149149+ unsigned char share_mode;
150150+};
151151+152152+typedef struct vm_region_extended_info *vm_region_extended_info_t;
153153+typedef struct vm_region_extended_info vm_region_extended_info_data_t;
154154+155155+#define VM_REGION_EXTENDED_INFO_COUNT ((mach_msg_type_number_t) \
156156+ (sizeof(vm_region_extended_info_data_t)/sizeof(int)))
157157+158158+159159+#define VM_REGION_TOP_INFO 12
160160+161161+struct vm_region_top_info {
162162+ unsigned int obj_id;
163163+ unsigned int ref_count;
164164+ unsigned int private_pages_resident;
165165+ unsigned int shared_pages_resident;
166166+ unsigned char share_mode;
167167+};
168168+169169+typedef struct vm_region_top_info *vm_region_top_info_t;
170170+typedef struct vm_region_top_info vm_region_top_info_data_t;
171171+172172+#define VM_REGION_TOP_INFO_COUNT ((mach_msg_type_number_t) \
173173+ (sizeof(vm_region_top_info_data_t)/sizeof(int)))
174174+175175+176176+177177+/*
178178+ * vm_region_submap_info will return information on a submap or object.
179179+ * The user supplies a nesting level on the call. When a walk of the
180180+ * user's map is done and a submap is encountered, the nesting count is
181181+ * checked. If the nesting count is greater than 1 the submap is entered and
182182+ * the offset relative to the address in the base map is examined. If the
183183+ * nesting count is zero, the information on the submap is returned.
184184+ * The caller may thus learn about a submap and its contents by judicious
185185+ * choice of the base map address and nesting count. The nesting count
186186+ * allows penetration of recursively mapped submaps. If a submap is
187187+ * encountered as a mapped entry of another submap, the caller may bump
188188+ * the nesting count and call vm_region_recurse again on the target address
189189+ * range. The "is_submap" field tells the caller whether or not a submap
190190+ * has been encountered.
191191+ *
192192+ * Object only fields are filled in through a walking of the object shadow
193193+ * chain (where one is present), and a walking of the resident page queue.
194194+ *
195195+ */
196196+197197+struct vm_region_submap_info {
198198+ vm_prot_t protection; /* present access protection */
199199+ vm_prot_t max_protection; /* max avail through vm_prot */
200200+ vm_inherit_t inheritance;/* behavior of map/obj on fork */
201201+ uint32_t offset; /* offset into object/map */
202202+ unsigned int user_tag; /* user tag on map entry */
203203+ unsigned int pages_resident; /* only valid for objects */
204204+ unsigned int pages_shared_now_private; /* only for objects */
205205+ unsigned int pages_swapped_out; /* only for objects */
206206+ unsigned int pages_dirtied; /* only for objects */
207207+ unsigned int ref_count; /* obj/map mappers, etc */
208208+ unsigned short shadow_depth; /* only for obj */
209209+ unsigned char external_pager; /* only for obj */
210210+ unsigned char share_mode; /* see enumeration */
211211+ boolean_t is_submap; /* submap vs obj */
212212+ vm_behavior_t behavior; /* access behavior hint */
213213+ vm32_object_id_t object_id; /* obj/map name, not a handle */
214214+ unsigned short user_wired_count;
215215+};
216216+217217+typedef struct vm_region_submap_info *vm_region_submap_info_t;
218218+typedef struct vm_region_submap_info vm_region_submap_info_data_t;
219219+220220+#define VM_REGION_SUBMAP_INFO_COUNT ((mach_msg_type_number_t) \
221221+ (sizeof(vm_region_submap_info_data_t)/sizeof(int)))
222222+223223+struct vm_region_submap_info_64 {
224224+ vm_prot_t protection; /* present access protection */
225225+ vm_prot_t max_protection; /* max avail through vm_prot */
226226+ vm_inherit_t inheritance;/* behavior of map/obj on fork */
227227+ memory_object_offset_t offset; /* offset into object/map */
228228+ unsigned int user_tag; /* user tag on map entry */
229229+ unsigned int pages_resident; /* only valid for objects */
230230+ unsigned int pages_shared_now_private; /* only for objects */
231231+ unsigned int pages_swapped_out; /* only for objects */
232232+ unsigned int pages_dirtied; /* only for objects */
233233+ unsigned int ref_count; /* obj/map mappers, etc */
234234+ unsigned short shadow_depth; /* only for obj */
235235+ unsigned char external_pager; /* only for obj */
236236+ unsigned char share_mode; /* see enumeration */
237237+ boolean_t is_submap; /* submap vs obj */
238238+ vm_behavior_t behavior; /* access behavior hint */
239239+ vm32_object_id_t object_id; /* obj/map name, not a handle */
240240+ unsigned short user_wired_count;
241241+};
242242+243243+typedef struct vm_region_submap_info_64 *vm_region_submap_info_64_t;
244244+typedef struct vm_region_submap_info_64 vm_region_submap_info_data_64_t;
245245+246246+#define VM_REGION_SUBMAP_INFO_COUNT_64 ((mach_msg_type_number_t) \
247247+ (sizeof(vm_region_submap_info_data_64_t)/sizeof(int)))
248248+249249+struct vm_region_submap_short_info_64 {
250250+ vm_prot_t protection; /* present access protection */
251251+ vm_prot_t max_protection; /* max avail through vm_prot */
252252+ vm_inherit_t inheritance;/* behavior of map/obj on fork */
253253+ memory_object_offset_t offset; /* offset into object/map */
254254+ unsigned int user_tag; /* user tag on map entry */
255255+ unsigned int ref_count; /* obj/map mappers, etc */
256256+ unsigned short shadow_depth; /* only for obj */
257257+ unsigned char external_pager; /* only for obj */
258258+ unsigned char share_mode; /* see enumeration */
259259+ boolean_t is_submap; /* submap vs obj */
260260+ vm_behavior_t behavior; /* access behavior hint */
261261+ vm32_object_id_t object_id; /* obj/map name, not a handle */
262262+ unsigned short user_wired_count;
263263+};
264264+265265+typedef struct vm_region_submap_short_info_64 *vm_region_submap_short_info_64_t;
266266+typedef struct vm_region_submap_short_info_64 vm_region_submap_short_info_data_64_t;
267267+268268+#define VM_REGION_SUBMAP_SHORT_INFO_COUNT_64 ((mach_msg_type_number_t) \
269269+ (sizeof(vm_region_submap_short_info_data_64_t)/sizeof(int)))
270270+271271+272272+struct mach_vm_read_entry {
273273+ mach_vm_address_t address;
274274+ mach_vm_size_t size;
275275+};
276276+277277+struct vm_read_entry {
278278+ vm_address_t address;
279279+ vm_size_t size;
280280+};
281281+282282+#if VM32_SUPPORT
283283+struct vm32_read_entry {
284284+ vm32_address_t address;
285285+ vm32_size_t size;
286286+};
287287+#endif
288288+289289+290290+#define VM_MAP_ENTRY_MAX (256)
291291+292292+typedef struct mach_vm_read_entry mach_vm_read_entry_t[VM_MAP_ENTRY_MAX];
293293+typedef struct vm_read_entry vm_read_entry_t[VM_MAP_ENTRY_MAX];
294294+#if VM32_SUPPORT
295295+typedef struct vm32_read_entry vm32_read_entry_t[VM_MAP_ENTRY_MAX];
296296+#endif
297297+298298+#pragma pack()
299299+300300+301301+#define VM_PAGE_INFO_MAX
302302+typedef int *vm_page_info_t;
303303+typedef int vm_page_info_data_t[VM_PAGE_INFO_MAX];
304304+typedef int vm_page_info_flavor_t;
305305+306306+#define VM_PAGE_INFO_BASIC 1
307307+struct vm_page_info_basic {
308308+ int disposition;
309309+ int ref_count;
310310+ vm_object_id_t object_id;
311311+ memory_object_offset_t offset;
312312+ int depth;
313313+ int __pad; /* pad to 64-bit boundary */
314314+};
315315+typedef struct vm_page_info_basic *vm_page_info_basic_t;
316316+typedef struct vm_page_info_basic vm_page_info_basic_data_t;
317317+318318+#define VM_PAGE_INFO_BASIC_COUNT ((mach_msg_type_number_t) \
319319+ (sizeof(vm_page_info_basic_data_t)/sizeof(int)))
320320+321321+322322+#endif /*_MACH_VM_REGION_H_*/
+80
libmac/xnu/mach/vm_sync.h
···11+/*
22+ * Copyright (c) 2000-2002 Apple Computer, Inc. All rights reserved.
33+ *
44+ * @APPLE_OSREFERENCE_LICENSE_HEADER_START@
55+ *
66+ * This file contains Original Code and/or Modifications of Original Code
77+ * as defined in and that are subject to the Apple Public Source License
88+ * Version 2.0 (the 'License'). You may not use this file except in
99+ * compliance with the License. The rights granted to you under the License
1010+ * may not be used to create, or enable the creation or redistribution of,
1111+ * unlawful or unlicensed copies of an Apple operating system, or to
1212+ * circumvent, violate, or enable the circumvention or violation of, any
1313+ * terms of an Apple operating system software license agreement.
1414+ *
1515+ * Please obtain a copy of the License at
1616+ * http://www.opensource.apple.com/apsl/ and read it before using this file.
1717+ *
1818+ * The Original Code and all software distributed under the License are
1919+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
2020+ * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
2121+ * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
2222+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
2323+ * Please see the License for the specific language governing rights and
2424+ * limitations under the License.
2525+ *
2626+ * @APPLE_OSREFERENCE_LICENSE_HEADER_END@
2727+ */
2828+/*
2929+ * @OSF_COPYRIGHT@
3030+ */
3131+/*
3232+ * Mach Operating System
3333+ * Copyright (c) 1991,1990,1989,1988,1987 Carnegie Mellon University
3434+ * All Rights Reserved.
3535+ *
3636+ * Permission to use, copy, modify and distribute this software and its
3737+ * documentation is hereby granted, provided that both the copyright
3838+ * notice and this permission notice appear in all copies of the
3939+ * software, derivative works or modified versions, and any portions
4040+ * thereof, and that both notices appear in supporting documentation.
4141+ *
4242+ * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
4343+ * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR
4444+ * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
4545+ *
4646+ * Carnegie Mellon requests users of this software to return to
4747+ *
4848+ * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU
4949+ * School of Computer Science
5050+ * Carnegie Mellon University
5151+ * Pittsburgh PA 15213-3890
5252+ *
5353+ * any improvements or extensions that they make and grant Carnegie Mellon
5454+ * the rights to redistribute these changes.
5555+ */
5656+/*
5757+ * File: mach/vm_sync.h
5858+ *
5959+ * Virtual memory synchronisation definitions.
6060+ *
6161+ */
6262+6363+#ifndef _MACH_VM_SYNC_H_
6464+#define _MACH_VM_SYNC_H_
6565+6666+typedef unsigned vm_sync_t;
6767+6868+/*
6969+ * Synchronization flags, defined as bits within the vm_sync_t type
7070+ */
7171+7272+#define VM_SYNC_ASYNCHRONOUS ((vm_sync_t) 0x01)
7373+#define VM_SYNC_SYNCHRONOUS ((vm_sync_t) 0x02)
7474+#define VM_SYNC_INVALIDATE ((vm_sync_t) 0x04)
7575+#define VM_SYNC_KILLPAGES ((vm_sync_t) 0x08)
7676+#define VM_SYNC_DEACTIVATE ((vm_sync_t) 0x10)
7777+#define VM_SYNC_CONTIGUOUS ((vm_sync_t) 0x20)
7878+#define VM_SYNC_REUSABLEPAGES ((vm_sync_t) 0x40)
7979+8080+#endif /* _MACH_VM_SYNC_H_ */
+146
libmac/xnu/mach/vm_types.h
···11+/*
22+ * Copyright (c) 2000-2004 Apple Computer, Inc. All rights reserved.
33+ *
44+ * @APPLE_OSREFERENCE_LICENSE_HEADER_START@
55+ *
66+ * This file contains Original Code and/or Modifications of Original Code
77+ * as defined in and that are subject to the Apple Public Source License
88+ * Version 2.0 (the 'License'). You may not use this file except in
99+ * compliance with the License. The rights granted to you under the License
1010+ * may not be used to create, or enable the creation or redistribution of,
1111+ * unlawful or unlicensed copies of an Apple operating system, or to
1212+ * circumvent, violate, or enable the circumvention or violation of, any
1313+ * terms of an Apple operating system software license agreement.
1414+ *
1515+ * Please obtain a copy of the License at
1616+ * http://www.opensource.apple.com/apsl/ and read it before using this file.
1717+ *
1818+ * The Original Code and all software distributed under the License are
1919+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
2020+ * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
2121+ * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
2222+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
2323+ * Please see the License for the specific language governing rights and
2424+ * limitations under the License.
2525+ *
2626+ * @APPLE_OSREFERENCE_LICENSE_HEADER_END@
2727+ */
2828+/*
2929+ * @OSF_COPYRIGHT@
3030+ *
3131+ */
3232+#ifndef _MACH_VM_TYPES_H_
3333+#define _MACH_VM_TYPES_H_
3434+3535+#include <mach/port.h>
3636+#include <mach/machine/vm_types.h>
3737+3838+#include <stdint.h>
3939+4040+typedef vm_offset_t pointer_t;
4141+typedef vm_offset_t vm_address_t;
4242+4343+/*
4444+ * We use addr64_t for 64-bit addresses that are used on both
4545+ * 32 and 64-bit machines. On PPC, they are passed and returned as
4646+ * two adjacent 32-bit GPRs. We use addr64_t in places where
4747+ * common code must be useable both on 32 and 64-bit machines.
4848+ */
4949+typedef uint64_t addr64_t; /* Basic effective address */
5050+5151+/*
5252+ * We use reg64_t for addresses that are 32 bits on a 32-bit
5353+ * machine, and 64 bits on a 64-bit machine, but are always
5454+ * passed and returned in a single GPR on PPC. This type
5555+ * cannot be used in generic 32-bit c, since on a 64-bit
5656+ * machine the upper half of the register will be ignored
5757+ * by the c compiler in 32-bit mode. In c, we can only use the
5858+ * type in prototypes of functions that are written in and called
5959+ * from assembly language. This type is basically a comment.
6060+ */
6161+typedef uint32_t reg64_t;
6262+6363+/*
6464+ * To minimize the use of 64-bit fields, we keep some physical
6565+ * addresses (that are page aligned) as 32-bit page numbers.
6666+ * This limits the physical address space to 16TB of RAM.
6767+ */
6868+typedef uint32_t ppnum_t; /* Physical page number */
6969+#define PPNUM_MAX UINT32_MAX
7070+7171+7272+#ifdef KERNEL_PRIVATE
7373+7474+#include <sys/cdefs.h>
7575+7676+#ifndef MACH_KERNEL_PRIVATE
7777+/*
7878+ * Use specifically typed null structures for these in
7979+ * other parts of the kernel to enable compiler warnings
8080+ * about type mismatches, etc... Otherwise, these would
8181+ * be void*.
8282+ */
8383+__BEGIN_DECLS
8484+8585+struct pmap ;
8686+struct _vm_map ;
8787+struct vm_object ;
8888+8989+__END_DECLS
9090+9191+#endif /* MACH_KERNEL_PRIVATE */
9292+9393+typedef struct pmap *pmap_t;
9494+typedef struct _vm_map *vm_map_t;
9595+typedef struct vm_object *vm_object_t;
9696+typedef struct vm_object_fault_info *vm_object_fault_info_t;
9797+9898+#define PMAP_NULL ((pmap_t) 0)
9999+#define VM_OBJECT_NULL ((vm_object_t) 0)
100100+101101+#else /* KERNEL_PRIVATE */
102102+103103+typedef mach_port_t vm_map_t;
104104+105105+#endif /* KERNEL_PRIVATE */
106106+107107+#define VM_MAP_NULL ((vm_map_t) 0)
108108+109109+/*
110110+ * Evolving definitions, likely to change.
111111+ */
112112+113113+typedef uint64_t vm_object_offset_t;
114114+typedef uint64_t vm_object_size_t;
115115+116116+#ifdef KERNEL_PRIVATE
117117+118118+#ifndef MACH_KERNEL_PRIVATE
119119+120120+__BEGIN_DECLS
121121+122122+struct upl ;
123123+struct vm_map_copy ;
124124+struct vm_named_entry ;
125125+126126+__END_DECLS
127127+128128+#endif /* MACH_KERNEL_PRIVATE */
129129+130130+typedef struct upl *upl_t;
131131+typedef struct vm_map_copy *vm_map_copy_t;
132132+typedef struct vm_named_entry *vm_named_entry_t;
133133+134134+#define VM_MAP_COPY_NULL ((vm_map_copy_t) 0)
135135+136136+#else /* KERNEL_PRIVATE */
137137+138138+typedef mach_port_t upl_t;
139139+typedef mach_port_t vm_named_entry_t;
140140+141141+#endif /* KERNEL_PRIVATE */
142142+143143+#define UPL_NULL ((upl_t) 0)
144144+#define VM_NAMED_ENTRY_NULL ((vm_named_entry_t) 0)
145145+146146+#endif /* _MACH_VM_TYPES_H_ */