Begin work, MachO dylib patching tool

This commit is contained in:
Jonathan Campbell 2021-12-05 19:10:12 -08:00
parent af459318d9
commit 916e7d0f9c
182 changed files with 42957 additions and 3 deletions

7
ref/Apple/MachO/README Normal file
View File

@ -0,0 +1,7 @@
Apple MachO header files.
It has become necessary to develop an in-tree tool to change MachO dylib dependency commands
because the official XCode tool has made itself useless with neurotic hand-writing over something
about link edit data failing to fill a __LINKEDIT segment, as if anybody really cares.
And I copied the header files in case Apple decides to remove them from standard XCode installs too!

View File

@ -0,0 +1,150 @@
/*
* Copyright (c) 1999 Apple Computer, Inc. All rights reserved.
*
* @APPLE_LICENSE_HEADER_START@
*
* This file contains Original Code and/or Modifications of Original Code
* as defined in and that are subject to the Apple Public Source License
* Version 2.0 (the 'License'). You may not use this file except in
* compliance with the License. Please obtain a copy of the License at
* http://www.opensource.apple.com/apsl/ and read it before using this
* file.
*
* The Original Code and all software distributed under the License are
* distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
* Please see the License for the specific language governing rights and
* limitations under the License.
*
* @APPLE_LICENSE_HEADER_END@
*/
#ifndef _MACH_O_ARCH_H_
#define _MACH_O_ARCH_H_
/*
* Copyright (c) 1997 Apple Computer, Inc.
*
* Functions that deal with information about architectures.
*
*/
#include <stdint.h>
#include <mach/machine.h>
#include <architecture/byte_order.h>
/* The NXArchInfo structs contain the architectures symbolic name
* (such as "ppc"), its CPU type and CPU subtype as defined in
* mach/machine.h, the byte order for the architecture, and a
* describing string (such as "PowerPC").
* There will both be entries for specific CPUs (such as ppc604e) as
* well as generic "family" entries (such as ppc).
*/
typedef struct {
const char *name;
cpu_type_t cputype;
cpu_subtype_t cpusubtype;
enum NXByteOrder byteorder;
const char *description;
} NXArchInfo;
#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */
/* NXGetAllArchInfos() returns a pointer to an array of all known
* NXArchInfo structures. The last NXArchInfo is marked by a NULL name.
*/
extern const NXArchInfo *NXGetAllArchInfos(void);
/* NXGetLocalArchInfo() returns the NXArchInfo for the local host, or NULL
* if none is known.
*/
extern const NXArchInfo *NXGetLocalArchInfo(void);
/* NXGetArchInfoFromName() and NXGetArchInfoFromCpuType() return the
* NXArchInfo from the architecture's name or cputype/cpusubtype
* combination. A cpusubtype of CPU_SUBTYPE_MULTIPLE can be used
* to request the most general NXArchInfo known for the given cputype.
* NULL is returned if no matching NXArchInfo can be found.
*/
extern const NXArchInfo *NXGetArchInfoFromName(const char *name);
extern const NXArchInfo *NXGetArchInfoFromCpuType(cpu_type_t cputype,
cpu_subtype_t cpusubtype);
/* The above interfaces that return pointers to NXArchInfo structs in normal
* cases returns a pointer from the array returned in NXGetAllArchInfos().
* In some cases when the cputype is CPU_TYPE_I386 or CPU_TYPE_POWERPC it will
* retun malloc(3)'ed NXArchInfo struct which contains a string in the
* description field also a malloc(3)'ed pointer. To allow programs not to
* leak memory they can call NXFreeArchInfo() on pointers returned from the
* above interfaces. Since this is a new API on older systems can use the
* code below. Going forward the above interfaces will only return pointers
* from the array returned in NXGetAllArchInfos().
*/
extern void NXFreeArchInfo(const NXArchInfo *x);
/* The code that can be used for NXFreeArchInfo() when it is not available is:
*
* static void NXFreeArchInfo(
* const NXArchInfo *x)
* {
* const NXArchInfo *p;
*
* p = NXGetAllArchInfos();
* while(p->name != NULL){
* if(x == p)
* return;
* p++;
* }
* free((char *)x->description);
* free((NXArchInfo *)x);
* }
*/
/* NXFindBestFatArch() is passed a cputype and cpusubtype and a set of
* fat_arch structs and selects the best one that matches (if any) and returns
* a pointer to that fat_arch struct (or NULL). The fat_arch structs must be
* in the host byte order and correct such that the fat_archs really points to
* enough memory for nfat_arch structs. It is possible that this routine could
* fail if new cputypes or cpusubtypes are added and an old version of this
* routine is used. But if there is an exact match between the cputype and
* cpusubtype and one of the fat_arch structs this routine will always succeed.
*/
extern struct fat_arch *NXFindBestFatArch(cpu_type_t cputype,
cpu_subtype_t cpusubtype,
struct fat_arch *fat_archs,
uint32_t nfat_archs);
/* NXFindBestFatArch_64() is passed a cputype and cpusubtype and a set of
* fat_arch_64 structs and selects the best one that matches (if any) and
* returns a pointer to that fat_arch_64 struct (or NULL). The fat_arch_64
* structs must be in the host byte order and correct such that the fat_archs64
* really points to enough memory for nfat_arch structs. It is possible that
* this routine could fail if new cputypes or cpusubtypes are added and an old
* version of this routine is used. But if there is an exact match between the
* cputype and cpusubtype and one of the fat_arch_64 structs this routine will
* always succeed.
*/
extern struct fat_arch_64 *NXFindBestFatArch_64(cpu_type_t cputype,
cpu_subtype_t cpusubtype,
struct fat_arch_64 *fat_archs64,
uint32_t nfat_archs);
/* NXCombineCpuSubtypes() returns the resulting cpusubtype when combining two
* different cpusubtypes for the specified cputype. If the two cpusubtypes
* can't be combined (the specific subtypes are mutually exclusive) -1 is
* returned indicating it is an error to combine them. This can also fail and
* return -1 if new cputypes or cpusubtypes are added and an old version of
* this routine is used. But if the cpusubtypes are the same they can always
* be combined and this routine will return the cpusubtype pass in.
*/
extern cpu_subtype_t NXCombineCpuSubtypes(cpu_type_t cputype,
cpu_subtype_t cpusubtype1,
cpu_subtype_t cpusubtype2);
#ifdef __cplusplus
}
#endif /* __cplusplus */
#endif /* _MACH_O_ARCH_H_ */

View File

@ -0,0 +1,60 @@
/*
* Copyright (c) 1999 Apple Computer, Inc. All rights reserved.
*
* @APPLE_LICENSE_HEADER_START@
*
* This file contains Original Code and/or Modifications of Original Code
* as defined in and that are subject to the Apple Public Source License
* Version 2.0 (the 'License'). You may not use this file except in
* compliance with the License. Please obtain a copy of the License at
* http://www.opensource.apple.com/apsl/ and read it before using this
* file.
*
* The Original Code and all software distributed under the License are
* distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
* Please see the License for the specific language governing rights and
* limitations under the License.
*
* @APPLE_LICENSE_HEADER_END@
*/
/*
* Relocation types used in the arm implementation. Relocation entries for
* things other than instructions use the same generic relocation as discribed
* in <mach-o/reloc.h> and their r_type is ARM_RELOC_VANILLA, one of the
* *_SECTDIFF or the *_PB_LA_PTR types. The rest of the relocation types are
* for instructions. Since they are for instructions the r_address field
* indicates the 32 bit instruction that the relocation is to be preformed on.
*/
enum reloc_type_arm
{
ARM_RELOC_VANILLA, /* generic relocation as discribed above */
ARM_RELOC_PAIR, /* the second relocation entry of a pair */
ARM_RELOC_SECTDIFF, /* a PAIR follows with subtract symbol value */
ARM_RELOC_LOCAL_SECTDIFF, /* like ARM_RELOC_SECTDIFF, but the symbol
referenced was local. */
ARM_RELOC_PB_LA_PTR,/* prebound lazy pointer */
ARM_RELOC_BR24, /* 24 bit branch displacement (to a word address) */
ARM_THUMB_RELOC_BR22, /* 22 bit branch displacement (to a half-word
address) */
ARM_THUMB_32BIT_BRANCH, /* obsolete - a thumb 32-bit branch instruction
possibly needing page-spanning branch workaround */
/*
* For these two r_type relocations they always have a pair following them
* and the r_length bits are used differently. The encoding of the
* r_length is as follows:
* low bit of r_length:
* 0 - :lower16: for movw instructions
* 1 - :upper16: for movt instructions
* high bit of r_length:
* 0 - arm instructions
* 1 - thumb instructions
* the other half of the relocated expression is in the following pair
* relocation entry in the the low 16 bits of r_address field.
*/
ARM_RELOC_HALF,
ARM_RELOC_HALF_SECTDIFF
};

View File

@ -0,0 +1,68 @@
/*
* Copyright (c) 2010 Apple Computer, Inc. All rights reserved.
*
* @APPLE_LICENSE_HEADER_START@
*
* This file contains Original Code and/or Modifications of Original Code
* as defined in and that are subject to the Apple Public Source License
* Version 2.0 (the 'License'). You may not use this file except in
* compliance with the License. Please obtain a copy of the License at
* http://www.opensource.apple.com/apsl/ and read it before using this
* file.
*
* The Original Code and all software distributed under the License are
* distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
* Please see the License for the specific language governing rights and
* limitations under the License.
*
* @APPLE_LICENSE_HEADER_END@
*/
#ifndef _MACHO_ARM64_RELOC_H_
#define _MACHO_ARM64_RELOC_H_
/*
* Relocation types used in the arm64 implementation.
*/
enum reloc_type_arm64
{
ARM64_RELOC_UNSIGNED, // for pointers
ARM64_RELOC_SUBTRACTOR, // must be followed by a ARM64_RELOC_UNSIGNED
ARM64_RELOC_BRANCH26, // a B/BL instruction with 26-bit displacement
ARM64_RELOC_PAGE21, // pc-rel distance to page of target
ARM64_RELOC_PAGEOFF12, // offset within page, scaled by r_length
ARM64_RELOC_GOT_LOAD_PAGE21, // pc-rel distance to page of GOT slot
ARM64_RELOC_GOT_LOAD_PAGEOFF12, // offset within page of GOT slot,
// scaled by r_length
ARM64_RELOC_POINTER_TO_GOT, // for pointers to GOT slots
ARM64_RELOC_TLVP_LOAD_PAGE21, // pc-rel distance to page of TLVP slot
ARM64_RELOC_TLVP_LOAD_PAGEOFF12, // offset within page of TLVP slot,
// scaled by r_length
ARM64_RELOC_ADDEND, // must be followed by PAGE21 or PAGEOFF12
// An arm64e authenticated pointer.
//
// Represents a pointer to a symbol (like ARM64_RELOC_UNSIGNED).
// Additionally, the resulting pointer is signed. The signature is
// specified in the target location: the addend is restricted to the lower
// 32 bits (instead of the full 64 bits for ARM64_RELOC_UNSIGNED):
//
// |63|62|61-51|50-49| 48 |47 - 32|31 - 0|
// | 1| 0| 0 | key | addr | discriminator | addend |
//
// The key is one of:
// IA: 00 IB: 01
// DA: 10 DB: 11
//
// The discriminator field is used as extra signature diversification.
//
// The addr field indicates whether the target address should be blended
// into the discriminator.
//
ARM64_RELOC_AUTHENTICATED_POINTER,
};
#endif /* #ifndef _MACHO_ARM64_RELOC_H_ */

View File

@ -0,0 +1,533 @@
//===------------------ mach-o/compact_unwind_encoding.h ------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//
// Darwin's alternative to DWARF based unwind encodings.
//
//===----------------------------------------------------------------------===//
#ifndef __COMPACT_UNWIND_ENCODING__
#define __COMPACT_UNWIND_ENCODING__
#include <stdint.h>
//
// Compilers can emit standard DWARF FDEs in the __TEXT,__eh_frame section
// of object files. Or compilers can emit compact unwind information in
// the __LD,__compact_unwind section.
//
// When the linker creates a final linked image, it will create a
// __TEXT,__unwind_info section. This section is a small and fast way for the
// runtime to access unwind info for any given function. If the compiler
// emitted compact unwind info for the function, that compact unwind info will
// be encoded in the __TEXT,__unwind_info section. If the compiler emitted
// DWARF unwind info, the __TEXT,__unwind_info section will contain the offset
// of the FDE in the __TEXT,__eh_frame section in the final linked image.
//
// Note: Previously, the linker would transform some DWARF unwind infos into
// compact unwind info. But that is fragile and no longer done.
//
// The compact unwind endoding is a 32-bit value which encoded in an
// architecture specific way, which registers to restore from where, and how
// to unwind out of the function.
//
typedef uint32_t compact_unwind_encoding_t;
// architecture independent bits
enum {
UNWIND_IS_NOT_FUNCTION_START = 0x80000000,
UNWIND_HAS_LSDA = 0x40000000,
UNWIND_PERSONALITY_MASK = 0x30000000,
};
//
// x86
//
// 1-bit: start
// 1-bit: has lsda
// 2-bit: personality index
//
// 4-bits: 0=old, 1=ebp based, 2=stack-imm, 3=stack-ind, 4=DWARF
// ebp based:
// 15-bits (5*3-bits per reg) register permutation
// 8-bits for stack offset
// frameless:
// 8-bits stack size
// 3-bits stack adjust
// 3-bits register count
// 10-bits register permutation
//
enum {
UNWIND_X86_MODE_MASK = 0x0F000000,
UNWIND_X86_MODE_EBP_FRAME = 0x01000000,
UNWIND_X86_MODE_STACK_IMMD = 0x02000000,
UNWIND_X86_MODE_STACK_IND = 0x03000000,
UNWIND_X86_MODE_DWARF = 0x04000000,
UNWIND_X86_EBP_FRAME_REGISTERS = 0x00007FFF,
UNWIND_X86_EBP_FRAME_OFFSET = 0x00FF0000,
UNWIND_X86_FRAMELESS_STACK_SIZE = 0x00FF0000,
UNWIND_X86_FRAMELESS_STACK_ADJUST = 0x0000E000,
UNWIND_X86_FRAMELESS_STACK_REG_COUNT = 0x00001C00,
UNWIND_X86_FRAMELESS_STACK_REG_PERMUTATION = 0x000003FF,
UNWIND_X86_DWARF_SECTION_OFFSET = 0x00FFFFFF,
};
enum {
UNWIND_X86_REG_NONE = 0,
UNWIND_X86_REG_EBX = 1,
UNWIND_X86_REG_ECX = 2,
UNWIND_X86_REG_EDX = 3,
UNWIND_X86_REG_EDI = 4,
UNWIND_X86_REG_ESI = 5,
UNWIND_X86_REG_EBP = 6,
};
//
// For x86 there are four modes for the compact unwind encoding:
// UNWIND_X86_MODE_EBP_FRAME:
// EBP based frame where EBP is push on stack immediately after return address,
// then ESP is moved to EBP. Thus, to unwind ESP is restored with the current
// EPB value, then EBP is restored by popping off the stack, and the return
// is done by popping the stack once more into the pc.
// All non-volatile registers that need to be restored must have been saved
// in a small range in the stack that starts EBP-4 to EBP-1020. The offset/4
// is encoded in the UNWIND_X86_EBP_FRAME_OFFSET bits. The registers saved
// are encoded in the UNWIND_X86_EBP_FRAME_REGISTERS bits as five 3-bit entries.
// Each entry contains which register to restore.
// UNWIND_X86_MODE_STACK_IMMD:
// A "frameless" (EBP not used as frame pointer) function with a small
// constant stack size. To return, a constant (encoded in the compact
// unwind encoding) is added to the ESP. Then the return is done by
// popping the stack into the pc.
// All non-volatile registers that need to be restored must have been saved
// on the stack immediately after the return address. The stack_size/4 is
// encoded in the UNWIND_X86_FRAMELESS_STACK_SIZE (max stack size is 1024).
// The number of registers saved is encoded in UNWIND_X86_FRAMELESS_STACK_REG_COUNT.
// UNWIND_X86_FRAMELESS_STACK_REG_PERMUTATION constains which registers were
// saved and their order.
// UNWIND_X86_MODE_STACK_IND:
// A "frameless" (EBP not used as frame pointer) function large constant
// stack size. This case is like the previous, except the stack size is too
// large to encode in the compact unwind encoding. Instead it requires that
// the function contains "subl $nnnnnnnn,ESP" in its prolog. The compact
// encoding contains the offset to the nnnnnnnn value in the function in
// UNWIND_X86_FRAMELESS_STACK_SIZE.
// UNWIND_X86_MODE_DWARF:
// No compact unwind encoding is available. Instead the low 24-bits of the
// compact encoding is the offset of the DWARF FDE in the __eh_frame section.
// This mode is never used in object files. It is only generated by the
// linker in final linked images which have only DWARF unwind info for a
// function.
//
// The permutation encoding is a Lehmer code sequence encoded into a
// single variable-base number so we can encode the ordering of up to
// six registers in a 10-bit space.
//
// The following is the algorithm used to create the permutation encoding used
// with frameless stacks. It is passed the number of registers to be saved and
// an array of the register numbers saved.
//
//uint32_t permute_encode(uint32_t registerCount, const uint32_t registers[6])
//{
// uint32_t renumregs[6];
// for (int i=6-registerCount; i < 6; ++i) {
// int countless = 0;
// for (int j=6-registerCount; j < i; ++j) {
// if ( registers[j] < registers[i] )
// ++countless;
// }
// renumregs[i] = registers[i] - countless -1;
// }
// uint32_t permutationEncoding = 0;
// switch ( registerCount ) {
// case 6:
// permutationEncoding |= (120*renumregs[0] + 24*renumregs[1]
// + 6*renumregs[2] + 2*renumregs[3]
// + renumregs[4]);
// break;
// case 5:
// permutationEncoding |= (120*renumregs[1] + 24*renumregs[2]
// + 6*renumregs[3] + 2*renumregs[4]
// + renumregs[5]);
// break;
// case 4:
// permutationEncoding |= (60*renumregs[2] + 12*renumregs[3]
// + 3*renumregs[4] + renumregs[5]);
// break;
// case 3:
// permutationEncoding |= (20*renumregs[3] + 4*renumregs[4]
// + renumregs[5]);
// break;
// case 2:
// permutationEncoding |= (5*renumregs[4] + renumregs[5]);
// break;
// case 1:
// permutationEncoding |= (renumregs[5]);
// break;
// }
// return permutationEncoding;
//}
//
//
// x86_64
//
// 1-bit: start
// 1-bit: has lsda
// 2-bit: personality index
//
// 4-bits: 0=old, 1=rbp based, 2=stack-imm, 3=stack-ind, 4=DWARF
// rbp based:
// 15-bits (5*3-bits per reg) register permutation
// 8-bits for stack offset
// frameless:
// 8-bits stack size
// 3-bits stack adjust
// 3-bits register count
// 10-bits register permutation
//
enum {
UNWIND_X86_64_MODE_MASK = 0x0F000000,
UNWIND_X86_64_MODE_RBP_FRAME = 0x01000000,
UNWIND_X86_64_MODE_STACK_IMMD = 0x02000000,
UNWIND_X86_64_MODE_STACK_IND = 0x03000000,
UNWIND_X86_64_MODE_DWARF = 0x04000000,
UNWIND_X86_64_RBP_FRAME_REGISTERS = 0x00007FFF,
UNWIND_X86_64_RBP_FRAME_OFFSET = 0x00FF0000,
UNWIND_X86_64_FRAMELESS_STACK_SIZE = 0x00FF0000,
UNWIND_X86_64_FRAMELESS_STACK_ADJUST = 0x0000E000,
UNWIND_X86_64_FRAMELESS_STACK_REG_COUNT = 0x00001C00,
UNWIND_X86_64_FRAMELESS_STACK_REG_PERMUTATION = 0x000003FF,
UNWIND_X86_64_DWARF_SECTION_OFFSET = 0x00FFFFFF,
};
enum {
UNWIND_X86_64_REG_NONE = 0,
UNWIND_X86_64_REG_RBX = 1,
UNWIND_X86_64_REG_R12 = 2,
UNWIND_X86_64_REG_R13 = 3,
UNWIND_X86_64_REG_R14 = 4,
UNWIND_X86_64_REG_R15 = 5,
UNWIND_X86_64_REG_RBP = 6,
};
//
// For x86_64 there are four modes for the compact unwind encoding:
// UNWIND_X86_64_MODE_RBP_FRAME:
// RBP based frame where RBP is push on stack immediately after return address,
// then RSP is moved to RBP. Thus, to unwind RSP is restored with the current
// EPB value, then RBP is restored by popping off the stack, and the return
// is done by popping the stack once more into the pc.
// All non-volatile registers that need to be restored must have been saved
// in a small range in the stack that starts RBP-8 to RBP-2040. The offset/8
// is encoded in the UNWIND_X86_64_RBP_FRAME_OFFSET bits. The registers saved
// are encoded in the UNWIND_X86_64_RBP_FRAME_REGISTERS bits as five 3-bit entries.
// Each entry contains which register to restore.
// UNWIND_X86_64_MODE_STACK_IMMD:
// A "frameless" (RBP not used as frame pointer) function with a small
// constant stack size. To return, a constant (encoded in the compact
// unwind encoding) is added to the RSP. Then the return is done by
// popping the stack into the pc.
// All non-volatile registers that need to be restored must have been saved
// on the stack immediately after the return address. The stack_size/8 is
// encoded in the UNWIND_X86_64_FRAMELESS_STACK_SIZE (max stack size is 2048).
// The number of registers saved is encoded in UNWIND_X86_64_FRAMELESS_STACK_REG_COUNT.
// UNWIND_X86_64_FRAMELESS_STACK_REG_PERMUTATION constains which registers were
// saved and their order.
// UNWIND_X86_64_MODE_STACK_IND:
// A "frameless" (RBP not used as frame pointer) function large constant
// stack size. This case is like the previous, except the stack size is too
// large to encode in the compact unwind encoding. Instead it requires that
// the function contains "subq $nnnnnnnn,RSP" in its prolog. The compact
// encoding contains the offset to the nnnnnnnn value in the function in
// UNWIND_X86_64_FRAMELESS_STACK_SIZE.
// UNWIND_X86_64_MODE_DWARF:
// No compact unwind encoding is available. Instead the low 24-bits of the
// compact encoding is the offset of the DWARF FDE in the __eh_frame section.
// This mode is never used in object files. It is only generated by the
// linker in final linked images which have only DWARF unwind info for a
// function.
//
// ARM64
//
// 1-bit: start
// 1-bit: has lsda
// 2-bit: personality index
//
// 4-bits: 4=frame-based, 3=DWARF, 2=frameless
// frameless:
// 12-bits of stack size
// frame-based:
// 4-bits D reg pairs saved
// 5-bits X reg pairs saved
// DWARF:
// 24-bits offset of DWARF FDE in __eh_frame section
//
enum {
UNWIND_ARM64_MODE_MASK = 0x0F000000,
UNWIND_ARM64_MODE_FRAMELESS = 0x02000000,
UNWIND_ARM64_MODE_DWARF = 0x03000000,
UNWIND_ARM64_MODE_FRAME = 0x04000000,
UNWIND_ARM64_FRAME_X19_X20_PAIR = 0x00000001,
UNWIND_ARM64_FRAME_X21_X22_PAIR = 0x00000002,
UNWIND_ARM64_FRAME_X23_X24_PAIR = 0x00000004,
UNWIND_ARM64_FRAME_X25_X26_PAIR = 0x00000008,
UNWIND_ARM64_FRAME_X27_X28_PAIR = 0x00000010,
UNWIND_ARM64_FRAME_D8_D9_PAIR = 0x00000100,
UNWIND_ARM64_FRAME_D10_D11_PAIR = 0x00000200,
UNWIND_ARM64_FRAME_D12_D13_PAIR = 0x00000400,
UNWIND_ARM64_FRAME_D14_D15_PAIR = 0x00000800,
UNWIND_ARM64_FRAMELESS_STACK_SIZE_MASK = 0x00FFF000,
UNWIND_ARM64_DWARF_SECTION_OFFSET = 0x00FFFFFF,
};
// For arm64 there are three modes for the compact unwind encoding:
// UNWIND_ARM64_MODE_FRAME:
// This is a standard arm64 prolog where FP/LR are immediately pushed on the
// stack, then SP is copied to FP. If there are any non-volatile registers
// saved, then are copied into the stack frame in pairs in a contiguous
// range right below the saved FP/LR pair. Any subset of the five X pairs
// and four D pairs can be saved, but the memory layout must be in register
// number order.
// UNWIND_ARM64_MODE_FRAMELESS:
// A "frameless" leaf function, where FP/LR are not saved. The return address
// remains in LR throughout the function. If any non-volatile registers
// are saved, they must be pushed onto the stack before any stack space is
// allocated for local variables. The stack sized (including any saved
// non-volatile registers) divided by 16 is encoded in the bits
// UNWIND_ARM64_FRAMELESS_STACK_SIZE_MASK.
// UNWIND_ARM64_MODE_DWARF:
// No compact unwind encoding is available. Instead the low 24-bits of the
// compact encoding is the offset of the DWARF FDE in the __eh_frame section.
// This mode is never used in object files. It is only generated by the
// linker in final linked images which have only DWARF unwind info for a
// function.
//
#ifndef __OPEN_SOURCE__
//
// armv7k
//
// 1-bit: start
// 1-bit: has lsda
// 2-bit: personality index
//
// 4-bits: 1=frame, 2=frame+dregs, 4=dwarf
//
enum {
UNWIND_ARM_MODE_MASK = 0x0F000000,
UNWIND_ARM_MODE_FRAME = 0x01000000,
UNWIND_ARM_MODE_FRAME_D = 0x02000000,
UNWIND_ARM_MODE_DWARF = 0x04000000,
UNWIND_ARM_FRAME_STACK_ADJUST_MASK = 0x00C00000,
UNWIND_ARM_FRAME_FIRST_PUSH_R4 = 0x00000001,
UNWIND_ARM_FRAME_FIRST_PUSH_R5 = 0x00000002,
UNWIND_ARM_FRAME_FIRST_PUSH_R6 = 0x00000004,
UNWIND_ARM_FRAME_SECOND_PUSH_R8 = 0x00000008,
UNWIND_ARM_FRAME_SECOND_PUSH_R9 = 0x00000010,
UNWIND_ARM_FRAME_SECOND_PUSH_R10 = 0x00000020,
UNWIND_ARM_FRAME_SECOND_PUSH_R11 = 0x00000040,
UNWIND_ARM_FRAME_SECOND_PUSH_R12 = 0x00000080,
UNWIND_ARM_FRAME_D_REG_COUNT_MASK = 0x00000700,
UNWIND_ARM_DWARF_SECTION_OFFSET = 0x00FFFFFF,
};
// For armv7k there are three modes for the compact unwind encoding:
// UNWIND_ARM_MODE_FRAME:
// This is a standard arm prolog where lr/r7 are immediately pushed on the
// stack. As part of that first push r4, r5, or r6 can be also pushed
// and if so the FIRST_PUSH bit is set in the compact unwind. Additionally
// there can be a second push multiple which can save r8 through r12.
// If that is used, the registers saved is recorded with a SECOND_PUSH bit.
// Lastly, for var-args support, the prolog may save r1, r2, r3 to the
// stack before the frame push. If that is done the STACK_ADJUST_MASK
// records that the stack pointer must be adjust (e.g 0x00800000 means
// the stack pointer was adjusted 8 bytes down and the unwinder would
// need to add back 8 bytes to SP when unwinding through this function.
// UNWIND_ARM_MODE_FRAME_D:
// This is the same as UNWIND_ARM_MODE_FRAME, except that additionally
// some D registers were saved. The D_REG_COUNT_MASK contains which
// set if D registers were saved and where. There are currently 8 (0-7)
// possible D register save patterns supported.
// UNWIND_ARM_MODE_DWARF:
// No compact unwind encoding is available. Instead the low 24-bits of the
// compact encoding is the offset of the dwarf FDE in the __eh_frame section.
// The offset only exists in final linked images. It is zero in object files.
#endif
////////////////////////////////////////////////////////////////////////////////
//
// Relocatable Object Files: __LD,__compact_unwind
//
////////////////////////////////////////////////////////////////////////////////
//
// A compiler can generated compact unwind information for a function by adding
// a "row" to the __LD,__compact_unwind section. This section has the
// S_ATTR_DEBUG bit set, so the section will be ignored by older linkers.
// It is removed by the new linker, so never ends up in final executables.
// This section is a table, initially with one row per function (that needs
// unwind info). The table columns and some conceptual entries are:
//
// range-start pointer to start of function/range
// range-length
// compact-unwind-encoding 32-bit encoding
// personality-function or zero if no personality function
// lsda or zero if no LSDA data
//
// The length and encoding fields are 32-bits. The other are all pointer sized.
//
// In x86_64 assembly, these entry would look like:
//
// .section __LD,__compact_unwind,regular,debug
//
// #compact unwind for _foo
// .quad _foo
// .set L1,LfooEnd-_foo
// .long L1
// .long 0x01010001
// .quad 0
// .quad 0
//
// #compact unwind for _bar
// .quad _bar
// .set L2,LbarEnd-_bar
// .long L2
// .long 0x01020011
// .quad __gxx_personality
// .quad except_tab1
//
//
// Notes: There is no need for any labels in the the __compact_unwind section.
// The use of the .set directive is to force the evaluation of the
// range-length at assembly time, instead of generating relocations.
//
// To support future compiler optimizations where which non-volatile registers
// are saved changes within a function (e.g. delay saving non-volatiles until
// necessary), there can by multiple lines in the __compact_unwind table for one
// function, each with a different (non-overlapping) range and each with
// different compact unwind encodings that correspond to the non-volatiles
// saved at that range of the function.
//
// If a particular function is so wacky that there is no compact unwind way
// to encode it, then the compiler can emit traditional DWARF unwind info.
// The runtime will use which ever is available.
//
// Runtime support for compact unwind encodings are only available on 10.6
// and later. So, the compiler should not generate it when targeting pre-10.6.
////////////////////////////////////////////////////////////////////////////////
//
// Final Linked Images: __TEXT,__unwind_info
//
////////////////////////////////////////////////////////////////////////////////
//
// The __TEXT,__unwind_info section is laid out for an efficient two level lookup.
// The header of the section contains a coarse index that maps function address
// to the page (4096 byte block) containing the unwind info for that function.
//
#define UNWIND_SECTION_VERSION 1
struct unwind_info_section_header
{
uint32_t version; // UNWIND_SECTION_VERSION
uint32_t commonEncodingsArraySectionOffset;
uint32_t commonEncodingsArrayCount;
uint32_t personalityArraySectionOffset;
uint32_t personalityArrayCount;
uint32_t indexSectionOffset;
uint32_t indexCount;
// compact_unwind_encoding_t[]
// uint32_t personalities[]
// unwind_info_section_header_index_entry[]
// unwind_info_section_header_lsda_index_entry[]
};
struct unwind_info_section_header_index_entry
{
uint32_t functionOffset;
uint32_t secondLevelPagesSectionOffset; // section offset to start of regular or compress page
uint32_t lsdaIndexArraySectionOffset; // section offset to start of lsda_index array for this range
};
struct unwind_info_section_header_lsda_index_entry
{
uint32_t functionOffset;
uint32_t lsdaOffset;
};
//
// There are two kinds of second level index pages: regular and compressed.
// A compressed page can hold up to 1021 entries, but it cannot be used
// if too many different encoding types are used. The regular page holds
// 511 entries.
//
struct unwind_info_regular_second_level_entry
{
uint32_t functionOffset;
compact_unwind_encoding_t encoding;
};
#define UNWIND_SECOND_LEVEL_REGULAR 2
struct unwind_info_regular_second_level_page_header
{
uint32_t kind; // UNWIND_SECOND_LEVEL_REGULAR
uint16_t entryPageOffset;
uint16_t entryCount;
// entry array
};
#define UNWIND_SECOND_LEVEL_COMPRESSED 3
struct unwind_info_compressed_second_level_page_header
{
uint32_t kind; // UNWIND_SECOND_LEVEL_COMPRESSED
uint16_t entryPageOffset;
uint16_t entryCount;
uint16_t encodingsPageOffset;
uint16_t encodingsCount;
// 32-bit entry array
// encodings array
};
#define UNWIND_INFO_COMPRESSED_ENTRY_FUNC_OFFSET(entry) (entry & 0x00FFFFFF)
#define UNWIND_INFO_COMPRESSED_ENTRY_ENCODING_INDEX(entry) ((entry >> 24) & 0xFF)
#endif

View File

@ -0,0 +1,4 @@
module MachO.compact_unwind_encoding [system] [extern_c] {
header "compact_unwind_encoding.h"
export *
}

View File

@ -0,0 +1,272 @@
/*
* Copyright (c) 1999-2008 Apple Inc. All rights reserved.
*
* @APPLE_LICENSE_HEADER_START@
*
* This file contains Original Code and/or Modifications of Original Code
* as defined in and that are subject to the Apple Public Source License
* Version 2.0 (the 'License'). You may not use this file except in
* compliance with the License. Please obtain a copy of the License at
* http://www.opensource.apple.com/apsl/ and read it before using this
* file.
*
* The Original Code and all software distributed under the License are
* distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
* Please see the License for the specific language governing rights and
* limitations under the License.
*
* @APPLE_LICENSE_HEADER_END@
*/
#ifndef _MACH_O_DYLD_H_
#define _MACH_O_DYLD_H_
#include <stddef.h>
#include <stdint.h>
#include <stdbool.h>
#include <mach-o/loader.h>
#include <Availability.h>
#if __cplusplus
extern "C" {
#endif
#ifdef __DRIVERKIT_19_0
#define DYLD_DRIVERKIT_UNAVAILABLE __API_UNAVAILABLE(driverkit)
#else
#define DYLD_DRIVERKIT_UNAVAILABLE
#endif
/*
* The following functions allow you to iterate through all loaded images.
* This is not a thread safe operation. Another thread can add or remove
* an image during the iteration.
*
* Many uses of these routines can be replace by a call to dladdr() which
* will return the mach_header and name of an image, given an address in
* the image. dladdr() is thread safe.
*/
extern uint32_t _dyld_image_count(void) __OSX_AVAILABLE_STARTING(__MAC_10_1, __IPHONE_2_0);
extern const struct mach_header* _dyld_get_image_header(uint32_t image_index) __OSX_AVAILABLE_STARTING(__MAC_10_1, __IPHONE_2_0);
extern intptr_t _dyld_get_image_vmaddr_slide(uint32_t image_index) __OSX_AVAILABLE_STARTING(__MAC_10_1, __IPHONE_2_0);
extern const char* _dyld_get_image_name(uint32_t image_index) __OSX_AVAILABLE_STARTING(__MAC_10_1, __IPHONE_2_0);
/*
* The following functions allow you to install callbacks which will be called
* by dyld whenever an image is loaded or unloaded. During a call to _dyld_register_func_for_add_image()
* the callback func is called for every existing image. Later, it is called as each new image
* is loaded and bound (but initializers not yet run). The callback registered with
* _dyld_register_func_for_remove_image() is called after any terminators in an image are run
* and before the image is un-memory-mapped.
*/
extern void _dyld_register_func_for_add_image(void (*func)(const struct mach_header* mh, intptr_t vmaddr_slide)) __OSX_AVAILABLE_STARTING(__MAC_10_1, __IPHONE_2_0);
extern void _dyld_register_func_for_remove_image(void (*func)(const struct mach_header* mh, intptr_t vmaddr_slide)) __OSX_AVAILABLE_STARTING(__MAC_10_1, __IPHONE_2_0);
/*
* NSVersionOfRunTimeLibrary() returns the current_version number of the currently dylib
* specifed by the libraryName. The libraryName parameter would be "bar" for /path/libbar.3.dylib and
* "Foo" for /path/Foo.framework/Versions/A/Foo. It returns -1 if no such library is loaded.
*/
extern int32_t NSVersionOfRunTimeLibrary(const char* libraryName) __OSX_AVAILABLE_STARTING(__MAC_10_1, __IPHONE_2_0);
/*
* NSVersionOfLinkTimeLibrary() returns the current_version number that the main executable was linked
* against at build time. The libraryName parameter would be "bar" for /path/libbar.3.dylib and
* "Foo" for /path/Foo.framework/Versions/A/Foo. It returns -1 if the main executable did not link
* against the specified library.
*/
extern int32_t NSVersionOfLinkTimeLibrary(const char* libraryName) __OSX_AVAILABLE_STARTING(__MAC_10_1, __IPHONE_2_0);
/*
* _NSGetExecutablePath() copies the path of the main executable into the buffer. The bufsize parameter
* should initially be the size of the buffer. The function returns 0 if the path was successfully copied,
* and *bufsize is left unchanged. It returns -1 if the buffer is not large enough, and *bufsize is set
* to the size required.
*
* Note that _NSGetExecutablePath will return "a path" to the executable not a "real path" to the executable.
* That is the path may be a symbolic link and not the real file. With deep directories the total bufsize
* needed could be more than MAXPATHLEN.
*/
extern int _NSGetExecutablePath(char* buf, uint32_t* bufsize) __OSX_AVAILABLE_STARTING(__MAC_10_2, __IPHONE_2_0);
/*
* Registers a function to be called when the current thread terminates.
* Called by c++ compiler to implement destructors on thread_local object variables.
*/
extern void _tlv_atexit(void (*termFunc)(void* objAddr), void* objAddr) __OSX_AVAILABLE_STARTING(__MAC_10_10, __IPHONE_8_0);
/*
* Never called. On-disk thread local variables contain a pointer to this. Once
* the thread local is prepared, the pointer changes to a real handler such as tlv_get_addr.
*/
extern void _tlv_bootstrap(void) __OSX_AVAILABLE_STARTING(__MAC_10_10, __IPHONE_8_0) DYLD_DRIVERKIT_UNAVAILABLE ;
/*
* Dylibs that are incorporated into the dyld cache are removed from disk. That means code
* cannot stat() the file to see if it "exists". This function is like a stat() call that checks if a
* path is to a dylib that was removed from disk and is incorporated into the active dyld cache.
*/
extern bool _dyld_shared_cache_contains_path(const char* path) __API_AVAILABLE(macos(11.0), ios(14.0), watchos(7.0), tvos(14.0)) DYLD_DRIVERKIT_UNAVAILABLE;
/*
* The following dyld API's are deprecated as of Mac OS X 10.5. They are either
* no longer necessary or are superceeded by dlopen and friends in <dlfcn.h>.
* dlopen/dlsym/dlclose have been available since Mac OS X 10.3 and work with
* dylibs and bundles.
*
* NSAddImage -> dlopen
* NSLookupSymbolInImage -> dlsym
* NSCreateObjectFileImageFromFile -> dlopen
* NSDestroyObjectFileImage -> dlclose
* NSLinkModule -> not needed when dlopen used
* NSUnLinkModule -> not needed when dlclose used
* NSLookupSymbolInModule -> dlsym
* _dyld_image_containing_address -> dladdr
* NSLinkEditError -> dlerror
*
*/
#ifndef ENUM_DYLD_BOOL
#define ENUM_DYLD_BOOL
#undef FALSE
#undef TRUE
enum DYLD_BOOL { FALSE, TRUE };
#endif /* ENUM_DYLD_BOOL */
/* Object file image API */
typedef enum {
NSObjectFileImageFailure, /* for this a message is printed on stderr */
NSObjectFileImageSuccess,
NSObjectFileImageInappropriateFile,
NSObjectFileImageArch,
NSObjectFileImageFormat, /* for this a message is printed on stderr */
NSObjectFileImageAccess
} NSObjectFileImageReturnCode;
typedef struct __NSObjectFileImage* NSObjectFileImage;
/* NSObjectFileImage can only be used with MH_BUNDLE files */
extern NSObjectFileImageReturnCode NSCreateObjectFileImageFromFile(const char* pathName, NSObjectFileImage *objectFileImage) __API_UNAVAILABLE(ios, tvos, watchos) DYLD_DRIVERKIT_UNAVAILABLE __OSX_DEPRECATED(10.1, 10.5, "dlopen()");
extern NSObjectFileImageReturnCode NSCreateObjectFileImageFromMemory(const void *address, size_t size, NSObjectFileImage *objectFileImage) __API_UNAVAILABLE(ios, tvos, watchos) DYLD_DRIVERKIT_UNAVAILABLE __OSX_DEPRECATED(10.1, 10.5, "");
extern bool NSDestroyObjectFileImage(NSObjectFileImage objectFileImage) __API_UNAVAILABLE(ios, tvos, watchos) DYLD_DRIVERKIT_UNAVAILABLE __OSX_DEPRECATED(10.1, 10.5, "dlclose()");
extern uint32_t NSSymbolDefinitionCountInObjectFileImage(NSObjectFileImage objectFileImage) __API_UNAVAILABLE(ios, tvos, watchos) DYLD_DRIVERKIT_UNAVAILABLE __OSX_DEPRECATED(10.1, 10.5, "");
extern const char* NSSymbolDefinitionNameInObjectFileImage(NSObjectFileImage objectFileImage, uint32_t ordinal) __API_UNAVAILABLE(ios, tvos, watchos) DYLD_DRIVERKIT_UNAVAILABLE __OSX_DEPRECATED(10.1, 10.5, "");
extern uint32_t NSSymbolReferenceCountInObjectFileImage(NSObjectFileImage objectFileImage) __API_UNAVAILABLE(ios, tvos, watchos) DYLD_DRIVERKIT_UNAVAILABLE __OSX_DEPRECATED(10.1, 10.5, "");
extern const char* NSSymbolReferenceNameInObjectFileImage(NSObjectFileImage objectFileImage, uint32_t ordinal, bool *tentative_definition) __API_UNAVAILABLE(ios, tvos, watchos) DYLD_DRIVERKIT_UNAVAILABLE __OSX_DEPRECATED(10.1, 10.5, "");
extern bool NSIsSymbolDefinedInObjectFileImage(NSObjectFileImage objectFileImage, const char* symbolName) __API_UNAVAILABLE(ios, tvos, watchos) DYLD_DRIVERKIT_UNAVAILABLE __OSX_DEPRECATED(10.1, 10.4, "dlsym()");
extern void* NSGetSectionDataInObjectFileImage(NSObjectFileImage objectFileImage, const char* segmentName, const char* sectionName, size_t *size) __API_UNAVAILABLE(ios, tvos, watchos) DYLD_DRIVERKIT_UNAVAILABLE __OSX_DEPRECATED(10.1, 10.5, "getsectiondata()");
typedef struct __NSModule* NSModule;
extern const char* NSNameOfModule(NSModule m) __API_UNAVAILABLE(ios, tvos, watchos) DYLD_DRIVERKIT_UNAVAILABLE __OSX_DEPRECATED(10.1, 10.5, "");
extern const char* NSLibraryNameForModule(NSModule m) __API_UNAVAILABLE(ios, tvos, watchos) DYLD_DRIVERKIT_UNAVAILABLE __OSX_DEPRECATED(10.1, 10.5, "");
extern NSModule NSLinkModule(NSObjectFileImage objectFileImage, const char* moduleName, uint32_t options) __API_UNAVAILABLE(ios, tvos, watchos) DYLD_DRIVERKIT_UNAVAILABLE __OSX_DEPRECATED(10.1, 10.5, "dlopen()");
#define NSLINKMODULE_OPTION_NONE 0x0
#define NSLINKMODULE_OPTION_BINDNOW 0x1
#define NSLINKMODULE_OPTION_PRIVATE 0x2
#define NSLINKMODULE_OPTION_RETURN_ON_ERROR 0x4
#define NSLINKMODULE_OPTION_DONT_CALL_MOD_INIT_ROUTINES 0x8
#define NSLINKMODULE_OPTION_TRAILING_PHYS_NAME 0x10
extern bool NSUnLinkModule(NSModule module, uint32_t options) __API_UNAVAILABLE(ios, tvos, watchos) DYLD_DRIVERKIT_UNAVAILABLE __OSX_DEPRECATED(10.1, 10.5, "");
#define NSUNLINKMODULE_OPTION_NONE 0x0
#define NSUNLINKMODULE_OPTION_KEEP_MEMORY_MAPPED 0x1
#define NSUNLINKMODULE_OPTION_RESET_LAZY_REFERENCES 0x2
/* symbol API */
typedef struct __NSSymbol* NSSymbol;
extern bool NSIsSymbolNameDefined(const char* symbolName) __API_UNAVAILABLE(ios, tvos, watchos) DYLD_DRIVERKIT_UNAVAILABLE __OSX_DEPRECATED(10.1, 10.4, "dlsym()");
extern bool NSIsSymbolNameDefinedWithHint(const char* symbolName, const char* libraryNameHint) __API_UNAVAILABLE(ios, tvos, watchos) DYLD_DRIVERKIT_UNAVAILABLE __OSX_DEPRECATED(10.1, 10.4, "dlsym()");
extern bool NSIsSymbolNameDefinedInImage(const struct mach_header* image, const char* symbolName) __API_UNAVAILABLE(ios, tvos, watchos) DYLD_DRIVERKIT_UNAVAILABLE __OSX_DEPRECATED(10.1, 10.4, "dlsym()");
extern NSSymbol NSLookupAndBindSymbol(const char* symbolName) __API_UNAVAILABLE(ios, tvos, watchos) DYLD_DRIVERKIT_UNAVAILABLE __OSX_DEPRECATED(10.1, 10.4, "dlsym()");
extern NSSymbol NSLookupAndBindSymbolWithHint(const char* symbolName, const char* libraryNameHint) __API_UNAVAILABLE(ios, tvos, watchos) DYLD_DRIVERKIT_UNAVAILABLE __OSX_DEPRECATED(10.1, 10.4, "dlsym()");
extern NSSymbol NSLookupSymbolInModule(NSModule module, const char* symbolName) __API_UNAVAILABLE(ios, tvos, watchos) DYLD_DRIVERKIT_UNAVAILABLE __OSX_DEPRECATED(10.1, 10.5, "dlsym()");
extern NSSymbol NSLookupSymbolInImage(const struct mach_header* image, const char* symbolName, uint32_t options) __API_UNAVAILABLE(ios, tvos, watchos) DYLD_DRIVERKIT_UNAVAILABLE __OSX_DEPRECATED(10.1, 10.5, "dlsym()");
#define NSLOOKUPSYMBOLINIMAGE_OPTION_BIND 0x0
#define NSLOOKUPSYMBOLINIMAGE_OPTION_BIND_NOW 0x1
#define NSLOOKUPSYMBOLINIMAGE_OPTION_BIND_FULLY 0x2
#define NSLOOKUPSYMBOLINIMAGE_OPTION_RETURN_ON_ERROR 0x4
extern const char* NSNameOfSymbol(NSSymbol symbol) __API_UNAVAILABLE(ios, tvos, watchos) DYLD_DRIVERKIT_UNAVAILABLE __OSX_DEPRECATED(10.1, 10.5, "");
extern void * NSAddressOfSymbol(NSSymbol symbol) __API_UNAVAILABLE(ios, tvos, watchos) DYLD_DRIVERKIT_UNAVAILABLE __OSX_DEPRECATED(10.1, 10.5, "dlsym()");
extern NSModule NSModuleForSymbol(NSSymbol symbol) __API_UNAVAILABLE(ios, tvos, watchos) DYLD_DRIVERKIT_UNAVAILABLE __OSX_DEPRECATED(10.1, 10.5, "dladdr()");
/* error handling API */
typedef enum {
NSLinkEditFileAccessError,
NSLinkEditFileFormatError,
NSLinkEditMachResourceError,
NSLinkEditUnixResourceError,
NSLinkEditOtherError,
NSLinkEditWarningError,
NSLinkEditMultiplyDefinedError,
NSLinkEditUndefinedError
} NSLinkEditErrors;
/*
* For the NSLinkEditErrors value NSLinkEditOtherError these are the values
* passed to the link edit error handler as the errorNumber (what would be an
* errno value for NSLinkEditUnixResourceError or a kern_return_t value for
* NSLinkEditMachResourceError).
*/
typedef enum {
NSOtherErrorRelocation,
NSOtherErrorLazyBind,
NSOtherErrorIndrLoop,
NSOtherErrorLazyInit,
NSOtherErrorInvalidArgs
} NSOtherErrorNumbers;
extern void NSLinkEditError(NSLinkEditErrors *c, int *errorNumber, const char** fileName, const char** errorString) __API_UNAVAILABLE(ios, tvos, watchos) DYLD_DRIVERKIT_UNAVAILABLE __OSX_DEPRECATED(10.1, 10.5, "dlerror()");
typedef struct {
void (*undefined)(const char* symbolName);
NSModule (*multiple)(NSSymbol s, NSModule oldModule, NSModule newModule);
void (*linkEdit)(NSLinkEditErrors errorClass, int errorNumber,
const char* fileName, const char* errorString);
} NSLinkEditErrorHandlers;
extern void NSInstallLinkEditErrorHandlers(const NSLinkEditErrorHandlers *handlers) __API_UNAVAILABLE(ios, tvos, watchos) DYLD_DRIVERKIT_UNAVAILABLE __OSX_DEPRECATED(10.1, 10.5, "");
extern bool NSAddLibrary(const char* pathName) __API_UNAVAILABLE(ios, tvos, watchos) DYLD_DRIVERKIT_UNAVAILABLE __OSX_DEPRECATED(10.1, 10.4, "dlopen()");
extern bool NSAddLibraryWithSearching(const char* pathName) __API_UNAVAILABLE(ios, tvos, watchos) DYLD_DRIVERKIT_UNAVAILABLE __OSX_DEPRECATED(10.1, 10.4, "dlopen()");
extern const struct mach_header* NSAddImage(const char* image_name, uint32_t options) __API_UNAVAILABLE(ios, tvos, watchos) DYLD_DRIVERKIT_UNAVAILABLE __OSX_DEPRECATED(10.1, 10.5, "dlopen()");
#define NSADDIMAGE_OPTION_NONE 0x0
#define NSADDIMAGE_OPTION_RETURN_ON_ERROR 0x1
#define NSADDIMAGE_OPTION_WITH_SEARCHING 0x2
#define NSADDIMAGE_OPTION_RETURN_ONLY_IF_LOADED 0x4
#define NSADDIMAGE_OPTION_MATCH_FILENAME_BY_INSTALLNAME 0x8
extern bool _dyld_present(void) __API_UNAVAILABLE(ios, tvos, watchos) DYLD_DRIVERKIT_UNAVAILABLE __OSX_DEPRECATED(10.1, 10.5, "always true");
extern bool _dyld_launched_prebound(void) __API_UNAVAILABLE(ios, tvos, watchos) DYLD_DRIVERKIT_UNAVAILABLE __OSX_DEPRECATED(10.1, 10.5, "moot");
extern bool _dyld_all_twolevel_modules_prebound(void) __API_UNAVAILABLE(ios, tvos, watchos) DYLD_DRIVERKIT_UNAVAILABLE __OSX_DEPRECATED(10.3, 10.5, "moot");
extern bool _dyld_bind_fully_image_containing_address(const void* address) __API_UNAVAILABLE(ios, tvos, watchos) DYLD_DRIVERKIT_UNAVAILABLE __OSX_DEPRECATED(10.1, 10.5, "dlopen(RTLD_NOW)");
extern bool _dyld_image_containing_address(const void* address) __API_UNAVAILABLE(ios, tvos, watchos) DYLD_DRIVERKIT_UNAVAILABLE __OSX_DEPRECATED(10.3, 10.5, "dladdr()");
extern void _dyld_lookup_and_bind(const char* symbol_name, void **address, NSModule* module) __API_UNAVAILABLE(ios, tvos, watchos) DYLD_DRIVERKIT_UNAVAILABLE __OSX_DEPRECATED(10.1, 10.4, "dlsym()");
extern void _dyld_lookup_and_bind_with_hint(const char* symbol_name, const char* library_name_hint, void** address, NSModule* module) __API_UNAVAILABLE(ios, tvos, watchos) DYLD_DRIVERKIT_UNAVAILABLE __OSX_DEPRECATED(10.1, 10.4, "dlsym()");
extern void _dyld_lookup_and_bind_fully(const char* symbol_name, void** address, NSModule* module) __API_UNAVAILABLE(ios, tvos, watchos) DYLD_DRIVERKIT_UNAVAILABLE __OSX_DEPRECATED(10.1, 10.5, "dlsym()");
extern const struct mach_header* _dyld_get_image_header_containing_address(const void* address) __API_UNAVAILABLE(ios, tvos, watchos) DYLD_DRIVERKIT_UNAVAILABLE __OSX_DEPRECATED(10.3, 10.5, "dladdr()");
#if __cplusplus
}
#endif
#endif /* _MACH_O_DYLD_H_ */

View File

@ -0,0 +1,4 @@
module MachO.dyld [system] [extern_c] {
header "dyld.h"
export *
}

View File

@ -0,0 +1,206 @@
/*
* Copyright (c) 2006-2010 Apple Inc. All rights reserved.
*
* @APPLE_LICENSE_HEADER_START@
*
* This file contains Original Code and/or Modifications of Original Code
* as defined in and that are subject to the Apple Public Source License
* Version 2.0 (the 'License'). You may not use this file except in
* compliance with the License. Please obtain a copy of the License at
* http://www.opensource.apple.com/apsl/ and read it before using this
* file.
*
* The Original Code and all software distributed under the License are
* distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
* Please see the License for the specific language governing rights and
* limitations under the License.
*
* @APPLE_LICENSE_HEADER_END@
*/
#ifndef _DYLD_IMAGES_
#define _DYLD_IMAGES_
#include <stdbool.h>
#include <unistd.h>
#include <mach/mach.h>
#include <uuid/uuid.h>
#if defined(__cplusplus) && (BUILDING_LIBDYLD || BUILDING_DYLD)
#include <atomic>
#endif
#ifdef __cplusplus
extern "C" {
#endif
/*
* Beginning in Mac OS X 10.4, this is how gdb discovers which mach-o images are loaded in a process.
*
* gdb looks for the symbol "_dyld_all_image_infos" in dyld. It contains the fields below.
*
* For a snashot of what images are currently loaded, the infoArray fields contain a pointer
* to an array of all images. If infoArray is NULL, it means it is being modified, come back later.
*
* To be notified of changes, gdb sets a break point on the address pointed to by the notificationn
* field. The function it points to is called by dyld with an array of information about what images
* have been added (dyld_image_adding) or are about to be removed (dyld_image_removing).
*
* The notification is called after infoArray is updated. This means that if gdb attaches to a process
* and infoArray is NULL, gdb can set a break point on notification and let the proccess continue to
* run until the break point. Then gdb can inspect the full infoArray.
*
* The dyldVersion field always points to a C string that contains the dyld version. For instance,
* in dyld-127.3, dyldVersion would contain a pointer to "127.3".
*
* The errorMessage and terminationFlags fields are normally zero. If dyld terminates a process
* (for instance because a required dylib or symbol is missing), then the errorMessage field will
* be set to point to a C string message buffer containing the reason dyld terminate the process.
* The low bit of the terminationFlags will be set if dyld terminated the process before any user
* code ran, in which case there is no need for the crash log to contain the backtrace.
*
* When dyld terminates a process because some required dylib or symbol cannot be bound, in
* addition to the errorMessage field, it now sets the errorKind field and the corresponding
* fields: errorClientOfDylibPath, errorTargetDylibPath, errorSymbol.
*
*/
enum dyld_image_mode { dyld_image_adding=0, dyld_image_removing=1, dyld_image_info_change=2 };
struct dyld_image_info {
const struct mach_header* imageLoadAddress; /* base address image is mapped into */
const char* imageFilePath; /* path dyld used to load the image */
uintptr_t imageFileModDate; /* time_t of image file */
/* if stat().st_mtime of imageFilePath does not match imageFileModDate, */
/* then file has been modified since dyld loaded it */
};
struct dyld_uuid_info {
const struct mach_header* imageLoadAddress; /* base address image is mapped into */
uuid_t imageUUID; /* UUID of image */
};
#define DYLD_AOT_IMAGE_KEY_SIZE 32
struct dyld_aot_image_info {
const struct mach_header* x86LoadAddress;
const struct mach_header* aotLoadAddress;
const uint64_t aotImageSize;
const uint8_t aotImageKey[DYLD_AOT_IMAGE_KEY_SIZE]; // uniquely identifying SHA-256 key for this aot
};
struct dyld_aot_shared_cache_info {
const uintptr_t cacheBaseAddress;
uuid_t cacheUUID;
};
typedef void (*dyld_image_notifier)(enum dyld_image_mode mode, uint32_t infoCount, const struct dyld_image_info info[]);
/* for use in dyld_all_image_infos.errorKind field */
enum { dyld_error_kind_none=0,
dyld_error_kind_dylib_missing=1,
dyld_error_kind_dylib_wrong_arch=2,
dyld_error_kind_dylib_version=3,
dyld_error_kind_symbol_missing=4
};
/* internal limit */
#define DYLD_MAX_PROCESS_INFO_NOTIFY_COUNT 8
struct dyld_all_image_infos {
uint32_t version; /* 1 in Mac OS X 10.4 and 10.5 */
uint32_t infoArrayCount;
#if defined(__cplusplus) && (BUILDING_LIBDYLD || BUILDING_DYLD)
std::atomic<const struct dyld_image_info*> infoArray;
#else
const struct dyld_image_info* infoArray;
#endif
dyld_image_notifier notification;
bool processDetachedFromSharedRegion;
/* the following fields are only in version 2 (Mac OS X 10.6, iPhoneOS 2.0) and later */
bool libSystemInitialized;
const struct mach_header* dyldImageLoadAddress;
/* the following field is only in version 3 (Mac OS X 10.6, iPhoneOS 3.0) and later */
void* jitInfo;
/* the following fields are only in version 5 (Mac OS X 10.6, iPhoneOS 3.0) and later */
const char* dyldVersion;
const char* errorMessage;
uintptr_t terminationFlags;
/* the following field is only in version 6 (Mac OS X 10.6, iPhoneOS 3.1) and later */
void* coreSymbolicationShmPage;
/* the following field is only in version 7 (Mac OS X 10.6, iPhoneOS 3.1) and later */
uintptr_t systemOrderFlag;
/* the following field is only in version 8 (Mac OS X 10.7, iPhoneOS 3.1) and later */
uintptr_t uuidArrayCount;
const struct dyld_uuid_info* uuidArray; /* only images not in dyld shared cache */
/* the following field is only in version 9 (Mac OS X 10.7, iOS 4.0) and later */
struct dyld_all_image_infos* dyldAllImageInfosAddress;
/* the following field is only in version 10 (Mac OS X 10.7, iOS 4.2) and later */
uintptr_t initialImageCount;
/* the following field is only in version 11 (Mac OS X 10.7, iOS 4.2) and later */
uintptr_t errorKind;
const char* errorClientOfDylibPath;
const char* errorTargetDylibPath;
const char* errorSymbol;
/* the following field is only in version 12 (Mac OS X 10.7, iOS 4.3) and later */
uintptr_t sharedCacheSlide;
/* the following field is only in version 13 (Mac OS X 10.9, iOS 7.0) and later */
uint8_t sharedCacheUUID[16];
/* the following field is only in version 15 (macOS 10.12, iOS 10.0) and later */
uintptr_t sharedCacheBaseAddress;
#if defined(__cplusplus) && (BUILDING_LIBDYLD || BUILDING_DYLD)
// We want this to be atomic in libdyld so that we can see updates when we map it shared
std::atomic<uint64_t> infoArrayChangeTimestamp;
#else
uint64_t infoArrayChangeTimestamp;
#endif
const char* dyldPath;
mach_port_t notifyPorts[DYLD_MAX_PROCESS_INFO_NOTIFY_COUNT];
#if __LP64__
uintptr_t reserved[13-(DYLD_MAX_PROCESS_INFO_NOTIFY_COUNT/2)];
#else
uintptr_t reserved[13-DYLD_MAX_PROCESS_INFO_NOTIFY_COUNT];
#endif
/* the following field is only in version 16 (macOS 10.13, iOS 11.0) and later */
uintptr_t compact_dyld_image_info_addr;
size_t compact_dyld_image_info_size;
uint32_t platform; // FIXME: really a dyld_platform_t, but those aren't exposed here.
/* the following field is only in version 17 (macOS 10.16) and later */
uint32_t aotInfoCount;
const struct dyld_aot_image_info* aotInfoArray;
uint64_t aotInfoArrayChangeTimestamp;
uintptr_t aotSharedCacheBaseAddress;
uint8_t aotSharedCacheUUID[16];
};
/*
* Beginning in Mac OS X 10.5, this is how gdb discovers where the shared cache is in a process.
* Images that are in the shared cache have their segments rearranged, so when using imageFilePath
* to load the file from disk, you have to know to adjust addresses based on how their segment
* was rearranged.
*
* gdb looks for the symbol "_dyld_shared_region_ranges" in dyld.
*
* It contains information the count of shared regions used by the process. The count is
* the number of start/length pairs.
*/
struct dyld_shared_cache_ranges {
uintptr_t sharedRegionsCount; /* how many ranges follow */
struct {
uintptr_t start;
uintptr_t length;
} ranges[4]; /* max regions */
};
extern struct dyld_shared_cache_ranges dyld_shared_cache_ranges __attribute__((visibility("hidden")));
#ifdef __cplusplus
}
#endif
#endif /* _DYLD_IMAGES_ */

View File

@ -0,0 +1,83 @@
/*
* Copyright (c) 2016 Apple, Inc. All rights reserved.
*
* @APPLE_LICENSE_HEADER_START@
*
* This file contains Original Code and/or Modifications of Original Code
* as defined in and that are subject to the Apple Public Source License
* Version 2.0 (the 'License'). You may not use this file except in
* compliance with the License. Please obtain a copy of the License at
* http://www.opensource.apple.com/apsl/ and read it before using this
* file.
*
* The Original Code and all software distributed under the License are
* distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
* Please see the License for the specific language governing rights and
* limitations under the License.
*
* @APPLE_LICENSE_HEADER_END@
*/
#ifndef _MACH_O_FAT_H_
#define _MACH_O_FAT_H_
/*
* This header file describes the structures of the file format for "fat"
* architecture specific file (wrapper design). At the begining of the file
* there is one fat_header structure followed by a number of fat_arch
* structures. For each architecture in the file, specified by a pair of
* cputype and cpusubtype, the fat_header describes the file offset, file
* size and alignment in the file of the architecture specific member.
* The padded bytes in the file to place each member on it's specific alignment
* are defined to be read as zeros and can be left as "holes" if the file system
* can support them as long as they read as zeros.
*
* All structures defined here are always written and read to/from disk
* in big-endian order.
*/
/*
* <mach/machine.h> is needed here for the cpu_type_t and cpu_subtype_t types
* and contains the constants for the possible values of these types.
*/
#include <stdint.h>
#include <mach/machine.h>
#include <architecture/byte_order.h>
#define FAT_MAGIC 0xcafebabe
#define FAT_CIGAM 0xbebafeca /* NXSwapLong(FAT_MAGIC) */
struct fat_header {
uint32_t magic; /* FAT_MAGIC or FAT_MAGIC_64 */
uint32_t nfat_arch; /* number of structs that follow */
};
struct fat_arch {
cpu_type_t cputype; /* cpu specifier (int) */
cpu_subtype_t cpusubtype; /* machine specifier (int) */
uint32_t offset; /* file offset to this object file */
uint32_t size; /* size of this object file */
uint32_t align; /* alignment as a power of 2 */
};
/*
* The support for the 64-bit fat file format described here is a work in
* progress and not yet fully supported in all the Apple Developer Tools.
*
* When a slice is greater than 4mb or an offset to a slice is greater than 4mb
* then the 64-bit fat file format is used.
*/
#define FAT_MAGIC_64 0xcafebabf
#define FAT_CIGAM_64 0xbfbafeca /* NXSwapLong(FAT_MAGIC_64) */
struct fat_arch_64 {
cpu_type_t cputype; /* cpu specifier (int) */
cpu_subtype_t cpusubtype; /* machine specifier (int) */
uint64_t offset; /* file offset to this object file */
uint64_t size; /* size of this object file */
uint32_t align; /* alignment as a power of 2 */
uint32_t reserved; /* reserved */
};
#endif /* _MACH_O_FAT_H_ */

View File

@ -0,0 +1,284 @@
/* -*- mode: C++; c-basic-offset: 4; tab-width: 4 -*-
*
* Copyright (c) 2018 Apple Inc. All rights reserved.
*
* @APPLE_LICENSE_HEADER_START@
*
* This file contains Original Code and/or Modifications of Original Code
* as defined in and that are subject to the Apple Public Source License
* Version 2.0 (the 'License'). You may not use this file except in
* compliance with the License. Please obtain a copy of the License at
* http://www.opensource.apple.com/apsl/ and read it before using this
* file.
*
* The Original Code and all software distributed under the License are
* distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
* Please see the License for the specific language governing rights and
* limitations under the License.
*
* @APPLE_LICENSE_HEADER_END@
*/
#ifndef __MACH_O_FIXUP_CHAINS__
#define __MACH_O_FIXUP_CHAINS__ 6
#include <stdint.h>
//#define LC_DYLD_EXPORTS_TRIE 0x80000033 // used with linkedit_data_command
//#define LC_DYLD_CHAINED_FIXUPS 0x80000034 // used with linkedit_data_command, payload is dyld_chained_fixups_header
// header of the LC_DYLD_CHAINED_FIXUPS payload
struct dyld_chained_fixups_header
{
uint32_t fixups_version; // 0
uint32_t starts_offset; // offset of dyld_chained_starts_in_image in chain_data
uint32_t imports_offset; // offset of imports table in chain_data
uint32_t symbols_offset; // offset of symbol strings in chain_data
uint32_t imports_count; // number of imported symbol names
uint32_t imports_format; // DYLD_CHAINED_IMPORT*
uint32_t symbols_format; // 0 => uncompressed, 1 => zlib compressed
};
// This struct is embedded in LC_DYLD_CHAINED_FIXUPS payload
struct dyld_chained_starts_in_image
{
uint32_t seg_count;
uint32_t seg_info_offset[1]; // each entry is offset into this struct for that segment
// followed by pool of dyld_chain_starts_in_segment data
};
// This struct is embedded in dyld_chain_starts_in_image
// and passed down to the kernel for page-in linking
struct dyld_chained_starts_in_segment
{
uint32_t size; // size of this (amount kernel needs to copy)
uint16_t page_size; // 0x1000 or 0x4000
uint16_t pointer_format; // DYLD_CHAINED_PTR_*
uint64_t segment_offset; // offset in memory to start of segment
uint32_t max_valid_pointer; // for 32-bit OS, any value beyond this is not a pointer
uint16_t page_count; // how many pages are in array
uint16_t page_start[1]; // each entry is offset in each page of first element in chain
// or DYLD_CHAINED_PTR_START_NONE if no fixups on page
// uint16_t chain_starts[1]; // some 32-bit formats may require multiple starts per page.
// for those, if high bit is set in page_starts[], then it
// is index into chain_starts[] which is a list of starts
// the last of which has the high bit set
};
enum {
DYLD_CHAINED_PTR_START_NONE = 0xFFFF, // used in page_start[] to denote a page with no fixups
DYLD_CHAINED_PTR_START_MULTI = 0x8000, // used in page_start[] to denote a page which has multiple starts
DYLD_CHAINED_PTR_START_LAST = 0x8000, // used in chain_starts[] to denote last start in list for page
};
// This struct is embedded in __TEXT,__chain_starts section in firmware
struct dyld_chained_starts_offsets
{
uint32_t pointer_format; // DYLD_CHAINED_PTR_32_FIRMWARE
uint32_t starts_count; // number of starts in array
uint32_t chain_starts[1]; // array chain start offsets
};
// values for dyld_chained_starts_in_segment.pointer_format
enum {
DYLD_CHAINED_PTR_ARM64E = 1, // stride 8, unauth target is vmaddr
DYLD_CHAINED_PTR_64 = 2, // target is vmaddr
DYLD_CHAINED_PTR_32 = 3,
DYLD_CHAINED_PTR_32_CACHE = 4,
DYLD_CHAINED_PTR_32_FIRMWARE = 5,
DYLD_CHAINED_PTR_64_OFFSET = 6, // target is vm offset
DYLD_CHAINED_PTR_ARM64E_OFFSET = 7, // old name
DYLD_CHAINED_PTR_ARM64E_KERNEL = 7, // stride 4, unauth target is vm offset
DYLD_CHAINED_PTR_64_KERNEL_CACHE = 8,
DYLD_CHAINED_PTR_ARM64E_USERLAND = 9, // stride 8, unauth target is vm offset
DYLD_CHAINED_PTR_ARM64E_FIRMWARE = 10, // stride 4, unauth target is vmaddr
DYLD_CHAINED_PTR_X86_64_KERNEL_CACHE = 11, // stride 1, x86_64 kernel caches
DYLD_CHAINED_PTR_ARM64E_USERLAND24 = 12, // stride 8, unauth target is vm offset, 24-bit bind
};
// DYLD_CHAINED_PTR_ARM64E
struct dyld_chained_ptr_arm64e_rebase
{
uint64_t target : 43,
high8 : 8,
next : 11, // 4 or 8-byte stide
bind : 1, // == 0
auth : 1; // == 0
};
// DYLD_CHAINED_PTR_ARM64E
struct dyld_chained_ptr_arm64e_bind
{
uint64_t ordinal : 16,
zero : 16,
addend : 19, // +/-256K
next : 11, // 4 or 8-byte stide
bind : 1, // == 1
auth : 1; // == 0
};
// DYLD_CHAINED_PTR_ARM64E
struct dyld_chained_ptr_arm64e_auth_rebase
{
uint64_t target : 32, // runtimeOffset
diversity : 16,
addrDiv : 1,
key : 2,
next : 11, // 4 or 8-byte stide
bind : 1, // == 0
auth : 1; // == 1
};
// DYLD_CHAINED_PTR_ARM64E
struct dyld_chained_ptr_arm64e_auth_bind
{
uint64_t ordinal : 16,
zero : 16,
diversity : 16,
addrDiv : 1,
key : 2,
next : 11, // 4 or 8-byte stide
bind : 1, // == 1
auth : 1; // == 1
};
// DYLD_CHAINED_PTR_64/DYLD_CHAINED_PTR_64_OFFSET
struct dyld_chained_ptr_64_rebase
{
uint64_t target : 36, // 64GB max image size (DYLD_CHAINED_PTR_64 => vmAddr, DYLD_CHAINED_PTR_64_OFFSET => runtimeOffset)
high8 : 8, // top 8 bits set to this (DYLD_CHAINED_PTR_64 => after slide added, DYLD_CHAINED_PTR_64_OFFSET => before slide added)
reserved : 7, // all zeros
next : 12, // 4-byte stride
bind : 1; // == 0
};
// DYLD_CHAINED_PTR_ARM64E_USERLAND24
struct dyld_chained_ptr_arm64e_bind24
{
uint64_t ordinal : 24,
zero : 8,
addend : 19, // +/-256K
next : 11, // 8-byte stide
bind : 1, // == 1
auth : 1; // == 0
};
// DYLD_CHAINED_PTR_ARM64E_USERLAND24
struct dyld_chained_ptr_arm64e_auth_bind24
{
uint64_t ordinal : 24,
zero : 8,
diversity : 16,
addrDiv : 1,
key : 2,
next : 11, // 8-byte stide
bind : 1, // == 1
auth : 1; // == 1
};
// DYLD_CHAINED_PTR_64
struct dyld_chained_ptr_64_bind
{
uint64_t ordinal : 24,
addend : 8, // 0 thru 255
reserved : 19, // all zeros
next : 12, // 4-byte stride
bind : 1; // == 1
};
// DYLD_CHAINED_PTR_64_KERNEL_CACHE, DYLD_CHAINED_PTR_X86_64_KERNEL_CACHE
struct dyld_chained_ptr_64_kernel_cache_rebase
{
uint64_t target : 30, // basePointers[cacheLevel] + target
cacheLevel : 2, // what level of cache to bind to (indexes a mach_header array)
diversity : 16,
addrDiv : 1,
key : 2,
next : 12, // 1 or 4-byte stide
isAuth : 1; // 0 -> not authenticated. 1 -> authenticated
};
// DYLD_CHAINED_PTR_32
// Note: for DYLD_CHAINED_PTR_32 some non-pointer values are co-opted into the chain
// as out of range rebases. If an entry in the chain is > max_valid_pointer, then it
// is not a pointer. To restore the value, subtract off the bias, which is
// (64MB+max_valid_pointer)/2.
struct dyld_chained_ptr_32_rebase
{
uint32_t target : 26, // vmaddr, 64MB max image size
next : 5, // 4-byte stride
bind : 1; // == 0
};
// DYLD_CHAINED_PTR_32
struct dyld_chained_ptr_32_bind
{
uint32_t ordinal : 20,
addend : 6, // 0 thru 63
next : 5, // 4-byte stride
bind : 1; // == 1
};
// DYLD_CHAINED_PTR_32_CACHE
struct dyld_chained_ptr_32_cache_rebase
{
uint32_t target : 30, // 1GB max dyld cache TEXT and DATA
next : 2; // 4-byte stride
};
// DYLD_CHAINED_PTR_32_FIRMWARE
struct dyld_chained_ptr_32_firmware_rebase
{
uint32_t target : 26, // 64MB max firmware TEXT and DATA
next : 6; // 4-byte stride
};
// values for dyld_chained_fixups_header.imports_format
enum {
DYLD_CHAINED_IMPORT = 1,
DYLD_CHAINED_IMPORT_ADDEND = 2,
DYLD_CHAINED_IMPORT_ADDEND64 = 3,
};
// DYLD_CHAINED_IMPORT
struct dyld_chained_import
{
uint32_t lib_ordinal : 8,
weak_import : 1,
name_offset : 23;
};
// DYLD_CHAINED_IMPORT_ADDEND
struct dyld_chained_import_addend
{
uint32_t lib_ordinal : 8,
weak_import : 1,
name_offset : 23;
int32_t addend;
};
// DYLD_CHAINED_IMPORT_ADDEND64
struct dyld_chained_import_addend64
{
uint64_t lib_ordinal : 16,
weak_import : 1,
reserved : 15,
name_offset : 32;
uint64_t addend;
};
#endif // __MACH_O_FIXUP_CHAINS__

View File

@ -0,0 +1,143 @@
/*
* Copyright (c) 2004 Apple Computer, Inc. All rights reserved.
*
* @APPLE_LICENSE_HEADER_START@
*
* This file contains Original Code and/or Modifications of Original Code
* as defined in and that are subject to the Apple Public Source License
* Version 2.0 (the 'License'). You may not use this file except in
* compliance with the License. Please obtain a copy of the License at
* http://www.opensource.apple.com/apsl/ and read it before using this
* file.
*
* The Original Code and all software distributed under the License are
* distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
* Please see the License for the specific language governing rights and
* limitations under the License.
*
* @APPLE_LICENSE_HEADER_END@
*/
#ifndef _MACH_O_GETSECT_H_
#define _MACH_O_GETSECT_H_
#include <stdint.h>
#include <mach-o/loader.h>
#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */
/*
* Runtime interfaces for Mach-O programs. For both 32-bit and 64-bit programs,
* where the sizes returned will be 32-bit or 64-bit based on the size of
* 'unsigned long'.
*/
extern char *getsectdata(
const char *segname,
const char *sectname,
unsigned long *size);
extern char *getsectdatafromFramework(
const char *FrameworkName,
const char *segname,
const char *sectname,
unsigned long *size);
extern unsigned long get_end(void);
extern unsigned long get_etext(void);
extern unsigned long get_edata(void);
#ifndef __LP64__
/*
* Runtime interfaces for 32-bit Mach-O programs.
*/
extern const struct section *getsectbyname(
const char *segname,
const char *sectname);
extern uint8_t *getsectiondata(
const struct mach_header *mhp,
const char *segname,
const char *sectname,
unsigned long *size);
extern const struct segment_command *getsegbyname(
const char *segname);
extern uint8_t *getsegmentdata(
const struct mach_header *mhp,
const char *segname,
unsigned long *size);
#else /* defined(__LP64__) */
/*
* Runtime interfaces for 64-bit Mach-O programs.
*/
extern const struct section_64 *getsectbyname(
const char *segname,
const char *sectname);
extern uint8_t *getsectiondata(
const struct mach_header_64 *mhp,
const char *segname,
const char *sectname,
unsigned long *size);
extern const struct segment_command_64 *getsegbyname(
const char *segname);
extern uint8_t *getsegmentdata(
const struct mach_header_64 *mhp,
const char *segname,
unsigned long *size);
#endif /* defined(__LP64__) */
/*
* Interfaces for tools working with 32-bit Mach-O files.
*/
extern char *getsectdatafromheader(
const struct mach_header *mhp,
const char *segname,
const char *sectname,
uint32_t *size);
extern const struct section *getsectbynamefromheader(
const struct mach_header *mhp,
const char *segname,
const char *sectname);
extern const struct section *getsectbynamefromheaderwithswap(
struct mach_header *mhp,
const char *segname,
const char *sectname,
int fSwap);
/*
* Interfaces for tools working with 64-bit Mach-O files.
*/
extern char *getsectdatafromheader_64(
const struct mach_header_64 *mhp,
const char *segname,
const char *sectname,
uint64_t *size);
extern const struct section_64 *getsectbynamefromheader_64(
const struct mach_header_64 *mhp,
const char *segname,
const char *sectname);
extern const struct section *getsectbynamefromheaderwithswap_64(
struct mach_header_64 *mhp,
const char *segname,
const char *sectname,
int fSwap);
#ifdef __cplusplus
}
#endif /* __cplusplus */
#endif /* _MACH_O_GETSECT_H_ */

View File

@ -0,0 +1,98 @@
/*
* Copyright (c) 1999 Apple Computer, Inc. All rights reserved.
*
* @APPLE_LICENSE_HEADER_START@
*
* This file contains Original Code and/or Modifications of Original Code
* as defined in and that are subject to the Apple Public Source License
* Version 2.0 (the 'License'). You may not use this file except in
* compliance with the License. Please obtain a copy of the License at
* http://www.opensource.apple.com/apsl/ and read it before using this
* file.
*
* The Original Code and all software distributed under the License are
* distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
* Please see the License for the specific language governing rights and
* limitations under the License.
*
* @APPLE_LICENSE_HEADER_END@
*/
#include <architecture/byte_order.h>
#include <mach/i386/thread_status.h>
struct i386_float_state;
extern void swap_i386_thread_state(
i386_thread_state_t *cpu,
enum NXByteOrder target_byte_order);
/* current i386 thread states */
#if i386_THREAD_STATE == 1
extern void swap_i386_float_state(
struct i386_float_state *fpu,
enum NXByteOrder target_byte_order);
extern void swap_i386_exception_state(
i386_exception_state_t *exc,
enum NXByteOrder target_byte_order);
#endif /* i386_THREAD_STATE == 1 */
/* i386 thread states on older releases */
#if i386_THREAD_STATE == -1
extern void swap_i386_thread_fpstate(
i386_thread_fpstate_t *fpu,
enum NXByteOrder target_byte_order);
extern void swap_i386_thread_exceptstate(
i386_thread_exceptstate_t *exc,
enum NXByteOrder target_byte_order);
extern void swap_i386_thread_cthreadstate(
i386_thread_cthreadstate_t *user,
enum NXByteOrder target_byte_order);
#endif /* i386_THREAD_STATE == -1 */
#ifdef x86_THREAD_STATE64
extern void swap_x86_thread_state64(
x86_thread_state64_t *cpu,
enum NXByteOrder target_byte_order);
extern void swap_x86_state_hdr(
x86_state_hdr_t *hdr,
enum NXByteOrder target_byte_order);
extern void swap_x86_float_state64(
x86_float_state64_t *fpu,
enum NXByteOrder target_byte_order);
extern void swap_x86_exception_state64(
x86_exception_state64_t *exc,
enum NXByteOrder target_byte_order);
extern void swap_x86_thread_state(
x86_thread_state_t *cpu,
enum NXByteOrder target_byte_order);
extern void swap_x86_float_state(
x86_float_state_t *fpu,
enum NXByteOrder target_byte_order);
extern void swap_x86_exception_state(
x86_exception_state_t *exc,
enum NXByteOrder target_byte_order);
extern void swap_x86_debug_state32(
x86_debug_state32_t *debug,
enum NXByteOrder target_byte_order);
extern void swap_x86_debug_state64(
x86_debug_state64_t *debug,
enum NXByteOrder target_byte_order);
extern void swap_x86_debug_state(
x86_debug_state_t *debug,
enum NXByteOrder target_byte_order);
#endif /* x86_THREAD_STATE64 */

View File

@ -0,0 +1,133 @@
/*
* Copyright (c) 1999 Apple Computer, Inc. All rights reserved.
*
* @APPLE_LICENSE_HEADER_START@
*
* This file contains Original Code and/or Modifications of Original Code
* as defined in and that are subject to the Apple Public Source License
* Version 2.0 (the 'License'). You may not use this file except in
* compliance with the License. Please obtain a copy of the License at
* http://www.opensource.apple.com/apsl/ and read it before using this
* file.
*
* The Original Code and all software distributed under the License are
* distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
* Please see the License for the specific language governing rights and
* limitations under the License.
*
* @APPLE_LICENSE_HEADER_END@
*/
#ifndef _MACHO_LDSYMS_H_
#define _MACHO_LDSYMS_H_
#include <mach-o/loader.h>
/*
* This file describes the link editor defined symbols. The semantics of a
* link editor symbol is that it is defined by the link editor only if it is
* referenced and it is an error for the user to define them (see the man page
* ld(1)). The standard UNIX link editor symbols: __end, __etext and __edata
* are not not supported by the Apple Mach-O link editor. These symbols are
* really not meaningful in a Mach-O object file and the link editor symbols
* that are supported (described here) replace them. In the case of the
* standard UNIX link editor symbols the program can use the symbol
* __mh_execute_header and walk the load commands of it's program to determine
* the ending (or beginning) of any section or segment in the program. Note
* that the compiler prepends an underbar to all external symbol names coded
* in a high level language. Thus in 'C' names are coded without an underbar
* and symbol names in the symbol table have an underbar. There are two cpp
* macros for each link editor defined name in this file. The macro with a
* leading underbar is the symbol name and the one without is the name as
* coded in 'C'.
*/
/*
* The value of the link editor defined symbol _MH_EXECUTE_SYM is the address
* of the mach header in a Mach-O executable file type. It does not appear in
* any file type other than a MH_EXECUTE file type. The type of the symbol is
* absolute as the header is not part of any section.
*/
#define _MH_EXECUTE_SYM "__mh_execute_header"
#define MH_EXECUTE_SYM "_mh_execute_header"
extern const struct
#ifdef __LP64__
mach_header_64
#else
mach_header
#endif
_mh_execute_header;
/*
* The value of the link editor defined symbol _MH_BUNDLE_SYM is the address
* of the mach header in a Mach-O bundle file type. It does not appear in
* any file type other than a MH_BUNDLE file type. The type of the symbol is
* an N_SECT symbol even thought the header is not part of any section. This
* symbol is private to the code in the bundle it is a part of.
*/
#define _MH_BUNDLE_SYM "__mh_bundle_header"
#define MH_BUNDLE_SYM "_mh_bundle_header"
extern const struct
#ifdef __LP64__
mach_header_64
#else
mach_header
#endif
_mh_bundle_header;
/*
* The value of the link editor defined symbol _MH_DYLIB_SYM is the address
* of the mach header in a Mach-O dylib file type. It does not appear in
* any file type other than a MH_DYLIB file type. The type of the symbol is
* an N_SECT symbol even thought the header is not part of any section. This
* symbol is private to the code in the library it is a part of.
*/
#define _MH_DYLIB_SYM "__mh_dylib_header"
#define MH_DYLIB_SYM "_mh_dylib_header"
extern const struct
#ifdef __LP64__
mach_header_64
#else
mach_header
#endif
_mh_dylib_header;
/*
* The value of the link editor defined symbol _MH_DYLINKER_SYM is the address
* of the mach header in a Mach-O dylinker file type. It does not appear in
* any file type other than a MH_DYLINKER file type. The type of the symbol is
* an N_SECT symbol even thought the header is not part of any section. This
* symbol is private to the code in the dynamic linker it is a part of.
*/
#define _MH_DYLINKER_SYM "__mh_dylinker_header"
#define MH_DYLINKER_SYM "_mh_dylinker_header"
extern const struct
#ifdef __LP64__
mach_header_64
#else
mach_header
#endif
_mh_dylinker_header;
/*
* For the MH_PRELOAD file type the headers are not loaded as part of any
* segment so the link editor defines symbols defined for the beginning
* and ending of each segment and each section in each segment. The names for
* the symbols for a segment's beginning and end will have the form:
* __SEGNAME__begin and __SEGNAME__end where __SEGNAME is the name of the
* segment. The names for the symbols for a section's beginning and end will
* have the form: __SEGNAME__sectname__begin and __SEGNAME__sectname__end
* where __sectname is the name of the section and __SEGNAME is the segment it
* is in.
*
* The above symbols' types are those of the section they are referring to.
* This is true even for symbols who's values are end's of a section and
* that value is next address after that section and not really in that
* section. This results in these symbols having types referring to sections
* who's values are not in that section.
*/
#endif /* _MACHO_LDSYMS_H_ */

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,58 @@
module MachO [system] [extern_c] {
extern module dyld "dyld.modulemap"
extern module compact_unwind_encoding "compact_unwind_encoding.modulemap"
export *
module arch {
header "arch.h"
export *
}
module fat {
header "fat.h"
export *
}
module getsect {
header "getsect.h"
export *
}
module ldsyms {
header "ldsyms.h"
export *
}
module loader {
header "loader.h"
export *
}
module nlist {
header "nlist.h"
export *
}
module ranlib {
header "ranlib.h"
export *
}
module reloc {
header "reloc.h"
export *
}
module stab {
header "stab.h"
export *
}
module swap {
header "swap.h"
export *
}
}

View File

@ -0,0 +1,324 @@
/*
* Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved.
*
* @APPLE_LICENSE_HEADER_START@
*
* This file contains Original Code and/or Modifications of Original Code
* as defined in and that are subject to the Apple Public Source License
* Version 2.0 (the 'License'). You may not use this file except in
* compliance with the License. Please obtain a copy of the License at
* http://www.opensource.apple.com/apsl/ and read it before using this
* file.
*
* The Original Code and all software distributed under the License are
* distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
* Please see the License for the specific language governing rights and
* limitations under the License.
*
* @APPLE_LICENSE_HEADER_END@
*/
#ifndef _MACHO_NLIST_H_
#define _MACHO_NLIST_H_
/* $NetBSD: nlist.h,v 1.5 1994/10/26 00:56:11 cgd Exp $ */
/*-
* Copyright (c) 1991, 1993
* The Regents of the University of California. All rights reserved.
* (c) UNIX System Laboratories, Inc.
* All or some portions of this file are derived from material licensed
* to the University of California by American Telephone and Telegraph
* Co. or Unix System Laboratories, Inc. and are reproduced herein with
* the permission of UNIX System Laboratories, Inc.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed by the University of
* California, Berkeley and its contributors.
* 4. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* @(#)nlist.h 8.2 (Berkeley) 1/21/94
*/
#include <stdint.h>
/*
* Format of a symbol table entry of a Mach-O file for 32-bit architectures.
* Modified from the BSD format. The modifications from the original format
* were changing n_other (an unused field) to n_sect and the addition of the
* N_SECT type. These modifications are required to support symbols in a larger
* number of sections not just the three sections (text, data and bss) in a BSD
* file.
*/
struct nlist {
union {
#ifndef __LP64__
char *n_name; /* for use when in-core */
#endif
uint32_t n_strx; /* index into the string table */
} n_un;
uint8_t n_type; /* type flag, see below */
uint8_t n_sect; /* section number or NO_SECT */
int16_t n_desc; /* see <mach-o/stab.h> */
uint32_t n_value; /* value of this symbol (or stab offset) */
};
/*
* This is the symbol table entry structure for 64-bit architectures.
*/
struct nlist_64 {
union {
uint32_t n_strx; /* index into the string table */
} n_un;
uint8_t n_type; /* type flag, see below */
uint8_t n_sect; /* section number or NO_SECT */
uint16_t n_desc; /* see <mach-o/stab.h> */
uint64_t n_value; /* value of this symbol (or stab offset) */
};
/*
* Symbols with a index into the string table of zero (n_un.n_strx == 0) are
* defined to have a null, "", name. Therefore all string indexes to non null
* names must not have a zero string index. This is bit historical information
* that has never been well documented.
*/
/*
* The n_type field really contains four fields:
* unsigned char N_STAB:3,
* N_PEXT:1,
* N_TYPE:3,
* N_EXT:1;
* which are used via the following masks.
*/
#define N_STAB 0xe0 /* if any of these bits set, a symbolic debugging entry */
#define N_PEXT 0x10 /* private external symbol bit */
#define N_TYPE 0x0e /* mask for the type bits */
#define N_EXT 0x01 /* external symbol bit, set for external symbols */
/*
* Only symbolic debugging entries have some of the N_STAB bits set and if any
* of these bits are set then it is a symbolic debugging entry (a stab). In
* which case then the values of the n_type field (the entire field) are given
* in <mach-o/stab.h>
*/
/*
* Values for N_TYPE bits of the n_type field.
*/
#define N_UNDF 0x0 /* undefined, n_sect == NO_SECT */
#define N_ABS 0x2 /* absolute, n_sect == NO_SECT */
#define N_SECT 0xe /* defined in section number n_sect */
#define N_PBUD 0xc /* prebound undefined (defined in a dylib) */
#define N_INDR 0xa /* indirect */
/*
* If the type is N_INDR then the symbol is defined to be the same as another
* symbol. In this case the n_value field is an index into the string table
* of the other symbol's name. When the other symbol is defined then they both
* take on the defined type and value.
*/
/*
* If the type is N_SECT then the n_sect field contains an ordinal of the
* section the symbol is defined in. The sections are numbered from 1 and
* refer to sections in order they appear in the load commands for the file
* they are in. This means the same ordinal may very well refer to different
* sections in different files.
*
* The n_value field for all symbol table entries (including N_STAB's) gets
* updated by the link editor based on the value of it's n_sect field and where
* the section n_sect references gets relocated. If the value of the n_sect
* field is NO_SECT then it's n_value field is not changed by the link editor.
*/
#define NO_SECT 0 /* symbol is not in any section */
#define MAX_SECT 255 /* 1 thru 255 inclusive */
/*
* Common symbols are represented by undefined (N_UNDF) external (N_EXT) types
* who's values (n_value) are non-zero. In which case the value of the n_value
* field is the size (in bytes) of the common symbol. The n_sect field is set
* to NO_SECT. The alignment of a common symbol may be set as a power of 2
* between 2^1 and 2^15 as part of the n_desc field using the macros below. If
* the alignment is not set (a value of zero) then natural alignment based on
* the size is used.
*/
#define GET_COMM_ALIGN(n_desc) (((n_desc) >> 8) & 0x0f)
#define SET_COMM_ALIGN(n_desc,align) \
(n_desc) = (((n_desc) & 0xf0ff) | (((align) & 0x0f) << 8))
/*
* To support the lazy binding of undefined symbols in the dynamic link-editor,
* the undefined symbols in the symbol table (the nlist structures) are marked
* with the indication if the undefined reference is a lazy reference or
* non-lazy reference. If both a non-lazy reference and a lazy reference is
* made to the same symbol the non-lazy reference takes precedence. A reference
* is lazy only when all references to that symbol are made through a symbol
* pointer in a lazy symbol pointer section.
*
* The implementation of marking nlist structures in the symbol table for
* undefined symbols will be to use some of the bits of the n_desc field as a
* reference type. The mask REFERENCE_TYPE will be applied to the n_desc field
* of an nlist structure for an undefined symbol to determine the type of
* undefined reference (lazy or non-lazy).
*
* The constants for the REFERENCE FLAGS are propagated to the reference table
* in a shared library file. In that case the constant for a defined symbol,
* REFERENCE_FLAG_DEFINED, is also used.
*/
/* Reference type bits of the n_desc field of undefined symbols */
#define REFERENCE_TYPE 0x7
/* types of references */
#define REFERENCE_FLAG_UNDEFINED_NON_LAZY 0
#define REFERENCE_FLAG_UNDEFINED_LAZY 1
#define REFERENCE_FLAG_DEFINED 2
#define REFERENCE_FLAG_PRIVATE_DEFINED 3
#define REFERENCE_FLAG_PRIVATE_UNDEFINED_NON_LAZY 4
#define REFERENCE_FLAG_PRIVATE_UNDEFINED_LAZY 5
/*
* To simplify stripping of objects that use are used with the dynamic link
* editor, the static link editor marks the symbols defined an object that are
* referenced by a dynamicly bound object (dynamic shared libraries, bundles).
* With this marking strip knows not to strip these symbols.
*/
#define REFERENCED_DYNAMICALLY 0x0010
/*
* For images created by the static link editor with the -twolevel_namespace
* option in effect the flags field of the mach header is marked with
* MH_TWOLEVEL. And the binding of the undefined references of the image are
* determined by the static link editor. Which library an undefined symbol is
* bound to is recorded by the static linker in the high 8 bits of the n_desc
* field using the SET_LIBRARY_ORDINAL macro below. The ordinal recorded
* references the libraries listed in the Mach-O's LC_LOAD_DYLIB,
* LC_LOAD_WEAK_DYLIB, LC_REEXPORT_DYLIB, LC_LOAD_UPWARD_DYLIB, and
* LC_LAZY_LOAD_DYLIB, etc. load commands in the order they appear in the
* headers. The library ordinals start from 1.
* For a dynamic library that is built as a two-level namespace image the
* undefined references from module defined in another use the same nlist struct
* an in that case SELF_LIBRARY_ORDINAL is used as the library ordinal. For
* defined symbols in all images they also must have the library ordinal set to
* SELF_LIBRARY_ORDINAL. The EXECUTABLE_ORDINAL refers to the executable
* image for references from plugins that refer to the executable that loads
* them.
*
* The DYNAMIC_LOOKUP_ORDINAL is for undefined symbols in a two-level namespace
* image that are looked up by the dynamic linker with flat namespace semantics.
* This ordinal was added as a feature in Mac OS X 10.3 by reducing the
* value of MAX_LIBRARY_ORDINAL by one. So it is legal for existing binaries
* or binaries built with older tools to have 0xfe (254) dynamic libraries. In
* this case the ordinal value 0xfe (254) must be treated as a library ordinal
* for compatibility.
*/
#define GET_LIBRARY_ORDINAL(n_desc) (((n_desc) >> 8) & 0xff)
#define SET_LIBRARY_ORDINAL(n_desc,ordinal) \
(n_desc) = (((n_desc) & 0x00ff) | (((ordinal) & 0xff) << 8))
#define SELF_LIBRARY_ORDINAL 0x0
#define MAX_LIBRARY_ORDINAL 0xfd
#define DYNAMIC_LOOKUP_ORDINAL 0xfe
#define EXECUTABLE_ORDINAL 0xff
/*
* The bit 0x0020 of the n_desc field is used for two non-overlapping purposes
* and has two different symbolic names, N_NO_DEAD_STRIP and N_DESC_DISCARDED.
*/
/*
* The N_NO_DEAD_STRIP bit of the n_desc field only ever appears in a
* relocatable .o file (MH_OBJECT filetype). And is used to indicate to the
* static link editor it is never to dead strip the symbol.
*/
#define N_NO_DEAD_STRIP 0x0020 /* symbol is not to be dead stripped */
/*
* The N_DESC_DISCARDED bit of the n_desc field never appears in linked image.
* But is used in very rare cases by the dynamic link editor to mark an in
* memory symbol as discared and longer used for linking.
*/
#define N_DESC_DISCARDED 0x0020 /* symbol is discarded */
/*
* The N_WEAK_REF bit of the n_desc field indicates to the dynamic linker that
* the undefined symbol is allowed to be missing and is to have the address of
* zero when missing.
*/
#define N_WEAK_REF 0x0040 /* symbol is weak referenced */
/*
* The N_WEAK_DEF bit of the n_desc field indicates to the static and dynamic
* linkers that the symbol definition is weak, allowing a non-weak symbol to
* also be used which causes the weak definition to be discared. Currently this
* is only supported for symbols in coalesed sections.
*/
#define N_WEAK_DEF 0x0080 /* coalesed symbol is a weak definition */
/*
* The N_REF_TO_WEAK bit of the n_desc field indicates to the dynamic linker
* that the undefined symbol should be resolved using flat namespace searching.
*/
#define N_REF_TO_WEAK 0x0080 /* reference to a weak symbol */
/*
* The N_ARM_THUMB_DEF bit of the n_desc field indicates that the symbol is
* a defintion of a Thumb function.
*/
#define N_ARM_THUMB_DEF 0x0008 /* symbol is a Thumb function (ARM) */
/*
* The N_SYMBOL_RESOLVER bit of the n_desc field indicates that the
* that the function is actually a resolver function and should
* be called to get the address of the real function to use.
* This bit is only available in .o files (MH_OBJECT filetype)
*/
#define N_SYMBOL_RESOLVER 0x0100
/*
* The N_ALT_ENTRY bit of the n_desc field indicates that the
* symbol is pinned to the previous content.
*/
#define N_ALT_ENTRY 0x0200
/*
* The N_COLD_FUNC bit of the n_desc field indicates that the symbol is used
* infrequently and the linker should order it towards the end of the section.
*/
#define N_COLD_FUNC 0x0400
#ifndef __STRICT_BSD__
#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */
/*
* The function nlist(3) from the C library.
*/
extern int nlist (const char *filename, struct nlist *list);
#ifdef __cplusplus
}
#endif /* __cplusplus */
#endif /* __STRICT_BSD__ */
#endif /* _MACHO_LIST_H_ */

View File

@ -0,0 +1,90 @@
/*
* Copyright (c) 2016 Apple, Inc. All rights reserved.
*
* @APPLE_LICENSE_HEADER_START@
*
* This file contains Original Code and/or Modifications of Original Code
* as defined in and that are subject to the Apple Public Source License
* Version 2.0 (the 'License'). You may not use this file except in
* compliance with the License. Please obtain a copy of the License at
* http://www.opensource.apple.com/apsl/ and read it before using this
* file.
*
* The Original Code and all software distributed under the License are
* distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
* Please see the License for the specific language governing rights and
* limitations under the License.
*
* @APPLE_LICENSE_HEADER_END@
*/
/* ranlib.h 4.1 83/05/03 */
#ifndef _MACH_O_RANLIB_H_
#define _MACH_O_RANLIB_H_
#include <stdint.h>
#include <sys/types.h> /* off_t */
/*
* There are two known orders of table of contents for archives. The first is
* the order ranlib(1) originally produced and still produces without any
* options. This table of contents has the archive member name "__.SYMDEF"
* This order has the ranlib structures in the order the objects appear in the
* archive and the symbol names of those objects in the order of symbol table.
* The second know order is sorted by symbol name and is produced with the -s
* option to ranlib(1). This table of contents has the archive member name
* "__.SYMDEF SORTED" and many programs (notably the 1.0 version of ld(1) can't
* tell the difference between names because of the imbedded blank in the name
* and works with either table of contents). This second order is used by the
* post 1.0 link editor to produce faster linking. The original 1.0 version of
* ranlib(1) gets confused when it is run on a archive with the second type of
* table of contents because it and ar(1) which it uses use different ways to
* determined the member name (ar(1) treats all blanks in the name as
* significant and ranlib(1) only checks for the first one).
*/
#define SYMDEF "__.SYMDEF"
#define SYMDEF_SORTED "__.SYMDEF SORTED"
/*
* Structure of the __.SYMDEF table of contents for an archive.
* __.SYMDEF begins with a uint32_t giving the size in bytes of the ranlib
* structures which immediately follow, and then continues with a string
* table consisting of a uint32_t giving the number of bytes of strings which
* follow and then the strings themselves. The ran_strx fields index the
* string table whose first byte is numbered 0.
*/
struct ranlib {
union {
uint32_t ran_strx; /* string table index of */
#ifndef __LP64__
char *ran_name; /* symbol defined by */
#endif
} ran_un;
uint32_t ran_off; /* library member at this offset */
};
#define SYMDEF_64 "__.SYMDEF_64"
#define SYMDEF_64_SORTED "__.SYMDEF_64 SORTED"
/*
* The support for the 64-bit table of contents described here is a work in
* progress and not yet fully supported in all the Apple Developer Tools.
*
* When an archive offset to a library member is more than 32-bits then this is
* the structure of the __.SYMDEF_64 table of contents for an archive.
* __.SYMDEF_64 begins with a uint64_t giving the size in bytes of the ranlib
* structures which immediately follow, and then continues with a string
* table consisting of a uint64_t giving the number of bytes of strings which
* follow and then the strings themselves. The ran_strx fields index the
* string table whose first byte is numbered 0.
*/
struct ranlib_64 {
union {
uint64_t ran_strx; /* string table index of */
} ran_un;
uint64_t ran_off; /* library member at this offset */
};
#endif /* _MACH_O_RANLIB_H_ */

View File

@ -0,0 +1,203 @@
/*
* Copyright (c) 1999 Apple Computer, Inc. All rights reserved.
*
* @APPLE_LICENSE_HEADER_START@
*
* This file contains Original Code and/or Modifications of Original Code
* as defined in and that are subject to the Apple Public Source License
* Version 2.0 (the 'License'). You may not use this file except in
* compliance with the License. Please obtain a copy of the License at
* http://www.opensource.apple.com/apsl/ and read it before using this
* file.
*
* The Original Code and all software distributed under the License are
* distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
* Please see the License for the specific language governing rights and
* limitations under the License.
*
* @APPLE_LICENSE_HEADER_END@
*/
/* $NetBSD: exec.h,v 1.6 1994/10/27 04:16:05 cgd Exp $ */
/*
* Copyright (c) 1993 Christopher G. Demetriou
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. The name of the author may not be used to endorse or promote products
* derived from this software without specific prior written permission
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef _MACHO_RELOC_H_
#define _MACHO_RELOC_H_
#include <stdint.h>
/*
* Format of a relocation entry of a Mach-O file. Modified from the 4.3BSD
* format. The modifications from the original format were changing the value
* of the r_symbolnum field for "local" (r_extern == 0) relocation entries.
* This modification is required to support symbols in an arbitrary number of
* sections not just the three sections (text, data and bss) in a 4.3BSD file.
* Also the last 4 bits have had the r_type tag added to them.
*/
struct relocation_info {
int32_t r_address; /* offset in the section to what is being
relocated */
uint32_t r_symbolnum:24, /* symbol index if r_extern == 1 or section
ordinal if r_extern == 0 */
r_pcrel:1, /* was relocated pc relative already */
r_length:2, /* 0=byte, 1=word, 2=long, 3=quad */
r_extern:1, /* does not include value of sym referenced */
r_type:4; /* if not 0, machine specific relocation type */
};
#define R_ABS 0 /* absolute relocation type for Mach-O files */
/*
* The r_address is not really the address as it's name indicates but an offset.
* In 4.3BSD a.out objects this offset is from the start of the "segment" for
* which relocation entry is for (text or data). For Mach-O object files it is
* also an offset but from the start of the "section" for which the relocation
* entry is for. See comments in <mach-o/loader.h> about the r_address feild
* in images for used with the dynamic linker.
*
* In 4.3BSD a.out objects if r_extern is zero then r_symbolnum is an ordinal
* for the segment the symbol being relocated is in. These ordinals are the
* symbol types N_TEXT, N_DATA, N_BSS or N_ABS. In Mach-O object files these
* ordinals refer to the sections in the object file in the order their section
* structures appear in the headers of the object file they are in. The first
* section has the ordinal 1, the second 2, and so on. This means that the
* same ordinal in two different object files could refer to two different
* sections. And further could have still different ordinals when combined
* by the link-editor. The value R_ABS is used for relocation entries for
* absolute symbols which need no further relocation.
*/
/*
* For RISC machines some of the references are split across two instructions
* and the instruction does not contain the complete value of the reference.
* In these cases a second, or paired relocation entry, follows each of these
* relocation entries, using a PAIR r_type, which contains the other part of the
* reference not contained in the instruction. This other part is stored in the
* pair's r_address field. The exact number of bits of the other part of the
* reference store in the r_address field is dependent on the particular
* relocation type for the particular architecture.
*/
/*
* To make scattered loading by the link editor work correctly "local"
* relocation entries can't be used when the item to be relocated is the value
* of a symbol plus an offset (where the resulting expresion is outside the
* block the link editor is moving, a blocks are divided at symbol addresses).
* In this case. where the item is a symbol value plus offset, the link editor
* needs to know more than just the section the symbol was defined. What is
* needed is the actual value of the symbol without the offset so it can do the
* relocation correctly based on where the value of the symbol got relocated to
* not the value of the expression (with the offset added to the symbol value).
* So for the NeXT 2.0 release no "local" relocation entries are ever used when
* there is a non-zero offset added to a symbol. The "external" and "local"
* relocation entries remain unchanged.
*
* The implemention is quite messy given the compatibility with the existing
* relocation entry format. The ASSUMPTION is that a section will never be
* bigger than 2**24 - 1 (0x00ffffff or 16,777,215) bytes. This assumption
* allows the r_address (which is really an offset) to fit in 24 bits and high
* bit of the r_address field in the relocation_info structure to indicate
* it is really a scattered_relocation_info structure. Since these are only
* used in places where "local" relocation entries are used and not where
* "external" relocation entries are used the r_extern field has been removed.
*
* For scattered loading to work on a RISC machine where some of the references
* are split across two instructions the link editor needs to be assured that
* each reference has a unique 32 bit reference (that more than one reference is
* NOT sharing the same high 16 bits for example) so it move each referenced
* item independent of each other. Some compilers guarantees this but the
* compilers don't so scattered loading can be done on those that do guarantee
* this.
*/
#if defined(__BIG_ENDIAN__) || defined(__LITTLE_ENDIAN__)
/*
* The reason for the ifdef's of __BIG_ENDIAN__ and __LITTLE_ENDIAN__ are that
* when stattered relocation entries were added the mistake of using a mask
* against a structure that is made up of bit fields was used. To make this
* design work this structure must be laid out in memory the same way so the
* mask can be applied can check the same bit each time (r_scattered).
*/
#endif /* defined(__BIG_ENDIAN__) || defined(__LITTLE_ENDIAN__) */
#define R_SCATTERED 0x80000000 /* mask to be applied to the r_address field
of a relocation_info structure to tell that
is is really a scattered_relocation_info
stucture */
struct scattered_relocation_info {
#ifdef __BIG_ENDIAN__
uint32_t r_scattered:1, /* 1=scattered, 0=non-scattered (see above) */
r_pcrel:1, /* was relocated pc relative already */
r_length:2, /* 0=byte, 1=word, 2=long, 3=quad */
r_type:4, /* if not 0, machine specific relocation type */
r_address:24; /* offset in the section to what is being
relocated */
int32_t r_value; /* the value the item to be relocated is
refering to (without any offset added) */
#endif /* __BIG_ENDIAN__ */
#ifdef __LITTLE_ENDIAN__
uint32_t
r_address:24, /* offset in the section to what is being
relocated */
r_type:4, /* if not 0, machine specific relocation type */
r_length:2, /* 0=byte, 1=word, 2=long, 3=quad */
r_pcrel:1, /* was relocated pc relative already */
r_scattered:1; /* 1=scattered, 0=non-scattered (see above) */
int32_t r_value; /* the value the item to be relocated is
refering to (without any offset added) */
#endif /* __LITTLE_ENDIAN__ */
};
/*
* Relocation types used in a generic implementation. Relocation entries for
* normal things use the generic relocation as discribed above and their r_type
* is GENERIC_RELOC_VANILLA (a value of zero).
*
* Another type of generic relocation, GENERIC_RELOC_SECTDIFF, is to support
* the difference of two symbols defined in different sections. That is the
* expression "symbol1 - symbol2 + constant" is a relocatable expression when
* both symbols are defined in some section. For this type of relocation the
* both relocations entries are scattered relocation entries. The value of
* symbol1 is stored in the first relocation entry's r_value field and the
* value of symbol2 is stored in the pair's r_value field.
*
* A special case for a prebound lazy pointer is needed to beable to set the
* value of the lazy pointer back to its non-prebound state. This is done
* using the GENERIC_RELOC_PB_LA_PTR r_type. This is a scattered relocation
* entry where the r_value feild is the value of the lazy pointer not prebound.
*/
enum reloc_type_generic
{
GENERIC_RELOC_VANILLA, /* generic relocation as discribed above */
GENERIC_RELOC_PAIR, /* Only follows a GENERIC_RELOC_SECTDIFF */
GENERIC_RELOC_SECTDIFF,
GENERIC_RELOC_PB_LA_PTR, /* prebound lazy pointer */
GENERIC_RELOC_LOCAL_SECTDIFF,
GENERIC_RELOC_TLV /* thread local variables */
};
#endif /* _MACHO_RELOC_H_ */

View File

@ -0,0 +1,126 @@
/*
* Copyright (c) 1999 Apple Computer, Inc. All rights reserved.
*
* @APPLE_LICENSE_HEADER_START@
*
* This file contains Original Code and/or Modifications of Original Code
* as defined in and that are subject to the Apple Public Source License
* Version 2.0 (the 'License'). You may not use this file except in
* compliance with the License. Please obtain a copy of the License at
* http://www.opensource.apple.com/apsl/ and read it before using this
* file.
*
* The Original Code and all software distributed under the License are
* distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
* Please see the License for the specific language governing rights and
* limitations under the License.
*
* @APPLE_LICENSE_HEADER_END@
*/
#ifndef _MACHO_STAB_H_
#define _MACHO_STAB_H_
/* $NetBSD: stab.h,v 1.4 1994/10/26 00:56:25 cgd Exp $ */
/*-
* Copyright (c) 1991 The Regents of the University of California.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed by the University of
* California, Berkeley and its contributors.
* 4. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* @(#)stab.h 5.2 (Berkeley) 4/4/91
*/
/*
* This file gives definitions supplementing <nlist.h> for permanent symbol
* table entries of Mach-O files. Modified from the BSD definitions. The
* modifications from the original definitions were changing what the values of
* what was the n_other field (an unused field) which is now the n_sect field.
* These modifications are required to support symbols in an arbitrary number of
* sections not just the three sections (text, data and bss) in a BSD file.
* The values of the defined constants have NOT been changed.
*
* These must have one of the N_STAB bits on. The n_value fields are subject
* to relocation according to the value of their n_sect field. So for types
* that refer to things in sections the n_sect field must be filled in with the
* proper section ordinal. For types that are not to have their n_value field
* relocatated the n_sect field must be NO_SECT.
*/
/*
* Symbolic debugger symbols. The comments give the conventional use for
*
* .stabs "n_name", n_type, n_sect, n_desc, n_value
*
* where n_type is the defined constant and not listed in the comment. Other
* fields not listed are zero. n_sect is the section ordinal the entry is
* refering to.
*/
#define N_GSYM 0x20 /* global symbol: name,,NO_SECT,type,0 */
#define N_FNAME 0x22 /* procedure name (f77 kludge): name,,NO_SECT,0,0 */
#define N_FUN 0x24 /* procedure: name,,n_sect,linenumber,address */
#define N_STSYM 0x26 /* static symbol: name,,n_sect,type,address */
#define N_LCSYM 0x28 /* .lcomm symbol: name,,n_sect,type,address */
#define N_BNSYM 0x2e /* begin nsect sym: 0,,n_sect,0,address */
#define N_AST 0x32 /* AST file path: name,,NO_SECT,0,0 */
#define N_OPT 0x3c /* emitted with gcc2_compiled and in gcc source */
#define N_RSYM 0x40 /* register sym: name,,NO_SECT,type,register */
#define N_SLINE 0x44 /* src line: 0,,n_sect,linenumber,address */
#define N_ENSYM 0x4e /* end nsect sym: 0,,n_sect,0,address */
#define N_SSYM 0x60 /* structure elt: name,,NO_SECT,type,struct_offset */
#define N_SO 0x64 /* source file name: name,,n_sect,0,address */
#define N_OSO 0x66 /* object file name: name,,(see below),0,st_mtime */
/* historically N_OSO set n_sect to 0. The N_OSO
* n_sect may instead hold the low byte of the
* cpusubtype value from the Mach-O header. */
#define N_LSYM 0x80 /* local sym: name,,NO_SECT,type,offset */
#define N_BINCL 0x82 /* include file beginning: name,,NO_SECT,0,sum */
#define N_SOL 0x84 /* #included file name: name,,n_sect,0,address */
#define N_PARAMS 0x86 /* compiler parameters: name,,NO_SECT,0,0 */
#define N_VERSION 0x88 /* compiler version: name,,NO_SECT,0,0 */
#define N_OLEVEL 0x8A /* compiler -O level: name,,NO_SECT,0,0 */
#define N_PSYM 0xa0 /* parameter: name,,NO_SECT,type,offset */
#define N_EINCL 0xa2 /* include file end: name,,NO_SECT,0,0 */
#define N_ENTRY 0xa4 /* alternate entry: name,,n_sect,linenumber,address */
#define N_LBRAC 0xc0 /* left bracket: 0,,NO_SECT,nesting level,address */
#define N_EXCL 0xc2 /* deleted include file: name,,NO_SECT,0,sum */
#define N_RBRAC 0xe0 /* right bracket: 0,,NO_SECT,nesting level,address */
#define N_BCOMM 0xe2 /* begin common: name,,NO_SECT,0,0 */
#define N_ECOMM 0xe4 /* end common: name,,n_sect,0,0 */
#define N_ECOML 0xe8 /* end common (local name): 0,,n_sect,0,address */
#define N_LENG 0xfe /* second stab entry with length information */
/*
* for the berkeley pascal compiler, pc(1):
*/
#define N_PC 0x30 /* global pascal symbol: name,,NO_SECT,subtype,line */
#endif /* _MACHO_STAB_H_ */

View File

@ -0,0 +1,278 @@
/*
* Copyright (c) 1999 Apple Computer, Inc. All rights reserved.
*
* @APPLE_LICENSE_HEADER_START@
*
* This file contains Original Code and/or Modifications of Original Code
* as defined in and that are subject to the Apple Public Source License
* Version 2.0 (the 'License'). You may not use this file except in
* compliance with the License. Please obtain a copy of the License at
* http://www.opensource.apple.com/apsl/ and read it before using this
* file.
*
* The Original Code and all software distributed under the License are
* distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
* Please see the License for the specific language governing rights and
* limitations under the License.
*
* @APPLE_LICENSE_HEADER_END@
*/
#ifndef _MACH_O_SWAP_H_
#define _MACH_O_SWAP_H_
#include <stdint.h>
#include <architecture/byte_order.h>
#include <mach-o/fat.h>
#include <mach-o/loader.h>
#include <mach-o/nlist.h>
#include <mach-o/reloc.h>
#include <mach-o/ranlib.h>
#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */
extern void swap_fat_header(
struct fat_header *fat_header,
enum NXByteOrder target_byte_order);
extern void swap_fat_arch(
struct fat_arch *fat_archs,
uint32_t nfat_arch,
enum NXByteOrder target_byte_order);
extern void swap_fat_arch_64(
struct fat_arch_64 *fat_archs64,
uint32_t nfat_arch,
enum NXByteOrder target_byte_order);
extern void swap_mach_header(
struct mach_header *mh,
enum NXByteOrder target_byte_order);
extern void swap_mach_header_64(
struct mach_header_64 *mh,
enum NXByteOrder target_byte_order);
extern void swap_load_command(
struct load_command *lc,
enum NXByteOrder target_byte_order);
extern void swap_segment_command(
struct segment_command *sg,
enum NXByteOrder target_byte_order);
extern void swap_segment_command_64(
struct segment_command_64 *sg,
enum NXByteOrder target_byte_order);
extern void swap_section(
struct section *s,
uint32_t nsects,
enum NXByteOrder target_byte_order);
extern void swap_section_64(
struct section_64 *s,
uint32_t nsects,
enum NXByteOrder target_byte_order);
extern void swap_symtab_command(
struct symtab_command *st,
enum NXByteOrder target_byte_order);
extern void swap_dysymtab_command(
struct dysymtab_command *dyst,
enum NXByteOrder target_byte_sex);
extern void swap_symseg_command(
struct symseg_command *ss,
enum NXByteOrder target_byte_order);
extern void swap_fvmlib_command(
struct fvmlib_command *fl,
enum NXByteOrder target_byte_order);
extern void swap_dylib_command(
struct dylib_command *dl,
enum NXByteOrder target_byte_sex);
extern void swap_sub_framework_command(
struct sub_framework_command *sub,
enum NXByteOrder target_byte_sex);
extern void swap_sub_umbrella_command(
struct sub_umbrella_command *usub,
enum NXByteOrder target_byte_sex);
extern void swap_sub_library_command(
struct sub_library_command *lsub,
enum NXByteOrder target_byte_sex);
extern void swap_sub_client_command(
struct sub_client_command *csub,
enum NXByteOrder target_byte_sex);
extern void swap_prebound_dylib_command(
struct prebound_dylib_command *pbdylib,
enum NXByteOrder target_byte_sex);
extern void swap_dylinker_command(
struct dylinker_command *dyld,
enum NXByteOrder target_byte_sex);
extern void swap_fvmfile_command(
struct fvmfile_command *ff,
enum NXByteOrder target_byte_order);
extern void swap_thread_command(
struct thread_command *ut,
enum NXByteOrder target_byte_order);
extern void swap_ident_command(
struct ident_command *ident,
enum NXByteOrder target_byte_order);
extern void swap_routines_command(
struct routines_command *r_cmd,
enum NXByteOrder target_byte_sex);
extern void swap_routines_command_64(
struct routines_command_64 *r_cmd,
enum NXByteOrder target_byte_sex);
extern void swap_twolevel_hints_command(
struct twolevel_hints_command *hints_cmd,
enum NXByteOrder target_byte_sex);
extern void swap_prebind_cksum_command(
struct prebind_cksum_command *cksum_cmd,
enum NXByteOrder target_byte_sex);
extern void swap_uuid_command(
struct uuid_command *uuid_cmd,
enum NXByteOrder target_byte_sex);
extern void swap_linkedit_data_command(
struct linkedit_data_command *ld,
enum NXByteOrder target_byte_sex);
extern void swap_version_min_command(
struct version_min_command *ver_cmd,
enum NXByteOrder target_byte_sex);
extern void swap_rpath_command(
struct rpath_command *rpath_cmd,
enum NXByteOrder target_byte_sex);
extern void swap_encryption_command(
struct encryption_info_command *ec,
enum NXByteOrder target_byte_sex);
extern void swap_encryption_command_64(
struct encryption_info_command_64 *ec,
enum NXByteOrder target_byte_sex);
extern void swap_linker_option_command(
struct linker_option_command *lo,
enum NXByteOrder target_byte_sex);
extern void swap_dyld_info_command(
struct dyld_info_command *ed,
enum NXByteOrder target_byte_sex);
extern void swap_entry_point_command(
struct entry_point_command *ep,
enum NXByteOrder target_byte_sex);
extern void swap_source_version_command(
struct source_version_command *sv,
enum NXByteOrder target_byte_sex);
extern void swap_note_command(
struct note_command *nc,
enum NXByteOrder target_byte_sex);
extern void swap_build_version_command(
struct build_version_command *bv,
enum NXByteOrder target_byte_sex);
extern void swap_build_tool_version(
struct build_tool_version *bt,
uint32_t ntools,
enum NXByteOrder target_byte_sex);
extern void swap_prebind_cksum_command(
struct prebind_cksum_command *cksum_cmd,
enum NXByteOrder target_byte_sex);
extern void swap_uuid_command(
struct uuid_command *uuid_cmd,
enum NXByteOrder target_byte_sex);
extern void swap_twolevel_hint(
struct twolevel_hint *hints,
uint32_t nhints,
enum NXByteOrder target_byte_sex);
extern void swap_fileset_entry_command(
struct fileset_entry_command *lc,
enum NXByteOrder target_byte_sex);
extern void swap_nlist(
struct nlist *symbols,
uint32_t nsymbols,
enum NXByteOrder target_byte_order);
extern void swap_nlist_64(
struct nlist_64 *symbols,
uint32_t nsymbols,
enum NXByteOrder target_byte_order);
extern void swap_ranlib(
struct ranlib *ranlibs,
uint32_t nranlibs,
enum NXByteOrder target_byte_order);
extern void swap_ranlib_64(
struct ranlib_64 *ranlibs,
uint64_t nranlibs,
enum NXByteOrder target_byte_order);
extern void swap_relocation_info(
struct relocation_info *relocs,
uint32_t nrelocs,
enum NXByteOrder target_byte_order);
extern void swap_indirect_symbols(
uint32_t *indirect_symbols,
uint32_t nindirect_symbols,
enum NXByteOrder target_byte_sex);
extern void swap_dylib_reference(
struct dylib_reference *refs,
uint32_t nrefs,
enum NXByteOrder target_byte_sex);
extern void swap_dylib_module(
struct dylib_module *mods,
uint32_t nmods,
enum NXByteOrder target_byte_sex);
extern void swap_dylib_module_64(
struct dylib_module_64 *mods,
uint32_t nmods,
enum NXByteOrder target_byte_sex);
extern void swap_dylib_table_of_contents(
struct dylib_table_of_contents *tocs,
uint32_t ntocs,
enum NXByteOrder target_byte_sex);
#ifdef __cplusplus
}
#endif /* __cplusplus */
#endif /* _MACH_O_SWAP_H_ */

View File

@ -0,0 +1,185 @@
/*
* Copyright (c) 2006 Apple Computer, Inc. All rights reserved.
*
* @APPLE_LICENSE_HEADER_START@
*
* This file contains Original Code and/or Modifications of Original Code
* as defined in and that are subject to the Apple Public Source License
* Version 2.0 (the 'License'). You may not use this file except in
* compliance with the License. Please obtain a copy of the License at
* http://www.opensource.apple.com/apsl/ and read it before using this
* file.
*
* The Original Code and all software distributed under the License are
* distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
* Please see the License for the specific language governing rights and
* limitations under the License.
*
* @APPLE_LICENSE_HEADER_END@
*/
/*
* Relocations for x86_64 are a bit different than for other architectures in
* Mach-O: Scattered relocations are not used. Almost all relocations produced
* by the compiler are external relocations. An external relocation has the
* r_extern bit set to 1 and the r_symbolnum field contains the symbol table
* index of the target label.
*
* When the assembler is generating relocations, if the target label is a local
* label (begins with 'L'), then the previous non-local label in the same
* section is used as the target of the external relocation. An addend is used
* with the distance from that non-local label to the target label. Only when
* there is no previous non-local label in the section is an internal
* relocation used.
*
* The addend (i.e. the 4 in _foo+4) is encoded in the instruction (Mach-O does
* not have RELA relocations). For PC-relative relocations, the addend is
* stored directly in the instruction. This is different from other Mach-O
* architectures, which encode the addend minus the current section offset.
*
* The relocation types are:
*
* X86_64_RELOC_UNSIGNED // for absolute addresses
* X86_64_RELOC_SIGNED // for signed 32-bit displacement
* X86_64_RELOC_BRANCH // a CALL/JMP instruction with 32-bit displacement
* X86_64_RELOC_GOT_LOAD // a MOVQ load of a GOT entry
* X86_64_RELOC_GOT // other GOT references
* X86_64_RELOC_SUBTRACTOR // must be followed by a X86_64_RELOC_UNSIGNED
*
* The following are sample assembly instructions, followed by the relocation
* and section content they generate in an object file:
*
* call _foo
* r_type=X86_64_RELOC_BRANCH, r_length=2, r_extern=1, r_pcrel=1, r_symbolnum=_foo
* E8 00 00 00 00
*
* call _foo+4
* r_type=X86_64_RELOC_BRANCH, r_length=2, r_extern=1, r_pcrel=1, r_symbolnum=_foo
* E8 04 00 00 00
*
* movq _foo@GOTPCREL(%rip), %rax
* r_type=X86_64_RELOC_GOT_LOAD, r_length=2, r_extern=1, r_pcrel=1, r_symbolnum=_foo
* 48 8B 05 00 00 00 00
*
* pushq _foo@GOTPCREL(%rip)
* r_type=X86_64_RELOC_GOT, r_length=2, r_extern=1, r_pcrel=1, r_symbolnum=_foo
* FF 35 00 00 00 00
*
* movl _foo(%rip), %eax
* r_type=X86_64_RELOC_SIGNED, r_length=2, r_extern=1, r_pcrel=1, r_symbolnum=_foo
* 8B 05 00 00 00 00
*
* movl _foo+4(%rip), %eax
* r_type=X86_64_RELOC_SIGNED, r_length=2, r_extern=1, r_pcrel=1, r_symbolnum=_foo
* 8B 05 04 00 00 00
*
* movb $0x12, _foo(%rip)
* r_type=X86_64_RELOC_SIGNED, r_length=2, r_extern=1, r_pcrel=1, r_symbolnum=_foo
* C6 05 FF FF FF FF 12
*
* movl $0x12345678, _foo(%rip)
* r_type=X86_64_RELOC_SIGNED, r_length=2, r_extern=1, r_pcrel=1, r_symbolnum=_foo
* C7 05 FC FF FF FF 78 56 34 12
*
* .quad _foo
* r_type=X86_64_RELOC_UNSIGNED, r_length=3, r_extern=1, r_pcrel=0, r_symbolnum=_foo
* 00 00 00 00 00 00 00 00
*
* .quad _foo+4
* r_type=X86_64_RELOC_UNSIGNED, r_length=3, r_extern=1, r_pcrel=0, r_symbolnum=_foo
* 04 00 00 00 00 00 00 00
*
* .quad _foo - _bar
* r_type=X86_64_RELOC_SUBTRACTOR, r_length=3, r_extern=1, r_pcrel=0, r_symbolnum=_bar
* r_type=X86_64_RELOC_UNSIGNED, r_length=3, r_extern=1, r_pcrel=0, r_symbolnum=_foo
* 00 00 00 00 00 00 00 00
*
* .quad _foo - _bar + 4
* r_type=X86_64_RELOC_SUBTRACTOR, r_length=3, r_extern=1, r_pcrel=0, r_symbolnum=_bar
* r_type=X86_64_RELOC_UNSIGNED, r_length=3, r_extern=1, r_pcrel=0, r_symbolnum=_foo
* 04 00 00 00 00 00 00 00
*
* .long _foo - _bar
* r_type=X86_64_RELOC_SUBTRACTOR, r_length=2, r_extern=1, r_pcrel=0, r_symbolnum=_bar
* r_type=X86_64_RELOC_UNSIGNED, r_length=2, r_extern=1, r_pcrel=0, r_symbolnum=_foo
* 00 00 00 00
*
* lea L1(%rip), %rax
* r_type=X86_64_RELOC_SIGNED, r_length=2, r_extern=1, r_pcrel=1, r_symbolnum=_prev
* 48 8d 05 12 00 00 00
* // assumes _prev is the first non-local label 0x12 bytes before L1
*
* lea L0(%rip), %rax
* r_type=X86_64_RELOC_SIGNED, r_length=2, r_extern=0, r_pcrel=1, r_symbolnum=3
* 48 8d 05 56 00 00 00
* // assumes L0 is in third section and there is no previous non-local label.
* // The rip-relative-offset of 0x00000056 is L0-address_of_next_instruction.
* // address_of_next_instruction is the address of the relocation + 4.
*
* add $6,L0(%rip)
* r_type=X86_64_RELOC_SIGNED_1, r_length=2, r_extern=0, r_pcrel=1, r_symbolnum=3
* 83 05 18 00 00 00 06
* // assumes L0 is in third section and there is no previous non-local label.
* // The rip-relative-offset of 0x00000018 is L0-address_of_next_instruction.
* // address_of_next_instruction is the address of the relocation + 4 + 1.
* // The +1 comes from SIGNED_1. This is used because the relocation is not
* // at the end of the instruction.
*
* .quad L1
* r_type=X86_64_RELOC_UNSIGNED, r_length=3, r_extern=1, r_pcrel=0, r_symbolnum=_prev
* 12 00 00 00 00 00 00 00
* // assumes _prev is the first non-local label 0x12 bytes before L1
*
* .quad L0
* r_type=X86_64_RELOC_UNSIGNED, r_length=3, r_extern=0, r_pcrel=0, r_symbolnum=3
* 56 00 00 00 00 00 00 00
* // assumes L0 is in third section, has an address of 0x00000056 in .o
* // file, and there is no previous non-local label
*
* .quad _foo - .
* r_type=X86_64_RELOC_SUBTRACTOR, r_length=3, r_extern=1, r_pcrel=0, r_symbolnum=_prev
* r_type=X86_64_RELOC_UNSIGNED, r_length=3, r_extern=1, r_pcrel=0, r_symbolnum=_foo
* EE FF FF FF FF FF FF FF
* // assumes _prev is the first non-local label 0x12 bytes before this
* // .quad
*
* .quad _foo - L1
* r_type=X86_64_RELOC_SUBTRACTOR, r_length=3, r_extern=1, r_pcrel=0, r_symbolnum=_prev
* r_type=X86_64_RELOC_UNSIGNED, r_length=3, r_extern=1, r_pcrel=0, r_symbolnum=_foo
* EE FF FF FF FF FF FF FF
* // assumes _prev is the first non-local label 0x12 bytes before L1
*
* .quad L1 - _prev
* // No relocations. This is an assembly time constant.
* 12 00 00 00 00 00 00 00
* // assumes _prev is the first non-local label 0x12 bytes before L1
*
*
*
* In final linked images, there are only two valid relocation kinds:
*
* r_type=X86_64_RELOC_UNSIGNED, r_length=3, r_pcrel=0, r_extern=1, r_symbolnum=sym_index
* This tells dyld to add the address of a symbol to a pointer sized (8-byte)
* piece of data (i.e on disk the 8-byte piece of data contains the addend). The
* r_symbolnum contains the index into the symbol table of the target symbol.
*
* r_type=X86_64_RELOC_UNSIGNED, r_length=3, r_pcrel=0, r_extern=0, r_symbolnum=0
* This tells dyld to adjust the pointer sized (8-byte) piece of data by the amount
* the containing image was loaded from its base address (e.g. slide).
*
*/
enum reloc_type_x86_64
{
X86_64_RELOC_UNSIGNED, // for absolute addresses
X86_64_RELOC_SIGNED, // for signed 32-bit displacement
X86_64_RELOC_BRANCH, // a CALL/JMP instruction with 32-bit displacement
X86_64_RELOC_GOT_LOAD, // a MOVQ load of a GOT entry
X86_64_RELOC_GOT, // other GOT references
X86_64_RELOC_SUBTRACTOR, // must be followed by a X86_64_RELOC_UNSIGNED
X86_64_RELOC_SIGNED_1, // for signed 32-bit displacement with a -1 addend
X86_64_RELOC_SIGNED_2, // for signed 32-bit displacement with a -2 addend
X86_64_RELOC_SIGNED_4, // for signed 32-bit displacement with a -4 addend
X86_64_RELOC_TLV, // for thread local variables
};

View File

@ -0,0 +1,645 @@
/*
* Copyright (c) 2004-2007 Apple Inc. All rights reserved.
*
* @APPLE_OSREFERENCE_LICENSE_HEADER_START@
*
* This file contains Original Code and/or Modifications of Original Code
* as defined in and that are subject to the Apple Public Source License
* Version 2.0 (the 'License'). You may not use this file except in
* compliance with the License. The rights granted to you under the License
* may not be used to create, or enable the creation or redistribution of,
* unlawful or unlicensed copies of an Apple operating system, or to
* circumvent, violate, or enable the circumvention or violation of, any
* terms of an Apple operating system software license agreement.
*
* Please obtain a copy of the License at
* http://www.opensource.apple.com/apsl/ and read it before using this file.
*
* The Original Code and all software distributed under the License are
* distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
* Please see the License for the specific language governing rights and
* limitations under the License.
*
* @APPLE_OSREFERENCE_LICENSE_HEADER_END@
*/
/*
* @OSF_COPYRIGHT@
*/
#ifndef _MACH_ARM__STRUCTS_H_
#define _MACH_ARM__STRUCTS_H_
#include <sys/cdefs.h> /* __DARWIN_UNIX03 */
#include <machine/types.h> /* __uint32_t */
#if __DARWIN_UNIX03
#define _STRUCT_ARM_EXCEPTION_STATE struct __darwin_arm_exception_state
_STRUCT_ARM_EXCEPTION_STATE
{
__uint32_t __exception; /* number of arm exception taken */
__uint32_t __fsr; /* Fault status */
__uint32_t __far; /* Virtual Fault Address */
};
#else /* !__DARWIN_UNIX03 */
#define _STRUCT_ARM_EXCEPTION_STATE struct arm_exception_state
_STRUCT_ARM_EXCEPTION_STATE
{
__uint32_t exception; /* number of arm exception taken */
__uint32_t fsr; /* Fault status */
__uint32_t far; /* Virtual Fault Address */
};
#endif /* __DARWIN_UNIX03 */
#if __DARWIN_UNIX03
#define _STRUCT_ARM_EXCEPTION_STATE64 struct __darwin_arm_exception_state64
_STRUCT_ARM_EXCEPTION_STATE64
{
__uint64_t __far; /* Virtual Fault Address */
__uint32_t __esr; /* Exception syndrome */
__uint32_t __exception; /* number of arm exception taken */
};
#else /* !__DARWIN_UNIX03 */
#define _STRUCT_ARM_EXCEPTION_STATE64 struct arm_exception_state64
_STRUCT_ARM_EXCEPTION_STATE64
{
__uint64_t far; /* Virtual Fault Address */
__uint32_t esr; /* Exception syndrome */
__uint32_t exception; /* number of arm exception taken */
};
#endif /* __DARWIN_UNIX03 */
#if __DARWIN_UNIX03
#define _STRUCT_ARM_THREAD_STATE struct __darwin_arm_thread_state
_STRUCT_ARM_THREAD_STATE
{
__uint32_t __r[13]; /* General purpose register r0-r12 */
__uint32_t __sp; /* Stack pointer r13 */
__uint32_t __lr; /* Link register r14 */
__uint32_t __pc; /* Program counter r15 */
__uint32_t __cpsr; /* Current program status register */
};
#else /* !__DARWIN_UNIX03 */
#define _STRUCT_ARM_THREAD_STATE struct arm_thread_state
_STRUCT_ARM_THREAD_STATE
{
__uint32_t r[13]; /* General purpose register r0-r12 */
__uint32_t sp; /* Stack pointer r13 */
__uint32_t lr; /* Link register r14 */
__uint32_t pc; /* Program counter r15 */
__uint32_t cpsr; /* Current program status register */
};
#endif /* __DARWIN_UNIX03 */
/*
* By default, the pointer fields in the arm_thread_state64_t structure are
* opaque on the arm64e architecture and require the use of accessor macros.
* This mode can also be enabled on the arm64 architecture by building with
* -D__DARWIN_OPAQUE_ARM_THREAD_STATE64=1.
*/
#if defined(__arm64__) && defined(__LP64__)
#if __has_feature(ptrauth_calls)
#define __DARWIN_OPAQUE_ARM_THREAD_STATE64 1
#define __DARWIN_PTRAUTH_ARM_THREAD_STATE64 1
#endif /* __has_feature(ptrauth_calls) */
#ifndef __DARWIN_OPAQUE_ARM_THREAD_STATE64
#define __DARWIN_OPAQUE_ARM_THREAD_STATE64 0
#endif
#else /* defined(__arm64__) && defined(__LP64__) */
#undef __DARWIN_OPAQUE_ARM_THREAD_STATE64
#define __DARWIN_OPAQUE_ARM_THREAD_STATE64 0
#endif /* defined(__arm64__) && defined(__LP64__) */
#if __DARWIN_UNIX03
#define _STRUCT_ARM_THREAD_STATE64 struct __darwin_arm_thread_state64
#if __DARWIN_OPAQUE_ARM_THREAD_STATE64
_STRUCT_ARM_THREAD_STATE64
{
__uint64_t __x[29]; /* General purpose registers x0-x28 */
void* __opaque_fp; /* Frame pointer x29 */
void* __opaque_lr; /* Link register x30 */
void* __opaque_sp; /* Stack pointer x31 */
void* __opaque_pc; /* Program counter */
__uint32_t __cpsr; /* Current program status register */
__uint32_t __opaque_flags; /* Flags describing structure format */
};
#else /* __DARWIN_OPAQUE_ARM_THREAD_STATE64 */
_STRUCT_ARM_THREAD_STATE64
{
__uint64_t __x[29]; /* General purpose registers x0-x28 */
__uint64_t __fp; /* Frame pointer x29 */
__uint64_t __lr; /* Link register x30 */
__uint64_t __sp; /* Stack pointer x31 */
__uint64_t __pc; /* Program counter */
__uint32_t __cpsr; /* Current program status register */
__uint32_t __pad; /* Same size for 32-bit or 64-bit clients */
};
#endif /* __DARWIN_OPAQUE_ARM_THREAD_STATE64 */
#else /* !__DARWIN_UNIX03 */
#define _STRUCT_ARM_THREAD_STATE64 struct arm_thread_state64
#if __DARWIN_OPAQUE_ARM_THREAD_STATE64
_STRUCT_ARM_THREAD_STATE64
{
__uint64_t x[29]; /* General purpose registers x0-x28 */
void* __opaque_fp; /* Frame pointer x29 */
void* __opaque_lr; /* Link register x30 */
void* __opaque_sp; /* Stack pointer x31 */
void* __opaque_pc; /* Program counter */
__uint32_t cpsr; /* Current program status register */
__uint32_t __opaque_flags; /* Flags describing structure format */
};
#else /* __DARWIN_OPAQUE_ARM_THREAD_STATE64 */
_STRUCT_ARM_THREAD_STATE64
{
__uint64_t x[29]; /* General purpose registers x0-x28 */
__uint64_t fp; /* Frame pointer x29 */
__uint64_t lr; /* Link register x30 */
__uint64_t sp; /* Stack pointer x31 */
__uint64_t pc; /* Program counter */
__uint32_t cpsr; /* Current program status register */
__uint32_t __pad; /* Same size for 32-bit or 64-bit clients */
};
#endif /* __DARWIN_OPAQUE_ARM_THREAD_STATE64 */
#endif /* __DARWIN_UNIX03 */
#if __DARWIN_C_LEVEL >= __DARWIN_C_FULL && defined(__arm64__)
/* Accessor macros for arm_thread_state64_t pointer fields */
#if __has_feature(ptrauth_calls) && defined(__LP64__)
#include <ptrauth.h>
#if !__DARWIN_OPAQUE_ARM_THREAD_STATE64 || !__DARWIN_PTRAUTH_ARM_THREAD_STATE64
#error "Invalid configuration"
#endif
#define __DARWIN_ARM_THREAD_STATE64_FLAGS_NO_PTRAUTH 0x1
#define __DARWIN_ARM_THREAD_STATE64_FLAGS_IB_SIGNED_LR 0x2
/* Return pc field of arm_thread_state64_t as a data pointer value */
#define __darwin_arm_thread_state64_get_pc(ts) \
__extension__ ({ const _STRUCT_ARM_THREAD_STATE64 *__tsp = &(ts); \
(uintptr_t)(__tsp->__opaque_pc && !(__tsp->__opaque_flags & \
__DARWIN_ARM_THREAD_STATE64_FLAGS_NO_PTRAUTH) ? \
ptrauth_auth_data(__tsp->__opaque_pc, \
ptrauth_key_process_independent_code, \
ptrauth_string_discriminator("pc")) : __tsp->__opaque_pc); })
/* Return pc field of arm_thread_state64_t as a function pointer. May return
* NULL if a valid function pointer cannot be constructed, the caller should
* fall back to the __darwin_arm_thread_state64_get_pc() macro in that case. */
#define __darwin_arm_thread_state64_get_pc_fptr(ts) \
__extension__ ({ const _STRUCT_ARM_THREAD_STATE64 *__tsp = &(ts); \
(__tsp->__opaque_pc && !(__tsp->__opaque_flags & \
__DARWIN_ARM_THREAD_STATE64_FLAGS_NO_PTRAUTH) ? \
ptrauth_auth_function(__tsp->__opaque_pc, \
ptrauth_key_process_independent_code, \
ptrauth_string_discriminator("pc")) : NULL); })
/* Set pc field of arm_thread_state64_t to a function pointer */
#define __darwin_arm_thread_state64_set_pc_fptr(ts, fptr) \
__extension__ ({ _STRUCT_ARM_THREAD_STATE64 *__tsp = &(ts); \
__typeof__(fptr) __f = (fptr); __tsp->__opaque_pc = \
(__f ? (!(__tsp->__opaque_flags & \
__DARWIN_ARM_THREAD_STATE64_FLAGS_NO_PTRAUTH) ? \
ptrauth_auth_and_resign(__f, ptrauth_key_function_pointer, 0, \
ptrauth_key_process_independent_code, \
ptrauth_string_discriminator("pc")) : ptrauth_auth_data(__f, \
ptrauth_key_function_pointer, 0)) : __f); })
/* Return lr field of arm_thread_state64_t as a data pointer value */
#define __darwin_arm_thread_state64_get_lr(ts) \
__extension__ ({ const _STRUCT_ARM_THREAD_STATE64 *__tsp = &(ts); \
(uintptr_t)(__tsp->__opaque_lr && !(__tsp->__opaque_flags & ( \
__DARWIN_ARM_THREAD_STATE64_FLAGS_NO_PTRAUTH | \
__DARWIN_ARM_THREAD_STATE64_FLAGS_IB_SIGNED_LR)) ? \
ptrauth_auth_data(__tsp->__opaque_lr, \
ptrauth_key_process_independent_code, \
ptrauth_string_discriminator("lr")) : __tsp->__opaque_lr); })
/* Return lr field of arm_thread_state64_t as a function pointer. May return
* NULL if a valid function pointer cannot be constructed, the caller should
* fall back to the __darwin_arm_thread_state64_get_lr() macro in that case. */
#define __darwin_arm_thread_state64_get_lr_fptr(ts) \
__extension__ ({ const _STRUCT_ARM_THREAD_STATE64 *__tsp = &(ts); \
(__tsp->__opaque_lr && !(__tsp->__opaque_flags & ( \
__DARWIN_ARM_THREAD_STATE64_FLAGS_NO_PTRAUTH | \
__DARWIN_ARM_THREAD_STATE64_FLAGS_IB_SIGNED_LR)) ? \
ptrauth_auth_function(__tsp->__opaque_lr, \
ptrauth_key_process_independent_code, \
ptrauth_string_discriminator("lr")) : NULL); })
/* Set lr field of arm_thread_state64_t to a function pointer */
#define __darwin_arm_thread_state64_set_lr_fptr(ts, fptr) \
__extension__ ({ _STRUCT_ARM_THREAD_STATE64 *__tsp = &(ts); \
__typeof__(fptr) __f = (fptr); __tsp->__opaque_lr = \
(__f ? (!(__tsp->__opaque_flags & \
__DARWIN_ARM_THREAD_STATE64_FLAGS_NO_PTRAUTH) ? (__tsp->__opaque_flags \
&= ~__DARWIN_ARM_THREAD_STATE64_FLAGS_IB_SIGNED_LR , \
ptrauth_auth_and_resign(__f, ptrauth_key_function_pointer, 0, \
ptrauth_key_process_independent_code, \
ptrauth_string_discriminator("lr"))) : ptrauth_auth_data(__f, \
ptrauth_key_function_pointer, 0)) : __f); })
/* Return sp field of arm_thread_state64_t as a data pointer value */
#define __darwin_arm_thread_state64_get_sp(ts) \
__extension__ ({ const _STRUCT_ARM_THREAD_STATE64 *__tsp = &(ts); \
(uintptr_t)(__tsp->__opaque_sp && !(__tsp->__opaque_flags & \
__DARWIN_ARM_THREAD_STATE64_FLAGS_NO_PTRAUTH) ? \
ptrauth_auth_data(__tsp->__opaque_sp, \
ptrauth_key_process_independent_data, \
ptrauth_string_discriminator("sp")) : __tsp->__opaque_sp); })
/* Set sp field of arm_thread_state64_t to a data pointer value */
#define __darwin_arm_thread_state64_set_sp(ts, ptr) \
__extension__ ({ _STRUCT_ARM_THREAD_STATE64 *__tsp = &(ts); \
void *__p = (void*)(uintptr_t)(ptr); __tsp->__opaque_sp = \
(__p && !(__tsp->__opaque_flags & \
__DARWIN_ARM_THREAD_STATE64_FLAGS_NO_PTRAUTH) ? \
ptrauth_sign_unauthenticated(__p, \
ptrauth_key_process_independent_data, \
ptrauth_string_discriminator("sp")) : __p); })
/* Return fp field of arm_thread_state64_t as a data pointer value */
#define __darwin_arm_thread_state64_get_fp(ts) \
__extension__ ({ const _STRUCT_ARM_THREAD_STATE64 *__tsp = &(ts); \
(uintptr_t)(__tsp->__opaque_fp && !(__tsp->__opaque_flags & \
__DARWIN_ARM_THREAD_STATE64_FLAGS_NO_PTRAUTH) ? \
ptrauth_auth_data(__tsp->__opaque_fp, \
ptrauth_key_process_independent_data, \
ptrauth_string_discriminator("fp")) : __tsp->__opaque_fp); })
/* Set fp field of arm_thread_state64_t to a data pointer value */
#define __darwin_arm_thread_state64_set_fp(ts, ptr) \
__extension__ ({ _STRUCT_ARM_THREAD_STATE64 *__tsp = &(ts); \
void *__p = (void*)(uintptr_t)(ptr); __tsp->__opaque_fp = \
(__p && !(__tsp->__opaque_flags & \
__DARWIN_ARM_THREAD_STATE64_FLAGS_NO_PTRAUTH) ? \
ptrauth_sign_unauthenticated(__p, \
ptrauth_key_process_independent_data, \
ptrauth_string_discriminator("fp")) : __p); })
/* Strip ptr auth bits from pc, lr, sp and fp field of arm_thread_state64_t */
#define __darwin_arm_thread_state64_ptrauth_strip(ts) \
__extension__ ({ _STRUCT_ARM_THREAD_STATE64 *__tsp = &(ts); \
__tsp->__opaque_pc = ((__tsp->__opaque_flags & \
__DARWIN_ARM_THREAD_STATE64_FLAGS_NO_PTRAUTH) ? __tsp->__opaque_pc : \
ptrauth_strip(__tsp->__opaque_pc, ptrauth_key_process_independent_code)); \
__tsp->__opaque_lr = ((__tsp->__opaque_flags & \
(__DARWIN_ARM_THREAD_STATE64_FLAGS_NO_PTRAUTH | \
__DARWIN_ARM_THREAD_STATE64_FLAGS_IB_SIGNED_LR)) ? __tsp->__opaque_lr : \
ptrauth_strip(__tsp->__opaque_lr, ptrauth_key_process_independent_code)); \
__tsp->__opaque_sp = ((__tsp->__opaque_flags & \
__DARWIN_ARM_THREAD_STATE64_FLAGS_NO_PTRAUTH) ? __tsp->__opaque_sp : \
ptrauth_strip(__tsp->__opaque_sp, ptrauth_key_process_independent_data)); \
__tsp->__opaque_fp = ((__tsp->__opaque_flags & \
__DARWIN_ARM_THREAD_STATE64_FLAGS_NO_PTRAUTH) ? __tsp->__opaque_fp : \
ptrauth_strip(__tsp->__opaque_fp, ptrauth_key_process_independent_data)); \
__tsp->__opaque_flags |= \
__DARWIN_ARM_THREAD_STATE64_FLAGS_NO_PTRAUTH; })
#else /* __has_feature(ptrauth_calls) && defined(__LP64__) */
#if __DARWIN_OPAQUE_ARM_THREAD_STATE64
#ifndef __LP64__
#error "Invalid configuration"
#endif
/* Return pc field of arm_thread_state64_t as a data pointer value */
#define __darwin_arm_thread_state64_get_pc(ts) \
((uintptr_t)((ts).__opaque_pc))
/* Return pc field of arm_thread_state64_t as a function pointer */
#define __darwin_arm_thread_state64_get_pc_fptr(ts) \
((ts).__opaque_pc)
/* Set pc field of arm_thread_state64_t to a function pointer */
#define __darwin_arm_thread_state64_set_pc_fptr(ts, fptr) \
((ts).__opaque_pc = (fptr))
/* Return lr field of arm_thread_state64_t as a data pointer value */
#define __darwin_arm_thread_state64_get_lr(ts) \
((uintptr_t)((ts).__opaque_lr))
/* Return lr field of arm_thread_state64_t as a function pointer */
#define __darwin_arm_thread_state64_get_lr_fptr(ts) \
((ts).__opaque_lr)
/* Set lr field of arm_thread_state64_t to a function pointer */
#define __darwin_arm_thread_state64_set_lr_fptr(ts, fptr) \
((ts).__opaque_lr = (fptr))
/* Return sp field of arm_thread_state64_t as a data pointer value */
#define __darwin_arm_thread_state64_get_sp(ts) \
((uintptr_t)((ts).__opaque_sp))
/* Set sp field of arm_thread_state64_t to a data pointer value */
#define __darwin_arm_thread_state64_set_sp(ts, ptr) \
((ts).__opaque_sp = (void*)(uintptr_t)(ptr))
/* Return fp field of arm_thread_state64_t as a data pointer value */
#define __darwin_arm_thread_state64_get_fp(ts) \
((uintptr_t)((ts).__opaque_fp))
/* Set fp field of arm_thread_state64_t to a data pointer value */
#define __darwin_arm_thread_state64_set_fp(ts, ptr) \
((ts).__opaque_fp = (void*)(uintptr_t)(ptr))
/* Strip ptr auth bits from pc, lr, sp and fp field of arm_thread_state64_t */
#define __darwin_arm_thread_state64_ptrauth_strip(ts) \
(void)(ts)
#else /* __DARWIN_OPAQUE_ARM_THREAD_STATE64 */
#if __DARWIN_UNIX03
/* Return pc field of arm_thread_state64_t as a data pointer value */
#define __darwin_arm_thread_state64_get_pc(ts) \
((ts).__pc)
/* Return pc field of arm_thread_state64_t as a function pointer */
#define __darwin_arm_thread_state64_get_pc_fptr(ts) \
((void*)(uintptr_t)((ts).__pc))
/* Set pc field of arm_thread_state64_t to a function pointer */
#define __darwin_arm_thread_state64_set_pc_fptr(ts, fptr) \
((ts).__pc = (uintptr_t)(fptr))
/* Return lr field of arm_thread_state64_t as a data pointer value */
#define __darwin_arm_thread_state64_get_lr(ts) \
((ts).__lr)
/* Return lr field of arm_thread_state64_t as a function pointer */
#define __darwin_arm_thread_state64_get_lr_fptr(ts) \
((void*)(uintptr_t)((ts).__lr))
/* Set lr field of arm_thread_state64_t to a function pointer */
#define __darwin_arm_thread_state64_set_lr_fptr(ts, fptr) \
((ts).__lr = (uintptr_t)(fptr))
/* Return sp field of arm_thread_state64_t as a data pointer value */
#define __darwin_arm_thread_state64_get_sp(ts) \
((ts).__sp)
/* Set sp field of arm_thread_state64_t to a data pointer value */
#define __darwin_arm_thread_state64_set_sp(ts, ptr) \
((ts).__sp = (uintptr_t)(ptr))
/* Return fp field of arm_thread_state64_t as a data pointer value */
#define __darwin_arm_thread_state64_get_fp(ts) \
((ts).__fp)
/* Set fp field of arm_thread_state64_t to a data pointer value */
#define __darwin_arm_thread_state64_set_fp(ts, ptr) \
((ts).__fp = (uintptr_t)(ptr))
/* Strip ptr auth bits from pc, lr, sp and fp field of arm_thread_state64_t */
#define __darwin_arm_thread_state64_ptrauth_strip(ts) \
(void)(ts)
#else /* __DARWIN_UNIX03 */
/* Return pc field of arm_thread_state64_t as a data pointer value */
#define __darwin_arm_thread_state64_get_pc(ts) \
((ts).pc)
/* Return pc field of arm_thread_state64_t as a function pointer */
#define __darwin_arm_thread_state64_get_pc_fptr(ts) \
((void*)(uintptr_t)((ts).pc))
/* Set pc field of arm_thread_state64_t to a function pointer */
#define __darwin_arm_thread_state64_set_pc_fptr(ts, fptr) \
((ts).pc = (uintptr_t)(fptr))
/* Return lr field of arm_thread_state64_t as a data pointer value */
#define __darwin_arm_thread_state64_get_lr(ts) \
((ts).lr)
/* Return lr field of arm_thread_state64_t as a function pointer */
#define __darwin_arm_thread_state64_get_lr_fptr(ts) \
((void*)(uintptr_t)((ts).lr))
/* Set lr field of arm_thread_state64_t to a function pointer */
#define __darwin_arm_thread_state64_set_lr_fptr(ts, fptr) \
((ts).lr = (uintptr_t)(fptr))
/* Return sp field of arm_thread_state64_t as a data pointer value */
#define __darwin_arm_thread_state64_get_sp(ts) \
((ts).sp)
/* Set sp field of arm_thread_state64_t to a data pointer value */
#define __darwin_arm_thread_state64_set_sp(ts, ptr) \
((ts).sp = (uintptr_t)(ptr))
/* Return fp field of arm_thread_state64_t as a data pointer value */
#define __darwin_arm_thread_state64_get_fp(ts) \
((ts).fp)
/* Set fp field of arm_thread_state64_t to a data pointer value */
#define __darwin_arm_thread_state64_set_fp(ts, ptr) \
((ts).fp = (uintptr_t)(ptr))
/* Strip ptr auth bits from pc, lr, sp and fp field of arm_thread_state64_t */
#define __darwin_arm_thread_state64_ptrauth_strip(ts) \
(void)(ts)
#endif /* __DARWIN_UNIX03 */
#endif /* __DARWIN_OPAQUE_ARM_THREAD_STATE64 */
#endif /* __has_feature(ptrauth_calls) && defined(__LP64__) */
#endif /* __DARWIN_C_LEVEL >= __DARWIN_C_FULL && defined(__arm64__) */
#if __DARWIN_UNIX03
#define _STRUCT_ARM_VFP_STATE struct __darwin_arm_vfp_state
_STRUCT_ARM_VFP_STATE
{
__uint32_t __r[64];
__uint32_t __fpscr;
};
#else /* !__DARWIN_UNIX03 */
#define _STRUCT_ARM_VFP_STATE struct arm_vfp_state
_STRUCT_ARM_VFP_STATE
{
__uint32_t r[64];
__uint32_t fpscr;
};
#endif /* __DARWIN_UNIX03 */
#if __DARWIN_UNIX03
#define _STRUCT_ARM_NEON_STATE64 struct __darwin_arm_neon_state64
#define _STRUCT_ARM_NEON_STATE struct __darwin_arm_neon_state
#if defined(__arm64__)
_STRUCT_ARM_NEON_STATE64
{
__uint128_t __v[32];
__uint32_t __fpsr;
__uint32_t __fpcr;
};
_STRUCT_ARM_NEON_STATE
{
__uint128_t __v[16];
__uint32_t __fpsr;
__uint32_t __fpcr;
};
#elif defined(__arm__)
/*
* No 128-bit intrinsic for ARM; leave it opaque for now.
*/
_STRUCT_ARM_NEON_STATE64
{
char opaque[(32 * 16) + (2 * sizeof(__uint32_t))];
} __attribute__((aligned(16)));
_STRUCT_ARM_NEON_STATE
{
char opaque[(16 * 16) + (2 * sizeof(__uint32_t))];
} __attribute__((aligned(16)));
#else
#error Unknown architecture.
#endif
#else /* !__DARWIN_UNIX03 */
#define _STRUCT_ARM_NEON_STATE64 struct arm_neon_state64
#define _STRUCT_ARM_NEON_STATE struct arm_neon_state
#if defined(__arm64__)
_STRUCT_ARM_NEON_STATE64
{
__uint128_t q[32];
uint32_t fpsr;
uint32_t fpcr;
};
_STRUCT_ARM_NEON_STATE
{
__uint128_t q[16];
uint32_t fpsr;
uint32_t fpcr;
};
#elif defined(__arm__)
/*
* No 128-bit intrinsic for ARM; leave it opaque for now.
*/
_STRUCT_ARM_NEON_STATE64
{
char opaque[(32 * 16) + (2 * sizeof(__uint32_t))];
} __attribute__((aligned(16)));
_STRUCT_ARM_NEON_STATE
{
char opaque[(16 * 16) + (2 * sizeof(__uint32_t))];
} __attribute__((aligned(16)));
#else
#error Unknown architecture.
#endif
#endif /* __DARWIN_UNIX03 */
#if __DARWIN_UNIX03
#define _STRUCT_ARM_AMX_STATE_V1 struct __darwin_arm_amx_state_v1
_STRUCT_ARM_AMX_STATE_V1
{
__uint8_t __x[8][64]; /* 8 64-byte registers */
__uint8_t __y[8][64]; /* 8 64-byte registers */
__uint8_t __z[64][64]; /* 64 64-byte registers in an M-by-N matrix */
__uint64_t __amx_state_t_el1; /* AMX_STATE_T_EL1 value */
} __attribute__((aligned(64)));
#else /* !__DARWIN_UNIX03 */
#define _STRUCT_ARM_AMX_STATE_V1 struct arm_amx_state_v1
_STRUCT_ARM_AMX_STATE_V1
{
__uint8_t x[8][64]; /* 8 64-byte registers */
__uint8_t y[8][64]; /* 8 64-byte registers */
__uint8_t z[64][64]; /* 64 64-byte registers in an M-by-N matrix */
__uint64_t amx_state_t_el1; /* AMX_STATE_T_EL1 value. */
} __attribute__((aligned(64)));
#endif /* __DARWIN_UNIX03 */
#define _STRUCT_ARM_PAGEIN_STATE struct __arm_pagein_state
_STRUCT_ARM_PAGEIN_STATE
{
int __pagein_error;
};
/*
* Debug State
*/
#if defined(__arm__)
/* Old-fashioned debug state is only for ARM */
#if __DARWIN_UNIX03
#define _STRUCT_ARM_DEBUG_STATE struct __darwin_arm_debug_state
_STRUCT_ARM_DEBUG_STATE
{
__uint32_t __bvr[16];
__uint32_t __bcr[16];
__uint32_t __wvr[16];
__uint32_t __wcr[16];
};
#else /* !__DARWIN_UNIX03 */
#define _STRUCT_ARM_DEBUG_STATE struct arm_debug_state
_STRUCT_ARM_DEBUG_STATE
{
__uint32_t bvr[16];
__uint32_t bcr[16];
__uint32_t wvr[16];
__uint32_t wcr[16];
};
#endif /* __DARWIN_UNIX03 */
#elif defined(__arm64__)
/* ARM's arm_debug_state is ARM64's arm_legacy_debug_state */
#if __DARWIN_UNIX03
#define _STRUCT_ARM_LEGACY_DEBUG_STATE struct __arm_legacy_debug_state
_STRUCT_ARM_LEGACY_DEBUG_STATE
{
__uint32_t __bvr[16];
__uint32_t __bcr[16];
__uint32_t __wvr[16];
__uint32_t __wcr[16];
};
#else /* __DARWIN_UNIX03 */
#define _STRUCT_ARM_LEGACY_DEBUG_STATE struct arm_legacy_debug_state
_STRUCT_ARM_LEGACY_DEBUG_STATE
{
__uint32_t bvr[16];
__uint32_t bcr[16];
__uint32_t wvr[16];
__uint32_t wcr[16];
};
#endif /* __DARWIN_UNIX03 */
#else
#error unknown architecture
#endif
#if __DARWIN_UNIX03
#define _STRUCT_ARM_DEBUG_STATE32 struct __darwin_arm_debug_state32
_STRUCT_ARM_DEBUG_STATE32
{
__uint32_t __bvr[16];
__uint32_t __bcr[16];
__uint32_t __wvr[16];
__uint32_t __wcr[16];
__uint64_t __mdscr_el1; /* Bit 0 is SS (Hardware Single Step) */
};
#define _STRUCT_ARM_DEBUG_STATE64 struct __darwin_arm_debug_state64
_STRUCT_ARM_DEBUG_STATE64
{
__uint64_t __bvr[16];
__uint64_t __bcr[16];
__uint64_t __wvr[16];
__uint64_t __wcr[16];
__uint64_t __mdscr_el1; /* Bit 0 is SS (Hardware Single Step) */
};
#else /* !__DARWIN_UNIX03 */
#define _STRUCT_ARM_DEBUG_STATE32 struct arm_debug_state32
_STRUCT_ARM_DEBUG_STATE32
{
__uint32_t bvr[16];
__uint32_t bcr[16];
__uint32_t wvr[16];
__uint32_t wcr[16];
__uint64_t mdscr_el1; /* Bit 0 is SS (Hardware Single Step) */
};
#define _STRUCT_ARM_DEBUG_STATE64 struct arm_debug_state64
_STRUCT_ARM_DEBUG_STATE64
{
__uint64_t bvr[16];
__uint64_t bcr[16];
__uint64_t wvr[16];
__uint64_t wcr[16];
__uint64_t mdscr_el1; /* Bit 0 is SS (Hardware Single Step) */
};
#endif /* __DARWIN_UNIX03 */
#if __DARWIN_UNIX03
#define _STRUCT_ARM_CPMU_STATE64 struct __darwin_arm_cpmu_state64
_STRUCT_ARM_CPMU_STATE64
{
__uint64_t __ctrs[16];
};
#else /* __DARWIN_UNIX03 */
#define _STRUCT_ARM_CPMU_STATE64 struct arm_cpmu_state64
_STRUCT_ARM_CPMU_STATE64
{
__uint64_t ctrs[16];
};
#endif /* !__DARWIN_UNIX03 */
#endif /* _MACH_ARM__STRUCTS_H_ */

View File

@ -0,0 +1,320 @@
/*
* Copyright (c) 2007 Apple Inc. All rights reserved.
*
* @APPLE_OSREFERENCE_LICENSE_HEADER_START@
*
* This file contains Original Code and/or Modifications of Original Code
* as defined in and that are subject to the Apple Public Source License
* Version 2.0 (the 'License'). You may not use this file except in
* compliance with the License. The rights granted to you under the License
* may not be used to create, or enable the creation or redistribution of,
* unlawful or unlicensed copies of an Apple operating system, or to
* circumvent, violate, or enable the circumvention or violation of, any
* terms of an Apple operating system software license agreement.
*
* Please obtain a copy of the License at
* http://www.opensource.apple.com/apsl/ and read it before using this file.
*
* The Original Code and all software distributed under the License are
* distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
* Please see the License for the specific language governing rights and
* limitations under the License.
*
* @APPLE_OSREFERENCE_LICENSE_HEADER_END@
*/
/*
* @OSF_COPYRIGHT@
*/
/*
* Mach Operating System
* Copyright (c) 1991,1990,1989 Carnegie Mellon University
* All Rights Reserved.
*
* Permission to use, copy, modify and distribute this software and its
* documentation is hereby granted, provided that both the copyright
* notice and this permission notice appear in all copies of the
* software, derivative works or modified versions, and any portions
* thereof, and that both notices appear in supporting documentation.
*
* CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
* CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR
* ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
*
* Carnegie Mellon requests users of this software to return to
*
* Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU
* School of Computer Science
* Carnegie Mellon University
* Pittsburgh PA 15213-3890
*
* any improvements or extensions that they make and grant Carnegie Mellon
* the rights to redistribute these changes.
*/
#ifndef _ARM_ASM_H_
#define _ARM_ASM_H_
#include <arm/arch.h>
#define FRAME pushl %ebp; movl %esp, %ebp
#define EMARF leave
/* There is another definition of ALIGN for .c sources */
#ifdef ASSEMBLER
#define ALIGN 2
#endif /* ASSEMBLER */
#ifndef FALIGN
#define FALIGN ALIGN
#endif
#define LB(x,n) n
#if __STDC__
#ifndef __NO_UNDERSCORES__
#define LCL(x) L ## x
#define EXT(x) _ ## x
#define LEXT(x) _ ## x ## :
#else
#define LCL(x) .L ## x
#define EXT(x) x
#define LEXT(x) x ## :
#endif
#define LBc(x,n) n ## :
#define LBb(x,n) n ## b
#define LBf(x,n) n ## f
#else /* __STDC__ */
#ifndef __NO_UNDERSCORES__
#define LCL(x) L/**/x
#define EXT(x) _/**/x
#define LEXT(x) _/**/x/**/:
#else /* __NO_UNDERSCORES__ */
#define LCL(x) .L/**/x
#define EXT(x) x
#define LEXT(x) x/**/:
#endif /* __NO_UNDERSCORES__ */
#define LBc(x,n) n/**/:
#define LBb(x,n) n/**/b
#define LBf(x,n) n/**/f
#endif /* __STDC__ */
#define String .asciz
#define Value .word
#define Times(a,b) (a*b)
#define Divide(a,b) (a/b)
#if 0 /* TOTOJK */
#ifdef __ELF__
#define ELF_FUNC(x) .type x,@function
#define ELF_DATA(x) .type x,@object
#define ELF_SIZE(x,s) .size x,s
#else
#define ELF_FUNC(x)
#define ELF_DATA(x)
#define ELF_SIZE(x,s)
#endif
#else
#define ELF_FUNC(x)
#define ELF_DATA(x)
#define ELF_SIZE(x,s)
#endif /* TODOJK */
#define Entry(x) .globl EXT(x); ELF_FUNC(EXT(x)); .align FALIGN; LEXT(x)
#define ENTRY(x) Entry(x) MCOUNT
#define ENTRY2(x,y) .globl EXT(x); .globl EXT(y); \
ELF_FUNC(EXT(x)); ELF_FUNC(EXT(y)); \
.align FALIGN; LEXT(x); LEXT(y) \
MCOUNT
#if __STDC__
#define ASENTRY(x) .globl x; .align FALIGN; x ## : ELF_FUNC(x) MCOUNT
#else
#define ASENTRY(x) .globl x; .align FALIGN; x: ELF_FUNC(x) MCOUNT
#endif /* __STDC__ */
#define DATA(x) .globl EXT(x); ELF_DATA(EXT(x)); .align ALIGN; LEXT(x)
#define End(x) ELF_SIZE(x,.-x)
#define END(x) End(EXT(x))
#define ENDDATA(x) END(x)
#define Enddata(x) End(x)
#ifdef ASSEMBLER
#define MCOUNT
#else /* NOT ASSEMBLER */
/* These defines are here for .c files that wish to reference global symbols
* within __asm__ statements.
*/
#ifndef __NO_UNDERSCORES__
#define CC_SYM_PREFIX "_"
#else
#define CC_SYM_PREFIX ""
#endif /* __NO_UNDERSCORES__ */
#endif /* ASSEMBLER */
#ifdef ASSEMBLER
#if defined (_ARM_ARCH_4T)
# define RET bx lr
# define RETeq bxeq lr
# define RETne bxne lr
# ifdef __STDC__
# define RETc(c) bx##c lr
# else
# define RETc(c) bx/**/c lr
# endif
#else
# define RET mov pc, lr
# define RETeq moveq pc, lr
# define RETne movne pc, lr
# ifdef __STDC__
# define RETc(c) mov##c pc, lr
# else
# define RETc(c) mov/**/c pc, lr
# endif
#endif
#if defined (__thumb__)
/* Provide a PI mechanism for thumb branching. */
# define BRANCH_EXTERN(x) ldr pc, [pc, #-4] ; \
.long EXT(x)
#else
# define BRANCH_EXTERN(x) b EXT(x)
#endif
/*
* arg0: Register for thread pointer
*/
.macro READ_THREAD
mrc p15, 0, $0, c13, c0, 4 /* Read TPIDRPRW */
.endmacro
/* Macros for loading up addresses that are external to the .s file.
* LOAD_ADDR: loads the address for (label) into (reg). Not safe for
* loading to the PC.
* LOAD_ADDR_PC: Variant for loading to the PC; load the address of (label)
* into the pc.
* LOAD_ADDR_GEN_DEF: The general definition needed to support loading
* a label address.
*
* Usage: For any label accessed, we require one (and only one) instance
* of LOAD_ADDR_GEN_DEF(label).
*
* Example:
* LOAD_ADDR(r0, arm_init)
* LOAD_ADDR(lr, arm_init_cpu)
* LOAD_ADDR_PC(arm_init)
* ...
*
* LOAD_ADDR_GEN_DEF(arm_init)
* LOAD_ADDR_GEN_DEF(arm_init_cpu)
*/
#if SLIDABLE
/* Definitions for a position dependent kernel using non-lazy pointers.
*/
/* TODO: Make this work with thumb .s files. */
#define PC_INC 0x8
/* We need wrapper macros in order to ensure that __LINE__ is expanded.
*
* There is some small potential for duplicate labels here, but because
* we do not export the generated labels, it should not be an issue.
*/
#define GLUE_LABEL_GUTS(label, tag) L_##label##_##tag##_glue
#define GLUE_LABEL(label, tag) GLUE_LABEL_GUTS(label, tag)
#define LOAD_ADDR(reg, label) \
movw reg, :lower16:(label##$non_lazy_ptr - (GLUE_LABEL(label, __LINE__) + PC_INC)) ; \
movt reg, :upper16:(label##$non_lazy_ptr - (GLUE_LABEL(label, __LINE__) + PC_INC)) ; \
GLUE_LABEL(label, __LINE__): ; \
ldr reg, [pc, reg]
/* Designed with the understanding that directly branching to thumb code
* is unreliable; this should allow for dealing with __thumb__ in
* assembly; the non-thumb variant still needs to provide the glue label
* to avoid failing to build on undefined symbols.
*
* TODO: Make this actually use a scratch register; this macro is convenient
* for translating (ldr pc, [?]) to a slidable format without the risk of
* clobbering registers, but it is also wasteful.
*/
#if defined(__thumb__)
#define LOAD_ADDR_PC(label) \
stmfd sp!, { r0 } ; \
stmfd sp!, { r0 } ; \
LOAD_ADDR(r0, label) ; \
str r0, [sp, #4] ; \
ldmfd sp!, { r0 } ; \
ldmfd sp!, { pc }
#else
#define LOAD_ADDR_PC(label) \
b EXT(label)
#endif
#define LOAD_ADDR_GEN_DEF(label) \
.section __DATA,__nl_symbol_ptr,non_lazy_symbol_pointers ; \
.align 2 ; \
label##$non_lazy_ptr: ; \
.indirect_symbol EXT(label) ; \
.long 0
#else /* !SLIDABLE */
/* Definitions for a position dependent kernel */
#define LOAD_ADDR(reg, label) \
ldr reg, L_##label
#if defined(__thumb__)
#define LOAD_ADDR_PC(label) \
ldr pc, L_##label
#else
#define LOAD_ADDR_PC(label) \
b EXT(label)
#endif
#define LOAD_ADDR_GEN_DEF(label) \
.text ; \
.align 2 ; \
L_##label: ; \
.long EXT(label)
#endif /* SLIDABLE */
/* The linker can deal with branching from ARM to thumb in unconditional
* branches, but not in conditional branches. To support this in our
* assembly (which allows us to build xnu without -mno-thumb), use the
* following macros for branching conditionally to external symbols.
* These macros are used just like the corresponding conditional branch
* instructions.
*/
#define SHIM_LABEL_GUTS(line_num) L_cond_extern_##line_num##_shim
#define SHIM_LABEL(line_num) SHIM_LABEL_GUTS(line_num)
#define COND_EXTERN_BEQ(label) \
bne SHIM_LABEL(__LINE__) ; \
b EXT(label) ; \
SHIM_LABEL(__LINE__):
#define COND_EXTERN_BLNE(label) \
beq SHIM_LABEL(__LINE__) ; \
bl EXT(label) ; \
SHIM_LABEL(__LINE__):
#define COND_EXTERN_BLGT(label) \
ble SHIM_LABEL(__LINE__) ; \
bl EXT(label) ; \
SHIM_LABEL(__LINE__):
#endif /* ASSEMBLER */
#endif /* _ARM_ASM_H_ */

View File

@ -0,0 +1,70 @@
/*
* Copyright (c) 2000-2007 Apple Inc. All rights reserved.
*
* @APPLE_OSREFERENCE_LICENSE_HEADER_START@
*
* This file contains Original Code and/or Modifications of Original Code
* as defined in and that are subject to the Apple Public Source License
* Version 2.0 (the 'License'). You may not use this file except in
* compliance with the License. The rights granted to you under the License
* may not be used to create, or enable the creation or redistribution of,
* unlawful or unlicensed copies of an Apple operating system, or to
* circumvent, violate, or enable the circumvention or violation of, any
* terms of an Apple operating system software license agreement.
*
* Please obtain a copy of the License at
* http://www.opensource.apple.com/apsl/ and read it before using this file.
*
* The Original Code and all software distributed under the License are
* distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
* Please see the License for the specific language governing rights and
* limitations under the License.
*
* @APPLE_OSREFERENCE_LICENSE_HEADER_END@
*/
/*
* @OSF_COPYRIGHT@
*/
/*
* Mach Operating System
* Copyright (c) 1991,1990,1989 Carnegie Mellon University
* All Rights Reserved.
*
* Permission to use, copy, modify and distribute this software and its
* documentation is hereby granted, provided that both the copyright
* notice and this permission notice appear in all copies of the
* software, derivative works or modified versions, and any portions
* thereof, and that both notices appear in supporting documentation.
*
* CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
* CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR
* ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
*
* Carnegie Mellon requests users of this software to return to
*
* Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU
* School of Computer Science
* Carnegie Mellon University
* Pittsburgh PA 15213-3890
*
* any improvements or extensions that they make and grant Carnegie Mellon
* the rights to redistribute these changes.
*/
/*
*/
/*
* File: boolean.h
*
* Boolean type, for ARM.
*/
#ifndef _MACH_ARM_BOOLEAN_H_
#define _MACH_ARM_BOOLEAN_H_
typedef int boolean_t;
#endif /* _MACH_ARM_BOOLEAN_H_ */

View File

@ -0,0 +1,79 @@
/*
* Copyright (c) 2007 Apple Inc. All rights reserved.
*
* @APPLE_OSREFERENCE_LICENSE_HEADER_START@
*
* This file contains Original Code and/or Modifications of Original Code
* as defined in and that are subject to the Apple Public Source License
* Version 2.0 (the 'License'). You may not use this file except in
* compliance with the License. The rights granted to you under the License
* may not be used to create, or enable the creation or redistribution of,
* unlawful or unlicensed copies of an Apple operating system, or to
* circumvent, violate, or enable the circumvention or violation of, any
* terms of an Apple operating system software license agreement.
*
* Please obtain a copy of the License at
* http://www.opensource.apple.com/apsl/ and read it before using this file.
*
* The Original Code and all software distributed under the License are
* distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
* Please see the License for the specific language governing rights and
* limitations under the License.
*
* @APPLE_OSREFERENCE_LICENSE_HEADER_END@
*/
#ifndef _MACH_ARM_EXCEPTION_H_
#define _MACH_ARM_EXCEPTION_H_
#define EXC_TYPES_COUNT 14 /* incl. illegal exception 0 */
#define EXC_MASK_MACHINE 0
#define EXCEPTION_CODE_MAX 2 /* code and subcode */
/*
* Trap numbers as defined by the hardware exception vectors.
*/
/*
* EXC_BAD_INSTRUCTION
*/
#define EXC_ARM_UNDEFINED 1 /* Undefined */
/*
* EXC_ARITHMETIC
*/
#define EXC_ARM_FP_UNDEFINED 0 /* Undefined Floating Point Exception */
#define EXC_ARM_FP_IO 1 /* Invalid Floating Point Operation */
#define EXC_ARM_FP_DZ 2 /* Floating Point Divide by Zero */
#define EXC_ARM_FP_OF 3 /* Floating Point Overflow */
#define EXC_ARM_FP_UF 4 /* Floating Point Underflow */
#define EXC_ARM_FP_IX 5 /* Inexact Floating Point Result */
#define EXC_ARM_FP_ID 6 /* Floating Point Denormal Input */
/*
* EXC_BAD_ACCESS
* Note: do not conflict with kern_return_t values returned by vm_fault
*/
#define EXC_ARM_DA_ALIGN 0x101 /* Alignment Fault */
#define EXC_ARM_DA_DEBUG 0x102 /* Debug (watch/break) Fault */
#define EXC_ARM_SP_ALIGN 0x103 /* SP Alignment Fault */
#define EXC_ARM_SWP 0x104 /* SWP instruction */
#define EXC_ARM_PAC_FAIL 0x105 /* PAC authentication failure */
/*
* EXC_BREAKPOINT
*/
#define EXC_ARM_BREAKPOINT 1 /* breakpoint trap */
#endif /* _MACH_ARM_EXCEPTION_H_ */

View File

@ -0,0 +1,74 @@
/*
* Copyright (c) 2000-2007 Apple Inc. All rights reserved.
*
* @APPLE_OSREFERENCE_LICENSE_HEADER_START@
*
* This file contains Original Code and/or Modifications of Original Code
* as defined in and that are subject to the Apple Public Source License
* Version 2.0 (the 'License'). You may not use this file except in
* compliance with the License. The rights granted to you under the License
* may not be used to create, or enable the creation or redistribution of,
* unlawful or unlicensed copies of an Apple operating system, or to
* circumvent, violate, or enable the circumvention or violation of, any
* terms of an Apple operating system software license agreement.
*
* Please obtain a copy of the License at
* http://www.opensource.apple.com/apsl/ and read it before using this file.
*
* The Original Code and all software distributed under the License are
* distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
* Please see the License for the specific language governing rights and
* limitations under the License.
*
* @APPLE_OSREFERENCE_LICENSE_HEADER_END@
*/
/*
* @OSF_COPYRIGHT@
*/
/*
* Mach Operating System
* Copyright (c) 1991,1990,1989 Carnegie Mellon University
* All Rights Reserved.
*
* Permission to use, copy, modify and distribute this software and its
* documentation is hereby granted, provided that both the copyright
* notice and this permission notice appear in all copies of the
* software, derivative works or modified versions, and any portions
* thereof, and that both notices appear in supporting documentation.
*
* CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
* CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR
* ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
*
* Carnegie Mellon requests users of this software to return to
*
* Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU
* School of Computer Science
* Carnegie Mellon University
* Pittsburgh PA 15213-3890
*
* any improvements or extensions that they make and grant Carnegie Mellon
* the rights to redistribute these changes.
*/
/*
*/
/*
* File: kern_return.h
* Author: Avadis Tevanian, Jr., Michael Wayne Young
* Date: 1985
*
* Machine-dependent kernel return definitions.
*/
#ifndef _MACH_ARM_KERN_RETURN_H_
#define _MACH_ARM_KERN_RETURN_H_
#ifndef ASSEMBLER
typedef int kern_return_t;
#endif /* ASSEMBLER */
#endif /* _MACH_ARM_KERN_RETURN_H_ */

View File

@ -0,0 +1,45 @@
/*
* Copyright (c) 2000-2007 Apple Inc. All rights reserved.
*
* @APPLE_OSREFERENCE_LICENSE_HEADER_START@
*
* This file contains Original Code and/or Modifications of Original Code
* as defined in and that are subject to the Apple Public Source License
* Version 2.0 (the 'License'). You may not use this file except in
* compliance with the License. The rights granted to you under the License
* may not be used to create, or enable the creation or redistribution of,
* unlawful or unlicensed copies of an Apple operating system, or to
* circumvent, violate, or enable the circumvention or violation of, any
* terms of an Apple operating system software license agreement.
*
* Please obtain a copy of the License at
* http://www.opensource.apple.com/apsl/ and read it before using this file.
*
* The Original Code and all software distributed under the License are
* distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
* Please see the License for the specific language governing rights and
* limitations under the License.
*
* @APPLE_OSREFERENCE_LICENSE_HEADER_END@
*/
/*
* @OSF_COPYRIGHT@
*/
/* NDR record for Intel x86s */
#include <mach/ndr.h>
NDR_record_t NDR_record = {
0, /* mig_reserved */
0, /* mig_reserved */
0, /* mig_reserved */
NDR_PROTOCOL_2_0,
NDR_INT_LITTLE_ENDIAN,
NDR_CHAR_ASCII,
NDR_FLOAT_IEEE,
0,
};

View File

@ -0,0 +1,72 @@
/*
* Copyright (c) 2007-2018 Apple Inc. All rights reserved.
*
* @APPLE_OSREFERENCE_LICENSE_HEADER_START@
*
* This file contains Original Code and/or Modifications of Original Code
* as defined in and that are subject to the Apple Public Source License
* Version 2.0 (the 'License'). You may not use this file except in
* compliance with the License. The rights granted to you under the License
* may not be used to create, or enable the creation or redistribution of,
* unlawful or unlicensed copies of an Apple operating system, or to
* circumvent, violate, or enable the circumvention or violation of, any
* terms of an Apple operating system software license agreement.
*
* Please obtain a copy of the License at
* http://www.opensource.apple.com/apsl/ and read it before using this file.
*
* The Original Code and all software distributed under the License are
* distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
* Please see the License for the specific language governing rights and
* limitations under the License.
*
* @APPLE_OSREFERENCE_LICENSE_HEADER_END@
*/
#ifndef _MACH_ARM_PROCESSOR_INFO_H_
#define _MACH_ARM_PROCESSOR_INFO_H_
#define PROCESSOR_CPU_STAT 0x10000003 /* Low-level CPU statistics */
#define PROCESSOR_CPU_STAT64 0x10000004 /* Low-level CPU statistics, in full 64-bit */
#include <stdint.h> /* uint32_t, uint64_t */
struct processor_cpu_stat {
uint32_t irq_ex_cnt;
uint32_t ipi_cnt;
uint32_t timer_cnt;
uint32_t undef_ex_cnt;
uint32_t unaligned_cnt;
uint32_t vfp_cnt;
uint32_t vfp_shortv_cnt;
uint32_t data_ex_cnt;
uint32_t instr_ex_cnt;
};
typedef struct processor_cpu_stat processor_cpu_stat_data_t;
typedef struct processor_cpu_stat *processor_cpu_stat_t;
#define PROCESSOR_CPU_STAT_COUNT ((mach_msg_type_number_t) \
(sizeof(processor_cpu_stat_data_t) / sizeof(natural_t)))
struct processor_cpu_stat64 {
uint64_t irq_ex_cnt;
uint64_t ipi_cnt;
uint64_t timer_cnt;
uint64_t undef_ex_cnt;
uint64_t unaligned_cnt;
uint64_t vfp_cnt;
uint64_t vfp_shortv_cnt;
uint64_t data_ex_cnt;
uint64_t instr_ex_cnt;
uint64_t pmi_cnt;
} __attribute__((packed, aligned(4)));
typedef struct processor_cpu_stat64 processor_cpu_stat64_data_t;
typedef struct processor_cpu_stat64 *processor_cpu_stat64_t;
#define PROCESSOR_CPU_STAT64_COUNT ((mach_msg_type_number_t) \
(sizeof(processor_cpu_stat64_data_t) / sizeof(integer_t)))
#endif /* _MACH_ARM_PROCESSOR_INFO_H_ */

View File

@ -0,0 +1,35 @@
/*
* Copyright (c) 2000-2007 Apple Inc. All rights reserved.
*
* @APPLE_OSREFERENCE_LICENSE_HEADER_START@
*
* This file contains Original Code and/or Modifications of Original Code
* as defined in and that are subject to the Apple Public Source License
* Version 2.0 (the 'License'). You may not use this file except in
* compliance with the License. The rights granted to you under the License
* may not be used to create, or enable the creation or redistribution of,
* unlawful or unlicensed copies of an Apple operating system, or to
* circumvent, violate, or enable the circumvention or violation of, any
* terms of an Apple operating system software license agreement.
*
* Please obtain a copy of the License at
* http://www.opensource.apple.com/apsl/ and read it before using this file.
*
* The Original Code and all software distributed under the License are
* distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
* Please see the License for the specific language governing rights and
* limitations under the License.
*
* @APPLE_OSREFERENCE_LICENSE_HEADER_END@
*/
/*
* @OSF_COPYRIGHT@
*/
#ifndef _MACH_ARM_RPC_H_
#define _MACH_ARM_RPC_H_
#endif /* _MACH_ARM_RPC_H_ */

View File

@ -0,0 +1,411 @@
/*
* Copyright (c) 2007 Apple Inc. All rights reserved.
*/
/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License, Version 1.0 only
* (the "License"). You may not use this file except in compliance
* with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* or http://www.opensolaris.org/os/licensing.
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*/
/*
* Copyright 2004 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#ifndef _MACH_ARM_SDT_ISA_H
#define _MACH_ARM_SDT_ISA_H
/*
* Only define when testing. This makes the calls into actual calls to
* test functions.
*/
/* #define DTRACE_CALL_TEST */
#define DTRACE_STRINGIFY(s) #s
#define DTRACE_TOSTRING(s) DTRACE_STRINGIFY(s)
#define DTRACE_LABEL(p, n) \
"__dtrace_probe$" DTRACE_TOSTRING(%=__LINE__) DTRACE_STRINGIFY(_##p##___##n) ":" "\n\t"
#ifdef DTRACE_CALL_TEST
#define DTRACE_CALL(p, n) \
DTRACE_LABEL(p,n) \
DTRACE_CALL_INSN(p,n)
#else /* !DTRACE_CALL_TEST */
#define DTRACE_CALL(p, n) \
DTRACE_LABEL(p,n) \
DTRACE_NOPS
#endif /* !DTRACE_CALL_TEST */
#if defined(__arm__)
#define DTRACE_NOPS \
"nop" "\n\t"
#define DTRACE_CALL_INSN(p, n) \
"blx _dtracetest" DTRACE_STRINGIFY(_##p##_##n) "\n\t"
#ifdef __thumb__
#define DTRACE_ALLOC_STACK(n) \
"sub sp, #" #n "\n\t"
#define DTRACE_DEALLOC_STACK(n) \
"add sp, #" #n "\n\t"
#else
#define DTRACE_ALLOC_STACK(n) \
"sub sp, sp, #" #n "\n\t"
#define DTRACE_DEALLOC_STACK(n) \
"add sp, sp, #" #n "\n\t"
#endif
#define ARG1_EXTENT 1
#define ARGS2_EXTENT 2
#define ARGS3_EXTENT 3
#define ARGS4_EXTENT 4
#define ARGS5_EXTENT 5
#define ARGS6_EXTENT 6
#define ARGS7_EXTENT 7
#define ARGS8_EXTENT 8
#define ARGS9_EXTENT 9
#define ARGS10_EXTENT 10
#define DTRACE_CALL0ARGS(provider, name) \
asm volatile ( \
DTRACE_CALL(provider, name) \
"# eat trailing nl+tab from DTRACE_CALL" \
: \
: \
);
#define DTRACE_CALL1ARG(provider, name) \
asm volatile ("ldr r0, [%0]" "\n\t" \
DTRACE_CALL(provider, name) \
: \
: "l" (__dtrace_args) \
: "memory", "r0" \
);
#define DTRACE_CALL2ARGS(provider, name) \
asm volatile ("ldr r1, [%0, #4]" "\n\t" \
"ldr r0, [%0]" "\n\t" \
DTRACE_CALL(provider, name) \
: \
: "l" (__dtrace_args) \
: "memory", "r0", "r1" \
);
#define DTRACE_CALL3ARGS(provider, name) \
asm volatile ("ldr r2, [%0, #8]" "\n\t" \
"ldr r1, [%0, #4]" "\n\t" \
"ldr r0, [%0]" "\n\t" \
DTRACE_CALL(provider, name) \
: \
: "l" (__dtrace_args) \
: "memory", "r0", "r1", "r2" \
);
#define DTRACE_CALL4ARGS(provider, name) \
asm volatile ("ldr r3, [%0, #12]" "\n\t" \
"ldr r2, [%0, #8]" "\n\t" \
"ldr r1, [%0, #4]" "\n\t" \
"ldr r0, [%0]" "\n\t" \
DTRACE_CALL(provider, name) \
: \
: "l" (__dtrace_args) \
: "memory", "r0", "r1", "r2", "r3" \
);
/*
* One of our ARM32 ABIs (armv7k) mandates that the stack be aligned to 16 bytes.
* We currently apply this constraint to all ARM32 DTRACE_CALL macros; hence the
* macros below will overallocate for some ABIs.
*/
#define DTRACE_CALL5ARGS(provider, name) \
asm volatile ( \
DTRACE_ALLOC_STACK(16) \
"ldr r0, [%0, #16]" "\n\t" \
"str r0, [sp]" "\n\t" \
"ldr r3, [%0, #12]" "\n\t" \
"ldr r2, [%0, #8]" "\n\t" \
"ldr r1, [%0, #4]" "\n\t" \
"ldr r0, [%0]" "\n\t" \
DTRACE_CALL(provider, name) \
DTRACE_DEALLOC_STACK(16) \
: \
: "l" (__dtrace_args) \
: "memory", "r0", "r1", "r2", "r3" \
);
#define DTRACE_CALL6ARGS(provider, name) \
asm volatile ( \
DTRACE_ALLOC_STACK(16) \
"ldr r1, [%0, #20]" "\n\t" \
"ldr r0, [%0, #16]" "\n\t" \
"str r1, [sp, #4]" "\n\t" \
"str r0, [sp]" "\n\t" \
"ldr r3, [%0, #12]" "\n\t" \
"ldr r2, [%0, #8]" "\n\t" \
"ldr r1, [%0, #4]" "\n\t" \
"ldr r0, [%0]" "\n\t" \
DTRACE_CALL(provider, name) \
DTRACE_DEALLOC_STACK(16) \
: \
: "l" (__dtrace_args) \
: "memory", "r0", "r1", "r2", "r3" \
);
#define DTRACE_CALL7ARGS(provider, name) \
asm volatile ( \
DTRACE_ALLOC_STACK(16) \
"ldr r2, [%0, #24]" "\n\t" \
"ldr r1, [%0, #20]" "\n\t" \
"ldr r0, [%0, #16]" "\n\t" \
"str r2, [sp, #8]" "\n\t" \
"str r1, [sp, #4]" "\n\t" \
"str r0, [sp]" "\n\t" \
"ldr r3, [%0, #12]" "\n\t" \
"ldr r2, [%0, #8]" "\n\t" \
"ldr r1, [%0, #4]" "\n\t" \
"ldr r0, [%0]" "\n\t" \
DTRACE_CALL(provider, name) \
DTRACE_DEALLOC_STACK(16) \
: \
: "l" (__dtrace_args) \
: "memory", "r0", "r1", "r2", "r3" \
);
#define DTRACE_CALL8ARGS(provider, name) \
asm volatile ( \
DTRACE_ALLOC_STACK(16) \
"ldr r3, [%0, #28]" "\n\t" \
"ldr r2, [%0, #24]" "\n\t" \
"ldr r1, [%0, #20]" "\n\t" \
"ldr r0, [%0, #16]" "\n\t" \
"str r3, [sp, #12]" "\n\t" \
"str r2, [sp, #8]" "\n\t" \
"str r1, [sp, #4]" "\n\t" \
"str r0, [sp]" "\n\t" \
"ldr r3, [%0, #12]" "\n\t" \
"ldr r2, [%0, #8]" "\n\t" \
"ldr r1, [%0, #4]" "\n\t" \
"ldr r0, [%0]" "\n\t" \
DTRACE_CALL(provider, name) \
DTRACE_DEALLOC_STACK(16) \
: \
: "l" (__dtrace_args) \
: "memory", "r0", "r1", "r2", "r3" \
);
#define DTRACE_CALL9ARGS(provider, name) \
asm volatile ( \
DTRACE_ALLOC_STACK(32) \
"ldr r0, [%0, #32]" "\n\t" \
"str r0, [sp, #16]" "\n\t" \
"ldr r3, [%0, #28]" "\n\t" \
"ldr r2, [%0, #24]" "\n\t" \
"ldr r1, [%0, #20]" "\n\t" \
"ldr r0, [%0, #16]" "\n\t" \
"str r3, [sp, #12]" "\n\t" \
"str r2, [sp, #8]" "\n\t" \
"str r1, [sp, #4]" "\n\t" \
"str r0, [sp]" "\n\t" \
"ldr r3, [%0, #12]" "\n\t" \
"ldr r2, [%0, #8]" "\n\t" \
"ldr r1, [%0, #4]" "\n\t" \
"ldr r0, [%0]" "\n\t" \
DTRACE_CALL(provider, name) \
DTRACE_DEALLOC_STACK(32) \
: \
: "l" (__dtrace_args) \
: "memory", "r0", "r1", "r2", "r3" \
);
#define DTRACE_CALL10ARGS(provider, name) \
asm volatile ( \
DTRACE_ALLOC_STACK(32) \
"ldr r1, [%0, #36]" "\n\t" \
"ldr r0, [%0, #32]" "\n\t" \
"str r1, [sp, #20]" "\n\t" \
"str r0, [sp, #16]" "\n\t" \
"ldr r3, [%0, #28]" "\n\t" \
"ldr r2, [%0, #24]" "\n\t" \
"ldr r1, [%0, #20]" "\n\t" \
"ldr r0, [%0, #16]" "\n\t" \
"str r3, [sp, #12]" "\n\t" \
"str r2, [sp, #8]" "\n\t" \
"str r1, [sp, #4]" "\n\t" \
"str r0, [sp]" "\n\t" \
"ldr r3, [%0, #12]" "\n\t" \
"ldr r2, [%0, #8]" "\n\t" \
"ldr r1, [%0, #4]" "\n\t" \
"ldr r0, [%0]" "\n\t" \
DTRACE_CALL(provider, name) \
DTRACE_DEALLOC_STACK(32) \
: \
: "l" (__dtrace_args) \
: "memory", "r0", "r1", "r2", "r3" \
);
#elif defined(__arm64__)
#define DTRACE_NOPS \
"nop" "\n\t"
#define DTRACE_CALL_INSN(p, n) \
"bl _dtracetest" DTRACE_STRINGIFY(_##p##_##n) "\n\t"
#define DTRACE_ALLOC_STACK(n) \
"sub sp, sp, #" #n "\n\t"
#define DTRACE_DEALLOC_STACK(n) \
"add sp, sp, #" #n "\n\t"
#define ARG1_EXTENT 1
#define ARGS2_EXTENT 2
#define ARGS3_EXTENT 3
#define ARGS4_EXTENT 4
#define ARGS5_EXTENT 5
#define ARGS6_EXTENT 6
#define ARGS7_EXTENT 7
#define ARGS8_EXTENT 8
#define ARGS9_EXTENT 9
#define ARGS10_EXTENT 10
#define DTRACE_CALL0ARGS(provider, name) \
asm volatile ( \
DTRACE_CALL(provider, name) \
"# eat trailing nl+tab from DTRACE_CALL" \
: \
: \
);
#define DTRACE_CALL1ARG(provider, name) \
asm volatile ("ldr x0, [%0]" "\n\t" \
DTRACE_CALL(provider, name) \
: \
: "r" (__dtrace_args) \
: "memory", "x0" \
);
#define DTRACE_CALL2ARGS(provider, name) \
asm volatile ("ldp x0, x1, [%0]" "\n\t" \
DTRACE_CALL(provider, name) \
: \
: "r" (__dtrace_args) \
: "memory", "x0", "x1" \
);
#define DTRACE_CALL3ARGS(provider, name) \
asm volatile ("ldr x2, [%0, #16]" "\n\t" \
"ldp x0, x1, [%0]" "\n\t" \
DTRACE_CALL(provider, name) \
: \
: "r" (__dtrace_args) \
: "memory", "x0", "x1", "x2" \
);
#define DTRACE_CALL4ARGS(provider, name) \
asm volatile ("ldp x2, x3, [%0, #16]" "\n\t" \
"ldp x0, x1, [%0]" "\n\t" \
DTRACE_CALL(provider, name) \
: \
: "r" (__dtrace_args) \
: "memory", "x0", "x1", "x2", "x3" \
);
#define DTRACE_CALL5ARGS(provider, name) \
asm volatile ("ldr x4, [%0, #32]" "\n\t" \
"ldp x2, x3, [%0, #16]" "\n\t" \
"ldp x0, x1, [%0]" "\n\t" \
DTRACE_CALL(provider, name) \
: \
: "r" (__dtrace_args) \
: "memory", "x0", "x1", "x2", "x3", "x4" \
);
#define DTRACE_CALL6ARGS(provider, name) \
asm volatile ("ldp x4, x5, [%0, #32]" "\n\t" \
"ldp x2, x3, [%0, #16]" "\n\t" \
"ldp x0, x1, [%0]" "\n\t" \
DTRACE_CALL(provider, name) \
: \
: "r" (__dtrace_args) \
: "memory", "x0", "x1", "x2", "x3", "x4", "x5" \
);
#define DTRACE_CALL7ARGS(provider, name) \
asm volatile ("ldr x6, [%0, #48]" "\n\t" \
"ldp x4, x5, [%0, #32]" "\n\t" \
"ldp x2, x3, [%0, #16]" "\n\t" \
"ldp x0, x1, [%0]" "\n\t" \
DTRACE_CALL(provider, name) \
: \
: "r" (__dtrace_args) \
: "memory", "x0", "x1", "x2", "x3", "x4", "x5", "x6" \
);
#define DTRACE_CALL8ARGS(provider, name) \
asm volatile ("ldp x6, x7, [%0, #48]" "\n\t" \
"ldp x4, x5, [%0, #32]" "\n\t" \
"ldp x2, x3, [%0, #16]" "\n\t" \
"ldp x0, x1, [%0]" "\n\t" \
DTRACE_CALL(provider, name) \
: \
: "r" (__dtrace_args) \
: "memory", "x0", "x1", "x2", "x3", "x4", "x5", "x6", "x7" \
);
/* Keep stack 16 byte aligned per ABI requirements */
#define DTRACE_CALL9ARGS(provider, name) \
asm volatile ( \
DTRACE_ALLOC_STACK(16) \
"ldr x0, [%0, #64]" "\n\t" \
"str x0, [sp]" "\n\t" \
"ldp x6, x7, [%0, #48]" "\n\t" \
"ldp x4, x5, [%0, #32]" "\n\t" \
"ldp x2, x3, [%0, #16]" "\n\t" \
"ldp x0, x1, [%0]" "\n\t" \
DTRACE_CALL(provider, name) \
DTRACE_DEALLOC_STACK(16) \
: \
: "r" (__dtrace_args) \
: "memory", "x0", "x1", "x2", "x3", "x4", "x5", "x6", "x7" \
);
#define DTRACE_CALL10ARGS(provider, name) \
asm volatile ( \
DTRACE_ALLOC_STACK(16) \
"ldp x0, x1, [%0, #64]" "\n\t" \
"stp x0, x1, [sp]" "\n\t" \
"ldp x6, x7, [%0, #48]" "\n\t" \
"ldp x4, x5, [%0, #32]" "\n\t" \
"ldp x2, x3, [%0, #16]" "\n\t" \
"ldp x0, x1, [%0]" "\n\t" \
DTRACE_CALL(provider, name) \
DTRACE_DEALLOC_STACK(16) \
: \
: "r" (__dtrace_args) \
: "memory", "x0", "x1", "x2", "x3", "x4", "x5", "x6", "x7" \
);
#endif /* __arm__ */
#endif /* _MACH_ARM_SDT_ISA_H */

View File

@ -0,0 +1,123 @@
/*
* Copyright (c) 2007 Apple Inc. All rights reserved.
*
* @APPLE_OSREFERENCE_LICENSE_HEADER_START@
*
* This file contains Original Code and/or Modifications of Original Code
* as defined in and that are subject to the Apple Public Source License
* Version 2.0 (the 'License'). You may not use this file except in
* compliance with the License. The rights granted to you under the License
* may not be used to create, or enable the creation or redistribution of,
* unlawful or unlicensed copies of an Apple operating system, or to
* circumvent, violate, or enable the circumvention or violation of, any
* terms of an Apple operating system software license agreement.
*
* Please obtain a copy of the License at
* http://www.opensource.apple.com/apsl/ and read it before using this file.
*
* The Original Code and all software distributed under the License are
* distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
* Please see the License for the specific language governing rights and
* limitations under the License.
*
* @APPLE_OSREFERENCE_LICENSE_HEADER_END@
*/
/*
* FILE_ID: syscall_sw.h
*/
#ifndef _MACH_ARM_SYSCALL_SW_H_
#define _MACH_ARM_SYSCALL_SW_H_
#if defined(__arm__)
#include <mach/machine/vm_param.h>
#include <architecture/arm/asm_help.h>
/* 0 to 4 args are already loaded in r0-r3 */
#define _kernel_trap_0to4(trap_name, trap_number) \
mov r12, # ## trap_number /* load syscall number */ ; \
swi #SWI_SYSCALL ; \
bx lr /* return */ ;
#define _kernel_trap_5(trap_name, trap_number) \
mov ip, sp /* save pointer to args */ ; \
stmfd sp!, { r4-r5 } /* save r4-r5, keep stack 64-bit aligned */; \
ldr r4, [ ip ] /* load arg 5 */ ; \
mov r12, # ## trap_number /* load syscall number */ ; \
swi #SWI_SYSCALL ; \
ldmfd sp!, { r4-r5 } /* restore r4-r5 */ ;\
bx lr /* return */ ;
#define _kernel_trap_6to9(trap_name, trap_number, save_regs, arg_regs) \
mov ip, sp /* save pointer to args */ ; \
stmfd sp!, { save_regs } /* callee saved regs */; \
ldmia ip, { arg_regs } /* load arg registers (above r0-r3) */ ;\
mov r12, # ## trap_number /* load syscall number */ ; \
swi #SWI_SYSCALL ; \
ldmfd sp!, { save_regs } /* restore callee saved regs */ ;\
bx lr /* return */ ;
#define COMMA ,
/* For the armv7k ABI, the alignment requirements may add padding. So we
* let the kernel figure it out and push extra on the stack to avoid un-needed
* copy-ins. We are relying on arguments that aren't in registers starting
* 32 bytes from sp. */
#if __BIGGEST_ALIGNMENT__ > 4
#define _kernel_trap_0(trap_name, trap_number) _kernel_trap_0to4(trap_name, trap_number)
#define _kernel_trap_1(trap_name, trap_number) _kernel_trap_0to4(trap_name, trap_number)
#define _kernel_trap_2(trap_name, trap_number) _kernel_trap_0to4(trap_name, trap_number)
#define _kernel_trap_3(trap_name, trap_number) _kernel_trap_0to4(trap_name, trap_number)
#define _kernel_trap_4(trap_name, trap_number) _kernel_trap_6to9(trap_name, trap_number, r4-r5, r4-r5)
#undef _kernel_trap_5
#define _kernel_trap_5(trap_name, trap_number) _kernel_trap_6to9(trap_name, trap_number, r4-r5, r4-r5)
#define _kernel_trap_6(trap_name, trap_number) _kernel_trap_6to9(trap_name, trap_number, r4-r6 COMMA r8, r4-r6 COMMA r8)
#define _kernel_trap_7(trap_name, trap_number) _kernel_trap_6to9(trap_name, trap_number, r4-r6 COMMA r8, r4-r6 COMMA r8)
#define _kernel_trap_8(trap_name, trap_number) _kernel_trap_6to9(trap_name, trap_number, r4-r6 COMMA r8, r4-r6 COMMA r8)
#define _kernel_trap_9(trap_name, trap_number) _kernel_trap_6to9(trap_name, trap_number, r4-r6 COMMA r8, r4-r6 COMMA r8)
#else // !(__BIGGEST_ALIGNMENT__ > 4)
#define _kernel_trap_0(trap_name, trap_number) _kernel_trap_0to4(trap_name, trap_number)
#define _kernel_trap_1(trap_name, trap_number) _kernel_trap_0to4(trap_name, trap_number)
#define _kernel_trap_2(trap_name, trap_number) _kernel_trap_0to4(trap_name, trap_number)
#define _kernel_trap_3(trap_name, trap_number) _kernel_trap_0to4(trap_name, trap_number)
#define _kernel_trap_4(trap_name, trap_number) _kernel_trap_0to4(trap_name, trap_number)
/* _kernel_trap_5 defined above */
#define _kernel_trap_6(trap_name, trap_number) _kernel_trap_6to9(trap_name, trap_number, r4-r5, r4-r5)
/* need to save r8 not just for alignment but because mach_msg_trap overwrites the eighth argument */
#define _kernel_trap_7(trap_name, trap_number) _kernel_trap_6to9(trap_name, trap_number, r4-r6 COMMA r8, r4-r6)
#define _kernel_trap_8(trap_name, trap_number) _kernel_trap_6to9(trap_name, trap_number, r4-r6 COMMA r8, r4-r6 COMMA r8)
/* there is only one nine-argument trap (mach_msg_overwrite_trap) and it doesn't use the ninth argument */
#define _kernel_trap_9(trap_name, trap_number) _kernel_trap_8(trap_name, trap_number)
#endif // __BIGGEST_ALIGNMENT__ > 4
/* select the appropriate trap macro based off the number of args */
#define kernel_trap(trap_name, trap_number, num_args) \
LEAF(_##trap_name, 0) \
_kernel_trap_##num_args(trap_name, trap_number)
#elif defined(__arm64__)
#include <mach/machine/vm_param.h>
#define kernel_trap(trap_name, trap_number, num_args) \
.globl _##trap_name %% \
.text %% \
.align 2 %% \
_##trap_name: %% \
mov x16, #(trap_number) %% \
svc #SWI_SYSCALL %% \
ret
#else
#error Unsupported architecture
#endif
#endif /* _MACH_ARM_SYSCALL_SW_H_ */

View File

@ -0,0 +1,44 @@
/*
* Copyright (c) 2000-2007 Apple Inc. All rights reserved.
*
* @APPLE_OSREFERENCE_LICENSE_HEADER_START@
*
* This file contains Original Code and/or Modifications of Original Code
* as defined in and that are subject to the Apple Public Source License
* Version 2.0 (the 'License'). You may not use this file except in
* compliance with the License. The rights granted to you under the License
* may not be used to create, or enable the creation or redistribution of,
* unlawful or unlicensed copies of an Apple operating system, or to
* circumvent, violate, or enable the circumvention or violation of, any
* terms of an Apple operating system software license agreement.
*
* Please obtain a copy of the License at
* http://www.opensource.apple.com/apsl/ and read it before using this file.
*
* The Original Code and all software distributed under the License are
* distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
* Please see the License for the specific language governing rights and
* limitations under the License.
*
* @APPLE_OSREFERENCE_LICENSE_HEADER_END@
*/
/*
* @OSF_COPYRIGHT@
*/
#ifndef _MACH_ARM_THREAD_STATE_H_
#define _MACH_ARM_THREAD_STATE_H_
/* Size of maximum exported thread state in words */
#define ARM_THREAD_STATE_MAX (1296) /* Size of biggest state possible */
#if defined (__arm__) || defined(__arm64__)
#define THREAD_STATE_MAX ARM_THREAD_STATE_MAX
#else
#error Unsupported arch
#endif
#endif /* _MACH_ARM_THREAD_STATE_H_ */

View File

@ -0,0 +1,249 @@
/*
* Copyright (c) 2007 Apple Inc. All rights reserved.
*
* @APPLE_OSREFERENCE_LICENSE_HEADER_START@
*
* This file contains Original Code and/or Modifications of Original Code
* as defined in and that are subject to the Apple Public Source License
* Version 2.0 (the 'License'). You may not use this file except in
* compliance with the License. The rights granted to you under the License
* may not be used to create, or enable the creation or redistribution of,
* unlawful or unlicensed copies of an Apple operating system, or to
* circumvent, violate, or enable the circumvention or violation of, any
* terms of an Apple operating system software license agreement.
*
* Please obtain a copy of the License at
* http://www.opensource.apple.com/apsl/ and read it before using this file.
*
* The Original Code and all software distributed under the License are
* distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
* Please see the License for the specific language governing rights and
* limitations under the License.
*
* @APPLE_OSREFERENCE_LICENSE_HEADER_END@
*/
/*
* FILE_ID: thread_status.h
*/
#ifndef _ARM_THREAD_STATUS_H_
#define _ARM_THREAD_STATUS_H_
#include <mach/machine/_structs.h>
#include <mach/message.h>
#include <mach/vm_types.h>
#include <mach/arm/thread_state.h>
/*
* Support for determining the state of a thread
*/
/*
* Flavors
*/
#define ARM_THREAD_STATE 1
#define ARM_UNIFIED_THREAD_STATE ARM_THREAD_STATE
#define ARM_VFP_STATE 2
#define ARM_EXCEPTION_STATE 3
#define ARM_DEBUG_STATE 4 /* pre-armv8 */
#define THREAD_STATE_NONE 5
#define ARM_THREAD_STATE64 6
#define ARM_EXCEPTION_STATE64 7
// ARM_THREAD_STATE_LAST 8 /* legacy */
#define ARM_THREAD_STATE32 9
/* API */
#define ARM_DEBUG_STATE32 14
#define ARM_DEBUG_STATE64 15
#define ARM_NEON_STATE 16
#define ARM_NEON_STATE64 17
#define ARM_CPMU_STATE64 18
/* API */
#define ARM_AMX_STATE 24
#define ARM_AMX_STATE_V1 25
#define ARM_STATE_FLAVOR_IS_OTHER_VALID(_flavor_) \
((_flavor_) == ARM_AMX_STATE_V1)
#define ARM_PAGEIN_STATE 27
#define VALID_THREAD_STATE_FLAVOR(x) \
((x == ARM_THREAD_STATE) || \
(x == ARM_VFP_STATE) || \
(x == ARM_EXCEPTION_STATE) || \
(x == ARM_DEBUG_STATE) || \
(x == THREAD_STATE_NONE) || \
(x == ARM_THREAD_STATE32) || \
(x == ARM_THREAD_STATE64) || \
(x == ARM_EXCEPTION_STATE64) || \
(x == ARM_NEON_STATE) || \
(x == ARM_NEON_STATE64) || \
(x == ARM_DEBUG_STATE32) || \
(x == ARM_DEBUG_STATE64) || \
(x == ARM_PAGEIN_STATE) || \
(ARM_STATE_FLAVOR_IS_OTHER_VALID(x)))
struct arm_state_hdr {
uint32_t flavor;
uint32_t count;
};
typedef struct arm_state_hdr arm_state_hdr_t;
typedef _STRUCT_ARM_THREAD_STATE arm_thread_state_t;
typedef _STRUCT_ARM_THREAD_STATE arm_thread_state32_t;
typedef _STRUCT_ARM_THREAD_STATE64 arm_thread_state64_t;
#if __DARWIN_C_LEVEL >= __DARWIN_C_FULL && defined(__arm64__)
/* Accessor macros for arm_thread_state64_t pointer fields */
/* Return pc field of arm_thread_state64_t as a data pointer value */
#define arm_thread_state64_get_pc(ts) \
__darwin_arm_thread_state64_get_pc(ts)
/* Return pc field of arm_thread_state64_t as a function pointer. May return
* NULL if a valid function pointer cannot be constructed, the caller should
* fall back to the arm_thread_state64_get_pc() macro in that case. */
#define arm_thread_state64_get_pc_fptr(ts) \
__darwin_arm_thread_state64_get_pc_fptr(ts)
/* Set pc field of arm_thread_state64_t to a function pointer */
#define arm_thread_state64_set_pc_fptr(ts, fptr) \
__darwin_arm_thread_state64_set_pc_fptr(ts, fptr)
/* Return lr field of arm_thread_state64_t as a data pointer value */
#define arm_thread_state64_get_lr(ts) \
__darwin_arm_thread_state64_get_lr(ts)
/* Return lr field of arm_thread_state64_t as a function pointer. May return
* NULL if a valid function pointer cannot be constructed, the caller should
* fall back to the arm_thread_state64_get_lr() macro in that case. */
#define arm_thread_state64_get_lr_fptr(ts) \
__darwin_arm_thread_state64_get_lr_fptr(ts)
/* Set lr field of arm_thread_state64_t to a function pointer */
#define arm_thread_state64_set_lr_fptr(ts, fptr) \
__darwin_arm_thread_state64_set_lr_fptr(ts, fptr)
/* Return sp field of arm_thread_state64_t as a data pointer value */
#define arm_thread_state64_get_sp(ts) \
__darwin_arm_thread_state64_get_sp(ts)
/* Set sp field of arm_thread_state64_t to a data pointer value */
#define arm_thread_state64_set_sp(ts, ptr) \
__darwin_arm_thread_state64_set_sp(ts, ptr)
/* Return fp field of arm_thread_state64_t as a data pointer value */
#define arm_thread_state64_get_fp(ts) \
__darwin_arm_thread_state64_get_fp(ts)
/* Set fp field of arm_thread_state64_t to a data pointer value */
#define arm_thread_state64_set_fp(ts, ptr) \
__darwin_arm_thread_state64_set_fp(ts, ptr)
/* Strip ptr auth bits from pc, lr, sp and fp field of arm_thread_state64_t */
#define arm_thread_state64_ptrauth_strip(ts) \
__darwin_arm_thread_state64_ptrauth_strip(ts)
#endif /* __DARWIN_C_LEVEL >= __DARWIN_C_FULL && defined(__arm64__) */
struct arm_unified_thread_state {
arm_state_hdr_t ash;
union {
arm_thread_state32_t ts_32;
arm_thread_state64_t ts_64;
} uts;
};
#define ts_32 uts.ts_32
#define ts_64 uts.ts_64
typedef struct arm_unified_thread_state arm_unified_thread_state_t;
#define ARM_THREAD_STATE_COUNT ((mach_msg_type_number_t) \
(sizeof (arm_thread_state_t)/sizeof(uint32_t)))
#define ARM_THREAD_STATE32_COUNT ((mach_msg_type_number_t) \
(sizeof (arm_thread_state32_t)/sizeof(uint32_t)))
#define ARM_THREAD_STATE64_COUNT ((mach_msg_type_number_t) \
(sizeof (arm_thread_state64_t)/sizeof(uint32_t)))
#define ARM_UNIFIED_THREAD_STATE_COUNT ((mach_msg_type_number_t) \
(sizeof (arm_unified_thread_state_t)/sizeof(uint32_t)))
typedef _STRUCT_ARM_VFP_STATE arm_vfp_state_t;
typedef _STRUCT_ARM_NEON_STATE arm_neon_state_t;
typedef _STRUCT_ARM_NEON_STATE arm_neon_state32_t;
typedef _STRUCT_ARM_NEON_STATE64 arm_neon_state64_t;
typedef _STRUCT_ARM_AMX_STATE_V1 arm_amx_state_v1_t;
typedef _STRUCT_ARM_EXCEPTION_STATE arm_exception_state_t;
typedef _STRUCT_ARM_EXCEPTION_STATE arm_exception_state32_t;
typedef _STRUCT_ARM_EXCEPTION_STATE64 arm_exception_state64_t;
typedef _STRUCT_ARM_DEBUG_STATE32 arm_debug_state32_t;
typedef _STRUCT_ARM_DEBUG_STATE64 arm_debug_state64_t;
typedef _STRUCT_ARM_PAGEIN_STATE arm_pagein_state_t;
/*
* Otherwise not ARM64 kernel and we must preserve legacy ARM definitions of
* arm_debug_state for binary compatability of userland consumers of this file.
*/
#if defined(__arm__)
typedef _STRUCT_ARM_DEBUG_STATE arm_debug_state_t;
#elif defined(__arm64__)
typedef _STRUCT_ARM_LEGACY_DEBUG_STATE arm_debug_state_t;
#else /* defined(__arm__) */
#error Undefined architecture
#endif /* defined(__arm__) */
#define ARM_VFP_STATE_COUNT ((mach_msg_type_number_t) \
(sizeof (arm_vfp_state_t)/sizeof(uint32_t)))
#define ARM_EXCEPTION_STATE_COUNT ((mach_msg_type_number_t) \
(sizeof (arm_exception_state_t)/sizeof(uint32_t)))
#define ARM_EXCEPTION_STATE64_COUNT ((mach_msg_type_number_t) \
(sizeof (arm_exception_state64_t)/sizeof(uint32_t)))
#define ARM_DEBUG_STATE_COUNT ((mach_msg_type_number_t) \
(sizeof (arm_debug_state_t)/sizeof(uint32_t)))
#define ARM_DEBUG_STATE32_COUNT ((mach_msg_type_number_t) \
(sizeof (arm_debug_state32_t)/sizeof(uint32_t)))
#define ARM_PAGEIN_STATE_COUNT ((mach_msg_type_number_t) \
(sizeof (arm_pagein_state_t)/sizeof(uint32_t)))
#define ARM_DEBUG_STATE64_COUNT ((mach_msg_type_number_t) \
(sizeof (arm_debug_state64_t)/sizeof(uint32_t)))
#define ARM_NEON_STATE_COUNT ((mach_msg_type_number_t) \
(sizeof (arm_neon_state_t)/sizeof(uint32_t)))
#define ARM_NEON_STATE64_COUNT ((mach_msg_type_number_t) \
(sizeof (arm_neon_state64_t)/sizeof(uint32_t)))
#define MACHINE_THREAD_STATE ARM_THREAD_STATE
#define MACHINE_THREAD_STATE_COUNT ARM_UNIFIED_THREAD_STATE_COUNT
struct arm_amx_state {
arm_state_hdr_t ash;
union {
arm_amx_state_v1_t as_v1;
} uas;
};
#define as_v1 uas.as_v1
typedef struct arm_amx_state arm_amx_state_t;
#define ARM_AMX_STATE_V1_COUNT ((mach_msg_type_number_t) \
(sizeof(arm_amx_state_v1_t)/sizeof(unsigned int)))
#define ARM_AMX_STATE_COUNT ((mach_msg_type_number_t) \
(sizeof(arm_amx_state_t)/sizeof(unsigned int)))
/*
* Largest state on this machine:
*/
#define THREAD_MACHINE_STATE_MAX THREAD_STATE_MAX
#endif /* _ARM_THREAD_STATUS_H_ */

View File

@ -0,0 +1,33 @@
/*
* Copyright (c) 2019 Apple Inc. All rights reserved.
*
* @APPLE_OSREFERENCE_LICENSE_HEADER_START@
*
* This file contains Original Code and/or Modifications of Original Code
* as defined in and that are subject to the Apple Public Source License
* Version 2.0 (the 'License'). You may not use this file except in
* compliance with the License. The rights granted to you under the License
* may not be used to create, or enable the creation or redistribution of,
* unlawful or unlicensed copies of an Apple operating system, or to
* circumvent, violate, or enable the circumvention or violation of, any
* terms of an Apple operating system software license agreement.
*
* Please obtain a copy of the License at
* http://www.opensource.apple.com/apsl/ and read it before using this file.
*
* The Original Code and all software distributed under the License are
* distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
* Please see the License for the specific language governing rights and
* limitations under the License.
*
* @APPLE_OSREFERENCE_LICENSE_HEADER_END@
*/
#pragma once
#define MACH_ARM_TRAP_ABSTIME -3
#define MACH_ARM_TRAP_CONTTIME -4

View File

@ -0,0 +1,107 @@
/*
* Copyright (c) 2007 Apple Inc. All rights reserved.
*
* @APPLE_OSREFERENCE_LICENSE_HEADER_START@
*
* This file contains Original Code and/or Modifications of Original Code
* as defined in and that are subject to the Apple Public Source License
* Version 2.0 (the 'License'). You may not use this file except in
* compliance with the License. The rights granted to you under the License
* may not be used to create, or enable the creation or redistribution of,
* unlawful or unlicensed copies of an Apple operating system, or to
* circumvent, violate, or enable the circumvention or violation of, any
* terms of an Apple operating system software license agreement.
*
* Please obtain a copy of the License at
* http://www.opensource.apple.com/apsl/ and read it before using this file.
*
* The Original Code and all software distributed under the License are
* distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
* Please see the License for the specific language governing rights and
* limitations under the License.
*
* @APPLE_OSREFERENCE_LICENSE_HEADER_END@
*/
/*
* FILE_ID: vm_param.h
*/
/*
* ARM machine dependent virtual memory parameters.
*/
#ifndef _MACH_ARM_VM_PARAM_H_
#define _MACH_ARM_VM_PARAM_H_
#if !defined (KERNEL) && !defined (__ASSEMBLER__)
#include <mach/vm_page_size.h>
#endif
#define BYTE_SIZE 8 /* byte size in bits */
#define PAGE_SHIFT vm_page_shift
#define PAGE_SIZE vm_page_size
#define PAGE_MASK vm_page_mask
#define VM_PAGE_SIZE vm_page_size
#define machine_ptob(x) ((x) << PAGE_SHIFT)
#define PAGE_MAX_SHIFT 14
#define PAGE_MAX_SIZE (1 << PAGE_MAX_SHIFT)
#define PAGE_MAX_MASK (PAGE_MAX_SIZE-1)
#define PAGE_MIN_SHIFT 12
#define PAGE_MIN_SIZE (1 << PAGE_MIN_SHIFT)
#define PAGE_MIN_MASK (PAGE_MIN_SIZE-1)
#define VM_MAX_PAGE_ADDRESS MACH_VM_MAX_ADDRESS
#ifndef __ASSEMBLER__
#if defined (__arm__)
#define VM_MIN_ADDRESS ((vm_address_t) 0x00000000)
#define VM_MAX_ADDRESS ((vm_address_t) 0x80000000)
/* system-wide values */
#define MACH_VM_MIN_ADDRESS ((mach_vm_offset_t) 0)
#define MACH_VM_MAX_ADDRESS ((mach_vm_offset_t) VM_MAX_ADDRESS)
#elif defined (__arm64__)
#define VM_MIN_ADDRESS ((vm_address_t) 0x0000000000000000ULL)
#define VM_MAX_ADDRESS ((vm_address_t) 0x0000000080000000ULL)
/* system-wide values */
#define MACH_VM_MIN_ADDRESS_RAW 0x0ULL
#define MACH_VM_MAX_ADDRESS_RAW 0x00007FFFFE000000ULL
#define MACH_VM_MIN_ADDRESS ((mach_vm_offset_t) MACH_VM_MIN_ADDRESS_RAW)
#define MACH_VM_MAX_ADDRESS ((mach_vm_offset_t) MACH_VM_MAX_ADDRESS_RAW)
#define MACH_VM_MIN_GPU_CARVEOUT_ADDRESS_RAW 0x0000001000000000ULL
#define MACH_VM_MAX_GPU_CARVEOUT_ADDRESS_RAW 0x0000007000000000ULL
#define MACH_VM_MIN_GPU_CARVEOUT_ADDRESS ((mach_vm_offset_t) MACH_VM_MIN_GPU_CARVEOUT_ADDRESS_RAW)
#define MACH_VM_MAX_GPU_CARVEOUT_ADDRESS ((mach_vm_offset_t) MACH_VM_MAX_GPU_CARVEOUT_ADDRESS_RAW)
#else /* defined(__arm64__) */
#error architecture not supported
#endif
#define VM_MAP_MIN_ADDRESS VM_MIN_ADDRESS
#define VM_MAP_MAX_ADDRESS VM_MAX_ADDRESS
#endif /* !__ASSEMBLER__ */
#define SWI_SYSCALL 0x80
#endif /* _MACH_ARM_VM_PARAM_H_ */

View File

@ -0,0 +1,157 @@
/*
* Copyright (c) 2000-2007 Apple Inc. All rights reserved.
*
* @APPLE_OSREFERENCE_LICENSE_HEADER_START@
*
* This file contains Original Code and/or Modifications of Original Code
* as defined in and that are subject to the Apple Public Source License
* Version 2.0 (the 'License'). You may not use this file except in
* compliance with the License. The rights granted to you under the License
* may not be used to create, or enable the creation or redistribution of,
* unlawful or unlicensed copies of an Apple operating system, or to
* circumvent, violate, or enable the circumvention or violation of, any
* terms of an Apple operating system software license agreement.
*
* Please obtain a copy of the License at
* http://www.opensource.apple.com/apsl/ and read it before using this file.
*
* The Original Code and all software distributed under the License are
* distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
* Please see the License for the specific language governing rights and
* limitations under the License.
*
* @APPLE_OSREFERENCE_LICENSE_HEADER_END@
*/
/*
* @OSF_COPYRIGHT@
*/
/*
* Mach Operating System
* Copyright (c) 1991,1990,1989,1988 Carnegie Mellon University
* All Rights Reserved.
*
* Permission to use, copy, modify and distribute this software and its
* documentation is hereby granted, provided that both the copyright
* notice and this permission notice appear in all copies of the
* software, derivative works or modified versions, and any portions
* thereof, and that both notices appear in supporting documentation.
*
* CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
* CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR
* ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
*
* Carnegie Mellon requests users of this software to return to
*
* Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU
* School of Computer Science
* Carnegie Mellon University
* Pittsburgh PA 15213-3890
*
* any improvements or extensions that they make and grant Carnegie Mellon
* the rights to redistribute these changes.
*/
/*
*/
/*
* File: vm_types.h
* Author: Avadis Tevanian, Jr.
* Date: 1985
*
* Header file for VM data types. ARM version.
*/
#ifndef _MACH_ARM_VM_TYPES_H_
#define _MACH_ARM_VM_TYPES_H_
#ifndef ASSEMBLER
#include <arm/_types.h>
#include <stdint.h>
#include <Availability.h>
/*
* natural_t and integer_t are Mach's legacy types for machine-
* independent integer types (unsigned, and signed, respectively).
* Their original purpose was to define other types in a machine/
* compiler independent way.
*
* They also had an implicit "same size as pointer" characteristic
* to them (i.e. Mach's traditional types are very ILP32 or ILP64
* centric). We will likely support x86 ABIs that do not follow
* either ofthese models (specifically LP64). Therefore, we had to
* make a choice between making these types scale with pointers or stay
* tied to integers. Because their use is predominantly tied to
* to the size of an integer, we are keeping that association and
* breaking free from pointer size guarantees.
*
* New use of these types is discouraged.
*/
typedef __darwin_natural_t natural_t;
typedef int integer_t;
/*
* A vm_offset_t is a type-neutral pointer,
* e.g. an offset into a virtual memory space.
*/
#ifdef __LP64__
typedef uintptr_t vm_offset_t;
typedef uintptr_t vm_size_t;
typedef uint64_t mach_vm_address_t;
typedef uint64_t mach_vm_offset_t;
typedef uint64_t mach_vm_size_t;
typedef uint64_t vm_map_offset_t;
typedef uint64_t vm_map_address_t;
typedef uint64_t vm_map_size_t;
#else
typedef natural_t vm_offset_t;
/*
* A vm_size_t is the proper type for e.g.
* expressing the difference between two
* vm_offset_t entities.
*/
typedef natural_t vm_size_t;
/*
* This new type is independent of a particular vm map's
* implementation size - and represents appropriate types
* for all possible maps. This is used for interfaces
* where the size of the map is not known - or we don't
* want to have to distinguish.
*/
#if defined(__IPHONE_OS_VERSION_MIN_REQUIRED) && (__IPHONE_OS_VERSION_MIN_REQUIRED < __IPHONE_5_0)
typedef uint32_t mach_vm_address_t;
typedef uint32_t mach_vm_offset_t;
typedef uint32_t mach_vm_size_t;
#else
typedef uint64_t mach_vm_address_t;
typedef uint64_t mach_vm_offset_t;
typedef uint64_t mach_vm_size_t;
#endif
typedef uint32_t vm_map_offset_t;
typedef uint32_t vm_map_address_t;
typedef uint32_t vm_map_size_t;
#endif /* __LP64__ */
typedef uint32_t vm32_offset_t;
typedef uint32_t vm32_address_t;
typedef uint32_t vm32_size_t;
typedef vm_offset_t mach_port_context_t;
#endif /* ASSEMBLER */
/*
* If composing messages by hand (please do not)
*/
#define MACH_MSG_TYPE_INTEGER_T MACH_MSG_TYPE_INTEGER_32
#endif /* _MACH_ARM_VM_TYPES_H_ */

View File

@ -0,0 +1,203 @@
/*
* Copyright (c) 2007 Apple Inc. All rights reserved.
*
* @APPLE_OSREFERENCE_LICENSE_HEADER_START@
*
* This file contains Original Code and/or Modifications of Original Code
* as defined in and that are subject to the Apple Public Source License
* Version 2.0 (the 'License'). You may not use this file except in
* compliance with the License. The rights granted to you under the License
* may not be used to create, or enable the creation or redistribution of,
* unlawful or unlicensed copies of an Apple operating system, or to
* circumvent, violate, or enable the circumvention or violation of, any
* terms of an Apple operating system software license agreement.
*
* Please obtain a copy of the License at
* http://www.opensource.apple.com/apsl/ and read it before using this file.
*
* The Original Code and all software distributed under the License are
* distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
* Please see the License for the specific language governing rights and
* limitations under the License.
*
* @APPLE_OSREFERENCE_LICENSE_HEADER_END@
*/
/*
* @OSF_COPYRIGHT@
*/
/*
* Mach Operating System
* Copyright (c) 1991,1990,1989 Carnegie Mellon University
* All Rights Reserved.
*
* Permission to use, copy, modify and distribute this software and its
* documentation is hereby granted, provided that both the copyright
* notice and this permission notice appear in all copies of the
* software, derivative works or modified versions, and any portions
* thereof, and that both notices appear in supporting documentation.
*
* CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
* CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR
* ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
*
* Carnegie Mellon requests users of this software to return to
*
* Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU
* School of Computer Science
* Carnegie Mellon University
* Pittsburgh PA 15213-3890
*
* any improvements or extensions that they make and grant Carnegie Mellon
* the rights to redistribute these changes.
*/
#ifndef _ARM_ASM_H_
#define _ARM_ASM_H_
#include <arm/arch.h>
#ifndef __arm64__
#error Why are we including this?
#endif
/* There is another definition of ALIGN for .c sources */
#ifdef __ASSEMBLER__
#define ALIGN 2
#endif /* ASSEMBLER */
#ifndef FALIGN
#define FALIGN ALIGN
#endif
#define LB(x,n) n
#if __STDC__
#ifndef __NO_UNDERSCORES__
#define LCL(x) L ## x
#define EXT(x) _ ## x
#define LEXT(x) _ ## x ## :
#else
#define LCL(x) .L ## x
#define EXT(x) x
#define LEXT(x) x ## :
#endif
#define LBc(x,n) n ## :
#define LBb(x,n) n ## b
#define LBf(x,n) n ## f
#else /* __STDC__ */
#ifndef __NO_UNDERSCORES__
#define LCL(x) L/**/x
#define EXT(x) _/**/x
#define LEXT(x) _/**/x/**/:
#else /* __NO_UNDERSCORES__ */
#define LCL(x) .L/**/x
#define EXT(x) x
#define LEXT(x) x/**/:
#endif /* __NO_UNDERSCORES__ */
#define LBc(x,n) n/**/:
#define LBb(x,n) n/**/b
#define LBf(x,n) n/**/f
#endif /* __STDC__ */
#define String .asciz
#define Value .word
#define Times(a,b) (a*b)
#define Divide(a,b) (a/b)
#ifdef __ASSEMBLER__
#if MACH_KDB
#include <ddb/stab.h>
/*
* This pseudo-assembler line is added so that there will be at least
* one N_SO entry in the symbol stable to define the current file name.
*/
#endif /* MACH_KDB */
/*
* Multiline macros must use .macro syntax for now,
* as there is no ARM64 statement separator.
*/
.macro ENTRY
.align FALIGN
.globl _$0
_$0 :
.endmacro
.macro ENTRY2
.align FALIGN
.globl _$0
.globl _$1
_$0 :
_$1 :
.endmacro
.macro READ_THREAD
mrs $0, TPIDR_EL1
.endmacro
.macro BRANCH_EXTERN
b _$0
.endmacro
.macro CALL_EXTERN
bl _$0
.endmacro
.macro MOV64
movk $0, #((($1) >> 48) & 0x000000000000FFFF), lsl #48
movk $0, #((($1) >> 32) & 0x000000000000FFFF), lsl #32
movk $0, #((($1) >> 16) & 0x000000000000FFFF), lsl #16
movk $0, #((($1) >> 00) & 0x000000000000FFFF), lsl #00
.endmacro
.macro MOV32
movz $0, #((($1) >> 16) & 0x000000000000FFFF), lsl #16
movk $0, #((($1) >> 00) & 0x000000000000FFFF), lsl #00
.endmacro
.macro ARM64_STACK_PROLOG
#if __has_feature(ptrauth_returns)
pacibsp
#endif
.endmacro
.macro ARM64_STACK_EPILOG
#if __has_feature(ptrauth_returns)
retab
#else
ret
#endif
.endmacro
#define PUSH_FRAME \
stp fp, lr, [sp, #-16]! %% \
mov fp, sp %%
#define POP_FRAME \
mov sp, fp %% \
ldp fp, lr, [sp], #16 %%
#define EXT(x) _ ## x
#else /* NOT __ASSEMBLER__ */
/* These defines are here for .c files that wish to reference global symbols
* within __asm__ statements.
*/
#ifndef __NO_UNDERSCORES__
#define CC_SYM_PREFIX "_"
#else
#define CC_SYM_PREFIX ""
#endif /* __NO_UNDERSCORES__ */
#endif /* __ASSEMBLER__ */
#ifdef __ASSEMBLER__
# define BRANCH_EXTERN(x) b EXT(x)
#endif /* __ASSEMBLER__ */
#endif /* _ARM_ASM_H_ */

View File

@ -0,0 +1,57 @@
/*
* Copyright (c) 2004-2008, Apple Inc. All rights reserved.
*
* @APPLE_BSD_LICENSE_HEADER_START@
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. Neither the name of Apple Inc. ("Apple") nor the names of
* its contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* @APPLE_BSD_LICENSE_HEADER_END@
*/
/*
* Interface definition for the audit logging facility.
*/
subsystem
#if KERNEL_USER
KernelUser
#endif /* KERNEL_USER */
audit_triggers 123;
#include <mach/std_types.defs>
#include <mach/mach_types.defs>
import <mach/audit_triggers_types.h>;
type string_t = c_string [*:1024];
simpleroutine audit_triggers(
audit_port : mach_port_t;
in flags : int);
simpleroutine audit_analytics(
audit_port : mach_port_t;
in caller_id : string_t;
in caller_name : string_t);

View File

@ -0,0 +1 @@
typedef const char* string_t;

View File

@ -0,0 +1,88 @@
/*
* Copyright (c) 2000 Apple Computer, Inc. All rights reserved.
*
* @APPLE_OSREFERENCE_LICENSE_HEADER_START@
*
* This file contains Original Code and/or Modifications of Original Code
* as defined in and that are subject to the Apple Public Source License
* Version 2.0 (the 'License'). You may not use this file except in
* compliance with the License. The rights granted to you under the License
* may not be used to create, or enable the creation or redistribution of,
* unlawful or unlicensed copies of an Apple operating system, or to
* circumvent, violate, or enable the circumvention or violation of, any
* terms of an Apple operating system software license agreement.
*
* Please obtain a copy of the License at
* http://www.opensource.apple.com/apsl/ and read it before using this file.
*
* The Original Code and all software distributed under the License are
* distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
* Please see the License for the specific language governing rights and
* limitations under the License.
*
* @APPLE_OSREFERENCE_LICENSE_HEADER_END@
*/
/*
* @OSF_COPYRIGHT@
*/
/*
* Mach Operating System
* Copyright (c) 1991,1990,1989,1988,1987 Carnegie Mellon University
* All Rights Reserved.
*
* Permission to use, copy, modify and distribute this software and its
* documentation is hereby granted, provided that both the copyright
* notice and this permission notice appear in all copies of the
* software, derivative works or modified versions, and any portions
* thereof, and that both notices appear in supporting documentation.
*
* CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
* CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR
* ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
*
* Carnegie Mellon requests users of this software to return to
*
* Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU
* School of Computer Science
* Carnegie Mellon University
* Pittsburgh PA 15213-3890
*
* any improvements or extensions that they make and grant Carnegie Mellon
* the rights to redistribute these changes.
*/
/*
*/
/*
* File: mach/boolean.h
*
* Boolean data type.
*
*/
#ifndef _MACH_BOOLEAN_H_
#define _MACH_BOOLEAN_H_
/*
* Pick up "boolean_t" type definition
*/
#ifndef ASSEMBLER
#include <mach/machine/boolean.h>
#endif /* ASSEMBLER */
/*
* Define TRUE and FALSE if not defined.
*/
#ifndef TRUE
#define TRUE 1
#endif /* TRUE */
#ifndef FALSE
#define FALSE 0
#endif /* FALSE */
#endif /* _MACH_BOOLEAN_H_ */

View File

@ -0,0 +1,34 @@
/*
* Copyright (c) 2002 Apple Computer, Inc. All rights reserved.
*
* @APPLE_OSREFERENCE_LICENSE_HEADER_START@
*
* This file contains Original Code and/or Modifications of Original Code
* as defined in and that are subject to the Apple Public Source License
* Version 2.0 (the 'License'). You may not use this file except in
* compliance with the License. The rights granted to you under the License
* may not be used to create, or enable the creation or redistribution of,
* unlawful or unlicensed copies of an Apple operating system, or to
* circumvent, violate, or enable the circumvention or violation of, any
* terms of an Apple operating system software license agreement.
*
* Please obtain a copy of the License at
* http://www.opensource.apple.com/apsl/ and read it before using this file.
*
* The Original Code and all software distributed under the License are
* distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
* Please see the License for the specific language governing rights and
* limitations under the License.
*
* @APPLE_OSREFERENCE_LICENSE_HEADER_END@
*/
/*
* Mach bootstrap interfaces (obsolete: header included only for compatibility)
*/
#ifndef _MACH_BOOTSTRAP_H_
#define _MACH_BOOTSTRAP_H_
#endif /* _MACH_BOOTSTRAP_H_ */

View File

@ -0,0 +1,81 @@
/*
* Copyright (c) 2000 Apple Computer, Inc. All rights reserved.
*
* @APPLE_OSREFERENCE_LICENSE_HEADER_START@
*
* This file contains Original Code and/or Modifications of Original Code
* as defined in and that are subject to the Apple Public Source License
* Version 2.0 (the 'License'). You may not use this file except in
* compliance with the License. The rights granted to you under the License
* may not be used to create, or enable the creation or redistribution of,
* unlawful or unlicensed copies of an Apple operating system, or to
* circumvent, violate, or enable the circumvention or violation of, any
* terms of an Apple operating system software license agreement.
*
* Please obtain a copy of the License at
* http://www.opensource.apple.com/apsl/ and read it before using this file.
*
* The Original Code and all software distributed under the License are
* distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
* Please see the License for the specific language governing rights and
* limitations under the License.
*
* @APPLE_OSREFERENCE_LICENSE_HEADER_END@
*/
/*
* @OSF_COPYRIGHT@
*/
/*
* File: mach/clock.defs
* Purpose: Kernel clock subsystem definitions. This
* file defines the clock request interface.
*/
subsystem
#if KERNEL_SERVER
KernelServer
#endif /* KERNEL_SERVER */
clock 1000;
#include <mach/std_types.defs>
#include <mach/mach_types.defs>
#include <mach/clock_types.defs>
/*
* References to clock objects are returned by:
* host_get_clock_service(host_t,...)
* host_get_clock_control(host_priv_t,...) - Priviledged subclass
*/
/*
* Get the clock time.
* Available to all.
*/
routine clock_get_time(
clock_serv : clock_serv_t;
out cur_time : mach_timespec_t);
/*
* Get clock attributes.
* Available to all.
*/
routine clock_get_attributes(
clock_serv : clock_serv_t;
in flavor : clock_flavor_t;
out clock_attr : clock_attr_t, CountInOut);
/*
* Setup a clock alarm.
* Available to all.
*/
routine clock_alarm(
clock_serv : clock_serv_t;
alarm_type : alarm_type_t;
alarm_time : mach_timespec_t;
alarm_port : clock_reply_t =
MACH_MSG_TYPE_MAKE_SEND_ONCE|polymorphic);
/* vim: set ft=c : */

View File

@ -0,0 +1,245 @@
#ifndef _clock_user_
#define _clock_user_
/* Module clock */
#include <string.h>
#include <mach/ndr.h>
#include <mach/boolean.h>
#include <mach/kern_return.h>
#include <mach/notify.h>
#include <mach/mach_types.h>
#include <mach/message.h>
#include <mach/mig_errors.h>
#include <mach/port.h>
/* BEGIN MIG_STRNCPY_ZEROFILL CODE */
#if defined(__has_include)
#if __has_include(<mach/mig_strncpy_zerofill_support.h>)
#ifndef USING_MIG_STRNCPY_ZEROFILL
#define USING_MIG_STRNCPY_ZEROFILL
#endif
#ifndef __MIG_STRNCPY_ZEROFILL_FORWARD_TYPE_DECLS__
#define __MIG_STRNCPY_ZEROFILL_FORWARD_TYPE_DECLS__
#ifdef __cplusplus
extern "C" {
#endif
extern int mig_strncpy_zerofill(char *dest, const char *src, int len) __attribute__((weak_import));
#ifdef __cplusplus
}
#endif
#endif /* __MIG_STRNCPY_ZEROFILL_FORWARD_TYPE_DECLS__ */
#endif /* __has_include(<mach/mig_strncpy_zerofill_support.h>) */
#endif /* __has_include */
/* END MIG_STRNCPY_ZEROFILL CODE */
#ifdef AUTOTEST
#ifndef FUNCTION_PTR_T
#define FUNCTION_PTR_T
typedef void (*function_ptr_t)(mach_port_t, char *, mach_msg_type_number_t);
typedef struct {
char *name;
function_ptr_t function;
} function_table_entry;
typedef function_table_entry *function_table_t;
#endif /* FUNCTION_PTR_T */
#endif /* AUTOTEST */
#ifndef clock_MSG_COUNT
#define clock_MSG_COUNT 3
#endif /* clock_MSG_COUNT */
#include <mach/std_types.h>
#include <mach/mig.h>
#include <mach/mig.h>
#include <mach/mach_types.h>
#include <mach/mach_types.h>
#ifdef __BeforeMigUserHeader
__BeforeMigUserHeader
#endif /* __BeforeMigUserHeader */
#include <sys/cdefs.h>
__BEGIN_DECLS
/* Routine clock_get_time */
#ifdef mig_external
mig_external
#else
extern
#endif /* mig_external */
kern_return_t clock_get_time
(
clock_serv_t clock_serv,
mach_timespec_t *cur_time
);
/* Routine clock_get_attributes */
#ifdef mig_external
mig_external
#else
extern
#endif /* mig_external */
kern_return_t clock_get_attributes
(
clock_serv_t clock_serv,
clock_flavor_t flavor,
clock_attr_t clock_attr,
mach_msg_type_number_t *clock_attrCnt
);
/* Routine clock_alarm */
#ifdef mig_external
mig_external
#else
extern
#endif /* mig_external */
kern_return_t clock_alarm
(
clock_serv_t clock_serv,
alarm_type_t alarm_type,
mach_timespec_t alarm_time,
clock_reply_t alarm_port
);
__END_DECLS
/********************** Caution **************************/
/* The following data types should be used to calculate */
/* maximum message sizes only. The actual message may be */
/* smaller, and the position of the arguments within the */
/* message layout may vary from what is presented here. */
/* For example, if any of the arguments are variable- */
/* sized, and less than the maximum is sent, the data */
/* will be packed tight in the actual message to reduce */
/* the presence of holes. */
/********************** Caution **************************/
/* typedefs for all requests */
#ifndef __Request__clock_subsystem__defined
#define __Request__clock_subsystem__defined
#ifdef __MigPackStructs
#pragma pack(push, 4)
#endif
typedef struct {
mach_msg_header_t Head;
} __Request__clock_get_time_t __attribute__((unused));
#ifdef __MigPackStructs
#pragma pack(pop)
#endif
#ifdef __MigPackStructs
#pragma pack(push, 4)
#endif
typedef struct {
mach_msg_header_t Head;
NDR_record_t NDR;
clock_flavor_t flavor;
mach_msg_type_number_t clock_attrCnt;
} __Request__clock_get_attributes_t __attribute__((unused));
#ifdef __MigPackStructs
#pragma pack(pop)
#endif
#ifdef __MigPackStructs
#pragma pack(push, 4)
#endif
typedef struct {
mach_msg_header_t Head;
/* start of the kernel processed data */
mach_msg_body_t msgh_body;
mach_msg_port_descriptor_t alarm_port;
/* end of the kernel processed data */
NDR_record_t NDR;
alarm_type_t alarm_type;
mach_timespec_t alarm_time;
} __Request__clock_alarm_t __attribute__((unused));
#ifdef __MigPackStructs
#pragma pack(pop)
#endif
#endif /* !__Request__clock_subsystem__defined */
/* union of all requests */
#ifndef __RequestUnion__clock_subsystem__defined
#define __RequestUnion__clock_subsystem__defined
union __RequestUnion__clock_subsystem {
__Request__clock_get_time_t Request_clock_get_time;
__Request__clock_get_attributes_t Request_clock_get_attributes;
__Request__clock_alarm_t Request_clock_alarm;
};
#endif /* !__RequestUnion__clock_subsystem__defined */
/* typedefs for all replies */
#ifndef __Reply__clock_subsystem__defined
#define __Reply__clock_subsystem__defined
#ifdef __MigPackStructs
#pragma pack(push, 4)
#endif
typedef struct {
mach_msg_header_t Head;
NDR_record_t NDR;
kern_return_t RetCode;
mach_timespec_t cur_time;
} __Reply__clock_get_time_t __attribute__((unused));
#ifdef __MigPackStructs
#pragma pack(pop)
#endif
#ifdef __MigPackStructs
#pragma pack(push, 4)
#endif
typedef struct {
mach_msg_header_t Head;
NDR_record_t NDR;
kern_return_t RetCode;
mach_msg_type_number_t clock_attrCnt;
int clock_attr[1];
} __Reply__clock_get_attributes_t __attribute__((unused));
#ifdef __MigPackStructs
#pragma pack(pop)
#endif
#ifdef __MigPackStructs
#pragma pack(push, 4)
#endif
typedef struct {
mach_msg_header_t Head;
NDR_record_t NDR;
kern_return_t RetCode;
} __Reply__clock_alarm_t __attribute__((unused));
#ifdef __MigPackStructs
#pragma pack(pop)
#endif
#endif /* !__Reply__clock_subsystem__defined */
/* union of all replies */
#ifndef __ReplyUnion__clock_subsystem__defined
#define __ReplyUnion__clock_subsystem__defined
union __ReplyUnion__clock_subsystem {
__Reply__clock_get_time_t Reply_clock_get_time;
__Reply__clock_get_attributes_t Reply_clock_get_attributes;
__Reply__clock_alarm_t Reply_clock_alarm;
};
#endif /* !__RequestUnion__clock_subsystem__defined */
#ifndef subsystem_to_name_map_clock
#define subsystem_to_name_map_clock \
{ "clock_get_time", 1000 },\
{ "clock_get_attributes", 1001 },\
{ "clock_alarm", 1002 }
#endif
#ifdef __AfterMigUserHeader
__AfterMigUserHeader
#endif /* __AfterMigUserHeader */
#endif /* _clock_user_ */

View File

@ -0,0 +1,69 @@
/*
* Copyright (c) 2000 Apple Computer, Inc. All rights reserved.
*
* @APPLE_OSREFERENCE_LICENSE_HEADER_START@
*
* This file contains Original Code and/or Modifications of Original Code
* as defined in and that are subject to the Apple Public Source License
* Version 2.0 (the 'License'). You may not use this file except in
* compliance with the License. The rights granted to you under the License
* may not be used to create, or enable the creation or redistribution of,
* unlawful or unlicensed copies of an Apple operating system, or to
* circumvent, violate, or enable the circumvention or violation of, any
* terms of an Apple operating system software license agreement.
*
* Please obtain a copy of the License at
* http://www.opensource.apple.com/apsl/ and read it before using this file.
*
* The Original Code and all software distributed under the License are
* distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
* Please see the License for the specific language governing rights and
* limitations under the License.
*
* @APPLE_OSREFERENCE_LICENSE_HEADER_END@
*/
/*
* @OSF_COPYRIGHT@
*/
/*
* File: mach/clock_priv.defs
* Purpose: Kernel clock subsystem definitions. This
* file defines the clock request interface.
*/
subsystem
#if KERNEL_SERVER
KernelServer
#endif /* KERNEL_SERVER */
clock_priv 1200;
#include <mach/std_types.defs>
#include <mach/mach_types.defs>
#include <mach/clock_types.defs>
/*
* References to clock_priv objects are returned by:
* host_get_clock_control(host_priv_t,...) - Priviledged subclass
*/
/*
* Set the clock time.
* Privileged.
*/
routine clock_set_time(
clock_ctrl : clock_ctrl_t;
new_time : mach_timespec_t);
/*
* Set clock attributes.
* Privileged.
*/
routine clock_set_attributes(
clock_ctrl : clock_ctrl_t;
in flavor : clock_flavor_t;
in clock_attr : clock_attr_t);
/* vim: set ft=c : */

View File

@ -0,0 +1,199 @@
#ifndef _clock_priv_user_
#define _clock_priv_user_
/* Module clock_priv */
#include <string.h>
#include <mach/ndr.h>
#include <mach/boolean.h>
#include <mach/kern_return.h>
#include <mach/notify.h>
#include <mach/mach_types.h>
#include <mach/message.h>
#include <mach/mig_errors.h>
#include <mach/port.h>
/* BEGIN MIG_STRNCPY_ZEROFILL CODE */
#if defined(__has_include)
#if __has_include(<mach/mig_strncpy_zerofill_support.h>)
#ifndef USING_MIG_STRNCPY_ZEROFILL
#define USING_MIG_STRNCPY_ZEROFILL
#endif
#ifndef __MIG_STRNCPY_ZEROFILL_FORWARD_TYPE_DECLS__
#define __MIG_STRNCPY_ZEROFILL_FORWARD_TYPE_DECLS__
#ifdef __cplusplus
extern "C" {
#endif
extern int mig_strncpy_zerofill(char *dest, const char *src, int len) __attribute__((weak_import));
#ifdef __cplusplus
}
#endif
#endif /* __MIG_STRNCPY_ZEROFILL_FORWARD_TYPE_DECLS__ */
#endif /* __has_include(<mach/mig_strncpy_zerofill_support.h>) */
#endif /* __has_include */
/* END MIG_STRNCPY_ZEROFILL CODE */
#ifdef AUTOTEST
#ifndef FUNCTION_PTR_T
#define FUNCTION_PTR_T
typedef void (*function_ptr_t)(mach_port_t, char *, mach_msg_type_number_t);
typedef struct {
char *name;
function_ptr_t function;
} function_table_entry;
typedef function_table_entry *function_table_t;
#endif /* FUNCTION_PTR_T */
#endif /* AUTOTEST */
#ifndef clock_priv_MSG_COUNT
#define clock_priv_MSG_COUNT 2
#endif /* clock_priv_MSG_COUNT */
#include <mach/std_types.h>
#include <mach/mig.h>
#include <mach/mig.h>
#include <mach/mach_types.h>
#include <mach/mach_types.h>
#ifdef __BeforeMigUserHeader
__BeforeMigUserHeader
#endif /* __BeforeMigUserHeader */
#include <sys/cdefs.h>
__BEGIN_DECLS
/* Routine clock_set_time */
#ifdef mig_external
mig_external
#else
extern
#endif /* mig_external */
kern_return_t clock_set_time
(
clock_ctrl_t clock_ctrl,
mach_timespec_t new_time
);
/* Routine clock_set_attributes */
#ifdef mig_external
mig_external
#else
extern
#endif /* mig_external */
kern_return_t clock_set_attributes
(
clock_ctrl_t clock_ctrl,
clock_flavor_t flavor,
clock_attr_t clock_attr,
mach_msg_type_number_t clock_attrCnt
);
__END_DECLS
/********************** Caution **************************/
/* The following data types should be used to calculate */
/* maximum message sizes only. The actual message may be */
/* smaller, and the position of the arguments within the */
/* message layout may vary from what is presented here. */
/* For example, if any of the arguments are variable- */
/* sized, and less than the maximum is sent, the data */
/* will be packed tight in the actual message to reduce */
/* the presence of holes. */
/********************** Caution **************************/
/* typedefs for all requests */
#ifndef __Request__clock_priv_subsystem__defined
#define __Request__clock_priv_subsystem__defined
#ifdef __MigPackStructs
#pragma pack(push, 4)
#endif
typedef struct {
mach_msg_header_t Head;
NDR_record_t NDR;
mach_timespec_t new_time;
} __Request__clock_set_time_t __attribute__((unused));
#ifdef __MigPackStructs
#pragma pack(pop)
#endif
#ifdef __MigPackStructs
#pragma pack(push, 4)
#endif
typedef struct {
mach_msg_header_t Head;
NDR_record_t NDR;
clock_flavor_t flavor;
mach_msg_type_number_t clock_attrCnt;
int clock_attr[1];
} __Request__clock_set_attributes_t __attribute__((unused));
#ifdef __MigPackStructs
#pragma pack(pop)
#endif
#endif /* !__Request__clock_priv_subsystem__defined */
/* union of all requests */
#ifndef __RequestUnion__clock_priv_subsystem__defined
#define __RequestUnion__clock_priv_subsystem__defined
union __RequestUnion__clock_priv_subsystem {
__Request__clock_set_time_t Request_clock_set_time;
__Request__clock_set_attributes_t Request_clock_set_attributes;
};
#endif /* !__RequestUnion__clock_priv_subsystem__defined */
/* typedefs for all replies */
#ifndef __Reply__clock_priv_subsystem__defined
#define __Reply__clock_priv_subsystem__defined
#ifdef __MigPackStructs
#pragma pack(push, 4)
#endif
typedef struct {
mach_msg_header_t Head;
NDR_record_t NDR;
kern_return_t RetCode;
} __Reply__clock_set_time_t __attribute__((unused));
#ifdef __MigPackStructs
#pragma pack(pop)
#endif
#ifdef __MigPackStructs
#pragma pack(push, 4)
#endif
typedef struct {
mach_msg_header_t Head;
NDR_record_t NDR;
kern_return_t RetCode;
} __Reply__clock_set_attributes_t __attribute__((unused));
#ifdef __MigPackStructs
#pragma pack(pop)
#endif
#endif /* !__Reply__clock_priv_subsystem__defined */
/* union of all replies */
#ifndef __ReplyUnion__clock_priv_subsystem__defined
#define __ReplyUnion__clock_priv_subsystem__defined
union __ReplyUnion__clock_priv_subsystem {
__Reply__clock_set_time_t Reply_clock_set_time;
__Reply__clock_set_attributes_t Reply_clock_set_attributes;
};
#endif /* !__RequestUnion__clock_priv_subsystem__defined */
#ifndef subsystem_to_name_map_clock_priv
#define subsystem_to_name_map_clock_priv \
{ "clock_set_time", 1200 },\
{ "clock_set_attributes", 1201 }
#endif
#ifdef __AfterMigUserHeader
__AfterMigUserHeader
#endif /* __AfterMigUserHeader */
#endif /* _clock_priv_user_ */

View File

@ -0,0 +1,56 @@
/*
* Copyright (c) 2000 Apple Computer, Inc. All rights reserved.
*
* @APPLE_OSREFERENCE_LICENSE_HEADER_START@
*
* This file contains Original Code and/or Modifications of Original Code
* as defined in and that are subject to the Apple Public Source License
* Version 2.0 (the 'License'). You may not use this file except in
* compliance with the License. The rights granted to you under the License
* may not be used to create, or enable the creation or redistribution of,
* unlawful or unlicensed copies of an Apple operating system, or to
* circumvent, violate, or enable the circumvention or violation of, any
* terms of an Apple operating system software license agreement.
*
* Please obtain a copy of the License at
* http://www.opensource.apple.com/apsl/ and read it before using this file.
*
* The Original Code and all software distributed under the License are
* distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
* Please see the License for the specific language governing rights and
* limitations under the License.
*
* @APPLE_OSREFERENCE_LICENSE_HEADER_END@
*/
/*
* @OSF_COPYRIGHT@
*/
/*
* File: clock_reply.defs
* Purpose: Kernel clock subsystem definitions. This
* file defines the clock reply interface.
*/
subsystem
#if KERNEL_USER
KernelUser
#endif /* KERNEL_USER */
clock_reply 3125107; /* Matches up with old value */
#include <mach/std_types.defs>
#include <mach/clock_types.defs>
/*
* Reply routine for clock_alarm.
*/
simpleroutine clock_alarm_reply(
alarm_port : clock_reply_t;
alarm_code : kern_return_t;
alarm_type : alarm_type_t;
alarm_time : mach_timespec_t);
/* vim: set ft=c : */

View File

@ -0,0 +1,159 @@
#ifndef _clock_reply_user_
#define _clock_reply_user_
/* Module clock_reply */
#include <string.h>
#include <mach/ndr.h>
#include <mach/boolean.h>
#include <mach/kern_return.h>
#include <mach/notify.h>
#include <mach/mach_types.h>
#include <mach/message.h>
#include <mach/mig_errors.h>
#include <mach/port.h>
/* BEGIN MIG_STRNCPY_ZEROFILL CODE */
#if defined(__has_include)
#if __has_include(<mach/mig_strncpy_zerofill_support.h>)
#ifndef USING_MIG_STRNCPY_ZEROFILL
#define USING_MIG_STRNCPY_ZEROFILL
#endif
#ifndef __MIG_STRNCPY_ZEROFILL_FORWARD_TYPE_DECLS__
#define __MIG_STRNCPY_ZEROFILL_FORWARD_TYPE_DECLS__
#ifdef __cplusplus
extern "C" {
#endif
extern int mig_strncpy_zerofill(char *dest, const char *src, int len) __attribute__((weak_import));
#ifdef __cplusplus
}
#endif
#endif /* __MIG_STRNCPY_ZEROFILL_FORWARD_TYPE_DECLS__ */
#endif /* __has_include(<mach/mig_strncpy_zerofill_support.h>) */
#endif /* __has_include */
/* END MIG_STRNCPY_ZEROFILL CODE */
#ifdef AUTOTEST
#ifndef FUNCTION_PTR_T
#define FUNCTION_PTR_T
typedef void (*function_ptr_t)(mach_port_t, char *, mach_msg_type_number_t);
typedef struct {
char *name;
function_ptr_t function;
} function_table_entry;
typedef function_table_entry *function_table_t;
#endif /* FUNCTION_PTR_T */
#endif /* AUTOTEST */
#ifndef clock_reply_MSG_COUNT
#define clock_reply_MSG_COUNT 1
#endif /* clock_reply_MSG_COUNT */
#include <mach/std_types.h>
#include <mach/mig.h>
#include <mach/mach_types.h>
#ifdef __BeforeMigUserHeader
__BeforeMigUserHeader
#endif /* __BeforeMigUserHeader */
#include <sys/cdefs.h>
__BEGIN_DECLS
/* SimpleRoutine clock_alarm_reply */
#ifdef mig_external
mig_external
#else
extern
#endif /* mig_external */
kern_return_t clock_alarm_reply
(
clock_reply_t alarm_port,
mach_msg_type_name_t alarm_portPoly,
kern_return_t alarm_code,
alarm_type_t alarm_type,
mach_timespec_t alarm_time
);
__END_DECLS
/********************** Caution **************************/
/* The following data types should be used to calculate */
/* maximum message sizes only. The actual message may be */
/* smaller, and the position of the arguments within the */
/* message layout may vary from what is presented here. */
/* For example, if any of the arguments are variable- */
/* sized, and less than the maximum is sent, the data */
/* will be packed tight in the actual message to reduce */
/* the presence of holes. */
/********************** Caution **************************/
/* typedefs for all requests */
#ifndef __Request__clock_reply_subsystem__defined
#define __Request__clock_reply_subsystem__defined
#ifdef __MigPackStructs
#pragma pack(push, 4)
#endif
typedef struct {
mach_msg_header_t Head;
NDR_record_t NDR;
kern_return_t alarm_code;
alarm_type_t alarm_type;
mach_timespec_t alarm_time;
} __Request__clock_alarm_reply_t __attribute__((unused));
#ifdef __MigPackStructs
#pragma pack(pop)
#endif
#endif /* !__Request__clock_reply_subsystem__defined */
/* union of all requests */
#ifndef __RequestUnion__clock_reply_subsystem__defined
#define __RequestUnion__clock_reply_subsystem__defined
union __RequestUnion__clock_reply_subsystem {
__Request__clock_alarm_reply_t Request_clock_alarm_reply;
};
#endif /* !__RequestUnion__clock_reply_subsystem__defined */
/* typedefs for all replies */
#ifndef __Reply__clock_reply_subsystem__defined
#define __Reply__clock_reply_subsystem__defined
#ifdef __MigPackStructs
#pragma pack(push, 4)
#endif
typedef struct {
mach_msg_header_t Head;
NDR_record_t NDR;
kern_return_t RetCode;
} __Reply__clock_alarm_reply_t __attribute__((unused));
#ifdef __MigPackStructs
#pragma pack(pop)
#endif
#endif /* !__Reply__clock_reply_subsystem__defined */
/* union of all replies */
#ifndef __ReplyUnion__clock_reply_subsystem__defined
#define __ReplyUnion__clock_reply_subsystem__defined
union __ReplyUnion__clock_reply_subsystem {
__Reply__clock_alarm_reply_t Reply_clock_alarm_reply;
};
#endif /* !__RequestUnion__clock_reply_subsystem__defined */
#ifndef subsystem_to_name_map_clock_reply
#define subsystem_to_name_map_clock_reply \
{ "clock_alarm_reply", 3125107 }
#endif
#ifdef __AfterMigUserHeader
__AfterMigUserHeader
#endif /* __AfterMigUserHeader */
#endif /* _clock_reply_user_ */

View File

@ -0,0 +1,73 @@
/*
* Copyright (c) 2000 Apple Computer, Inc. All rights reserved.
*
* @APPLE_OSREFERENCE_LICENSE_HEADER_START@
*
* This file contains Original Code and/or Modifications of Original Code
* as defined in and that are subject to the Apple Public Source License
* Version 2.0 (the 'License'). You may not use this file except in
* compliance with the License. The rights granted to you under the License
* may not be used to create, or enable the creation or redistribution of,
* unlawful or unlicensed copies of an Apple operating system, or to
* circumvent, violate, or enable the circumvention or violation of, any
* terms of an Apple operating system software license agreement.
*
* Please obtain a copy of the License at
* http://www.opensource.apple.com/apsl/ and read it before using this file.
*
* The Original Code and all software distributed under the License are
* distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
* Please see the License for the specific language governing rights and
* limitations under the License.
*
* @APPLE_OSREFERENCE_LICENSE_HEADER_END@
*/
/*
* @OSF_COPYRIGHT@
*/
/*
* File: clock_types.defs
* Purpose:
* Clock kernel interface type declarations
*/
#ifndef _MACH_CLOCK_TYPES_DEFS_
#define _MACH_CLOCK_TYPES_DEFS_
#include <mach/std_types.defs>
type clock_serv_t = mach_port_t
cusertype: clock_serv_t
#if KERNEL_SERVER
intran: clock_serv_t convert_port_to_clock(mach_port_t)
outtran: mach_port_t convert_clock_to_port(clock_serv_t)
#endif /* KERNEL_SERVER */
;
type clock_ctrl_t = mach_port_t
cusertype: clock_ctrl_t
#if KERNEL_SERVER
intran: clock_ctrl_t convert_port_to_clock_ctrl(mach_port_t)
outtran: mach_port_t convert_clock_ctrl_to_port(clock_ctrl_t)
#endif /* KERNEL_SERVER */
;
type clock_reply_t = polymorphic|MACH_MSG_TYPE_MAKE_SEND_ONCE;
type clock_flavor_t = int;
type clock_attr_t = array[*:1] of int;
type mach_timespec_t = struct[2] of int;
type time_t = int;
type sleep_type_t = int;
type alarm_type_t = int;
type clock_res_t = int;
type clock_id_t = int;
import <mach/mach_types.h>;
#endif /* _MACH_CLOCK_TYPES_DEFS_ */
/* vim: set ft=c : */

View File

@ -0,0 +1,127 @@
/*
* Copyright (c) 2000 Apple Computer, Inc. All rights reserved.
*
* @APPLE_OSREFERENCE_LICENSE_HEADER_START@
*
* This file contains Original Code and/or Modifications of Original Code
* as defined in and that are subject to the Apple Public Source License
* Version 2.0 (the 'License'). You may not use this file except in
* compliance with the License. The rights granted to you under the License
* may not be used to create, or enable the creation or redistribution of,
* unlawful or unlicensed copies of an Apple operating system, or to
* circumvent, violate, or enable the circumvention or violation of, any
* terms of an Apple operating system software license agreement.
*
* Please obtain a copy of the License at
* http://www.opensource.apple.com/apsl/ and read it before using this file.
*
* The Original Code and all software distributed under the License are
* distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
* Please see the License for the specific language governing rights and
* limitations under the License.
*
* @APPLE_OSREFERENCE_LICENSE_HEADER_END@
*/
/*
* @OSF_COPYRIGHT@
*/
/*
* File: clock_types.h
* Purpose: Clock facility header definitions. These
* definitons are needed by both kernel and
* user-level software.
*/
/*
* All interfaces defined here are obsolete.
*/
#ifndef _MACH_CLOCK_TYPES_H_
#define _MACH_CLOCK_TYPES_H_
#include <stdint.h>
#include <mach/time_value.h>
/*
* Type definitions.
*/
typedef int alarm_type_t; /* alarm time type */
typedef int sleep_type_t; /* sleep time type */
typedef int clock_id_t; /* clock identification type */
typedef int clock_flavor_t; /* clock flavor type */
typedef int *clock_attr_t; /* clock attribute type */
typedef int clock_res_t; /* clock resolution type */
/*
* Normal time specification used by the kernel clock facility.
*/
struct mach_timespec {
unsigned int tv_sec; /* seconds */
clock_res_t tv_nsec; /* nanoseconds */
};
typedef struct mach_timespec mach_timespec_t;
/*
* Reserved clock id values for default clocks.
*/
#define SYSTEM_CLOCK 0
#define CALENDAR_CLOCK 1
#define REALTIME_CLOCK 0
/*
* Attribute names.
*/
#define CLOCK_GET_TIME_RES 1 /* get_time call resolution */
/* 2 * was map_time call resolution */
#define CLOCK_ALARM_CURRES 3 /* current alarm resolution */
#define CLOCK_ALARM_MINRES 4 /* minimum alarm resolution */
#define CLOCK_ALARM_MAXRES 5 /* maximum alarm resolution */
#define NSEC_PER_USEC 1000ull /* nanoseconds per microsecond */
#define USEC_PER_SEC 1000000ull /* microseconds per second */
#define NSEC_PER_SEC 1000000000ull /* nanoseconds per second */
#define NSEC_PER_MSEC 1000000ull /* nanoseconds per millisecond */
#define BAD_MACH_TIMESPEC(t) \
((t)->tv_nsec < 0 || (t)->tv_nsec >= (long)NSEC_PER_SEC)
/* t1 <=> t2, also (t1 - t2) in nsec with max of +- 1 sec */
#define CMP_MACH_TIMESPEC(t1, t2) \
((t1)->tv_sec > (t2)->tv_sec ? (long) +NSEC_PER_SEC : \
((t1)->tv_sec < (t2)->tv_sec ? (long) -NSEC_PER_SEC : \
(t1)->tv_nsec - (t2)->tv_nsec))
/* t1 += t2 */
#define ADD_MACH_TIMESPEC(t1, t2) \
do { \
if (((t1)->tv_nsec += (t2)->tv_nsec) >= (long) NSEC_PER_SEC) { \
(t1)->tv_nsec -= (long) NSEC_PER_SEC; \
(t1)->tv_sec += 1; \
} \
(t1)->tv_sec += (t2)->tv_sec; \
} while (0)
/* t1 -= t2 */
#define SUB_MACH_TIMESPEC(t1, t2) \
do { \
if (((t1)->tv_nsec -= (t2)->tv_nsec) < 0) { \
(t1)->tv_nsec += (long) NSEC_PER_SEC; \
(t1)->tv_sec -= 1; \
} \
(t1)->tv_sec -= (t2)->tv_sec; \
} while (0)
/*
* Alarm parameter defines.
*/
#define ALRMTYPE 0xff /* type (8-bit field) */
#define TIME_ABSOLUTE 0x00 /* absolute time */
#define TIME_RELATIVE 0x01 /* relative time */
#define BAD_ALRMTYPE(t) (((t) &~ TIME_RELATIVE) != 0)
#endif /* _MACH_CLOCK_TYPES_H_ */

View File

@ -0,0 +1,66 @@
/*
* Copyright (c) 2016 Apple Computer, Inc. All rights reserved.
*
* @APPLE_OSREFERENCE_LICENSE_HEADER_START@
*
* This file contains Original Code and/or Modifications of Original Code
* as defined in and that are subject to the Apple Public Source License
* Version 2.0 (the 'License'). You may not use this file except in
* compliance with the License. The rights granted to you under the License
* may not be used to create, or enable the creation or redistribution of,
* unlawful or unlicensed copies of an Apple operating system, or to
* circumvent, violate, or enable the circumvention or violation of, any
* terms of an Apple operating system software license agreement.
*
* Please obtain a copy of the License at
* http://www.opensource.apple.com/apsl/ and read it before using this file.
*
* The Original Code and all software distributed under the License are
* distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
* Please see the License for the specific language governing rights and
* limitations under the License.
*
* @APPLE_OSREFERENCE_LICENSE_HEADER_END@
*/
#ifndef _MACH_DYLIB_INFO_H_
#define _MACH_DYLIB_INFO_H_
#include <mach/boolean.h>
#include <stdint.h>
#include <sys/_types/_fsid_t.h>
#include <sys/_types/_u_int32_t.h>
#include <sys/_types/_fsobj_id_t.h>
#include <sys/_types/_uuid_t.h>
/* These definitions must be kept in sync with the ones in
* osfmk/mach/mach_types.defs.
*/
struct dyld_kernel_image_info {
uuid_t uuid;
fsobj_id_t fsobjid;
fsid_t fsid;
uint64_t load_addr;
};
struct dyld_kernel_process_info {
struct dyld_kernel_image_info cache_image_info;
uint64_t timestamp; // mach_absolute_time of last time dyld change to image list
uint32_t imageCount; // number of images currently loaded into process
uint32_t initialImageCount; // number of images statically loaded into process (before any dlopen() calls)
uint8_t dyldState; // one of dyld_process_state_* values
boolean_t no_cache; // process is running without a dyld cache
boolean_t private_cache; // process is using a private copy of its dyld cache
};
/* typedefs so our MIG is sane */
typedef struct dyld_kernel_image_info dyld_kernel_image_info_t;
typedef struct dyld_kernel_process_info dyld_kernel_process_info_t;
typedef dyld_kernel_image_info_t *dyld_kernel_image_info_array_t;
#endif /* _MACH_DYLIB_INFO_H_ */

View File

@ -0,0 +1,114 @@
/*
* Copyright (c) 2000 Apple Computer, Inc. All rights reserved.
*
* @APPLE_OSREFERENCE_LICENSE_HEADER_START@
*
* This file contains Original Code and/or Modifications of Original Code
* as defined in and that are subject to the Apple Public Source License
* Version 2.0 (the 'License'). You may not use this file except in
* compliance with the License. The rights granted to you under the License
* may not be used to create, or enable the creation or redistribution of,
* unlawful or unlicensed copies of an Apple operating system, or to
* circumvent, violate, or enable the circumvention or violation of, any
* terms of an Apple operating system software license agreement.
*
* Please obtain a copy of the License at
* http://www.opensource.apple.com/apsl/ and read it before using this file.
*
* The Original Code and all software distributed under the License are
* distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
* Please see the License for the specific language governing rights and
* limitations under the License.
*
* @APPLE_OSREFERENCE_LICENSE_HEADER_END@
*/
/*
* @OSF_COPYRIGHT@
*/
/*
* Mach Operating System
* Copyright (c) 1991,1990,1989,1988,1987 Carnegie Mellon University
* All Rights Reserved.
*
* Permission to use, copy, modify and distribute this software and its
* documentation is hereby granted, provided that both the copyright
* notice and this permission notice appear in all copies of the
* software, derivative works or modified versions, and any portions
* thereof, and that both notices appear in supporting documentation.
*
* CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
* CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR
* ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
*
* Carnegie Mellon requests users of this software to return to
*
* Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU
* School of Computer Science
* Carnegie Mellon University
* Pittsburgh PA 15213-3890
*
* any improvements or extensions that they make and grant Carnegie Mellon
* the rights to redistribute these changes.
*/
/*
*/
/*
* File: mach/error.h
* Purpose:
* error module definitions
*
*/
#ifndef _MACH_ERROR_H_
#define _MACH_ERROR_H_
#include <mach/kern_return.h>
/*
* error number layout as follows:
*
* hi lo
* | system(6) | subsystem(12) | code(14) |
*/
#define err_none (mach_error_t)0
#define ERR_SUCCESS (mach_error_t)0
#define ERR_ROUTINE_NIL (mach_error_fn_t)0
#define err_system(x) ((signed)((((unsigned)(x))&0x3f)<<26))
#define err_sub(x) (((x)&0xfff)<<14)
#define err_get_system(err) (((err)>>26)&0x3f)
#define err_get_sub(err) (((err)>>14)&0xfff)
#define err_get_code(err) ((err)&0x3fff)
#define system_emask (err_system(0x3f))
#define sub_emask (err_sub(0xfff))
#define code_emask (0x3fff)
/* major error systems */
#define err_kern err_system(0x0) /* kernel */
#define err_us err_system(0x1) /* user space library */
#define err_server err_system(0x2) /* user space servers */
#define err_ipc err_system(0x3) /* old ipc errors */
#define err_mach_ipc err_system(0x4) /* mach-ipc errors */
#define err_dipc err_system(0x7) /* distributed ipc */
#define err_local err_system(0x3e) /* user defined errors */
#define err_ipc_compat err_system(0x3f) /* (compatibility) mach-ipc errors */
#define err_max_system 0x3f
/* unix errors get lumped into one subsystem */
#define unix_err(errno) (err_kern|err_sub(3)|errno)
typedef kern_return_t mach_error_t;
typedef mach_error_t (* mach_error_fn_t)( void );
#endif /* _MACH_ERROR_H_ */

View File

@ -0,0 +1,133 @@
/*
* Copyright (c) 2000 Apple Computer, Inc. All rights reserved.
*
* @APPLE_OSREFERENCE_LICENSE_HEADER_START@
*
* This file contains Original Code and/or Modifications of Original Code
* as defined in and that are subject to the Apple Public Source License
* Version 2.0 (the 'License'). You may not use this file except in
* compliance with the License. The rights granted to you under the License
* may not be used to create, or enable the creation or redistribution of,
* unlawful or unlicensed copies of an Apple operating system, or to
* circumvent, violate, or enable the circumvention or violation of, any
* terms of an Apple operating system software license agreement.
*
* Please obtain a copy of the License at
* http://www.opensource.apple.com/apsl/ and read it before using this file.
*
* The Original Code and all software distributed under the License are
* distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
* Please see the License for the specific language governing rights and
* limitations under the License.
*
* @APPLE_OSREFERENCE_LICENSE_HEADER_END@
*/
/*
* @OSF_COPYRIGHT@
*/
/*
* Mach Operating System
* Copyright (c) 1991,1990,1989,1988,1987 Carnegie Mellon University
* All Rights Reserved.
*
* Permission to use, copy, modify and distribute this software and its
* documentation is hereby granted, provided that both the copyright
* notice and this permission notice appear in all copies of the
* software, derivative works or modified versions, and any portions
* thereof, and that both notices appear in supporting documentation.
*
* CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
* CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR
* ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
*
* Carnegie Mellon requests users of this software to return to
*
* Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU
* School of Computer Science
* Carnegie Mellon University
* Pittsburgh PA 15213-3890
*
* any improvements or extensions that they make and grant Carnegie Mellon
* the rights to redistribute these changes.
*/
/*
*/
/*
* Abstract:
* MiG definitions file for Mach exception interface.
*/
subsystem
#if KERNEL_SERVER
KernelServer
#endif /* KERNEL_SERVER */
#if KERNEL_USER
KernelUser
#endif
exc 2401;
#include <mach/std_types.defs>
#include <mach/mach_types.defs>
ServerPrefix catch_;
type exception_data_t = array[*:2] of integer_t;
type exception_type_t = int;
routine exception_raise(
exception_port : mach_port_t;
thread : mach_port_t;
task : mach_port_t;
exception : exception_type_t;
code : exception_data_t
#if EXC_SERVER_SECTOKEN
;
ServerSecToken stoken : security_token_t
#endif
#if EXC_SERVER_AUDITTOKEN
;
ServerAuditToken atoken: audit_token_t
#endif
);
routine exception_raise_state(
exception_port : mach_port_t;
exception : exception_type_t;
code : exception_data_t, const;
inout flavor : int;
old_state : thread_state_t, const;
out new_state : thread_state_t
#if EXC_SERVER_SECTOKEN
;
ServerSecToken stoken : security_token_t
#endif
#if EXC_SERVER_AUDITTOKEN
;
ServerAuditToken atoken: audit_token_t
#endif
);
routine exception_raise_state_identity(
exception_port : mach_port_t;
thread : mach_port_t;
task : mach_port_t;
exception : exception_type_t;
code : exception_data_t;
inout flavor : int;
old_state : thread_state_t;
out new_state : thread_state_t
#if EXC_SERVER_SECTOKEN
;
ServerSecToken stoken : security_token_t
#endif
#if EXC_SERVER_AUDITTOKEN
;
ServerAuditToken atoken: audit_token_t
#endif
);
/* vim: set ft=c : */

281
ref/Apple/MachO/mach/exc.h Normal file
View File

@ -0,0 +1,281 @@
#ifndef _exc_user_
#define _exc_user_
/* Module exc */
#include <string.h>
#include <mach/ndr.h>
#include <mach/boolean.h>
#include <mach/kern_return.h>
#include <mach/notify.h>
#include <mach/mach_types.h>
#include <mach/message.h>
#include <mach/mig_errors.h>
#include <mach/port.h>
/* BEGIN MIG_STRNCPY_ZEROFILL CODE */
#if defined(__has_include)
#if __has_include(<mach/mig_strncpy_zerofill_support.h>)
#ifndef USING_MIG_STRNCPY_ZEROFILL
#define USING_MIG_STRNCPY_ZEROFILL
#endif
#ifndef __MIG_STRNCPY_ZEROFILL_FORWARD_TYPE_DECLS__
#define __MIG_STRNCPY_ZEROFILL_FORWARD_TYPE_DECLS__
#ifdef __cplusplus
extern "C" {
#endif
extern int mig_strncpy_zerofill(char *dest, const char *src, int len) __attribute__((weak_import));
#ifdef __cplusplus
}
#endif
#endif /* __MIG_STRNCPY_ZEROFILL_FORWARD_TYPE_DECLS__ */
#endif /* __has_include(<mach/mig_strncpy_zerofill_support.h>) */
#endif /* __has_include */
/* END MIG_STRNCPY_ZEROFILL CODE */
#ifdef AUTOTEST
#ifndef FUNCTION_PTR_T
#define FUNCTION_PTR_T
typedef void (*function_ptr_t)(mach_port_t, char *, mach_msg_type_number_t);
typedef struct {
char *name;
function_ptr_t function;
} function_table_entry;
typedef function_table_entry *function_table_t;
#endif /* FUNCTION_PTR_T */
#endif /* AUTOTEST */
#ifndef exc_MSG_COUNT
#define exc_MSG_COUNT 3
#endif /* exc_MSG_COUNT */
#include <mach/std_types.h>
#include <mach/mig.h>
#include <mach/mig.h>
#include <mach/mach_types.h>
#ifdef __BeforeMigUserHeader
__BeforeMigUserHeader
#endif /* __BeforeMigUserHeader */
#include <sys/cdefs.h>
__BEGIN_DECLS
/* Routine exception_raise */
#ifdef mig_external
mig_external
#else
extern
#endif /* mig_external */
kern_return_t exception_raise
(
mach_port_t exception_port,
mach_port_t thread,
mach_port_t task,
exception_type_t exception,
exception_data_t code,
mach_msg_type_number_t codeCnt
);
/* Routine exception_raise_state */
#ifdef mig_external
mig_external
#else
extern
#endif /* mig_external */
kern_return_t exception_raise_state
(
mach_port_t exception_port,
exception_type_t exception,
const exception_data_t code,
mach_msg_type_number_t codeCnt,
int *flavor,
const thread_state_t old_state,
mach_msg_type_number_t old_stateCnt,
thread_state_t new_state,
mach_msg_type_number_t *new_stateCnt
);
/* Routine exception_raise_state_identity */
#ifdef mig_external
mig_external
#else
extern
#endif /* mig_external */
kern_return_t exception_raise_state_identity
(
mach_port_t exception_port,
mach_port_t thread,
mach_port_t task,
exception_type_t exception,
exception_data_t code,
mach_msg_type_number_t codeCnt,
int *flavor,
thread_state_t old_state,
mach_msg_type_number_t old_stateCnt,
thread_state_t new_state,
mach_msg_type_number_t *new_stateCnt
);
__END_DECLS
/********************** Caution **************************/
/* The following data types should be used to calculate */
/* maximum message sizes only. The actual message may be */
/* smaller, and the position of the arguments within the */
/* message layout may vary from what is presented here. */
/* For example, if any of the arguments are variable- */
/* sized, and less than the maximum is sent, the data */
/* will be packed tight in the actual message to reduce */
/* the presence of holes. */
/********************** Caution **************************/
/* typedefs for all requests */
#ifndef __Request__exc_subsystem__defined
#define __Request__exc_subsystem__defined
#ifdef __MigPackStructs
#pragma pack(push, 4)
#endif
typedef struct {
mach_msg_header_t Head;
/* start of the kernel processed data */
mach_msg_body_t msgh_body;
mach_msg_port_descriptor_t thread;
mach_msg_port_descriptor_t task;
/* end of the kernel processed data */
NDR_record_t NDR;
exception_type_t exception;
mach_msg_type_number_t codeCnt;
integer_t code[2];
} __Request__exception_raise_t __attribute__((unused));
#ifdef __MigPackStructs
#pragma pack(pop)
#endif
#ifdef __MigPackStructs
#pragma pack(push, 4)
#endif
typedef struct {
mach_msg_header_t Head;
NDR_record_t NDR;
exception_type_t exception;
mach_msg_type_number_t codeCnt;
integer_t code[2];
int flavor;
mach_msg_type_number_t old_stateCnt;
natural_t old_state[1296];
} __Request__exception_raise_state_t __attribute__((unused));
#ifdef __MigPackStructs
#pragma pack(pop)
#endif
#ifdef __MigPackStructs
#pragma pack(push, 4)
#endif
typedef struct {
mach_msg_header_t Head;
/* start of the kernel processed data */
mach_msg_body_t msgh_body;
mach_msg_port_descriptor_t thread;
mach_msg_port_descriptor_t task;
/* end of the kernel processed data */
NDR_record_t NDR;
exception_type_t exception;
mach_msg_type_number_t codeCnt;
integer_t code[2];
int flavor;
mach_msg_type_number_t old_stateCnt;
natural_t old_state[1296];
} __Request__exception_raise_state_identity_t __attribute__((unused));
#ifdef __MigPackStructs
#pragma pack(pop)
#endif
#endif /* !__Request__exc_subsystem__defined */
/* union of all requests */
#ifndef __RequestUnion__exc_subsystem__defined
#define __RequestUnion__exc_subsystem__defined
union __RequestUnion__exc_subsystem {
__Request__exception_raise_t Request_exception_raise;
__Request__exception_raise_state_t Request_exception_raise_state;
__Request__exception_raise_state_identity_t Request_exception_raise_state_identity;
};
#endif /* !__RequestUnion__exc_subsystem__defined */
/* typedefs for all replies */
#ifndef __Reply__exc_subsystem__defined
#define __Reply__exc_subsystem__defined
#ifdef __MigPackStructs
#pragma pack(push, 4)
#endif
typedef struct {
mach_msg_header_t Head;
NDR_record_t NDR;
kern_return_t RetCode;
} __Reply__exception_raise_t __attribute__((unused));
#ifdef __MigPackStructs
#pragma pack(pop)
#endif
#ifdef __MigPackStructs
#pragma pack(push, 4)
#endif
typedef struct {
mach_msg_header_t Head;
NDR_record_t NDR;
kern_return_t RetCode;
int flavor;
mach_msg_type_number_t new_stateCnt;
natural_t new_state[1296];
} __Reply__exception_raise_state_t __attribute__((unused));
#ifdef __MigPackStructs
#pragma pack(pop)
#endif
#ifdef __MigPackStructs
#pragma pack(push, 4)
#endif
typedef struct {
mach_msg_header_t Head;
NDR_record_t NDR;
kern_return_t RetCode;
int flavor;
mach_msg_type_number_t new_stateCnt;
natural_t new_state[1296];
} __Reply__exception_raise_state_identity_t __attribute__((unused));
#ifdef __MigPackStructs
#pragma pack(pop)
#endif
#endif /* !__Reply__exc_subsystem__defined */
/* union of all replies */
#ifndef __ReplyUnion__exc_subsystem__defined
#define __ReplyUnion__exc_subsystem__defined
union __ReplyUnion__exc_subsystem {
__Reply__exception_raise_t Reply_exception_raise;
__Reply__exception_raise_state_t Reply_exception_raise_state;
__Reply__exception_raise_state_identity_t Reply_exception_raise_state_identity;
};
#endif /* !__RequestUnion__exc_subsystem__defined */
#ifndef subsystem_to_name_map_exc
#define subsystem_to_name_map_exc \
{ "exception_raise", 2401 },\
{ "exception_raise_state", 2402 },\
{ "exception_raise_state_identity", 2403 }
#endif
#ifdef __AfterMigUserHeader
__AfterMigUserHeader
#endif /* __AfterMigUserHeader */
#endif /* _exc_user_ */

View File

@ -0,0 +1,62 @@
/*
* Copyright (c) 2000 Apple Computer, Inc. All rights reserved.
*
* @APPLE_OSREFERENCE_LICENSE_HEADER_START@
*
* This file contains Original Code and/or Modifications of Original Code
* as defined in and that are subject to the Apple Public Source License
* Version 2.0 (the 'License'). You may not use this file except in
* compliance with the License. The rights granted to you under the License
* may not be used to create, or enable the creation or redistribution of,
* unlawful or unlicensed copies of an Apple operating system, or to
* circumvent, violate, or enable the circumvention or violation of, any
* terms of an Apple operating system software license agreement.
*
* Please obtain a copy of the License at
* http://www.opensource.apple.com/apsl/ and read it before using this file.
*
* The Original Code and all software distributed under the License are
* distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
* Please see the License for the specific language governing rights and
* limitations under the License.
*
* @APPLE_OSREFERENCE_LICENSE_HEADER_END@
*/
/*
* @OSF_COPYRIGHT@
*/
/*
* Mach Operating System
* Copyright (c) 1991,1990,1989,1988,1987 Carnegie Mellon University
* All Rights Reserved.
*
* Permission to use, copy, modify and distribute this software and its
* documentation is hereby granted, provided that both the copyright
* notice and this permission notice appear in all copies of the
* software, derivative works or modified versions, and any portions
* thereof, and that both notices appear in supporting documentation.
*
* CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
* CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR
* ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
*
* Carnegie Mellon requests users of this software to return to
*
* Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU
* School of Computer Science
* Carnegie Mellon University
* Pittsburgh PA 15213-3890
*
* any improvements or extensions that they make and grant Carnegie Mellon
* the rights to redistribute these changes.
*/
#ifndef _MACH_EXCEPTION_H_
#define _MACH_EXCEPTION_H_
#include <mach/exception_types.h>
#endif /* _MACH_EXCEPTION_H_ */

View File

@ -0,0 +1,206 @@
/*
* Copyright (c) 2000 Apple Computer, Inc. All rights reserved.
*
* @APPLE_OSREFERENCE_LICENSE_HEADER_START@
*
* This file contains Original Code and/or Modifications of Original Code
* as defined in and that are subject to the Apple Public Source License
* Version 2.0 (the 'License'). You may not use this file except in
* compliance with the License. The rights granted to you under the License
* may not be used to create, or enable the creation or redistribution of,
* unlawful or unlicensed copies of an Apple operating system, or to
* circumvent, violate, or enable the circumvention or violation of, any
* terms of an Apple operating system software license agreement.
*
* Please obtain a copy of the License at
* http://www.opensource.apple.com/apsl/ and read it before using this file.
*
* The Original Code and all software distributed under the License are
* distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
* Please see the License for the specific language governing rights and
* limitations under the License.
*
* @APPLE_OSREFERENCE_LICENSE_HEADER_END@
*/
/*
* @OSF_COPYRIGHT@
*/
/*
* Mach Operating System
* Copyright (c) 1991,1990,1989,1988,1987 Carnegie Mellon University
* All Rights Reserved.
*
* Permission to use, copy, modify and distribute this software and its
* documentation is hereby granted, provided that both the copyright
* notice and this permission notice appear in all copies of the
* software, derivative works or modified versions, and any portions
* thereof, and that both notices appear in supporting documentation.
*
* CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
* CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR
* ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
*
* Carnegie Mellon requests users of this software to return to
*
* Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU
* School of Computer Science
* Carnegie Mellon University
* Pittsburgh PA 15213-3890
*
* any improvements or extensions that they make and grant Carnegie Mellon
* the rights to redistribute these changes.
*/
/*
*/
#ifndef _MACH_EXCEPTION_TYPES_H_
#define _MACH_EXCEPTION_TYPES_H_
#include <mach/machine/exception.h>
/*
* Machine-independent exception definitions.
*/
#define EXC_BAD_ACCESS 1 /* Could not access memory */
/* Code contains kern_return_t describing error. */
/* Subcode contains bad memory address. */
#define EXC_BAD_INSTRUCTION 2 /* Instruction failed */
/* Illegal or undefined instruction or operand */
#define EXC_ARITHMETIC 3 /* Arithmetic exception */
/* Exact nature of exception is in code field */
#define EXC_EMULATION 4 /* Emulation instruction */
/* Emulation support instruction encountered */
/* Details in code and subcode fields */
#define EXC_SOFTWARE 5 /* Software generated exception */
/* Exact exception is in code field. */
/* Codes 0 - 0xFFFF reserved to hardware */
/* Codes 0x10000 - 0x1FFFF reserved for OS emulation (Unix) */
#define EXC_BREAKPOINT 6 /* Trace, breakpoint, etc. */
/* Details in code field. */
#define EXC_SYSCALL 7 /* System calls. */
#define EXC_MACH_SYSCALL 8 /* Mach system calls. */
#define EXC_RPC_ALERT 9 /* RPC alert */
#define EXC_CRASH 10 /* Abnormal process exit */
#define EXC_RESOURCE 11 /* Hit resource consumption limit */
/* Exact resource is in code field. */
#define EXC_GUARD 12 /* Violated guarded resource protections */
#define EXC_CORPSE_NOTIFY 13 /* Abnormal process exited to corpse state */
#define EXC_CORPSE_VARIANT_BIT 0x100 /* bit set for EXC_*_CORPSE variants of EXC_* */
/*
* Machine-independent exception behaviors
*/
# define EXCEPTION_DEFAULT 1
/* Send a catch_exception_raise message including the identity.
*/
# define EXCEPTION_STATE 2
/* Send a catch_exception_raise_state message including the
* thread state.
*/
# define EXCEPTION_STATE_IDENTITY 3
/* Send a catch_exception_raise_state_identity message including
* the thread identity and state.
*/
#define MACH_EXCEPTION_ERRORS 0x40000000
/* include additional exception specific errors, not used yet. */
#define MACH_EXCEPTION_CODES 0x80000000
/* Send 64-bit code and subcode in the exception header */
#define MACH_EXCEPTION_MASK (MACH_EXCEPTION_CODES | MACH_EXCEPTION_ERRORS)
/*
* Masks for exception definitions, above
* bit zero is unused, therefore 1 word = 31 exception types
*/
#define EXC_MASK_BAD_ACCESS (1 << EXC_BAD_ACCESS)
#define EXC_MASK_BAD_INSTRUCTION (1 << EXC_BAD_INSTRUCTION)
#define EXC_MASK_ARITHMETIC (1 << EXC_ARITHMETIC)
#define EXC_MASK_EMULATION (1 << EXC_EMULATION)
#define EXC_MASK_SOFTWARE (1 << EXC_SOFTWARE)
#define EXC_MASK_BREAKPOINT (1 << EXC_BREAKPOINT)
#define EXC_MASK_SYSCALL (1 << EXC_SYSCALL)
#define EXC_MASK_MACH_SYSCALL (1 << EXC_MACH_SYSCALL)
#define EXC_MASK_RPC_ALERT (1 << EXC_RPC_ALERT)
#define EXC_MASK_CRASH (1 << EXC_CRASH)
#define EXC_MASK_RESOURCE (1 << EXC_RESOURCE)
#define EXC_MASK_GUARD (1 << EXC_GUARD)
#define EXC_MASK_CORPSE_NOTIFY (1 << EXC_CORPSE_NOTIFY)
#define EXC_MASK_ALL (EXC_MASK_BAD_ACCESS | \
EXC_MASK_BAD_INSTRUCTION | \
EXC_MASK_ARITHMETIC | \
EXC_MASK_EMULATION | \
EXC_MASK_SOFTWARE | \
EXC_MASK_BREAKPOINT | \
EXC_MASK_SYSCALL | \
EXC_MASK_MACH_SYSCALL | \
EXC_MASK_RPC_ALERT | \
EXC_MASK_RESOURCE | \
EXC_MASK_GUARD | \
EXC_MASK_MACHINE)
#define FIRST_EXCEPTION 1 /* ZERO is illegal */
/*
* Machine independent codes for EXC_SOFTWARE
* Codes 0x10000 - 0x1FFFF reserved for OS emulation (Unix)
* 0x10000 - 0x10002 in use for unix signals
* 0x20000 - 0x2FFFF reserved for MACF
*/
#define EXC_SOFT_SIGNAL 0x10003 /* Unix signal exceptions */
#define EXC_MACF_MIN 0x20000 /* MACF exceptions */
#define EXC_MACF_MAX 0x2FFFF
#ifndef ASSEMBLER
#include <mach/port.h>
#include <mach/thread_status.h>
#include <mach/machine/vm_types.h>
#include <mach_debug/ipc_info.h>
/*
* Exported types
*/
typedef int exception_type_t;
typedef integer_t exception_data_type_t;
typedef int64_t mach_exception_data_type_t;
typedef int exception_behavior_t;
typedef exception_data_type_t *exception_data_t;
typedef mach_exception_data_type_t *mach_exception_data_t;
typedef unsigned int exception_mask_t;
typedef exception_mask_t *exception_mask_array_t;
typedef exception_behavior_t *exception_behavior_array_t;
typedef thread_state_flavor_t *exception_flavor_array_t;
typedef mach_port_t *exception_port_array_t;
typedef ipc_info_port_t *exception_port_info_array_t;
typedef mach_exception_data_type_t mach_exception_code_t;
typedef mach_exception_data_type_t mach_exception_subcode_t;
#endif /* ASSEMBLER */
#endif /* _MACH_EXCEPTION_TYPES_H_ */

View File

@ -0,0 +1,260 @@
/*
* Copyright (c) 2000-2015 Apple Inc. All rights reserved.
*
* @APPLE_OSREFERENCE_LICENSE_HEADER_START@
*
* This file contains Original Code and/or Modifications of Original Code
* as defined in and that are subject to the Apple Public Source License
* Version 2.0 (the 'License'). You may not use this file except in
* compliance with the License. The rights granted to you under the License
* may not be used to create, or enable the creation or redistribution of,
* unlawful or unlicensed copies of an Apple operating system, or to
* circumvent, violate, or enable the circumvention or violation of, any
* terms of an Apple operating system software license agreement.
*
* Please obtain a copy of the License at
* http://www.opensource.apple.com/apsl/ and read it before using this file.
*
* The Original Code and all software distributed under the License are
* distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
* Please see the License for the specific language governing rights and
* limitations under the License.
*
* @APPLE_OSREFERENCE_LICENSE_HEADER_END@
*/
/*
* @OSF_COPYRIGHT@
*/
/*
* Mach Operating System
* Copyright (c) 1991,1990,1989,1988 Carnegie Mellon University
* All Rights Reserved.
*
* Permission to use, copy, modify and distribute this software and its
* documentation is hereby granted, provided that both the copyright
* notice and this permission notice appear in all copies of the
* software, derivative works or modified versions, and any portions
* thereof, and that both notices appear in supporting documentation.
*
* CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
* CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR
* ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
*
* Carnegie Mellon requests users of this software to return to
*
* Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU
* School of Computer Science
* Carnegie Mellon University
* Pittsburgh PA 15213-3890
*
* any improvements or extensions that they make and grant Carnegie Mellon
* the rights to redistribute these changes.
*/
/*
* File: mach/host_info.h
*
* Definitions for host_info call.
*/
#ifndef _MACH_HOST_INFO_H_
#define _MACH_HOST_INFO_H_
#include <mach/message.h>
#include <mach/vm_statistics.h>
#include <mach/machine.h>
#include <mach/machine/vm_types.h>
#include <mach/time_value.h>
#include <sys/cdefs.h>
/*
* Generic information structure to allow for expansion.
*/
typedef integer_t *host_info_t; /* varying array of int. */
typedef integer_t *host_info64_t; /* varying array of int. */
#define HOST_INFO_MAX (1024) /* max array size */
typedef integer_t host_info_data_t[HOST_INFO_MAX];
#define KERNEL_VERSION_MAX (512)
typedef char kernel_version_t[KERNEL_VERSION_MAX];
#define KERNEL_BOOT_INFO_MAX (4096)
typedef char kernel_boot_info_t[KERNEL_BOOT_INFO_MAX];
/*
* Currently defined information.
*/
/* host_info() */
typedef integer_t host_flavor_t;
#define HOST_BASIC_INFO 1 /* basic info */
#define HOST_SCHED_INFO 3 /* scheduling info */
#define HOST_RESOURCE_SIZES 4 /* kernel struct sizes */
#define HOST_PRIORITY_INFO 5 /* priority information */
#define HOST_SEMAPHORE_TRAPS 7 /* Has semaphore traps */
#define HOST_MACH_MSG_TRAP 8 /* Has mach_msg_trap */
#define HOST_VM_PURGABLE 9 /* purg'e'able memory info */
#define HOST_DEBUG_INFO_INTERNAL 10 /* Used for kernel internal development tests only */
#define HOST_CAN_HAS_DEBUGGER 11
#define HOST_PREFERRED_USER_ARCH 12 /* Get the preferred user-space architecture */
struct host_can_has_debugger_info {
boolean_t can_has_debugger;
};
typedef struct host_can_has_debugger_info host_can_has_debugger_info_data_t;
typedef struct host_can_has_debugger_info *host_can_has_debugger_info_t;
#define HOST_CAN_HAS_DEBUGGER_COUNT ((mach_msg_type_number_t) \
(sizeof(host_can_has_debugger_info_data_t)/sizeof(integer_t)))
#pragma pack(push, 4)
struct host_basic_info {
integer_t max_cpus; /* max number of CPUs possible */
integer_t avail_cpus; /* number of CPUs now available */
natural_t memory_size; /* size of memory in bytes, capped at 2 GB */
cpu_type_t cpu_type; /* cpu type */
cpu_subtype_t cpu_subtype; /* cpu subtype */
cpu_threadtype_t cpu_threadtype; /* cpu threadtype */
integer_t physical_cpu; /* number of physical CPUs now available */
integer_t physical_cpu_max; /* max number of physical CPUs possible */
integer_t logical_cpu; /* number of logical cpu now available */
integer_t logical_cpu_max; /* max number of physical CPUs possible */
uint64_t max_mem; /* actual size of physical memory */
};
#pragma pack(pop)
typedef struct host_basic_info host_basic_info_data_t;
typedef struct host_basic_info *host_basic_info_t;
#define HOST_BASIC_INFO_COUNT ((mach_msg_type_number_t) \
(sizeof(host_basic_info_data_t)/sizeof(integer_t)))
struct host_sched_info {
integer_t min_timeout; /* minimum timeout in milliseconds */
integer_t min_quantum; /* minimum quantum in milliseconds */
};
typedef struct host_sched_info host_sched_info_data_t;
typedef struct host_sched_info *host_sched_info_t;
#define HOST_SCHED_INFO_COUNT ((mach_msg_type_number_t) \
(sizeof(host_sched_info_data_t)/sizeof(integer_t)))
struct kernel_resource_sizes {
natural_t task;
natural_t thread;
natural_t port;
natural_t memory_region;
natural_t memory_object;
};
typedef struct kernel_resource_sizes kernel_resource_sizes_data_t;
typedef struct kernel_resource_sizes *kernel_resource_sizes_t;
#define HOST_RESOURCE_SIZES_COUNT ((mach_msg_type_number_t) \
(sizeof(kernel_resource_sizes_data_t)/sizeof(integer_t)))
struct host_priority_info {
integer_t kernel_priority;
integer_t system_priority;
integer_t server_priority;
integer_t user_priority;
integer_t depress_priority;
integer_t idle_priority;
integer_t minimum_priority;
integer_t maximum_priority;
};
typedef struct host_priority_info host_priority_info_data_t;
typedef struct host_priority_info *host_priority_info_t;
#define HOST_PRIORITY_INFO_COUNT ((mach_msg_type_number_t) \
(sizeof(host_priority_info_data_t)/sizeof(integer_t)))
/* host_statistics() */
#define HOST_LOAD_INFO 1 /* System loading stats */
#define HOST_VM_INFO 2 /* Virtual memory stats */
#define HOST_CPU_LOAD_INFO 3 /* CPU load stats */
/* host_statistics64() */
#define HOST_VM_INFO64 4 /* 64-bit virtual memory stats */
#define HOST_EXTMOD_INFO64 5 /* External modification stats */
#define HOST_EXPIRED_TASK_INFO 6 /* Statistics for expired tasks */
struct host_load_info {
integer_t avenrun[3]; /* scaled by LOAD_SCALE */
integer_t mach_factor[3]; /* scaled by LOAD_SCALE */
};
typedef struct host_load_info host_load_info_data_t;
typedef struct host_load_info *host_load_info_t;
#define HOST_LOAD_INFO_COUNT ((mach_msg_type_number_t) \
(sizeof(host_load_info_data_t)/sizeof(integer_t)))
typedef struct vm_purgeable_info host_purgable_info_data_t;
typedef struct vm_purgeable_info *host_purgable_info_t;
#define HOST_VM_PURGABLE_COUNT ((mach_msg_type_number_t) \
(sizeof(host_purgable_info_data_t)/sizeof(integer_t)))
/* in <mach/vm_statistics.h> */
/* vm_statistics64 */
#define HOST_VM_INFO64_COUNT ((mach_msg_type_number_t) \
(sizeof(vm_statistics64_data_t)/sizeof(integer_t)))
/* size of the latest version of the structure */
#define HOST_VM_INFO64_LATEST_COUNT HOST_VM_INFO64_COUNT
#define HOST_VM_INFO64_REV1_COUNT HOST_VM_INFO64_LATEST_COUNT
/* previous versions: adjust the size according to what was added each time */
#define HOST_VM_INFO64_REV0_COUNT /* added compression and swapper info (14 ints) */ \
((mach_msg_type_number_t) \
(HOST_VM_INFO64_REV1_COUNT - 14))
/* in <mach/vm_statistics.h> */
/* vm_extmod_statistics */
#define HOST_EXTMOD_INFO64_COUNT ((mach_msg_type_number_t) \
(sizeof(vm_extmod_statistics_data_t)/sizeof(integer_t)))
/* size of the latest version of the structure */
#define HOST_EXTMOD_INFO64_LATEST_COUNT HOST_EXTMOD_INFO64_COUNT
/* vm_statistics */
#define HOST_VM_INFO_COUNT ((mach_msg_type_number_t) \
(sizeof(vm_statistics_data_t)/sizeof(integer_t)))
/* size of the latest version of the structure */
#define HOST_VM_INFO_LATEST_COUNT HOST_VM_INFO_COUNT
#define HOST_VM_INFO_REV2_COUNT HOST_VM_INFO_LATEST_COUNT
/* previous versions: adjust the size according to what was added each time */
#define HOST_VM_INFO_REV1_COUNT /* added "speculative_count" (1 int) */ \
((mach_msg_type_number_t) \
(HOST_VM_INFO_REV2_COUNT - 1))
#define HOST_VM_INFO_REV0_COUNT /* added "purgable" info (2 ints) */ \
((mach_msg_type_number_t) \
(HOST_VM_INFO_REV1_COUNT - 2))
struct host_cpu_load_info { /* number of ticks while running... */
natural_t cpu_ticks[CPU_STATE_MAX]; /* ... in the given mode */
};
typedef struct host_cpu_load_info host_cpu_load_info_data_t;
typedef struct host_cpu_load_info *host_cpu_load_info_t;
#define HOST_CPU_LOAD_INFO_COUNT ((mach_msg_type_number_t) \
(sizeof (host_cpu_load_info_data_t) / sizeof (integer_t)))
struct host_preferred_user_arch {
cpu_type_t cpu_type; /* Preferred user-space cpu type */
cpu_subtype_t cpu_subtype; /* Preferred user-space cpu subtype */
};
typedef struct host_preferred_user_arch host_preferred_user_arch_data_t;
typedef struct host_preferred_user_arch *host_preferred_user_arch_t;
#define HOST_PREFERRED_USER_ARCH_COUNT ((mach_msg_type_number_t) \
(sizeof(host_preferred_user_arch_data_t)/sizeof(integer_t)))
#endif /* _MACH_HOST_INFO_H_ */

View File

@ -0,0 +1,39 @@
/*
* Copyright (c) 2003 Apple Computer, Inc. All rights reserved.
*
* @APPLE_OSREFERENCE_LICENSE_HEADER_START@
*
* This file contains Original Code and/or Modifications of Original Code
* as defined in and that are subject to the Apple Public Source License
* Version 2.0 (the 'License'). You may not use this file except in
* compliance with the License. The rights granted to you under the License
* may not be used to create, or enable the creation or redistribution of,
* unlawful or unlicensed copies of an Apple operating system, or to
* circumvent, violate, or enable the circumvention or violation of, any
* terms of an Apple operating system software license agreement.
*
* Please obtain a copy of the License at
* http://www.opensource.apple.com/apsl/ and read it before using this file.
*
* The Original Code and all software distributed under the License are
* distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
* Please see the License for the specific language governing rights and
* limitations under the License.
*
* @APPLE_OSREFERENCE_LICENSE_HEADER_END@
*/
#ifndef _MACH_HOST_NOTIFY_H_
#define _MACH_HOST_NOTIFY_H_
#define HOST_NOTIFY_CALENDAR_CHANGE 0
#define HOST_NOTIFY_CALENDAR_SET 1
#define HOST_NOTIFY_TYPE_MAX 1
#define HOST_CALENDAR_CHANGED_REPLYID 950
#define HOST_CALENDAR_SET_REPLYID 951
#endif /* _MACH_HOST_NOTIFY_H_ */

View File

@ -0,0 +1,43 @@
/*
* Copyright (c) 2003 Apple Computer, Inc. All rights reserved.
*
* @APPLE_OSREFERENCE_LICENSE_HEADER_START@
*
* This file contains Original Code and/or Modifications of Original Code
* as defined in and that are subject to the Apple Public Source License
* Version 2.0 (the 'License'). You may not use this file except in
* compliance with the License. The rights granted to you under the License
* may not be used to create, or enable the creation or redistribution of,
* unlawful or unlicensed copies of an Apple operating system, or to
* circumvent, violate, or enable the circumvention or violation of, any
* terms of an Apple operating system software license agreement.
*
* Please obtain a copy of the License at
* http://www.opensource.apple.com/apsl/ and read it before using this file.
*
* The Original Code and all software distributed under the License are
* distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
* Please see the License for the specific language governing rights and
* limitations under the License.
*
* @APPLE_OSREFERENCE_LICENSE_HEADER_END@
*/
subsystem
#if KERNEL_USER
KernelUser
#endif /* KERN_USER */
host_notify_reply 950;
#include <mach/std_types.defs>
simpleroutine host_calendar_changed(
notify_port : mach_port_move_send_once_t);
simpleroutine host_calendar_set(
notify_port : mach_port_move_send_once_t);
/* vim: set ft=c : */

View File

@ -0,0 +1,361 @@
/*
* Copyright (c) 2000-2004 Apple Inc. All rights reserved.
*
* @APPLE_OSREFERENCE_LICENSE_HEADER_START@
*
* This file contains Original Code and/or Modifications of Original Code
* as defined in and that are subject to the Apple Public Source License
* Version 2.0 (the 'License'). You may not use this file except in
* compliance with the License. The rights granted to you under the License
* may not be used to create, or enable the creation or redistribution of,
* unlawful or unlicensed copies of an Apple operating system, or to
* circumvent, violate, or enable the circumvention or violation of, any
* terms of an Apple operating system software license agreement.
*
* Please obtain a copy of the License at
* http://www.opensource.apple.com/apsl/ and read it before using this file.
*
* The Original Code and all software distributed under the License are
* distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
* Please see the License for the specific language governing rights and
* limitations under the License.
*
* @APPLE_OSREFERENCE_LICENSE_HEADER_END@
*/
/*
* @OSF_COPYRIGHT@
*/
/*
* Mach Operating System
* Copyright (c) 1991,1990,1989,1988 Carnegie Mellon University
* All Rights Reserved.
*
* Permission to use, copy, modify and distribute this software and its
* documentation is hereby granted, provided that both the copyright
* notice and this permission notice appear in all copies of the
* software, derivative works or modified versions, and any portions
* thereof, and that both notices appear in supporting documentation.
*
* CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
* CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR
* ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
*
* Carnegie Mellon requests users of this software to return to
*
* Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU
* School of Computer Science
* Carnegie Mellon University
* Pittsburgh PA 15213-3890
*
* any improvements or extensions that they make and grant Carnegie Mellon
* the rights to redistribute these changes.
*/
/*
*/
/*
* Matchmaker definitions file for Mach kernel interface.
*/
subsystem
#if KERNEL_USER
KernelUser
#endif /* KERNEL_USER */
#if KERNEL_SERVER
KernelServer
#endif /* KERNEL_SERVER */
host_priv 400;
#ifdef KERNEL_USER
userprefix r_;
#endif /* KERNEL_USER */
#define CONCAT(a,b) a ## b
#if KERNEL_SERVER
#define KERNEL_SERVER_SUFFIX(NAME) CONCAT(NAME, _external)
#else
#define KERNEL_SERVER_SUFFIX(NAME) NAME
#endif
#include <mach/std_types.defs>
#include <mach/mach_types.defs>
#include <mach/clock_types.defs>
#include <mach_debug/mach_debug_types.defs>
/*
* Get boot configuration information from kernel.
*/
routine host_get_boot_info(
host_priv : host_priv_t;
out boot_info : kernel_boot_info_t);
/*
* Reboot this host.
* Only available to privileged users.
*/
routine host_reboot(
host_priv : host_priv_t;
options : int);
/*
* Return privileged statistics from this host.
*/
routine host_priv_statistics(
host_priv : host_priv_t;
flavor : host_flavor_t;
out host_info_out : host_info_t, CountInOut);
/*
* Sets the default memory manager, the port to which
* newly-created temporary memory objects are delivered.
* [See (memory_object_default)memory_object_create.]
* Also sets the default cluster size used for pagein/pageout
* to this port.
* The old memory manager port is returned.
*/
routine host_default_memory_manager(
host_priv : host_priv_t;
inout default_manager : memory_object_default_t =
MACH_MSG_TYPE_MAKE_SEND;
cluster_size : memory_object_cluster_size_t);
/*
* Specify that the range of the virtual address space
* of the target task must not cause page faults for
* the indicated accesses.
*
* [ To unwire the pages, specify VM_PROT_NONE. ]
*/
routine vm_wire(
host_priv : host_priv_t;
task : vm_map_t;
address : vm_address_t;
size : vm_size_t;
desired_access : vm_prot_t);
/*
* Specify that the target thread must always be able
* to run and to allocate memory.
*/
routine thread_wire(
host_priv : host_priv_t;
thread : thread_act_t;
wired : boolean_t);
/*
* Allocate zero-filled, wired, contiguous physical memory
* in the address space of the target task, either at the
* specified address, or wherever space can be found (if
* anywhere is TRUE), of the specified size. The address
* at which the allocation actually took place is returned.
* All pages will be entered into the task's pmap immediately,
* with VM_PROT_ALL.
*
* In addition to all the failure modes of its cousin,
* vm_allocate, this call may also fail if insufficient
* contiguous memory exists to satisfy the request.
*
* Memory obtained from this call should be freed the
* normal way, via vm_deallocate.
*
* N.B. This is an EXPERIMENTAL interface!
*/
routine vm_allocate_cpm(
host_priv : host_priv_t;
task : vm_map_t;
inout address : vm_address_t;
size : vm_size_t;
flags : int);
/*
* Get list of processors on this host.
*/
routine host_processors(
host_priv : host_priv_t;
out out_processor_list : processor_array_t);
/*
* Get control port for a system-wide clock.
* Privileged.
*/
routine host_get_clock_control(
host_priv : host_priv_t;
clock_id : clock_id_t;
out clock_ctrl : clock_ctrl_t);
/*
* kernel module interface (obsolete as of SnowLeopard)
* see mach/kmod.h
*/
/* kmod_ MIG calls now return KERN_NOT_SUPPORTED on PPC/i386/x86_64. */
routine kmod_create(
host_priv : host_priv_t;
info : vm_address_t;
out module : kmod_t);
routine kmod_destroy(
host_priv : host_priv_t;
module : kmod_t);
routine kmod_control(
host_priv : host_priv_t;
module : kmod_t;
flavor : kmod_control_flavor_t;
inout data : kmod_args_t);
/*
* Get a given special port for a given node.
* Special ports are defined in host_special_ports.h;
* examples include the master device port.
* There are a limited number of slots available for system servers.
*/
routine
host_get_special_port(
host_priv : host_priv_t;
node : int;
which : int;
out port : mach_port_t);
/*
* Set a given special port for the local node.
* See host_get_special_port.
*/
routine
host_set_special_port(
host_priv : host_priv_t;
which : int;
port : mach_port_t);
/*
* Set an exception handler for a host on one or more exception types.
* These handlers are invoked for all threads on the host if there are
* no task or thread-specific exception handlers or those handlers returned
* an error.
*/
routine host_set_exception_ports(
host_priv : host_priv_t;
exception_mask : exception_mask_t;
new_port : mach_port_t;
behavior : exception_behavior_t;
new_flavor : thread_state_flavor_t);
/*
* Lookup some of the old exception handlers for a host
*/
routine host_get_exception_ports(
host_priv : host_priv_t;
exception_mask : exception_mask_t;
out masks : exception_mask_array_t;
out old_handlers : exception_handler_array_t, SameCount;
out old_behaviors : exception_behavior_array_t, SameCount;
out old_flavors : exception_flavor_array_t, SameCount);
/*
* Set an exception handler for a host on one or more exception types.
* At the same time, return the previously defined exception handlers for
* those types.
*/
routine host_swap_exception_ports(
host_priv : host_priv_t;
exception_mask : exception_mask_t;
new_port : mach_port_t;
behavior : exception_behavior_t;
new_flavor : thread_state_flavor_t;
out masks : exception_mask_array_t;
out old_handlerss : exception_handler_array_t, SameCount;
out old_behaviors : exception_behavior_array_t, SameCount;
out old_flavors : exception_flavor_array_t, SameCount);
skip; /* old host_load_symbol_table */
/*
* Specify that the range of the virtual address space
* of the target task must not cause page faults for
* the indicated accesses.
*
* [ To unwire the pages, specify VM_PROT_NONE. ]
*/
routine KERNEL_SERVER_SUFFIX(mach_vm_wire)(
host_priv : host_priv_t;
task : vm_map_t;
address : mach_vm_address_t;
size : mach_vm_size_t;
desired_access : vm_prot_t);
/*
* JMM - Keep all processor_set related items at the end for easy
* removal.
*/
/*
* List all processor sets on host.
*/
routine host_processor_sets(
host_priv : host_priv_t;
out processor_sets : processor_set_name_array_t);
/*
* Get control port for a processor set.
*/
routine host_processor_set_priv(
host_priv : host_priv_t;
set_name : processor_set_name_t;
out set : processor_set_t);
/************************** Warning *************************************/
/* The following routines are going away in a future release */
/* use the appropriate variant of host_set_special_port instead */
/************************************************************************/
skip;/* old set_dp_control_port */
skip;/* old get_dp_control_port */
/*
* Set the UserNotification daemon access port for this host.
* If this value is already set, the kernel will discard its
* reference to the previously registered port.
*/
routine host_set_UNDServer(
host : host_priv_t;
in server : UNDServerRef);
/*
* Get the UserNotification daemon access port for this host.
* This can then be used to communicate with that daemon, which
* in turn communicates with the User through whatever means
* available (pop-up-menus for GUI systems, text for non-GUI, etc..).
*
* Access to this port is restricted to privileged clients because
* it is a special purpose port intended for kernel clients. User
* level clients should go directly to the CFUserNotifcation services.
*/
routine host_get_UNDServer(
host : host_priv_t;
out server : UNDServerRef);
/*
* Perform an operation with a kernel extension, on the kext loading system,
* or request information about loaded kexts or the state of the kext loading
* system.
* Active operations (load, unload, disable/enable) require host_priv/root access.
* Info retrieval does not.
*
* WARNING: THIS ROUTINE IS PRIVATE TO THE KEXT-MANAGEMENT STACK AND IS
* SUBJECT TO CHANGE AT ANY TIME.
*/
routine kext_request(
host_priv : host_priv_t;
in user_log_flags : uint32_t;
in request_data : pointer_t;
out response_data : pointer_t;
out log_data : pointer_t;
out op_result : kern_return_t);
/* vim: set ft=c : */

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,39 @@
/*
* Copyright (c) 2000-2004 Apple Computer, Inc. All rights reserved.
*
* @APPLE_OSREFERENCE_LICENSE_HEADER_START@
*
* This file contains Original Code and/or Modifications of Original Code
* as defined in and that are subject to the Apple Public Source License
* Version 2.0 (the 'License'). You may not use this file except in
* compliance with the License. The rights granted to you under the License
* may not be used to create, or enable the creation or redistribution of,
* unlawful or unlicensed copies of an Apple operating system, or to
* circumvent, violate, or enable the circumvention or violation of, any
* terms of an Apple operating system software license agreement.
*
* Please obtain a copy of the License at
* http://www.opensource.apple.com/apsl/ and read it before using this file.
*
* The Original Code and all software distributed under the License are
* distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
* Please see the License for the specific language governing rights and
* limitations under the License.
*
* @APPLE_OSREFERENCE_LICENSE_HEADER_END@
*/
/*
* @OSF_COPYRIGHT@
*/
#ifndef _MACH_HOST_REBOOT_
#define _MACH_HOST_REBOOT_
#define HOST_REBOOT_HALT 0x0008
#define HOST_REBOOT_UPSDELAY 0x0100
#define HOST_REBOOT_DEBUGGER 0x1000
#endif /* _MACH_HOST_REBOOT_ */

View File

@ -0,0 +1,101 @@
/*
* Copyright (c) 2000 Apple Computer, Inc. All rights reserved.
*
* @APPLE_OSREFERENCE_LICENSE_HEADER_START@
*
* This file contains Original Code and/or Modifications of Original Code
* as defined in and that are subject to the Apple Public Source License
* Version 2.0 (the 'License'). You may not use this file except in
* compliance with the License. The rights granted to you under the License
* may not be used to create, or enable the creation or redistribution of,
* unlawful or unlicensed copies of an Apple operating system, or to
* circumvent, violate, or enable the circumvention or violation of, any
* terms of an Apple operating system software license agreement.
*
* Please obtain a copy of the License at
* http://www.opensource.apple.com/apsl/ and read it before using this file.
*
* The Original Code and all software distributed under the License are
* distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
* Please see the License for the specific language governing rights and
* limitations under the License.
*
* @APPLE_OSREFERENCE_LICENSE_HEADER_END@
*/
/*
* @OSF_COPYRIGHT@
*/
/*
* Mach Operating System
* Copyright (c) 1991,1990,1989 Carnegie Mellon University
* All Rights Reserved.
*
* Permission to use, copy, modify and distribute this software and its
* documentation is hereby granted, provided that both the copyright
* notice and this permission notice appear in all copies of the
* software, derivative works or modified versions, and any portions
* thereof, and that both notices appear in supporting documentation.
*
* CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
* CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR
* ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
*
* Carnegie Mellon requests users of this software to return to
*
* Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU
* School of Computer Science
* Carnegie Mellon University
* Pittsburgh PA 15213-3890
*
* any improvements or extensions that they make and grant Carnegie Mellon
* the rights to redistribute these changes.
*/
/*
*/
/*
* File: mach/host_security.defs
*
* Abstract:
* Mach host security operations support.
*/
subsystem
#if KERNEL_SERVER
KernelServer
#endif /* KERNEL_SERVER */
host_security 600;
/*
* Basic types
*/
#include <mach/std_types.defs>
#include <mach/mach_types.defs>
/*
* Create a new task with an explicit security token
*/
routine host_security_create_task_token(
host_security : host_security_t;
parent_task : task_t;
sec_token : security_token_t;
audit_token : audit_token_t;
host : host_t;
ledgers : ledger_array_t;
inherit_memory : boolean_t;
out child_task : task_t);
/*
* Change a task's security token
*/
routine host_security_set_task_token(
host_security : host_security_t;
target_task : task_t;
sec_token : security_token_t;
audit_token : audit_token_t;
host : host_t);
/* vim: set ft=c : */

View File

@ -0,0 +1,221 @@
#ifndef _host_security_user_
#define _host_security_user_
/* Module host_security */
#include <string.h>
#include <mach/ndr.h>
#include <mach/boolean.h>
#include <mach/kern_return.h>
#include <mach/notify.h>
#include <mach/mach_types.h>
#include <mach/message.h>
#include <mach/mig_errors.h>
#include <mach/port.h>
/* BEGIN MIG_STRNCPY_ZEROFILL CODE */
#if defined(__has_include)
#if __has_include(<mach/mig_strncpy_zerofill_support.h>)
#ifndef USING_MIG_STRNCPY_ZEROFILL
#define USING_MIG_STRNCPY_ZEROFILL
#endif
#ifndef __MIG_STRNCPY_ZEROFILL_FORWARD_TYPE_DECLS__
#define __MIG_STRNCPY_ZEROFILL_FORWARD_TYPE_DECLS__
#ifdef __cplusplus
extern "C" {
#endif
extern int mig_strncpy_zerofill(char *dest, const char *src, int len) __attribute__((weak_import));
#ifdef __cplusplus
}
#endif
#endif /* __MIG_STRNCPY_ZEROFILL_FORWARD_TYPE_DECLS__ */
#endif /* __has_include(<mach/mig_strncpy_zerofill_support.h>) */
#endif /* __has_include */
/* END MIG_STRNCPY_ZEROFILL CODE */
#ifdef AUTOTEST
#ifndef FUNCTION_PTR_T
#define FUNCTION_PTR_T
typedef void (*function_ptr_t)(mach_port_t, char *, mach_msg_type_number_t);
typedef struct {
char *name;
function_ptr_t function;
} function_table_entry;
typedef function_table_entry *function_table_t;
#endif /* FUNCTION_PTR_T */
#endif /* AUTOTEST */
#ifndef host_security_MSG_COUNT
#define host_security_MSG_COUNT 2
#endif /* host_security_MSG_COUNT */
#include <mach/std_types.h>
#include <mach/mig.h>
#include <mach/mig.h>
#include <mach/mach_types.h>
#ifdef __BeforeMigUserHeader
__BeforeMigUserHeader
#endif /* __BeforeMigUserHeader */
#include <sys/cdefs.h>
__BEGIN_DECLS
/* Routine host_security_create_task_token */
#ifdef mig_external
mig_external
#else
extern
#endif /* mig_external */
kern_return_t host_security_create_task_token
(
host_security_t host_security,
task_t parent_task,
security_token_t sec_token,
audit_token_t audit_token,
host_t host,
ledger_array_t ledgers,
mach_msg_type_number_t ledgersCnt,
boolean_t inherit_memory,
task_t *child_task
);
/* Routine host_security_set_task_token */
#ifdef mig_external
mig_external
#else
extern
#endif /* mig_external */
kern_return_t host_security_set_task_token
(
host_security_t host_security,
task_t target_task,
security_token_t sec_token,
audit_token_t audit_token,
host_t host
);
__END_DECLS
/********************** Caution **************************/
/* The following data types should be used to calculate */
/* maximum message sizes only. The actual message may be */
/* smaller, and the position of the arguments within the */
/* message layout may vary from what is presented here. */
/* For example, if any of the arguments are variable- */
/* sized, and less than the maximum is sent, the data */
/* will be packed tight in the actual message to reduce */
/* the presence of holes. */
/********************** Caution **************************/
/* typedefs for all requests */
#ifndef __Request__host_security_subsystem__defined
#define __Request__host_security_subsystem__defined
#ifdef __MigPackStructs
#pragma pack(push, 4)
#endif
typedef struct {
mach_msg_header_t Head;
/* start of the kernel processed data */
mach_msg_body_t msgh_body;
mach_msg_port_descriptor_t parent_task;
mach_msg_port_descriptor_t host;
mach_msg_ool_ports_descriptor_t ledgers;
/* end of the kernel processed data */
NDR_record_t NDR;
security_token_t sec_token;
audit_token_t audit_token;
mach_msg_type_number_t ledgersCnt;
boolean_t inherit_memory;
} __Request__host_security_create_task_token_t __attribute__((unused));
#ifdef __MigPackStructs
#pragma pack(pop)
#endif
#ifdef __MigPackStructs
#pragma pack(push, 4)
#endif
typedef struct {
mach_msg_header_t Head;
/* start of the kernel processed data */
mach_msg_body_t msgh_body;
mach_msg_port_descriptor_t target_task;
mach_msg_port_descriptor_t host;
/* end of the kernel processed data */
NDR_record_t NDR;
security_token_t sec_token;
audit_token_t audit_token;
} __Request__host_security_set_task_token_t __attribute__((unused));
#ifdef __MigPackStructs
#pragma pack(pop)
#endif
#endif /* !__Request__host_security_subsystem__defined */
/* union of all requests */
#ifndef __RequestUnion__host_security_subsystem__defined
#define __RequestUnion__host_security_subsystem__defined
union __RequestUnion__host_security_subsystem {
__Request__host_security_create_task_token_t Request_host_security_create_task_token;
__Request__host_security_set_task_token_t Request_host_security_set_task_token;
};
#endif /* !__RequestUnion__host_security_subsystem__defined */
/* typedefs for all replies */
#ifndef __Reply__host_security_subsystem__defined
#define __Reply__host_security_subsystem__defined
#ifdef __MigPackStructs
#pragma pack(push, 4)
#endif
typedef struct {
mach_msg_header_t Head;
/* start of the kernel processed data */
mach_msg_body_t msgh_body;
mach_msg_port_descriptor_t child_task;
/* end of the kernel processed data */
} __Reply__host_security_create_task_token_t __attribute__((unused));
#ifdef __MigPackStructs
#pragma pack(pop)
#endif
#ifdef __MigPackStructs
#pragma pack(push, 4)
#endif
typedef struct {
mach_msg_header_t Head;
NDR_record_t NDR;
kern_return_t RetCode;
} __Reply__host_security_set_task_token_t __attribute__((unused));
#ifdef __MigPackStructs
#pragma pack(pop)
#endif
#endif /* !__Reply__host_security_subsystem__defined */
/* union of all replies */
#ifndef __ReplyUnion__host_security_subsystem__defined
#define __ReplyUnion__host_security_subsystem__defined
union __ReplyUnion__host_security_subsystem {
__Reply__host_security_create_task_token_t Reply_host_security_create_task_token;
__Reply__host_security_set_task_token_t Reply_host_security_set_task_token;
};
#endif /* !__RequestUnion__host_security_subsystem__defined */
#ifndef subsystem_to_name_map_host_security
#define subsystem_to_name_map_host_security \
{ "host_security_create_task_token", 600 },\
{ "host_security_set_task_token", 601 }
#endif
#ifdef __AfterMigUserHeader
__AfterMigUserHeader
#endif /* __AfterMigUserHeader */
#endif /* _host_security_user_ */

View File

@ -0,0 +1,289 @@
/*
* Copyright (c) 2003 Apple Computer, Inc. All rights reserved.
*
* @APPLE_OSREFERENCE_LICENSE_HEADER_START@
*
* This file contains Original Code and/or Modifications of Original Code
* as defined in and that are subject to the Apple Public Source License
* Version 2.0 (the 'License'). You may not use this file except in
* compliance with the License. The rights granted to you under the License
* may not be used to create, or enable the creation or redistribution of,
* unlawful or unlicensed copies of an Apple operating system, or to
* circumvent, violate, or enable the circumvention or violation of, any
* terms of an Apple operating system software license agreement.
*
* Please obtain a copy of the License at
* http://www.opensource.apple.com/apsl/ and read it before using this file.
*
* The Original Code and all software distributed under the License are
* distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
* Please see the License for the specific language governing rights and
* limitations under the License.
*
* @APPLE_OSREFERENCE_LICENSE_HEADER_END@
*/
/*
* @OSF_COPYRIGHT@
*/
/*
* Mach Operating System
* Copyright (c) 1991 Carnegie Mellon University
* All Rights Reserved.
*
* Permission to use, copy, modify and distribute this software and its
* documentation is hereby granted, provided that both the copyright
* notice and this permission notice appear in all copies of the
* software, derivative works or modified versions, and any portions
* thereof, and that both notices appear in supporting documentation.
*
* CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
* CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR
* ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
*
* Carnegie Mellon requests users of this software to return to
*
* Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU
* School of Computer Science
* Carnegie Mellon University
* Pittsburgh PA 15213-3890
*
* any improvements or extensions that they make and grant Carnegie Mellon
* the rights to redistribute these changes.
*/
/*
*/
/*
* File: mach/host_special_ports.h
*
* Defines codes for access to host-wide special ports.
*/
#ifndef _MACH_HOST_SPECIAL_PORTS_H_
#define _MACH_HOST_SPECIAL_PORTS_H_
/*
* Cannot be set or gotten from user space
*/
#define HOST_SECURITY_PORT 0
#define HOST_MIN_SPECIAL_PORT HOST_SECURITY_PORT
/*
* Always provided by kernel (cannot be set from user-space).
*/
#define HOST_PORT 1
#define HOST_PRIV_PORT 2
#define HOST_IO_MASTER_PORT 3
#define HOST_MAX_SPECIAL_KERNEL_PORT 7 /* room to grow */
#define HOST_LAST_SPECIAL_KERNEL_PORT HOST_IO_MASTER_PORT
/*
* Not provided by kernel
*/
#define HOST_DYNAMIC_PAGER_PORT (1 + HOST_MAX_SPECIAL_KERNEL_PORT)
#define HOST_AUDIT_CONTROL_PORT (2 + HOST_MAX_SPECIAL_KERNEL_PORT)
#define HOST_USER_NOTIFICATION_PORT (3 + HOST_MAX_SPECIAL_KERNEL_PORT)
#define HOST_AUTOMOUNTD_PORT (4 + HOST_MAX_SPECIAL_KERNEL_PORT)
#define HOST_LOCKD_PORT (5 + HOST_MAX_SPECIAL_KERNEL_PORT)
#define HOST_KTRACE_BACKGROUND_PORT (6 + HOST_MAX_SPECIAL_KERNEL_PORT)
#define HOST_SEATBELT_PORT (7 + HOST_MAX_SPECIAL_KERNEL_PORT)
#define HOST_KEXTD_PORT (8 + HOST_MAX_SPECIAL_KERNEL_PORT)
#define HOST_LAUNCHCTL_PORT (9 + HOST_MAX_SPECIAL_KERNEL_PORT)
#define HOST_UNFREED_PORT (10 + HOST_MAX_SPECIAL_KERNEL_PORT)
#define HOST_AMFID_PORT (11 + HOST_MAX_SPECIAL_KERNEL_PORT)
#define HOST_GSSD_PORT (12 + HOST_MAX_SPECIAL_KERNEL_PORT)
#define HOST_TELEMETRY_PORT (13 + HOST_MAX_SPECIAL_KERNEL_PORT)
#define HOST_ATM_NOTIFICATION_PORT (14 + HOST_MAX_SPECIAL_KERNEL_PORT)
#define HOST_COALITION_PORT (15 + HOST_MAX_SPECIAL_KERNEL_PORT)
#define HOST_SYSDIAGNOSE_PORT (16 + HOST_MAX_SPECIAL_KERNEL_PORT)
#define HOST_XPC_EXCEPTION_PORT (17 + HOST_MAX_SPECIAL_KERNEL_PORT)
#define HOST_CONTAINERD_PORT (18 + HOST_MAX_SPECIAL_KERNEL_PORT)
#define HOST_NODE_PORT (19 + HOST_MAX_SPECIAL_KERNEL_PORT)
#define HOST_RESOURCE_NOTIFY_PORT (20 + HOST_MAX_SPECIAL_KERNEL_PORT)
#define HOST_CLOSURED_PORT (21 + HOST_MAX_SPECIAL_KERNEL_PORT)
#define HOST_SYSPOLICYD_PORT (22 + HOST_MAX_SPECIAL_KERNEL_PORT)
#define HOST_FILECOORDINATIOND_PORT (23 + HOST_MAX_SPECIAL_KERNEL_PORT)
#define HOST_FAIRPLAYD_PORT (24 + HOST_MAX_SPECIAL_KERNEL_PORT)
#define HOST_IOCOMPRESSIONSTATS_PORT (25 + HOST_MAX_SPECIAL_KERNEL_PORT)
#define HOST_MAX_SPECIAL_PORT HOST_IOCOMPRESSIONSTATS_PORT
/* MAX = last since rdar://59872249 */
/* obsolete name */
#define HOST_CHUD_PORT HOST_LAUNCHCTL_PORT
/*
* Special node identifier to always represent the local node.
*/
#define HOST_LOCAL_NODE -1
/*
* Definitions for ease of use.
*
* In the get call, the host parameter can be any host, but will generally
* be the local node host port. In the set call, the host must the per-node
* host port for the node being affected.
*/
#define host_get_host_port(host, port) \
(host_get_special_port((host), \
HOST_LOCAL_NODE, HOST_PORT, (port)))
#define host_set_host_port(host, port) (KERN_INVALID_ARGUMENT)
#define host_get_host_priv_port(host, port) \
(host_get_special_port((host), \
HOST_LOCAL_NODE, HOST_PRIV_PORT, (port)))
#define host_set_host_priv_port(host, port) (KERN_INVALID_ARGUMENT)
#define host_get_io_master_port(host, port) \
(host_get_special_port((host), \
HOST_LOCAL_NODE, HOST_IO_MASTER_PORT, (port)))
#define host_set_io_master_port(host, port) (KERN_INVALID_ARGUMENT)
/*
* User-settable special ports.
*/
#define host_get_dynamic_pager_port(host, port) \
(host_get_special_port((host), \
HOST_LOCAL_NODE, HOST_DYNAMIC_PAGER_PORT, (port)))
#define host_set_dynamic_pager_port(host, port) \
(host_set_special_port((host), HOST_DYNAMIC_PAGER_PORT, (port)))
#define host_get_audit_control_port(host, port) \
(host_get_special_port((host), \
HOST_LOCAL_NODE, HOST_AUDIT_CONTROL_PORT, (port)))
#define host_set_audit_control_port(host, port) \
(host_set_special_port((host), HOST_AUDIT_CONTROL_PORT, (port)))
#define host_get_user_notification_port(host, port) \
(host_get_special_port((host), \
HOST_LOCAL_NODE, HOST_USER_NOTIFICATION_PORT, (port)))
#define host_set_user_notification_port(host, port) \
(host_set_special_port((host), HOST_USER_NOTIFICATION_PORT, (port)))
#define host_get_automountd_port(host, port) \
(host_get_special_port((host), \
HOST_LOCAL_NODE, HOST_AUTOMOUNTD_PORT, (port)))
#define host_set_automountd_port(host, port) \
(host_set_special_port((host), HOST_AUTOMOUNTD_PORT, (port)))
#define host_get_lockd_port(host, port) \
(host_get_special_port((host), \
HOST_LOCAL_NODE, HOST_LOCKD_PORT, (port)))
#define host_set_lockd_port(host, port) \
(host_set_special_port((host), HOST_LOCKD_PORT, (port)))
#define host_get_ktrace_background_port(host, port) \
(host_get_special_port((host), \
HOST_LOCAL_NODE, HOST_KTRACE_BACKGROUND_PORT, (port)))
#define host_set_ktrace_background_port(host, port) \
(host_set_special_port((host), HOST_KTRACE_BACKGROUND_PORT, (port)))
#define host_get_kextd_port(host, port) \
(host_get_special_port((host), \
HOST_LOCAL_NODE, HOST_KEXTD_PORT, (port)))
#define host_set_kextd_port(host, port) \
(host_set_special_port((host), HOST_KEXTD_PORT, (port)))
#define host_get_launchctl_port(host, port) \
(host_get_special_port((host), HOST_LOCAL_NODE, HOST_LAUNCHCTL_PORT, \
(port)))
#define host_set_launchctl_port(host, port) \
(host_set_special_port((host), HOST_LAUNCHCTL_PORT, (port)))
#define host_get_chud_port(host, port) host_get_launchctl_port(host, port)
#define host_set_chud_port(host, port) host_set_launchctl_port(host, port)
#define host_get_unfreed_port(host, port) \
(host_get_special_port((host), \
HOST_LOCAL_NODE, HOST_UNFREED_PORT, (port)))
#define host_set_unfreed_port(host, port) \
(host_set_special_port((host), HOST_UNFREED_PORT, (port)))
#define host_get_amfid_port(host, port) \
(host_get_special_port((host), \
HOST_LOCAL_NODE, HOST_AMFID_PORT, (port)))
#define host_set_amfid_port(host, port) \
(host_set_special_port((host), HOST_AMFID_PORT, (port)))
#define host_get_gssd_port(host, port) \
(host_get_special_port((host), \
HOST_LOCAL_NODE, HOST_GSSD_PORT, (port)))
#define host_set_gssd_port(host, port) \
(host_set_special_port((host), HOST_GSSD_PORT, (port)))
#define host_get_telemetry_port(host, port) \
(host_get_special_port((host), \
HOST_LOCAL_NODE, HOST_TELEMETRY_PORT, (port)))
#define host_set_telemetry_port(host, port) \
(host_set_special_port((host), HOST_TELEMETRY_PORT, (port)))
#define host_get_atm_notification_port(host, port) \
(host_get_special_port((host), \
HOST_LOCAL_NODE, HOST_ATM_NOTIFICATION_PORT, (port)))
#define host_set_atm_notification_port(host, port) \
(host_set_special_port((host), HOST_ATM_NOTIFICATION_PORT, (port)))
#define host_get_coalition_port(host, port) \
(host_get_special_port((host), \
HOST_LOCAL_NODE, HOST_COALITION_PORT, (port)))
#define host_set_coalition_port(host, port) \
(host_set_special_port((host), HOST_COALITION_PORT, (port)))
#define host_get_sysdiagnose_port(host, port) \
(host_get_special_port((host), \
HOST_LOCAL_NODE, HOST_SYSDIAGNOSE_PORT, (port)))
#define host_set_sysdiagnose_port(host, port) \
(host_set_special_port((host), HOST_SYSDIAGNOSE_PORT, (port)))
#define host_get_container_port(host, port) \
(host_get_special_port((host), \
HOST_LOCAL_NODE, HOST_CONTAINERD_PORT, (port)))
#define host_set_container_port(host, port) \
(host_set_special_port((host), HOST_CONTAINERD_PORT, (port)))
#define host_get_node_port(host, port) \
(host_get_special_port((host), \
HOST_LOCAL_NODE, HOST_NODE_PORT, (port)))
#define host_set_node_port(host, port) \
(host_set_special_port((host), HOST_NODE_PORT, (port)))
#define host_get_closured_port(host, port) \
(host_get_special_port((host), \
HOST_LOCAL_NODE, HOST_CLOSURED_PORT, (port)))
#define host_set_closured_port(host, port) \
(host_set_special_port((host), HOST_CLOSURED_PORT, (port)))
#define host_get_syspolicyd_port(host, port) \
(host_get_special_port((host), \
HOST_LOCAL_NODE, HOST_SYSPOLICYD_PORT, (port)))
#define host_set_syspolicyd_port(host, port) \
(host_set_special_port((host), HOST_SYSPOLICYD_PORT, (port)))
#define host_get_filecoordinationd_port(host, port) \
(host_get_special_port((host), \
HOST_LOCAL_NODE, HOST_FILECOORDINATIOND_PORT, (port)))
#define host_set_filecoordinationd_port(host, port) \
(host_set_special_port((host), HOST_FILECOORDINATIOND_PORT, (port)))
#define host_get_fairplayd_port(host, port) \
(host_get_special_port((host), \
HOST_LOCAL_NODE, HOST_FAIRPLAYD_PORT, (port)))
#define host_set_fairplayd_port(host, port) \
(host_set_special_port((host), HOST_FAIRPLAYD_PORT, (port)))
#define host_get_iocompressionstats_port(host, port) \
(host_get_special_port((host), \
HOST_LOCAL_NODE, HOST_IOCOMPRESSIONSTATS_PORT, (port)))
#define host_set_iocompressionstats_port(host, port) \
(host_set_special_port((host), HOST_IOCOMPRESSIONSTATS_PORT, (port)))
/* HOST_RESOURCE_NOTIFY_PORT doesn't #defines these conveniences.
* All lookups go through send_resource_violation()
*/
#endif /* _MACH_HOST_SPECIAL_PORTS_H_ */

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,380 @@
/*
* Copyright (c) 2000-2018 Apple Computer, Inc. All rights reserved.
*
* @APPLE_OSREFERENCE_LICENSE_HEADER_START@
*
* This file contains Original Code and/or Modifications of Original Code
* as defined in and that are subject to the Apple Public Source License
* Version 2.0 (the 'License'). You may not use this file except in
* compliance with the License. The rights granted to you under the License
* may not be used to create, or enable the creation or redistribution of,
* unlawful or unlicensed copies of an Apple operating system, or to
* circumvent, violate, or enable the circumvention or violation of, any
* terms of an Apple operating system software license agreement.
*
* Please obtain a copy of the License at
* http://www.opensource.apple.com/apsl/ and read it before using this file.
*
* The Original Code and all software distributed under the License are
* distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
* Please see the License for the specific language governing rights and
* limitations under the License.
*
* @APPLE_OSREFERENCE_LICENSE_HEADER_END@
*/
/*
* @OSF_COPYRIGHT@
*/
/*
* Mach Operating System
* Copyright (c) 1991,1990,1989 Carnegie Mellon University
* All Rights Reserved.
*
* Permission to use, copy, modify and distribute this software and its
* documentation is hereby granted, provided that both the copyright
* notice and this permission notice appear in all copies of the
* software, derivative works or modified versions, and any portions
* thereof, and that both notices appear in supporting documentation.
*
* CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
* CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR
* ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
*
* Carnegie Mellon requests users of this software to return to
*
* Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU
* School of Computer Science
* Carnegie Mellon University
* Pittsburgh PA 15213-3890
*
* any improvements or extensions that they make and grant Carnegie Mellon
* the rights to redistribute these changes.
*/
#ifndef _I386_ASM_H_
#define _I386_ASM_H_
#if defined(__i386__)
#define S_PC (%esp)
#define S_ARG0 4(%esp)
#define S_ARG1 8(%esp)
#define S_ARG2 12(%esp)
#define S_ARG3 16(%esp)
#define S_ARG4 20(%esp)
#define FRAME pushl %ebp; movl %esp, %ebp
#define EMARF leave
#define B_LINK (%ebp)
#define B_PC 4(%ebp)
#define B_ARG0 8(%ebp)
#define B_ARG1 12(%ebp)
#define B_ARG2 16(%ebp)
#define B_ARG3 20(%ebp)
#elif defined(__x86_64__)
#define S_PC (%rsp)
#define FRAME pushq %rbp; movq %rsp, %rbp
#define EMARF leave
#define B_LINK (%rbp)
#define B_PC 8(%rbp)
#else
#error unsupported architecture
#endif
/* There is another definition of ALIGN for .c sources */
#ifdef __ASSEMBLER__
#define ALIGN 4,0x90
#endif /* __ASSEMBLER__ */
#ifndef FALIGN
#define FALIGN ALIGN
#endif
#define LB(x,n) n
#if __STDC__
#ifndef __NO_UNDERSCORES__
#define LCL(x) L ## x
#define EXT(x) _ ## x
#define LEXT(x) _ ## x ## :
#else
#define LCL(x) .L ## x
#define EXT(x) x
#define LEXT(x) x ## :
#endif
#define LBc(x,n) n ## :
#define LBb(x,n) n ## b
#define LBf(x,n) n ## f
#else /* __STDC__ */
#ifndef __NO_UNDERSCORES__
#define LCL(x) L/**/x
#define EXT(x) _/**/x
#define LEXT(x) _/**/x/**/:
#else /* __NO_UNDERSCORES__ */
#define LCL(x) .L/**/x
#define EXT(x) x
#define LEXT(x) x/**/:
#endif /* __NO_UNDERSCORES__ */
#define LBc(x,n) n/**/:
#define LBb(x,n) n/**/b
#define LBf(x,n) n/**/f
#endif /* __STDC__ */
#define SVC .byte 0x9a; .long 0; .word 0x7
#define RPC_SVC .byte 0x9a; .long 0; .word 0xf
#define String .asciz
#define Value .word
#define Times(a,b) (a*b)
#define Divide(a,b) (a/b)
#define INB inb %dx, %al
#define OUTB outb %al, %dx
#define INL inl %dx, %eax
#define OUTL outl %eax, %dx
#define data16 .byte 0x66
#define addr16 .byte 0x67
#define MCOUNT
#if defined(__SHARED__)
#define MCOUNT ; .data;\
.align ALIGN;\
LBc(x, 8) .long 0;\
.text;\
Gpush;\
Gload;\
leal Gotoff(LBb(x,8)),%edx;\
Egaddr(%eax,_mcount_ptr);\
Gpop;\
call *(%eax);
#endif /* __SHARED__ */
#ifdef __ELF__
#define ELF_FUNC(x) .type x,@function
#define ELF_DATA(x) .type x,@object
#define ELF_SIZE(x,s) .size x,s
#else
#define ELF_FUNC(x)
#define ELF_DATA(x)
#define ELF_SIZE(x,s)
#endif
#define Entry(x) .globl EXT(x); ELF_FUNC(EXT(x)); .align FALIGN; LEXT(x)
#define ENTRY(x) Entry(x) MCOUNT
#define ENTRY2(x,y) .globl EXT(x); .globl EXT(y); \
ELF_FUNC(EXT(x)); ELF_FUNC(EXT(y)); \
.align FALIGN; LEXT(x); LEXT(y) \
MCOUNT
#if __STDC__
#define ASENTRY(x) .globl x; .align FALIGN; x ## : ELF_FUNC(x) MCOUNT
#else
#define ASENTRY(x) .globl x; .align FALIGN; x: ELF_FUNC(x) MCOUNT
#endif /* __STDC__ */
#define DATA(x) .globl EXT(x); ELF_DATA(EXT(x)); .align ALIGN; LEXT(x)
#define End(x) ELF_SIZE(x,.-x)
#define END(x) End(EXT(x))
#define ENDDATA(x) END(x)
#define Enddata(x) End(x)
/*
* ELF shared library accessor macros.
* Gpush saves the %ebx register used for the GOT address
* Gpop pops %ebx if we need a GOT
* Gload loads %ebx with the GOT address if shared libraries are used
* Gcall calls an external function.
* Gotoff allows you to reference local labels.
* Gotoff2 allows you to reference local labels with an index reg.
* Gotoff3 allows you to reference local labels with an index reg & size.
* Gaddr loads up a register with an address of an external item.
* Gstack is the number of bytes that Gpush pushes on the stack.
*
* Varients of the above with E or L prefixes do EXT(name) or LCL(name)
* respectively.
*/
#ifndef __SHARED__
#define Gpush
#define Gpop
#define Gload
#define Gcall(func) call func
#define Gotoff(lab) lab
#define Gotoff2(l,r) l(r)
#define Gotoff3(l,r,s) l(,r,s)
#define Gaddr(to,lab) movl $lab,to
#define Gcmp(lab,reg) cmpl $lab,reg
#define Gmemload(lab,reg) movl lab,reg
#define Gmemstore(reg,lab,tmp) movl reg,lab
#define Gstack 0
#else
#ifdef __ELF__ /* ELF shared libraries */
#define Gpush pushl %ebx
#define Gpop popl %ebx
#define Gload call 9f; 9: popl %ebx; addl $_GLOBAL_OFFSET_TABLE_+[.-9b],%ebx
#define Gcall(func) call EXT(func)@PLT
#define Gotoff(lab) lab@GOTOFF(%ebx)
#define Gotoff2(l,r) l@GOTOFF(%ebx,r)
#define Gotoff3(l,r,s) l@GOTOFF(%ebx,r,s)
#define Gaddr(to,lab) movl lab@GOT(%ebx),to
#define Gcmp(lab,reg) cmpl reg,lab@GOT(%ebx)
#define Gmemload(lab,reg) movl lab@GOT(%ebx),reg; movl (reg),reg
#define Gmemstore(reg,lab,tmp) movl lab@GOT(%ebx),tmp; movl reg,(tmp)
#define Gstack 4
#else /* ROSE shared libraries */
#define Gpush
#define Gpop
#define Gload
#define Gcall(func) call *9f; .data; .align ALIGN; 9: .long func; .text
#define Gotoff(lab) lab
#define Gotoff2(l,r) l(r)
#define Gotoff3(l,r,s) l(,r,s)
#define Gaddr(to,lab) movl 9f,to; .data; .align ALIGN; 9: .long lab; .text
#define Gcmp(lab,reg) cmpl reg,9f; .data; .align ALIGN; 9: .long lab; .text
#define Gmemload(lab,reg) movl 9f,reg; movl (reg),reg; .data; .align ALIGN; 9: .long lab; .text
#define Gmemstore(reg,lab,tmp) movl 9f,tmp; movl reg,(tmp); .data; .align ALIGN; 9: .long lab; .text
#define Gstack 0
#endif /* __ELF__ */
#endif /* __SHARED__ */
/* Egotoff is not provided, since external symbols should not use @GOTOFF
relocations. */
#define Egcall(func) Gcall(EXT(func))
#define Egaddr(to,lab) Gaddr(to,EXT(lab))
#define Egcmp(lab,reg) Gcmp(EXT(lab),reg)
#define Egmemload(lab,reg) Gmemload(EXT(lab),reg)
#define Egmemstore(reg,lab,tmp) Gmemstore(reg,EXT(lab),tmp)
#define Lgotoff(lab) Gotoff(LCL(lab))
#define Lgotoff2(l,r) Gotoff2(LCL(l),r)
#define Lgotoff3(l,r,s) Gotoff3(LCL(l),r,s)
#define Lgcmp(lab,reg) Gcmp(LCL(lab),reg)
#define Lgmemload(lab,reg) movl Lgotoff(lab),reg
#define Lgmemstore(reg,lab,tmp) movl reg,Lgotoff(lab)
#ifndef __ASSEMBLER__
/* These defines are here for .c files that wish to reference global symbols
* within __asm__ statements.
*/
#ifndef __NO_UNDERSCORES__
#define CC_SYM_PREFIX "_"
#else
#define CC_SYM_PREFIX ""
#endif /* __NO_UNDERSCORES__ */
#endif /* __ASSEMBLER__ */
/*
* The following macros make calls into C code.
* They dynamically align the stack to 16 bytes.
*/
#if defined(__i386__)
/*
* Arguments are moved (not pushed) onto the correctly aligned stack.
* NOTE: ESI is destroyed in the process, and hence cannot
* be directly used as a parameter. Users of this macro must
* independently preserve ESI (a non-volatile) if the routine is
* intended to be called from C, for instance.
*/
#define CCALL(fn) \
movl %esp, %esi ;\
andl $0xFFFFFFF0, %esp ;\
call EXT(fn) ;\
movl %esi, %esp
#define CCALL1(fn, arg1) \
movl %esp, %esi ;\
subl $4, %esp ;\
andl $0xFFFFFFF0, %esp ;\
movl arg1, (%esp) ;\
call EXT(fn) ;\
movl %esi, %esp
#define CCALL2(fn, arg1, arg2) \
movl %esp, %esi ;\
subl $8, %esp ;\
andl $0xFFFFFFF0, %esp ;\
movl arg2, 4(%esp) ;\
movl arg1, (%esp) ;\
call EXT(fn) ;\
movl %esi, %esp
/* This variant exists to permit adjustment of the stack by "dtrace" */
#define CCALL1WITHSP(fn, arg1) \
movl %esp, %esi ;\
subl $12, %esp ;\
andl $0xFFFFFFF0, %esp ;\
movl %esi, 8(%esp) ;\
leal 8(%esp), %esi ;\
movl %esi, 4(%esp) ;\
movl arg1, (%esp) ;\
call EXT(fn) ;\
movl 8(%esp), %esp
/*
* CCALL5 is used for callee functions with 3 arguments but
* where arg2 (a3:a2) and arg3 (a5:a4) are 64-bit values.
*/
#define CCALL5(fn, a1, a2, a3, a4, a5) \
movl %esp, %esi ;\
subl $20, %esp ;\
andl $0xFFFFFFF0, %esp ;\
movl a5, 16(%esp) ;\
movl a4, 12(%esp) ;\
movl a3, 8(%esp) ;\
movl a2, 4(%esp) ;\
movl a1, (%esp) ;\
call EXT(fn) ;\
movl %esi, %esp
#elif defined(__x86_64__)
/* This variant exists to permit adjustment of the stack by "dtrace" */
#define CCALLWITHSP(fn) \
mov %rsp, %r12 ;\
sub $8, %rsp ;\
and $0xFFFFFFFFFFFFFFF0, %rsp ;\
mov %r12, (%rsp) ;\
leaq (%rsp), %rsi ;\
call EXT(fn) ;\
mov (%rsp), %rsp
#define CCALL(fn) \
mov %rsp, %r12 ;\
and $0xFFFFFFFFFFFFFFF0, %rsp ;\
call EXT(fn) ;\
mov %r12, %rsp
#define CCALL1(fn, arg1) \
mov arg1, %rdi ;\
CCALL(fn)
#define CCALL2(fn, arg1, arg2) \
mov arg1, %rdi ;\
mov arg2, %rsi ;\
CCALL(fn)
#define CCALL3(fn, arg1, arg2, arg3) \
mov arg1, %rdi ;\
mov arg2, %rsi ;\
mov arg3, %rdx ;\
CCALL(fn)
#else
#error unsupported architecture
#endif
#endif /* _I386_ASM_H_ */

View File

@ -0,0 +1,74 @@
/*
* Copyright (c) 2000-2006 Apple Computer, Inc. All rights reserved.
*
* @APPLE_OSREFERENCE_LICENSE_HEADER_START@
*
* This file contains Original Code and/or Modifications of Original Code
* as defined in and that are subject to the Apple Public Source License
* Version 2.0 (the 'License'). You may not use this file except in
* compliance with the License. The rights granted to you under the License
* may not be used to create, or enable the creation or redistribution of,
* unlawful or unlicensed copies of an Apple operating system, or to
* circumvent, violate, or enable the circumvention or violation of, any
* terms of an Apple operating system software license agreement.
*
* Please obtain a copy of the License at
* http://www.opensource.apple.com/apsl/ and read it before using this file.
*
* The Original Code and all software distributed under the License are
* distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
* Please see the License for the specific language governing rights and
* limitations under the License.
*
* @APPLE_OSREFERENCE_LICENSE_HEADER_END@
*/
/*
* @OSF_COPYRIGHT@
*/
/*
* Mach Operating System
* Copyright (c) 1991,1990,1989 Carnegie Mellon University
* All Rights Reserved.
*
* Permission to use, copy, modify and distribute this software and its
* documentation is hereby granted, provided that both the copyright
* notice and this permission notice appear in all copies of the
* software, derivative works or modified versions, and any portions
* thereof, and that both notices appear in supporting documentation.
*
* CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
* CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR
* ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
*
* Carnegie Mellon requests users of this software to return to
*
* Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU
* School of Computer Science
* Carnegie Mellon University
* Pittsburgh PA 15213-3890
*
* any improvements or extensions that they make and grant Carnegie Mellon
* the rights to redistribute these changes.
*/
/*
*/
/*
* File: boolean.h
*
* Boolean type, for I386.
*/
#ifndef _MACH_I386_BOOLEAN_H_
#define _MACH_I386_BOOLEAN_H_
#if defined(__x86_64__) && !defined(KERNEL)
typedef unsigned int boolean_t;
#else
typedef int boolean_t;
#endif
#endif /* _MACH_I386_BOOLEAN_H_ */

View File

@ -0,0 +1,135 @@
/*
* Copyright (c) 2000 Apple Computer, Inc. All rights reserved.
*
* @APPLE_OSREFERENCE_LICENSE_HEADER_START@
*
* This file contains Original Code and/or Modifications of Original Code
* as defined in and that are subject to the Apple Public Source License
* Version 2.0 (the 'License'). You may not use this file except in
* compliance with the License. The rights granted to you under the License
* may not be used to create, or enable the creation or redistribution of,
* unlawful or unlicensed copies of an Apple operating system, or to
* circumvent, violate, or enable the circumvention or violation of, any
* terms of an Apple operating system software license agreement.
*
* Please obtain a copy of the License at
* http://www.opensource.apple.com/apsl/ and read it before using this file.
*
* The Original Code and all software distributed under the License are
* distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
* Please see the License for the specific language governing rights and
* limitations under the License.
*
* @APPLE_OSREFERENCE_LICENSE_HEADER_END@
*/
/*
* @OSF_COPYRIGHT@
*/
/*
* Mach Operating System
* Copyright (c) 1991,1990,1989,1988 Carnegie Mellon University
* All Rights Reserved.
*
* Permission to use, copy, modify and distribute this software and its
* documentation is hereby granted, provided that both the copyright
* notice and this permission notice appear in all copies of the
* software, derivative works or modified versions, and any portions
* thereof, and that both notices appear in supporting documentation.
*
* CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
* CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR
* ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
*
* Carnegie Mellon requests users of this software to return to
*
* Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU
* School of Computer Science
* Carnegie Mellon University
* Pittsburgh PA 15213-3890
*
* any improvements or extensions that they make and grant Carnegie Mellon
* the rights to redistribute these changes.
*/
/*
*/
#ifndef _MACH_I386_EXCEPTION_H_
#define _MACH_I386_EXCEPTION_H_
/*
* No machine dependent types for the 80386
*/
#define EXC_TYPES_COUNT 14 /* incl. illegal exception 0 */
/*
* Codes and subcodes for 80386 exceptions.
*/
#define EXCEPTION_CODE_MAX 2 /* currently code and subcode */
/*
* EXC_BAD_INSTRUCTION
*/
#define EXC_I386_INVOP 1
/*
* EXC_ARITHMETIC
*/
#define EXC_I386_DIV 1
#define EXC_I386_INTO 2
#define EXC_I386_NOEXT 3
#define EXC_I386_EXTOVR 4
#define EXC_I386_EXTERR 5
#define EXC_I386_EMERR 6
#define EXC_I386_BOUND 7
#define EXC_I386_SSEEXTERR 8
/*
* EXC_SOFTWARE
* Note: 0x10000-0x10003 in use for unix signal
*/
/*
* EXC_BAD_ACCESS
*/
/*
* EXC_BREAKPOINT
*/
#define EXC_I386_SGL 1
#define EXC_I386_BPT 2
#define EXC_I386_DIVERR 0 /* divide by 0 eprror */
#define EXC_I386_SGLSTP 1 /* single step */
#define EXC_I386_NMIFLT 2 /* NMI */
#define EXC_I386_BPTFLT 3 /* breakpoint fault */
#define EXC_I386_INTOFLT 4 /* INTO overflow fault */
#define EXC_I386_BOUNDFLT 5 /* BOUND instruction fault */
#define EXC_I386_INVOPFLT 6 /* invalid opcode fault */
#define EXC_I386_NOEXTFLT 7 /* extension not available fault*/
#define EXC_I386_DBLFLT 8 /* double fault */
#define EXC_I386_EXTOVRFLT 9 /* extension overrun fault */
#define EXC_I386_INVTSSFLT 10 /* invalid TSS fault */
#define EXC_I386_SEGNPFLT 11 /* segment not present fault */
#define EXC_I386_STKFLT 12 /* stack fault */
#define EXC_I386_GPFLT 13 /* general protection fault */
#define EXC_I386_PGFLT 14 /* page fault */
#define EXC_I386_EXTERRFLT 16 /* extension error fault */
#define EXC_I386_ALIGNFLT 17 /* Alignment fault */
#define EXC_I386_ENDPERR 33 /* emulated extension error flt */
#define EXC_I386_ENOEXTFLT 32 /* emulated ext not present */
/*
* machine dependent exception masks
*/
#define EXC_MASK_MACHINE 0
#endif /* _MACH_I386_EXCEPTION_H_ */

View File

@ -0,0 +1,118 @@
/*
* Copyright (c) 2000 Apple Computer, Inc. All rights reserved.
*
* @APPLE_OSREFERENCE_LICENSE_HEADER_START@
*
* This file contains Original Code and/or Modifications of Original Code
* as defined in and that are subject to the Apple Public Source License
* Version 2.0 (the 'License'). You may not use this file except in
* compliance with the License. The rights granted to you under the License
* may not be used to create, or enable the creation or redistribution of,
* unlawful or unlicensed copies of an Apple operating system, or to
* circumvent, violate, or enable the circumvention or violation of, any
* terms of an Apple operating system software license agreement.
*
* Please obtain a copy of the License at
* http://www.opensource.apple.com/apsl/ and read it before using this file.
*
* The Original Code and all software distributed under the License are
* distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
* Please see the License for the specific language governing rights and
* limitations under the License.
*
* @APPLE_OSREFERENCE_LICENSE_HEADER_END@
*/
/*
* @OSF_COPYRIGHT@
*/
/*
* Mach Operating System
* Copyright (c) 1992-1989 Carnegie Mellon University
* All Rights Reserved.
*
* Permission to use, copy, modify and distribute this software and its
* documentation is hereby granted, provided that both the copyright
* notice and this permission notice appear in all copies of the
* software, derivative works or modified versions, and any portions
* thereof, and that both notices appear in supporting documentation.
*
* CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
* CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR
* ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
*
* Carnegie Mellon requests users of this software to return to
*
* Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU
* School of Computer Science
* Carnegie Mellon University
* Pittsburgh PA 15213-3890
*
* any improvements or extensions that they make and grant Carnegie Mellon
* the rights to redistribute these changes.
*/
/*
*/
#ifndef _I386_FP_SAVE_H_
#define _I386_FP_SAVE_H_
/*
* Control register
*/
#define FPC_IE 0x0001 /* enable invalid operation
* exception */
#define FPC_IM FPC_IE
#define FPC_DE 0x0002 /* enable denormalized operation
* exception */
#define FPC_DM FPC_DE
#define FPC_ZE 0x0004 /* enable zero-divide exception */
#define FPC_ZM FPC_ZE
#define FPC_OE 0x0008 /* enable overflow exception */
#define FPC_OM FPC_OE
#define FPC_UE 0x0010 /* enable underflow exception */
#define FPC_PE 0x0020 /* enable precision exception */
#define FPC_PC 0x0300 /* precision control: */
#define FPC_PC_24 0x0000 /* 24 bits */
#define FPC_PC_53 0x0200 /* 53 bits */
#define FPC_PC_64 0x0300 /* 64 bits */
#define FPC_RC 0x0c00 /* rounding control: */
#define FPC_RC_RN 0x0000 /* round to nearest or even */
#define FPC_RC_RD 0x0400 /* round down */
#define FPC_RC_RU 0x0800 /* round up */
#define FPC_RC_CHOP 0x0c00 /* chop */
#define FPC_IC 0x1000 /* infinity control (obsolete) */
#define FPC_IC_PROJ 0x0000 /* projective infinity */
#define FPC_IC_AFF 0x1000 /* affine infinity (std) */
/*
* Status register
*/
#define FPS_IE 0x0001 /* invalid operation */
#define FPS_DE 0x0002 /* denormalized operand */
#define FPS_ZE 0x0004 /* divide by zero */
#define FPS_OE 0x0008 /* overflow */
#define FPS_UE 0x0010 /* underflow */
#define FPS_PE 0x0020 /* precision */
#define FPS_SF 0x0040 /* stack flag */
#define FPS_ES 0x0080 /* error summary */
#define FPS_C0 0x0100 /* condition code bit 0 */
#define FPS_C1 0x0200 /* condition code bit 1 */
#define FPS_C2 0x0400 /* condition code bit 2 */
#define FPS_TOS 0x3800 /* top-of-stack pointer */
#define FPS_TOS_SHIFT 11
#define FPS_C3 0x4000 /* condition code bit 3 */
#define FPS_BUSY 0x8000 /* FPU busy */
/*
* Kind of floating-point support provided by kernel.
*/
#define FP_NO 0 /* no floating point */
#define FP_SOFT 1 /* software FP emulator */
#define FP_287 2 /* 80287 */
#define FP_387 3 /* 80387 or 80486 */
#define FP_FXSR 4 /* Fast save/restore SIMD Extension */
#endif /* _I386_FP_SAVE_H_ */

View File

@ -0,0 +1,74 @@
/*
* Copyright (c) 2000 Apple Computer, Inc. All rights reserved.
*
* @APPLE_OSREFERENCE_LICENSE_HEADER_START@
*
* This file contains Original Code and/or Modifications of Original Code
* as defined in and that are subject to the Apple Public Source License
* Version 2.0 (the 'License'). You may not use this file except in
* compliance with the License. The rights granted to you under the License
* may not be used to create, or enable the creation or redistribution of,
* unlawful or unlicensed copies of an Apple operating system, or to
* circumvent, violate, or enable the circumvention or violation of, any
* terms of an Apple operating system software license agreement.
*
* Please obtain a copy of the License at
* http://www.opensource.apple.com/apsl/ and read it before using this file.
*
* The Original Code and all software distributed under the License are
* distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
* Please see the License for the specific language governing rights and
* limitations under the License.
*
* @APPLE_OSREFERENCE_LICENSE_HEADER_END@
*/
/*
* @OSF_COPYRIGHT@
*/
/*
* Mach Operating System
* Copyright (c) 1991,1990,1989 Carnegie Mellon University
* All Rights Reserved.
*
* Permission to use, copy, modify and distribute this software and its
* documentation is hereby granted, provided that both the copyright
* notice and this permission notice appear in all copies of the
* software, derivative works or modified versions, and any portions
* thereof, and that both notices appear in supporting documentation.
*
* CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
* CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR
* ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
*
* Carnegie Mellon requests users of this software to return to
*
* Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU
* School of Computer Science
* Carnegie Mellon University
* Pittsburgh PA 15213-3890
*
* any improvements or extensions that they make and grant Carnegie Mellon
* the rights to redistribute these changes.
*/
/*
*/
/*
* File: kern_return.h
* Author: Avadis Tevanian, Jr., Michael Wayne Young
* Date: 1985
*
* Machine-dependent kernel return definitions.
*/
#ifndef _MACH_I386_KERN_RETURN_H_
#define _MACH_I386_KERN_RETURN_H_
#ifndef ASSEMBLER
typedef int kern_return_t;
#endif /* ASSEMBLER */
#endif /* _MACH_I386_KERN_RETURN_H_ */

View File

@ -0,0 +1,45 @@
/*
* Copyright (c) 2000 Apple Computer, Inc. All rights reserved.
*
* @APPLE_OSREFERENCE_LICENSE_HEADER_START@
*
* This file contains Original Code and/or Modifications of Original Code
* as defined in and that are subject to the Apple Public Source License
* Version 2.0 (the 'License'). You may not use this file except in
* compliance with the License. The rights granted to you under the License
* may not be used to create, or enable the creation or redistribution of,
* unlawful or unlicensed copies of an Apple operating system, or to
* circumvent, violate, or enable the circumvention or violation of, any
* terms of an Apple operating system software license agreement.
*
* Please obtain a copy of the License at
* http://www.opensource.apple.com/apsl/ and read it before using this file.
*
* The Original Code and all software distributed under the License are
* distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
* Please see the License for the specific language governing rights and
* limitations under the License.
*
* @APPLE_OSREFERENCE_LICENSE_HEADER_END@
*/
/*
* @OSF_COPYRIGHT@
*/
/* NDR record for Intel x86s */
#include <mach/ndr.h>
NDR_record_t NDR_record = {
0, /* mig_reserved */
0, /* mig_reserved */
0, /* mig_reserved */
NDR_PROTOCOL_2_0,
NDR_INT_LITTLE_ENDIAN,
NDR_CHAR_ASCII,
NDR_FLOAT_IEEE,
0,
};

View File

@ -0,0 +1,37 @@
/*
* Copyright (c) 2000 Apple Computer, Inc. All rights reserved.
*
* @APPLE_OSREFERENCE_LICENSE_HEADER_START@
*
* This file contains Original Code and/or Modifications of Original Code
* as defined in and that are subject to the Apple Public Source License
* Version 2.0 (the 'License'). You may not use this file except in
* compliance with the License. The rights granted to you under the License
* may not be used to create, or enable the creation or redistribution of,
* unlawful or unlicensed copies of an Apple operating system, or to
* circumvent, violate, or enable the circumvention or violation of, any
* terms of an Apple operating system software license agreement.
*
* Please obtain a copy of the License at
* http://www.opensource.apple.com/apsl/ and read it before using this file.
*
* The Original Code and all software distributed under the License are
* distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
* Please see the License for the specific language governing rights and
* limitations under the License.
*
* @APPLE_OSREFERENCE_LICENSE_HEADER_END@
*/
/*
* File: mach/i386/processor_info.h
*
* Data structure definitions for i386 specific processor control
*/
#ifndef _MACH_I386_PROCESSOR_INFO_H_
#define _MACH_I386_PROCESSOR_INFO_H_
#endif /* _MACH_I386_PROCESSOR_INFO_H_ */

View File

@ -0,0 +1,35 @@
/*
* Copyright (c) 2002,2000 Apple Computer, Inc. All rights reserved.
*
* @APPLE_OSREFERENCE_LICENSE_HEADER_START@
*
* This file contains Original Code and/or Modifications of Original Code
* as defined in and that are subject to the Apple Public Source License
* Version 2.0 (the 'License'). You may not use this file except in
* compliance with the License. The rights granted to you under the License
* may not be used to create, or enable the creation or redistribution of,
* unlawful or unlicensed copies of an Apple operating system, or to
* circumvent, violate, or enable the circumvention or violation of, any
* terms of an Apple operating system software license agreement.
*
* Please obtain a copy of the License at
* http://www.opensource.apple.com/apsl/ and read it before using this file.
*
* The Original Code and all software distributed under the License are
* distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
* Please see the License for the specific language governing rights and
* limitations under the License.
*
* @APPLE_OSREFERENCE_LICENSE_HEADER_END@
*/
/*
* @OSF_COPYRIGHT@
*/
#ifndef _MACH_I386_RPC_H_
#define _MACH_I386_RPC_H_
#endif /* _MACH_I386_RPC_H_ */

View File

@ -0,0 +1,433 @@
/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License, Version 1.0 only
* (the "License"). You may not use this file except in compliance
* with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* or http://www.opensolaris.org/os/licensing.
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*/
/*
* Copyright 2004 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#ifndef _MACH_I386_SDT_ISA_H
#define _MACH_I386_SDT_ISA_H
/*
* Only define when testing. This makes the calls into actual calls to
* test functions.
*/
/* #define DTRACE_CALL_TEST */
#define DTRACE_STRINGIFY(s) #s
#define DTRACE_TOSTRING(s) DTRACE_STRINGIFY(s)
#define DTRACE_LABEL(p, n) \
"__dtrace_probe$" DTRACE_TOSTRING(%=__LINE__) DTRACE_STRINGIFY(_##p##___##n) ":" "\n\t"
#ifdef DTRACE_CALL_TEST
#define DTRACE_CALL(p, n) \
DTRACE_LABEL(p,n) \
DTRACE_CALL_INSN(p,n)
#else
#define DTRACE_CALL(p, n) \
DTRACE_LABEL(p,n) \
DTRACE_NOPS
#endif
#ifdef __x86_64__
#define DTRACE_NOPS \
"nop" "\n\t" \
"nop" "\n\t" \
"nop" "\n\t"
#define DTRACE_CALL_INSN(p, n) \
"call _dtracetest" DTRACE_STRINGIFY(_##p##_##n) "\n\t"
#define ARG1_EXTENT 1
#define ARGS2_EXTENT 2
#define ARGS3_EXTENT 3
#define ARGS4_EXTENT 4
#define ARGS5_EXTENT 5
#define ARGS6_EXTENT 6
#define ARGS7_EXTENT 7
#define ARGS8_EXTENT 8
#define ARGS9_EXTENT 9
#define ARGS10_EXTENT 10
#define DTRACE_CALL0ARGS(provider, name) \
asm volatile ( \
DTRACE_CALL(provider, name) \
: \
: \
);
#define DTRACE_CALL1ARG(provider, name) \
asm volatile ("movq\t0x0(%0),%%rdi" "\n\t" \
DTRACE_CALL(provider, name) \
: \
: "r" (__dtrace_args) \
: "memory", "rdi" \
);
#define DTRACE_CALL2ARGS(provider, name) \
asm volatile ("movq\t0x0(%0),%%rdi" "\n\t" \
"movq\t0x8(%0),%%rsi" "\n\t" \
DTRACE_CALL(provider, name) \
: \
: "r" (__dtrace_args) \
: "memory", "rdi", "rsi" \
);
#define DTRACE_CALL3ARGS(provider, name) \
asm volatile ("movq\t0x0(%0),%%rdi" "\n\t" \
"movq\t0x8(%0),%%rsi" "\n\t" \
"movq\t0x10(%0),%%rdx" "\n\t" \
DTRACE_CALL(provider, name) \
: \
: "r" (__dtrace_args) \
: "memory", "rdi", "rsi", "rdx" \
);
#define DTRACE_CALL4ARGS(provider, name) \
asm volatile ("movq\t0x0(%0),%%rdi" "\n\t" \
"movq\t0x8(%0),%%rsi" "\n\t" \
"movq\t0x10(%0),%%rdx" "\n\t" \
"movq\t0x18(%0),%%rcx" "\n\t" \
DTRACE_CALL(provider, name) \
: \
: "r" (__dtrace_args) \
: "memory", "rdi", "rsi", "rdx", "rcx" \
);
#define DTRACE_CALL5ARGS(provider, name) \
asm volatile ("movq\t0x0(%0),%%rdi" "\n\t" \
"movq\t0x8(%0),%%rsi" "\n\t" \
"movq\t0x10(%0),%%rdx" "\n\t" \
"movq\t0x18(%0),%%rcx" "\n\t" \
"movq\t0x20(%0),%%r8" "\n\t" \
DTRACE_CALL(provider, name) \
: \
: "r" (__dtrace_args) \
: "memory", "rdi", "rsi", "rdx", "rcx", "r8" \
);
#define DTRACE_CALL6ARGS(provider, name) \
asm volatile ("movq\t0x0(%0),%%rdi" "\n\t" \
"movq\t0x8(%0),%%rsi" "\n\t" \
"movq\t0x10(%0),%%rdx" "\n\t" \
"movq\t0x18(%0),%%rcx" "\n\t" \
"movq\t0x20(%0),%%r8" "\n\t" \
"movq\t0x28(%0),%%r9" "\n\t" \
DTRACE_CALL(provider, name) \
: \
: "r" (__dtrace_args) \
: "memory", "rdi", "rsi", "rdx", "rcx", "r8", "r9" \
);
#define DTRACE_CALL7ARGS(provider, name) \
asm volatile ("subq\t$0x8,%%rsp" "\n\t" \
"movq\t0x0(%0),%%rdi" "\n\t" \
"movq\t0x8(%0),%%rsi" "\n\t" \
"movq\t0x10(%0),%%rdx" "\n\t" \
"movq\t0x18(%0),%%rcx" "\n\t" \
"movq\t0x20(%0),%%r8" "\n\t" \
"movq\t0x28(%0),%%r9" "\n\t" \
"movq\t0x30(%0),%%rax" "\n\t" \
"movq\t%%rax,0x0(%%rsp)" "\n\t" \
DTRACE_CALL(provider, name) \
"addq\t$0x8,%%rsp" "\n\t" \
: \
: "r" (__dtrace_args) \
: "memory", "rdi", "rsi", "rdx", "rcx", "r8", "r9", "rax" \
);
#define DTRACE_CALL8ARGS(provider, name) \
asm volatile ("subq\t$0x10,%%rsp" "\n\t" \
"movq\t0x0(%0),%%rdi" "\n\t" \
"movq\t0x8(%0),%%rsi" "\n\t" \
"movq\t0x10(%0),%%rdx" "\n\t" \
"movq\t0x18(%0),%%rcx" "\n\t" \
"movq\t0x20(%0),%%r8" "\n\t" \
"movq\t0x28(%0),%%r9" "\n\t" \
"movq\t0x30(%0),%%rax" "\n\t" \
"movq\t%%rax,0x0(%%rsp)" "\n\t" \
"movq\t0x38(%0),%%rax" "\n\t" \
"movq\t%%rax,0x8(%%rsp)" "\n\t" \
DTRACE_CALL(provider, name) \
"addq\t$0x10,%%rsp" "\n\t" \
: \
: "r" (__dtrace_args) \
: "memory", "rdi", "rsi", "rdx", "rcx", "r8", "r9", "rax" \
);
#endif // __x86_64__
#ifdef __i386__
#define DTRACE_NOPS \
"nop" "\n\t" \
"leal 0(%%esi), %%esi" "\n\t"
#define DTRACE_CALL_INSN(p, n) \
"call _dtracetest" DTRACE_STRINGIFY(_##p##_##n) "\n\t"
#define ARG1_EXTENT 1
#define ARGS2_EXTENT 2
#define ARGS3_EXTENT 4
#define ARGS4_EXTENT 4
#define ARGS5_EXTENT 8
#define ARGS6_EXTENT 8
#define ARGS7_EXTENT 8
#define ARGS8_EXTENT 8
#define ARGS9_EXTENT 12
#define ARGS10_EXTENT 12
/*
* Because this code is used in the kernel, we must not touch any floating point
* or specialized registers. This leaves the following registers:
*
* eax ; volatile, safe to use
* ebx ; PIC register, gcc error when used
* ecx ; volatile, safe to use
* edx ; volatile, safe to use
* esi ; non-volatile, otherwise safe to use
* edi ; non-volatile, otherwise safe to use
*
* Using any of the non volatile register causes a spill to stack which is almost
* certainly a net performance loss. Also, note that the array ref (__dtrace_args)
* consumes one free register. If all three of the volatile regs are used for load/store,
* the compiler will spill a register to hold the array ref.
*
* The end result is that we only pipeline two loads/stores at a time. Blech.
*/
#define DTRACE_CALL0ARGS(provider, name) \
asm volatile ( \
DTRACE_CALL(provider, name) \
"# eat trailing nl +tabfrom DTRACE_CALL" \
: \
: \
);
#define DTRACE_CALL1ARG(provider, name) \
asm volatile ("subl\t$0x10,%%esp" "\n\t" \
"movl\t0x0(%0),%%eax" "\n\t" \
"movl\t%%eax,0x0(%%esp)" "\n\t" \
DTRACE_CALL(provider, name) \
"addl\t$0x10,%%esp" \
: \
: "r" (__dtrace_args) \
: "memory", "eax" \
);
#define DTRACE_CALL2ARGS(provider, name) \
asm volatile ("subl\t$0x10,%%esp" "\n\t" \
"movl\t0x0(%0),%%eax" "\n\t" \
"movl\t0x4(%0),%%edx" "\n\t" \
"movl\t%%eax,0x0(%%esp)" "\n\t" \
"movl\t%%edx,0x4(%%esp)" "\n\t" \
DTRACE_CALL(provider, name) \
"addl\t$0x10,%%esp" \
: \
: "r" (__dtrace_args) \
: "memory", "eax", "edx" \
);
#define DTRACE_CALL3ARGS(provider, name) \
asm volatile ("subl\t$0x10,%%esp" "\n\t" \
"movl\t0x0(%0),%%eax" "\n\t" \
"movl\t0x4(%0),%%edx" "\n\t" \
"movl\t%%eax,0x0(%%esp)" "\n\t" \
"movl\t%%edx,0x4(%%esp)" "\n\t" \
"movl\t0x8(%0),%%eax" "\n\t" \
"movl\t%%eax,0x8(%%esp)" "\n\t" \
DTRACE_CALL(provider, name) \
"addl\t$0x10,%%esp" \
: \
: "r" (__dtrace_args) \
: "memory", "eax", "edx" \
);
#define DTRACE_CALL4ARGS(provider, name) \
asm volatile ("subl\t$0x10,%%esp" "\n\t" \
"movl\t0x0(%0),%%eax" "\n\t" \
"movl\t0x4(%0),%%edx" "\n\t" \
"movl\t%%eax,0x0(%%esp)" "\n\t" \
"movl\t%%edx,0x4(%%esp)" "\n\t" \
"movl\t0x8(%0),%%eax" "\n\t" \
"movl\t0xC(%0),%%edx" "\n\t" \
"movl\t%%eax,0x8(%%esp)" "\n\t" \
"movl\t%%edx,0xC(%%esp)" "\n\t" \
DTRACE_CALL(provider, name) \
"addl\t$0x10,%%esp" \
: \
: "r" (__dtrace_args) \
: "memory", "eax", "edx" \
);
#define DTRACE_CALL5ARGS(provider, name) \
asm volatile ("subl\t$0x20,%%esp" "\n\t" \
"movl\t0x0(%0),%%eax" "\n\t" \
"movl\t0x4(%0),%%edx" "\n\t" \
"movl\t%%eax,0x0(%%esp)" "\n\t" \
"movl\t%%edx,0x4(%%esp)" "\n\t" \
"movl\t0x8(%0),%%eax" "\n\t" \
"movl\t0xC(%0),%%edx" "\n\t" \
"movl\t%%eax,0x8(%%esp)" "\n\t" \
"movl\t%%edx,0xC(%%esp)" "\n\t" \
"movl\t0x10(%0),%%eax" "\n\t" \
"movl\t%%eax,0x10(%%esp)" "\n\t" \
DTRACE_CALL(provider, name) \
"addl\t$0x20,%%esp" \
: \
: "r" (__dtrace_args) \
: "memory", "eax", "edx" \
);
#define DTRACE_CALL6ARGS(provider, name) \
asm volatile ("subl\t$0x20,%%esp" "\n\t" \
"movl\t0x0(%0),%%eax" "\n\t" \
"movl\t0x4(%0),%%edx" "\n\t" \
"movl\t%%eax,0x0(%%esp)" "\n\t" \
"movl\t%%edx,0x4(%%esp)" "\n\t" \
"movl\t0x8(%0),%%eax" "\n\t" \
"movl\t0xC(%0),%%edx" "\n\t" \
"movl\t%%eax,0x8(%%esp)" "\n\t" \
"movl\t%%edx,0xC(%%esp)" "\n\t" \
"movl\t0x10(%0),%%eax" "\n\t" \
"movl\t0x14(%0),%%edx" "\n\t" \
"movl\t%%eax,0x10(%%esp)" "\n\t" \
"movl\t%%edx,0x14(%%esp)" "\n\t" \
DTRACE_CALL(provider, name) \
"addl\t$0x20,%%esp" \
: \
: "r" (__dtrace_args) \
: "memory", "eax", "edx" \
);
#define DTRACE_CALL7ARGS(provider, name) \
asm volatile ("subl\t$0x20,%%esp" "\n\t" \
"movl\t0x0(%0),%%eax" "\n\t" \
"movl\t0x4(%0),%%edx" "\n\t" \
"movl\t%%eax,0x0(%%esp)" "\n\t" \
"movl\t%%edx,0x4(%%esp)" "\n\t" \
"movl\t0x8(%0),%%eax" "\n\t" \
"movl\t0xC(%0),%%edx" "\n\t" \
"movl\t%%eax,0x8(%%esp)" "\n\t" \
"movl\t%%edx,0xC(%%esp)" "\n\t" \
"movl\t0x10(%0),%%eax" "\n\t" \
"movl\t0x14(%0),%%edx" "\n\t" \
"movl\t%%eax,0x10(%%esp)" "\n\t" \
"movl\t%%edx,0x14(%%esp)" "\n\t" \
"movl\t0x18(%0),%%eax" "\n\t" \
"movl\t%%eax,0x18(%%esp)" "\n\t" \
DTRACE_CALL(provider, name) \
"addl\t$0x20,%%esp" \
: \
: "r" (__dtrace_args) \
: "memory", "eax", "edx" \
);
#define DTRACE_CALL8ARGS(provider, name) \
asm volatile ("subl\t$0x20,%%esp" "\n\t" \
"movl\t0x0(%0),%%eax" "\n\t" \
"movl\t0x4(%0),%%edx" "\n\t" \
"movl\t%%eax,0x0(%%esp)" "\n\t" \
"movl\t%%edx,0x4(%%esp)" "\n\t" \
"movl\t0x8(%0),%%eax" "\n\t" \
"movl\t0xC(%0),%%edx" "\n\t" \
"movl\t%%eax,0x8(%%esp)" "\n\t" \
"movl\t%%edx,0xC(%%esp)" "\n\t" \
"movl\t0x10(%0),%%eax" "\n\t" \
"movl\t0x14(%0),%%edx" "\n\t" \
"movl\t%%eax,0x10(%%esp)" "\n\t" \
"movl\t%%edx,0x14(%%esp)" "\n\t" \
"movl\t0x18(%0),%%eax" "\n\t" \
"movl\t0x1C(%0),%%edx" "\n\t" \
"movl\t%%eax,0x18(%%esp)" "\n\t" \
"movl\t%%edx,0x1C(%%esp)" "\n\t" \
DTRACE_CALL(provider, name) \
"addl\t$0x20,%%esp" \
: \
: "r" (__dtrace_args) \
: "memory", "eax", "edx" \
);
#define DTRACE_CALL9ARGS(provider, name) \
asm volatile ("subl\t$0x30,%%esp" "\n\t" \
"movl\t0x0(%0),%%eax" "\n\t" \
"movl\t0x4(%0),%%edx" "\n\t" \
"movl\t%%eax,0x0(%%esp)" "\n\t" \
"movl\t%%edx,0x4(%%esp)" "\n\t" \
"movl\t0x8(%0),%%eax" "\n\t" \
"movl\t0xC(%0),%%edx" "\n\t" \
"movl\t%%eax,0x8(%%esp)" "\n\t" \
"movl\t%%edx,0xC(%%esp)" "\n\t" \
"movl\t0x10(%0),%%eax" "\n\t" \
"movl\t0x14(%0),%%edx" "\n\t" \
"movl\t%%eax,0x10(%%esp)" "\n\t" \
"movl\t%%edx,0x14(%%esp)" "\n\t" \
"movl\t0x18(%0),%%eax" "\n\t" \
"movl\t0x1C(%0),%%edx" "\n\t" \
"movl\t%%eax,0x18(%%esp)" "\n\t" \
"movl\t%%edx,0x1C(%%esp)" "\n\t" \
"movl\t0x20(%0),%%eax" "\n\t" \
"movl\t%%eax,0x20(%%esp)" "\n\t" \
DTRACE_CALL(provider, name) \
"addl\t$0x30,%%esp" \
: \
: "r" (__dtrace_args) \
: "memory", "eax", "edx" \
);
#define DTRACE_CALL10ARGS(provider, name) \
asm volatile ("subl\t$0x30,%%esp" "\n\t" \
"movl\t0x0(%0),%%eax" "\n\t" \
"movl\t0x4(%0),%%edx" "\n\t" \
"movl\t%%eax,0x0(%%esp)" "\n\t" \
"movl\t%%edx,0x4(%%esp)" "\n\t" \
"movl\t0x8(%0),%%eax" "\n\t" \
"movl\t0xC(%0),%%edx" "\n\t" \
"movl\t%%eax,0x8(%%esp)" "\n\t" \
"movl\t%%edx,0xC(%%esp)" "\n\t" \
"movl\t0x10(%0),%%eax" "\n\t" \
"movl\t0x14(%0),%%edx" "\n\t" \
"movl\t%%eax,0x10(%%esp)" "\n\t" \
"movl\t%%edx,0x14(%%esp)" "\n\t" \
"movl\t0x18(%0),%%eax" "\n\t" \
"movl\t0x1C(%0),%%edx" "\n\t" \
"movl\t%%eax,0x18(%%esp)" "\n\t" \
"movl\t%%edx,0x1C(%%esp)" "\n\t" \
"movl\t0x20(%0),%%eax" "\n\t" \
"movl\t0x24(%0),%%edx" "\n\t" \
"movl\t%%eax,0x20(%%esp)" "\n\t" \
"movl\t%%edx,0x24(%%esp)" "\n\t" \
DTRACE_CALL(provider, name) \
"addl\t$0x30,%%esp" \
: \
: "r" (__dtrace_args) \
: "memory", "eax", "edx" \
);
#endif // __i386__
#endif /* _MACH_I386_SDT_ISA_H */

View File

@ -0,0 +1,42 @@
/*
* Copyright (c) 2000-2006 Apple Computer, Inc. All rights reserved.
*
* @APPLE_OSREFERENCE_LICENSE_HEADER_START@
*
* This file contains Original Code and/or Modifications of Original Code
* as defined in and that are subject to the Apple Public Source License
* Version 2.0 (the 'License'). You may not use this file except in
* compliance with the License. The rights granted to you under the License
* may not be used to create, or enable the creation or redistribution of,
* unlawful or unlicensed copies of an Apple operating system, or to
* circumvent, violate, or enable the circumvention or violation of, any
* terms of an Apple operating system software license agreement.
*
* Please obtain a copy of the License at
* http://www.opensource.apple.com/apsl/ and read it before using this file.
*
* The Original Code and all software distributed under the License are
* distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
* Please see the License for the specific language governing rights and
* limitations under the License.
*
* @APPLE_OSREFERENCE_LICENSE_HEADER_END@
*/
/*
* @OSF_COPYRIGHT@
*/
#ifndef _MACH_I386_THREAD_STATE_H_
#define _MACH_I386_THREAD_STATE_H_
/* Size of maximum exported thread state in 32-bit words */
#define I386_THREAD_STATE_MAX (614) /* Size of biggest state possible */
#if defined (__i386__) || defined(__x86_64__)
#define THREAD_STATE_MAX I386_THREAD_STATE_MAX
#endif
#endif /* _MACH_I386_THREAD_STATE_H_ */

View File

@ -0,0 +1,362 @@
/*
* Copyright (c) 2000-2020 Apple Computer, Inc. All rights reserved.
*
* @APPLE_OSREFERENCE_LICENSE_HEADER_START@
*
* This file contains Original Code and/or Modifications of Original Code
* as defined in and that are subject to the Apple Public Source License
* Version 2.0 (the 'License'). You may not use this file except in
* compliance with the License. The rights granted to you under the License
* may not be used to create, or enable the creation or redistribution of,
* unlawful or unlicensed copies of an Apple operating system, or to
* circumvent, violate, or enable the circumvention or violation of, any
* terms of an Apple operating system software license agreement.
*
* Please obtain a copy of the License at
* http://www.opensource.apple.com/apsl/ and read it before using this file.
*
* The Original Code and all software distributed under the License are
* distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
* Please see the License for the specific language governing rights and
* limitations under the License.
*
* @APPLE_OSREFERENCE_LICENSE_HEADER_END@
*/
/*
* @OSF_COPYRIGHT@
*/
/*
* Mach Operating System
* Copyright (c) 1991,1990,1989 Carnegie Mellon University
* All Rights Reserved.
*
* Permission to use, copy, modify and distribute this software and its
* documentation is hereby granted, provided that both the copyright
* notice and this permission notice appear in all copies of the
* software, derivative works or modified versions, and any portions
* thereof, and that both notices appear in supporting documentation.
*
* CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
* CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR
* ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
*
* Carnegie Mellon requests users of this software to return to
*
* Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU
* School of Computer Science
* Carnegie Mellon University
* Pittsburgh PA 15213-3890
*
* any improvements or extensions that they make and grant Carnegie Mellon
* the rights to redistribute these changes.
*/
/*
*/
/*
* File: thread_status.h
* Author: Avadis Tevanian, Jr.
* Date: 1985
*
* This file contains the structure definitions for the thread
* state as applied to I386 processors.
*/
#ifndef _MACH_I386_THREAD_STATUS_H_
#define _MACH_I386_THREAD_STATUS_H_
#include <mach/machine/_structs.h>
#include <mach/message.h>
#include <mach/i386/fp_reg.h>
#include <mach/i386/thread_state.h>
#include <i386/eflags.h>
/*
* the i386_xxxx form is kept for legacy purposes since these types
* are externally known... eventually they should be deprecated.
* our internal implementation has moved to the following naming convention
*
* x86_xxxx32 names are used to deal with 32 bit states
* x86_xxxx64 names are used to deal with 64 bit states
* x86_xxxx names are used to deal with either 32 or 64 bit states
* via a self-describing mechanism
*/
/*
* these are the legacy names which should be deprecated in the future
* they are externally known which is the only reason we don't just get
* rid of them
*/
#define i386_THREAD_STATE 1
#define i386_FLOAT_STATE 2
#define i386_EXCEPTION_STATE 3
/*
* THREAD_STATE_FLAVOR_LIST 0
* these are the supported flavors
*/
#define x86_THREAD_STATE32 1
#define x86_FLOAT_STATE32 2
#define x86_EXCEPTION_STATE32 3
#define x86_THREAD_STATE64 4
#define x86_FLOAT_STATE64 5
#define x86_EXCEPTION_STATE64 6
#define x86_THREAD_STATE 7
#define x86_FLOAT_STATE 8
#define x86_EXCEPTION_STATE 9
#define x86_DEBUG_STATE32 10
#define x86_DEBUG_STATE64 11
#define x86_DEBUG_STATE 12
#define THREAD_STATE_NONE 13
/* 14 and 15 are used for the internal x86_SAVED_STATE flavours */
/* Arrange for flavors to take sequential values, 32-bit, 64-bit, non-specific */
#define x86_AVX_STATE32 16
#define x86_AVX_STATE64 (x86_AVX_STATE32 + 1)
#define x86_AVX_STATE (x86_AVX_STATE32 + 2)
#define x86_AVX512_STATE32 19
#define x86_AVX512_STATE64 (x86_AVX512_STATE32 + 1)
#define x86_AVX512_STATE (x86_AVX512_STATE32 + 2)
#define x86_PAGEIN_STATE 22
#define x86_THREAD_FULL_STATE64 23
#define x86_INSTRUCTION_STATE 24
#define x86_LAST_BRANCH_STATE 25
/*
* Largest state on this machine:
* (be sure mach/machine/thread_state.h matches!)
*/
#define THREAD_MACHINE_STATE_MAX THREAD_STATE_MAX
/*
* VALID_THREAD_STATE_FLAVOR is a platform specific macro that when passed
* an exception flavor will return if that is a defined flavor for that
* platform. The macro must be manually updated to include all of the valid
* exception flavors as defined above.
*/
#define VALID_THREAD_STATE_FLAVOR(x) \
((x == x86_THREAD_STATE32) || \
(x == x86_FLOAT_STATE32) || \
(x == x86_EXCEPTION_STATE32) || \
(x == x86_DEBUG_STATE32) || \
(x == x86_THREAD_STATE64) || \
(x == x86_THREAD_FULL_STATE64) || \
(x == x86_FLOAT_STATE64) || \
(x == x86_EXCEPTION_STATE64) || \
(x == x86_DEBUG_STATE64) || \
(x == x86_THREAD_STATE) || \
(x == x86_FLOAT_STATE) || \
(x == x86_EXCEPTION_STATE) || \
(x == x86_DEBUG_STATE) || \
(x == x86_AVX_STATE32) || \
(x == x86_AVX_STATE64) || \
(x == x86_AVX_STATE) || \
(x == x86_AVX512_STATE32) || \
(x == x86_AVX512_STATE64) || \
(x == x86_AVX512_STATE) || \
(x == x86_PAGEIN_STATE) || \
(x == x86_INSTRUCTION_STATE) || \
(x == x86_LAST_BRANCH_STATE) || \
(x == THREAD_STATE_NONE))
struct x86_state_hdr {
uint32_t flavor;
uint32_t count;
};
typedef struct x86_state_hdr x86_state_hdr_t;
/*
* Default segment register values.
*/
#define USER_CODE_SELECTOR 0x0017
#define USER_DATA_SELECTOR 0x001f
#define KERN_CODE_SELECTOR 0x0008
#define KERN_DATA_SELECTOR 0x0010
/*
* to be deprecated in the future
*/
typedef _STRUCT_X86_THREAD_STATE32 i386_thread_state_t;
#define i386_THREAD_STATE_COUNT ((mach_msg_type_number_t) \
( sizeof (i386_thread_state_t) / sizeof (int) ))
typedef _STRUCT_X86_THREAD_STATE32 x86_thread_state32_t;
#define x86_THREAD_STATE32_COUNT ((mach_msg_type_number_t) \
( sizeof (x86_thread_state32_t) / sizeof (int) ))
/*
* to be deprecated in the future
*/
typedef _STRUCT_X86_FLOAT_STATE32 i386_float_state_t;
#define i386_FLOAT_STATE_COUNT ((mach_msg_type_number_t) \
(sizeof(i386_float_state_t)/sizeof(unsigned int)))
typedef _STRUCT_X86_FLOAT_STATE32 x86_float_state32_t;
#define x86_FLOAT_STATE32_COUNT ((mach_msg_type_number_t) \
(sizeof(x86_float_state32_t)/sizeof(unsigned int)))
typedef _STRUCT_X86_AVX_STATE32 x86_avx_state32_t;
#define x86_AVX_STATE32_COUNT ((mach_msg_type_number_t) \
(sizeof(x86_avx_state32_t)/sizeof(unsigned int)))
typedef _STRUCT_X86_AVX512_STATE32 x86_avx512_state32_t;
#define x86_AVX512_STATE32_COUNT ((mach_msg_type_number_t) \
(sizeof(x86_avx512_state32_t)/sizeof(unsigned int)))
/*
* to be deprecated in the future
*/
typedef _STRUCT_X86_EXCEPTION_STATE32 i386_exception_state_t;
#define i386_EXCEPTION_STATE_COUNT ((mach_msg_type_number_t) \
( sizeof (i386_exception_state_t) / sizeof (int) ))
typedef _STRUCT_X86_EXCEPTION_STATE32 x86_exception_state32_t;
#define x86_EXCEPTION_STATE32_COUNT ((mach_msg_type_number_t) \
( sizeof (x86_exception_state32_t) / sizeof (int) ))
#define I386_EXCEPTION_STATE_COUNT i386_EXCEPTION_STATE_COUNT
typedef _STRUCT_X86_DEBUG_STATE32 x86_debug_state32_t;
#define x86_DEBUG_STATE32_COUNT ((mach_msg_type_number_t) \
( sizeof (x86_debug_state32_t) / sizeof (int) ))
#define X86_DEBUG_STATE32_COUNT x86_DEBUG_STATE32_COUNT
typedef _STRUCT_X86_THREAD_STATE64 x86_thread_state64_t;
#define x86_THREAD_STATE64_COUNT ((mach_msg_type_number_t) \
( sizeof (x86_thread_state64_t) / sizeof (int) ))
typedef _STRUCT_X86_THREAD_FULL_STATE64 x86_thread_full_state64_t;
#define x86_THREAD_FULL_STATE64_COUNT ((mach_msg_type_number_t) \
( sizeof (x86_thread_full_state64_t) / sizeof (int) ))
typedef _STRUCT_X86_FLOAT_STATE64 x86_float_state64_t;
#define x86_FLOAT_STATE64_COUNT ((mach_msg_type_number_t) \
(sizeof(x86_float_state64_t)/sizeof(unsigned int)))
typedef _STRUCT_X86_AVX_STATE64 x86_avx_state64_t;
#define x86_AVX_STATE64_COUNT ((mach_msg_type_number_t) \
(sizeof(x86_avx_state64_t)/sizeof(unsigned int)))
typedef _STRUCT_X86_AVX512_STATE64 x86_avx512_state64_t;
#define x86_AVX512_STATE64_COUNT ((mach_msg_type_number_t) \
(sizeof(x86_avx512_state64_t)/sizeof(unsigned int)))
typedef _STRUCT_X86_EXCEPTION_STATE64 x86_exception_state64_t;
#define x86_EXCEPTION_STATE64_COUNT ((mach_msg_type_number_t) \
( sizeof (x86_exception_state64_t) / sizeof (int) ))
#define X86_EXCEPTION_STATE64_COUNT x86_EXCEPTION_STATE64_COUNT
typedef _STRUCT_X86_DEBUG_STATE64 x86_debug_state64_t;
#define x86_DEBUG_STATE64_COUNT ((mach_msg_type_number_t) \
( sizeof (x86_debug_state64_t) / sizeof (int) ))
#define X86_DEBUG_STATE64_COUNT x86_DEBUG_STATE64_COUNT
typedef _STRUCT_X86_PAGEIN_STATE x86_pagein_state_t;
#define x86_PAGEIN_STATE_COUNT \
((mach_msg_type_number_t)(sizeof(x86_pagein_state_t) / sizeof(int)))
#define X86_PAGEIN_STATE_COUNT x86_PAGEIN_STATE_COUNT
typedef _STRUCT_X86_INSTRUCTION_STATE x86_instruction_state_t;
#define x86_INSTRUCTION_STATE_COUNT \
((mach_msg_type_number_t)(sizeof(x86_instruction_state_t) / sizeof(int)))
#define X86_INSTRUCTION_STATE_COUNT x86_INSTRUCTION_STATE_COUNT
typedef _STRUCT_LAST_BRANCH_STATE last_branch_state_t;
#define x86_LAST_BRANCH_STATE_COUNT \
((mach_msg_type_number_t)(sizeof(last_branch_state_t) / sizeof(int)))
#define X86_LAST_BRANCH_STATE_COUNT x86_LAST_BRANCH_STATE_COUNT
/*
* Combined thread, float and exception states
*/
struct x86_thread_state {
x86_state_hdr_t tsh;
union {
x86_thread_state32_t ts32;
x86_thread_state64_t ts64;
} uts;
};
struct x86_float_state {
x86_state_hdr_t fsh;
union {
x86_float_state32_t fs32;
x86_float_state64_t fs64;
} ufs;
};
struct x86_exception_state {
x86_state_hdr_t esh;
union {
x86_exception_state32_t es32;
x86_exception_state64_t es64;
} ues;
};
struct x86_debug_state {
x86_state_hdr_t dsh;
union {
x86_debug_state32_t ds32;
x86_debug_state64_t ds64;
} uds;
};
struct x86_avx_state {
x86_state_hdr_t ash;
union {
x86_avx_state32_t as32;
x86_avx_state64_t as64;
} ufs;
};
struct x86_avx512_state {
x86_state_hdr_t ash;
union {
x86_avx512_state32_t as32;
x86_avx512_state64_t as64;
} ufs;
};
typedef struct x86_thread_state x86_thread_state_t;
#define x86_THREAD_STATE_COUNT ((mach_msg_type_number_t) \
( sizeof (x86_thread_state_t) / sizeof (int) ))
typedef struct x86_float_state x86_float_state_t;
#define x86_FLOAT_STATE_COUNT ((mach_msg_type_number_t) \
(sizeof(x86_float_state_t)/sizeof(unsigned int)))
typedef struct x86_exception_state x86_exception_state_t;
#define x86_EXCEPTION_STATE_COUNT ((mach_msg_type_number_t) \
(sizeof(x86_exception_state_t)/sizeof(unsigned int)))
typedef struct x86_debug_state x86_debug_state_t;
#define x86_DEBUG_STATE_COUNT ((mach_msg_type_number_t) \
(sizeof(x86_debug_state_t)/sizeof(unsigned int)))
typedef struct x86_avx_state x86_avx_state_t;
#define x86_AVX_STATE_COUNT ((mach_msg_type_number_t) \
(sizeof(x86_avx_state_t)/sizeof(unsigned int)))
typedef struct x86_avx512_state x86_avx512_state_t;
#define x86_AVX512_STATE_COUNT ((mach_msg_type_number_t) \
(sizeof(x86_avx512_state_t)/sizeof(unsigned int)))
/*
* Machine-independent way for servers and Mach's exception mechanism to
* choose the most efficient state flavor for exception RPC's:
*/
#define MACHINE_THREAD_STATE x86_THREAD_STATE
#define MACHINE_THREAD_STATE_COUNT x86_THREAD_STATE_COUNT
#endif /* _MACH_I386_THREAD_STATUS_H_ */

View File

@ -0,0 +1,157 @@
/*
* Copyright (c) 2000-2012 Apple Inc. All rights reserved.
*
* @APPLE_OSREFERENCE_LICENSE_HEADER_START@
*
* This file contains Original Code and/or Modifications of Original Code
* as defined in and that are subject to the Apple Public Source License
* Version 2.0 (the 'License'). You may not use this file except in
* compliance with the License. The rights granted to you under the License
* may not be used to create, or enable the creation or redistribution of,
* unlawful or unlicensed copies of an Apple operating system, or to
* circumvent, violate, or enable the circumvention or violation of, any
* terms of an Apple operating system software license agreement.
*
* Please obtain a copy of the License at
* http://www.opensource.apple.com/apsl/ and read it before using this file.
*
* The Original Code and all software distributed under the License are
* distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
* Please see the License for the specific language governing rights and
* limitations under the License.
*
* @APPLE_OSREFERENCE_LICENSE_HEADER_END@
*/
/*
* @OSF_COPYRIGHT@
*/
/*
* Mach Operating System
* Copyright (c) 1991,1990,1989,1988 Carnegie Mellon University
* All Rights Reserved.
*
* Permission to use, copy, modify and distribute this software and its
* documentation is hereby granted, provided that both the copyright
* notice and this permission notice appear in all copies of the
* software, derivative works or modified versions, and any portions
* thereof, and that both notices appear in supporting documentation.
*
* CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
* CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR
* ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
*
* Carnegie Mellon requests users of this software to return to
*
* Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU
* School of Computer Science
* Carnegie Mellon University
* Pittsburgh PA 15213-3890
*
* any improvements or extensions that they make and grant Carnegie Mellon
* the rights to redistribute these changes.
*/
/*
* Copyright (c) 1994 The University of Utah and
* the Computer Systems Laboratory at the University of Utah (CSL).
* All rights reserved.
*
* Permission to use, copy, modify and distribute this software is hereby
* granted provided that (1) source code retains these copyright, permission,
* and disclaimer notices, and (2) redistributions including binaries
* reproduce the notices in supporting documentation, and (3) all advertising
* materials mentioning features or use of this software display the following
* acknowledgement: ``This product includes software developed by the
* Computer Systems Laboratory at the University of Utah.''
*
* THE UNIVERSITY OF UTAH AND CSL ALLOW FREE USE OF THIS SOFTWARE IN ITS "AS
* IS" CONDITION. THE UNIVERSITY OF UTAH AND CSL DISCLAIM ANY LIABILITY OF
* ANY KIND FOR ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
*
* CSL requests users of this software to return to csl-dist@cs.utah.edu any
* improvements that they make and grant CSL redistribution rights.
*
*/
/*
* File: vm_param.h
* Author: Avadis Tevanian, Jr.
* Date: 1985
*
* I386 machine dependent virtual memory parameters.
* Most of the declarations are preceeded by I386_ (or i386_)
* which is OK because only I386 specific code will be using
* them.
*/
#ifndef _MACH_I386_VM_PARAM_H_
#define _MACH_I386_VM_PARAM_H_
#if !defined(KERNEL) && !defined(__ASSEMBLER__)
#include <mach/vm_page_size.h>
#endif
#define BYTE_SIZE 8 /* byte size in bits */
#define I386_PGBYTES 4096 /* bytes per 80386 page */
#define I386_PGSHIFT 12 /* bitshift for pages */
#if !defined(__MAC_OS_X_VERSION_MIN_REQUIRED) || (__MAC_OS_X_VERSION_MIN_REQUIRED < 101600)
#define PAGE_SHIFT I386_PGSHIFT
#define PAGE_SIZE I386_PGBYTES
#define PAGE_MASK (PAGE_SIZE-1)
#else /* !defined(__MAC_OS_X_VERSION_MIN_REQUIRED) || (__MAC_OS_X_VERSION_MIN_REQUIRED < 101600) */
#define PAGE_SHIFT vm_page_shift
#define PAGE_SIZE vm_page_size
#define PAGE_MASK vm_page_mask
#endif /* !defined(__MAC_OS_X_VERSION_MIN_REQUIRED) || (__MAC_OS_X_VERSION_MIN_REQUIRED < 101600) */
#define PAGE_MAX_SHIFT 14
#define PAGE_MAX_SIZE (1 << PAGE_MAX_SHIFT)
#define PAGE_MAX_MASK (PAGE_MAX_SIZE-1)
#define PAGE_MIN_SHIFT 12
#define PAGE_MIN_SIZE (1 << PAGE_MIN_SHIFT)
#define PAGE_MIN_MASK (PAGE_MIN_SIZE-1)
#define VM_MIN_ADDRESS64 ((user_addr_t) 0x0000000000000000ULL)
/*
* default top of user stack... it grows down from here
*/
#define VM_USRSTACK64 ((user_addr_t) 0x00007FFEEFC00000ULL)
/*
* XXX TODO: Obsolete?
*/
#define VM_DYLD64 ((user_addr_t) 0x00007FFF5FC00000ULL)
#define VM_LIB64_SHR_DATA ((user_addr_t) 0x00007FFF60000000ULL)
#define VM_LIB64_SHR_TEXT ((user_addr_t) 0x00007FFF80000000ULL)
/*
* the end of the usable user address space , for now about 47 bits.
* the 64 bit commpage is past the end of this
*/
#define VM_MAX_PAGE_ADDRESS ((user_addr_t) 0x00007FFFFFE00000ULL)
/*
* canonical end of user address space for limits checking
*/
#define VM_MAX_USER_PAGE_ADDRESS ((user_addr_t)0x00007FFFFFFFF000ULL)
/* system-wide values */
#define MACH_VM_MIN_ADDRESS ((mach_vm_offset_t) 0)
#define MACH_VM_MAX_ADDRESS ((mach_vm_offset_t) VM_MAX_PAGE_ADDRESS)
/* process-relative values (all 32-bit legacy only for now) */
#define VM_MIN_ADDRESS ((vm_offset_t) 0)
#define VM_USRSTACK32 ((vm_offset_t) 0xC0000000) /* ASLR slides stack down by up to 1 MB */
#define VM_MAX_ADDRESS ((vm_offset_t) 0xFFE00000)
#endif /* _MACH_I386_VM_PARAM_H_ */

View File

@ -0,0 +1,141 @@
/*
* Copyright (c) 2000-2016 Apple Computer, Inc. All rights reserved.
*
* @APPLE_OSREFERENCE_LICENSE_HEADER_START@
*
* This file contains Original Code and/or Modifications of Original Code
* as defined in and that are subject to the Apple Public Source License
* Version 2.0 (the 'License'). You may not use this file except in
* compliance with the License. The rights granted to you under the License
* may not be used to create, or enable the creation or redistribution of,
* unlawful or unlicensed copies of an Apple operating system, or to
* circumvent, violate, or enable the circumvention or violation of, any
* terms of an Apple operating system software license agreement.
*
* Please obtain a copy of the License at
* http://www.opensource.apple.com/apsl/ and read it before using this file.
*
* The Original Code and all software distributed under the License are
* distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
* Please see the License for the specific language governing rights and
* limitations under the License.
*
* @APPLE_OSREFERENCE_LICENSE_HEADER_END@
*/
/*
* @OSF_COPYRIGHT@
*/
/*
* Mach Operating System
* Copyright (c) 1991,1990,1989,1988 Carnegie Mellon University
* All Rights Reserved.
*
* Permission to use, copy, modify and distribute this software and its
* documentation is hereby granted, provided that both the copyright
* notice and this permission notice appear in all copies of the
* software, derivative works or modified versions, and any portions
* thereof, and that both notices appear in supporting documentation.
*
* CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
* CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR
* ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
*
* Carnegie Mellon requests users of this software to return to
*
* Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU
* School of Computer Science
* Carnegie Mellon University
* Pittsburgh PA 15213-3890
*
* any improvements or extensions that they make and grant Carnegie Mellon
* the rights to redistribute these changes.
*/
/*
*/
/*
* File: vm_types.h
* Author: Avadis Tevanian, Jr.
* Date: 1985
*
* Header file for VM data types. I386 version.
*/
#ifndef _MACH_I386_VM_TYPES_H_
#define _MACH_I386_VM_TYPES_H_
#ifndef ASSEMBLER
#include <i386/_types.h>
#include <stdint.h>
/*
* natural_t and integer_t are Mach's legacy types for machine-
* independent integer types (unsigned, and signed, respectively).
* Their original purpose was to define other types in a machine/
* compiler independent way.
*
* They also had an implicit "same size as pointer" characteristic
* to them (i.e. Mach's traditional types are very ILP32 or ILP64
* centric). We support x86 ABIs that do not follow either of
* these models (specifically LP64). Therefore, we had to make a
* choice between making these types scale with pointers or stay
* tied to integers. Because their use is predominantly tied to
* to the size of an integer, we are keeping that association and
* breaking free from pointer size guarantees.
*
* New use of these types is discouraged.
*/
typedef __darwin_natural_t natural_t;
typedef int integer_t;
/*
* A vm_offset_t is a type-neutral pointer,
* e.g. an offset into a virtual memory space.
*/
#ifdef __LP64__
typedef uintptr_t vm_offset_t;
#else /* __LP64__ */
typedef natural_t vm_offset_t;
#endif /* __LP64__ */
/*
* A vm_size_t is the proper type for e.g.
* expressing the difference between two
* vm_offset_t entities.
*/
#ifdef __LP64__
typedef uintptr_t vm_size_t;
#else /* __LP64__ */
typedef natural_t vm_size_t;
#endif /* __LP64__ */
/*
* This new type is independent of a particular vm map's
* implementation size - and represents appropriate types
* for all possible maps. This is used for interfaces
* where the size of the map is not known - or we don't
* want to have to distinguish.
*/
typedef uint64_t mach_vm_address_t;
typedef uint64_t mach_vm_offset_t;
typedef uint64_t mach_vm_size_t;
typedef uint64_t vm_map_offset_t;
typedef uint64_t vm_map_address_t;
typedef uint64_t vm_map_size_t;
typedef mach_vm_address_t mach_port_context_t;
#endif /* ASSEMBLER */
/*
* If composing messages by hand (please do not)
*/
#define MACH_MSG_TYPE_INTEGER_T MACH_MSG_TYPE_INTEGER_32
#endif /* _MACH_I386_VM_TYPES_H_ */

View File

@ -0,0 +1,342 @@
/*
* Copyright (c) 2000 Apple Computer, Inc. All rights reserved.
*
* @APPLE_OSREFERENCE_LICENSE_HEADER_START@
*
* This file contains Original Code and/or Modifications of Original Code
* as defined in and that are subject to the Apple Public Source License
* Version 2.0 (the 'License'). You may not use this file except in
* compliance with the License. The rights granted to you under the License
* may not be used to create, or enable the creation or redistribution of,
* unlawful or unlicensed copies of an Apple operating system, or to
* circumvent, violate, or enable the circumvention or violation of, any
* terms of an Apple operating system software license agreement.
*
* Please obtain a copy of the License at
* http://www.opensource.apple.com/apsl/ and read it before using this file.
*
* The Original Code and all software distributed under the License are
* distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
* Please see the License for the specific language governing rights and
* limitations under the License.
*
* @APPLE_OSREFERENCE_LICENSE_HEADER_END@
*/
/*
* @OSF_COPYRIGHT@
*/
/*
* Mach Operating System
* Copyright (c) 1991,1990,1989,1988,1987 Carnegie Mellon University
* All Rights Reserved.
*
* Permission to use, copy, modify and distribute this software and its
* documentation is hereby granted, provided that both the copyright
* notice and this permission notice appear in all copies of the
* software, derivative works or modified versions, and any portions
* thereof, and that both notices appear in supporting documentation.
*
* CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
* CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR
* ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
*
* Carnegie Mellon requests users of this software to return to
*
* Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU
* School of Computer Science
* Carnegie Mellon University
* Pittsburgh PA 15213-3890
*
* any improvements or extensions that they make and grant Carnegie Mellon
* the rights to redistribute these changes.
*/
/*
*/
/*
* File: h/kern_return.h
* Author: Avadis Tevanian, Jr.
* Date: 1985
*
* Kernel return codes.
*
*/
#ifndef _MACH_KERN_RETURN_H_
#define _MACH_KERN_RETURN_H_
#include <mach/machine/kern_return.h>
#define KERN_SUCCESS 0
#define KERN_INVALID_ADDRESS 1
/* Specified address is not currently valid.
*/
#define KERN_PROTECTION_FAILURE 2
/* Specified memory is valid, but does not permit the
* required forms of access.
*/
#define KERN_NO_SPACE 3
/* The address range specified is already in use, or
* no address range of the size specified could be
* found.
*/
#define KERN_INVALID_ARGUMENT 4
/* The function requested was not applicable to this
* type of argument, or an argument is invalid
*/
#define KERN_FAILURE 5
/* The function could not be performed. A catch-all.
*/
#define KERN_RESOURCE_SHORTAGE 6
/* A system resource could not be allocated to fulfill
* this request. This failure may not be permanent.
*/
#define KERN_NOT_RECEIVER 7
/* The task in question does not hold receive rights
* for the port argument.
*/
#define KERN_NO_ACCESS 8
/* Bogus access restriction.
*/
#define KERN_MEMORY_FAILURE 9
/* During a page fault, the target address refers to a
* memory object that has been destroyed. This
* failure is permanent.
*/
#define KERN_MEMORY_ERROR 10
/* During a page fault, the memory object indicated
* that the data could not be returned. This failure
* may be temporary; future attempts to access this
* same data may succeed, as defined by the memory
* object.
*/
#define KERN_ALREADY_IN_SET 11
/* The receive right is already a member of the portset.
*/
#define KERN_NOT_IN_SET 12
/* The receive right is not a member of a port set.
*/
#define KERN_NAME_EXISTS 13
/* The name already denotes a right in the task.
*/
#define KERN_ABORTED 14
/* The operation was aborted. Ipc code will
* catch this and reflect it as a message error.
*/
#define KERN_INVALID_NAME 15
/* The name doesn't denote a right in the task.
*/
#define KERN_INVALID_TASK 16
/* Target task isn't an active task.
*/
#define KERN_INVALID_RIGHT 17
/* The name denotes a right, but not an appropriate right.
*/
#define KERN_INVALID_VALUE 18
/* A blatant range error.
*/
#define KERN_UREFS_OVERFLOW 19
/* Operation would overflow limit on user-references.
*/
#define KERN_INVALID_CAPABILITY 20
/* The supplied (port) capability is improper.
*/
#define KERN_RIGHT_EXISTS 21
/* The task already has send or receive rights
* for the port under another name.
*/
#define KERN_INVALID_HOST 22
/* Target host isn't actually a host.
*/
#define KERN_MEMORY_PRESENT 23
/* An attempt was made to supply "precious" data
* for memory that is already present in a
* memory object.
*/
#define KERN_MEMORY_DATA_MOVED 24
/* A page was requested of a memory manager via
* memory_object_data_request for an object using
* a MEMORY_OBJECT_COPY_CALL strategy, with the
* VM_PROT_WANTS_COPY flag being used to specify
* that the page desired is for a copy of the
* object, and the memory manager has detected
* the page was pushed into a copy of the object
* while the kernel was walking the shadow chain
* from the copy to the object. This error code
* is delivered via memory_object_data_error
* and is handled by the kernel (it forces the
* kernel to restart the fault). It will not be
* seen by users.
*/
#define KERN_MEMORY_RESTART_COPY 25
/* A strategic copy was attempted of an object
* upon which a quicker copy is now possible.
* The caller should retry the copy using
* vm_object_copy_quickly. This error code
* is seen only by the kernel.
*/
#define KERN_INVALID_PROCESSOR_SET 26
/* An argument applied to assert processor set privilege
* was not a processor set control port.
*/
#define KERN_POLICY_LIMIT 27
/* The specified scheduling attributes exceed the thread's
* limits.
*/
#define KERN_INVALID_POLICY 28
/* The specified scheduling policy is not currently
* enabled for the processor set.
*/
#define KERN_INVALID_OBJECT 29
/* The external memory manager failed to initialize the
* memory object.
*/
#define KERN_ALREADY_WAITING 30
/* A thread is attempting to wait for an event for which
* there is already a waiting thread.
*/
#define KERN_DEFAULT_SET 31
/* An attempt was made to destroy the default processor
* set.
*/
#define KERN_EXCEPTION_PROTECTED 32
/* An attempt was made to fetch an exception port that is
* protected, or to abort a thread while processing a
* protected exception.
*/
#define KERN_INVALID_LEDGER 33
/* A ledger was required but not supplied.
*/
#define KERN_INVALID_MEMORY_CONTROL 34
/* The port was not a memory cache control port.
*/
#define KERN_INVALID_SECURITY 35
/* An argument supplied to assert security privilege
* was not a host security port.
*/
#define KERN_NOT_DEPRESSED 36
/* thread_depress_abort was called on a thread which
* was not currently depressed.
*/
#define KERN_TERMINATED 37
/* Object has been terminated and is no longer available
*/
#define KERN_LOCK_SET_DESTROYED 38
/* Lock set has been destroyed and is no longer available.
*/
#define KERN_LOCK_UNSTABLE 39
/* The thread holding the lock terminated before releasing
* the lock
*/
#define KERN_LOCK_OWNED 40
/* The lock is already owned by another thread
*/
#define KERN_LOCK_OWNED_SELF 41
/* The lock is already owned by the calling thread
*/
#define KERN_SEMAPHORE_DESTROYED 42
/* Semaphore has been destroyed and is no longer available.
*/
#define KERN_RPC_SERVER_TERMINATED 43
/* Return from RPC indicating the target server was
* terminated before it successfully replied
*/
#define KERN_RPC_TERMINATE_ORPHAN 44
/* Terminate an orphaned activation.
*/
#define KERN_RPC_CONTINUE_ORPHAN 45
/* Allow an orphaned activation to continue executing.
*/
#define KERN_NOT_SUPPORTED 46
/* Empty thread activation (No thread linked to it)
*/
#define KERN_NODE_DOWN 47
/* Remote node down or inaccessible.
*/
#define KERN_NOT_WAITING 48
/* A signalled thread was not actually waiting. */
#define KERN_OPERATION_TIMED_OUT 49
/* Some thread-oriented operation (semaphore_wait) timed out
*/
#define KERN_CODESIGN_ERROR 50
/* During a page fault, indicates that the page was rejected
* as a result of a signature check.
*/
#define KERN_POLICY_STATIC 51
/* The requested property cannot be changed at this time.
*/
#define KERN_INSUFFICIENT_BUFFER_SIZE 52
/* The provided buffer is of insufficient size for the requested data.
*/
#define KERN_DENIED 53
/* Denied by security policy
*/
#define KERN_MISSING_KC 54
/* The KC on which the function is operating is missing
*/
#define KERN_INVALID_KC 55
/* The KC on which the function is operating is invalid
*/
#define KERN_RETURN_MAX 0x100
/* Maximum return value allowable
*/
#endif /* _MACH_KERN_RETURN_H_ */

180
ref/Apple/MachO/mach/kmod.h Normal file
View File

@ -0,0 +1,180 @@
/*
* Copyright (c) 2000-2007 Apple Inc. All rights reserved.
*
* @APPLE_OSREFERENCE_LICENSE_HEADER_START@
*
* This file contains Original Code and/or Modifications of Original Code
* as defined in and that are subject to the Apple Public Source License
* Version 2.0 (the 'License'). You may not use this file except in
* compliance with the License. The rights granted to you under the License
* may not be used to create, or enable the creation or redistribution of,
* unlawful or unlicensed copies of an Apple operating system, or to
* circumvent, violate, or enable the circumvention or violation of, any
* terms of an Apple operating system software license agreement.
*
* Please obtain a copy of the License at
* http://www.opensource.apple.com/apsl/ and read it before using this file.
*
* The Original Code and all software distributed under the License are
* distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
* Please see the License for the specific language governing rights and
* limitations under the License.
*
* @APPLE_OSREFERENCE_LICENSE_HEADER_END@
*/
/*
* NOTICE: This file was modified by SPARTA, Inc. in 2005 to introduce
* support for mandatory and extensible security protections. This notice
* is included in support of clause 2.2 (b) of the Apple Public License,
* Version 2.0.
*/
#ifndef _MACH_KMOD_H_
#define _MACH_KMOD_H_
#include <mach/kern_return.h>
#include <mach/mach_types.h>
#include <sys/cdefs.h>
__BEGIN_DECLS
#if PRAGMA_MARK
#pragma mark Basic macros & typedefs
#endif
/***********************************************************************
* Basic macros & typedefs
***********************************************************************/
#define KMOD_MAX_NAME 64
#define KMOD_RETURN_SUCCESS KERN_SUCCESS
#define KMOD_RETURN_FAILURE KERN_FAILURE
typedef int kmod_t;
struct kmod_info;
typedef kern_return_t kmod_start_func_t(struct kmod_info * ki, void * data);
typedef kern_return_t kmod_stop_func_t(struct kmod_info * ki, void * data);
#if PRAGMA_MARK
#pragma mark Structure definitions
#endif
/***********************************************************************
* Structure definitions
*
* All structures must be #pragma pack(4).
***********************************************************************/
#pragma pack(push, 4)
/* Run-time struct only; never saved to a file */
typedef struct kmod_reference {
struct kmod_reference * next;
struct kmod_info * info;
} kmod_reference_t;
/***********************************************************************
* Warning: Any changes to the kmod_info structure affect the
* KMOD_..._DECL macros below.
***********************************************************************/
/* The kmod_info_t structure is only safe to use inside the running
* kernel. If you need to work with a kmod_info_t structure outside
* the kernel, please use the compatibility definitions below.
*/
typedef struct kmod_info {
struct kmod_info * next;
int32_t info_version; // version of this structure
uint32_t id;
char name[KMOD_MAX_NAME];
char version[KMOD_MAX_NAME];
int32_t reference_count; // # linkage refs to this
kmod_reference_t * reference_list; // who this refs (links on)
vm_address_t address; // starting address
vm_size_t size; // total size
vm_size_t hdr_size; // unwired hdr size
kmod_start_func_t * start;
kmod_stop_func_t * stop;
} kmod_info_t;
/* A compatibility definition of kmod_info_t for 32-bit kexts.
*/
typedef struct kmod_info_32_v1 {
uint32_t next_addr;
int32_t info_version;
uint32_t id;
uint8_t name[KMOD_MAX_NAME];
uint8_t version[KMOD_MAX_NAME];
int32_t reference_count;
uint32_t reference_list_addr;
uint32_t address;
uint32_t size;
uint32_t hdr_size;
uint32_t start_addr;
uint32_t stop_addr;
} kmod_info_32_v1_t;
/* A compatibility definition of kmod_info_t for 64-bit kexts.
*/
typedef struct kmod_info_64_v1 {
uint64_t next_addr;
int32_t info_version;
uint32_t id;
uint8_t name[KMOD_MAX_NAME];
uint8_t version[KMOD_MAX_NAME];
int32_t reference_count;
uint64_t reference_list_addr;
uint64_t address;
uint64_t size;
uint64_t hdr_size;
uint64_t start_addr;
uint64_t stop_addr;
} kmod_info_64_v1_t;
#pragma pack(pop)
#if PRAGMA_MARK
#pragma mark Kmod structure declaration macros
#endif
/***********************************************************************
* Kmod structure declaration macros
***********************************************************************/
#define KMOD_INFO_NAME kmod_info
#define KMOD_INFO_VERSION 1
#define KMOD_DECL(name, version) \
static kmod_start_func_t name ## _module_start; \
static kmod_stop_func_t name ## _module_stop; \
kmod_info_t KMOD_INFO_NAME = { 0, KMOD_INFO_VERSION, -1U, \
{ #name }, { version }, -1, 0, 0, 0, 0, \
name ## _module_start, \
name ## _module_stop };
#define KMOD_EXPLICIT_DECL(name, version, start, stop) \
kmod_info_t KMOD_INFO_NAME = { 0, KMOD_INFO_VERSION, -1U, \
{ #name }, { version }, -1, 0, 0, 0, 0, \
start, stop };
#if PRAGMA_MARK
#pragma mark Kernel private declarations
#endif
/***********************************************************************
* Kernel private declarations.
***********************************************************************/
#if PRAGMA_MARK
#pragma mark Obsolete kmod stuff
#endif
/***********************************************************************
* These 3 should be dropped but they're referenced by MIG declarations.
***********************************************************************/
typedef void * kmod_args_t;
typedef int kmod_control_flavor_t;
typedef kmod_info_t * kmod_info_array_t;
__END_DECLS
#endif /* _MACH_KMOD_H_ */

View File

@ -0,0 +1,83 @@
/*
* Copyright (c) 2000 Apple Computer, Inc. All rights reserved.
*
* @APPLE_OSREFERENCE_LICENSE_HEADER_START@
*
* This file contains Original Code and/or Modifications of Original Code
* as defined in and that are subject to the Apple Public Source License
* Version 2.0 (the 'License'). You may not use this file except in
* compliance with the License. The rights granted to you under the License
* may not be used to create, or enable the creation or redistribution of,
* unlawful or unlicensed copies of an Apple operating system, or to
* circumvent, violate, or enable the circumvention or violation of, any
* terms of an Apple operating system software license agreement.
*
* Please obtain a copy of the License at
* http://www.opensource.apple.com/apsl/ and read it before using this file.
*
* The Original Code and all software distributed under the License are
* distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
* Please see the License for the specific language governing rights and
* limitations under the License.
*
* @APPLE_OSREFERENCE_LICENSE_HEADER_END@
*/
/*
* @OSF_COPYRIGHT@
*
*/
/*
* File: mach/lock_set.defs
* Author: Joseph CaraDonna
*
* Exported kernel calls
*
*/
subsystem
#if KERNEL_SERVER
KernelServer
#endif /* KERNEL_SERVER */
lock_set 617000;
#include <mach/std_types.defs>
#include <mach/mach_types.defs>
/*
* OBSOLETE interfaces
* a lock_set_t is created and destroyed through the task object.
* lock_set_create(task,&lock_set_t,...);
* lock_set_destroy(task,lock_set_t);
*/
/*
* OBSOLETE interfaces
*/
routine lock_acquire(
lock_set : lock_set_t;
lock_id : int);
routine lock_release(
lock_set : lock_set_t;
lock_id : int);
routine lock_try(
lock_set : lock_set_t;
lock_id : int);
routine lock_make_stable(
lock_set : lock_set_t;
lock_id : int);
routine lock_handoff(
lock_set : lock_set_t;
lock_id : int);
routine lock_handoff_accept(
lock_set : lock_set_t;
lock_id : int);
/* vim: set ft=c : */

View File

@ -0,0 +1,350 @@
#ifndef _lock_set_user_
#define _lock_set_user_
/* Module lock_set */
#include <string.h>
#include <mach/ndr.h>
#include <mach/boolean.h>
#include <mach/kern_return.h>
#include <mach/notify.h>
#include <mach/mach_types.h>
#include <mach/message.h>
#include <mach/mig_errors.h>
#include <mach/port.h>
/* BEGIN MIG_STRNCPY_ZEROFILL CODE */
#if defined(__has_include)
#if __has_include(<mach/mig_strncpy_zerofill_support.h>)
#ifndef USING_MIG_STRNCPY_ZEROFILL
#define USING_MIG_STRNCPY_ZEROFILL
#endif
#ifndef __MIG_STRNCPY_ZEROFILL_FORWARD_TYPE_DECLS__
#define __MIG_STRNCPY_ZEROFILL_FORWARD_TYPE_DECLS__
#ifdef __cplusplus
extern "C" {
#endif
extern int mig_strncpy_zerofill(char *dest, const char *src, int len) __attribute__((weak_import));
#ifdef __cplusplus
}
#endif
#endif /* __MIG_STRNCPY_ZEROFILL_FORWARD_TYPE_DECLS__ */
#endif /* __has_include(<mach/mig_strncpy_zerofill_support.h>) */
#endif /* __has_include */
/* END MIG_STRNCPY_ZEROFILL CODE */
#ifdef AUTOTEST
#ifndef FUNCTION_PTR_T
#define FUNCTION_PTR_T
typedef void (*function_ptr_t)(mach_port_t, char *, mach_msg_type_number_t);
typedef struct {
char *name;
function_ptr_t function;
} function_table_entry;
typedef function_table_entry *function_table_t;
#endif /* FUNCTION_PTR_T */
#endif /* AUTOTEST */
#ifndef lock_set_MSG_COUNT
#define lock_set_MSG_COUNT 6
#endif /* lock_set_MSG_COUNT */
#include <mach/std_types.h>
#include <mach/mig.h>
#include <mach/mig.h>
#include <mach/mach_types.h>
#ifdef __BeforeMigUserHeader
__BeforeMigUserHeader
#endif /* __BeforeMigUserHeader */
#include <sys/cdefs.h>
__BEGIN_DECLS
/* Routine lock_acquire */
#ifdef mig_external
mig_external
#else
extern
#endif /* mig_external */
kern_return_t lock_acquire
(
lock_set_t lock_set,
int lock_id
);
/* Routine lock_release */
#ifdef mig_external
mig_external
#else
extern
#endif /* mig_external */
kern_return_t lock_release
(
lock_set_t lock_set,
int lock_id
);
/* Routine lock_try */
#ifdef mig_external
mig_external
#else
extern
#endif /* mig_external */
kern_return_t lock_try
(
lock_set_t lock_set,
int lock_id
);
/* Routine lock_make_stable */
#ifdef mig_external
mig_external
#else
extern
#endif /* mig_external */
kern_return_t lock_make_stable
(
lock_set_t lock_set,
int lock_id
);
/* Routine lock_handoff */
#ifdef mig_external
mig_external
#else
extern
#endif /* mig_external */
kern_return_t lock_handoff
(
lock_set_t lock_set,
int lock_id
);
/* Routine lock_handoff_accept */
#ifdef mig_external
mig_external
#else
extern
#endif /* mig_external */
kern_return_t lock_handoff_accept
(
lock_set_t lock_set,
int lock_id
);
__END_DECLS
/********************** Caution **************************/
/* The following data types should be used to calculate */
/* maximum message sizes only. The actual message may be */
/* smaller, and the position of the arguments within the */
/* message layout may vary from what is presented here. */
/* For example, if any of the arguments are variable- */
/* sized, and less than the maximum is sent, the data */
/* will be packed tight in the actual message to reduce */
/* the presence of holes. */
/********************** Caution **************************/
/* typedefs for all requests */
#ifndef __Request__lock_set_subsystem__defined
#define __Request__lock_set_subsystem__defined
#ifdef __MigPackStructs
#pragma pack(push, 4)
#endif
typedef struct {
mach_msg_header_t Head;
NDR_record_t NDR;
int lock_id;
} __Request__lock_acquire_t __attribute__((unused));
#ifdef __MigPackStructs
#pragma pack(pop)
#endif
#ifdef __MigPackStructs
#pragma pack(push, 4)
#endif
typedef struct {
mach_msg_header_t Head;
NDR_record_t NDR;
int lock_id;
} __Request__lock_release_t __attribute__((unused));
#ifdef __MigPackStructs
#pragma pack(pop)
#endif
#ifdef __MigPackStructs
#pragma pack(push, 4)
#endif
typedef struct {
mach_msg_header_t Head;
NDR_record_t NDR;
int lock_id;
} __Request__lock_try_t __attribute__((unused));
#ifdef __MigPackStructs
#pragma pack(pop)
#endif
#ifdef __MigPackStructs
#pragma pack(push, 4)
#endif
typedef struct {
mach_msg_header_t Head;
NDR_record_t NDR;
int lock_id;
} __Request__lock_make_stable_t __attribute__((unused));
#ifdef __MigPackStructs
#pragma pack(pop)
#endif
#ifdef __MigPackStructs
#pragma pack(push, 4)
#endif
typedef struct {
mach_msg_header_t Head;
NDR_record_t NDR;
int lock_id;
} __Request__lock_handoff_t __attribute__((unused));
#ifdef __MigPackStructs
#pragma pack(pop)
#endif
#ifdef __MigPackStructs
#pragma pack(push, 4)
#endif
typedef struct {
mach_msg_header_t Head;
NDR_record_t NDR;
int lock_id;
} __Request__lock_handoff_accept_t __attribute__((unused));
#ifdef __MigPackStructs
#pragma pack(pop)
#endif
#endif /* !__Request__lock_set_subsystem__defined */
/* union of all requests */
#ifndef __RequestUnion__lock_set_subsystem__defined
#define __RequestUnion__lock_set_subsystem__defined
union __RequestUnion__lock_set_subsystem {
__Request__lock_acquire_t Request_lock_acquire;
__Request__lock_release_t Request_lock_release;
__Request__lock_try_t Request_lock_try;
__Request__lock_make_stable_t Request_lock_make_stable;
__Request__lock_handoff_t Request_lock_handoff;
__Request__lock_handoff_accept_t Request_lock_handoff_accept;
};
#endif /* !__RequestUnion__lock_set_subsystem__defined */
/* typedefs for all replies */
#ifndef __Reply__lock_set_subsystem__defined
#define __Reply__lock_set_subsystem__defined
#ifdef __MigPackStructs
#pragma pack(push, 4)
#endif
typedef struct {
mach_msg_header_t Head;
NDR_record_t NDR;
kern_return_t RetCode;
} __Reply__lock_acquire_t __attribute__((unused));
#ifdef __MigPackStructs
#pragma pack(pop)
#endif
#ifdef __MigPackStructs
#pragma pack(push, 4)
#endif
typedef struct {
mach_msg_header_t Head;
NDR_record_t NDR;
kern_return_t RetCode;
} __Reply__lock_release_t __attribute__((unused));
#ifdef __MigPackStructs
#pragma pack(pop)
#endif
#ifdef __MigPackStructs
#pragma pack(push, 4)
#endif
typedef struct {
mach_msg_header_t Head;
NDR_record_t NDR;
kern_return_t RetCode;
} __Reply__lock_try_t __attribute__((unused));
#ifdef __MigPackStructs
#pragma pack(pop)
#endif
#ifdef __MigPackStructs
#pragma pack(push, 4)
#endif
typedef struct {
mach_msg_header_t Head;
NDR_record_t NDR;
kern_return_t RetCode;
} __Reply__lock_make_stable_t __attribute__((unused));
#ifdef __MigPackStructs
#pragma pack(pop)
#endif
#ifdef __MigPackStructs
#pragma pack(push, 4)
#endif
typedef struct {
mach_msg_header_t Head;
NDR_record_t NDR;
kern_return_t RetCode;
} __Reply__lock_handoff_t __attribute__((unused));
#ifdef __MigPackStructs
#pragma pack(pop)
#endif
#ifdef __MigPackStructs
#pragma pack(push, 4)
#endif
typedef struct {
mach_msg_header_t Head;
NDR_record_t NDR;
kern_return_t RetCode;
} __Reply__lock_handoff_accept_t __attribute__((unused));
#ifdef __MigPackStructs
#pragma pack(pop)
#endif
#endif /* !__Reply__lock_set_subsystem__defined */
/* union of all replies */
#ifndef __ReplyUnion__lock_set_subsystem__defined
#define __ReplyUnion__lock_set_subsystem__defined
union __ReplyUnion__lock_set_subsystem {
__Reply__lock_acquire_t Reply_lock_acquire;
__Reply__lock_release_t Reply_lock_release;
__Reply__lock_try_t Reply_lock_try;
__Reply__lock_make_stable_t Reply_lock_make_stable;
__Reply__lock_handoff_t Reply_lock_handoff;
__Reply__lock_handoff_accept_t Reply_lock_handoff_accept;
};
#endif /* !__RequestUnion__lock_set_subsystem__defined */
#ifndef subsystem_to_name_map_lock_set
#define subsystem_to_name_map_lock_set \
{ "lock_acquire", 617000 },\
{ "lock_release", 617001 },\
{ "lock_try", 617002 },\
{ "lock_make_stable", 617003 },\
{ "lock_handoff", 617004 },\
{ "lock_handoff_accept", 617005 }
#endif
#ifdef __AfterMigUserHeader
__AfterMigUserHeader
#endif /* __AfterMigUserHeader */
#endif /* _lock_set_user_ */

245
ref/Apple/MachO/mach/mach.h Normal file
View File

@ -0,0 +1,245 @@
/*
* Copyright (c) 1999-2014 Apple Computer, Inc. All rights reserved.
*
* @APPLE_OSREFERENCE_LICENSE_HEADER_START@
*
* This file contains Original Code and/or Modifications of Original Code
* as defined in and that are subject to the Apple Public Source License
* Version 2.0 (the 'License'). You may not use this file except in
* compliance with the License. The rights granted to you under the License
* may not be used to create, or enable the creation or redistribution of,
* unlawful or unlicensed copies of an Apple operating system, or to
* circumvent, violate, or enable the circumvention or violation of, any
* terms of an Apple operating system software license agreement.
*
* Please obtain a copy of the License at
* http://www.opensource.apple.com/apsl/ and read it before using this file.
*
* The Original Code and all software distributed under the License are
* distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
* Please see the License for the specific language governing rights and
* limitations under the License.
*
* @APPLE_OSREFERENCE_LICENSE_HEADER_END@
*/
/*
* Mach Operating System
* Copyright (c) 1991,1990,1989 Carnegie Mellon University
* All Rights Reserved.
*
* Permission to use, copy, modify and distribute this software and its
* documentation is hereby granted, provided that both the copyright
* notice and this permission notice appear in all copies of the
* software, derivative works or modified versions, and any portions
* thereof, and that both notices appear in supporting documentation.
*
* CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
* CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR
* ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
*
* Carnegie Mellon requests users of this software to return to
*
* Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU
* School of Computer Science
* Carnegie Mellon University
* Pittsburgh PA 15213-3890
*
* any improvements or extensions that they make and grant Carnegie Mellon
* the rights to redistribute these changes.
*/
/*
* Includes all the types that a normal user
* of Mach programs should need
*/
#ifndef _MACH_H_
#define _MACH_H_
#define __MACH30__
#define MACH_IPC_FLAVOR UNTYPED
#include <mach/std_types.h>
#include <mach/mach_types.h>
#include <mach/mach_interface.h>
#include <mach/mach_port.h>
#include <mach/mach_init.h>
#include <mach/mach_host.h>
#include <mach/thread_switch.h>
#include <mach/rpc.h> /* for compatibility only */
#include <mach/mig.h>
#include <mach/mig_errors.h>
#include <mach/mach_error.h>
#include <sys/cdefs.h>
__BEGIN_DECLS
/*
* Standard prototypes
*/
extern void panic_init(mach_port_t);
extern void panic(const char *, ...);
extern void safe_gets(char *,
char *,
int);
extern void slot_name(cpu_type_t,
cpu_subtype_t,
char **,
char **);
extern void mig_reply_setup(mach_msg_header_t *,
mach_msg_header_t *);
__WATCHOS_PROHIBITED __TVOS_PROHIBITED
extern void mach_msg_destroy(mach_msg_header_t *);
__WATCHOS_PROHIBITED __TVOS_PROHIBITED
extern mach_msg_return_t mach_msg_receive(mach_msg_header_t *);
__WATCHOS_PROHIBITED __TVOS_PROHIBITED
extern mach_msg_return_t mach_msg_send(mach_msg_header_t *);
__WATCHOS_PROHIBITED __TVOS_PROHIBITED
extern mach_msg_return_t mach_msg_server_once(boolean_t (*)
(mach_msg_header_t *,
mach_msg_header_t *),
mach_msg_size_t,
mach_port_t,
mach_msg_options_t);
__WATCHOS_PROHIBITED __TVOS_PROHIBITED
extern mach_msg_return_t mach_msg_server(boolean_t (*)
(mach_msg_header_t *,
mach_msg_header_t *),
mach_msg_size_t,
mach_port_t,
mach_msg_options_t);
__WATCHOS_PROHIBITED __TVOS_PROHIBITED
extern mach_msg_return_t mach_msg_server_importance(boolean_t (*)
(mach_msg_header_t *,
mach_msg_header_t *),
mach_msg_size_t,
mach_port_t,
mach_msg_options_t);
/*
* Prototypes for compatibility
*/
extern kern_return_t clock_get_res(mach_port_t,
clock_res_t *);
extern kern_return_t clock_set_res(mach_port_t,
clock_res_t);
extern kern_return_t clock_sleep(mach_port_t,
int,
mach_timespec_t,
mach_timespec_t *);
/*!
* @group voucher_mach_msg Prototypes
*/
#define VOUCHER_MACH_MSG_API_VERSION 20140205
/*!
* @typedef voucher_mach_msg_state_t
*
* @abstract
* Opaque object encapsulating state changed by voucher_mach_msg_adopt().
*/
typedef struct voucher_mach_msg_state_s *voucher_mach_msg_state_t;
/*!
* @const VOUCHER_MACH_MSG_STATE_UNCHANGED
*
* @discussion
* Constant indicating no state change occurred.
*/
#define VOUCHER_MACH_MSG_STATE_UNCHANGED ((voucher_mach_msg_state_t)~0ul)
/*!
* @function voucher_mach_msg_set
*
* @abstract
* Change specified message header to contain current mach voucher with a
* COPY_SEND disposition.
* Does not change message if it already has non-zero MACH_MSGH_BITS_VOUCHER.
*
* @discussion
* Borrows reference to current thread voucher so message should be sent
* immediately (without intervening calls that might change that voucher).
*
* @param msg
* The message to modify.
*
* @result
* True if header was changed.
*/
extern boolean_t voucher_mach_msg_set(mach_msg_header_t *msg);
/*!
* @function voucher_mach_msg_clear
*
* @abstract
* Removes changes made to specified message header by voucher_mach_msg_set()
* and any mach_msg() send operations (successful or not).
* If the message is not needed further, mach_msg_destroy() should be called
* instead.
*
* @discussion
* Not intended to be called if voucher_mach_msg_set() returned false.
* Releases reference to message mach voucher if an extra reference was
* acquired due to an unsuccessful send operation (pseudo-receive).
*
* @param msg
* The message to modify.
*/
extern void voucher_mach_msg_clear(mach_msg_header_t *msg);
/*!
* @function voucher_mach_msg_adopt
*
* @abstract
* Adopt the voucher contained in the specified message on the current thread
* and return the previous thread voucher state.
*
* @discussion
* Ownership of the mach voucher in the message is transferred to the current
* thread and the message header voucher fields are cleared.
*
* @param msg
* The message to query and modify.
*
* @result
* The previous thread voucher state or VOUCHER_MACH_MSG_STATE_UNCHANGED if no
* state change occurred.
*/
extern voucher_mach_msg_state_t voucher_mach_msg_adopt(mach_msg_header_t *msg);
/*!
* @function voucher_mach_msg_revert
*
* @abstract
* Restore thread voucher state previously modified by voucher_mach_msg_adopt().
*
* @discussion
* Current thread voucher reference is released.
* No change to thread voucher state if passed VOUCHER_MACH_MSG_STATE_UNCHANGED.
*
* @param state
* The thread voucher state to restore.
*/
extern void voucher_mach_msg_revert(voucher_mach_msg_state_t state);
__END_DECLS
#endif /* _MACH_H_ */

View File

@ -0,0 +1,93 @@
/*
* Copyright (c) 1999 Apple Computer, Inc. All rights reserved.
*
* @APPLE_OSREFERENCE_LICENSE_HEADER_START@
*
* This file contains Original Code and/or Modifications of Original Code
* as defined in and that are subject to the Apple Public Source License
* Version 2.0 (the 'License'). You may not use this file except in
* compliance with the License. The rights granted to you under the License
* may not be used to create, or enable the creation or redistribution of,
* unlawful or unlicensed copies of an Apple operating system, or to
* circumvent, violate, or enable the circumvention or violation of, any
* terms of an Apple operating system software license agreement.
*
* Please obtain a copy of the License at
* http://www.opensource.apple.com/apsl/ and read it before using this file.
*
* The Original Code and all software distributed under the License are
* distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
* Please see the License for the specific language governing rights and
* limitations under the License.
*
* @APPLE_OSREFERENCE_LICENSE_HEADER_END@
*/
/*
* Mach Operating System
* Copyright (c) 1991,1990,1989 Carnegie Mellon University
* All Rights Reserved.
*
* Permission to use, copy, modify and distribute this software and its
* documentation is hereby granted, provided that both the copyright
* notice and this permission notice appear in all copies of the
* software, derivative works or modified versions, and any portions
* thereof, and that both notices appear in supporting documentation.
*
* CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS
* CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR
* ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
*
* Carnegie Mellon requests users of this software to return to
*
* Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU
* School of Computer Science
* Carnegie Mellon University
* Pittsburgh PA 15213-3890
*
* any improvements or extensions that they make and grant Carnegie the
* rights to redistribute these changes.
*/
/*
* File: mach_error.h
* Author: Douglas Orr, Carnegie Mellon University
* Date: Mar. 1988
*
* Definitions of routines in mach_error.c
*/
#ifndef _MACH_ERROR_
#define _MACH_ERROR_ 1
#include <mach/error.h>
#include <sys/cdefs.h>
__BEGIN_DECLS
char *mach_error_string(
/*
* Returns a string appropriate to the error argument given
*/
mach_error_t error_value
);
void mach_error(
/*
* Prints an appropriate message on the standard error stream
*/
const char *str,
mach_error_t error_value
);
char *mach_error_type(
/*
* Returns a string with the error system, subsystem and code
*/
mach_error_t error_value
);
__END_DECLS
#endif /* _MACH_ERROR_ */

View File

@ -0,0 +1,287 @@
#ifndef _mach_eventlink_user_
#define _mach_eventlink_user_
/* Module mach_eventlink */
#include <string.h>
#include <mach/ndr.h>
#include <mach/boolean.h>
#include <mach/kern_return.h>
#include <mach/notify.h>
#include <mach/mach_types.h>
#include <mach/message.h>
#include <mach/mig_errors.h>
#include <mach/port.h>
/* BEGIN MIG_STRNCPY_ZEROFILL CODE */
#if defined(__has_include)
#if __has_include(<mach/mig_strncpy_zerofill_support.h>)
#ifndef USING_MIG_STRNCPY_ZEROFILL
#define USING_MIG_STRNCPY_ZEROFILL
#endif
#ifndef __MIG_STRNCPY_ZEROFILL_FORWARD_TYPE_DECLS__
#define __MIG_STRNCPY_ZEROFILL_FORWARD_TYPE_DECLS__
#ifdef __cplusplus
extern "C" {
#endif
extern int mig_strncpy_zerofill(char *dest, const char *src, int len) __attribute__((weak_import));
#ifdef __cplusplus
}
#endif
#endif /* __MIG_STRNCPY_ZEROFILL_FORWARD_TYPE_DECLS__ */
#endif /* __has_include(<mach/mig_strncpy_zerofill_support.h>) */
#endif /* __has_include */
/* END MIG_STRNCPY_ZEROFILL CODE */
#ifdef AUTOTEST
#ifndef FUNCTION_PTR_T
#define FUNCTION_PTR_T
typedef void (*function_ptr_t)(mach_port_t, char *, mach_msg_type_number_t);
typedef struct {
char *name;
function_ptr_t function;
} function_table_entry;
typedef function_table_entry *function_table_t;
#endif /* FUNCTION_PTR_T */
#endif /* AUTOTEST */
#ifndef mach_eventlink_MSG_COUNT
#define mach_eventlink_MSG_COUNT 4
#endif /* mach_eventlink_MSG_COUNT */
#include <mach/mach_eventlink_types.h>
#include <mach/std_types.h>
#include <mach/mig.h>
#include <mach/mig.h>
#include <mach/mach_types.h>
#include <mach/mach_types.h>
#ifdef __BeforeMigUserHeader
__BeforeMigUserHeader
#endif /* __BeforeMigUserHeader */
#include <sys/cdefs.h>
__BEGIN_DECLS
/* Routine mach_eventlink_create */
#ifdef mig_external
mig_external
#else
extern
#endif /* mig_external */
kern_return_t mach_eventlink_create
(
task_t task,
mach_eventlink_create_option_t option,
eventlink_port_pair_t eventlink_pair
);
/* Routine mach_eventlink_destroy */
#ifdef mig_external
mig_external
#else
extern
#endif /* mig_external */
kern_return_t mach_eventlink_destroy
(
mach_port_t eventlink
);
/* Routine mach_eventlink_associate */
#ifdef mig_external
mig_external
#else
extern
#endif /* mig_external */
kern_return_t mach_eventlink_associate
(
mach_port_t eventlink,
thread_t thread,
mach_vm_address_t copyin_addr_wait,
uint64_t copyin_mask_wait,
mach_vm_address_t copyin_addr_signal,
uint64_t copyin_mask_signal,
mach_eventlink_associate_option_t option
);
/* Routine mach_eventlink_disassociate */
#ifdef mig_external
mig_external
#else
extern
#endif /* mig_external */
kern_return_t mach_eventlink_disassociate
(
mach_port_t eventlink,
mach_eventlink_disassociate_option_t option
);
__END_DECLS
/********************** Caution **************************/
/* The following data types should be used to calculate */
/* maximum message sizes only. The actual message may be */
/* smaller, and the position of the arguments within the */
/* message layout may vary from what is presented here. */
/* For example, if any of the arguments are variable- */
/* sized, and less than the maximum is sent, the data */
/* will be packed tight in the actual message to reduce */
/* the presence of holes. */
/********************** Caution **************************/
/* typedefs for all requests */
#ifndef __Request__mach_eventlink_subsystem__defined
#define __Request__mach_eventlink_subsystem__defined
#ifdef __MigPackStructs
#pragma pack(push, 4)
#endif
typedef struct {
mach_msg_header_t Head;
NDR_record_t NDR;
mach_eventlink_create_option_t option;
} __Request__mach_eventlink_create_t __attribute__((unused));
#ifdef __MigPackStructs
#pragma pack(pop)
#endif
#ifdef __MigPackStructs
#pragma pack(push, 4)
#endif
typedef struct {
mach_msg_header_t Head;
} __Request__mach_eventlink_destroy_t __attribute__((unused));
#ifdef __MigPackStructs
#pragma pack(pop)
#endif
#ifdef __MigPackStructs
#pragma pack(push, 4)
#endif
typedef struct {
mach_msg_header_t Head;
/* start of the kernel processed data */
mach_msg_body_t msgh_body;
mach_msg_port_descriptor_t thread;
/* end of the kernel processed data */
NDR_record_t NDR;
mach_vm_address_t copyin_addr_wait;
uint64_t copyin_mask_wait;
mach_vm_address_t copyin_addr_signal;
uint64_t copyin_mask_signal;
mach_eventlink_associate_option_t option;
} __Request__mach_eventlink_associate_t __attribute__((unused));
#ifdef __MigPackStructs
#pragma pack(pop)
#endif
#ifdef __MigPackStructs
#pragma pack(push, 4)
#endif
typedef struct {
mach_msg_header_t Head;
NDR_record_t NDR;
mach_eventlink_disassociate_option_t option;
} __Request__mach_eventlink_disassociate_t __attribute__((unused));
#ifdef __MigPackStructs
#pragma pack(pop)
#endif
#endif /* !__Request__mach_eventlink_subsystem__defined */
/* union of all requests */
#ifndef __RequestUnion__mach_eventlink_subsystem__defined
#define __RequestUnion__mach_eventlink_subsystem__defined
union __RequestUnion__mach_eventlink_subsystem {
__Request__mach_eventlink_create_t Request_mach_eventlink_create;
__Request__mach_eventlink_destroy_t Request_mach_eventlink_destroy;
__Request__mach_eventlink_associate_t Request_mach_eventlink_associate;
__Request__mach_eventlink_disassociate_t Request_mach_eventlink_disassociate;
};
#endif /* !__RequestUnion__mach_eventlink_subsystem__defined */
/* typedefs for all replies */
#ifndef __Reply__mach_eventlink_subsystem__defined
#define __Reply__mach_eventlink_subsystem__defined
#ifdef __MigPackStructs
#pragma pack(push, 4)
#endif
typedef struct {
mach_msg_header_t Head;
/* start of the kernel processed data */
mach_msg_body_t msgh_body;
mach_msg_port_descriptor_t eventlink_pair[2];
/* end of the kernel processed data */
} __Reply__mach_eventlink_create_t __attribute__((unused));
#ifdef __MigPackStructs
#pragma pack(pop)
#endif
#ifdef __MigPackStructs
#pragma pack(push, 4)
#endif
typedef struct {
mach_msg_header_t Head;
NDR_record_t NDR;
kern_return_t RetCode;
} __Reply__mach_eventlink_destroy_t __attribute__((unused));
#ifdef __MigPackStructs
#pragma pack(pop)
#endif
#ifdef __MigPackStructs
#pragma pack(push, 4)
#endif
typedef struct {
mach_msg_header_t Head;
NDR_record_t NDR;
kern_return_t RetCode;
} __Reply__mach_eventlink_associate_t __attribute__((unused));
#ifdef __MigPackStructs
#pragma pack(pop)
#endif
#ifdef __MigPackStructs
#pragma pack(push, 4)
#endif
typedef struct {
mach_msg_header_t Head;
NDR_record_t NDR;
kern_return_t RetCode;
} __Reply__mach_eventlink_disassociate_t __attribute__((unused));
#ifdef __MigPackStructs
#pragma pack(pop)
#endif
#endif /* !__Reply__mach_eventlink_subsystem__defined */
/* union of all replies */
#ifndef __ReplyUnion__mach_eventlink_subsystem__defined
#define __ReplyUnion__mach_eventlink_subsystem__defined
union __ReplyUnion__mach_eventlink_subsystem {
__Reply__mach_eventlink_create_t Reply_mach_eventlink_create;
__Reply__mach_eventlink_destroy_t Reply_mach_eventlink_destroy;
__Reply__mach_eventlink_associate_t Reply_mach_eventlink_associate;
__Reply__mach_eventlink_disassociate_t Reply_mach_eventlink_disassociate;
};
#endif /* !__RequestUnion__mach_eventlink_subsystem__defined */
#ifndef subsystem_to_name_map_mach_eventlink
#define subsystem_to_name_map_mach_eventlink \
{ "mach_eventlink_create", 716200 },\
{ "mach_eventlink_destroy", 716201 },\
{ "mach_eventlink_associate", 716202 },\
{ "mach_eventlink_disassociate", 716203 }
#endif
#ifdef __AfterMigUserHeader
__AfterMigUserHeader
#endif /* __AfterMigUserHeader */
#endif /* _mach_eventlink_user_ */

View File

@ -0,0 +1,133 @@
/*
* Copyright (c) 2006 Apple Computer, Inc. All rights reserved.
*
* @APPLE_OSREFERENCE_LICENSE_HEADER_START@
*
* This file contains Original Code and/or Modifications of Original Code
* as defined in and that are subject to the Apple Public Source License
* Version 2.0 (the 'License'). You may not use this file except in
* compliance with the License. The rights granted to you under the License
* may not be used to create, or enable the creation or redistribution of,
* unlawful or unlicensed copies of an Apple operating system, or to
* circumvent, violate, or enable the circumvention or violation of, any
* terms of an Apple operating system software license agreement.
*
* Please obtain a copy of the License at
* http://www.opensource.apple.com/apsl/ and read it before using this file.
*
* The Original Code and all software distributed under the License are
* distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
* Please see the License for the specific language governing rights and
* limitations under the License.
*
* @APPLE_OSREFERENCE_LICENSE_HEADER_END@
*/
/*
* @OSF_COPYRIGHT@
*/
/*
* Mach Operating System
* Copyright (c) 1991,1990,1989,1988,1987 Carnegie Mellon University
* All Rights Reserved.
*
* Permission to use, copy, modify and distribute this software and its
* documentation is hereby granted, provided that both the copyright
* notice and this permission notice appear in all copies of the
* software, derivative works or modified versions, and any portions
* thereof, and that both notices appear in supporting documentation.
*
* CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
* CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR
* ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
*
* Carnegie Mellon requests users of this software to return to
*
* Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU
* School of Computer Science
* Carnegie Mellon University
* Pittsburgh PA 15213-3890
*
* any improvements or extensions that they make and grant Carnegie Mellon
* the rights to redistribute these changes.
*/
/*
*/
/*
* Abstract:
* MiG definitions file for Mach exception interface.
*/
subsystem
#if KERNEL_USER
KernelUser
#endif
#if KERNEL_SERVER
KernelServer
#endif /* KERNEL_SERVER */
mach_exc 2405;
#include <mach/std_types.defs>
#include <mach/mach_types.defs>
ServerPrefix catch_;
type mach_exception_data_t = array[*:2] of int64_t;
type exception_type_t = int;
routine mach_exception_raise(
exception_port : mach_port_t;
thread : mach_port_t;
task : mach_port_t;
exception : exception_type_t;
code : mach_exception_data_t
#if MACH_EXC_SERVER_SECTOKEN
;
ServerSecToken stoken : security_token_t
#endif
#if MACH_EXC_SERVER_AUDITTOKEN
;
ServerAuditToken atoken: audit_token_t
#endif
);
routine mach_exception_raise_state(
exception_port : mach_port_t;
exception : exception_type_t;
code : mach_exception_data_t, const;
inout flavor : int;
old_state : thread_state_t, const;
out new_state : thread_state_t
#if MACH_EXC_SERVER_SECTOKEN
;
ServerSecToken stoken : security_token_t
#endif
#if MACH_EXC_SERVER_AUDITTOKEN
;
ServerAuditToken atoken: audit_token_t
#endif
);
routine mach_exception_raise_state_identity(
exception_port : mach_port_t;
thread : mach_port_t;
task : mach_port_t;
exception : exception_type_t;
code : mach_exception_data_t;
inout flavor : int;
old_state : thread_state_t;
out new_state : thread_state_t
#if MACH_EXC_SERVER_SECTOKEN
;
ServerSecToken stoken : security_token_t
#endif
#if MACH_EXC_SERVER_AUDITTOKEN
;
ServerAuditToken atoken: audit_token_t
#endif
);
/* vim: set ft=c : */

View File

@ -0,0 +1,357 @@
/*
* Copyright (c) 2000-2009 Apple Inc. All rights reserved.
*
* @APPLE_OSREFERENCE_LICENSE_HEADER_START@
*
* This file contains Original Code and/or Modifications of Original Code
* as defined in and that are subject to the Apple Public Source License
* Version 2.0 (the 'License'). You may not use this file except in
* compliance with the License. The rights granted to you under the License
* may not be used to create, or enable the creation or redistribution of,
* unlawful or unlicensed copies of an Apple operating system, or to
* circumvent, violate, or enable the circumvention or violation of, any
* terms of an Apple operating system software license agreement.
*
* Please obtain a copy of the License at
* http://www.opensource.apple.com/apsl/ and read it before using this file.
*
* The Original Code and all software distributed under the License are
* distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
* Please see the License for the specific language governing rights and
* limitations under the License.
*
* @APPLE_OSREFERENCE_LICENSE_HEADER_END@
*/
/*
* @OSF_COPYRIGHT@
*/
/*
* Mach Operating System
* Copyright (c) 1991,1990,1989 Carnegie Mellon University
* All Rights Reserved.
*
* Permission to use, copy, modify and distribute this software and its
* documentation is hereby granted, provided that both the copyright
* notice and this permission notice appear in all copies of the
* software, derivative works or modified versions, and any portions
* thereof, and that both notices appear in supporting documentation.
*
* CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
* CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR
* ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
*
* Carnegie Mellon requests users of this software to return to
*
* Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU
* School of Computer Science
* Carnegie Mellon University
* Pittsburgh PA 15213-3890
*
* any improvements or extensions that they make and grant Carnegie Mellon
* the rights to redistribute these changes.
*/
/*
*/
/*
* File: mach/mach_host.defs
*
* Abstract:
* Mach host operations support. Includes processor allocation and
* control.
*/
subsystem
#if KERNEL_SERVER
KernelServer
#endif /* KERNEL_SERVER */
mach_host 200;
/*
* Basic types
*/
#include <mach/std_types.defs>
#include <mach/mach_types.defs>
#include <mach/clock_types.defs>
#include <mach_debug/mach_debug_types.defs>
/*
* References to host objects are returned by:
* mach_host_self() - trap
*/
/*
* Return information about this host.
*/
routine host_info(
host : host_t;
flavor : host_flavor_t;
out host_info_out : host_info_t, CountInOut);
/*
* Get string describing current kernel version.
*/
routine host_kernel_version(
host : host_t;
out kernel_version : kernel_version_t);
/*
* Get host page size
* (compatibility for running old libraries on new kernels -
* host_page_size() is now a library routine based on constants)
*/
routine _host_page_size(
host : host_t;
out out_page_size : vm_size_t);
/*
* Allow pagers to create named entries that point to un-mapped
* abstract memory object. The named entries are generally mappable
* and can be subsetted through the mach_make_memory_entry call
*/
routine mach_memory_object_memory_entry(
host :host_t;
internal :boolean_t;
size :vm_size_t;
permission :vm_prot_t;
pager :memory_object_t;
out entry_handle :mach_port_move_send_t);
/*
* Get processor info for all the processors on this host.
* The returned data is an OOL array of processor info.
*/
routine host_processor_info(
host : host_t;
flavor : processor_flavor_t;
out out_processor_count : natural_t;
out out_processor_info : processor_info_array_t);
/*
* Return host IO master access port
*/
routine host_get_io_master(
host : host_t;
out io_master : io_master_t);
/*
* Get service port for a processor set.
* Available to all.
*/
routine host_get_clock_service(
host : host_t;
clock_id : clock_id_t;
out clock_serv : clock_serv_t);
/*
* kernel module interface (obsolete as of SnowLeopard)
* see mach/kmod.h
*/
/* kmod_ MIG calls now return KERN_NOT_SUPPORTED on PPC/i386/x86_64. */
routine kmod_get_info(
host : host_t;
out modules : kmod_args_t);
skip; /* was host_zone_info */
/*
* Returns information about the global VP table.
* Only supported in MACH_VM_DEBUG kernels,
* otherwise returns KERN_FAILURE.
*/
routine host_virtual_physical_table_info(
host : host_t;
out info : hash_info_bucket_array_t,
Dealloc);
skip; /* was host_ipc_hash_info */
skip; /* was enable_bluebox */
skip; /* was disable_bluebox */
/*
* JMM - Keep processor_set related items at the end for easy
* removal.
*/
/*
* Get default processor set for host.
*/
routine processor_set_default(
host : host_t;
out default_set : processor_set_name_t);
/*
* Create new processor set. Returns real port for manipulations,
* and name port for obtaining information.
*/
routine processor_set_create(
host : host_t;
out new_set : processor_set_t;
out new_name : processor_set_name_t);
/*
* Temporary interfaces for conversion to 64 bit data path
*/
routine mach_memory_object_memory_entry_64(
host :host_t;
internal :boolean_t;
size :memory_object_size_t;
permission :vm_prot_t;
pager :memory_object_t;
out entry_handle :mach_port_move_send_t);
/*
* Return statistics from this host.
*/
routine
#ifdef KERNEL_SERVER
host_statistics_from_user(
#else
host_statistics(
#endif
host_priv : host_t;
flavor : host_flavor_t;
out host_info_out : host_info_t, CountInOut);
routine host_request_notification(
host : host_t;
notify_type : host_flavor_t;
notify_port : mach_port_make_send_once_t);
routine host_lockgroup_info(
host : host_t;
out lockgroup_info : lockgroup_info_array_t,
Dealloc);
/*
* Return 64-bit statistics from this host.
*/
routine
#ifdef KERNEL_SERVER
host_statistics64_from_user(
#else
host_statistics64(
#endif
host_priv : host_t;
flavor : host_flavor_t;
out host_info64_out : host_info64_t, CountInOut);
/*
* Returns information about the memory allocation zones.
* Data returned is compatible with various caller and kernel
* address space sizes.
*/
routine mach_zone_info(
host : host_priv_t;
out names : mach_zone_name_array_t,
Dealloc;
out info : mach_zone_info_array_t,
Dealloc);
skip;
/*
* Create a new voucher by running a series of commands against
* <key, previous-voucher> pairs of resource attributes.
*/
#if !KERNEL && !LIBSYSCALL_INTERFACE
routine _kernelrpc_host_create_mach_voucher(
#else
routine host_create_mach_voucher(
#endif
host : host_t;
recipes : mach_voucher_attr_raw_recipe_array_t;
out voucher : ipc_voucher_t);
/*
* Register a resource manager with the kernel. A new key is selected.
*/
routine host_register_mach_voucher_attr_manager(
host : host_t;
attr_manager : mach_voucher_attr_manager_t;
default_value : mach_voucher_attr_value_handle_t;
out new_key : mach_voucher_attr_key_t;
out new_attr_control: ipc_voucher_attr_control_t);
/*
* Register a resource manager (with a well-known key value) with the kernel.
*/
routine host_register_well_known_mach_voucher_attr_manager(
host : host_t;
attr_manager : mach_voucher_attr_manager_t;
default_value : mach_voucher_attr_value_handle_t;
key : mach_voucher_attr_key_t;
out new_attr_control: ipc_voucher_attr_control_t);
/*
* Update the global ATM diagnostic flag, readable from the commpage
*/
routine host_set_atm_diagnostic_flag(
host : host_t;
in diagnostic_flag : uint32_t);
#if !KERNEL && LIBSYSCALL_INTERFACE
routine host_get_atm_diagnostic_flag(
host : host_t;
out diagnostic_flag : uint32_t);
#else
skip;
#endif
routine mach_memory_info(
host : host_priv_t;
out names : mach_zone_name_array_t,
Dealloc;
out info : mach_zone_info_array_t,
Dealloc;
out memory_info : mach_memory_info_array_t,
Dealloc);
/*
* Update the global multiuser flags, readable from the commpage
*/
routine host_set_multiuser_config_flags(
host_priv : host_priv_t;
in multiuser_flags : uint32_t);
#if !KERNEL && LIBSYSCALL_INTERFACE
routine host_get_multiuser_config_flags(
host : host_t;
out multiuser_flags : uint32_t);
#else
skip;
#endif // !KERNEL && LIBSYSCALL_INTERFACE
#if !KERNEL && LIBSYSCALL_INTERFACE
routine host_check_multiuser_mode(
host : host_t;
out multiuser_mode : uint32_t);
#else
skip;
#endif // !KERNEL && LIBSYSCALL_INTERFACE
/*
* Returns information about a specific zone.
* The zone name is passed in via the argument name,
* info returns the zone info.
*/
routine mach_zone_info_for_zone(
host : host_priv_t;
name : mach_zone_name_t;
out info : mach_zone_info_t);
skip;
skip;
skip;
/* vim: set ft=c : */

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,116 @@
/*
* Copyright (c) 1999 Apple Computer, Inc. All rights reserved.
*
* @APPLE_OSREFERENCE_LICENSE_HEADER_START@
*
* This file contains Original Code and/or Modifications of Original Code
* as defined in and that are subject to the Apple Public Source License
* Version 2.0 (the 'License'). You may not use this file except in
* compliance with the License. The rights granted to you under the License
* may not be used to create, or enable the creation or redistribution of,
* unlawful or unlicensed copies of an Apple operating system, or to
* circumvent, violate, or enable the circumvention or violation of, any
* terms of an Apple operating system software license agreement.
*
* Please obtain a copy of the License at
* http://www.opensource.apple.com/apsl/ and read it before using this file.
*
* The Original Code and all software distributed under the License are
* distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
* Please see the License for the specific language governing rights and
* limitations under the License.
*
* @APPLE_OSREFERENCE_LICENSE_HEADER_END@
*/
/*
* Mach Operating System
* Copyright (c) 1991,1990,1989,1988,1987,1986 Carnegie Mellon University
* All Rights Reserved.
*
* Permission to use, copy, modify and distribute this software and its
* documentation is hereby granted, provided that both the copyright
* notice and this permission notice appear in all copies of the
* software, derivative works or modified versions, and any portions
* thereof, and that both notices appear in supporting documentation.
*
* CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
* CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR
* ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
*
* Carnegie Mellon requests users of this software to return to
*
* Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU
* School of Computer Science
* Carnegie Mellon University
* Pittsburgh PA 15213-3890
*
* any improvements or extensions that they make and grant Carnegie Mellon
* the rights to redistribute these changes.
*/
/*
* Items provided by the Mach environment initialization.
*/
#ifndef _MACH_INIT_
#define _MACH_INIT_ 1
#include <mach/mach_types.h>
#include <mach/vm_page_size.h>
#include <stdarg.h>
#include <sys/cdefs.h>
#ifndef KERNEL
#include <Availability.h>
#endif
/*
* Kernel-related ports; how a task/thread controls itself
*/
__BEGIN_DECLS
extern mach_port_t mach_host_self(void);
extern mach_port_t mach_thread_self(void);
__API_AVAILABLE(macos(11.3), ios(14.5), tvos(14.5), watchos(7.3))
extern boolean_t mach_task_is_self(task_name_t task);
extern kern_return_t host_page_size(host_t, vm_size_t *);
extern mach_port_t mach_task_self_;
#define mach_task_self() mach_task_self_
#define current_task() mach_task_self()
__END_DECLS
#include <mach/mach_traps.h>
__BEGIN_DECLS
/*
* Other important ports in the Mach user environment
*/
extern mach_port_t bootstrap_port;
/*
* Where these ports occur in the "mach_ports_register"
* collection... only servers or the runtime library need know.
*/
#define NAME_SERVER_SLOT 0
#define ENVIRONMENT_SLOT 1
#define SERVICE_SLOT 2
#define MACH_PORTS_SLOTS_USED 3
/*
* fprintf_stderr uses vprintf_stderr_func to produce
* error messages, this can be overridden by a user
* application to point to a user-specified output function
*/
extern int (*vprintf_stderr_func)(const char *format, va_list ap);
__END_DECLS
#endif /* _MACH_INIT_ */

View File

@ -0,0 +1,53 @@
/*
* Copyright (c) 2003 Apple Computer, Inc. All rights reserved.
*
* @APPLE_OSREFERENCE_LICENSE_HEADER_START@
*
* This file contains Original Code and/or Modifications of Original Code
* as defined in and that are subject to the Apple Public Source License
* Version 2.0 (the 'License'). You may not use this file except in
* compliance with the License. The rights granted to you under the License
* may not be used to create, or enable the creation or redistribution of,
* unlawful or unlicensed copies of an Apple operating system, or to
* circumvent, violate, or enable the circumvention or violation of, any
* terms of an Apple operating system software license agreement.
*
* Please obtain a copy of the License at
* http://www.opensource.apple.com/apsl/ and read it before using this file.
*
* The Original Code and all software distributed under the License are
* distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
* Please see the License for the specific language governing rights and
* limitations under the License.
*
* @APPLE_OSREFERENCE_LICENSE_HEADER_END@
*/
/*
* Copyright (C) Apple Computer 1998
* ALL Rights Reserved
*/
/*
* This file represents the interfaces that used to come
* from creating the user headers from the mach.defs file.
* Because mach.defs was decomposed, this file now just
* wraps up all the new interface headers generated from
* each of the new .defs resulting from that decomposition.
*/
#ifndef _MACH_INTERFACE_H_
#define _MACH_INTERFACE_H_
#include <mach/clock_priv.h>
#include <mach/host_priv.h>
#include <mach/host_security.h>
#include <mach/lock_set.h>
#include <mach/processor.h>
#include <mach/processor_set.h>
#include <mach/semaphore.h>
#include <mach/task.h>
#include <mach/thread_act.h>
#include <mach/vm_map.h>
#endif /* _MACH_INTERFACE_H_ */

View File

@ -0,0 +1,82 @@
/*
* Copyright (c) 2000 Apple Computer, Inc. All rights reserved.
*
* @APPLE_OSREFERENCE_LICENSE_HEADER_START@
*
* This file contains Original Code and/or Modifications of Original Code
* as defined in and that are subject to the Apple Public Source License
* Version 2.0 (the 'License'). You may not use this file except in
* compliance with the License. The rights granted to you under the License
* may not be used to create, or enable the creation or redistribution of,
* unlawful or unlicensed copies of an Apple operating system, or to
* circumvent, violate, or enable the circumvention or violation of, any
* terms of an Apple operating system software license agreement.
*
* Please obtain a copy of the License at
* http://www.opensource.apple.com/apsl/ and read it before using this file.
*
* The Original Code and all software distributed under the License are
* distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
* Please see the License for the specific language governing rights and
* limitations under the License.
*
* @APPLE_OSREFERENCE_LICENSE_HEADER_END@
*/
/*
* @OSF_COPYRIGHT@
*/
/*
* Mach Operating System
* Copyright (c) 1991,1990,1989,1988,1987 Carnegie Mellon University
* All Rights Reserved.
*
* Permission to use, copy, modify and distribute this software and its
* documentation is hereby granted, provided that both the copyright
* notice and this permission notice appear in all copies of the
* software, derivative works or modified versions, and any portions
* thereof, and that both notices appear in supporting documentation.
*
* CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
* CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR
* ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
*
* Carnegie Mellon requests users of this software to return to
*
* Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU
* School of Computer Science
* Carnegie Mellon University
* Pittsburgh PA 15213-3890
*
* any improvements or extensions that they make and grant Carnegie Mellon
* the rights to redistribute these changes.
*/
/*
*/
/*
* File: mach/mach_param.h
* Author: Avadis Tevanian, Jr., Michael Wayne Young
* Date: 1986
*
* Mach system sizing parameters
*/
#ifndef _MACH_MACH_PARAM_H_
#define _MACH_MACH_PARAM_H_
/* Number of "registered" ports */
#define TASK_PORT_REGISTER_MAX 3
/* Number of watchport for task */
#define TASK_MAX_WATCHPORT_COUNT 32
/* Number of different task port flavor */
#define TASK_SELF_PORT_COUNT 4
/* Number of different thread port flavor */
#define THREAD_SELF_PORT_COUNT 3
#endif /* _MACH_MACH_PARAM_H_ */

View File

@ -0,0 +1,715 @@
/*
* Copyright (c) 2000-2004 Apple Computer, Inc. All rights reserved.
*
* @APPLE_OSREFERENCE_LICENSE_HEADER_START@
*
* This file contains Original Code and/or Modifications of Original Code
* as defined in and that are subject to the Apple Public Source License
* Version 2.0 (the 'License'). You may not use this file except in
* compliance with the License. The rights granted to you under the License
* may not be used to create, or enable the creation or redistribution of,
* unlawful or unlicensed copies of an Apple operating system, or to
* circumvent, violate, or enable the circumvention or violation of, any
* terms of an Apple operating system software license agreement.
*
* Please obtain a copy of the License at
* http://www.opensource.apple.com/apsl/ and read it before using this file.
*
* The Original Code and all software distributed under the License are
* distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
* Please see the License for the specific language governing rights and
* limitations under the License.
*
* @APPLE_OSREFERENCE_LICENSE_HEADER_END@
*/
/*
* @OSF_FREE_COPYRIGHT@
*/
/*
* Mach Operating System
* Copyright (c) 1991,1990,1989 Carnegie Mellon University
* All Rights Reserved.
*
* Permission to use, copy, modify and distribute this software and its
* documentation is hereby granted, provided that both the copyright
* notice and this permission notice appear in all copies of the
* software, derivative works or modified versions, and any portions
* thereof, and that both notices appear in supporting documentation.
*
* CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
* CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR
* ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
*
* Carnegie Mellon requests users of this software to return to
*
* Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU
* School of Computer Science
* Carnegie Mellon University
* Pittsburgh PA 15213-3890
*
* any improvements or extensions that they make and grant Carnegie Mellon
* the rights to redistribute these changes.
*/
/*
*/
/*
* File: mach/mach_port.defs
* Author: Rich Draves
*
* Exported kernel calls.
*/
subsystem
#if KERNEL_SERVER
KernelServer
#endif /* KERNEL_SERVER */
mach_port 3200;
#if !KERNEL && !LIBSYSCALL_INTERFACE
UserPrefix _kernelrpc_;
#endif
#include <mach/std_types.defs>
#include <mach/mach_types.defs>
#include <mach_debug/mach_debug_types.defs>
type kobject_description_t = c_string[*:512];
/*
* Returns the set of port and port set names
* to which the target task has access, along with
* the type (set or port) for each name.
*/
routine mach_port_names(
task : ipc_space_t;
out names : mach_port_name_array_t;
out types : mach_port_type_array_t);
/*
* Returns the type (set or port) for the port name
* within the target task. Also indicates whether
* there is a dead-name request for the name.
*/
routine mach_port_type(
task : ipc_space_t;
name : mach_port_name_t;
out ptype : mach_port_type_t);
/*
* Changes the name by which a port (or port set) is known to
* the target task. The new name can't be in use. The
* old name becomes available for recycling.
*
* This interface is OBSOLETE and will always
* return KERN_NOT_SUPPORTED.
*/
routine mach_port_rename(
task : ipc_space_t;
old_name : mach_port_name_t;
new_name : mach_port_name_t);
/*
* Allocates the specified kind of object, with the given name.
* The right must be one of
* MACH_PORT_RIGHT_RECEIVE
* MACH_PORT_RIGHT_PORT_SET
* MACH_PORT_RIGHT_DEAD_NAME
* New port sets are empty. New ports don't have any
* send/send-once rights or queued messages. The make-send
* count is zero and their queue limit is MACH_PORT_QLIMIT_DEFAULT.
* New sets, ports, and dead names have one user reference.
*/
routine mach_port_allocate_name(
task : ipc_space_t;
right : mach_port_right_t;
name : mach_port_name_t);
/*
* Allocates the specified kind of object.
* The right must be one of
* MACH_PORT_RIGHT_RECEIVE
* MACH_PORT_RIGHT_PORT_SET
* MACH_PORT_RIGHT_DEAD_NAME
* Like port_allocate_name, but the kernel picks a name.
* It can use any name not associated with a right.
*/
routine mach_port_allocate(
task : ipc_space_t;
right : mach_port_right_t;
out name : mach_port_name_t);
/*
* Destroys all rights associated with the name and makes it
* available for recycling immediately. The name can be a
* port (possibly with multiple user refs), a port set, or
* a dead name (again, with multiple user refs).
*/
routine mach_port_destroy(
task : ipc_space_t;
name : mach_port_name_t);
/*
* Releases one send/send-once/dead-name user ref.
* Just like mach_port_mod_refs -1, but deduces the
* correct type of right. This allows a user task
* to release a ref for a port without worrying
* about whether the port has died or not.
*/
routine mach_port_deallocate(
task : ipc_space_t;
name : mach_port_name_t);
/*
* A port set always has one user ref.
* A send-once right always has one user ref.
* A dead name always has one or more user refs.
* A send right always has one or more user refs.
* A receive right always has one user ref.
* The right must be one of
* MACH_PORT_RIGHT_RECEIVE
* MACH_PORT_RIGHT_PORT_SET
* MACH_PORT_RIGHT_DEAD_NAME
* MACH_PORT_RIGHT_SEND
* MACH_PORT_RIGHT_SEND_ONCE
*/
routine mach_port_get_refs(
task : ipc_space_t;
name : mach_port_name_t;
right : mach_port_right_t;
out refs : mach_port_urefs_t);
/*
* The delta is a signed change to the task's
* user ref count for the right. Only dead names
* and send rights can have a positive delta.
* The resulting user ref count can't be negative.
* If it is zero, the right is deallocated.
* If the name isn't a composite right, it becomes
* available for recycling. The right must be one of
* MACH_PORT_RIGHT_RECEIVE
* MACH_PORT_RIGHT_PORT_SET
* MACH_PORT_RIGHT_DEAD_NAME
* MACH_PORT_RIGHT_SEND
* MACH_PORT_RIGHT_SEND_ONCE
*/
routine mach_port_mod_refs(
task : ipc_space_t;
name : mach_port_name_t;
right : mach_port_right_t;
delta : mach_port_delta_t);
/*
* Peek at the message queue for the specified receive
* right and return info about the message with the
* sequence number matching the input. If zero is
* specified as the seqno, the first message in the
* queue will be peeked.
*
* Only the following trailer types are currently supported:
* MACH_RCV_TRAILER_TYPE(MACH_MSG_TRAILER_FORMAT_0)
*
* or'ed with one of these element types:
* MACH_RCV_TRAILER_ELEMENTS(MACH_RCV_TRAILER_NULL)
* MACH_RCV_TRAILER_ELEMENTS(MACH_RCV_TRAILER_SEQNO)
* MACH_RCV_TRAILER_ELEMENTS(MACH_RCV_TRAILER_SENDER)
* MACH_RCV_TRAILER_ELEMENTS(MACH_RCV_TRAILER_AUDIT)
*/
routine mach_port_peek(
task : ipc_space_t;
name : mach_port_name_t;
trailer_type : mach_msg_trailer_type_t;
inout request_seqnop : mach_port_seqno_t;
out msg_sizep : mach_msg_size_t;
out msg_idp : mach_msg_id_t;
out trailer_infop : mach_msg_trailer_info_t, CountInOut);
/*
* Only valid for receive rights.
* Sets the make-send count for the port.
*/
routine mach_port_set_mscount(
task : ipc_space_t;
name : mach_port_name_t;
mscount : mach_port_mscount_t);
/*
* Only valid for port sets. Returns a list of
* the members.
*/
routine
#ifdef KERNEL_SERVER
mach_port_get_set_status_from_user(
port : mach_port_t;
#else
mach_port_get_set_status(
task : ipc_space_read_t;
#endif
name : mach_port_name_t;
out members : mach_port_name_array_t);
/*
* Puts the member port (the task must have receive rights)
* into the after port set. If the port is already a member
* of any set(s), it is atomically removed from those sets as
* part of this operation. (If after is MACH_PORT_NULL, the
* port is still removed from all current sets).
*/
routine mach_port_move_member(
task : ipc_space_t;
member : mach_port_name_t;
after : mach_port_name_t);
/*
* Requests a notification from the kernel. The request
* must supply the send-once right which is used for
* the notification. If a send-once right was previously
* registered, it is returned. The msgid must be one of:
* MACH_NOTIFY_PORT_DESTROYED (receive rights)
* MACH_NOTIFY_DEAD_NAME (send/receive/send-once rights)
* MACH_NOTIFY_SEND_POSSIBLE (send/receive/send-once rights)
* MACH_NOTIFY_NO_SENDERS (receive rights)
*
* The sync value specifies whether a notification should
* get sent immediately, if appropriate. The exact meaning
* depends on the notification:
* MACH_NOTIFY_PORT_DESTROYED: must be zero.
* MACH_NOTIFY_DEAD_NAME: if non-zero, then name can be dead,
* and the notification gets sent immediately.
* If zero, then name can't be dead.
* MACH_NOTIFY_SEND_POSSIBLE: if non-zero, will generate a send-
* possible notification as soon as it is possible to send
* to the port. If zero, will generate a send-possible
* notification only after a subsequent failed send
* (with MACH_SEND_NOTIFY option to mach_msg call). Can
* generate a dead-name notification if name is already dead
* or becomes dead before a send-possible notification fires.
* MACH_NOTIFY_NO_SENDERS: the notification gets sent
* immediately if the current mscount is greater
* than or equal to the sync value and there are no
* extant send rights.
*
* If the name is deleted before a successfully registered notification
* is delivered, it is replaced with a port-deleted notification.
*/
routine mach_port_request_notification(
task : ipc_space_t;
name : mach_port_name_t;
msgid : mach_msg_id_t;
sync : mach_port_mscount_t;
notify : mach_port_send_once_t;
out previous : mach_port_move_send_once_t);
/*
* Inserts the specified rights into the target task,
* using the specified name. If inserting send/receive
* rights and the task already has send/receive rights
* for the port, then the names must agree. In any case,
* the task gains a user ref for the port.
*/
routine mach_port_insert_right(
task : ipc_space_t;
name : mach_port_name_t;
poly : mach_port_poly_t);
/*
* Returns the specified right for the named port
* in the target task, extracting that right from
* the target task. The target task loses a user
* ref and the name may be available for recycling.
* msgt_name must be one of
* MACH_MSG_TYPE_MOVE_RECEIVE
* MACH_MSG_TYPE_COPY_SEND
* MACH_MSG_TYPE_MAKE_SEND
* MACH_MSG_TYPE_MOVE_SEND
* MACH_MSG_TYPE_MAKE_SEND_ONCE
* MACH_MSG_TYPE_MOVE_SEND_ONCE
*/
routine mach_port_extract_right(
task : ipc_space_t;
name : mach_port_name_t;
msgt_name : mach_msg_type_name_t;
out poly : mach_port_poly_t);
/*
* Only valid for receive rights.
* Sets the sequence number for the port.
*/
routine mach_port_set_seqno(
task : ipc_space_t;
name : mach_port_name_t;
seqno : mach_port_seqno_t);
/*
* Returns information about a port.
*/
routine
#ifdef KERNEL_SERVER
mach_port_get_attributes_from_user(
port : mach_port_t;
#else
mach_port_get_attributes(
task : ipc_space_read_t;
#endif
name : mach_port_name_t;
flavor : mach_port_flavor_t;
out port_info_out : mach_port_info_t, CountInOut);
/*
* Set attributes of a port
*/
routine mach_port_set_attributes(
task : ipc_space_t;
name : mach_port_name_t;
flavor : mach_port_flavor_t;
port_info : mach_port_info_t);
/*
* Allocates the specified kind of object, qos version.
* The right must be
* MACH_PORT_RIGHT_RECEIVE
* Like port_allocate_name, but the kernel picks a name.
* It can use any name not associated with a right.
*/
routine mach_port_allocate_qos(
task : ipc_space_t;
right : mach_port_right_t;
inout qos : mach_port_qos_t;
out name : mach_port_name_t);
/*
* Generic interface to allocation various kinds of ports.
* Should never be called directly by users (at least not
* unless they are exceedingly masochistic).
*/
routine mach_port_allocate_full(
task : ipc_space_t;
right : mach_port_right_t;
proto : mach_port_t;
inout qos : mach_port_qos_t;
inout name : mach_port_name_t);
/*
* Pre-expand task port name space.
*/
routine task_set_port_space(
task : ipc_space_t;
table_entries : int);
/*
* Returns the exact number of extant send rights
* for the given receive right.
* This call is only valid on MACH_IPC_DEBUG kernels.
* Otherwise, KERN_FAILURE is returned.
*/
routine mach_port_get_srights(
task : ipc_space_t;
name : mach_port_name_t;
out srights : mach_port_rights_t);
/*
* Returns information about an IPC space.
* This call is only valid on MACH_IPC_DEBUG kernels.
* Otherwise, KERN_FAILURE is returned.
*/
routine
#ifdef KERNEL_SERVER
mach_port_space_info_from_user(
port : mach_port_t;
#else
mach_port_space_info(
space : ipc_space_read_t;
#endif
out space_info : ipc_info_space_t;
out table_info : ipc_info_name_array_t;
out tree_info : ipc_info_tree_name_array_t);
/*
* Returns information about the dead-name requests
* registered with the named receive right.
* This call is only valid on MACH_IPC_DEBUG kernels.
* Otherwise, KERN_FAILURE is returned.
*/
routine mach_port_dnrequest_info(
task : ipc_space_t;
name : mach_port_name_t;
out dnr_total : unsigned; /* total size of table */
out dnr_used : unsigned); /* amount used */
/*
* Return the type and address of the kernel object
* that the given send/receive right represents.
* This call is only valid on MACH_IPC_DEBUG kernels.
* Otherwise, KERN_FAILURE is returned.
*
* This interface is DEPRECATED in favor of the new
* mach_port_kernel_object64() call (see below).
*/
routine
#ifdef KERNEL_SERVER
mach_port_kernel_object_from_user(
port : mach_port_t;
#else
mach_port_kernel_object(
task : ipc_space_read_t;
#endif
name : mach_port_name_t;
out object_type : unsigned;
out object_addr : unsigned);
/*
* Inserts the specified rights into the portset identified
* by the <task, pset> pair. The results of passing in the
* Poly argument via the supplied disposition must yield a
* receive right.
*
* If the <task,pset> pair does not represent a valid portset
* KERN_INVALID_RIGHT is returned.
*
* If the passed in name argument does not represent a receive
* right, KERN_INVALID_CAPABILITY will be returned.
*
* If the port represented by the receive right is already in
* the portset, KERN_ALREADY_IN_SET is returned.
*/
routine mach_port_insert_member(
task : ipc_space_t;
name : mach_port_name_t;
pset : mach_port_name_t);
/*
* Extracts the specified right from the named portset
* in the target task.
* the target task. The target task loses a user
* ref and the name may be available for recycling.
* msgt_name must be one of
* MACH_MSG_TYPE_MOVE_RECEIVE
* MACH_MSG_TYPE_COPY_SEND
* MACH_MSG_TYPE_MAKE_SEND
* MACH_MSG_TYPE_MOVE_SEND
* MACH_MSG_TYPE_MAKE_SEND_ONCE
* MACH_MSG_TYPE_MOVE_SEND_ONCE
*/
routine mach_port_extract_member(
task : ipc_space_t;
name : mach_port_name_t;
pset : mach_port_name_t);
/*
* Only valid for receive rights.
* Gets the context pointer for the port.
*/
routine
#ifdef KERNEL_SERVER
mach_port_get_context_from_user(
port : mach_port_t;
#else
mach_port_get_context(
task : ipc_space_read_t;
#endif
name : mach_port_name_t;
#ifdef LIBSYSCALL_INTERFACE
out context : mach_port_context_t
#else
out context : mach_vm_address_t
#endif
);
/*
* Only valid for receive rights.
* Sets the context pointer for the port.
*/
routine mach_port_set_context(
task : ipc_space_t;
name : mach_port_name_t;
#ifdef LIBSYSCALL_INTERFACE
context : mach_port_context_t
#else
context : mach_vm_address_t
#endif
);
/*
* Return the type and address of the kernel object
* that the given send/receive right represents.
* This call is only valid on MACH_IPC_DEBUG kernels.
* Otherwise, KERN_FAILURE is returned.
*/
routine
#ifdef KERNEL_SERVER
mach_port_kobject_from_user(
port : mach_port_t;
#else
mach_port_kobject(
task : ipc_space_read_t;
#endif
name : mach_port_name_t;
out object_type : natural_t;
out object_addr : mach_vm_address_t);
/*
* Constructs a right based on the options passed
* in. Also allows guarding the port as one of the
* options if the requested right is a receive
* right.
*/
routine mach_port_construct(
task : ipc_space_t;
options : mach_port_options_ptr_t;
#ifdef LIBSYSCALL_INTERFACE
context : mach_port_context_t;
#else
context : uint64_t;
#endif
out name : mach_port_name_t);
/*
* Destroys a mach port using the guard provided
* for guarded ports. Also reduces the user ref
* count for send rights as specified by srdelta.
*/
routine mach_port_destruct(
task : ipc_space_t;
name : mach_port_name_t;
srdelta : mach_port_delta_t;
#ifdef LIBSYSCALL_INTERFACE
guard : mach_port_context_t
#else
guard : uint64_t
#endif
);
/*
* Guard an already existing port. Allows guarding
* receive rights only. Uses the context field in the
* port structure to store the guard.
*/
routine mach_port_guard(
task : ipc_space_t;
name : mach_port_name_t;
#ifdef LIBSYSCALL_INTERFACE
guard : mach_port_context_t;
#else
guard : uint64_t;
#endif
strict : boolean_t);
/*
* Unguard a port guarded previously. For unguarded ports
* or incorrect guards passed in it raises an exception
* indicating guarding misbehavior.
*/
routine mach_port_unguard(
task : ipc_space_t;
name : mach_port_name_t;
#ifdef LIBSYSCALL_INTERFACE
guard : mach_port_context_t
#else
guard : uint64_t
#endif
);
/*
* Returns basic information about an IPC space.
* This call is only valid on MACH_IPC_DEBUG kernels.
* Otherwise, KERN_FAILURE is returned.
*/
routine mach_port_space_basic_info(
task : ipc_space_inspect_t;
out basic_info : ipc_info_space_basic_t);
#if KERNEL || !LIBSYSCALL_INTERFACE
/*
* Returns sync ipc turnstile link status
* for special reply ports.
*/
routine mach_port_special_reply_port_reset_link(
task : ipc_space_t;
name : mach_port_name_t;
out srp_lost_link : boolean_t);
#else
skip;
#endif
/*
* Guard an already existing port. Allows guarding
* receive rights only. Uses the context field in the
* port structure to store the guard.
*/
routine mach_port_guard_with_flags(
task : ipc_space_t;
name : mach_port_name_t;
#ifdef LIBSYSCALL_INTERFACE
guard : mach_port_context_t;
#else
guard : uint64_t;
#endif
flags : uint64_t);
/*
* Swap guard value of an existing guarded port. Works
* only if it is not a strict guard.
*/
routine mach_port_swap_guard(
task : ipc_space_t;
name : mach_port_name_t;
#ifdef LIBSYSCALL_INTERFACE
old_guard : mach_port_context_t;
#else
old_guard : uint64_t;
#endif
#ifdef LIBSYSCALL_INTERFACE
new_guard : mach_port_context_t);
#else
new_guard : uint64_t);
#endif
/*
* Return the type and address of the kernel object
* that the given send/receive right represents.
* This call is only valid on MACH_IPC_DEBUG kernels.
* Otherwise, KERN_FAILURE is returned.
*/
routine
#ifdef KERNEL_SERVER
mach_port_kobject_description_from_user(
port : mach_port_t;
#else
mach_port_kobject_description(
task : ipc_space_read_t;
#endif
name : mach_port_name_t;
out object_type : natural_t;
out object_addr : mach_vm_address_t;
out description : kobject_description_t);
/* vim: set ft=c : */

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,37 @@
/*
* Copyright (c) 2018 Apple Inc. All rights reserved.
*
* @APPLE_OSREFERENCE_LICENSE_HEADER_START@
*
* This file contains Original Code and/or Modifications of Original Code
* as defined in and that are subject to the Apple Public Source License
* Version 2.0 (the 'License'). You may not use this file except in
* compliance with the License. The rights granted to you under the License
* may not be used to create, or enable the creation or redistribution of,
* unlawful or unlicensed copies of an Apple operating system, or to
* circumvent, violate, or enable the circumvention or violation of, any
* terms of an Apple operating system software license agreement.
*
* Please obtain a copy of the License at
* http://www.opensource.apple.com/apsl/ and read it before using this file.
*
* The Original Code and all software distributed under the License are
* distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
* Please see the License for the specific language governing rights and
* limitations under the License.
*
* @APPLE_OSREFERENCE_LICENSE_HEADER_END@
*/
#ifndef __MACH_RIGHT_H
#define __MACH_RIGHT_H
#include <sys/cdefs.h>
#if __has_include(<mach/mach_right_private.h>)
#include <mach/mach_right_private.h>
#endif
#endif // __MACH_RIGHT_H

View File

@ -0,0 +1,37 @@
/*
* Copyright (c) 2000-2004 Apple Computer, Inc. All rights reserved.
*
* @APPLE_OSREFERENCE_LICENSE_HEADER_START@
*
* This file contains Original Code and/or Modifications of Original Code
* as defined in and that are subject to the Apple Public Source License
* Version 2.0 (the 'License'). You may not use this file except in
* compliance with the License. The rights granted to you under the License
* may not be used to create, or enable the creation or redistribution of,
* unlawful or unlicensed copies of an Apple operating system, or to
* circumvent, violate, or enable the circumvention or violation of, any
* terms of an Apple operating system software license agreement.
*
* Please obtain a copy of the License at
* http://www.opensource.apple.com/apsl/ and read it before using this file.
*
* The Original Code and all software distributed under the License are
* distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
* Please see the License for the specific language governing rights and
* limitations under the License.
*
* @APPLE_OSREFERENCE_LICENSE_HEADER_END@
*/
/*
* @OSF_COPYRIGHT@
*/
#ifndef _MACH_MACH_SYSCALLS_H_
#define _MACH_MACH_SYSCALLS_H_
#include <mach/mach_traps.h>
#endif /* _MACH_MACH_SYSCALLS_H_ */

View File

@ -0,0 +1,73 @@
/*
* Copyright (c) 2001-2005 Apple Computer, Inc. All rights reserved.
*
* @APPLE_OSREFERENCE_LICENSE_HEADER_START@
*
* This file contains Original Code and/or Modifications of Original Code
* as defined in and that are subject to the Apple Public Source License
* Version 2.0 (the 'License'). You may not use this file except in
* compliance with the License. The rights granted to you under the License
* may not be used to create, or enable the creation or redistribution of,
* unlawful or unlicensed copies of an Apple operating system, or to
* circumvent, violate, or enable the circumvention or violation of, any
* terms of an Apple operating system software license agreement.
*
* Please obtain a copy of the License at
* http://www.opensource.apple.com/apsl/ and read it before using this file.
*
* The Original Code and all software distributed under the License are
* distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
* Please see the License for the specific language governing rights and
* limitations under the License.
*
* @APPLE_OSREFERENCE_LICENSE_HEADER_END@
*/
#ifndef _MACH_MACH_TIME_H_
#define _MACH_MACH_TIME_H_
#include <mach/mach_types.h>
#include <sys/cdefs.h>
#include <Availability.h>
struct mach_timebase_info {
uint32_t numer;
uint32_t denom;
};
typedef struct mach_timebase_info *mach_timebase_info_t;
typedef struct mach_timebase_info mach_timebase_info_data_t;
__BEGIN_DECLS
kern_return_t mach_timebase_info(
mach_timebase_info_t info);
kern_return_t mach_wait_until(
uint64_t deadline);
uint64_t mach_absolute_time(void);
__OSX_AVAILABLE_STARTING(__MAC_10_10, __IPHONE_8_0)
uint64_t mach_approximate_time(void);
/*
* like mach_absolute_time, but advances during sleep
*/
__OSX_AVAILABLE(10.12) __IOS_AVAILABLE(10.0) __TVOS_AVAILABLE(10.0) __WATCHOS_AVAILABLE(3.0)
uint64_t mach_continuous_time(void);
/*
* like mach_approximate_time, but advances during sleep
*/
__OSX_AVAILABLE(10.12) __IOS_AVAILABLE(10.0) __TVOS_AVAILABLE(10.0) __WATCHOS_AVAILABLE(3.0)
uint64_t mach_continuous_approximate_time(void);
__END_DECLS
#endif /* _MACH_MACH_TIME_H_ */

View File

@ -0,0 +1,302 @@
/*
* Copyright (c) 2000-2019 Apple Inc. All rights reserved.
*
* @APPLE_OSREFERENCE_LICENSE_HEADER_START@
*
* This file contains Original Code and/or Modifications of Original Code
* as defined in and that are subject to the Apple Public Source License
* Version 2.0 (the 'License'). You may not use this file except in
* compliance with the License. The rights granted to you under the License
* may not be used to create, or enable the creation or redistribution of,
* unlawful or unlicensed copies of an Apple operating system, or to
* circumvent, violate, or enable the circumvention or violation of, any
* terms of an Apple operating system software license agreement.
*
* Please obtain a copy of the License at
* http://www.opensource.apple.com/apsl/ and read it before using this file.
*
* The Original Code and all software distributed under the License are
* distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
* Please see the License for the specific language governing rights and
* limitations under the License.
*
* @APPLE_OSREFERENCE_LICENSE_HEADER_END@
*/
/*
* @OSF_COPYRIGHT@
*/
/*
* Mach Operating System
* Copyright (c) 1991,1990,1989,1988,1987 Carnegie Mellon University
* All Rights Reserved.
*
* Permission to use, copy, modify and distribute this software and its
* documentation is hereby granted, provided that both the copyright
* notice and this permission notice appear in all copies of the
* software, derivative works or modified versions, and any portions
* thereof, and that both notices appear in supporting documentation.
*
* CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
* CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR
* ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
*
* Carnegie Mellon requests users of this software to return to
*
* Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU
* School of Computer Science
* Carnegie Mellon University
* Pittsburgh PA 15213-3890
*
* any improvements or extensions that they make and grant Carnegie Mellon
* the rights to redistribute these changes.
*/
/*
*/
/*
* Definitions of general Mach system traps.
*
* These are the definitions as seen from user-space.
* The kernel definitions are in <mach/syscall_sw.h>.
* Kernel RPC functions are defined in <mach/mach_interface.h>.
*/
#ifndef _MACH_MACH_TRAPS_H_
#define _MACH_MACH_TRAPS_H_
#include <stdint.h>
#include <mach/std_types.h>
#include <mach/mach_types.h>
#include <mach/kern_return.h>
#include <mach/port.h>
#include <mach/vm_types.h>
#include <mach/clock_types.h>
#include <machine/endian.h>
#include <sys/cdefs.h>
__BEGIN_DECLS
extern kern_return_t clock_sleep_trap(
mach_port_name_t clock_name,
sleep_type_t sleep_type,
int sleep_sec,
int sleep_nsec,
mach_timespec_t *wakeup_time);
extern kern_return_t _kernelrpc_mach_vm_allocate_trap(
mach_port_name_t target,
mach_vm_offset_t *addr,
mach_vm_size_t size,
int flags);
extern kern_return_t _kernelrpc_mach_vm_deallocate_trap(
mach_port_name_t target,
mach_vm_address_t address,
mach_vm_size_t size
);
extern kern_return_t task_dyld_process_info_notify_get(
mach_port_name_array_t names_addr,
natural_t *names_count_addr
);
extern kern_return_t _kernelrpc_mach_vm_protect_trap(
mach_port_name_t target,
mach_vm_address_t address,
mach_vm_size_t size,
boolean_t set_maximum,
vm_prot_t new_protection
);
extern kern_return_t _kernelrpc_mach_vm_map_trap(
mach_port_name_t target,
mach_vm_offset_t *address,
mach_vm_size_t size,
mach_vm_offset_t mask,
int flags,
vm_prot_t cur_protection
);
extern kern_return_t _kernelrpc_mach_vm_purgable_control_trap(
mach_port_name_t target,
mach_vm_offset_t address,
vm_purgable_t control,
int *state);
extern kern_return_t _kernelrpc_mach_port_allocate_trap(
mach_port_name_t target,
mach_port_right_t right,
mach_port_name_t *name
);
extern kern_return_t _kernelrpc_mach_port_deallocate_trap(
mach_port_name_t target,
mach_port_name_t name
);
extern kern_return_t _kernelrpc_mach_port_mod_refs_trap(
mach_port_name_t target,
mach_port_name_t name,
mach_port_right_t right,
mach_port_delta_t delta
);
extern kern_return_t _kernelrpc_mach_port_move_member_trap(
mach_port_name_t target,
mach_port_name_t member,
mach_port_name_t after
);
extern kern_return_t _kernelrpc_mach_port_insert_right_trap(
mach_port_name_t target,
mach_port_name_t name,
mach_port_name_t poly,
mach_msg_type_name_t polyPoly
);
extern kern_return_t _kernelrpc_mach_port_get_attributes_trap(
mach_port_name_t target,
mach_port_name_t name,
mach_port_flavor_t flavor,
mach_port_info_t port_info_out,
mach_msg_type_number_t *port_info_outCnt
);
extern kern_return_t _kernelrpc_mach_port_insert_member_trap(
mach_port_name_t target,
mach_port_name_t name,
mach_port_name_t pset
);
extern kern_return_t _kernelrpc_mach_port_extract_member_trap(
mach_port_name_t target,
mach_port_name_t name,
mach_port_name_t pset
);
extern kern_return_t _kernelrpc_mach_port_construct_trap(
mach_port_name_t target,
mach_port_options_t *options,
uint64_t context,
mach_port_name_t *name
);
extern kern_return_t _kernelrpc_mach_port_destruct_trap(
mach_port_name_t target,
mach_port_name_t name,
mach_port_delta_t srdelta,
uint64_t guard
);
extern kern_return_t _kernelrpc_mach_port_guard_trap(
mach_port_name_t target,
mach_port_name_t name,
uint64_t guard,
boolean_t strict
);
extern kern_return_t _kernelrpc_mach_port_unguard_trap(
mach_port_name_t target,
mach_port_name_t name,
uint64_t guard
);
extern kern_return_t mach_generate_activity_id(
mach_port_name_t target,
int count,
uint64_t *activity_id
);
extern kern_return_t macx_swapon(
uint64_t filename,
int flags,
int size,
int priority);
extern kern_return_t macx_swapoff(
uint64_t filename,
int flags);
extern kern_return_t macx_triggers(
int hi_water,
int low_water,
int flags,
mach_port_t alert_port);
extern kern_return_t macx_backing_store_suspend(
boolean_t suspend);
extern kern_return_t macx_backing_store_recovery(
int pid);
extern boolean_t swtch_pri(int pri);
extern boolean_t swtch(void);
extern kern_return_t thread_switch(
mach_port_name_t thread_name,
int option,
mach_msg_timeout_t option_time);
extern mach_port_name_t task_self_trap(void);
extern kern_return_t host_create_mach_voucher_trap(
mach_port_name_t host,
mach_voucher_attr_raw_recipe_array_t recipes,
int recipes_size,
mach_port_name_t *voucher);
extern kern_return_t mach_voucher_extract_attr_recipe_trap(
mach_port_name_t voucher_name,
mach_voucher_attr_key_t key,
mach_voucher_attr_raw_recipe_t recipe,
mach_msg_type_number_t *recipe_size);
extern kern_return_t _kernelrpc_mach_port_type_trap(
ipc_space_t task,
mach_port_name_t name,
mach_port_type_t *ptype);
extern kern_return_t _kernelrpc_mach_port_request_notification_trap(
ipc_space_t task,
mach_port_name_t name,
mach_msg_id_t msgid,
mach_port_mscount_t sync,
mach_port_name_t notify,
mach_msg_type_name_t notifyPoly,
mach_port_name_t *previous);
/*
* Obsolete interfaces.
*/
extern kern_return_t task_for_pid(
mach_port_name_t target_tport,
int pid,
mach_port_name_t *t);
extern kern_return_t task_name_for_pid(
mach_port_name_t target_tport,
int pid,
mach_port_name_t *tn);
extern kern_return_t pid_for_task(
mach_port_name_t t,
int *x);
extern kern_return_t debug_control_port_for_pid(
mach_port_name_t target_tport,
int pid,
mach_port_name_t *t);
__END_DECLS
#endif /* _MACH_MACH_TRAPS_H_ */

View File

@ -0,0 +1,713 @@
/*
* Copyright (c) 2000-2016 Apple Inc. All rights reserved.
*
* @APPLE_OSREFERENCE_LICENSE_HEADER_START@
*
* This file contains Original Code and/or Modifications of Original Code
* as defined in and that are subject to the Apple Public Source License
* Version 2.0 (the 'License'). You may not use this file except in
* compliance with the License. The rights granted to you under the License
* may not be used to create, or enable the creation or redistribution of,
* unlawful or unlicensed copies of an Apple operating system, or to
* circumvent, violate, or enable the circumvention or violation of, any
* terms of an Apple operating system software license agreement.
*
* Please obtain a copy of the License at
* http://www.opensource.apple.com/apsl/ and read it before using this file.
*
* The Original Code and all software distributed under the License are
* distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
* Please see the License for the specific language governing rights and
* limitations under the License.
*
* @APPLE_OSREFERENCE_LICENSE_HEADER_END@
*/
/*
* @OSF_COPYRIGHT@
*/
/*
* Mach Operating System
* Copyright (c) 1991,1990,1989,1988 Carnegie Mellon University
* All Rights Reserved.
*
* Permission to use, copy, modify and distribute this software and its
* documentation is hereby granted, provided that both the copyright
* notice and this permission notice appear in all copies of the
* software, derivative works or modified versions, and any portions
* thereof, and that both notices appear in supporting documentation.
*
* CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
* CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR
* ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
*
* Carnegie Mellon requests users of this software to return to
*
* Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU
* School of Computer Science
* Carnegie Mellon University
* Pittsburgh PA 15213-3890
*
* any improvements or extensions that they make and grant Carnegie Mellon
* the rights to redistribute these changes.
*/
/*
* NOTICE: This file was modified by McAfee Research in 2004 to introduce
* support for mandatory and extensible security protections. This notice
* is included in support of clause 2.2 (b) of the Apple Public License,
* Version 2.0.
*/
/*
*/
/*
* Mach kernel interface type declarations
*/
#ifndef _MACH_MACH_TYPES_DEFS_
#define _MACH_MACH_TYPES_DEFS_
#include <mach/std_types.defs>
type memory_object_offset_t = uint64_t;
type memory_object_size_t = uint64_t;
type memory_object_cluster_size_t = uint32_t;
type memory_object_fault_info_t = array[16] of integer_t;
type mach_port_status_t = struct[10] of integer_t; /* obsolete */
type mach_port_info_ext_t = struct[17] of integer_t;
/* mach_port_info_t: can hold either a
* mach_port_status_t (9 ints) or a
* mach_port_limits_t (1 int) or a
* mach_port_info_ext_t (17 ints). If new flavors of
* mach_port_{get,set}_attributes are added, the size of
* this array may have to be increased. (See mach/port.h)
*/
type mach_port_flavor_t = int;
type mach_port_info_t = array[*:17] of integer_t;
/*
* mach_msg_max_trailer_t: can hold
* mach_msg_trailer_type_t (1 int)
* mach_msg_trailer_size_t (1 int)
* mach_port_seqno_t (1 int)
* security_token_t (2 ints)
* audit_token_t (8 ints)
* mach_port_context_t (2 ints)
* msgh_ad (1 int)
* msg_labels_t (1 int)
*/
type mach_msg_trailer_type_t = int;
type mach_msg_trailer_info_t = array[*:68] of char;
type mach_task_flavor_t = int;
type task_t = mach_port_t
#if KERNEL_SERVER
intran: task_t convert_port_to_task(mach_port_t)
outtran: mach_port_t convert_task_to_port(task_t)
destructor: task_deallocate(task_t)
#endif /* KERNEL_SERVER */
;
type task_name_t = mach_port_t
#if KERNEL_SERVER
intran: task_name_t convert_port_to_task_name(mach_port_t)
outtran: mach_port_t convert_task_name_to_port(task_name_t)
destructor: task_name_deallocate(task_name_t)
#endif /* KERNEL_SERVER */
;
type task_policy_set_t = mach_port_t
#if KERNEL_SERVER
intran: task_policy_set_t convert_port_to_task_policy_set(mach_port_t)
destructor: task_policy_set_deallocate(task_policy_set_t)
#endif /* KERNEL_SERVER */
;
type task_policy_get_t = mach_port_t
#if KERNEL_SERVER
intran: task_policy_get_t convert_port_to_task_policy_get(mach_port_t)
destructor: task_policy_get_deallocate(task_policy_get_t)
#endif /* KERNEL_SERVER */
;
type task_inspect_t = mach_port_t
#if KERNEL_SERVER
intran: task_inspect_t convert_port_to_task_inspect(mach_port_t)
outtran: mach_port_t convert_task_inspect_to_port(task_inspect_t)
destructor: task_inspect_deallocate(task_inspect_t)
#endif /* KERNEL_SERVER */
;
type task_read_t = mach_port_t
#if KERNEL_SERVER
intran: task_read_t convert_port_to_task_read(mach_port_t)
outtran: mach_port_t convert_task_read_to_port(task_read_t)
destructor: task_read_deallocate(task_read_t)
#endif /* KERNEL_SERVER */
;
type task_id_token_t = mach_port_t
#if KERNEL_SERVER
intran: task_id_token_t convert_port_to_task_id_token(mach_port_t)
outtran: mach_port_t convert_task_id_token_to_port(task_id_token_t)
destructor: task_id_token_release(task_id_token_t)
#endif /* KERNEL_SERVER */
;
type thread_t = mach_port_t
#if KERNEL_SERVER
intran: thread_t convert_port_to_thread(mach_port_t)
outtran: mach_port_t convert_thread_to_port(thread_t)
destructor: thread_deallocate(thread_t)
#endif /* KERNEL_SERVER */
;
type thread_inspect_t = mach_port_t
#if KERNEL_SERVER
intran: thread_inspect_t convert_port_to_thread_inspect(mach_port_t)
outtran: mach_port_t convert_thread_inspect_to_port(thread_inspect_t)
destructor: thread_inspect_deallocate(thread_inspect_t)
#endif /* KERNEL_SERVER */
;
type thread_read_t = mach_port_t
#if KERNEL_SERVER
intran: thread_read_t convert_port_to_thread_read(mach_port_t)
outtran: mach_port_t convert_thread_read_to_port(thread_read_t)
destructor: thread_read_deallocate(thread_read_t)
#endif /* KERNEL_SERVER */
;
type thread_act_t = mach_port_t
#if KERNEL_SERVER
intran: thread_act_t convert_port_to_thread(mach_port_t)
outtran: mach_port_t convert_thread_to_port(thread_act_t)
destructor: thread_deallocate(thread_act_t)
#endif /* KERNEL_SERVER */
;
type thread_act_consume_ref_t = mach_port_move_send_t
cusertype: thread_act_t
#if KERNEL_SERVER
intran: thread_act_t convert_port_to_thread(mach_port_t)
destructor: thread_deallocate(thread_act_t)
#endif /* KERNEL_SERVER */
;
type suid_cred_path_t = c_string[*:1024];
type suid_cred_uid_t = uint32_t;
type suid_cred_t = mach_port_t
#if KERNEL_SERVER
outtran: mach_port_t convert_suid_cred_to_port(suid_cred_t)
#endif /* KERNEL_SERVER */
;
/* thread_state_t: This inline array can hold
* a machine-dependent amount of data, defined in
* mach/machine/???? (currently THREAD_STATE_MAX,
* in mach/thread_state.h)
*/
#include <mach/machine/thread_state.h>
type thread_state_flavor_t = int;
type thread_state_t = array[*:THREAD_STATE_MAX] of natural_t;
type task_array_t = ^array[] of task_t;
type thread_array_t = ^array[] of thread_t;
type thread_act_array_t = ^array[] of thread_act_t;
type act_params_t = array[6] of int;
type vm_map_t = mach_port_t
#if KERNEL_SERVER
intran: vm_map_t convert_port_to_map(mach_port_t)
destructor: vm_map_deallocate(vm_map_t)
#endif /* KERNEL_SERVER */
;
type vm_map_inspect_t = mach_port_t
#if KERNEL_SERVER
intran: vm_map_inspect_t convert_port_to_map_inspect(mach_port_t)
destructor: vm_map_inspect_deallocate(vm_map_inspect_t)
#endif /* KERNEL_SERVER */
;
type vm_map_read_t = mach_port_t
#if KERNEL_SERVER
intran: vm_map_read_t convert_port_to_map_read(mach_port_t)
destructor: vm_map_read_deallocate(vm_map_read_t)
#endif /* KERNEL_SERVER */
;
type vm_task_entry_t = mach_port_t
cusertype: vm_map_t
#if KERNEL_SERVER
intran: vm_map_t convert_port_entry_to_map(mach_port_t)
destructor: vm_map_deallocate(vm_map_t)
#endif /* KERNEL_SERVER */
;
type ipc_space_t = mach_port_t
#if KERNEL_SERVER
intran: ipc_space_t convert_port_to_space(mach_port_t)
destructor: space_deallocate(ipc_space_t)
#endif /* KERNEL_SERVER */
;
type ipc_space_read_t = mach_port_t
#if KERNEL_SERVER
intran: ipc_space_read_t convert_port_to_space_read(mach_port_t)
destructor: space_read_deallocate(ipc_space_read_t)
#endif /* KERNEL_SERVER */
;
type ipc_space_inspect_t = mach_port_t
#if KERNEL_SERVER
intran: ipc_space_inspect_t convert_port_to_space_inspect(mach_port_t)
destructor: space_inspect_deallocate(ipc_space_inspect_t)
#endif /* KERNEL_SERVER */
;
type arcade_register_t = mach_port_t
#if KERNEL_SERVER
intran: arcade_register_t convert_port_to_arcade_register(mach_port_t)
#endif /* KERNEL_SERVER */
;
type vm_prot_t = int;
type vm_inherit_t = int;
type vm_purgable_t = int;
type xxx_vm_statistics_data_t = struct[13] of integer_t;
type vm_behavior_t = int;
type vm_statistics_data_t = struct[15] of integer_t;
type vm_machine_attribute_t = int;
type vm_machine_attribute_val_t = int;
type vm_sync_t = int;
/* thread_info_t: this inline array can hold any of:
* thread_basic_info_t (10 ints)
* policy_timeshare_info_t (5 ints)
* policy_fifo_info_t (4 ints)
* policy_rr_info_t (5 ints)
* thread_extended_info (12 ints + 64 chars)
* if other thread_info flavors are added, this
* definition may need to be changed. (See
* mach/thread_info.h and mach/policy.h) */
type thread_flavor_t = int;
type thread_info_t = array[*:32] of integer_t;
type thread_policy_flavor_t = natural_t;
type thread_policy_t = array[*:16] of integer_t;
/* task_info_t: this inline array can hold any of:
* task_basic_info_32_t (8 ints)
* task_basic_info_64_t (10 ints)
* task_events_info_t (8 ints)
* task_thread_times_info_t (4 ints)
* policy_timeshare_info_t (5 ints)
* policy_fifo_info_t (4 ints)
* policy_rr_info_t (5 ints)
* task security token (2 ints)
* task audit token (8 ints)
* dyld info (2 64-bit ints and 1 int)
* task_extmod_info_t (8 64-bit ints)
* task_basic_info_64_2_t
* mach_task_basic_info_t (12 ints)
* task_power_info_t (18 ints)
* task_vm_info_t (87 ints)
* If other task_info flavors are added, this
* definition may need to be changed. (See
* mach/task_info.h and mach/policy.h) */
type task_flavor_t = int;
type task_info_t = array[*:87] of integer_t;
type task_purgable_info_t = struct[68] of integer_t;
type task_policy_flavor_t = natural_t;
type task_policy_t = array[*:16] of integer_t;
type task_inspect_flavor_t = natural_t;
type task_inspect_info_t = array[*:4] of integer_t;
type task_exc_guard_behavior_t = uint32_t;
type mem_entry_name_port_t = mach_port_t
#if KERNEL_SERVER
intran: mem_entry_name_port_t null_conversion(mach_port_t)
outtran: mach_port_t null_conversion(mem_entry_name_port_t)
#endif /* KERNEL_SERVER */
;
type mem_entry_name_port_move_send_t = mach_port_move_send_t
cusertype: mem_entry_name_port_t
#if KERNEL_SERVER
intran: mem_entry_name_port_t null_conversion(mach_port_t)
outtran: mach_port_t null_conversion(mem_entry_name_port_t)
#endif /* KERNEL_SERVER */
;
type memory_object_default_t = mach_port_t
;
type memory_object_t = mach_port_t
;
type memory_object_control_t = mach_port_t
;
type memory_object_name_t = mach_port_t
ctype: mach_port_t
;
type memory_object_copy_strategy_t = int;
type memory_object_return_t = int;
type machine_info_data_t = struct[5] of integer_t;
type machine_slot_data_t = struct[8] of integer_t;
type host_t = mach_port_t
#if KERNEL_SERVER
intran: host_t convert_port_to_host(mach_port_t)
outtran: mach_port_t convert_host_to_port(host_t)
#endif /* KERNEL_SERVER */
;
type host_priv_t = mach_port_t
#if KERNEL_SERVER
intran: host_priv_t convert_port_to_host_priv(mach_port_t)
#endif /* KERNEL_SERVER */
;
type host_security_t = mach_port_t
#if KERNEL_SERVER
intran: host_security_t convert_port_to_host_security(mach_port_t)
#endif /* KERNEL_SERVER */
;
/*
* host_info_t: variable-sized inline array that can contain:
*
* host_basic_info_old_t (5 ints)
* host_basic_info_t (12 ints)
* host_sched_info_t (2 ints)
* kernel_resource_sizes_t (5 ints)
* host_load_info_t (6 ints)
* vm_statistics32_t (15 ints)
* host_purgable_info_t (68 ints)
* host_expired_task_info uses a task_power_info (18 ints)
*
* If other host_info flavors are added, this definition may
* need to be changed. (See mach/{host_info,vm_statistics}.h)
*/
type host_flavor_t = int;
type host_info_t = array[*:68] of integer_t;
/*
* host_info64_t: variable-sized inline array that can contain:
*
* vm_statistics_t (6 ints and 9 longs)
* vm_extmod_statistics_t (6 64-bit ints)
*/
type host_info64_t = array[*:256] of integer_t;
type processor_t = mach_port_t
#if KERNEL_SERVER
intran: processor_t convert_port_to_processor(mach_port_t)
outtran: mach_port_t convert_processor_to_port(processor_t)
#endif /* KERNEL_SERVER */
;
type processor_array_t = ^array[] of processor_t;
/*
* processor_info_t: variable-sized inline array that can
* contain:
*
* - processor_basic_info_t: (5 ints)
* - processor_cpu_load_info_t: (4 ints)
* - processor_machine_info_t: (12 ints)
* - processor_cpu_stat_t: (10 ints)
* - processor_cpu_stat64_t: (20 ints)
*
* If other processor_info flavors are added, this definition
* may need to be changed.
*
* See mach/processor_info.h and mach/arm/processor_info.h.
*/
type processor_flavor_t = int;
type processor_info_t = array[*:20] of integer_t;
type processor_info_array_t = ^array[] of integer_t;
type processor_set_t = mach_port_t
#if KERNEL_SERVER
intran: processor_set_t convert_port_to_pset(mach_port_t)
outtran: mach_port_t convert_pset_to_port(processor_set_t)
destructor: pset_deallocate(processor_set_t)
#endif /* KERNEL_SERVER */
;
type processor_set_array_t = ^array[] of processor_set_t;
type processor_set_name_t = mach_port_t
#if KERNEL_SERVER
intran: processor_set_name_t convert_port_to_pset_name(mach_port_t)
outtran: mach_port_t convert_pset_name_to_port(processor_set_name_t)
destructor: pset_deallocate(processor_set_name_t)
#endif /* KERNEL_SERVER */
;
type processor_set_name_array_t = ^array[] of processor_set_name_t;
/* processor_set_info_t: variable-size inline array
* that can hold:
* processor_set_basic_info (5 ints)
* processor_set_load_info (4 ints)
* policy_timeshare_base_t (1 int)
* policy_fifo_base_t (1 int)
* policy_rr_base_t (1 int)
* policy_timeshare_base_t (1 int)
* policy_fifo_base_t (1 int)
* policy_rr_base_t (1 int)
* policy_t (1 int)
* If other flavors are added, this definition may
* need to be changed. (see mach/processor.h) */
type processor_set_flavor_t = int;
type processor_set_info_t = array[*:5] of integer_t;
type bootstrap_t = mach_port_t;
type kernel_version_t = c_string[*:512];
type kernel_boot_info_t = c_string[*:4096];
type time_value_t = struct[2] of integer_t;
type mach_port_qos_t = struct[2] of integer_t;
type mach_port_options_t = struct[3] of uint64_t;
type mach_port_options_ptr_t = ^ mach_port_options_t;
type emulation_vector_t = ^array[] of vm_offset_t;
type inline_existence_map_t = array[*:512] of char;
type policy_t = int;
/* policy_info_t: variable-size inline array. Can hold:
* policy_timeshare_info_t (5 ints)
* policy_fifo_info_t (4 ints)
* policy_rr_info_t (5 ints) */
type policy_base_t = array[*:5] of integer_t;
type policy_info_t = array[*:2] of integer_t;
type policy_limit_t = array[*:1] of integer_t;
type ledger_t = mach_port_t
#if KERNEL_SERVER
intran: ledger_t convert_port_to_ledger(mach_port_t)
outtran: mach_port_t convert_ledger_to_port(ledger_t)
#endif /* KERNEL_SERVER */
;
type ledger_array_t = ^array[] of ledger_t;
type ledger_item_t = integer_t;
/* DEPRECATED */
type ledger_amount_t = int64_t;
type security_token_t = struct[2] of uint32_t;
type audit_token_t = struct[8] of uint32_t;
type msg_labels_t = mach_port_t;
/* memory_object_info_t: variable-size inline array:
* memory_object_attr_info_t (5 ints)
* XXX actually it's 6 ints temporarily (object_ready!)
* memory_object_behave_info_t (4 ints)
* memory_object_perf_info_t (2 ints)
* old_memory_object_attr_info_t (3 ints)
* If other flavors are added, this definition may
* need to be changed. (see mach/memory_object.h) */
type memory_object_flavor_t = int;
type memory_object_info_t = array[*:6] of int;
/* vm_region_info_t: variable-size inline array that can hold:
* vm_region_basic_info_t (8 ints)
* If other flavors are added, this definition may
* need to be changed. (see mach/vm_region.h) */
type vm_region_flavor_t = int;
type vm_region_info_t = array[*:10] of int;
type vm_region_recurse_info_t = array[*:19] of int;
type vm_page_info_flavor_t = int;
type vm_page_info_t = array[*:32] of int;
type mach_vm_read_entry_t = array[512] of mach_vm_offset_t;
type vm_read_entry_t = array[512] of vm_offset_t;
#ifdef VM32_SUPPORT
type vm32_read_entry_t = array[512] of vm32_offset_t;
#endif
type exception_mask_t = int;
type exception_behavior_t = int;
type exception_handler_t = mach_port_t;
type exception_handler_info_t = struct[2] of natural_t;
type exception_handler_array_t =
array[*:32] of exception_handler_t;
type exception_handler_info_array_t =
array[*:32] of exception_handler_info_t;
type exception_behavior_array_t =
array[*:32] of exception_behavior_t;
type exception_flavor_array_t =
array[*:32] of thread_state_flavor_t;
type exception_mask_array_t =
array[*:32] of exception_mask_t;
type semaphore_t = mach_port_t
#if KERNEL_SERVER
intran: semaphore_t convert_port_to_semaphore(mach_port_t)
outtran: mach_port_t convert_semaphore_to_port(semaphore_t)
destructor: semaphore_dereference(semaphore_t)
#endif /* KERNEL_SERVER */
;
type semaphore_consume_ref_t = mach_port_move_send_t
cusertype: semaphore_t
#if KERNEL_SERVER
intran: semaphore_t convert_port_to_semaphore(mach_port_t)
outtran: mach_port_t convert_semaphore_to_port(semaphore_t)
#endif /* KERNEL_SERVER */
;
#ifndef _MACH_MACH_EVENTLINK_TYPE_DEFS
#define _MACH_MACH_EVENTLINK_TYPE_DEFS
type eventlink_t = mach_port_t
ctype: mach_port_t
#if KERNEL_SERVER
intran: ipc_eventlink_t convert_port_to_eventlink(mach_port_t)
destructor: ipc_eventlink_deallocate(ipc_eventlink_t)
#endif /* KERNEL_SERVER */
;
type eventlink_consume_ref_t = mach_port_move_send_t
ctype: mach_port_t
#if KERNEL_SERVER
intran: ipc_eventlink_t convert_port_to_eventlink(mach_port_t)
destructor: ipc_eventlink_deallocate(ipc_eventlink_t)
#endif /* KERNEL_SERVER */
;
type eventlink_port_pair_t = array[2] of mach_port_t;
type mach_eventlink_create_option_t = uint32_t;
type mach_eventlink_associate_option_t = uint32_t;
type mach_eventlink_disassociate_option_t = uint32_t;
type mach_eventlink_signal_wait_option_t = uint32_t;
#endif /* _MACH_MACH_EVENTLINK_TYPE_DEFS */
type lock_set_t = mach_port_t
#if KERNEL_SERVER
intran: lock_set_t convert_port_to_lock_set(mach_port_t)
outtran: mach_port_t convert_lock_set_to_port(lock_set_t)
destructor: lock_set_dereference(lock_set_t)
#endif /* KERNEL_SERVER */
;
type task_suspension_token_t = mach_port_move_send_once_t
#if KERNEL_SERVER
intran: task_suspension_token_t convert_port_to_task_suspension_token(mach_port_t)
outtran: mach_port_t convert_task_suspension_token_to_port(task_suspension_token_t)
#endif /* KERNEL_SERVER */
;
type vfs_path_t = c_string[4096];
type nspace_path_t = c_string[1024]; /* 1024 == PATH_MAX */
/* public voucher types */
/* Mach voucher object */
type mach_voucher_t = mach_port_t;
type mach_voucher_name_t = mach_port_name_t;
type mach_voucher_attr_manager_t = mach_port_t;
type mach_voucher_attr_control_t = mach_port_t;
/* IPC voucher internal object */
type ipc_voucher_t = mach_port_t
#if KERNEL_SERVER
intran: ipc_voucher_t convert_port_to_voucher(mach_port_t)
outtran: mach_port_t convert_voucher_to_port(ipc_voucher_t)
destructor: ipc_voucher_release(ipc_voucher_t)
#endif /* KERNEL_SERVER */
;
/* IPC voucher attribute control internal object */
type ipc_voucher_attr_control_t = mach_port_t
#if KERNEL_SERVER
intran: ipc_voucher_attr_control_t convert_port_to_voucher_attr_control(mach_port_t)
outtran: mach_port_t convert_voucher_attr_control_to_port(ipc_voucher_attr_control_t)
destructor: ipc_voucher_attr_control_release(ipc_voucher_attr_control_t)
#endif /* KERNEL_SERVER */
;
type mach_voucher_attr_key_t = uint32_t;
type mach_voucher_attr_command_t = uint32_t;
type mach_voucher_attr_recipe_command_t = uint32_t;
type mach_voucher_attr_content_size_t = uint32_t;
type mach_voucher_attr_content_t = array[*:4096] of uint8_t;
type mach_voucher_attr_content_array_t = array[*:5120] of uint8_t;
type mach_voucher_attr_raw_recipe_size_t = uint32_t;
type mach_voucher_attr_raw_recipe_t = array[*:4096] of uint8_t;
type mach_voucher_attr_raw_recipe_array_t = array[*:5120] of uint8_t;
type mach_voucher_selector_t = uint32_t;
type mach_voucher_attr_value_handle_t = uint64_t;
type mach_voucher_attr_value_handle_array_t = array[*:4] of mach_voucher_attr_value_handle_t;
type mach_voucher_attr_value_reference_t = uint32_t;
/* kernel module loader */
type kmod_t = int;
type kmod_control_flavor_t = int;
type kmod_args_t = ^array[] of MACH_MSG_TYPE_BYTE
ctype: kmod_args_t;
type io_master_t = mach_port_t;
type UNDServerRef = mach_port_t;
/* These must be kept in sync with definitions in osfmk/mach/dyld_kernel.h */
type dyld_kernel_image_info_t = struct[40] of MACH_MSG_TYPE_BYTE;
type dyld_kernel_image_info_array_t = ^array[] of dyld_kernel_image_info_t;
type dyld_kernel_process_info_t = struct[64] of MACH_MSG_TYPE_BYTE;
#if KERNEL_SERVER
simport <kern/ipc_mig.h>; /* pick up kernel-specific MIG things */
simport <kern/suid_cred.h>;
simport <kern/task_ident.h>; /* for task_id_token conversions */
#endif /* KERNEL_SERVER */
import <mach/mig.h>;
import <mach/mach_types.h>;
#endif /* _MACH_MACH_TYPES_DEFS_ */
/* vim: set ft=c : */

View File

@ -0,0 +1,287 @@
/*
* Copyright (c) 2000-2018 Apple Inc. All rights reserved.
*
* @APPLE_OSREFERENCE_LICENSE_HEADER_START@
*
* This file contains Original Code and/or Modifications of Original Code
* as defined in and that are subject to the Apple Public Source License
* Version 2.0 (the 'License'). You may not use this file except in
* compliance with the License. The rights granted to you under the License
* may not be used to create, or enable the creation or redistribution of,
* unlawful or unlicensed copies of an Apple operating system, or to
* circumvent, violate, or enable the circumvention or violation of, any
* terms of an Apple operating system software license agreement.
*
* Please obtain a copy of the License at
* http://www.opensource.apple.com/apsl/ and read it before using this file.
*
* The Original Code and all software distributed under the License are
* distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
* Please see the License for the specific language governing rights and
* limitations under the License.
*
* @APPLE_OSREFERENCE_LICENSE_HEADER_END@
*/
/*
* @OSF_COPYRIGHT@
*/
/*
* Mach Operating System
* Copyright (c) 1991,1990,1989,1988 Carnegie Mellon University
* All Rights Reserved.
*
* Permission to use, copy, modify and distribute this software and its
* documentation is hereby granted, provided that both the copyright
* notice and this permission notice appear in all copies of the
* software, derivative works or modified versions, and any portions
* thereof, and that both notices appear in supporting documentation.
*
* CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
* CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR
* ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
*
* Carnegie Mellon requests users of this software to return to
*
* Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU
* School of Computer Science
* Carnegie Mellon University
* Pittsburgh PA 15213-3890
*
* any improvements or extensions that they make and grant Carnegie Mellon
* the rights to redistribute these changes.
*/
/*
*/
/*
* NOTICE: This file was modified by SPARTA, Inc. in 2005 to introduce
* support for mandatory and extensible security protections. This notice
* is included in support of clause 2.2 (b) of the Apple Public License,
* Version 2.0.
*/
/*
* File: mach/mach_types.h
* Author: Avadis Tevanian, Jr., Michael Wayne Young
* Date: 1986
*
* Mach external interface definitions.
*
*/
#ifndef _MACH_MACH_TYPES_H_
#define _MACH_MACH_TYPES_H_
#include <stdint.h>
#include <sys/cdefs.h>
#include <mach/host_info.h>
#include <mach/host_notify.h>
#include <mach/host_special_ports.h>
#include <mach/machine.h>
#include <mach/machine/vm_types.h>
#include <mach/memory_object_types.h>
#include <mach/message.h>
#include <mach/exception_types.h>
#include <mach/port.h>
#include <mach/mach_voucher_types.h>
#include <mach/processor_info.h>
#include <mach/task_info.h>
#include <mach/task_inspect.h>
#include <mach/task_policy.h>
#include <mach/task_special_ports.h>
#include <mach/thread_info.h>
#include <mach/thread_policy.h>
#include <mach/thread_special_ports.h>
#include <mach/thread_status.h>
#include <mach/time_value.h>
#include <mach/clock_types.h>
#include <mach/vm_attributes.h>
#include <mach/vm_inherit.h>
#include <mach/vm_purgable.h>
#include <mach/vm_behavior.h>
#include <mach/vm_prot.h>
#include <mach/vm_statistics.h>
#include <mach/vm_sync.h>
#include <mach/vm_types.h>
#include <mach/vm_region.h>
#include <mach/kmod.h>
#include <mach/dyld_kernel.h>
/*
* If we are not in the kernel, then these will all be represented by
* ports at user-space.
*/
typedef mach_port_t task_t;
typedef mach_port_t task_name_t;
typedef mach_port_t task_policy_set_t;
typedef mach_port_t task_policy_get_t;
typedef mach_port_t task_inspect_t;
typedef mach_port_t task_read_t;
typedef mach_port_t task_suspension_token_t;
typedef mach_port_t thread_t;
typedef mach_port_t thread_act_t;
typedef mach_port_t thread_inspect_t;
typedef mach_port_t thread_read_t;
typedef mach_port_t ipc_space_t;
typedef mach_port_t ipc_space_read_t;
typedef mach_port_t ipc_space_inspect_t;
typedef mach_port_t coalition_t;
typedef mach_port_t host_t;
typedef mach_port_t host_priv_t;
typedef mach_port_t host_security_t;
typedef mach_port_t processor_t;
typedef mach_port_t processor_set_t;
typedef mach_port_t processor_set_control_t;
typedef mach_port_t semaphore_t;
typedef mach_port_t lock_set_t;
typedef mach_port_t ledger_t;
typedef mach_port_t alarm_t;
typedef mach_port_t clock_serv_t;
typedef mach_port_t clock_ctrl_t;
typedef mach_port_t arcade_register_t;
typedef mach_port_t ipc_eventlink_t;
typedef mach_port_t eventlink_port_pair_t[2];
typedef mach_port_t suid_cred_t;
typedef mach_port_t task_id_token_t;
/*
* These aren't really unique types. They are just called
* out as unique types at one point in history. So we list
* them here for compatibility.
*/
typedef processor_set_t processor_set_name_t;
/*
* These types are just hard-coded as ports
*/
typedef mach_port_t clock_reply_t;
typedef mach_port_t bootstrap_t;
typedef mach_port_t mem_entry_name_port_t;
typedef mach_port_t exception_handler_t;
typedef exception_handler_t *exception_handler_array_t;
typedef mach_port_t vm_task_entry_t;
typedef mach_port_t io_master_t;
typedef mach_port_t UNDServerRef;
typedef mach_port_t mach_eventlink_t;
typedef ipc_info_port_t exception_handler_info_t;
/*
* Mig doesn't translate the components of an array.
* For example, Mig won't use the thread_t translations
* to translate a thread_array_t argument. So, these definitions
* are not completely accurate at the moment for other kernel
* components.
*/
typedef task_t *task_array_t;
typedef thread_t *thread_array_t;
typedef processor_set_t *processor_set_array_t;
typedef processor_set_t *processor_set_name_array_t;
typedef processor_t *processor_array_t;
typedef thread_act_t *thread_act_array_t;
typedef ledger_t *ledger_array_t;
/*
* However the real mach_types got declared, we also have to declare
* types with "port" in the name for compatability with the way OSF
* had declared the user interfaces at one point. Someday these should
* go away.
*/
typedef task_t task_port_t;
typedef task_array_t task_port_array_t;
typedef thread_t thread_port_t;
typedef thread_array_t thread_port_array_t;
typedef ipc_space_t ipc_space_port_t;
typedef host_t host_name_t;
typedef host_t host_name_port_t;
typedef processor_set_t processor_set_port_t;
typedef processor_set_t processor_set_name_port_t;
typedef processor_set_array_t processor_set_name_port_array_t;
typedef processor_set_t processor_set_control_port_t;
typedef processor_t processor_port_t;
typedef processor_array_t processor_port_array_t;
typedef thread_act_t thread_act_port_t;
typedef thread_act_array_t thread_act_port_array_t;
typedef semaphore_t semaphore_port_t;
typedef lock_set_t lock_set_port_t;
typedef ledger_t ledger_port_t;
typedef ledger_array_t ledger_port_array_t;
typedef alarm_t alarm_port_t;
typedef clock_serv_t clock_serv_port_t;
typedef clock_ctrl_t clock_ctrl_port_t;
typedef exception_handler_t exception_port_t;
typedef exception_handler_array_t exception_port_arrary_t;
typedef char vfs_path_t[4096];
typedef char nspace_path_t[1024]; /* 1024 == PATH_MAX */
typedef char suid_cred_path_t[1024];
typedef uint32_t suid_cred_uid_t;
#define TASK_NULL ((task_t) 0)
#define TASK_NAME_NULL ((task_name_t) 0)
#define TASK_INSPECT_NULL ((task_inspect_t) 0)
#define TASK_READ_NULL ((task_read_t) 0)
#define THREAD_NULL ((thread_t) 0)
#define THREAD_INSPECT_NULL ((thread_inspect_t) 0)
#define THREAD_READ_NULL ((thread_read_t) 0)
#define TID_NULL ((uint64_t) 0)
#define THR_ACT_NULL ((thread_act_t) 0)
#define IPC_SPACE_NULL ((ipc_space_t) 0)
#define IPC_SPACE_READ_NULL ((ipc_space_read_t) 0)
#define IPC_SPACE_INSPECT_NULL ((ipc_space_inspect_t) 0)
#define COALITION_NULL ((coalition_t) 0)
#define HOST_NULL ((host_t) 0)
#define HOST_PRIV_NULL ((host_priv_t) 0)
#define HOST_SECURITY_NULL ((host_security_t) 0)
#define PROCESSOR_SET_NULL ((processor_set_t) 0)
#define PROCESSOR_NULL ((processor_t) 0)
#define SEMAPHORE_NULL ((semaphore_t) 0)
#define LOCK_SET_NULL ((lock_set_t) 0)
#define LEDGER_NULL ((ledger_t) 0)
#define ALARM_NULL ((alarm_t) 0)
#define CLOCK_NULL ((clock_t) 0)
#define UND_SERVER_NULL ((UNDServerRef) 0)
#define ARCADE_REG_NULL ((arcade_register_t) 0)
#define MACH_EVENTLINK_NULL ((mach_eventlink_t) 0)
#define IPC_EVENTLINK_NULL ((ipc_eventlink_t) 0)
#define SUID_CRED_NULL ((suid_cred_t) 0)
#define TASK_ID_TOKEN_NULL ((task_id_token_t) 0)
/* capability strictly _DECREASING_.
* not ordered the other way around because we want TASK_FLAVOR_CONTROL
* to be closest to the itk_lock. see task.h.
*/
typedef unsigned int mach_task_flavor_t;
#define TASK_FLAVOR_CONTROL 0 /* a task_t */
#define TASK_FLAVOR_READ 1 /* a task_read_t */
#define TASK_FLAVOR_INSPECT 2 /* a task_inspect_t */
#define TASK_FLAVOR_NAME 3 /* a task_name_t */
/* capability strictly _DECREASING_ */
typedef unsigned int mach_thread_flavor_t;
#define THREAD_FLAVOR_CONTROL 0 /* a thread_t */
#define THREAD_FLAVOR_READ 1 /* a thread_read_t */
#define THREAD_FLAVOR_INSPECT 2 /* a thread_inspect_t */
/* DEPRECATED */
typedef natural_t ledger_item_t;
#define LEDGER_ITEM_INFINITY ((ledger_item_t) (~0))
typedef int64_t ledger_amount_t;
#define LEDGER_LIMIT_INFINITY ((ledger_amount_t)((1ULL << 63) - 1))
typedef mach_vm_offset_t *emulation_vector_t;
typedef char *user_subsystem_t;
typedef char *labelstr_t;
/*
* Backwards compatibility, for those programs written
* before mach/{std,mach}_types.{defs,h} were set up.
*/
#include <mach/std_types.h>
#endif /* _MACH_MACH_TYPES_H_ */

Some files were not shown because too many files have changed in this diff Show More