diff options
Diffstat (limited to 'include/mach')
62 files changed, 7738 insertions, 0 deletions
diff --git a/include/mach/alert.h b/include/mach/alert.h new file mode 100644 index 0000000..e8eb371 --- /dev/null +++ b/include/mach/alert.h @@ -0,0 +1,37 @@ +/* + * Copyright (c) 1993,1994 The University of Utah and + * the Computer Systems Laboratory (CSL). 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. + * + * 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. + * + * Author: Bryan Ford, University of Utah CSL + */ +/* + * File: mach/alert.h + * + * Standard alert definitions + * + */ + +#ifndef _MACH_ALERT_H_ +#define _MACH_ALERT_H_ + +#define ALERT_BITS 32 /* Minimum; more may actually be available */ + +#define ALERT_ABORT_STRONG 0x00000001 /* Request to abort _all_ operations */ +#define ALERT_ABORT_SAFE 0x00000002 /* Request to abort restartable operations */ + +#define ALERT_USER 0xffff0000 /* User-defined alert bits */ + +#endif /* _MACH_ALERT_H_ */ diff --git a/include/mach/boolean.h b/include/mach/boolean.h new file mode 100644 index 0000000..f0f36a2 --- /dev/null +++ b/include/mach/boolean.h @@ -0,0 +1,63 @@ +/* + * 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__ */ + +#endif /* _MACH_BOOLEAN_H_ */ + +/* + * Define TRUE and FALSE, only if they haven't been before, + * and not if they're explicitly refused. Note that we're + * outside the BOOLEAN_H_ conditional, to avoid ordering + * problems. + */ + +#if !defined(NOBOOL) + +#ifndef TRUE +#define TRUE ((boolean_t) 1) +#endif /* TRUE */ + +#ifndef FALSE +#define FALSE ((boolean_t) 0) +#endif /* FALSE */ + +#endif /* !defined(NOBOOL) */ diff --git a/include/mach/boot.h b/include/mach/boot.h new file mode 100644 index 0000000..7f14cc4 --- /dev/null +++ b/include/mach/boot.h @@ -0,0 +1,93 @@ +/* + * 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. + * + * Author: Bryan Ford, University of Utah CSL + */ +#ifndef _MACH_BOOT_ +#define _MACH_BOOT_ + +#include <mach/machine/boot.h> + +#ifndef __ASSEMBLER__ + +#include <mach/machine/vm_types.h> + +struct boot_image_info +{ + /* First of the chain of boot modules in the boot image. */ + struct boot_module *first_bmod; + + /* List of rendezvous points: + starts out 0; and bmods can add nodes as needed. */ + struct boot_rendezvous *first_rzv; + + /* These register the total virtual address extent of the boot image. */ + vm_offset_t start, end; + + /* Machine-dependent boot information. */ + struct machine_boot_image_info mboot; +}; + +struct boot_module +{ + int magic; + int (*init)(struct boot_image_info *bii); + vm_offset_t text; + vm_offset_t etext; + vm_offset_t data; + vm_offset_t edata; + vm_offset_t bss; + vm_offset_t ebss; +}; +#define BMOD_VALID(bmod) ((bmod)->magic == BMOD_MAGIC) +#define BMOD_NEXT(bmod) ((struct boot_module*)((bmod)->edata)) + +struct boot_rendezvous +{ + struct boot_rendezvous *next; + int code; +}; + +#endif /* !__ASSEMBLER__ */ + + +/* This is the magic value that must appear in boot_module.magic. */ +#define BMOD_MAGIC 0x424d4f44 /* 'BMOD' */ + + +/* Following are the codes for boot_rendezvous.code. */ + +/* This rendezvous is used for choosing a microkernel to start. + XX not used yet */ +#define BRZV_KERNEL 'K' + +/* Once the microkernel is fully initialized, + it starts one or more bootstrap services... */ +#define BRZV_BOOTSTRAP 'B' + +/* The bootstrap services might need other OS-dependent data, + such as initial programs to run, filesystem snapshots, etc. + These generic chunks of data are packaged up by the microkernel + and provided to the bootstrap services upon request. + XX When can they be deallocated? */ +#define BRZV_DATA 'D' + + +#endif /* _MACH_BOOT_ */ diff --git a/include/mach/default_pager.defs b/include/mach/default_pager.defs new file mode 100644 index 0000000..e2154e2 --- /dev/null +++ b/include/mach/default_pager.defs @@ -0,0 +1,65 @@ +/* + * 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. + */ + +subsystem default_pager 2275; + +#include <mach/std_types.defs> +#include <mach/mach_types.defs> +#include <mach/default_pager_types.defs> + +routine default_pager_object_create( + default_pager : mach_port_t; + out memory_object : memory_object_t = + MACH_MSG_TYPE_MAKE_SEND; + object_size : vm_size_t); + +routine default_pager_info( + default_pager : mach_port_t; + out info : default_pager_info_t); + +routine default_pager_objects( + default_pager : mach_port_t; + out objects : default_pager_object_array_t, + CountInOut, Dealloc; + out ports : mach_port_array_t = + array[] of mach_port_move_send_t, + CountInOut, Dealloc); + +routine default_pager_object_pages( + default_pager : mach_port_t; + memory_object : memory_object_name_t; + out pages : default_pager_page_array_t, + CountInOut, Dealloc); + +routine default_pager_paging_file( + default_pager : mach_port_t; + master_device_port : mach_port_t; + filename : default_pager_filename_t; + add : boolean_t); + +routine default_pager_register_fileserver( + default_pager : mach_port_t; + fileserver_port : mach_port_t); diff --git a/include/mach/default_pager_types.defs b/include/mach/default_pager_types.defs new file mode 100644 index 0000000..398c62c --- /dev/null +++ b/include/mach/default_pager_types.defs @@ -0,0 +1,53 @@ +/* + * Mach Operating System + * Copyright (c) 1992 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_DEFAULT_PAGER_TYPES_DEFS_ +#define _MACH_DEFAULT_PAGER_TYPES_DEFS_ + +#include <mach/std_types.defs> + +type default_pager_info_t = struct { + vm_size_t dpi_total_space; + vm_size_t dpi_free_space; + vm_size_t dpi_page_size; +}; + +type default_pager_object_t = struct { + vm_offset_t dpo_object; + vm_size_t dpo_size; +}; +type default_pager_object_array_t = array[] of default_pager_object_t; + +type default_pager_page_t = struct { + vm_offset_t dpp_offset; +}; +type default_pager_page_array_t = array[] of default_pager_page_t; + +type default_pager_filename_t = (MACH_MSG_TYPE_STRING_C, 8*256); + +import <mach/default_pager_types.h>; + +#endif /* _MACH_DEFAULT_PAGER_TYPES_DEFS_ */ diff --git a/include/mach/default_pager_types.h b/include/mach/default_pager_types.h new file mode 100644 index 0000000..2cf7da2 --- /dev/null +++ b/include/mach/default_pager_types.h @@ -0,0 +1,59 @@ +/* + * Mach Operating System + * Copyright (c) 1992 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_DEFAULT_PAGER_TYPES_H_ +#define _MACH_DEFAULT_PAGER_TYPES_H_ + +/* + * Remember to update the mig type definitions + * in default_pager_types.defs when adding/removing fields. + */ + +typedef struct default_pager_info { + vm_size_t dpi_total_space; /* size of backing store */ + vm_size_t dpi_free_space; /* how much of it is unused */ + vm_size_t dpi_page_size; /* the pager's vm page size */ +} default_pager_info_t; + + +typedef struct default_pager_object { + vm_offset_t dpo_object; /* object managed by the pager */ + vm_size_t dpo_size; /* backing store used for the object */ +} default_pager_object_t; + +typedef default_pager_object_t *default_pager_object_array_t; + + +typedef struct default_pager_page { + vm_offset_t dpp_offset; /* offset of the page in its object */ +} default_pager_page_t; + +typedef default_pager_page_t *default_pager_page_array_t; + +typedef char default_pager_filename_t[256]; +typedef const char *const_default_pager_filename_t; + +#endif /* _MACH_DEFAULT_PAGER_TYPES_H_ */ diff --git a/include/mach/error.h b/include/mach/error.h new file mode 100644 index 0000000..035dcf8 --- /dev/null +++ b/include/mach/error.h @@ -0,0 +1,93 @@ +/* + * 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_system(x) (((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) + + +/* Mach 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_bootstrap err_system(0x5) /* bootstrap errors */ +#define err_hurd err_system(0x10) /* GNU Hurd server errors */ +#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 + + +/* special old "subsystems" that don't really follow the above rules */ +#define err_mig -300 +#define err_exec 6000 + +/* unix errors get lumped into one subsystem */ +#define err_unix (err_kern|err_sub(3)) +#define unix_err(errno) (err_kern|err_sub(3)|errno) + +/* MS-DOS extended error codes */ +#define err_dos (err_kern|err_sub(0xd05)) + +/* Flux OS error systems */ +#define err_fluke err_system(0x20) /* Fluke API */ + +#ifndef __ASSEMBLER__ +typedef kern_return_t mach_error_t; +#endif /* __ASSEMBLER__ */ + +#endif /* _MACH_ERROR_H_ */ diff --git a/include/mach/exc.defs b/include/mach/exc.defs new file mode 100644 index 0000000..28638e2 --- /dev/null +++ b/include/mach/exc.defs @@ -0,0 +1,47 @@ +/* + * Mach Operating System + * Copyright (c) 1993,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 /* KERNEL_USER */ + exc 2400; + +#include <mach/std_types.defs> + +ServerPrefix catch_; + +routine exception_raise( + exception_port : mach_port_t; + thread : mach_port_t; + task : mach_port_t; + exception : integer_t; + code : integer_t; + subcode : rpc_long_integer_t); diff --git a/include/mach/exception.h b/include/mach/exception.h new file mode 100644 index 0000000..c44fd53 --- /dev/null +++ b/include/mach/exception.h @@ -0,0 +1,58 @@ +/* + * 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/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. */ + +#endif /* _MACH_EXCEPTION_H_ */ diff --git a/include/mach/exec/a.out.h b/include/mach/exec/a.out.h new file mode 100644 index 0000000..c6dcaff --- /dev/null +++ b/include/mach/exec/a.out.h @@ -0,0 +1,68 @@ +/* + * 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. + * + * Author: Bryan Ford, University of Utah CSL + */ +#ifndef _MACH_A_OUT_ +#define _MACH_A_OUT_ + +struct exec +{ + unsigned long a_magic; /* magic number */ + unsigned long a_text; /* size of text segment */ + unsigned long a_data; /* size of initialized data */ + unsigned long a_bss; /* size of uninitialized data */ + unsigned long a_syms; /* size of symbol table */ + unsigned long a_entry; /* entry point */ + unsigned long a_trsize; /* size of text relocation */ + unsigned long a_drsize; /* size of data relocation */ +}; + +struct nlist { + long n_strx; + unsigned char n_type; + char n_other; + short n_desc; + unsigned long n_value; +}; + +#define OMAGIC 0407 +#define NMAGIC 0410 +#define ZMAGIC 0413 +#define QMAGIC 0314 + +#define N_GETMAGIC(ex) \ + ( (ex).a_magic & 0xffff ) +#define N_GETMAGIC_NET(ex) \ + (ntohl((ex).a_magic) & 0xffff) + +/* Valid magic number check. */ +#define N_BADMAG(ex) \ + (N_GETMAGIC(ex) != OMAGIC && N_GETMAGIC(ex) != NMAGIC && \ + N_GETMAGIC(ex) != ZMAGIC && N_GETMAGIC(ex) != QMAGIC && \ + N_GETMAGIC_NET(ex) != OMAGIC && N_GETMAGIC_NET(ex) != NMAGIC && \ + N_GETMAGIC_NET(ex) != ZMAGIC && N_GETMAGIC_NET(ex) != QMAGIC) + +/* We don't provide any N_???OFF macros here + because they vary too much between the different a.out variants; + it's practically impossible to create one set of macros + that works for UX, FreeBSD, NetBSD, Linux, etc. */ + +#endif /* _MACH_A_OUT_ */ diff --git a/include/mach/exec/elf.h b/include/mach/exec/elf.h new file mode 100644 index 0000000..409947c --- /dev/null +++ b/include/mach/exec/elf.h @@ -0,0 +1,364 @@ +/* + * Copyright (c) 1995, 1994, 1993, 1992, 1991, 1990 + * Open Software Foundation, Inc. + * + * Permission to use, copy, modify, and distribute this software and + * its documentation for any purpose and without fee is hereby granted, + * provided that the above copyright notice appears in all copies and + * that both the copyright notice and this permission notice appear in + * supporting documentation, and that the name of ("OSF") or Open Software + * Foundation not be used in advertising or publicity pertaining to + * distribution of the software without specific, written prior permission. + * + * OSF DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE + * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL OSF BE LIABLE FOR ANY + * SPECIAL, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN + * ACTION OF CONTRACT, NEGLIGENCE, OR OTHER TORTIOUS ACTION, ARISING + * OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE + * + */ +/* + * OSF Research Institute MK6.1 (unencumbered) 1/31/1995 + */ +#ifndef _MACH_EXEC_ELF_H_ +#define _MACH_EXEC_ELF_H_ + +#include <mach/machine/exec/elf.h> + +/* ELF Header - figure 4-3, page 4-4 */ + +#define EI_NIDENT 16 + +typedef struct { + unsigned char e_ident[EI_NIDENT]; + Elf32_Half e_type; + Elf32_Half e_machine; + Elf32_Word e_version; + Elf32_Addr e_entry; + Elf32_Off e_phoff; + Elf32_Off e_shoff; + Elf32_Word e_flags; + Elf32_Half e_ehsize; + Elf32_Half e_phentsize; + Elf32_Half e_phnum; + Elf32_Half e_shentsize; + Elf32_Half e_shnum; + Elf32_Half e_shstrndx; +} Elf32_Ehdr; + +typedef struct { + unsigned char e_ident[EI_NIDENT]; /* Id bytes */ + Elf64_Half e_type; /* file type */ + Elf64_Half e_machine; /* machine type */ + Elf64_Word e_version; /* version number */ + Elf64_Addr e_entry; /* entry point */ + Elf64_Off e_phoff; /* Program hdr offset */ + Elf64_Off e_shoff; /* Section hdr offset */ + Elf64_Word e_flags; /* Processor flags */ + Elf64_Half e_ehsize; /* sizeof ehdr */ + Elf64_Half e_phentsize; /* Program header entry size */ + Elf64_Half e_phnum; /* Number of program headers */ + Elf64_Half e_shentsize; /* Section header entry size */ + Elf64_Half e_shnum; /* Number of section headers */ + Elf64_Half e_shstrndx; /* String table index */ +} Elf64_Ehdr; + +/* e_ident[] identification indexes - figure 4-4, page 4-7 */ + +#define EI_MAG0 0 +#define EI_MAG1 1 +#define EI_MAG2 2 +#define EI_MAG3 3 +#define EI_CLASS 4 +#define EI_DATA 5 +#define EI_VERSION 6 +#define EI_PAD 7 + +/* magic number - pg 4-8 */ + +#define ELFMAG0 0x7f +#define ELFMAG1 'E' +#define ELFMAG2 'L' +#define ELFMAG3 'F' + +/* file class or capacity - page 4-8 */ + +#define ELFCLASSNONE 0 +#define ELFCLASS32 1 +#define ELFCLASS64 2 + +/* date encoding - page 4-9 */ + +#define ELFDATANONE 0 +#define ELFDATA2LSB 1 +#define ELFDATA2MSB 2 + +/* object file types - page 4-5 */ + +#define ET_NONE 0 +#define ET_REL 1 +#define ET_EXEC 2 +#define ET_DYN 3 +#define ET_CORE 4 + +#define ET_LOPROC 0xff00 +#define ET_HIPROC 0xffff + +/* architecture - page 4-5 */ + +#define EM_NONE 0 +#define EM_M32 1 +#define EM_SPARC 2 +#define EM_386 3 +#define EM_68K 4 +#define EM_88K 5 +#define EM_860 7 +#define EM_MIPS 8 +#define EM_MIPS_RS4_BE 10 +#define EM_SPARC64 11 +#define EM_PARISC 15 +#define EM_PPC 20 +#define EM_X86_64 62 + +/* version - page 4-6 */ + +#define EV_NONE 0 +#define EV_CURRENT 1 + +/* special section indexes - page 4-11, figure 4-7 */ + +#define SHN_UNDEF 0 +#define SHN_LORESERVE 0xff00 +#define SHN_LOPROC 0xff00 +#define SHN_HIPROC 0xff1f +#define SHN_ABS 0xfff1 +#define SHN_COMMON 0xfff2 +#define SHN_HIRESERVE 0xffff + +/* section header - page 4-13, figure 4-8 */ + +typedef struct { + Elf32_Word sh_name; + Elf32_Word sh_type; + Elf32_Word sh_flags; + Elf32_Addr sh_addr; + Elf32_Off sh_offset; + Elf32_Word sh_size; + Elf32_Word sh_link; + Elf32_Word sh_info; + Elf32_Word sh_addralign; + Elf32_Word sh_entsize; +} Elf32_Shdr; + +typedef struct elf64_shdr { + Elf64_Word sh_name; + Elf64_Word sh_type; + Elf64_Xword sh_flags; + Elf64_Addr sh_addr; + Elf64_Off sh_offset; + Elf64_Xword sh_size; + Elf64_Word sh_link; + Elf64_Word sh_info; + Elf64_Xword sh_addralign; + Elf64_Xword sh_entsize; +} Elf64_Shdr; + +/* section types - page 4-15, figure 4-9 */ + +#define SHT_NULL 0 +#define SHT_PROGBITS 1 +#define SHT_SYMTAB 2 +#define SHT_STRTAB 3 +#define SHT_RELA 4 +#define SHT_HASH 5 +#define SHT_DYNAMIC 6 +#define SHT_NOTE 7 +#define SHT_NOBITS 8 +#define SHT_REL 9 +#define SHT_SHLIB 10 +#define SHT_DYNSYM 11 + +#define SHT_LOPROC 0x70000000 +#define SHT_HIPROC 0x7fffffff +#define SHT_LOUSER 0x80000000 +#define SHT_HIUSER 0xffffffff + +/* section attribute flags - page 4-18, figure 4-11 */ + +#define SHF_WRITE 0x1 +#define SHF_ALLOC 0x2 +#define SHF_EXECINSTR 0x4 +#define SHF_MASKPROC 0xf0000000 + +/* symbol table - page 4-25, figure 4-15 */ +typedef struct +{ + Elf32_Word st_name; + Elf32_Addr st_value; + Elf32_Word st_size; + unsigned char st_info; + unsigned char st_other; + Elf32_Half st_shndx; +} Elf32_Sym; + +typedef struct elf64_sym { + Elf64_Word st_name; + unsigned char st_info; + unsigned char st_other; + Elf64_Half st_shndx; + Elf64_Addr st_value; + Elf64_Xword st_size; +} Elf64_Sym; + +#ifdef __x86_64__ +#define Elf_Sym Elf64_Sym +#define Elf_Shdr Elf64_Shdr +#else +#define Elf_Sym Elf32_Sym +#define Elf_Shdr Elf32_Shdr +#endif + +/* symbol type and binding attributes - page 4-26 */ + +#define ELF_ST_BIND(i) ((i) >> 4) +#define ELF_ST_TYPE(i) ((i) & 0xf) +#define ELF_ST_INFO(b,t) (((b)<<4)+((t)&0xf)) + +/* symbol binding - page 4-26, figure 4-16 */ + +#define STB_LOCAL 0 +#define STB_GLOBAL 1 +#define STB_WEAK 2 +#define STB_LOPROC 13 +#define STB_HIPROC 15 + +/* symbol types - page 4-28, figure 4-17 */ + +#define STT_NOTYPE 0 +#define STT_OBJECT 1 +#define STT_FUNC 2 +#define STT_SECTION 3 +#define STT_FILE 4 +#define STT_LOPROC 13 +#define STT_HIPROC 15 + + +/* relocation entries - page 4-31, figure 4-19 */ + +typedef struct +{ + Elf32_Addr r_offset; + Elf32_Word r_info; +} Elf32_Rel; + +typedef struct +{ + Elf32_Addr r_offset; + Elf32_Word r_info; + Elf32_Sword r_addend; +} Elf32_Rela; + +/* Macros to split/combine relocation type and symbol page 4-32 */ + +#define ELF32_R_SYM(__i) ((__i)>>8) +#define ELF32_R_TYPE(__i) ((unsigned char) (__i)) +#define ELF32_R_INFO(__s, __t) (((__s)<<8) + (unsigned char) (__t)) + + +/* program header - page 5-2, figure 5-1 */ + +typedef struct { + Elf32_Word p_type; + Elf32_Off p_offset; + Elf32_Addr p_vaddr; + Elf32_Addr p_paddr; + Elf32_Word p_filesz; + Elf32_Word p_memsz; + Elf32_Word p_flags; + Elf32_Word p_align; +} Elf32_Phdr; + +typedef struct { + Elf64_Word p_type; /* entry type */ + Elf64_Word p_flags; /* flags */ + Elf64_Off p_offset; /* offset */ + Elf64_Addr p_vaddr; /* virtual address */ + Elf64_Addr p_paddr; /* physical address */ + Elf64_Xword p_filesz; /* file size */ + Elf64_Xword p_memsz; /* memory size */ + Elf64_Xword p_align; /* memory & file alignment */ +} Elf64_Phdr; + +/* segment types - page 5-3, figure 5-2 */ + +#define PT_NULL 0 +#define PT_LOAD 1 +#define PT_DYNAMIC 2 +#define PT_INTERP 3 +#define PT_NOTE 4 +#define PT_SHLIB 5 +#define PT_PHDR 6 + +#define PT_LOPROC 0x70000000 +#define PT_HIPROC 0x7fffffff + +/* segment permissions - page 5-6 */ + +#define PF_X 0x1 +#define PF_W 0x2 +#define PF_R 0x4 +#define PF_MASKPROC 0xf0000000 + + +/* dynamic structure - page 5-15, figure 5-9 */ + +typedef struct { + Elf32_Sword d_tag; + union { + Elf32_Word d_val; + Elf32_Addr d_ptr; + } d_un; +} Elf32_Dyn; + +/* Dynamic array tags - page 5-16, figure 5-10. */ + +#define DT_NULL 0 +#define DT_NEEDED 1 +#define DT_PLTRELSZ 2 +#define DT_PLTGOT 3 +#define DT_HASH 4 +#define DT_STRTAB 5 +#define DT_SYMTAB 6 +#define DT_RELA 7 +#define DT_RELASZ 8 +#define DT_RELAENT 9 +#define DT_STRSZ 10 +#define DT_SYMENT 11 +#define DT_INIT 12 +#define DT_FINI 13 +#define DT_SONAME 14 +#define DT_RPATH 15 +#define DT_SYMBOLIC 16 +#define DT_REL 17 +#define DT_RELSZ 18 +#define DT_RELENT 19 +#define DT_PLTREL 20 +#define DT_DEBUG 21 +#define DT_TEXTREL 22 +#define DT_JMPREL 23 + +#if defined(__x86_64__) && ! defined(USER32) +typedef Elf64_Ehdr Elf_Ehdr; +typedef Elf64_Phdr Elf_Phdr; +#else +typedef Elf32_Ehdr Elf_Ehdr; +typedef Elf32_Phdr Elf_Phdr; +#endif + +/* + * Bootstrap doesn't need machine dependent extensions. + */ + +#endif /* _MACH_EXEC_ELF_H_ */ diff --git a/include/mach/exec/exec.h b/include/mach/exec/exec.h new file mode 100644 index 0000000..94b234b --- /dev/null +++ b/include/mach/exec/exec.h @@ -0,0 +1,130 @@ +/* + * 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 + * 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. + */ + +#ifndef _MACH_EXEC_H_ +#define _MACH_EXEC_H_ + +#include <mach/machine/vm_types.h> +#include <mach/vm_prot.h> + +/* XXX */ +typedef enum +{ + EXEC_ELF = 1, + EXEC_AOUT = 2, +} exec_format_t; + +typedef struct exec_info +{ + /* Format of executable loaded - see above. */ + exec_format_t format; + + /* Program entrypoint. */ + vm_offset_t entry; + + /* Initial data pointer - only some architectures use this. */ + vm_offset_t init_dp; + + /* (ELF) Address of interpreter string for loading shared libraries, null if none. */ + vm_offset_t interp; + +} exec_info_t; + +typedef int exec_sectype_t; +#define EXEC_SECTYPE_READ VM_PROT_READ +#define EXEC_SECTYPE_WRITE VM_PROT_WRITE +#define EXEC_SECTYPE_EXECUTE VM_PROT_EXECUTE +#define EXEC_SECTYPE_PROT_MASK VM_PROT_ALL +#define EXEC_SECTYPE_ALLOC ((exec_sectype_t)0x000100) +#define EXEC_SECTYPE_LOAD ((exec_sectype_t)0x000200) +#define EXEC_SECTYPE_DEBUG ((exec_sectype_t)0x010000) +#define EXEC_SECTYPE_AOUT_SYMTAB ((exec_sectype_t)0x020000) +#define EXEC_SECTYPE_AOUT_STRTAB ((exec_sectype_t)0x040000) + +typedef int exec_read_func_t(void *handle, vm_offset_t file_ofs, + void *buf, vm_size_t size, + vm_size_t *out_actual); + +typedef int exec_read_exec_func_t(void *handle, + vm_offset_t file_ofs, vm_size_t file_size, + vm_offset_t mem_addr, vm_size_t mem_size, + exec_sectype_t section_type); + +/* + * Routines exported from libmach_exec.a + */ + +/* Generic function to interpret an executable "file" + and "load" it into "memory". + Doesn't really know about files, loading, or memory; + all file I/O and destination memory accesses + go through provided functions. + Thus, this is a very generic loading mechanism. + + The read() function is used to read metadata from the file + into the local address space. + + The read_exec() function is used to load the actual sections. + It is used for all kinds of sections - code, data, bss, debugging data. + The 'section_type' parameter specifies what type of section is being loaded. + + For code, data, and bss, the EXEC_SECTYPE_ALLOC flag will be set. + For code and data (i.e. stuff that's actually loaded from the file), + EXEC_SECTYPE_LOAD will also be set. + The EXEC_SECTYPE_PROT_MASK contains the intended access permissions + for the section. + 'file_size' may be less than 'mem_size'; + the remaining data must be zero-filled. + 'mem_size' is always greater than zero, but 'file_size' may be zero + (e.g. in the case of a bss section). + No two read_exec() calls for one executable + will load data into the same virtual memory page, + although they may load from arbitrary (possibly overlapping) file positions. + + For sections that aren't normally loaded into the process image + (e.g. debug sections), EXEC_SECTYPE_ALLOC isn't set, + but some other appropriate flag is set to indicate the type of section. + + The 'handle' is an opaque pointer which is simply passed on + to the read() and read_exec() functions. + + On return, the specified info structure is filled in + with information about the loaded executable. +*/ +int exec_load(exec_read_func_t *read, exec_read_exec_func_t *read_exec, + void *handle, exec_info_t *out_info); + +/* + * Error codes + */ + +#define EX_NOT_EXECUTABLE 6000 /* not a recognized executable format */ +#define EX_WRONG_ARCH 6001 /* valid executable, but wrong arch. */ +#define EX_CORRUPT 6002 /* recognized executable, but mangled */ +#define EX_BAD_LAYOUT 6003 /* something wrong with the memory or file image layout */ + + +#endif /* _MACH_EXEC_H_ */ diff --git a/include/mach/experimental.defs b/include/mach/experimental.defs new file mode 100644 index 0000000..ddcbea5 --- /dev/null +++ b/include/mach/experimental.defs @@ -0,0 +1,15 @@ +subsystem +#if KERNEL_USER + KernelUser +#endif /* KERNEL_USER */ +#if KERNEL_SERVER + KernelServer +#endif /* KERNEL_SERVER */ + experimental 424242; + +#include <mach/std_types.defs> +#include <mach/mach_types.defs> + +serverprefix experimental_; + +/* This is free for experimenting RPCs, with no backward compatibility guarantees. */ diff --git a/include/mach/gnumach.defs b/include/mach/gnumach.defs new file mode 100644 index 0000000..7ecf74d --- /dev/null +++ b/include/mach/gnumach.defs @@ -0,0 +1,217 @@ +/* + * Copyright (C) 2012 Free Software Foundation + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ + +subsystem +#if KERNEL_SERVER + KernelServer +#endif /* KERNEL_SERVER */ +#if KERNEL_USER + KernelUser +#endif /* KERNEL_USER */ + gnumach 4200; + +#include <mach/std_types.defs> +#include <mach/mach_types.defs> +#include <mach_debug/mach_debug_types.defs> + +#ifdef GNUMACH_IMPORTS +GNUMACH_IMPORTS +#endif + +type vm_cache_statistics_data_t = struct[11] of integer_t; + +type vm_wire_t = int; + +/* + * Return page cache statistics for the host on which the target task + * resides. + */ +routine vm_cache_statistics( + target_task : vm_task_t; + out vm_cache_stats : vm_cache_statistics_data_t); + +/* + * Terminate a thread and release rights and memory. + * + * Intended to be used by threading libraries to provide a clean way for + * threads to terminate themselves. The resources a thread wouldn't be able + * to release without this call when terminating itself are its + * last reference to its kernel port, its reply port, and its stack. + * + * This call is semantically equivalent to : + * - mach_port_deallocate(task, thread_name); + * - if (reply_port != MACH_PORT_NULL) + * mach_port_destroy(task, reply_port); + * - if ((address != 0) || (size != 0)) + * vm_deallocate(task, address, size) + * - thread_terminate(thread) + * + * Implemented as a simple routine so a reply port isn't required. + */ +simpleroutine thread_terminate_release( + thread : thread_t; + task : task_t; + thread_name : mach_port_name_t; + reply_port : mach_port_name_t; + address : vm_address_t; + size : vm_size_t); + +/* + * Set the name of task TASK to NAME. This is a debugging aid. + * NAME will be used in error messages printed by the kernel. + */ +simpleroutine task_set_name( + task : task_t; + name : kernel_debug_name_t); + +/* + * Register a port to which a notification about newly created tasks + * are sent. + */ +routine register_new_task_notification( + host_priv : host_priv_t; + notification : mach_port_send_t); + +/* Test that the contents of ADDR are equal to the 32-bit integer VAL1. + * If they are not, return immediately, otherwise, block until a + * matching 'gsync_wake' is done on the same address. FLAGS is used + * to control how the thread waits, and may be composed of: + * - GSYNC_SHARED: The address may be shared among tasks. If this + bit is not set, the address is assumed to be task-local. + * - GSYNC_QUAD: Additionally check that the adjacent 32-bit word + following ADDR matches the value VAL2. + * - GSYNC_TIMED: The call only blocks for MSEC milliseconds. */ +routine gsync_wait( + task : task_t; + addr : vm_address_t; + val1 : unsigned; + val2 : unsigned; + msec : natural_t; + flags : int); + +/* Wake up threads waiting on the address ADDR. Much like with + * 'gsync_wait', the parameter FLAGS controls how it is done. In this + * case, it may be composed of the following: + * - GSYNC_SHARED: Same as with 'gsync_wait'. + * - GSYNC_BROADCAST: Wake up every thread waiting on the address. If + * this flag is not set, the call wakes (at most) 1 thread. + * - GSYNC_MUTATE: Before waking any potential waiting threads, set the + * contents of ADDR to VAL. + * + * This RPC is implemented as a simple routine for efficiency reasons, + * and because the return value rarely matters. */ +simpleroutine gsync_wake( + task : task_t; + addr : vm_address_t; + val : unsigned; + flags : int); + +/* Arrange for threads waiting on address SRC_ADDR to instead + * wait on address DST_ADDR. If WAKE_ONE is true, additionally + * wake one of the threads waiting on SRC_ADDR. For this function, + * the parameter flags may be a combination of: + * - GSYNC_SHARED: Just like with 'gsync_wait' and 'gsync_wake'. + * - GSYNC_BROADCAST: Move all the threads waiting on SRC_ADDR. If + this flag is not set, the call moves (at most) 1 thread. + * + * This RPC is also a simple routine, and for the same reasons as + * with 'gsync_wake'. */ +simpleroutine gsync_requeue( + task : task_t; + src_addr : vm_address_t; + dst_addr : vm_address_t; + wake_one : boolean_t; + flags : int); + +/* + * If the VM_WIRE_CURRENT flag is passed, specify that the entire + * virtual address space of the target task must not cause page faults. + * + * If the VM_WIRE_FUTURE flag is passed, automatically wire new + * mappings in the address space of the target task. + * + * If the flags are empty (VM_WIRE_NONE), unwire all mappings. + */ +routine vm_wire_all( + host : mach_port_t; + task : vm_task_t; + flags : vm_wire_t); + +routine vm_object_sync( + object : memory_object_name_t; + offset : vm_offset_t; + size : vm_size_t; + should_flush : boolean_t; + should_return : boolean_t; + should_iosync : boolean_t); + +routine vm_msync( + target_task : vm_task_t; + address : vm_address_t; + size : vm_size_t; + sync_flags : vm_sync_t); + +/* + * This routine is created for allocating DMA buffers. + * We are going to get a contiguous physical memory + * and its physical address in addition to the virtual address. + * We can specify physical memory range limits and alignment. + * NB: + * pmax is defined as the byte after the maximum address, + * eg 0x100000000 for 4GiB limit. + */ +/* XXX + * Future work: the RPC should return a special + * memory object (similar to device_map() ), which can then be mapped into + * the process address space with vm_map() like any other memory object. + */ +routine vm_allocate_contiguous( + host_priv : host_priv_t; + target_task : vm_task_t; + out vaddr : vm_address_t; + out paddr : rpc_phys_addr_t; + size : vm_size_t; + pmin : rpc_phys_addr_t; + pmax : rpc_phys_addr_t; + palign : rpc_phys_addr_t); + +/* + * Set whether TASK is an essential task, i.e. the whole system will crash + * if this task crashes. + */ +simpleroutine task_set_essential( + task : task_t; + essential : boolean_t); + +/* + * Returns physical addresses of a region of memory + */ +routine vm_pages_phys( + host_priv : host_priv_t; + target_task : vm_task_t; + vaddr : vm_address_t; + size : vm_size_t; + out pages : rpc_phys_addr_array_t); + +/* + * Set the name of thread THREAD to NAME. This is a debugging aid. + * NAME will be used in error messages printed by the kernel. + */ +simpleroutine thread_set_name( + thread : thread_t; + name : kernel_debug_name_t); diff --git a/include/mach/host_info.h b/include/mach/host_info.h new file mode 100644 index 0000000..b84376b --- /dev/null +++ b/include/mach/host_info.h @@ -0,0 +1,90 @@ +/* + * Mach Operating System + * Copyright (c) 1993,1992,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/machine.h> +#include <mach/machine/vm_types.h> + +/* + * Generic information structure to allow for expansion. + */ +typedef integer_t *host_info_t; /* varying array of integers */ + +#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]; + +/* + * Currently defined information. + */ +#define HOST_BASIC_INFO 1 /* basic info */ +#define HOST_PROCESSOR_SLOTS 2 /* processor slot numbers */ +#define HOST_SCHED_INFO 3 /* scheduling info */ +#define HOST_LOAD_INFO 4 /* avenrun/mach_factor info */ + +struct host_basic_info { + integer_t max_cpus; /* max number of cpus possible */ + integer_t avail_cpus; /* number of cpus now available */ + rpc_vm_size_t memory_size; /* size of memory in bytes */ + cpu_type_t cpu_type; /* cpu type */ + cpu_subtype_t cpu_subtype; /* cpu subtype */ +}; + +typedef struct host_basic_info host_basic_info_data_t; +typedef struct host_basic_info *host_basic_info_t; +#define HOST_BASIC_INFO_COUNT \ + (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 \ + (sizeof(host_sched_info_data_t)/sizeof(integer_t)) + +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 \ + (sizeof(host_load_info_data_t)/sizeof(integer_t)) + +#endif /* _MACH_HOST_INFO_H_ */ diff --git a/include/mach/inline.h b/include/mach/inline.h new file mode 100644 index 0000000..35f5c5d --- /dev/null +++ b/include/mach/inline.h @@ -0,0 +1,27 @@ +/* + * Copyright (c) 1994 The University of Utah and + * the Center for Software Science (CSS). 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. + * + * THE UNIVERSITY OF UTAH AND CSS ALLOW FREE USE OF THIS SOFTWARE IN ITS "AS + * IS" CONDITION. THE UNIVERSITY OF UTAH AND CSS DISCLAIM ANY LIABILITY OF + * ANY KIND FOR ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE. + * + * CSS requests users of this software to return to css-dist@cs.utah.edu any + * improvements that they make and grant CSS redistribution rights. + * + * Author: Bryan Ford, University of Utah CSS + */ +#ifndef _MACH_INLINE_H_ +#define _MACH_INLINE_H_ + +#ifndef MACH_INLINE +#define MACH_INLINE extern __inline +#endif + +#endif /* _MACH_INLINE_H_ */ diff --git a/include/mach/kern_return.h b/include/mach/kern_return.h new file mode 100644 index 0000000..15b836f --- /dev/null +++ b/include/mach/kern_return.h @@ -0,0 +1,166 @@ +/* + * Mach Operating System + * Copyright (c) 1991,1990,1989,1988,1987 Carnegie Mellon University. + * Copyright (c) 1993,1994 The University of Utah and + * the Computer Systems Laboratory (CSL). + * 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, THE UNIVERSITY OF UTAH AND CSL ALLOW FREE USE OF + * THIS SOFTWARE IN ITS "AS IS" CONDITION, AND DISCLAIM 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 + */ + +#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. + */ + +/* KERN_ALREADY_IN_SET 11 obsolete */ + +#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_WRITE_PROTECTION_FAILURE 24 + /* + * A page was marked as VM_PROT_NOTIFY and an attempt was + * made to write it + */ +#define KERN_TERMINATED 26 + /* Object has been terminated and is no longer available. + */ + +#define KERN_TIMEDOUT 27 + /* Kernel operation timed out. */ + +#define KERN_INTERRUPTED 28 + /* Kernel operation was interrupted. */ + +#endif /* _MACH_KERN_RETURN_H_ */ diff --git a/include/mach/mach.defs b/include/mach/mach.defs new file mode 100644 index 0000000..c6ad077 --- /dev/null +++ b/include/mach/mach.defs @@ -0,0 +1,724 @@ +/* + * Mach Operating System + * Copyright (c) 1991,1990,1989,1988 Carnegie Mellon University. + * Copyright (c) 1993,1994 The University of Utah and + * the Computer Systems Laboratory (CSL). + * 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, THE UNIVERSITY OF UTAH AND CSL ALLOW FREE USE OF + * THIS SOFTWARE IN ITS "AS IS" CONDITION, AND DISCLAIM 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 */ + mach 2000; + +#ifdef KERNEL_USER +userprefix r_; +#endif /* KERNEL_USER */ + +#include <mach/std_types.defs> +#include <mach/mach_types.defs> + +#ifdef MACH_IMPORTS +MACH_IMPORTS +#endif + +skip; /* old port_allocate */ +skip; /* old port_deallocate */ +skip; /* old port_enable */ +skip; /* old port_disable */ +skip; /* old port_select */ +skip; /* old port_set_backlog */ +skip; /* old port_status */ + +/* We use only a handful of RPCs as client. Skip the rest. */ +#if ! KERNEL_USER + +/* + * Create a new task with an empty set of IPC rights, + * and having an address space constructed from the + * target task (or empty, if inherit_memory is FALSE). + */ +routine task_create( + target_task : task_t; + inherit_memory : boolean_t; + out child_task : task_t); + +/* + * Destroy the target task, causing all of its threads + * to be destroyed, all of its IPC rights to be deallocated, + * and all of its address space to be deallocated. + */ +routine task_terminate( + target_task : task_t); + +/* + * Get user-level handler entry points for all + * emulated system calls. + */ +routine task_get_emulation_vector( + task : task_t; + out vector_start : int; + out emulation_vector: emulation_vector_t); + +/* + * Establish user-level handlers for the specified + * system calls. Non-emulated system calls are specified + * with emulation_vector[i] == EML_ROUTINE_NULL. + */ +routine task_set_emulation_vector( + task : task_t; + vector_start : int; + emulation_vector: emulation_vector_t); + + +/* + * Returns the set of threads belonging to the target task. + */ +routine task_threads( + target_task : task_t; + out thread_list : thread_array_t); + +/* + * Returns information about the target task. + */ +routine task_info( + target_task : task_t; + flavor : int; + out task_info_out : task_info_t, CountInOut); + + +skip; /* old task_status */ +skip; /* old task_set_notify */ +skip; /* old thread_create */ + +/* + * Destroy the target thread. + */ +routine thread_terminate( + target_thread : thread_t); + +/* + * Return the selected state information for the target + * thread. If the thread is currently executing, the results + * may be stale. [Flavor THREAD_STATE_FLAVOR_LIST provides a + * list of valid flavors for the target thread.] + */ +routine thread_get_state( + target_thread : thread_t; + flavor : int; + out old_state : thread_state_t, CountInOut); + +/* + * Set the selected state information for the target thread. + * If the thread is currently executing, the state change + * may be ill-defined. + */ +routine thread_set_state( + target_thread : thread_t; + flavor : int; + new_state : thread_state_t); + +/* + * Returns information about the target thread. + */ +routine thread_info( + target_thread : thread_t; + flavor : int; + out thread_info_out : thread_info_t, CountInOut); + +skip; /* old thread_mutate */ + +/* + * Allocate zero-filled 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. + */ +#ifdef EMULATOR +skip; /* the emulator redefines vm_allocate using vm_map */ +#else /* EMULATOR */ +routine vm_allocate( + target_task : vm_task_t; + inout address : vm_address_t; + size : vm_size_t; + anywhere : boolean_t); +#endif /* EMULATOR */ + +skip; /* old vm_allocate_with_pager */ + +/* + * Deallocate the specified range from the virtual + * address space of the target task. + */ +routine vm_deallocate( + target_task : vm_task_t; + address : vm_address_t; + size : vm_size_t); + +/* + * Set the current or maximum protection attribute + * for the specified range of the virtual address + * space of the target task. The current protection + * limits the memory access rights of threads within + * the task; the maximum protection limits the accesses + * that may be given in the current protection. + * Protections are specified as a set of {read, write, execute} + * *permissions*. + */ +routine vm_protect( + target_task : vm_task_t; + address : vm_address_t; + size : vm_size_t; + set_maximum : boolean_t; + new_protection : vm_prot_t); + +/* + * Set the inheritance attribute for the specified range + * of the virtual address space of the target task. + * The inheritance value is one of {none, copy, share}, and + * specifies how the child address space should acquire + * this memory at the time of a task_create call. + */ +routine vm_inherit( + target_task : vm_task_t; + address : vm_address_t; + size : vm_size_t; + new_inheritance : vm_inherit_t); + +/* + * Returns the contents of the specified range of the + * virtual address space of the target task. [The + * range must be aligned on a virtual page boundary, + * and must be a multiple of pages in extent. The + * protection on the specified range must permit reading.] + */ +routine vm_read( + target_task : vm_task_t; + address : vm_address_t; + size : vm_size_t; + out data : pointer_t); + +/* + * Writes the contents of the specified range of the + * virtual address space of the target task. [The + * range must be aligned on a virtual page boundary, + * and must be a multiple of pages in extent. The + * protection on the specified range must permit writing.] + */ +routine vm_write( + target_task : vm_task_t; + address : vm_address_t; + data : pointer_t); + +/* + * Copy the contents of the source range of the virtual + * address space of the target task to the destination + * range in that same address space. [Both of the + * ranges must be aligned on a virtual page boundary, + * and must be multiples of pages in extent. The + * protection on the source range must permit reading, + * and the protection on the destination range must + * permit writing.] + */ +routine vm_copy( + target_task : vm_task_t; + source_address : vm_address_t; + size : vm_size_t; + dest_address : vm_address_t); + +/* + * Returns information about the contents of the virtual + * address space of the target task at the specified + * address. The returned protection, inheritance, sharing + * and memory object values apply to the entire range described + * by the address range returned; the memory object offset + * corresponds to the beginning of the address range. + * [If the specified address is not allocated, the next + * highest address range is described. If no addresses beyond + * the one specified are allocated, the call returns KERN_NO_SPACE.] + */ +routine vm_region( + target_task : vm_task_t; + inout address : vm_address_t; + out size : vm_size_t; + out protection : vm_prot_t; + out max_protection : vm_prot_t; + out inheritance : vm_inherit_t; + out is_shared : boolean_t; + /* avoid out-translation of the argument */ + out object_name : memory_object_name_t = + MACH_MSG_TYPE_MOVE_SEND + ctype: mach_port_t; + out offset : vm_offset_t); + +/* + * Return virtual memory statistics for the host + * on which the target task resides. [Note that the + * statistics are not specific to the target task.] + */ +routine vm_statistics( + target_task : vm_task_t; + out vm_stats : vm_statistics_data_t); + +skip; /* old task_by_u*x_pid */ +skip; /* old vm_pageable */ + +/* + * Stash a handful of ports for the target task; child + * tasks inherit this stash at task_create time. + */ +routine mach_ports_register( + target_task : task_t; + init_port_set : mach_port_array_t = + ^array[] of mach_port_t); + +/* + * Retrieve the stashed ports for the target task. + */ +routine mach_ports_lookup( + target_task : task_t; + out init_port_set : mach_port_array_t = + ^array[] of mach_port_t); + +skip; /* old u*x_pid */ +skip; /* old netipc_listen */ +skip; /* old netipc_ignore */ + +#else /* ! KERNEL_USER */ + +skip; skip; skip; skip; skip; +skip; skip; skip; skip; skip; +skip; skip; skip; skip; skip; +skip; skip; skip; skip; skip; +skip; skip; skip; skip; skip; +skip; skip; skip; skip; skip; +skip; + +#endif /* ! KERNEL_USER */ + +skip; /* was: memory_object_data_provided */ + +/* + * Indicate that a range of the given temporary memory object does + * not exist, and that the backing memory object should be used + * instead (or zero-fill memory be used, if no backing object exists). + * [This call is intended for use only by the default memory manager. + * It should not be used to indicate a real error -- + * memory_object_data_error should be used for that purpose.] + */ +simpleroutine memory_object_data_unavailable( + memory_control : memory_object_control_t; + offset : vm_offset_t; + size : vm_size_t); + +/* + * Retrieves the attributes currently associated with + * a memory object. + */ +routine memory_object_get_attributes( + memory_control : memory_object_control_t; + out object_ready : boolean_t; + out may_cache : boolean_t; + out copy_strategy : memory_object_copy_strategy_t); + +#if ! KERNEL_USER + +/* + * Sets the default memory manager, the port to which + * newly-created temporary memory objects are delivered. + * [See (memory_object_default)memory_object_create.] + * The old memory manager port is returned. + */ +routine vm_set_default_memory_manager( + host_priv : host_priv_t; + inout default_manager : mach_port_make_send_t); + +#else /* ! KERNEL_USER */ + +skip; + +#endif /* ! KERNEL_USER */ + +skip; /* old pager_flush_request */ + +/* + * Control use of the data associated with the given + * memory object. For each page in the given range, + * perform the following operations, in order: + * 1) restrict access to the page (disallow + * forms specified by "prot"); + * 2) write back modifications (if "should_return" + * is RETURN_DIRTY and the page is dirty, or + * "should_return" is RETURN_ALL and the page + * is either dirty or precious); and, + * 3) flush the cached copy (if "should_flush" + * is asserted). + * The set of pages is defined by a starting offset + * ("offset") and size ("size"). Only pages with the + * same page alignment as the starting offset are + * considered. + * + * A single acknowledgement is sent (to the "reply_to" + * port) when these actions are complete. + * + * There are two versions of this routine because IPC distinguishes + * between booleans and integers (a 2-valued integer is NOT a + * boolean). The new routine is backwards compatible at the C + * language interface. + */ + +skip; /* old xxx_memory_object_lock_request */ + +simpleroutine memory_object_lock_request( + memory_control : memory_object_control_t; + offset : vm_offset_t; + size : vm_size_t; + should_return : memory_object_return_t; + should_flush : boolean_t; + lock_value : vm_prot_t; + reply_to : mach_port_t = + MACH_MSG_TYPE_MAKE_SEND_ONCE|polymorphic); + +skip; /* old xxx_task_get_emulation_vector */ +skip; /* old xxx_task_set_emulation_vector */ +skip; /* old xxx_host_info */ +skip; /* old xxx_slot_info */ +skip; /* old xxx_cpu_control */ +skip; /* old thread_statistics */ +skip; /* old task_statistics */ +skip; /* old netport_init */ +skip; /* old netport_enter */ +skip; /* old netport_remove */ +skip; /* old thread_set_priority */ + +#if ! KERNEL_USER + +/* + * Increment the suspend count for the target task. + * No threads within a task may run when the suspend + * count for that task is non-zero. + */ +routine task_suspend( + target_task : task_t); + +/* + * Decrement the suspend count for the target task, + * if the count is currently non-zero. If the resulting + * suspend count is zero, then threads within the task + * that also have non-zero suspend counts may execute. + */ +routine task_resume( + target_task : task_t); + +/* + * Returns the current value of the selected special port + * associated with the target task. + */ +routine task_get_special_port( + task : task_t; + which_port : int; + out special_port : mach_port_t); + +/* + * Set one of the special ports associated with the + * target task. + */ +routine task_set_special_port( + task : task_t; + which_port : int; + special_port : mach_port_t); + +skip; /* old xxx_task_info */ + + +/* + * Create a new thread within the target task, returning + * the port representing that new thread. The + * initial execution state of the thread is undefined. + */ +routine thread_create( + parent_task : task_t; + out child_thread : thread_t); + +/* + * Increment the suspend count for the target thread. + * Once this call has completed, the thread will not + * execute any further user or meta- instructions. + * Once suspended, a thread may not execute again until + * its suspend count is zero, and the suspend count + * for its task is also zero. + */ +routine thread_suspend( + target_thread : thread_t); + +/* + * Decrement the suspend count for the target thread, + * if that count is not already zero. + */ +routine thread_resume( + target_thread : thread_t); + +/* + * Cause any user or meta- instructions currently being + * executed by the target thread to be aborted. [Meta- + * instructions consist of the basic traps for IPC + * (e.g., msg_send, msg_receive) and self-identification + * (e.g., task_self, thread_self, thread_reply). Calls + * described by MiG interfaces are not meta-instructions + * themselves.] + */ +routine thread_abort( + target_thread : thread_t); + +skip; /* old xxx_thread_get_state */ +skip; /* old xxx_thread_set_state */ + +/* + * Returns the current value of the selected special port + * associated with the target thread. + */ +routine thread_get_special_port( + thread : thread_t; + which_port : int; + out special_port : mach_port_t); + +/* + * Set one of the special ports associated with the + * target thread. + */ +routine thread_set_special_port( + thread : thread_t; + which_port : int; + special_port : mach_port_t); + +skip; /* old xxx_thread_info */ + +/* + * Establish a user-level handler for the specified + * system call. + */ +routine task_set_emulation( + target_port : task_t; + routine_entry_pt: vm_address_t; + routine_number : int); + +/* + * Establish restart pc for interrupted atomic sequences. + * This reuses the message number for the old task_get_io_port. + * See task_info.h for description of flavors. + * + */ +routine task_ras_control( + target_task : task_t; + basepc : vm_address_t; + boundspc : vm_address_t; + flavor : int); + + + +skip; /* old host_ipc_statistics */ +skip; /* old port_names */ +skip; /* old port_type */ +skip; /* old port_rename */ +skip; /* old port_allocate */ +skip; /* old port_deallocate */ +skip; /* old port_set_backlog */ +skip; /* old port_status */ +skip; /* old port_set_allocate */ +skip; /* old port_set_deallocate */ +skip; /* old port_set_add */ +skip; /* old port_set_remove */ +skip; /* old port_set_status */ +skip; /* old port_insert_send */ +skip; /* old port_extract_send */ +skip; /* old port_insert_receive */ +skip; /* old port_extract_receive */ + +/* + * Map a user-defined memory object into the virtual address + * space of the target task. If desired (anywhere is TRUE), + * the kernel will find a suitable address range of the + * specified size; else, the specific address will be allocated. + * + * The beginning address of the range will be aligned on a virtual + * page boundary, be at or beyond the address specified, and + * meet the mask requirements (bits turned on in the mask must not + * be turned on in the result); the size of the range, in bytes, + * will be rounded up to an integral number of virtual pages. + * + * The memory in the resulting range will be associated with the + * specified memory object, with the beginning of the memory range + * referring to the specified offset into the memory object. + * + * The mapping will take the current and maximum protections and + * the inheritance attributes specified; see the vm_protect and + * vm_inherit calls for a description of these attributes. + * + * If desired (copy is TRUE), the memory range will be filled + * with a copy of the data from the memory object; this copy will + * be private to this mapping in this target task. Otherwise, + * the memory in this mapping will be shared with other mappings + * of the same memory object at the same offset (in this task or + * in other tasks). [The Mach kernel only enforces shared memory + * consistency among mappings on one host with similar page alignments. + * The user-defined memory manager for this object is responsible + * for further consistency.] + */ +#ifdef EMULATOR +routine htg_vm_map( + target_task : vm_task_t; + ureplyport reply_port : mach_port_make_send_once_t; + inout address : vm_address_t; + size : vm_size_t; + mask : vm_address_t; + anywhere : boolean_t; + memory_object : memory_object_t; + offset : vm_offset_t; + copy : boolean_t; + cur_protection : vm_prot_t; + max_protection : vm_prot_t; + inheritance : vm_inherit_t); +#else /* EMULATOR */ +routine vm_map( + target_task : vm_task_t; + inout address : vm_address_t; + size : vm_size_t; + mask : vm_address_t; + anywhere : boolean_t; + memory_object : memory_object_t; + offset : vm_offset_t; + copy : boolean_t; + cur_protection : vm_prot_t; + max_protection : vm_prot_t; + inheritance : vm_inherit_t); +#endif /* EMULATOR */ + +#else /* ! KERNEL_USER */ + +skip; skip; skip; skip; skip; +skip; skip; skip; skip; skip; +skip; skip; skip; skip; skip; +skip; skip; skip; skip; skip; +skip; skip; skip; skip; skip; +skip; skip; skip; skip; skip; +skip; skip; skip; skip; + +#endif /* ! KERNEL_USER */ + +/* + * Indicate that a range of the specified memory object cannot + * be provided at this time. [Threads waiting for memory pages + * specified by this call will experience a memory exception. + * Only threads waiting at the time of the call are affected.] + */ +simpleroutine memory_object_data_error( + memory_control : memory_object_control_t; + offset : vm_offset_t; + size : vm_size_t; + error_value : kern_return_t); + +skip; /* was: memory_object_set_attributes */ + +/* + */ +simpleroutine memory_object_destroy( + memory_control : memory_object_control_t; + reason : kern_return_t); + +/* + * Provide the data contents of a range of the given memory + * object, with the access restriction specified, optional + * precious attribute, and reply message. [Only + * whole virtual pages of data can be accepted; partial pages + * will be discarded. Data should be provided on request, but + * may be provided in advance as desired. When data already + * held by this kernel is provided again, the new data is ignored. + * The access restriction is the subset of {read, write, execute} + * which are prohibited. The kernel may not provide any data (or + * protection) consistency among pages with different virtual page + * alignments within the same object. The precious value controls + * how the kernel treats the data. If it is FALSE, the kernel treats + * its copy as a temporary and may throw it away if it hasn't been + * changed. If the precious value is TRUE, the kernel treats its + * copy as a data repository and promises to return it to the manager; + * the manager may tell the kernel to throw it away instead by flushing + * and not cleaning the data -- see memory_object_lock_request. The + * reply_to port is for a compeletion message; it will be + * memory_object_supply_completed.] + */ + +simpleroutine memory_object_data_supply( + memory_control : memory_object_control_t; + offset : vm_offset_t; + data : pointer_t, Dealloc[]; + lock_value : vm_prot_t; + precious : boolean_t; + reply_to : mach_port_t = + MACH_MSG_TYPE_MAKE_SEND_ONCE|polymorphic); + +simpleroutine memory_object_ready( + memory_control : memory_object_control_t; + may_cache : boolean_t; + copy_strategy : memory_object_copy_strategy_t); + +simpleroutine memory_object_change_attributes( + memory_control : memory_object_control_t; + may_cache : boolean_t; + copy_strategy : memory_object_copy_strategy_t; + reply_to : mach_port_t = + MACH_MSG_TYPE_MAKE_SEND_ONCE|polymorphic); + +#if ! KERNEL_USER + +skip; /* old host_callout_statistics_reset */ +skip; /* old port_set_select */ +skip; /* old port_set_backup */ + +/* + * Set/Get special properties of memory associated + * to some virtual address range, such as cachability, + * migrability, replicability. Machine-dependent. + */ +routine vm_machine_attribute( + target_task : vm_task_t; + address : vm_address_t; + size : vm_size_t; + attribute : vm_machine_attribute_t; + inout value : vm_machine_attribute_val_t); + +skip; /* old host_fpa_counters_reset */ + +#endif /* ! KERNEL_USER */ + +/* + * There is no more room in this interface for additional calls. + */ diff --git a/include/mach/mach4.defs b/include/mach/mach4.defs new file mode 100644 index 0000000..d63d6f7 --- /dev/null +++ b/include/mach/mach4.defs @@ -0,0 +1,131 @@ +/* + * Mach Operating System + * Copyright (c) 1994,1993,1992 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 Mach4 kernel interface. + */ + +subsystem +#if KERNEL_SERVER + KernelServer +#endif /* KERNEL_SERVER */ +#if KERNEL_USER + KernelUser +#endif /* KERNEL_USER */ + mach4 4000; + +#include <mach/std_types.defs> +#include <mach/mach_types.defs> + + +#ifdef MACH_PCSAMPLE +type sampled_pc_flavor_t = unsigned; + +type sampled_pc_t = struct { + rpc_vm_offset_t id; + rpc_vm_offset_t pc; + sampled_pc_flavor_t sampletype; +}; + +type sampled_pc_array_t = array[*:512] of sampled_pc_t; +type sampled_pc_seqno_t = unsigned; + +routine task_enable_pc_sampling( + host : task_t; + out tick : int; /* sample frequency in usecs */ + flavor : sampled_pc_flavor_t ); + +routine task_disable_pc_sampling( + host : task_t; + out samplecnt : int); + +routine task_get_sampled_pcs( + host : task_t; + inout seqno : sampled_pc_seqno_t; + out sampled_pcs : sampled_pc_array_t); + +routine thread_enable_pc_sampling( + host : thread_t; + out tick : int; /* sample frequency in usecs*/ + flavor : sampled_pc_flavor_t ); + +routine thread_disable_pc_sampling( + host : thread_t; + out samplecnt : int); + +routine thread_get_sampled_pcs( + host : thread_t; + inout seqno : sampled_pc_seqno_t; + out sampled_pcs : sampled_pc_array_t); + + +skip /* pc_sampling reserved 1*/; +skip /* pc_sampling reserved 2*/; +skip /* pc_sampling reserved 3*/; +skip /* pc_sampling reserved 4*/; + +#else + +skip; /* task_enable_pc_sampling */ +skip; /* task_disable_pc_sampling */ +skip; /* task_get_sampled_pcs */ +skip; /* thread_enable_pc_sampling */ +skip; /* thread_disable_pc_sampling */ +skip; /* thread_get_sampled_pcs */ + +skip /* pc_sampling reserved 1*/; +skip /* pc_sampling reserved 2*/; +skip /* pc_sampling reserved 3*/; +skip /* pc_sampling reserved 4*/; + +#endif + + +/* Create a new proxy memory object from [START;START+LEN) in the + given memory object OBJECT at OFFSET in the new object with the maximum + protection MAX_PROTECTION and return it in *PORT. */ +type vm_offset_array_t = array[*:1024] of vm_offset_t; +type vm_size_array_t = array[*:1024] of vm_size_t; +type rpc_vm_size_array_t = array[*:1024] of rpc_vm_size_t; +type rpc_vm_offset_array_t = array[*:1024] of rpc_vm_offset_t; +routine memory_object_create_proxy( + task : ipc_space_t; + max_protection : vm_prot_t; + object : memory_object_array_t = + array[*:1024] of mach_port_send_t; + offset : rpc_vm_offset_array_t; + start : rpc_vm_offset_array_t; + len : rpc_vm_size_array_t; + out proxy : mach_port_t); + +/* Gets a proxy to the region that ADDRESS belongs to, starting at the region + start, with MAX_PROTECTION and LEN limited by the region ones, and returns + it in *PORT. */ +routine vm_region_create_proxy( + task : task_t; + address : vm_address_t; + max_protection : vm_prot_t; + len : vm_size_t; + out proxy : mach_port_t); diff --git a/include/mach/mach_host.defs b/include/mach/mach_host.defs new file mode 100644 index 0000000..a8c40af --- /dev/null +++ b/include/mach/mach_host.defs @@ -0,0 +1,388 @@ +/* + * Mach Operating System + * Copyright (c) 1991,1990,1989 Carnegie Mellon University. + * Copyright (c) 1993,1994 The University of Utah and + * the Computer Systems Laboratory (CSL). + * 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, THE UNIVERSITY OF UTAH AND CSL ALLOW FREE USE OF + * THIS SOFTWARE IN ITS "AS IS" CONDITION, AND DISCLAIM 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 + mach_host 2600; + +/* + * Basic types + */ + +#include <mach/std_types.defs> +#include <mach/mach_types.defs> + +#ifdef MACH_HOST_IMPORTS +MACH_HOST_IMPORTS +#endif + +/* + * Get list of processors on this host. + */ + +routine host_processors( + host_priv : host_priv_t; + out processor_list : processor_array_t); + +skip; /* old yyy_host_info */ +skip; /* old yyy_processor_info */ + +/* + * Start processor. + */ + +routine processor_start( + processor : processor_t); + +/* + * Exit processor -- may not be restartable. + */ + +routine processor_exit( + processor : processor_t); + +skip; /* old yyy_processor_control */ + +/* + * Get default processor set for host. + */ +routine processor_set_default( + host : host_t; + out default_set : processor_set_name_t); + +skip; /* old xxx_processor_set_default_priv */ + +/* + * 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); + +/* + * Destroy processor set. + */ +routine processor_set_destroy( + set : processor_set_t); + +skip; /* old yyy_processor_set_info */ + +/* + * Assign processor to processor set. + */ +routine processor_assign( + processor : processor_t; + new_set : processor_set_t; + wait : boolean_t); + +/* + * Get current assignment for processor. + */ + +routine processor_get_assignment( + processor : processor_t; + out assigned_set : processor_set_name_t); + +/* + * Assign thread to processor set. + */ +routine thread_assign( + thread : thread_t; + new_set : processor_set_t); + +/* + * Assign thread to default set. + */ +routine thread_assign_default( + thread : thread_t); + +/* + * Get current assignment for thread. + */ +routine thread_get_assignment( + thread : thread_t; + out assigned_set : processor_set_name_t); + +/* + * Assign task to processor set. + */ +routine task_assign( + task : task_t; + new_set : processor_set_t; + assign_threads : boolean_t); +/* + * Assign task to default set. + */ +routine task_assign_default( + task : task_t; + assign_threads : boolean_t); + +/* + * Get current assignment for task. + */ +routine task_get_assignment( + task : task_t; + out assigned_set : processor_set_name_t); + +#if defined(__x86_64__) && !defined(USER32) +skip; +#else +/* + * Get string describing current kernel version. + * Deprecated, use host_get_kernel_version. + */ +routine host_kernel_version( + host : host_t; + out kernel_version : kernel_version_t); +#endif + +/* + * Set priority for thread. + */ +routine thread_priority( + thread : thread_t; + priority : int; + set_max : boolean_t); + +/* + * Set max priority for thread. + */ +routine thread_max_priority( + thread : thread_t; + processor_set : processor_set_t; + max_priority : int); + +/* + * Set task priority. + */ +routine task_priority( + task : task_t; + priority : int; + change_threads : boolean_t); + +/* + * Set max priority for processor_set. + */ +routine processor_set_max_priority( + processor_set : processor_set_t; + max_priority : int; + change_threads : boolean_t); + +/* + * Set policy for thread + */ +routine thread_policy( + thread : thread_t; + policy : int; + data : int); + +/* + * Enable policy for processor set + */ +routine processor_set_policy_enable( + processor_set : processor_set_t; + policy : int); + +/* + * Disable policy for processor set + */ +routine processor_set_policy_disable( + processor_set : processor_set_t; + policy : int; + change_threads : boolean_t); +/* + * List all tasks in processor set. + */ +routine processor_set_tasks( + processor_set : processor_set_t; + out task_list : task_array_t); + +/* + * List all threads in processor set. + */ +routine processor_set_threads( + processor_set : processor_set_t; + out thread_list : thread_array_t); + +/* + * List all processor sets on host. + */ +routine host_processor_sets( + host : host_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); + +routine thread_depress_abort( + thread : thread_t); + +/* + * Set the time on this host. + * Only available to privileged users. + */ +routine host_set_time( + host_priv : host_priv_t; + new_time : time_value_t); + +/* + * Arrange for the time on this host to be gradually changed + * by an adjustment value, and return the old value. + * Only available to privileged users. + */ +routine host_adjust_time( + host_priv : host_priv_t; + in new_adjustment : time_value_t; + out old_adjustment : time_value_t); + +/* + * Get the time on this host. + * Available to all. + */ +routine host_get_time( + host : host_t; + out current_time : time_value_t); + +/* + * Reboot this host. + * Only available to privileged users. + */ +routine host_reboot( + host_priv : host_priv_t; + options : int); + +/* + * 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 : mach_port_t; + task : vm_task_t; + address : vm_address_t; + size : vm_size_t; + 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_t; + wired : boolean_t); + +/* + * Return information about this host. + */ + +routine host_info( + host : host_t; + flavor : int; + out host_info_out : host_info_t, CountInOut); + + +/* + * Return information about this processor. + */ +routine processor_info( + processor : processor_t; + flavor : int; + out host : host_t; + out processor_info_out: processor_info_t, CountInOut); + +/* + * Get information about processor set. + */ +routine processor_set_info( + set_name : processor_set_name_t; + flavor : int; + out host : host_t; + out info_out : processor_set_info_t, CountInOut); + +/* + * Do something machine-dependent to processor. + */ +routine processor_control( + processor : processor_t; + processor_cmd : processor_info_t); + +/* host_get_boot_info */ +skip; + +/* + * Get the time on this host. + * Available to all. + */ +routine host_get_time64( + host : host_t; + out current_time : time_value64_t); + +/* + * Set the time on this host. + * Only available to privileged users. + */ +routine host_set_time64( + host : host_t; + new_time : time_value64_t); + +/* + * Arrange for the time on this host to be gradually changed + * by an adjustment value, and return the old value. + * Only available to privileged users. + */ +routine host_adjust_time64( + host_priv : host_priv_t; + in new_adjustment : time_value64_t; + out old_adjustment : time_value64_t); + +/* + * Get string describing current kernel version. + */ +routine host_get_kernel_version( + host : host_t; + out kernel_version : new_kernel_version_t); diff --git a/include/mach/mach_param.h b/include/mach/mach_param.h new file mode 100644 index 0000000..b2aca08 --- /dev/null +++ b/include/mach/mach_param.h @@ -0,0 +1,39 @@ +/* + * 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_ + +#define TASK_PORT_REGISTER_MAX 4 /* Number of "registered" ports */ + +#endif /* _MACH_MACH_PARAM_H_ */ diff --git a/include/mach/mach_port.defs b/include/mach/mach_port.defs new file mode 100644 index 0000000..3823bb1 --- /dev/null +++ b/include/mach/mach_port.defs @@ -0,0 +1,360 @@ +/* + * Mach Operating System + * Copyright (c) 1991,1990,1989 Carnegie Mellon University. + * Copyright (c) 1993,1994 The University of Utah and + * the Computer Systems Laboratory (CSL). + * 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, THE UNIVERSITY OF UTAH AND CSL ALLOW FREE USE OF + * THIS SOFTWARE IN ITS "AS IS" CONDITION, AND DISCLAIM 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 + * + * Copyright (c) 1989 Richard P. Draves, Jr. + * + * Exported kernel calls. + */ + +subsystem +#if KERNEL_SERVER + KernelServer +#endif + mach_port 3200; + +#include <mach/std_types.defs> +#include <mach/mach_types.defs> + +/* + * 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 = + ^array[] of mach_port_name_t; + out types : mach_port_type_array_t = + ^array[] of mach_port_type_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. + */ + +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); + +skip; /* old old_mach_port_get_receive_status */ + +/* + * Only valid for receive rights. + * Sets the queue-limit for the port. + * The limit must be + * 1 <= qlimit <= MACH_PORT_QLIMIT_MAX + */ + +routine mach_port_set_qlimit( + task : ipc_space_t; + name : mach_port_name_t; + qlimit : mach_port_msgcount_t); + +/* + * 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 mach_port_get_set_status( + task : ipc_space_t; + name : mach_port_name_t; + out members : mach_port_name_array_t = + ^array[] of mach_port_name_t); + +/* + * Puts the member port (the task must have receive rights) + * into the after port set. (Or removes it from any port set + * if after is MACH_PORT_NULL.) If the port is already in + * a set, does an atomic move. + */ + +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 msg_id must be one of + * MACH_NOTIFY_PORT_DESTROYED (receive rights) + * MACH_NOTIFY_DEAD_NAME (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_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. + */ + +routine mach_port_request_notification( + task : ipc_space_t; + name : mach_port_name_t; + id : mach_msg_id_t; + sync : mach_port_mscount_t; + notify : mach_port_send_once_t; + out previous : mach_port_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); + +/* + * The task must have receive rights for the named port. + * Returns a status structure (see mach/port.h). + */ + +routine mach_port_get_receive_status( + task : ipc_space_t; + name : mach_port_name_t; + out status : mach_port_status_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); + +#ifdef MIGRATING_THREADS +/* + * Only valid for receive rights. + * Set the user-mode entry info for RPCs coming through this port. + * Do this BEFORE attaching an ActPool to this port, + * unless you can be sure no RPCs will be coming through it yet. + */ + +routine mach_port_set_rpcinfo( + task : ipc_space_t; + name : mach_port_name_t; + rpc_info : thread_info_t); /* XXX */ + +/* + * Only valid for receive rights. + * Create a new activation for migrating RPC, and attach it to the port's ActPool. + * Create an ActPool for the port if it doesn't already have one. + * Supply a stack and receive memory buffer. + */ + +routine mach_port_create_act( + task : task_t; + name : mach_port_name_t; + user_stack : vm_offset_t; + user_rbuf : vm_offset_t; + user_rbuf_size : vm_size_t; + out new_act : thread_t); + +#else /* MIGRATING_THREADS */ + +skip; /* mach_port_set_rpcinfo */ +skip; /* mach_port_create_act */ + +#endif /* MIGRATING_THREADS */ + +/* + * Only valid for receive rights. + * Set the protected payload for this right to the given value. + */ + +routine mach_port_set_protected_payload( + task : ipc_space_t; + name : mach_port_name_t; + payload : rpc_uintptr_t); + +/* + * Only valid for receive rights. + * Clear the protected payload for this right. + */ + +routine mach_port_clear_protected_payload( + task : ipc_space_t; + name : mach_port_name_t); diff --git a/include/mach/mach_traps.h b/include/mach/mach_traps.h new file mode 100644 index 0000000..2a87f62 --- /dev/null +++ b/include/mach/mach_traps.h @@ -0,0 +1,43 @@ +/* + * 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. + * + * IPC traps are defined in <mach/message.h>. + * Kernel RPC functions are defined in <mach/mach_interface.h>. + */ + +#ifndef _MACH_MACH_TRAPS_H_ +#define _MACH_MACH_TRAPS_H_ + +#include <mach/port.h> + +mach_port_name_t mach_reply_port (void); +mach_port_name_t mach_thread_self (void); +mach_port_name_t mach_task_self (void); +mach_port_name_t mach_host_self (void); + +#endif /* _MACH_MACH_TRAPS_H_ */ diff --git a/include/mach/mach_types.defs b/include/mach/mach_types.defs new file mode 100644 index 0000000..7419601 --- /dev/null +++ b/include/mach/mach_types.defs @@ -0,0 +1,299 @@ +/* + * Mach Operating System + * Copyright (c) 1994-1988 Carnegie Mellon University. + * Copyright (c) 1993,1994 The University of Utah and + * the Computer Systems Laboratory (CSL). + * 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, THE UNIVERSITY OF UTAH AND CSL ALLOW FREE USE OF + * THIS SOFTWARE IN ITS "AS IS" CONDITION, AND DISCLAIM 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. + */ +/* + * Mach kernel interface type declarations + */ + +#ifndef _MACH_MACH_TYPES_DEFS_ +#define _MACH_MACH_TYPES_DEFS_ + +/* + * For KernelServer and KernelUser interfaces, Mig will + * automagically use ipc_port_t instead of mach_port_t + * on the kernel side of the interface. For example, + * convert_task_to_port really returns ipc_port_t. + * Doing this in Mig saves many explicit conditional + * cusertype/cservertype declarations. + * + * 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. + */ + +#include <mach/std_types.defs> +#if KERNEL_SERVER +#endif /* KERNEL_SERVER */ + +#ifdef USERPREFIX +userprefix USERPREFIX; +#endif + +#ifdef SERVERPREFIX +serverprefix SERVERPREFIX; +#endif + +type mach_port_status_t = struct { + mach_port_name_t mps_pset; /* containing port set */ + mach_port_seqno_t mps_seqno; /* sequence number */ + mach_port_mscount_t mps_mscount; /* make-send count */ + mach_port_msgcount_t mps_qlimit; /* queue limit */ + mach_port_msgcount_t mps_msgcount; /* number in the queue */ + mach_port_rights_t mps_sorights; /* how many send-once rights */ + boolean_t mps_srights; /* do send rights exist? */ + boolean_t mps_pdrequest; /* port-deleted requested? */ + boolean_t mps_nsrequest; /* no-senders requested? */ +}; + +type task_t = mach_port_t + ctype: 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 */ + ; + +#ifdef MIGRATING_THREADS +#if KERNEL +/* What the conventional external Mach interfaces see as a thread_t + is really an act_t within the kernel. */ +#define thread_t act_t +#define convert_port_to_thread convert_port_to_act +#define convert_thread_to_port convert_act_to_port +#define thread_deallocate act_deallocate +#endif /* KERNEL */ +#endif /* MIGRATING_THREADS */ + +type thread_t = mach_port_t + ctype: 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_state_t = array[*:1024] of natural_t; + +type task_array_t = ^array[] of task_t; +type thread_array_t = ^array[] of thread_t; + +type vm_task_t = mach_port_t + ctype: 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 ipc_space_t = mach_port_t + ctype: 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 */ + ; + +#if defined(KERNEL) && defined(USER32) +type rpc_uintptr_t = uint32_t; +type rpc_vm_size_t = uint32_t; +#else /* KERNEL and USER32 */ +type rpc_uintptr_t = uintptr_t; +type rpc_vm_size_t = uintptr_t; +#endif /* KERNEL_SERVER and USER32 */ + +type rpc_vm_offset_t = rpc_vm_size_t; + +type vm_address_t = rpc_vm_size_t +#if defined(KERNEL_SERVER) + intran: vm_address_t convert_vm_from_user(rpc_vm_address_t) + outtran: rpc_vm_address_t convert_vm_to_user(vm_address_t) +#elif defined(KERNEL_USER) + ctype: rpc_vm_address_t +#endif + ; +type vm_offset_t = rpc_vm_offset_t +#if defined(KERNEL_SERVER) + intran: vm_offset_t convert_vm_from_user(rpc_vm_offset_t) + outtran: rpc_vm_offset_t convert_vm_to_user(vm_offset_t) +#elif defined(KERNEL_USER) + ctype: rpc_vm_offset_t +#endif + ; +type vm_size_t = rpc_vm_size_t +#if defined(KERNEL_SERVER) + intran: vm_size_t convert_vm_from_user(rpc_vm_size_t) + outtran: rpc_vm_size_t convert_vm_to_user(vm_size_t) +#elif defined(KERNEL_USER) + ctype: rpc_vm_size_t +#endif +; +type vm_prot_t = int; +type vm_inherit_t = int; +type vm_statistics_data_t = struct[13] of integer_t; +type vm_machine_attribute_t = int; +type vm_machine_attribute_val_t = int; +type vm_sync_t = int; + +type thread_info_t = array[*:1024] of integer_t; + +type task_info_t = array[*:1024] of integer_t; + +type memory_object_t = mach_port_t + ctype: mach_port_t +#if KERNEL_SERVER + intran: ipc_port_t null_conversion(mach_port_t) +#else /* KERNEL_SERVER */ +#ifdef MEMORY_OBJECT_INTRAN + intran: MEMORY_OBJECT_INTRAN +#endif +#ifdef MEMORY_OBJECT_INTRAN_PAYLOAD + intranpayload: MEMORY_OBJECT_INTRAN_PAYLOAD +#endif +#ifdef MEMORY_OBJECT_OUTTRAN + outtran: MEMORY_OBJECT_OUTTRAN +#endif +#ifdef MEMORY_OBJECT_DESTRUCTOR + destructor: MEMORY_OBJECT_DESTRUCTOR +#endif +#endif /* KERNEL_SERVER */ + ; + +type memory_object_control_t = mach_port_t + ctype: mach_port_t +#if KERNEL_SERVER + intran: vm_object_t vm_object_lookup(mach_port_t) +#endif /* KERNEL_SERVER */ + ; + +type memory_object_name_t = mach_port_t + ctype: mach_port_t +#if KERNEL_SERVER + intran: vm_object_t vm_object_lookup_name(mach_port_t) + destructor: vm_object_deallocate(vm_object_t) +#endif /* KERNEL_SERVER */ + ; + +type memory_object_copy_strategy_t = int; +type memory_object_return_t = int; + +type host_t = mach_port_t + ctype: 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 + ctype: mach_port_t +#if KERNEL_SERVER + intran: host_t convert_port_to_host_priv(mach_port_t) +#endif /* KERNEL_SERVER */ + ; + +type host_info_t = array[*:1024] of integer_t; + +type processor_t = mach_port_t + ctype: 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; +type processor_info_t = array[*:1024] of integer_t; + +type processor_set_t = mach_port_t + ctype: 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 + ctype: mach_port_t +#if KERNEL_SERVER + intran: processor_set_t convert_port_to_pset_name(mach_port_t) + outtran: mach_port_t convert_pset_name_to_port(processor_set_t) + destructor: pset_deallocate(processor_set_t) +#endif /* KERNEL_SERVER */ + ; + +type processor_set_name_array_t = ^array[] of processor_set_name_t; + +type processor_set_info_t = array[*:1024] of integer_t; + +type kernel_version_t = (MACH_MSG_TYPE_STRING, 512*8); +type new_kernel_version_t = c_string[512] + ctype: kernel_version_t; + +type rpc_time_value_t = struct { + rpc_long_integer_t seconds; + integer_t microseconds; +}; +type time_value_t = rpc_time_value_t +#if defined(KERNEL_SERVER) + intran: time_value_t convert_time_value_from_user(rpc_time_value_t) + outtran: rpc_time_value_t convert_time_value_to_user(time_value_t) +#elif defined(KERNEL_USER) + ctype: rpc_time_value_t +#endif + ; + +type time_value64_t = struct { + int64_t seconds; + int64_t nanoseconds; +}; + +type emulation_vector_t = ^array[] of vm_offset_t; + +type rpc_signature_info_t = array[*:1024] of int; + +#if KERNEL_SERVER +simport <kern/ipc_kobject.h>; /* for null conversion */ +simport <kern/ipc_tt.h>; /* for task/thread conversion */ +simport <kern/ipc_host.h>; /* for host/processor/pset conversions */ +simport <kern/task.h>; /* for task_t */ +simport <kern/thread.h>; /* for thread_t */ +simport <kern/host.h>; /* for host_t */ +simport <kern/processor.h>; /* for processor_t, processor_set_t */ +simport <vm/vm_object.h>; /* for vm_object_t */ +simport <vm/vm_map.h>; /* for vm_map_t */ +simport <ipc/ipc_space.h>; /* for ipc_space_t */ +#endif /* KERNEL_SERVER */ + +import <mach/mach_types.h>; + +#endif /* _MACH_MACH_TYPES_DEFS_ */ diff --git a/include/mach/mach_types.h b/include/mach/mach_types.h new file mode 100644 index 0000000..5ecd686 --- /dev/null +++ b/include/mach/mach_types.h @@ -0,0 +1,90 @@ +/* + * Mach Operating System + * Copyright (c) 1992,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/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 <mach/host_info.h> +#include <mach/machine.h> +#include <mach/machine/vm_types.h> +#include <mach/memory_object.h> +#include <mach/pc_sample.h> +#include <mach/port.h> +#include <mach/processor_info.h> +#include <mach/task_info.h> +#include <mach/task_special_ports.h> +#include <mach/thread_info.h> +#include <mach/thread_special_ports.h> +#include <mach/thread_status.h> +#include <mach/time_value.h> +#include <mach/vm_attributes.h> +#include <mach/vm_inherit.h> +#include <mach/vm_prot.h> +#include <mach/vm_statistics.h> +#include <mach/vm_cache_statistics.h> +#include <mach/vm_wire.h> +#include <mach/vm_sync.h> + +#ifdef MACH_KERNEL + +typedef struct task *task_t; +typedef struct thread *thread_t; +typedef struct processor *processor_t; +typedef struct processor_set *processor_set_t; + +#else /* MACH_KERNEL */ +typedef mach_port_t task_t; +typedef task_t *task_array_t; +typedef task_t vm_task_t; +typedef task_t ipc_space_t; +typedef mach_port_t thread_t; +typedef thread_t *thread_array_t; +typedef mach_port_t host_t; +typedef mach_port_t host_priv_t; +typedef mach_port_t processor_t; +typedef mach_port_t *processor_array_t; +typedef mach_port_t processor_set_t; +typedef mach_port_t processor_set_name_t; +typedef mach_port_t *processor_set_array_t; +typedef mach_port_t *processor_set_name_array_t; +typedef vm_offset_t *emulation_vector_t; +#endif /* MACH_KERNEL */ + +/* + * 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_ */ diff --git a/include/mach/machine.h b/include/mach/machine.h new file mode 100644 index 0000000..9a176e8 --- /dev/null +++ b/include/mach/machine.h @@ -0,0 +1,268 @@ +/* + * 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: machine.h + * Author: Avadis Tevanian, Jr. + * Date: 1986 + * + * Machine independent machine abstraction. + */ + +#ifndef _MACH_MACHINE_H_ +#define _MACH_MACHINE_H_ + +#include <mach/machine/vm_types.h> +#include <mach/boolean.h> + +/* + * For each host, there is a maximum possible number of + * cpus that may be available in the system. This is the + * compile-time constant NCPUS, which is defined in cpus.h. + * + * In addition, there is a machine_slot specifier for each + * possible cpu in the system. + */ + +struct machine_info { + integer_t major_version; /* kernel major version id */ + integer_t minor_version; /* kernel minor version id */ + integer_t max_cpus; /* max number of cpus compiled */ + integer_t avail_cpus; /* number actually available */ + vm_size_t memory_size; /* size of memory in bytes */ +}; + +typedef struct machine_info *machine_info_t; +typedef struct machine_info machine_info_data_t; /* bogus */ + +typedef integer_t cpu_type_t; +typedef integer_t cpu_subtype_t; + +#define CPU_STATE_MAX 3 + +#define CPU_STATE_USER 0 +#define CPU_STATE_SYSTEM 1 +#define CPU_STATE_IDLE 2 + +struct machine_slot { +/*boolean_t*/integer_t is_cpu; /* is there a cpu in this slot? */ + cpu_type_t cpu_type; /* type of cpu */ + cpu_subtype_t cpu_subtype; /* subtype of cpu */ +/*boolean_t*/integer_t running; /* is cpu running */ + integer_t cpu_ticks[CPU_STATE_MAX]; + integer_t clock_freq; /* clock interrupt frequency */ +}; + +typedef struct machine_slot *machine_slot_t; +typedef struct machine_slot machine_slot_data_t; /* bogus */ + +#ifdef MACH_KERNEL +extern struct machine_info machine_info; +extern struct machine_slot machine_slot[NCPUS]; +#endif /* MACH_KERNEL */ + +/* + * Machine types known by all. + * + * When adding new types & subtypes, please also update slot_name.c + * in the libmach sources. + */ + +#define CPU_TYPE_VAX ((cpu_type_t) 1) +#define CPU_TYPE_ROMP ((cpu_type_t) 2) +#define CPU_TYPE_MC68020 ((cpu_type_t) 3) +#define CPU_TYPE_NS32032 ((cpu_type_t) 4) +#define CPU_TYPE_NS32332 ((cpu_type_t) 5) +#define CPU_TYPE_NS32532 ((cpu_type_t) 6) +#define CPU_TYPE_I386 ((cpu_type_t) 7) +#define CPU_TYPE_MIPS ((cpu_type_t) 8) +#define CPU_TYPE_MC68030 ((cpu_type_t) 9) +#define CPU_TYPE_MC68040 ((cpu_type_t) 10) +#define CPU_TYPE_HPPA ((cpu_type_t) 11) +#define CPU_TYPE_ARM ((cpu_type_t) 12) +#define CPU_TYPE_MC88000 ((cpu_type_t) 13) +#define CPU_TYPE_SPARC ((cpu_type_t) 14) +#define CPU_TYPE_I860 ((cpu_type_t) 15) +#define CPU_TYPE_ALPHA ((cpu_type_t) 16) +#define CPU_TYPE_I486 ((cpu_type_t) 17) +#define CPU_TYPE_PENTIUM ((cpu_type_t) 18) +#define CPU_TYPE_PENTIUMPRO ((cpu_type_t) 19) +#define CPU_TYPE_POWERPC ((cpu_type_t) 20) +#define CPU_TYPE_X86_64 ((cpu_type_t) 21) + +/* + * Machine subtypes (these are defined here, instead of in a machine + * dependent directory, so that any program can get all definitions + * regardless of where is it compiled). + */ + +/* + * VAX subtypes (these do *not* necessarily conform to the actual cpu + * ID assigned by DEC available via the SID register). + */ + +#define CPU_SUBTYPE_VAX780 ((cpu_subtype_t) 1) +#define CPU_SUBTYPE_VAX785 ((cpu_subtype_t) 2) +#define CPU_SUBTYPE_VAX750 ((cpu_subtype_t) 3) +#define CPU_SUBTYPE_VAX730 ((cpu_subtype_t) 4) +#define CPU_SUBTYPE_UVAXI ((cpu_subtype_t) 5) +#define CPU_SUBTYPE_UVAXII ((cpu_subtype_t) 6) +#define CPU_SUBTYPE_VAX8200 ((cpu_subtype_t) 7) +#define CPU_SUBTYPE_VAX8500 ((cpu_subtype_t) 8) +#define CPU_SUBTYPE_VAX8600 ((cpu_subtype_t) 9) +#define CPU_SUBTYPE_VAX8650 ((cpu_subtype_t) 10) +#define CPU_SUBTYPE_VAX8800 ((cpu_subtype_t) 11) +#define CPU_SUBTYPE_UVAXIII ((cpu_subtype_t) 12) + +/* + * ROMP subtypes. + */ + +#define CPU_SUBTYPE_RT_PC ((cpu_subtype_t) 1) +#define CPU_SUBTYPE_RT_APC ((cpu_subtype_t) 2) +#define CPU_SUBTYPE_RT_135 ((cpu_subtype_t) 3) + +/* + * 68020 subtypes. + */ + +#define CPU_SUBTYPE_SUN3_50 ((cpu_subtype_t) 1) +#define CPU_SUBTYPE_SUN3_160 ((cpu_subtype_t) 2) +#define CPU_SUBTYPE_SUN3_260 ((cpu_subtype_t) 3) +#define CPU_SUBTYPE_SUN3_110 ((cpu_subtype_t) 4) +#define CPU_SUBTYPE_SUN3_60 ((cpu_subtype_t) 5) + +#define CPU_SUBTYPE_HP_320 ((cpu_subtype_t) 6) + /* 16.67 Mhz HP 300 series, custom MMU [HP 320] */ +#define CPU_SUBTYPE_HP_330 ((cpu_subtype_t) 7) + /* 16.67 Mhz HP 300 series, MC68851 MMU [HP 318,319,330,349] */ +#define CPU_SUBTYPE_HP_350 ((cpu_subtype_t) 8) + /* 25.00 Mhz HP 300 series, custom MMU [HP 350] */ + +/* + * 32032/32332/32532 subtypes. + */ + +#define CPU_SUBTYPE_MMAX_DPC ((cpu_subtype_t) 1) /* 032 CPU */ +#define CPU_SUBTYPE_SQT ((cpu_subtype_t) 2) +#define CPU_SUBTYPE_MMAX_APC_FPU ((cpu_subtype_t) 3) /* 32081 FPU */ +#define CPU_SUBTYPE_MMAX_APC_FPA ((cpu_subtype_t) 4) /* Weitek FPA */ +#define CPU_SUBTYPE_MMAX_XPC ((cpu_subtype_t) 5) /* 532 CPU */ +#define CPU_SUBTYPE_PC532 ((cpu_subtype_t) 6) /* pc532 board */ + +/* + * 80386/80486 subtypes. + */ + +#define CPU_SUBTYPE_AT386 ((cpu_subtype_t) 1) +#define CPU_SUBTYPE_EXL ((cpu_subtype_t) 2) +#define CPU_SUBTYPE_iPSC386 ((cpu_subtype_t) 3) +#define CPU_SUBTYPE_SYMMETRY ((cpu_subtype_t) 4) +#define CPU_SUBTYPE_PS2 ((cpu_subtype_t) 5) /* PS/2 w/ MCA */ + +/* + * Mips subtypes. + */ + +#define CPU_SUBTYPE_MIPS_R2300 ((cpu_subtype_t) 1) +#define CPU_SUBTYPE_MIPS_R2600 ((cpu_subtype_t) 2) +#define CPU_SUBTYPE_MIPS_R2800 ((cpu_subtype_t) 3) +#define CPU_SUBTYPE_MIPS_R2000a ((cpu_subtype_t) 4) /* pmax */ +#define CPU_SUBTYPE_MIPS_R2000 ((cpu_subtype_t) 5) +#define CPU_SUBTYPE_MIPS_R3000a ((cpu_subtype_t) 6) /* 3max */ +#define CPU_SUBTYPE_MIPS_R3000 ((cpu_subtype_t) 7) + +/* + * MC68030 subtypes. + */ + +#define CPU_SUBTYPE_NeXT ((cpu_subtype_t) 1) + /* NeXt thinks MC68030 is 6 rather than 9 */ +#define CPU_SUBTYPE_HP_340 ((cpu_subtype_t) 2) + /* 16.67 Mhz HP 300 series [HP 332,340] */ +#define CPU_SUBTYPE_HP_360 ((cpu_subtype_t) 3) + /* 25.00 Mhz HP 300 series [HP 360] */ +#define CPU_SUBTYPE_HP_370 ((cpu_subtype_t) 4) + /* 33.33 Mhz HP 300 series [HP 370] */ + +/* + * HPPA subtypes. + */ + +#define CPU_SUBTYPE_HPPA_825 ((cpu_subtype_t) 1) +#define CPU_SUBTYPE_HPPA_835 ((cpu_subtype_t) 2) +#define CPU_SUBTYPE_HPPA_840 ((cpu_subtype_t) 3) +#define CPU_SUBTYPE_HPPA_850 ((cpu_subtype_t) 4) +#define CPU_SUBTYPE_HPPA_855 ((cpu_subtype_t) 5) + +/* + * ARM subtypes. + */ + +#define CPU_SUBTYPE_ARM_A500_ARCH ((cpu_subtype_t) 1) +#define CPU_SUBTYPE_ARM_A500 ((cpu_subtype_t) 2) +#define CPU_SUBTYPE_ARM_A440 ((cpu_subtype_t) 3) +#define CPU_SUBTYPE_ARM_M4 ((cpu_subtype_t) 4) +#define CPU_SUBTYPE_ARM_A680 ((cpu_subtype_t) 5) + +/* + * MC88000 subtypes. + */ + +#define CPU_SUBTYPE_MMAX_JPC ((cpu_subtype_t) 1) +#define CPU_SUBTYPE_LUNA88K ((cpu_subtype_t) 2) + +/* + * Sparc subtypes. + */ + +#define CPU_SUBTYPE_SUN4_260 ((cpu_subtype_t) 1) +#define CPU_SUBTYPE_SUN4_110 ((cpu_subtype_t) 2) +#define CPU_SUBTYPE_SUN4_330 ((cpu_subtype_t) 3) +#define CPU_SUBTYPE_SUN4C_60 ((cpu_subtype_t) 4) +#define CPU_SUBTYPE_SUN4C_65 ((cpu_subtype_t) 5) +#define CPU_SUBTYPE_SUN4C_20 ((cpu_subtype_t) 6) +#define CPU_SUBTYPE_SUN4C_30 ((cpu_subtype_t) 7) +#define CPU_SUBTYPE_SUN4C_40 ((cpu_subtype_t) 8) +#define CPU_SUBTYPE_SUN4C_50 ((cpu_subtype_t) 9) +#define CPU_SUBTYPE_SUN4C_75 ((cpu_subtype_t) 10) + +/* + * i860 subtypes. + */ + +#define CPU_SUBTYPE_iPSC860 ((cpu_subtype_t) 1) +#define CPU_SUBTYPE_OKI860 ((cpu_subtype_t) 2) + +/* + * Alpha subtypes. + */ + +#define CPU_SUBTYPE_ALPHA_EV3 ((cpu_subtype_t) 1) +#define CPU_SUBTYPE_ALPHA_EV4 ((cpu_subtype_t) 2) +#define CPU_SUBTYPE_ALPHA_ISP ((cpu_subtype_t) 3) +#define CPU_SUBTYPE_ALPHA_21064 ((cpu_subtype_t) 4) + + +#endif /* _MACH_MACHINE_H_ */ diff --git a/include/mach/macro_help.h b/include/mach/macro_help.h new file mode 100644 index 0000000..f041e40 --- /dev/null +++ b/include/mach/macro_help.h @@ -0,0 +1,18 @@ +/* + * Mach Operating System + * Copyright (c) 1988 Carnegie-Mellon University + * All rights reserved. The CMU software License Agreement specifies + * the terms and conditions for use and redistribution. + */ + +#ifndef _MACRO_HELP_H_ +#define _MACRO_HELP_H_ 1 + +#define MACRO_BEGIN do { +#define MACRO_END } while (0) + +#define MACRO_RETURN if (1) return + +#endif /* _MACRO_HELP_H_ */ + + diff --git a/include/mach/memory_object.defs b/include/mach/memory_object.defs new file mode 100644 index 0000000..4afd67b --- /dev/null +++ b/include/mach/memory_object.defs @@ -0,0 +1,333 @@ +/* + * 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/memory_object.defs + * + * Abstract: + * Basic Mach external memory management interface declaration. + */ + +subsystem +#if KERNEL_USER + KernelUser +#endif /* KERNEL_USER */ +#if KERNEL_SERVER + KernelServer +#endif /* KERNEL_SERVER */ + memory_object 2200; + +#include <mach/std_types.defs> +#include <mach/mach_types.defs> + +#ifdef MEMORY_OBJECT_IMPORTS +MEMORY_OBJECT_IMPORTS +#endif + +#if SEQNOS +serverprefix seqnos_; +serverdemux seqnos_memory_object_server; +#endif /* SEQNOS */ + +/* + * Initialize the specified memory object, providing + * a reqeust port on which control calls can be made, and + * a name port that identifies this object to callers of + * vm_regions. + * [To allow the mapping of this object to be used, the + * memory manager must call memory_object_ready or + * memory_object_change_attributes. To reject all mappings of + * this object, the memory manager may use + * memory_object_destroy.] + */ +simpleroutine memory_object_init( + memory_object : memory_object_t; +#if SEQNOS + msgseqno seqno : mach_port_seqno_t; +#endif /* SEQNOS */ + memory_control : memory_object_control_t = + MACH_MSG_TYPE_MAKE_SEND + ctype: mach_port_t; + memory_object_name : memory_object_name_t = + MACH_MSG_TYPE_MAKE_SEND + ctype: mach_port_t; + memory_object_page_size : vm_size_t); + +/* + * Indicates that the specified memory object is no longer mapped + * (or cached -- see memory_object_ready or + * memory_object_change_attributes), and that further mappings + * will cause another memory_object_init call to be made. No + * further calls will be made on the memory object by this + * kernel. + * + * [All rights to the control and name ports are included + * in this call. The memory manager should use port_deallocate + * to release them once they are no longer needed.] + */ +simpleroutine memory_object_terminate( + memory_object : memory_object_t = + MACH_MSG_TYPE_MOVE_SEND + ctype: mach_port_t +#ifdef MEMORY_OBJECT_INTRAN + intran: MEMORY_OBJECT_INTRAN +#endif +#ifdef MEMORY_OBJECT_INTRAN_PAYLOAD + intranpayload: + MEMORY_OBJECT_INTRAN_PAYLOAD +#endif +#ifdef MEMORY_OBJECT_DESTRUCTOR + destructor: MEMORY_OBJECT_DESTRUCTOR +#endif + ; +#if SEQNOS + msgseqno seqno : mach_port_seqno_t; +#endif /* SEQNOS */ + memory_control : memory_object_control_t = + MACH_MSG_TYPE_MOVE_RECEIVE + ctype: mach_port_t +#if KERNEL_USER + /* for compatibility with Mach 2.5 kernels */ + , dealloc +#endif /* KERNEL_USER */ + ; + memory_object_name : memory_object_name_t = + MACH_MSG_TYPE_MOVE_RECEIVE + ctype: mach_port_t +#if KERNEL_USER + /* for compatibility with Mach 2.5 kernels */ + , dealloc +#endif /* KERNEL_USER */ + ); + +/* + * Indicates that a copy has been made of the specified range of + * the given original memory object. The kernel will use the new + * memory object, control and name ports to refer to the new copy + * (once the memory manager has asserted its "ready" attribute). + * + * Cached pages from the original memory object at the time of + * the copy operation are handled as follows: + * Readable pages may be silently copied to the new + * memory object (with all access permissions). + * Pages not copied are locked to prevent write access. + * + * This call includes only the new memory object itself; a + * memory_object_init call will be made on the new memory + * object after the actions above are completed. + * + * The new memory object is *temporary*, meaning that the + * memory manager should not change its contents or allow + * the memory object to be mapped in another client. The + * memory manager may use the memory_object_data_unavailable + * call to indicate that the appropriate page of the original + * memory object may be used to fulfill a data request. + * + * [Reply should be memory_object_ready or + * memory_object_change_attributes on the new memory object control + * port to indicate readiness.] + */ +simpleroutine memory_object_copy( + old_memory_object : memory_object_t; +#if SEQNOS + msgseqno seqno : mach_port_seqno_t; +#endif /* SEQNOS */ + old_memory_control : memory_object_control_t = + MACH_MSG_TYPE_MAKE_SEND + ctype: mach_port_t; + offset : vm_offset_t; + length : vm_size_t; + new_memory_object : memory_object_t = + MACH_MSG_TYPE_MOVE_RECEIVE + ctype: mach_port_t +#if KERNEL_USER + /* for compatibility with Mach 2.5 kernels */ + , dealloc +#endif /* KERNEL_USER */ + ); + +/* + * Request data from this memory object. At least + * the specified data should be returned with at + * least the specified access permitted. + * + * [Reply should be memory_object_data_supply.] + */ +simpleroutine memory_object_data_request( + memory_object : memory_object_t; +#if SEQNOS + msgseqno seqno : mach_port_seqno_t; +#endif /* SEQNOS */ + memory_control : memory_object_control_t = + MACH_MSG_TYPE_MAKE_SEND + ctype: mach_port_t; + offset : vm_offset_t; + length : vm_size_t; + desired_access : vm_prot_t); + +/* + * Request that the specified portion of this + * memory object be unlocked to allow the specified + * forms of access; the kernel already has the data. + * + * [Reply should be memory_object_lock_request.] + */ +simpleroutine memory_object_data_unlock( + memory_object : memory_object_t; +#if SEQNOS + msgseqno seqno : mach_port_seqno_t; +#endif /* SEQNOS */ + memory_control : memory_object_control_t = + MACH_MSG_TYPE_MAKE_SEND + ctype: mach_port_t; + offset : vm_offset_t; + length : vm_size_t; + desired_access : vm_prot_t); + +skip; /* was: memory_object_data_write */ + +/* + * Indicate that a previous memory_object_lock_request has been + * completed. Note that this call is made on whatever + * port is specified in the memory_object_lock_request; that port + * need not be the memory object port itself. + * + * [No reply expected.] + */ +simpleroutine memory_object_lock_completed( + memory_object : memory_object_t = + polymorphic|MACH_MSG_TYPE_PORT_SEND_ONCE + ctype: mach_port_t +#ifdef MEMORY_OBJECT_INTRAN + intran: MEMORY_OBJECT_INTRAN +#endif +#ifdef MEMORY_OBJECT_INTRAN_PAYLOAD + intranpayload: MEMORY_OBJECT_INTRAN_PAYLOAD +#endif +#ifdef MEMORY_OBJECT_DESTRUCTOR + destructor: MEMORY_OBJECT_DESTRUCTOR +#endif + ; +#if SEQNOS + msgseqno seqno : mach_port_seqno_t; +#endif /* SEQNOS */ + memory_control : memory_object_control_t = + MACH_MSG_TYPE_MAKE_SEND + ctype: mach_port_t; + offset : vm_offset_t; + length : vm_size_t); + +/* + * Indicate that a previous memory_object_data_supply has been + * completed. Note that this call is made on whatever + * port is specified in the memory_object_data_supply; that port + * need not be the memory object port itself. + * + * The result parameter indicates what happened during the supply. + * If it is not KERN_SUCCESS, then error_offset identifies the + * first offset at which a problem occurred. The pagein operation + * stopped at this point. Note that the only failures reported + * by this mechanism are KERN_MEMORY_PRESENT. All other failures + * (invalid argument, error on pagein of supplied data in manager's + * address space) cause the entire operation to fail. + * + * XXX Check what actually happens in latter case! + * + * [No reply expected.] + */ +simpleroutine memory_object_supply_completed( + memory_object : memory_object_t = + polymorphic|MACH_MSG_TYPE_PORT_SEND_ONCE + ctype: mach_port_t +#ifdef MEMORY_OBJECT_INTRAN + intran: MEMORY_OBJECT_INTRAN +#endif +#ifdef MEMORY_OBJECT_INTRAN_PAYLOAD + intranpayload: MEMORY_OBJECT_INTRAN_PAYLOAD +#endif +#ifdef MEMORY_OBJECT_DESTRUCTOR + destructor: MEMORY_OBJECT_DESTRUCTOR +#endif + ; +#if SEQNOS + msgseqno seqno : mach_port_seqno_t; +#endif /* SEQNOS */ + memory_control : memory_object_control_t = + MACH_MSG_TYPE_MAKE_SEND + ctype: mach_port_t; + offset : vm_offset_t; + length : vm_size_t; + result : kern_return_t; + error_offset : vm_offset_t); + +/* + * Return data to manager. This call indicates whether the + * returned data is dirty and whether the kernel kept a copy. + * Precious data remains precious if the kernel keeps a copy. + * The indication that the kernel kept a copy is only a hint if + * the data is not precious; the cleaned copy may be discarded + * without further notifying the manager. + * + * [Reply should be vm_deallocate to release the data.] + */ +simpleroutine memory_object_data_return( + memory_object : memory_object_t; +#if SEQNOS + msgseqno seqno : mach_port_seqno_t; +#endif /* SEQNOS */ + memory_control : memory_object_control_t = + MACH_MSG_TYPE_MAKE_SEND + ctype: mach_port_t; + offset : vm_offset_t; + data : pointer_t; + dirty : boolean_t; + kernel_copy : boolean_t); + +/* + * XXX Warning: This routine does NOT contain a memory_object_control_t + * XXX because the memory_object_change_attributes call may cause + * XXX memory object termination (by uncaching the object). This would + * XXX yield an invalid port. + */ + +simpleroutine memory_object_change_completed( + memory_object : memory_object_t = + polymorphic|MACH_MSG_TYPE_PORT_SEND_ONCE + ctype: mach_port_t +#ifdef MEMORY_OBJECT_INTRAN + intran: MEMORY_OBJECT_INTRAN +#endif +#ifdef MEMORY_OBJECT_INTRAN_PAYLOAD + intranpayload: MEMORY_OBJECT_INTRAN_PAYLOAD +#endif +#ifdef MEMORY_OBJECT_DESTRUCTOR + destructor: MEMORY_OBJECT_DESTRUCTOR +#endif + ; +#if SEQNOS + msgseqno seqno : mach_port_seqno_t; +#endif /* SEQNOS */ + may_cache : boolean_t; + copy_strategy : memory_object_copy_strategy_t); diff --git a/include/mach/memory_object.h b/include/mach/memory_object.h new file mode 100644 index 0000000..7e0c374 --- /dev/null +++ b/include/mach/memory_object.h @@ -0,0 +1,90 @@ +/* + * 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: memory_object.h + * Author: Michael Wayne Young + * + * External memory management interface definition. + */ + +#ifndef _MACH_MEMORY_OBJECT_H_ +#define _MACH_MEMORY_OBJECT_H_ + +/* + * User-visible types used in the external memory + * management interface: + */ + +#include <mach/port.h> + +#ifdef MACH_KERNEL +#include <ipc/ipc_types.h> +typedef ipc_port_t memory_object_t; +#else +typedef mach_port_t memory_object_t; +#endif + /* Represents a memory object ... */ + /* Used by user programs to specify */ + /* the object to map; used by the */ + /* kernel to retrieve or store data */ + +typedef memory_object_t *memory_object_array_t; + +typedef mach_port_t memory_object_control_t; + /* Provided to a memory manager; ... */ + /* used to control a memory object */ + +typedef mach_port_t memory_object_name_t; + /* Used to describe the memory ... */ + /* object in vm_regions() calls */ + +typedef int memory_object_copy_strategy_t; + /* How memory manager handles copy: */ +#define MEMORY_OBJECT_COPY_NONE 0 + /* ... No special support */ +#define MEMORY_OBJECT_COPY_CALL 1 + /* ... Make call on memory manager */ +#define MEMORY_OBJECT_COPY_DELAY 2 + /* ... Memory manager doesn't ... */ + /* change data externally. */ +#define MEMORY_OBJECT_COPY_TEMPORARY 3 + /* ... Memory manager doesn't ... */ + /* change data externally, and */ + /* doesn't need to see changes. */ + +typedef int memory_object_return_t; + /* Which pages to return to manager + this time (lock_request) */ +#define MEMORY_OBJECT_RETURN_NONE 0 + /* ... don't return any. */ +#define MEMORY_OBJECT_RETURN_DIRTY 1 + /* ... only dirty pages. */ +#define MEMORY_OBJECT_RETURN_ALL 2 + /* ... dirty and precious pages. */ + +#define MEMORY_OBJECT_NULL MACH_PORT_NULL + +#endif /* _MACH_MEMORY_OBJECT_H_ */ diff --git a/include/mach/memory_object_default.defs b/include/mach/memory_object_default.defs new file mode 100644 index 0000000..e62f14d --- /dev/null +++ b/include/mach/memory_object_default.defs @@ -0,0 +1,118 @@ +/* + * 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/memory_object_default.defs + * + * Abstract: + * Mach external memory management interface declaration; subset + * that is applicable to managers of kernel-created memory objects. + */ + +subsystem +#if KERNEL_USER + KernelUser +#endif /* KERNEL_USER */ + memory_object_default 2250; + +#include <mach/std_types.defs> +#include <mach/mach_types.defs> + +#ifdef MEMORY_OBJECT_IMPORTS +MEMORY_OBJECT_IMPORTS +#endif + +#if SEQNOS +serverprefix seqnos_; +serverdemux seqnos_memory_object_default_server; +#endif /* SEQNOS */ + +/* + * Pass on responsibility for the new kernel-created memory + * object. The port on which this request is that port + * (possibly a memory object itself) registered as the "default + * pager". Other arguments are as described for memory_object_init. + * [No reply required.] + */ +simpleroutine memory_object_create( + old_memory_object : memory_object_t = + MACH_MSG_TYPE_MOVE_SEND + ctype: mach_port_t; +#if SEQNOS + msgseqno seqno : mach_port_seqno_t; +#endif /* SEQNOS */ + new_memory_object : memory_object_t = + MACH_MSG_TYPE_MOVE_RECEIVE + ctype: mach_port_t +#if KERNEL_USER + /* for compatibility with Mach 2.5 kernels */ + , dealloc +#endif /* KERNEL_USER */ + ; + new_object_size : vm_size_t; + new_control_port : memory_object_control_t = + MACH_MSG_TYPE_MAKE_SEND + ctype: mach_port_t; + new_name : memory_object_name_t = + MACH_MSG_TYPE_MAKE_SEND + ctype: mach_port_t; + new_page_size : vm_size_t); + +/* + * Provide initial data contents for this region of + * the memory object. If data has already been written + * to the object, this value must be discarded; otherwise, + * this call acts identically to memory_object_data_return. + */ +simpleroutine memory_object_data_initialize( + memory_object : memory_object_t; +#if SEQNOS + msgseqno seqno : mach_port_seqno_t; +#endif /* SEQNOS */ + memory_control_port : memory_object_control_t = + MACH_MSG_TYPE_MAKE_SEND + ctype: mach_port_t; + offset : vm_offset_t; + data : pointer_t); + +#if 0 +/* + * Indicate that the specified range of data in this memory object + * will not be requested again until it is reinitialized with + * memory_object_data_return or memory_object_data_initialize. + */ +simpleroutine memory_object_data_terminate( + memory_object : memory_object_t; +#if SEQNOS + msgseqno seqno : mach_port_seqno_t; +#endif /* SEQNOS */ + memory_control_port : memory_object_control_t = + MACH_MSG_TYPE_MAKE_SEND + ctype: mach_port_t; + offset : vm_offset_t; + size : vm_size_t); +#else /* 0 */ +skip; /* memory_object_data_terminate */ +#endif /* 0 */ diff --git a/include/mach/message.h b/include/mach/message.h new file mode 100644 index 0000000..9790ef9 --- /dev/null +++ b/include/mach/message.h @@ -0,0 +1,540 @@ +/* + * Mach Operating System + * Copyright (c) 1992-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/message.h + * + * Mach IPC message and primitive function definitions. + */ + +#ifndef _MACH_MESSAGE_H_ +#define _MACH_MESSAGE_H_ + +#include <mach/kern_return.h> +#include <mach/port.h> + + +/* + * The timeout mechanism uses mach_msg_timeout_t values, + * passed by value. The timeout units are milliseconds. + * It is controlled with the MACH_SEND_TIMEOUT + * and MACH_RCV_TIMEOUT options. + */ + +typedef natural_t mach_msg_timeout_t; + +/* + * The value to be used when there is no timeout. + * (No MACH_SEND_TIMEOUT/MACH_RCV_TIMEOUT option.) + */ + +#define MACH_MSG_TIMEOUT_NONE ((mach_msg_timeout_t) 0) + +/* + * The kernel uses MACH_MSGH_BITS_COMPLEX as a hint. It it isn't on, it + * assumes the body of the message doesn't contain port rights or OOL + * data. The field is set in received messages. A user task must + * use caution in interpreting the body of a message if the bit isn't + * on, because the mach_msg_type's in the body might "lie" about the + * contents. If the bit isn't on, but the mach_msg_types + * in the body specify rights or OOL data, the behaviour is undefined. + * (Ie, an error may or may not be produced.) + * + * The value of MACH_MSGH_BITS_REMOTE determines the interpretation + * of the msgh_remote_port field. It is handled like a msgt_name. + * + * The value of MACH_MSGH_BITS_LOCAL determines the interpretation + * of the msgh_local_port field. It is handled like a msgt_name. + * + * MACH_MSGH_BITS() combines two MACH_MSG_TYPE_* values, for the remote + * and local fields, into a single value suitable for msgh_bits. + * + * MACH_MSGH_BITS_COMPLEX_PORTS, MACH_MSGH_BITS_COMPLEX_DATA, and + * MACH_MSGH_BITS_CIRCULAR should be zero; they are used internally. + * + * The unused bits should be zero. + */ + +#define MACH_MSGH_BITS_ZERO 0x00000000 +#define MACH_MSGH_BITS_REMOTE_MASK 0x000000ff +#define MACH_MSGH_BITS_LOCAL_MASK 0x0000ff00 +#define MACH_MSGH_BITS_COMPLEX 0x80000000U +#define MACH_MSGH_BITS_CIRCULAR 0x40000000 /* internal use only */ +#define MACH_MSGH_BITS_COMPLEX_PORTS 0x20000000 /* internal use only */ +#define MACH_MSGH_BITS_COMPLEX_DATA 0x10000000 /* internal use only */ +#define MACH_MSGH_BITS_MIGRATED 0x08000000 /* internal use only */ +#define MACH_MSGH_BITS_UNUSED 0x07ff0000 + +#define MACH_MSGH_BITS_PORTS_MASK \ + (MACH_MSGH_BITS_REMOTE_MASK|MACH_MSGH_BITS_LOCAL_MASK) + +#define MACH_MSGH_BITS(remote, local) \ + ((remote) | ((local) << 8)) +#define MACH_MSGH_BITS_REMOTE(bits) \ + ((bits) & MACH_MSGH_BITS_REMOTE_MASK) +#define MACH_MSGH_BITS_LOCAL(bits) \ + (((bits) & MACH_MSGH_BITS_LOCAL_MASK) >> 8) +#define MACH_MSGH_BITS_PORTS(bits) \ + ((bits) & MACH_MSGH_BITS_PORTS_MASK) +#define MACH_MSGH_BITS_OTHER(bits) \ + ((bits) &~ MACH_MSGH_BITS_PORTS_MASK) + +/* + * Every message starts with a message header. + * Following the message header are zero or more pairs of + * type descriptors (mach_msg_type_t/mach_msg_type_long_t) and + * data values. The size of the message must be specified in bytes, + * and includes the message header, type descriptors, inline + * data, and inline pointer for out-of-line data. + * + * The msgh_remote_port field specifies the destination of the message. + * It must specify a valid send or send-once right for a port. + * + * The msgh_local_port field specifies a "reply port". Normally, + * This field carries a send-once right that the receiver will use + * to reply to the message. It may carry the values MACH_PORT_NULL, + * MACH_PORT_DEAD, a send-once right, or a send right. + * + * The msgh_seqno field carries a sequence number associated with the + * received-from port. A port's sequence number is incremented every + * time a message is received from it. In sent messages, the field's + * value is ignored. + * + * The msgh_id field is uninterpreted by the message primitives. + * It normally carries information specifying the format + * or meaning of the message. + */ + +typedef unsigned int mach_msg_bits_t; +typedef unsigned int mach_msg_size_t; +typedef natural_t mach_msg_seqno_t; +typedef integer_t mach_msg_id_t; + +/* full header structure, may have different size in user/kernel spaces */ +typedef struct mach_msg_header { + mach_msg_bits_t msgh_bits; + mach_msg_size_t msgh_size; + union { + mach_port_t msgh_remote_port; + /* + * Ensure msgh_remote_port is wide enough to hold a kernel pointer + * to avoid message resizing for the 64 bits case. This field should + * not be used since it is here just for padding purposes. + */ + rpc_uintptr_t msgh_remote_port_do_not_use; + }; + union { + mach_port_t msgh_local_port; + rpc_uintptr_t msgh_protected_payload; + }; + mach_port_seqno_t msgh_seqno; + mach_msg_id_t msgh_id; +} mach_msg_header_t; + +#ifdef KERNEL +/* user-side header format, needed in the kernel */ +typedef struct { + mach_msg_bits_t msgh_bits; + mach_msg_size_t msgh_size; + union { + mach_port_name_t msgh_remote_port; + rpc_uintptr_t msgh_remote_port_do_not_use; + }; + union { + mach_port_name_t msgh_local_port; + rpc_uintptr_t msgh_protected_payload; + }; + mach_port_seqno_t msgh_seqno; + mach_msg_id_t msgh_id; +} mach_msg_user_header_t; +#else +typedef mach_msg_header_t mach_msg_user_header_t; +#endif + +/* + * There is no fixed upper bound to the size of Mach messages. + */ + +#define MACH_MSG_SIZE_MAX ((mach_msg_size_t) ~0) + +/* + * Compatibility definitions, for code written + * when there was a msgh_kind instead of msgh_seqno. + */ + +#define MACH_MSGH_KIND_NORMAL 0x00000000 +#if 0 +/* code using this is likely to break, so better not to have it defined */ +#define MACH_MSGH_KIND_NOTIFICATION 0x00000001 +#endif +#define msgh_kind msgh_seqno +#define mach_msg_kind_t mach_port_seqno_t + +/* + * The msgt_number field specifies the number of data elements. + * The msgt_size field specifies the size of each data element, in bits. + * The msgt_name field specifies the type of each data element. + * If msgt_inline is TRUE, the data follows the type descriptor + * in the body of the message. If msgt_inline is FALSE, then a pointer + * to the data should follow the type descriptor, and the data is + * sent out-of-line. In this case, if msgt_deallocate is TRUE, + * then the out-of-line data is moved (instead of copied) into the message. + * If msgt_longform is TRUE, then the type descriptor is actually + * a mach_msg_type_long_t. + * + * The actual amount of inline data following the descriptor must + * a multiple of the word size. For out-of-line data, this is a + * pointer. For inline data, the supplied data size (calculated + * from msgt_number/msgt_size) is rounded up. This guarantees + * that type descriptors always fall on word boundaries. + * + * For port rights, msgt_size must be 8*sizeof(mach_port_t). + * If the data is inline, msgt_deallocate should be FALSE. + * The msgt_unused bit should be zero. + * The msgt_name, msgt_size, msgt_number fields in + * a mach_msg_type_long_t should be zero. + */ + +typedef unsigned int mach_msg_type_name_t; +typedef unsigned int mach_msg_type_size_t; +typedef natural_t mach_msg_type_number_t; + +/** + * Structure used for inlined port rights in messages. + * + * We use this to avoid having to perform message resizing in the kernel + * since userspace port rights might be smaller than kernel ports in 64 bit + * architectures. + */ +typedef struct { + union { + mach_port_name_t name; +#ifdef KERNEL + mach_port_t kernel_port; +#else + uintptr_t kernel_port_do_not_use; +#endif /* KERNEL */ + }; +} mach_port_name_inlined_t; + +typedef struct { +#ifdef __x86_64__ + /* + * For 64 bits, this struct is 8 bytes long so we + * can pack the same amount of information as mach_msg_type_long_t. + * Note that for 64 bit userland, msgt_size only needs to be 8 bits long + * but for kernel compatibility with 32 bit userland we allow it to be + * 16 bits long. + * + * Effectively, we don't need mach_msg_type_long_t but we are keeping it + * for a while to make the code similar between 32 and 64 bits. + * + * We also keep the msgt_longform bit around simply because it makes it + * very easy to convert messages from a 32 bit userland into a 64 bit + * kernel. Otherwise, we would have to replicate some of the MiG logic + * internally in the kernel. + */ + unsigned int msgt_name : 8, + msgt_size : 16, + msgt_unused : 5, + msgt_inline : 1, + msgt_longform : 1, + msgt_deallocate : 1; + mach_msg_type_number_t msgt_number; +#else + unsigned int msgt_name : 8, + msgt_size : 8, + msgt_number : 12, + msgt_inline : 1, + msgt_longform : 1, + msgt_deallocate : 1, + msgt_unused : 1; +#endif +} __attribute__ ((aligned (__alignof__ (uintptr_t)))) mach_msg_type_t; + +typedef struct { +#ifdef __x86_64__ + union { + /* On x86_64 this is equivalent to mach_msg_type_t so use + * union to overlay with the old field names. */ + mach_msg_type_t msgtl_header; + struct { + unsigned int msgtl_name : 8, + msgtl_size : 16, + msgtl_unused : 5, + msgtl_inline : 1, + msgtl_longform : 1, + msgtl_deallocate : 1; + mach_msg_type_number_t msgtl_number; + }; + }; +#else + mach_msg_type_t msgtl_header; + unsigned short msgtl_name; + unsigned short msgtl_size; + natural_t msgtl_number; +#endif +} __attribute__ ((aligned (__alignof__ (uintptr_t)))) mach_msg_type_long_t; + +#ifdef __x86_64__ +#ifdef __cplusplus +#if __cplusplus >= 201103L +static_assert (sizeof (mach_msg_type_t) == sizeof (mach_msg_type_long_t), + "mach_msg_type_t and mach_msg_type_long_t need to have the same size."); +#endif +#else +_Static_assert (sizeof (mach_msg_type_t) == sizeof (mach_msg_type_long_t), + "mach_msg_type_t and mach_msg_type_long_t need to have the same size."); +#endif +#endif + +/* + * Known values for the msgt_name field. + * + * The only types known to the Mach kernel are + * the port types, and those types used in the + * kernel RPC interface. + */ + +#define MACH_MSG_TYPE_UNSTRUCTURED 0 +#define MACH_MSG_TYPE_BIT 0 +#define MACH_MSG_TYPE_BOOLEAN 0 +#define MACH_MSG_TYPE_INTEGER_16 1 +#define MACH_MSG_TYPE_INTEGER_32 2 +#define MACH_MSG_TYPE_CHAR 8 +#define MACH_MSG_TYPE_BYTE 9 +#define MACH_MSG_TYPE_INTEGER_8 9 +#define MACH_MSG_TYPE_REAL 10 +#define MACH_MSG_TYPE_INTEGER_64 11 +#define MACH_MSG_TYPE_STRING 12 +#define MACH_MSG_TYPE_STRING_C 12 + +/* + * Values used when sending a port right. + */ + +#define MACH_MSG_TYPE_MOVE_RECEIVE 16 /* Must hold receive rights */ +#define MACH_MSG_TYPE_MOVE_SEND 17 /* Must hold send rights */ +#define MACH_MSG_TYPE_MOVE_SEND_ONCE 18 /* Must hold sendonce rights */ +#define MACH_MSG_TYPE_COPY_SEND 19 /* Must hold send rights */ +#define MACH_MSG_TYPE_MAKE_SEND 20 /* Must hold receive rights */ +#define MACH_MSG_TYPE_MAKE_SEND_ONCE 21 /* Must hold receive rights */ + +/* + * Values received/carried in messages. Tells the receiver what + * sort of port right he now has. + * + * MACH_MSG_TYPE_PORT_NAME is used to transfer a port name + * which should remain uninterpreted by the kernel. (Port rights + * are not transferred, just the port name.) + */ + +#define MACH_MSG_TYPE_PORT_NAME 15 +#define MACH_MSG_TYPE_PORT_RECEIVE MACH_MSG_TYPE_MOVE_RECEIVE +#define MACH_MSG_TYPE_PORT_SEND MACH_MSG_TYPE_MOVE_SEND +#define MACH_MSG_TYPE_PORT_SEND_ONCE MACH_MSG_TYPE_MOVE_SEND_ONCE + +#define MACH_MSG_TYPE_PROTECTED_PAYLOAD 23 + +#define MACH_MSG_TYPE_LAST 23 /* Last assigned */ + +/* + * A dummy value. Mostly used to indicate that the actual value + * will be filled in later, dynamically. + */ + +#define MACH_MSG_TYPE_POLYMORPHIC ((mach_msg_type_name_t) -1) + +/* + * Is a given item a port type? + */ + +#define MACH_MSG_TYPE_PORT_ANY(x) \ + (((x) >= MACH_MSG_TYPE_MOVE_RECEIVE) && \ + ((x) <= MACH_MSG_TYPE_MAKE_SEND_ONCE)) + +#define MACH_MSG_TYPE_PORT_ANY_SEND(x) \ + (((x) >= MACH_MSG_TYPE_MOVE_SEND) && \ + ((x) <= MACH_MSG_TYPE_MAKE_SEND_ONCE)) + +#define MACH_MSG_TYPE_PORT_ANY_RIGHT(x) \ + (((x) >= MACH_MSG_TYPE_MOVE_RECEIVE) && \ + ((x) <= MACH_MSG_TYPE_MOVE_SEND_ONCE)) + +typedef integer_t mach_msg_option_t; + +#define MACH_MSG_OPTION_NONE 0x00000000 + +#define MACH_SEND_MSG 0x00000001 +#define MACH_RCV_MSG 0x00000002 + +#define MACH_SEND_TIMEOUT 0x00000010 +#define MACH_SEND_NOTIFY 0x00000020 +#define MACH_SEND_INTERRUPT 0x00000040 /* libmach implements */ +#define MACH_SEND_CANCEL 0x00000080 +#define MACH_RCV_TIMEOUT 0x00000100 +#define MACH_RCV_NOTIFY 0x00000200 +#define MACH_RCV_INTERRUPT 0x00000400 /* libmach implements */ +#define MACH_RCV_LARGE 0x00000800 + +#define MACH_SEND_ALWAYS 0x00010000 /* internal use only */ + +#ifdef __x86_64__ +#if defined(KERNEL) && defined(USER32) +#define MACH_MSG_USER_ALIGNMENT 4 +#else +#define MACH_MSG_USER_ALIGNMENT 8 +#endif +#else +#define MACH_MSG_USER_ALIGNMENT 4 +#endif + +#ifdef KERNEL +/* This is the alignment of msg descriptors and the actual data + * for both in kernel messages and user land messages. + * + * We have two types of alignment because for specific configurations + * (in particular a 64 bit kernel with 32 bit userland) we transform + * 4-byte aligned user messages into 8-byte aligned messages (and vice-versa) + * so that kernel messages are correctly aligned. + */ +#define MACH_MSG_KERNEL_ALIGNMENT sizeof(uintptr_t) + +#define mach_msg_align(x, alignment) \ + ( ( ((vm_offset_t)(x)) + ((alignment)-1) ) & ~((alignment)-1) ) +#define mach_msg_user_align(x) mach_msg_align(x, MACH_MSG_USER_ALIGNMENT) +#define mach_msg_kernel_align(x) mach_msg_align(x, MACH_MSG_KERNEL_ALIGNMENT) +#define mach_msg_user_is_misaligned(x) ((x) & ((MACH_MSG_USER_ALIGNMENT)-1)) +#define mach_msg_kernel_is_misaligned(x) ((x) & ((MACH_MSG_KERNEL_ALIGNMENT)-1)) +#endif /* KERNEL */ + +/* + * Much code assumes that mach_msg_return_t == kern_return_t. + * This definition is useful for descriptive purposes. + * + * See <mach/error.h> for the format of error codes. + * IPC errors are system 4. Send errors are subsystem 0; + * receive errors are subsystem 1. The code field is always non-zero. + * The high bits of the code field communicate extra information + * for some error codes. MACH_MSG_MASK masks off these special bits. + */ + +typedef kern_return_t mach_msg_return_t; + +#define MACH_MSG_SUCCESS 0x00000000 + +#define MACH_MSG_MASK 0x00003c00 + /* All special error code bits defined below. */ +#define MACH_MSG_IPC_SPACE 0x00002000 + /* No room in IPC name space for another capability name. */ +#define MACH_MSG_VM_SPACE 0x00001000 + /* No room in VM address space for out-of-line memory. */ +#define MACH_MSG_IPC_KERNEL 0x00000800 + /* Kernel resource shortage handling an IPC capability. */ +#define MACH_MSG_VM_KERNEL 0x00000400 + /* Kernel resource shortage handling out-of-line memory. */ + +#define MACH_SEND_IN_PROGRESS 0x10000001 + /* Thread is waiting to send. (Internal use only.) */ +#define MACH_SEND_INVALID_DATA 0x10000002 + /* Bogus in-line data. */ +#define MACH_SEND_INVALID_DEST 0x10000003 + /* Bogus destination port. */ +#define MACH_SEND_TIMED_OUT 0x10000004 + /* Message not sent before timeout expired. */ +#define MACH_SEND_WILL_NOTIFY 0x10000005 + /* Msg-accepted notification will be generated. */ +#define MACH_SEND_NOTIFY_IN_PROGRESS 0x10000006 + /* Msg-accepted notification already pending. */ +#define MACH_SEND_INTERRUPTED 0x10000007 + /* Software interrupt. */ +#define MACH_SEND_MSG_TOO_SMALL 0x10000008 + /* Data doesn't contain a complete message. */ +#define MACH_SEND_INVALID_REPLY 0x10000009 + /* Bogus reply port. */ +#define MACH_SEND_INVALID_RIGHT 0x1000000a + /* Bogus port rights in the message body. */ +#define MACH_SEND_INVALID_NOTIFY 0x1000000b + /* Bogus notify port argument. */ +#define MACH_SEND_INVALID_MEMORY 0x1000000c + /* Invalid out-of-line memory pointer. */ +#define MACH_SEND_NO_BUFFER 0x1000000d + /* No message buffer is available. */ +#define MACH_SEND_NO_NOTIFY 0x1000000e + /* Resource shortage; can't request msg-accepted notif. */ +#define MACH_SEND_INVALID_TYPE 0x1000000f + /* Invalid msg-type specification. */ +#define MACH_SEND_INVALID_HEADER 0x10000010 + /* A field in the header had a bad value. */ + +#define MACH_RCV_IN_PROGRESS 0x10004001 + /* Thread is waiting for receive. (Internal use only.) */ +#define MACH_RCV_INVALID_NAME 0x10004002 + /* Bogus name for receive port/port-set. */ +#define MACH_RCV_TIMED_OUT 0x10004003 + /* Didn't get a message within the timeout value. */ +#define MACH_RCV_TOO_LARGE 0x10004004 + /* Message buffer is not large enough for inline data. */ +#define MACH_RCV_INTERRUPTED 0x10004005 + /* Software interrupt. */ +#define MACH_RCV_PORT_CHANGED 0x10004006 + /* Port moved into a set during the receive. */ +#define MACH_RCV_INVALID_NOTIFY 0x10004007 + /* Bogus notify port argument. */ +#define MACH_RCV_INVALID_DATA 0x10004008 + /* Bogus message buffer for inline data. */ +#define MACH_RCV_PORT_DIED 0x10004009 + /* Port/set was sent away/died during receive. */ +#define MACH_RCV_IN_SET 0x1000400a + /* Port is a member of a port set. */ +#define MACH_RCV_HEADER_ERROR 0x1000400b + /* Error receiving message header. See special bits. */ +#define MACH_RCV_BODY_ERROR 0x1000400c + /* Error receiving message body. See special bits. */ + +extern mach_msg_return_t +mach_msg_trap + (mach_msg_user_header_t *msg, + mach_msg_option_t option, + mach_msg_size_t send_size, + mach_msg_size_t rcv_size, + mach_port_name_t rcv_name, + mach_msg_timeout_t timeout, + mach_port_name_t notify); + +extern mach_msg_return_t +mach_msg + (mach_msg_header_t *msg, + mach_msg_option_t option, + mach_msg_size_t send_size, + mach_msg_size_t rcv_size, + mach_port_name_t rcv_name, + mach_msg_timeout_t timeout, + mach_port_name_t notify); + +extern __typeof (mach_msg) __mach_msg; +extern __typeof (mach_msg_trap) __mach_msg_trap; + +#endif /* _MACH_MESSAGE_H_ */ diff --git a/include/mach/mig_errors.h b/include/mach/mig_errors.h new file mode 100644 index 0000000..389ce77 --- /dev/null +++ b/include/mach/mig_errors.h @@ -0,0 +1,89 @@ +/* + * 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. + */ +/* + * Mach Interface Generator errors + * + */ + +#ifndef _MACH_MIG_ERRORS_H_ +#define _MACH_MIG_ERRORS_H_ + +#include <mach/kern_return.h> +#include <mach/message.h> + +/* + * These error codes should be specified as system 4, subsytem 2. + * But alas backwards compatibility makes that impossible. + * The problem is old clients of new servers (eg, the kernel) + * which get strange large error codes when there is a Mig problem + * in the server. Unfortunately, the IPC system doesn't have + * the knowledge to convert the codes in this situation. + */ + +#define MIG_TYPE_ERROR -300 /* client type check failure */ +#define MIG_REPLY_MISMATCH -301 /* wrong reply message ID */ +#define MIG_REMOTE_ERROR -302 /* server detected error */ +#define MIG_BAD_ID -303 /* bad request message ID */ +#define MIG_BAD_ARGUMENTS -304 /* server type check failure */ +#define MIG_NO_REPLY -305 /* no reply should be sent */ +#define MIG_EXCEPTION -306 /* server raised exception */ +#define MIG_ARRAY_TOO_LARGE -307 /* array not large enough */ +#define MIG_SERVER_DIED -308 /* server died */ +#define MIG_DESTROY_REQUEST -309 /* destroy request with no reply */ + +typedef struct { + mach_msg_header_t Head; + mach_msg_type_t RetCodeType; + kern_return_t RetCode; +} mig_reply_header_t; + +typedef struct mig_symtab { + char *ms_routine_name; + int ms_routine_number; +#if defined(__STDC__) || defined(c_plus_plus) || defined(hc) + void +#else + int +#endif + (*ms_routine)(void); +} mig_symtab_t; + +/* + * Definition for server stub routines. These routines + * unpack the request message, call the server procedure, + * and pack the reply message. + */ +#if defined(__STDC__) || defined(c_plus_plus) +typedef void (*mig_routine_t)(mach_msg_header_t *, mach_msg_header_t *); +#else +#if defined(hc) +typedef void (*mig_routine_t)(); +#else +typedef int (*mig_routine_t)(); /* PCC cannot handle void (*)() */ +#endif +#endif + +#endif /* _MACH_MIG_ERRORS_H_ */ diff --git a/include/mach/mig_support.h b/include/mach/mig_support.h new file mode 100644 index 0000000..ed871c0 --- /dev/null +++ b/include/mach/mig_support.h @@ -0,0 +1,57 @@ +/* + * Mach Operating System + * Copyright (c) 1992 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: + * Header file for support routines called by MiG generated interfaces. + * + */ + +#ifndef _MACH_MIG_SUPPORT_H_ +#define _MACH_MIG_SUPPORT_H_ + +#include <string.h> + +#include <mach/message.h> +#include <mach/mach_types.h> + +extern void mig_init(void *_first); + +extern void mig_allocate(vm_address_t *_addr_p, vm_size_t _size); + +extern void mig_deallocate(vm_address_t _addr, vm_size_t _size); + +extern void mig_dealloc_reply_port(mach_port_t); + +extern void mig_put_reply_port(mach_port_t); + +extern mach_port_name_t mig_get_reply_port(void); + +extern void mig_reply_setup(const mach_msg_header_t *_request, + mach_msg_header_t *reply); + +extern vm_size_t mig_strncpy(char *_dest, const char *_src, vm_size_t _len); + +#endif /* not defined(_MACH_MIG_SUPPORT_H_) */ diff --git a/include/mach/notify.defs b/include/mach/notify.defs new file mode 100644 index 0000000..6ba4cde --- /dev/null +++ b/include/mach/notify.defs @@ -0,0 +1,112 @@ +/* + * 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. + */ + +subsystem notify 64; + +#include <mach/std_types.defs> + +#ifdef NOTIFY_IMPORTS +NOTIFY_IMPORTS +#endif + +#if SEQNOS +serverprefix do_seqnos_; +serverdemux seqnos_notify_server; +#else +serverprefix do_; +serverdemux notify_server; +#endif + +type notify_port_t = MACH_MSG_TYPE_MOVE_SEND_ONCE + ctype: mach_port_t +#ifdef NOTIFY_INTRAN + intran: NOTIFY_INTRAN +#endif +#ifdef NOTIFY_INTRAN_PAYLOAD + intranpayload: NOTIFY_INTRAN_PAYLOAD +#endif +#ifdef NOTIFY_OUTTRAN + outtran: NOTIFY_OUTTRAN +#endif +#ifdef NOTIFY_DESTRUCTOR + destructor: NOTIFY_DESTRUCTOR +#endif +; + +/* MACH_NOTIFY_FIRST: 0100 */ +skip; + +/* MACH_NOTIFY_PORT_DELETED: 0101 */ +simpleroutine mach_notify_port_deleted( + notify : notify_port_t; +#if SEQNOS + msgseqno seqno : mach_port_seqno_t; +#endif + name : mach_port_name_t); + +/* MACH_NOTIFY_MSG_ACCEPTED: 0102 */ +simpleroutine mach_notify_msg_accepted( + notify : notify_port_t; +#if SEQNOS + msgseqno seqno : mach_port_seqno_t; +#endif + name : mach_port_name_t); + +skip; /* was NOTIFY_OWNERSHIP_RIGHTS: 0103 */ + +skip; /* was NOTIFY_RECEIVE_RIGHTS: 0104 */ + +/* MACH_NOTIFY_PORT_DESTROYED: 0105 */ +simpleroutine mach_notify_port_destroyed( + notify : notify_port_t; +#if SEQNOS + msgseqno seqno : mach_port_seqno_t; +#endif + rights : mach_port_receive_t); + +/* MACH_NOTIFY_NO_SENDERS: 0106 */ +simpleroutine mach_notify_no_senders( + notify : notify_port_t; +#if SEQNOS + msgseqno seqno : mach_port_seqno_t; +#endif + mscount : mach_port_mscount_t); + +/* MACH_NOTIFY_SEND_ONCE: 0107 */ +simpleroutine mach_notify_send_once( + notify : notify_port_t +#if SEQNOS +; msgseqno seqno : mach_port_seqno_t +#endif + ); + +/* MACH_NOTIFY_DEAD_NAME: 0110 */ +simpleroutine mach_notify_dead_name( + notify : notify_port_t; +#if SEQNOS + msgseqno seqno : mach_port_seqno_t; +#endif + name : mach_port_name_t); diff --git a/include/mach/notify.h b/include/mach/notify.h new file mode 100644 index 0000000..14bcd6f --- /dev/null +++ b/include/mach/notify.h @@ -0,0 +1,92 @@ +/* + * 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/notify.h + * + * Kernel notification message definitions. + */ + +#ifndef _MACH_NOTIFY_H_ +#define _MACH_NOTIFY_H_ + +#include <mach/port.h> +#include <mach/message.h> + +/* + * An alternative specification of the notification interface + * may be found in mach/notify.defs. + */ + +#define MACH_NOTIFY_FIRST 0100 +#define MACH_NOTIFY_PORT_DELETED (MACH_NOTIFY_FIRST + 001 ) + /* A send or send-once right was deleted. */ +#define MACH_NOTIFY_MSG_ACCEPTED (MACH_NOTIFY_FIRST + 002) + /* A MACH_SEND_NOTIFY msg was accepted */ +#define MACH_NOTIFY_PORT_DESTROYED (MACH_NOTIFY_FIRST + 005) + /* A receive right was (would have been) deallocated */ +#define MACH_NOTIFY_NO_SENDERS (MACH_NOTIFY_FIRST + 006) + /* Receive right has no extant send rights */ +#define MACH_NOTIFY_SEND_ONCE (MACH_NOTIFY_FIRST + 007) + /* An extant send-once right died */ +#define MACH_NOTIFY_DEAD_NAME (MACH_NOTIFY_FIRST + 010) + /* Send or send-once right died, leaving a dead-name */ +#define MACH_NOTIFY_LAST (MACH_NOTIFY_FIRST + 015) + +typedef struct { + mach_msg_header_t not_header; + mach_msg_type_t not_type; /* MACH_MSG_TYPE_PORT_NAME */ + mach_port_name_t not_port; +} mach_port_deleted_notification_t; + +typedef struct { + mach_msg_header_t not_header; + mach_msg_type_t not_type; /* MACH_MSG_TYPE_PORT_NAME */ + mach_port_name_t not_port; +} mach_msg_accepted_notification_t; + +typedef struct { + mach_msg_header_t not_header; + mach_msg_type_t not_type; /* MACH_MSG_TYPE_PORT_RECEIVE */ + mach_port_t not_port; +} mach_port_destroyed_notification_t; + +typedef struct { + mach_msg_header_t not_header; + mach_msg_type_t not_type; /* MACH_MSG_TYPE_INTEGER_32 */ + unsigned int not_count; +} mach_no_senders_notification_t; + +typedef struct { + mach_msg_header_t not_header; +} mach_send_once_notification_t; + +typedef struct { + mach_msg_header_t not_header; + mach_msg_type_t not_type; /* MACH_MSG_TYPE_PORT_NAME */ + mach_port_name_t not_port; +} mach_dead_name_notification_t; + +#endif /* _MACH_NOTIFY_H_ */ diff --git a/include/mach/pc_sample.h b/include/mach/pc_sample.h new file mode 100644 index 0000000..2d56b34 --- /dev/null +++ b/include/mach/pc_sample.h @@ -0,0 +1,66 @@ +/* + * Mach Operating System + * Copyright (c) 1993,1992 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_PC_SAMPLE_H_ +#define _MACH_PC_SAMPLE_H_ + +#include <mach/machine/vm_types.h> + +typedef unsigned int sampled_pc_flavor_t; + + +#define SAMPLED_PC_PERIODIC 0x1 /* default */ + + +#define SAMPLED_PC_VM_ZFILL_FAULTS 0x10 +#define SAMPLED_PC_VM_REACTIVATION_FAULTS 0x20 +#define SAMPLED_PC_VM_PAGEIN_FAULTS 0x40 +#define SAMPLED_PC_VM_COW_FAULTS 0x80 +#define SAMPLED_PC_VM_FAULTS_ANY 0x100 +#define SAMPLED_PC_VM_FAULTS \ + (SAMPLED_PC_VM_ZFILL_FAULTS | \ + SAMPLED_PC_VM_REACTIVATION_FAULTS |\ + SAMPLED_PC_VM_PAGEIN_FAULTS |\ + SAMPLED_PC_VM_COW_FAULTS ) + + + + +/* + * Definitions for the PC sampling interface. + */ + +typedef struct sampled_pc { + rpc_vm_offset_t id; /* task_t address */ + rpc_vm_offset_t pc; /* program counter */ + sampled_pc_flavor_t sampletype; +} sampled_pc_t; + +typedef sampled_pc_t *sampled_pc_array_t; +typedef unsigned int sampled_pc_seqno_t; + + +#endif /* _MACH_PC_SAMPLE_H_ */ diff --git a/include/mach/policy.h b/include/mach/policy.h new file mode 100644 index 0000000..da776c9 --- /dev/null +++ b/include/mach/policy.h @@ -0,0 +1,45 @@ +/* + * 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_POLICY_H_ +#define _MACH_POLICY_H_ + +/* + * mach/policy.h + * + * Definitions for scheduing policy. + */ + +/* + * Policy definitions. Policies must be powers of 2. + */ +#define POLICY_TIMESHARE 1 +#define POLICY_FIXEDPRI 2 +#define POLICY_LAST 2 + +#define invalid_policy(policy) (((policy) <= 0) || ((policy) > POLICY_LAST)) + +#endif /* _MACH_POLICY_H_ */ diff --git a/include/mach/port.h b/include/mach/port.h new file mode 100644 index 0000000..c9bbcf1 --- /dev/null +++ b/include/mach/port.h @@ -0,0 +1,159 @@ +/* + * 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/port.h + * + * Definition of a port + * + * [The basic mach_port_t type should probably be machine-dependent, + * as it must be represented by a 32-bit integer.] + */ + +#ifndef _MACH_PORT_H_ +#define _MACH_PORT_H_ + +#include <mach/boolean.h> +#include <mach/machine/vm_types.h> + +/* + * Port names are the type used by userspace, they are always 32-bit wide. + */ +typedef unsigned int mach_port_name_t; +typedef mach_port_name_t *mach_port_name_array_t; +typedef const mach_port_name_t *const_mach_port_name_array_t; + +/* + * A port is represented + * - by a port name in userspace + * - by a pointer in kernel space + * While in userspace mach_port_name_t and mach_port_name are interchangable, + * in kernelspace they need to be different and appropriately converted. + */ +#ifdef KERNEL +typedef vm_offset_t mach_port_t; +#else /* KERNEL */ +typedef mach_port_name_t mach_port_t; +#endif +typedef mach_port_t *mach_port_array_t; +typedef const mach_port_t *const_mach_port_array_t; +typedef int *rpc_signature_info_t; + +/* + * MACH_PORT_NULL is a legal value that can be carried in messages. + * It indicates the absence of any port or port rights. (A port + * argument keeps the message from being "simple", even if the + * value is MACH_PORT_NULL.) The value MACH_PORT_DEAD is also + * a legal value that can be carried in messages. It indicates + * that a port right was present, but it died. + */ + +#define MACH_PORT_NULL 0 /* works with both user and kernel ports */ +#define MACH_PORT_DEAD ((mach_port_t) ~0) +#define MACH_PORT_NAME_NULL ((mach_port_name_t) 0) +#define MACH_PORT_NAME_DEAD ((mach_port_name_t) ~0) + +#define MACH_PORT_VALID(port) \ + (((port) != MACH_PORT_NULL) && ((port) != MACH_PORT_DEAD)) +#define MACH_PORT_NAME_VALID(name) \ + (((name) != MACH_PORT_NAME_NULL) && ((name) != MACH_PORT_NAME_DEAD)) + +/* + * These are the different rights a task may have. + * The MACH_PORT_RIGHT_* definitions are used as arguments + * to mach_port_allocate, mach_port_get_refs, etc, to specify + * a particular right to act upon. The mach_port_names and + * mach_port_type calls return bitmasks using the MACH_PORT_TYPE_* + * definitions. This is because a single name may denote + * multiple rights. + */ + +typedef natural_t mach_port_right_t; + +#define MACH_PORT_RIGHT_SEND ((mach_port_right_t) 0) +#define MACH_PORT_RIGHT_RECEIVE ((mach_port_right_t) 1) +#define MACH_PORT_RIGHT_SEND_ONCE ((mach_port_right_t) 2) +#define MACH_PORT_RIGHT_PORT_SET ((mach_port_right_t) 3) +#define MACH_PORT_RIGHT_DEAD_NAME ((mach_port_right_t) 4) +#define MACH_PORT_RIGHT_NUMBER ((mach_port_right_t) 5) + +typedef natural_t mach_port_type_t; +typedef mach_port_type_t *mach_port_type_array_t; + +#define MACH_PORT_TYPE(right) ((mach_port_type_t)(1 << ((right)+16))) +#define MACH_PORT_TYPE_NONE ((mach_port_type_t) 0) +#define MACH_PORT_TYPE_SEND MACH_PORT_TYPE(MACH_PORT_RIGHT_SEND) +#define MACH_PORT_TYPE_RECEIVE MACH_PORT_TYPE(MACH_PORT_RIGHT_RECEIVE) +#define MACH_PORT_TYPE_SEND_ONCE MACH_PORT_TYPE(MACH_PORT_RIGHT_SEND_ONCE) +#define MACH_PORT_TYPE_PORT_SET MACH_PORT_TYPE(MACH_PORT_RIGHT_PORT_SET) +#define MACH_PORT_TYPE_DEAD_NAME MACH_PORT_TYPE(MACH_PORT_RIGHT_DEAD_NAME) + +/* Convenient combinations. */ + +#define MACH_PORT_TYPE_SEND_RECEIVE \ + (MACH_PORT_TYPE_SEND|MACH_PORT_TYPE_RECEIVE) +#define MACH_PORT_TYPE_SEND_RIGHTS \ + (MACH_PORT_TYPE_SEND|MACH_PORT_TYPE_SEND_ONCE) +#define MACH_PORT_TYPE_PORT_RIGHTS \ + (MACH_PORT_TYPE_SEND_RIGHTS|MACH_PORT_TYPE_RECEIVE) +#define MACH_PORT_TYPE_PORT_OR_DEAD \ + (MACH_PORT_TYPE_PORT_RIGHTS|MACH_PORT_TYPE_DEAD_NAME) +#define MACH_PORT_TYPE_ALL_RIGHTS \ + (MACH_PORT_TYPE_PORT_OR_DEAD|MACH_PORT_TYPE_PORT_SET) + +/* Dummy type bits that mach_port_type/mach_port_names can return. */ + +#define MACH_PORT_TYPE_DNREQUEST 0x80000000U +#define MACH_PORT_TYPE_MAREQUEST 0x40000000 +#define MACH_PORT_TYPE_COMPAT 0x20000000 + +/* User-references for capabilities. */ + +typedef natural_t mach_port_urefs_t; +typedef integer_t mach_port_delta_t; /* change in urefs */ + +/* Attributes of ports. (See mach_port_get_receive_status.) */ + +typedef natural_t mach_port_seqno_t; /* sequence number */ +typedef unsigned int mach_port_mscount_t; /* make-send count */ +typedef unsigned int mach_port_msgcount_t; /* number of msgs */ +typedef unsigned int mach_port_rights_t; /* number of rights */ + +typedef struct mach_port_status { + mach_port_name_t mps_pset; /* containing port set */ + mach_port_seqno_t mps_seqno; /* sequence number */ + mach_port_mscount_t mps_mscount; /* make-send count */ + mach_port_msgcount_t mps_qlimit; /* queue limit */ + mach_port_msgcount_t mps_msgcount; /* number in the queue */ + mach_port_rights_t mps_sorights; /* how many send-once rights */ + boolean_t mps_srights; /* do send rights exist? */ + boolean_t mps_pdrequest; /* port-deleted requested? */ + boolean_t mps_nsrequest; /* no-senders requested? */ +} mach_port_status_t; + +#define MACH_PORT_QLIMIT_DEFAULT ((mach_port_msgcount_t) 5) +#define MACH_PORT_QLIMIT_MAX ((mach_port_msgcount_t) 16) + +#endif /* _MACH_PORT_H_ */ diff --git a/include/mach/processor_info.h b/include/mach/processor_info.h new file mode 100644 index 0000000..5f761ea --- /dev/null +++ b/include/mach/processor_info.h @@ -0,0 +1,104 @@ +/* + * Mach Operating System + * Copyright (c) 1993,1992,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/processor_info.h + * Author: David L. Black + * Date: 1988 + * + * Data structure definitions for processor_info, processor_set_info + */ + +#ifndef _MACH_PROCESSOR_INFO_H_ +#define _MACH_PROCESSOR_INFO_H_ + +#include <mach/machine.h> + +/* + * Generic information structure to allow for expansion. + */ +typedef integer_t *processor_info_t; /* varying array of int. */ + +#define PROCESSOR_INFO_MAX (1024) /* max array size */ +typedef integer_t processor_info_data_t[PROCESSOR_INFO_MAX]; + + +typedef integer_t *processor_set_info_t; /* varying array of int. */ + +#define PROCESSOR_SET_INFO_MAX (1024) /* max array size */ +typedef integer_t processor_set_info_data_t[PROCESSOR_SET_INFO_MAX]; + +/* + * Currently defined information. + */ +#define PROCESSOR_BASIC_INFO 1 /* basic information */ + +struct processor_basic_info { + cpu_type_t cpu_type; /* type of cpu */ + cpu_subtype_t cpu_subtype; /* subtype of cpu */ +/*boolean_t*/integer_t running; /* is processor running */ + integer_t slot_num; /* slot number */ +/*boolean_t*/integer_t is_master; /* is this the master processor */ +}; + +typedef struct processor_basic_info processor_basic_info_data_t; +typedef struct processor_basic_info *processor_basic_info_t; +#define PROCESSOR_BASIC_INFO_COUNT \ + (sizeof(processor_basic_info_data_t)/sizeof(integer_t)) + + +#define PROCESSOR_SET_BASIC_INFO 1 /* basic information */ + +struct processor_set_basic_info { + integer_t processor_count; /* How many processors */ + integer_t task_count; /* How many tasks */ + integer_t thread_count; /* How many threads */ + integer_t load_average; /* Scaled */ + integer_t mach_factor; /* Scaled */ +}; + +/* + * Scaling factor for load_average, mach_factor. + */ +#define LOAD_SCALE 1000 + +typedef struct processor_set_basic_info processor_set_basic_info_data_t; +typedef struct processor_set_basic_info *processor_set_basic_info_t; +#define PROCESSOR_SET_BASIC_INFO_COUNT \ + (sizeof(processor_set_basic_info_data_t)/sizeof(integer_t)) + +#define PROCESSOR_SET_SCHED_INFO 2 /* scheduling info */ + +struct processor_set_sched_info { + integer_t policies; /* allowed policies */ + integer_t max_priority; /* max priority for new threads */ +}; + +typedef struct processor_set_sched_info processor_set_sched_info_data_t; +typedef struct processor_set_sched_info *processor_set_sched_info_t; +#define PROCESSOR_SET_SCHED_INFO_COUNT \ + (sizeof(processor_set_sched_info_data_t)/sizeof(integer_t)) + +#endif /* _MACH_PROCESSOR_INFO_H_ */ diff --git a/include/mach/profil.h b/include/mach/profil.h new file mode 100644 index 0000000..866f267 --- /dev/null +++ b/include/mach/profil.h @@ -0,0 +1,212 @@ +/* + * 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. + */ + +/* + * Copyright 1991 by Open Software Foundation, + * Grenoble, FRANCE + * + * All Rights Reserved + * + * Permission to use, copy, modify, and distribute this software and + * its documentation for any purpose and without fee is hereby granted, + * provided that the above copyright notice appears in all copies and + * that both the copyright notice and this permission notice appear in + * supporting documentation, and that the name of OSF or Open Software + * Foundation not be used in advertising or publicity pertaining to + * distribution of the software without specific, written prior + * permission. + * + * OSF DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE + * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, + * IN NO EVENT SHALL OSF BE LIABLE FOR ANY SPECIAL, INDIRECT, OR + * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM + * LOSS OF USE, DATA OR PROFITS, WHETHER IN ACTION OF CONTRACT, + * NEGLIGENCE, OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION + * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + */ + + +#ifndef _MACH_PROFIL_H_ +#define _MACH_PROFIL_H_ + +#include <mach/boolean.h> +#include <ipc/ipc_object.h> +#include <vm/vm_kern.h> + + +#define NB_PROF_BUFFER 2 /* number of buffers servicing a + * profiled thread */ +#define SIZE_PROF_BUFFER 100 /* size of a profil buffer (in int) + * This values is also defined in + * the server (ugly), be careful ! */ + + +struct prof_data { + ipc_object_t prof_port; /* where to send a full buffer */ + + struct buffer { + int *p_zone; /* points to the actual storage area */ + int p_index;/* next slot to be filled */ + boolean_t p_full; /* is the current buffer full ? */ + } prof_area[NB_PROF_BUFFER]; + + int prof_index; /* index of the buffer structure + * currently in use */ + +}; +typedef struct prof_data *prof_data_t; +#define NULLPBUF ((prof_data_t) 0) +typedef struct buffer *buffer_t; + +/* Macros */ + +#define set_pbuf_nb(pbuf, nb) \ + (((nb) >= 0 && (nb) < NB_PROF_BUFFER) \ + ? (pbuf)->prof_index = (nb), 1 \ + : 0) + + +#define get_pbuf_nb(pbuf) \ + (pbuf)->prof_index + + +extern vm_map_t kernel_map; + +#define dealloc_pbuf_area(pbuf) \ + { \ + register int i; \ + \ + for(i=0; i < NB_PROF_BUFFER ; i++) \ + kmem_free(kernel_map, \ + (vm_offset_t) (pbuf)->prof_area[i].p_zone, \ + SIZE_PROF_BUFFER*sizeof(int)); \ + kmem_free(kernel_map, \ + (vm_offset_t)(pbuf), \ + sizeof(struct prof_data)); \ + } + + +#define alloc_pbuf_area(pbuf, vmpbuf) \ + (vmpbuf) = (vm_offset_t) 0; \ + if (kmem_alloc(kernel_map, &(vmpbuf) , sizeof(struct prof_data)) == \ + KERN_SUCCESS) { \ + register int i; \ + register boolean_t end; \ + \ + (pbuf) = (prof_data_t) (vmpbuf); \ + for(i=0, end=FALSE; i < NB_PROF_BUFFER && end == FALSE; i++) { \ + (vmpbuf) = (vm_offset_t) 0; \ + if (kmem_alloc(kernel_map,&(vmpbuf),SIZE_PROF_BUFFER*sizeof(int)) == KERN_SUCCESS) { \ + (pbuf)->prof_area[i].p_zone = (int *) (vmpbuf); \ + (pbuf)->prof_area[i].p_full = FALSE; \ + } \ + else { \ + (pbuf) = NULLPBUF; \ + end = TRUE; \ + } \ + } \ + } \ + else \ + (pbuf) = NULLPBUF; + + + +/* MACRO set_pbuf_value +** +** enters the value 'val' in the buffer 'pbuf' and returns the following +** indications: 0: means that a fatal error occurred: the buffer was full +** (it hasn't been sent yet) +** 1: means that a value has been inserted successfully +** 2: means that we'v just entered the last value causing +** the current buffer to be full.(must switch to +** another buffer and signal the sender to send it) +*/ + +#define set_pbuf_value(pbuf, val) \ + { \ + register buffer_t a = &((pbuf)->prof_area[(pbuf)->prof_index]); \ + register int i = a->p_index++; \ + register boolean_t f = a->p_full; \ + \ + if (f == TRUE ) \ + *(val) = 0; \ + else { \ + a->p_zone[i] = *(val); \ + if (i == SIZE_PROF_BUFFER-1) { \ + a->p_full = TRUE; \ + *(val) = 2; \ + } \ + else \ + *(val) = 1; \ + } \ + } + + +#define reset_pbuf_area(pbuf) \ + { \ + register int *i = &((pbuf)->prof_index); \ + \ + *i = (*i == NB_PROF_BUFFER-1) ? 0 : ++(*i); \ + (pbuf)->prof_area[*i].p_index = 0; \ + } + + +/**************************************************************/ +/* Structure, elements used for queuing operations on buffers */ +/**************************************************************/ + +#define thread_t int * +/* +** This must be done in order to avoid a circular inclusion +** with file kern/thread.h . +** When using this data structure, one must cast the actual +** type, this is (int *) or (thread_t) +*/ + +struct buf_to_send { + queue_chain_t list; + thread_t thread; + int number; /* the number of the buffer to be sent */ + char wakeme; /* do wakeup when buffer has been sent */ + } ; + +#undef thread_t + + + +typedef struct buf_to_send *buf_to_send_t; + +#define NULLBTS ((buf_to_send_t) 0) + +/* +** Global variable: the head of the queue of buffers to send +** It is a queue with locks (uses macros from queue.h) and it +** is shared by hardclock() and the sender_thread() +*/ + +mpqueue_head_t prof_queue; + +#endif /* _MACH_PROF_H_ */ diff --git a/include/mach/profilparam.h b/include/mach/profilparam.h new file mode 100644 index 0000000..20a8aaf --- /dev/null +++ b/include/mach/profilparam.h @@ -0,0 +1,62 @@ +/* + * 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. + */ + +/* + * Copyright 1991 by Open Software Foundation, + * Grenoble, FRANCE + * + * All Rights Reserved + * + * Permission to use, copy, modify, and distribute this software and + * its documentation for any purpose and without fee is hereby granted, + * provided that the above copyright notice appears in all copies and + * that both the copyright notice and this permission notice appear in + * supporting documentation, and that the name of OSF or Open Software + * Foundation not be used in advertising or publicity pertaining to + * distribution of the software without specific, written prior + * permission. + * + * OSF DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE + * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, + * IN NO EVENT SHALL OSF BE LIABLE FOR ANY SPECIAL, INDIRECT, OR + * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM + * LOSS OF USE, DATA OR PROFITS, WHETHER IN ACTION OF CONTRACT, + * NEGLIGENCE, OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION + * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + */ + +#ifndef _MACH_PROFILPARAM_H_ +#define _MACH_PROFILPARAM_H_ + +/* + * These values are also used when compiling the server, be careful ! + */ + +#define NB_PROF_BUFFER 2 /* number of buffers servicing a + * profiled thread */ +#define SIZE_PROF_BUFFER 100 /* size of a profil buffer (in int) */ + +#endif /* _MACH_PROFILPARAM_H_ */ diff --git a/include/mach/std_types.defs b/include/mach/std_types.defs new file mode 100644 index 0000000..b461f06 --- /dev/null +++ b/include/mach/std_types.defs @@ -0,0 +1,101 @@ +/* + * 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. + */ +/* + * Mach kernel standard interface type declarations + */ + +#ifndef _MACH_STD_TYPES_DEFS_ +#define _MACH_STD_TYPES_DEFS_ + +type int32_t = MACH_MSG_TYPE_INTEGER_32; +type int64_t = MACH_MSG_TYPE_INTEGER_64; +type boolean_t = MACH_MSG_TYPE_BOOLEAN; +type unsigned = MACH_MSG_TYPE_INTEGER_32; +type uint32_t = MACH_MSG_TYPE_INTEGER_32; +type uint64_t = MACH_MSG_TYPE_INTEGER_64; + +/* Get the definitions for natural_t and integer_t */ +#include <mach/machine/machine_types.defs> + +type kern_return_t = int; + +type pointer_t = ^array[] of MACH_MSG_TYPE_BYTE + ctype: vm_offset_t; + + +type mach_port_t = MACH_MSG_TYPE_COPY_SEND +#ifndef KERNEL_SERVER +#ifdef MACH_PAYLOAD_TO_PORT + intranpayload: mach_port_t MACH_PAYLOAD_TO_PORT +#endif /* MACH_PAYLOAD_TO_PORT */ +#endif /* KERNEL_SERVER */ +; +type mach_port_array_t = array[] of mach_port_t; + +type mach_port_name_t = MACH_MSG_TYPE_PORT_NAME; +type mach_port_name_array_t = array[] of mach_port_name_t; + +type mach_port_right_t = natural_t; + +type mach_port_type_t = natural_t; +type mach_port_type_array_t = array[] of mach_port_type_t; + +type mach_port_urefs_t = natural_t; +type mach_port_delta_t = integer_t; +type mach_port_seqno_t = natural_t; +type mach_port_mscount_t = unsigned; +type mach_port_msgcount_t = unsigned; +type mach_port_rights_t = unsigned; +type mach_msg_id_t = integer_t; +type mach_msg_type_name_t = unsigned; +type mach_msg_type_number_t = natural_t; + +type mach_port_move_receive_t = MACH_MSG_TYPE_MOVE_RECEIVE + ctype: mach_port_t; +type mach_port_copy_send_t = MACH_MSG_TYPE_COPY_SEND + ctype: mach_port_t; +type mach_port_make_send_t = MACH_MSG_TYPE_MAKE_SEND + ctype: mach_port_t; +type mach_port_move_send_t = MACH_MSG_TYPE_MOVE_SEND + ctype: mach_port_t; +type mach_port_make_send_once_t = MACH_MSG_TYPE_MAKE_SEND_ONCE + ctype: mach_port_t; +type mach_port_move_send_once_t = MACH_MSG_TYPE_MOVE_SEND_ONCE + ctype: mach_port_t; + +type mach_port_receive_t = MACH_MSG_TYPE_PORT_RECEIVE + ctype: mach_port_t; +type mach_port_send_t = MACH_MSG_TYPE_PORT_SEND + ctype: mach_port_t; +type mach_port_send_once_t = MACH_MSG_TYPE_PORT_SEND_ONCE + ctype: mach_port_t; + +type mach_port_poly_t = polymorphic + ctype: mach_port_t; + +import <mach/std_types.h>; + +#endif /* _MACH_STD_TYPES_DEFS_ */ diff --git a/include/mach/std_types.h b/include/mach/std_types.h new file mode 100644 index 0000000..0d5db0a --- /dev/null +++ b/include/mach/std_types.h @@ -0,0 +1,44 @@ +/* + * Mach Operating System + * Copyright (c) 1992,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. + */ +/* + * Mach standard external interface type definitions. + * + */ + +#ifndef _MACH_STD_TYPES_H_ +#define _MACH_STD_TYPES_H_ + +#define EXPORT_BOOLEAN + +#include <mach/boolean.h> +#include <mach/kern_return.h> +#include <mach/port.h> +#include <mach/machine/vm_types.h> + +typedef vm_offset_t pointer_t; +typedef vm_offset_t vm_address_t; + +#endif /* _MACH_STD_TYPES_H_ */ diff --git a/include/mach/syscall_sw.h b/include/mach/syscall_sw.h new file mode 100644 index 0000000..89597e9 --- /dev/null +++ b/include/mach/syscall_sw.h @@ -0,0 +1,121 @@ +/* + * 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_SYSCALL_SW_H_ +#define _MACH_SYSCALL_SW_H_ + +/* + * The machine-dependent "syscall_sw.h" file should + * define a macro for + * kernel_trap(trap_name, trap_number, arg_count) + * which will expand into assembly code for the + * trap. + * + * N.B.: When adding calls, do not put spaces in the macros. + */ + +#include <mach/machine/syscall_sw.h> + +/* + * These trap numbers should be taken from the + * table in <kern/syscall_sw.c>. + */ + +kernel_trap(evc_wait,-17,1) +kernel_trap(evc_wait_clear,-18,1) + +kernel_trap(mach_msg_trap,-25,7) +kernel_trap(mach_reply_port,-26,0) +kernel_trap(mach_thread_self,-27,0) +kernel_trap(mach_task_self,-28,0) +kernel_trap(mach_host_self,-29,0) +kernel_trap(mach_print,-30,1) + +kernel_trap(swtch_pri,-59,1) +kernel_trap(swtch,-60,0) +kernel_trap(thread_switch,-61,3) +kernel_trap(nw_update,-80,3) +kernel_trap(nw_lookup,-81,2) +kernel_trap(nw_endpoint_allocate,-82,4) +kernel_trap(nw_endpoint_deallocate,-83,1) +kernel_trap(nw_buffer_allocate,-84,2) +kernel_trap(nw_buffer_deallocate,-85,2) +kernel_trap(nw_connection_open,-86,4) +kernel_trap(nw_connection_accept,-87,3) +kernel_trap(nw_connection_close,-88,1) +kernel_trap(nw_multicast_add,-89,4) +kernel_trap(nw_multicast_drop,-90,4) +kernel_trap(nw_endpoint_status,-91,3) +kernel_trap(nw_send,-92,3) +kernel_trap(nw_receive,-93,2) +kernel_trap(nw_rpc,-94,4) +kernel_trap(nw_select,-95,3) + + +/* + * These are syscall versions of Mach kernel calls. + * They only work on local tasks. + */ + +kernel_trap(syscall_vm_map,-64,11) +kernel_trap(syscall_vm_allocate,-65,4) +kernel_trap(syscall_vm_deallocate,-66,3) + +kernel_trap(syscall_task_create,-68,3) +kernel_trap(syscall_task_terminate,-69,1) +kernel_trap(syscall_task_suspend,-70,1) +kernel_trap(syscall_task_set_special_port,-71,3) + +kernel_trap(syscall_mach_port_allocate,-72,3) +kernel_trap(syscall_mach_port_deallocate,-73,2) +kernel_trap(syscall_mach_port_insert_right,-74,4) +kernel_trap(syscall_mach_port_allocate_name,-75,3) +kernel_trap(syscall_thread_depress_abort,-76,1) + +/* These are screwing up glibc somehow. */ +/*kernel_trap(syscall_device_writev_request,-39,6)*/ +/*kernel_trap(syscall_device_write_request,-40,6)*/ + +/* + * These "Mach" traps are not implemented by the kernel; + * the emulation library and Unix server implement them. + * But they are traditionally part of libmach, and use + * the Mach trap calling conventions and numbering. + */ + +#if UNIXOID_TRAPS + +kernel_trap(task_by_pid,-33,1) +kernel_trap(pid_by_task,-34,4) +kernel_trap(init_process,-41,0) +kernel_trap(map_fd,-43,5) +kernel_trap(rfs_make_symlink,-44,3) +kernel_trap(htg_syscall,-52,3) +kernel_trap(set_ras_address,-53,2) + +#endif /* UNIXOID_TRAPS */ + +#endif /* _MACH_SYSCALL_SW_H_ */ diff --git a/include/mach/task_info.h b/include/mach/task_info.h new file mode 100644 index 0000000..0e048c5 --- /dev/null +++ b/include/mach/task_info.h @@ -0,0 +1,126 @@ +/* + * Mach Operating System + * Copyright (c) 1993-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. + */ +/* + * Machine-independent task information structures and definitions. + * + * The definitions in this file are exported to the user. The kernel + * will translate its internal data structures to these structures + * as appropriate. + * + */ + +#ifndef _MACH_TASK_INFO_H_ +#define _MACH_TASK_INFO_H_ + +#include <mach/machine/vm_types.h> +#include <mach/time_value.h> + +/* + * Generic information structure to allow for expansion. + */ +typedef integer_t *task_info_t; /* varying array of int */ + +#define TASK_INFO_MAX (1024) /* maximum array size */ +typedef integer_t task_info_data_t[TASK_INFO_MAX]; + +/* + * Currently defined information structures. + */ +#define TASK_BASIC_INFO 1 /* basic information */ + +struct task_basic_info { + integer_t suspend_count; /* suspend count for task */ + integer_t base_priority; /* base scheduling priority */ + rpc_vm_size_t virtual_size; /* number of virtual pages */ + rpc_vm_size_t resident_size; /* number of resident pages */ + /* Deprecated, please use user_time64 */ + rpc_time_value_t user_time; /* total user run time for + terminated threads */ + /* Deprecated, please use system_time64 */ + rpc_time_value_t system_time; /* total system run time for + terminated threads */ + /* Deprecated, please use creation_time64 */ + rpc_time_value_t creation_time; /* creation time stamp */ + time_value64_t user_time64; /* total user run time for + terminated threads */ + time_value64_t system_time64; /* total system run time for + terminated threads */ + time_value64_t creation_time64; /* creation time stamp */ +}; + +typedef struct task_basic_info task_basic_info_data_t; +typedef struct task_basic_info *task_basic_info_t; +#define TASK_BASIC_INFO_COUNT \ + (sizeof(task_basic_info_data_t) / sizeof(integer_t)) + + +#define TASK_EVENTS_INFO 2 /* various event counts */ + +struct task_events_info { + rpc_long_natural_t faults; /* number of page faults */ + rpc_long_natural_t zero_fills; /* number of zero fill pages */ + rpc_long_natural_t reactivations; /* number of reactivated pages */ + rpc_long_natural_t pageins; /* number of actual pageins */ + rpc_long_natural_t cow_faults; /* number of copy-on-write faults */ + rpc_long_natural_t messages_sent; /* number of messages sent */ + rpc_long_natural_t messages_received; /* number of messages received */ +}; +typedef struct task_events_info task_events_info_data_t; +typedef struct task_events_info *task_events_info_t; +#define TASK_EVENTS_INFO_COUNT \ + (sizeof(task_events_info_data_t) / sizeof(integer_t)) + +#define TASK_THREAD_TIMES_INFO 3 /* total times for live threads - + only accurate if suspended */ + +struct task_thread_times_info { + /* Deprecated, please use user_time64 */ + rpc_time_value_t user_time; /* total user run time for + live threads */ + /* Deprecated, please use system_time64 */ + rpc_time_value_t system_time; /* total system run time for + live threads */ + time_value64_t user_time64; /* total user run time for + live threads */ + time_value64_t system_time64; /* total system run time for + live threads */ +}; + +typedef struct task_thread_times_info task_thread_times_info_data_t; +typedef struct task_thread_times_info *task_thread_times_info_t; +#define TASK_THREAD_TIMES_INFO_COUNT \ + (sizeof(task_thread_times_info_data_t) / sizeof(integer_t)) + +/* + * Flavor definitions for task_ras_control + */ +#define TASK_RAS_CONTROL_PURGE_ALL 0 +#define TASK_RAS_CONTROL_PURGE_ONE 1 +#define TASK_RAS_CONTROL_PURGE_ALL_AND_INSTALL_ONE 2 +#define TASK_RAS_CONTROL_INSTALL_ONE 3 + +#endif /* _MACH_TASK_INFO_H_ */ + diff --git a/include/mach/task_notify.defs b/include/mach/task_notify.defs new file mode 100644 index 0000000..a4aff67 --- /dev/null +++ b/include/mach/task_notify.defs @@ -0,0 +1,59 @@ +/* + * Copyright (C) 2014 Free Software Foundation + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + */ + +subsystem +#if KERNEL_SERVER + KernelServer +#endif /* KERNEL_SERVER */ +#if KERNEL_USER + KernelUser +#endif /* KERNEL_USER */ + task_notify 4400; + +#include <mach/std_types.defs> +#include <mach/mach_types.defs> + +type task_notify_port_t = mach_port_t + ctype: mach_port_t +#ifdef TASK_NOTIFY_INTRAN + intran: TASK_NOTIFY_INTRAN +#endif +#ifdef TASK_NOTIFY_INTRAN_PAYLOAD + intranpayload: TASK_NOTIFY_INTRAN_PAYLOAD +#endif +#ifdef TASK_NOTIFY_OUTTRAN + outtran: TASK_NOTIFY_OUTTRAN +#endif +#ifdef TASK_NOTIFY_DESTRUCTOR + destructor: TASK_NOTIFY_DESTRUCTOR +#endif +; + +#ifdef TASK_NOTIFY_IMPORTS +TASK_NOTIFY_IMPORTS +#endif + +type task_move_t = MACH_MSG_TYPE_MOVE_SEND + ctype: mach_port_t; + +/* These notifications are sent to the port registered via + `register_new_task_notification' and provide a robust parental + relation between tasks. */ +simpleroutine mach_notify_new_task( + notify : task_notify_port_t; + task : task_move_t; + parent : task_move_t); diff --git a/include/mach/task_special_ports.h b/include/mach/task_special_ports.h new file mode 100644 index 0000000..42ecc15 --- /dev/null +++ b/include/mach/task_special_ports.h @@ -0,0 +1,66 @@ +/* + * 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/task_special_ports.h + * + * Defines codes for special_purpose task ports. These are NOT + * port identifiers - they are only used for the task_get_special_port + * and task_set_special_port routines. + * + */ + +#ifndef _MACH_TASK_SPECIAL_PORTS_H_ +#define _MACH_TASK_SPECIAL_PORTS_H_ + +#define TASK_KERNEL_PORT 1 /* Represents task to the outside + world.*/ +#define TASK_EXCEPTION_PORT 3 /* Exception messages for task are + sent to this port. */ +#define TASK_BOOTSTRAP_PORT 4 /* Bootstrap environment for task. */ + +/* + * Definitions for ease of use + */ + +#define task_get_kernel_port(task, port) \ + (task_get_special_port((task), TASK_KERNEL_PORT, (port))) + +#define task_set_kernel_port(task, port) \ + (task_set_special_port((task), TASK_KERNEL_PORT, (port))) + +#define task_get_exception_port(task, port) \ + (task_get_special_port((task), TASK_EXCEPTION_PORT, (port))) + +#define task_set_exception_port(task, port) \ + (task_set_special_port((task), TASK_EXCEPTION_PORT, (port))) + +#define task_get_bootstrap_port(task, port) \ + (task_get_special_port((task), TASK_BOOTSTRAP_PORT, (port))) + +#define task_set_bootstrap_port(task, port) \ + (task_set_special_port((task), TASK_BOOTSTRAP_PORT, (port))) + +#endif /* _MACH_TASK_SPECIAL_PORTS_H_ */ diff --git a/include/mach/thread_info.h b/include/mach/thread_info.h new file mode 100644 index 0000000..4f322e0 --- /dev/null +++ b/include/mach/thread_info.h @@ -0,0 +1,124 @@ +/* + * 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/thread_info + * + * Thread information structure and definitions. + * + * The defintions in this file are exported to the user. The kernel + * will translate its internal data structures to these structures + * as appropriate. + * + */ + +#ifndef _MACH_THREAD_INFO_H_ +#define _MACH_THREAD_INFO_H_ + +#include <mach/boolean.h> +#include <mach/policy.h> +#include <mach/time_value.h> + +/* + * Generic information structure to allow for expansion. + */ +typedef integer_t *thread_info_t; /* varying array of ints */ + +#define THREAD_INFO_MAX (1024) /* maximum array size */ +typedef integer_t thread_info_data_t[THREAD_INFO_MAX]; + +/* + * Currently defined information. + */ +#define THREAD_BASIC_INFO 1 /* basic information */ + +struct thread_basic_info { + /* Deprecated, please use user_time64 */ + rpc_time_value_t user_time; /* user run time */ + /* Deprecated, please use system_time64 */ + rpc_time_value_t system_time; /* system run time */ + integer_t cpu_usage; /* scaled cpu usage percentage */ + integer_t base_priority; /* base scheduling priority */ + integer_t cur_priority; /* current scheduling priority */ + integer_t run_state; /* run state (see below) */ + integer_t flags; /* various flags (see below) */ + integer_t suspend_count; /* suspend count for thread */ + integer_t sleep_time; /* number of seconds that thread + has been sleeping */ + /* Deprecated, please use creation_time64 */ + rpc_time_value_t creation_time; /* time stamp of creation */ + time_value64_t user_time64; /* user run time */ + time_value64_t system_time64; /* system run time */ + time_value64_t creation_time64; /* time stamp of creation */ +}; + +typedef struct thread_basic_info thread_basic_info_data_t; +typedef struct thread_basic_info *thread_basic_info_t; +#define THREAD_BASIC_INFO_COUNT \ + (sizeof(thread_basic_info_data_t) / sizeof(natural_t)) + +/* + * Scale factor for usage field. + */ + +#define TH_USAGE_SCALE 1000 + +/* + * Thread run states (state field). + */ + +#define TH_STATE_RUNNING 1 /* thread is running normally */ +#define TH_STATE_STOPPED 2 /* thread is stopped */ +#define TH_STATE_WAITING 3 /* thread is waiting normally */ +#define TH_STATE_UNINTERRUPTIBLE 4 /* thread is in an uninterruptible + wait */ +#define TH_STATE_HALTED 5 /* thread is halted at a + clean point */ + +/* + * Thread flags (flags field). + */ +#define TH_FLAGS_SWAPPED 0x1 /* thread is swapped out */ +#define TH_FLAGS_IDLE 0x2 /* thread is an idle thread */ + +#define THREAD_SCHED_INFO 2 + +struct thread_sched_info { + integer_t policy; /* scheduling policy */ + integer_t data; /* associated data */ + integer_t base_priority; /* base priority */ + integer_t max_priority; /* max priority */ + integer_t cur_priority; /* current priority */ +/*boolean_t*/integer_t depressed; /* depressed ? */ + integer_t depress_priority; /* priority depressed from */ + integer_t last_processor; /* last processor used by the thread */ +}; + +typedef struct thread_sched_info thread_sched_info_data_t; +typedef struct thread_sched_info *thread_sched_info_t; +#define THREAD_SCHED_INFO_COUNT \ + (sizeof(thread_sched_info_data_t) / sizeof(natural_t)) + +#endif /* _MACH_THREAD_INFO_H_ */ diff --git a/include/mach/thread_special_ports.h b/include/mach/thread_special_ports.h new file mode 100644 index 0000000..33e3a1f --- /dev/null +++ b/include/mach/thread_special_ports.h @@ -0,0 +1,59 @@ +/* + * 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/thread_special_ports.h + * + * Defines codes for special_purpose thread ports. These are NOT + * port identifiers - they are only used for the thread_get_special_port + * and thread_set_special_port routines. + * + */ + +#ifndef _MACH_THREAD_SPECIAL_PORTS_H_ +#define _MACH_THREAD_SPECIAL_PORTS_H_ + +#define THREAD_KERNEL_PORT 1 /* Represents the thread to the outside + world.*/ +#define THREAD_EXCEPTION_PORT 3 /* Exception messages for the thread + are sent to this port. */ + +/* + * Definitions for ease of use + */ + +#define thread_get_kernel_port(thread, port) \ + (thread_get_special_port((thread), THREAD_KERNEL_PORT, (port))) + +#define thread_set_kernel_port(thread, port) \ + (thread_set_special_port((thread), THREAD_KERNEL_PORT, (port))) + +#define thread_get_exception_port(thread, port) \ + (thread_get_special_port((thread), THREAD_EXCEPTION_PORT, (port))) + +#define thread_set_exception_port(thread, port) \ + (thread_set_special_port((thread), THREAD_EXCEPTION_PORT, (port))) + +#endif /* _MACH_THREAD_SPECIAL_PORTS_H_ */ diff --git a/include/mach/thread_status.h b/include/mach/thread_status.h new file mode 100644 index 0000000..b02f5b4 --- /dev/null +++ b/include/mach/thread_status.h @@ -0,0 +1,55 @@ +/* + * Mach Operating System + * Copyright (c) 1993-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. + */ +/* + * + * This file contains the structure definitions for the user-visible + * thread state. This thread state is examined with the thread_get_state + * kernel call and may be changed with the thread_set_state kernel call. + * + */ + +#ifndef _MACH_THREAD_STATUS_H_ +#define _MACH_THREAD_STATUS_H_ + +/* + * The actual structure that comprises the thread state is defined + * in the machine dependent module. + */ +#include <mach/machine/vm_types.h> +#include <mach/machine/thread_status.h> + +/* + * Generic definition for machine-dependent thread status. + */ + +typedef natural_t *thread_state_t; /* Variable-length array */ + +#define THREAD_STATE_MAX (1024) /* Maximum array size */ +typedef natural_t thread_state_data_t[THREAD_STATE_MAX]; + +#define THREAD_STATE_FLAVOR_LIST 0 /* List of valid flavors */ + +#endif /* _MACH_THREAD_STATUS_H_ */ diff --git a/include/mach/thread_switch.h b/include/mach/thread_switch.h new file mode 100644 index 0000000..5235b87 --- /dev/null +++ b/include/mach/thread_switch.h @@ -0,0 +1,40 @@ +/* + * 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 _MACH_THREAD_SWITCH_H_ +#define _MACH_THREAD_SWITCH_H_ + +/* + * Constant definitions for thread_switch trap. + */ + +#define SWITCH_OPTION_NONE 0 +#define SWITCH_OPTION_DEPRESS 1 +#define SWITCH_OPTION_WAIT 2 + +#define valid_switch_option(opt) ((0 <= (opt)) && ((opt) <= 2)) + +#endif /* _MACH_THREAD_SWITCH_H_ */ diff --git a/include/mach/time_value.h b/include/mach/time_value.h new file mode 100644 index 0000000..e08707b --- /dev/null +++ b/include/mach/time_value.h @@ -0,0 +1,201 @@ +/* + * 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_TIME_VALUE_H_ +#define _MACH_TIME_VALUE_H_ + +#include <mach/machine/vm_types.h> + +/* + * Time value returned by kernel. + */ + +struct rpc_time_value { + /* TODO: this should be 64 bits regardless of the arch to be Y2038 proof. */ + rpc_long_integer_t seconds; + integer_t microseconds; +}; + +/* + * Time value used by kernel interfaces. Ideally they should be migrated + * to use time_value64 below. + */ +struct time_value { + long_integer_t seconds; + integer_t microseconds; +}; +typedef struct time_value time_value_t; + +#ifdef KERNEL +typedef struct rpc_time_value rpc_time_value_t; +#else +typedef struct time_value rpc_time_value_t; +#endif + +/* + * Time value used internally by the kernel that uses 64 bits to track seconds + * and nanoseconds. Note that the current resolution is only microseconds. + */ +struct time_value64 { + int64_t seconds; + int64_t nanoseconds; +}; +typedef struct time_value64 time_value64_t; + +/** + * Functions used by Mig to perform user to kernel conversion and vice-versa. + * We only do this because we may run a 64 bit kernel with a 32 bit user space. + */ +static __inline__ rpc_time_value_t convert_time_value_to_user(time_value_t tv) +{ + rpc_time_value_t user = {.seconds = tv.seconds, .microseconds = tv.microseconds}; + return user; +} +static __inline__ time_value_t convert_time_value_from_user(rpc_time_value_t tv) +{ + time_value_t kernel = {.seconds = tv.seconds, .microseconds = tv.microseconds}; + return kernel; +} + +/* + * Macros to manipulate time values. Assume that time values + * are normalized (microseconds <= 999999). + */ +#define TIME_MICROS_MAX (1000000) +#define TIME_NANOS_MAX (1000000000) + +#define time_value_assert(val) \ + assert(0 <= (val)->microseconds && (val)->microseconds < TIME_MICROS_MAX); + +#define time_value64_assert(val) \ + assert(0 <= (val)->nanoseconds && (val)->nanoseconds < TIME_NANOS_MAX); + +#define time_value_add_usec(val, micros) { \ + time_value_assert(val); \ + if (((val)->microseconds += (micros)) \ + >= TIME_MICROS_MAX) { \ + (val)->microseconds -= TIME_MICROS_MAX; \ + (val)->seconds++; \ + } \ + time_value_assert(val); \ +} + +#define time_value64_add_nanos(val, nanos) { \ + time_value64_assert(val); \ + if (((val)->nanoseconds += (nanos)) \ + >= TIME_NANOS_MAX) { \ + (val)->nanoseconds -= TIME_NANOS_MAX; \ + (val)->seconds++; \ + } \ + time_value64_assert(val); \ +} + +#define time_value64_sub_nanos(val, nanos) { \ + time_value64_assert(val); \ + if (((val)->nanoseconds -= (nanos)) < 0) { \ + (val)->nanoseconds += TIME_NANOS_MAX; \ + (val)->seconds--; \ + } \ + time_value64_assert(val); \ +} + +#define time_value_add(result, addend) { \ + time_value_assert(addend); \ + (result)->seconds += (addend)->seconds; \ + time_value_add_usec(result, (addend)->microseconds); \ + } + +#define time_value64_add(result, addend) { \ + time_value64_assert(addend); \ + (result)->seconds += (addend)->seconds; \ + time_value64_add_nanos(result, (addend)->nanoseconds); \ + } + +#define time_value64_sub(result, subtrahend) { \ + time_value64_assert(subtrahend); \ + (result)->seconds -= (subtrahend)->seconds; \ + time_value64_sub_nanos(result, (subtrahend)->nanoseconds); \ + } + +#define time_value64_init(tv) { \ + (tv)->seconds = 0; \ + (tv)->nanoseconds = 0; \ + } + +#define TIME_VALUE64_TO_TIME_VALUE(tv64, tv) do { \ + (tv)->seconds = (tv64)->seconds; \ + (tv)->microseconds = (tv64)->nanoseconds / 1000; \ +} while(0) + +#define TIME_VALUE_TO_TIME_VALUE64(tv, tv64) do { \ + (tv64)->seconds = (tv)->seconds; \ + (tv64)->nanoseconds = (tv)->microseconds * 1000; \ +} while(0) + +/* + * Time value available through the mapped-time interface. + * Read this mapped value with + * do { + * secs = mtime->seconds; + * __sync_synchronize(); + * usecs = mtime->microseconds; + * __sync_synchronize(); + * } while (secs != mtime->check_seconds); + */ + +typedef struct mapped_time_value { + integer_t seconds; + integer_t microseconds; + integer_t check_seconds; + struct time_value64 time_value; + int64_t check_seconds64; +} mapped_time_value_t; + +/* Macros for converting between struct timespec and time_value_t. */ + +#define TIME_VALUE_TO_TIMESPEC(tv, ts) do { \ + (ts)->tv_sec = (tv)->seconds; \ + (ts)->tv_nsec = (tv)->microseconds * 1000; \ +} while(0) + +#define TIMESPEC_TO_TIME_VALUE(tv, ts) do { \ + (tv)->seconds = (ts)->tv_sec; \ + (tv)->microseconds = (ts)->tv_nsec / 1000; \ +} while(0) + +/* Macros for converting between struct timespec and time_value64_t. */ + +#define TIME_VALUE64_TO_TIMESPEC(tv, ts) do { \ + (ts)->tv_sec = (tv)->seconds; \ + (ts)->tv_nsec = (tv)->nanoseconds; \ +} while(0) + +#define TIMESPEC_TO_TIME_VALUE64(tv, ts) do { \ + (tv)->seconds = (ts)->tv_sec; \ + (tv)->nanoseconds = (ts)->tv_nsec; \ +} while(0) + +#endif /* _MACH_TIME_VALUE_H_ */ diff --git a/include/mach/version.h b/include/mach/version.h new file mode 100644 index 0000000..3ef7859 --- /dev/null +++ b/include/mach/version.h @@ -0,0 +1,73 @@ +/* + * 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 rights + * to redistribute these changes. + */ +/* + * Each kernel has a major and minor version number. Changes in + * the major number in general indicate a change in exported features. + * Changes in minor number usually correspond to internal-only + * changes that the user need not be aware of (in general). These + * values are stored at boot time in the machine_info strucuture and + * can be obtained by user programs with the host_info kernel call. + * This mechanism is intended to be the formal way for Mach programs + * to provide for backward compatibility in future releases. + * + * [ This needs to be reconciled somehow with the major/minor version + * number stuffed into the version string - mja, 5/8/87 ] + * + * Following is an informal history of the numbers: + * + * 25-March-87 Avadis Tevanian, Jr. + * Created version numbering scheme. Started with major 1, + * minor 0. + */ + +#ifndef _MACH_VERSION_H_ +#define _MACH_VERSION_H_ + +#define KERNEL_MAJOR_VERSION 4 +#define KERNEL_MINOR_VERSION 0 + +/* + * Version number of the kernel include files. + * + * This number must be changed whenever an incompatible change is made to one + * or more of our include files which are used by application programs that + * delve into kernel memory. The number should normally be simply incremented + * but may actually be changed in any manner so long as it differs from the + * numbers previously assigned to any other versions with which the current + * version is incompatible. It is used at boot time to determine which + * versions of the system programs to install. + * + * Note that the symbol _INCLUDE_VERSION must be set to this in the symbol + * table. On the VAX for example, this is done in locore.s. + */ + +/* + * Current allocation strategy: bump either branch by 2, until non-MACH is + * excised from the CSD environment. + */ +#define INCLUDE_VERSION 0 + +#endif /* _MACH_VERSION_H_ */ diff --git a/include/mach/vm_attributes.h b/include/mach/vm_attributes.h new file mode 100644 index 0000000..9ca3ef5 --- /dev/null +++ b/include/mach/vm_attributes.h @@ -0,0 +1,63 @@ +/* + * 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/vm_attributes.h + * Author: Alessandro Forin + * + * Virtual memory attributes definitions. + * + * These definitions are in addition to the machine-independent + * ones (e.g. protection), and are only selectively supported + * on specific machine architectures. + * + */ + +#ifndef _MACH_VM_ATTRIBUTES_H_ +#define _MACH_VM_ATTRIBUTES_H_ + +/* + * Types of machine-dependent attributes + */ +typedef unsigned int vm_machine_attribute_t; + +#define MATTR_CACHE 1 /* cachability */ +#define MATTR_MIGRATE 2 /* migrability */ +#define MATTR_REPLICATE 4 /* replicability */ + +/* + * Values for the above, e.g. operations on attribute + */ +typedef int vm_machine_attribute_val_t; + +#define MATTR_VAL_OFF 0 /* (generic) turn attribute off */ +#define MATTR_VAL_ON 1 /* (generic) turn attribute on */ +#define MATTR_VAL_GET 2 /* (generic) return current value */ + +#define MATTR_VAL_CACHE_FLUSH 6 /* flush from all caches */ +#define MATTR_VAL_DCACHE_FLUSH 7 /* flush from data caches */ +#define MATTR_VAL_ICACHE_FLUSH 8 /* flush from instruction caches */ + +#endif /* _MACH_VM_ATTRIBUTES_H_ */ diff --git a/include/mach/vm_cache_statistics.h b/include/mach/vm_cache_statistics.h new file mode 100644 index 0000000..072976a --- /dev/null +++ b/include/mach/vm_cache_statistics.h @@ -0,0 +1,41 @@ +/* + * Copyright (C) 2012 Free Software Foundation + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ + +#ifndef _MACH_VM_CACHE_STATISTICS_H_ +#define _MACH_VM_CACHE_STATISTICS_H_ + +#include <mach/machine/vm_types.h> + +struct vm_cache_statistics { + integer_t cache_object_count; /* # of cached objects */ + integer_t cache_count; /* # of cached pages */ + integer_t active_tmp_count; /* # of active temporary pages */ + integer_t inactive_tmp_count; /* # of inactive temporary pages */ + integer_t active_perm_count; /* # of active permanent pages */ + integer_t inactive_perm_count; /* # of inactive permanent pages */ + integer_t dirty_count; /* # of dirty pages */ + integer_t laundry_count; /* # of pages being laundered */ + integer_t writeback_count; /* # of pages being written back */ + integer_t slab_count; /* # of slab allocator pages */ + integer_t slab_reclaim_count; /* # of reclaimable slab pages */ +}; + +typedef struct vm_cache_statistics *vm_cache_statistics_t; +typedef struct vm_cache_statistics vm_cache_statistics_data_t; + +#endif /* _MACH_VM_CACHE_STATISTICS_H_ */ diff --git a/include/mach/vm_inherit.h b/include/mach/vm_inherit.h new file mode 100644 index 0000000..2899290 --- /dev/null +++ b/include/mach/vm_inherit.h @@ -0,0 +1,55 @@ +/* + * 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/vm_inherit.h + * Author: Avadis Tevanian, Jr., Michael Wayne Young + * + * Virtual memory map inheritance definitions. + * + */ + +#ifndef _MACH_VM_INHERIT_H_ +#define _MACH_VM_INHERIT_H_ + +/* + * Types defined: + * + * vm_inherit_t inheritance codes. + */ + +typedef int vm_inherit_t; /* might want to change this */ + +/* + * Enumeration of valid values for vm_inherit_t. + */ + +#define VM_INHERIT_SHARE ((vm_inherit_t) 0) /* share with child */ +#define VM_INHERIT_COPY ((vm_inherit_t) 1) /* copy into child */ +#define VM_INHERIT_NONE ((vm_inherit_t) 2) /* absent from child */ + +#define VM_INHERIT_DEFAULT VM_INHERIT_COPY + +#endif /* _MACH_VM_INHERIT_H_ */ diff --git a/include/mach/vm_param.h b/include/mach/vm_param.h new file mode 100644 index 0000000..4cbd0ec --- /dev/null +++ b/include/mach/vm_param.h @@ -0,0 +1,102 @@ +/* + * 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/vm_param.h + * Author: Avadis Tevanian, Jr., Michael Wayne Young + * Date: 1985 + * + * Machine independent virtual memory parameters. + * + */ + +#ifndef _MACH_VM_PARAM_H_ +#define _MACH_VM_PARAM_H_ + +#include <mach/machine/vm_param.h> +#include <mach/machine/vm_types.h> + +/* + * The machine independent pages are referred to as PAGES. A page + * is some number of hardware pages, depending on the target machine. + * + * All references to the size of a page should be done + * with PAGE_SIZE, PAGE_SHIFT, or PAGE_MASK. + * They may be implemented as either constants or variables, + * depending on more-specific code. + * If they're variables, they had better be initialized + * by the time system-independent code starts getting called. + * + * Regardless whether it is implemented with a constant or a variable, + * the PAGE_SIZE is assumed to be a power of two throughout the + * virtual memory system implementation. + * + * More-specific code must at least provide PAGE_SHIFT; + * we can calculate the others if necessary. + * (However, if PAGE_SHIFT really refers to a variable, + * PAGE_SIZE and PAGE_MASK should also be variables + * so their values don't have to be constantly recomputed.) + */ +#ifndef PAGE_SHIFT +#error mach/machine/vm_param.h needs to define PAGE_SHIFT. +#endif + +#ifndef PAGE_SIZE +#define PAGE_SIZE (1 << PAGE_SHIFT) +#endif + +#ifndef PAGE_MASK +#define PAGE_MASK (PAGE_SIZE-1) +#endif + +/* + * Convert addresses to pages and vice versa. + * No rounding is used. + */ + +#define atop(x) (((vm_size_t)(x)) >> PAGE_SHIFT) +#define ptoa(x) ((vm_offset_t)((x) << PAGE_SHIFT)) + +/* + * Round off or truncate to the nearest page. These will work + * for either addresses or counts. (i.e. 1 byte rounds to 1 page + * bytes. + */ + +#define round_page(x) ((vm_offset_t)((((vm_offset_t)(x)) + PAGE_MASK) & ~PAGE_MASK)) +#define trunc_page(x) ((vm_offset_t)(((vm_offset_t)(x)) & ~PAGE_MASK)) + +#define round_phys(x) ((phys_addr_t)((((phys_addr_t)(x)) + PAGE_MASK) & ~PAGE_MASK)) +#define trunc_phys(x) ((phys_addr_t)(((phys_addr_t)(x)) & ~PAGE_MASK)) + +/* + * Determine whether an address is page-aligned, or a count is + * an exact page multiple. + */ + +#define page_aligned(x) ((((vm_offset_t) (x)) & PAGE_MASK) == 0) +#define phys_aligned(x) ((((phys_addr_t) (x)) & PAGE_MASK) == 0) + +#endif /* _MACH_VM_PARAM_H_ */ diff --git a/include/mach/vm_prot.h b/include/mach/vm_prot.h new file mode 100644 index 0000000..22a76a8 --- /dev/null +++ b/include/mach/vm_prot.h @@ -0,0 +1,79 @@ +/* + * 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/vm_prot.h + * Author: Avadis Tevanian, Jr., Michael Wayne Young + * + * Virtual memory protection definitions. + * + */ + +#ifndef _MACH_VM_PROT_H_ +#define _MACH_VM_PROT_H_ + +/* + * Types defined: + * + * vm_prot_t VM protection values. + */ + +typedef int vm_prot_t; + +/* + * Protection values, defined as bits within the vm_prot_t type + */ + +#define VM_PROT_NONE ((vm_prot_t) 0x00) + +#define VM_PROT_READ ((vm_prot_t) 0x01) /* read permission */ +#define VM_PROT_WRITE ((vm_prot_t) 0x02) /* write permission */ +#define VM_PROT_EXECUTE ((vm_prot_t) 0x04) /* execute permission */ + +/* + * The default protection for newly-created virtual memory + */ + +#define VM_PROT_DEFAULT (VM_PROT_READ|VM_PROT_WRITE) + +/* + * The maximum privileges possible, for parameter checking. + */ + +#define VM_PROT_ALL (VM_PROT_READ|VM_PROT_WRITE|VM_PROT_EXECUTE) + +/* + * An invalid protection value. + * Used only by memory_object_lock_request to indicate no change + * to page locks. Using -1 here is a bad idea because it + * looks like VM_PROT_ALL and then some. + */ +#define VM_PROT_NO_CHANGE ((vm_prot_t) 0x08) + +/* + * This protection value says whether special notification is to be used. + */ +#define VM_PROT_NOTIFY ((vm_prot_t) 0x10) +#endif /* _MACH_VM_PROT_H_ */ diff --git a/include/mach/vm_statistics.h b/include/mach/vm_statistics.h new file mode 100644 index 0000000..2039a82 --- /dev/null +++ b/include/mach/vm_statistics.h @@ -0,0 +1,75 @@ +/* + * Mach Operating System + * Copyright (c) 1993-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/vm_statistics.h + * Author: Avadis Tevanian, Jr., Michael Wayne Young, David Golub + * + * Virtual memory statistics structure. + * + */ + +#ifndef _MACH_VM_STATISTICS_H_ +#define _MACH_VM_STATISTICS_H_ + +#include <mach/machine/vm_types.h> + +struct vm_statistics { + integer_t pagesize; /* page size in bytes */ + integer_t free_count; /* # of pages free */ + integer_t active_count; /* # of pages active */ + integer_t inactive_count; /* # of pages inactive */ + integer_t wire_count; /* # of pages wired down */ + integer_t zero_fill_count; /* # of zero fill pages */ + integer_t reactivations; /* # of pages reactivated */ + integer_t pageins; /* # of pageins */ + integer_t pageouts; /* # of pageouts */ + integer_t faults; /* # of faults */ + integer_t cow_faults; /* # of copy-on-writes */ + integer_t lookups; /* object cache lookups */ + integer_t hits; /* object cache hits */ +}; + +typedef struct vm_statistics *vm_statistics_t; +typedef struct vm_statistics vm_statistics_data_t; + +#ifdef MACH_KERNEL +extern vm_statistics_data_t vm_stat; +#endif /* MACH_KERNEL */ + +/* + * Each machine dependent implementation is expected to + * keep certain statistics. They may do this anyway they + * so choose, but are expected to return the statistics + * in the following structure. + */ + +struct pmap_statistics { + integer_t resident_count; /* # of pages mapped (total)*/ + integer_t wired_count; /* # of pages wired */ +}; + +typedef struct pmap_statistics *pmap_statistics_t; +#endif /* _MACH_VM_STATISTICS_H_ */ diff --git a/include/mach/vm_sync.h b/include/mach/vm_sync.h new file mode 100644 index 0000000..0c7451c --- /dev/null +++ b/include/mach/vm_sync.h @@ -0,0 +1,45 @@ +/* + * Copyright (c) 2018 Free Software Foundation + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + * All Rights Reserved. + */ + +#ifndef _MACH_VM_SYNC_H_ +#define _MACH_VM_SYNC_H_ + +/* + * Types defined: + * + * vm_sync_t VM synchronization flags + */ + +typedef int vm_sync_t; + +/* + * Synchronization values + */ + +#define VM_SYNC_ASYNCHRONOUS ((vm_sync_t) 0x01) +#define VM_SYNC_SYNCHRONOUS ((vm_sync_t) 0x02) +#define VM_SYNC_INVALIDATE ((vm_sync_t) 0x04) +#if 0 +/* Not supported yet. */ +#define VM_SYNC_KILLPAGES ((vm_sync_t) 0x08) +#define VM_SYNC_DEACTIVATE ((vm_sync_t) 0x10) +#define VM_SYNC_CONTIGUOUS ((vm_sync_t) 0x20) +#define VM_SYNC_REUSABLEPAGES ((vm_sync_t) 0x40) +#endif + +#endif /* _MACH_VM_SYNC_H_ */ diff --git a/include/mach/vm_wire.h b/include/mach/vm_wire.h new file mode 100644 index 0000000..1552dfa --- /dev/null +++ b/include/mach/vm_wire.h @@ -0,0 +1,30 @@ +/* + * Copyright (C) 2017 Free Software Foundation + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ + +#ifndef _MACH_VM_WIRE_H_ +#define _MACH_VM_WIRE_H_ + +typedef int vm_wire_t; + +#define VM_WIRE_NONE 0 +#define VM_WIRE_CURRENT 1 +#define VM_WIRE_FUTURE 2 + +#define VM_WIRE_ALL (VM_WIRE_CURRENT | VM_WIRE_FUTURE) + +#endif /* _MACH_VM_WIRE_H_ */ diff --git a/include/mach/xen.h b/include/mach/xen.h new file mode 100644 index 0000000..4462082 --- /dev/null +++ b/include/mach/xen.h @@ -0,0 +1,95 @@ + +/* + * Copyright (C) 2006-2009, 2011 Free Software Foundation + * + * This program is free software ; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation ; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY ; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with the program ; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ + +#ifndef _MACH_XEN_H +#define _MACH_XEN_H +#ifdef MACH_XEN +#include <sys/types.h> +#include <xen/public/xen.h> +#include <i386/vm_param.h> + +extern struct start_info boot_info; + +extern volatile struct shared_info hyp_shared_info; + +#ifdef MACH_PV_PAGETABLES +/* Memory translations */ + +/* pa are physical addresses, from 0 to size of memory */ +/* ma are machine addresses, i.e. _real_ hardware adresses */ +/* la are linear addresses, i.e. without segmentation */ + +/* This might also be useful out of Xen */ +#if VM_MIN_KERNEL_ADDRESS != LINEAR_MIN_KERNEL_ADDRESS +extern unsigned long la_shift; +#else +#define la_shift LINEAR_MIN_KERNEL_ADDRESS +#endif +#define la_to_pa(a) ((vm_offset_t)(((vm_offset_t)(a)) - la_shift)) +#define pa_to_la(a) ((vm_offset_t)(((vm_offset_t)(a)) + la_shift)) + +#define kv_to_la(a) pa_to_la(_kvtophys(a)) +#define la_to_kv(a) phystokv(la_to_pa(a)) + +#ifdef MACH_PSEUDO_PHYS +#ifdef __i386__ +#if PAE +#define PFN_LIST MACH2PHYS_VIRT_START_PAE +#else +#define PFN_LIST MACH2PHYS_VIRT_START_NONPAE +#endif +#else +#define PFN_LIST MACH2PHYS_VIRT_START +#endif +#if VM_MIN_KERNEL_ADDRESS != LINEAR_MIN_KERNEL_ADDRESS +extern unsigned long *pfn_list; +#else +#define pfn_list ((unsigned long *) PFN_LIST) +#endif +#define mfn_to_pfn(n) (pfn_list[n]) + +extern unsigned long *mfn_list; +#define pfn_to_mfn(n) (mfn_list[n]) +#else +#define mfn_to_pfn(n) (n) +#define pfn_to_mfn(n) (n) +#endif /* MACH_PSEUDO_PHYS */ + +#define pa_to_mfn(a) (pfn_to_mfn(atop(a))) +#ifdef PAE +#define pa_to_ma(a) ({ vm_offset_t __a = (vm_offset_t) (a); (((pt_entry_t) pa_to_mfn(__a)) << PAGE_SHIFT) | (__a & PAGE_MASK); }) +#define ma_to_pa(a) ({ pt_entry_t __a = (pt_entry_t) (a); (mfn_to_pfn(__a >> PAGE_SHIFT) << PAGE_SHIFT) | (__a & PAGE_MASK); }) +#else +#define pa_to_ma(a) ({ vm_offset_t __a = (vm_offset_t) (a); ptoa(pa_to_mfn(__a)) | (__a & PAGE_MASK); }) +#define ma_to_pa(a) ({ vm_offset_t __a = (vm_offset_t) (a); (mfn_to_pfn(atop((__a))) << PAGE_SHIFT) | (__a & PAGE_MASK); }) +#endif + +#define kv_to_mfn(a) pa_to_mfn(_kvtophys(a)) +#define kv_to_ma(a) pa_to_ma(_kvtophys(a)) +#else /* MACH_PV_PAGETABLES */ +#define mfn_to_pfn(n) (n) +#define pfn_to_mfn(n) (n) +#endif /* MACH_PV_PAGETABLES */ + +#define mfn_to_kv(mfn) phystokv(ptoa(mfn_to_pfn(mfn))) + +#include <machine/xen.h> + +#endif /* MACH_XEN */ +#endif /* _MACH_XEN_H */ |