### Install kernel and headers with make install Source: https://ftp.gnu.org/old-gnu/Manuals/machinfo-0.3/html_mono/mach.html Installs the kernel to $(prefix)/boot/gnumach and header files to $(prefix)/include. Targets install-kernel and install-headers are also available. ```shell make install ``` -------------------------------- ### Define and use macros to traverse a list with macro Source: https://ftp.gnu.org/old-gnu/Manuals/machinfo-0.3/html_mono/mach.html Example showing how to define macros with macro and use them to print the contents of a list starting from xxx_list. The macro xinit sets a work variable, and xlist examines memory and advances the pointer. Each xlist command prints the next list element. ```ddb macro xinit set $work0 $arg1 macro xlist examine/m $work0,4; set $work0 *($work0) xinit *(xxx_list) xlist .... ``` -------------------------------- ### processor_start Source: https://ftp.gnu.org/old-gnu/Manuals/machinfo-0.3/html_mono/mach.html Starts a processor. This operation is machine-dependent and may do nothing. ```APIDOC ## processor_start ### Description Starts a processor. This operation is machine-dependent and may do nothing. A newly started processor is assigned to the default processor set. ### Function Signature ```c kern_return_t processor_start(mach_port_t processor) ``` ### Parameters - **processor** (mach_port_t) - Required - The processor port. ### Return Values - **KERN_SUCCESS** - The operation was performed. - **KERN_FAILURE** - The operation was not performed (likely not supported on this processor). - **KERN_INVALID_ARGUMENT** - processor is not a processor. - **KERN_INVALID_ADDRESS** - cmd points to inaccessible memory (if applicable). ``` -------------------------------- ### print command example with format and string Source: https://ftp.gnu.org/old-gnu/Manuals/machinfo-0.3/html_mono/mach.html Shows the print command with /x modifier and string arguments to display register values with labels. The output shows the printed result with hexadecimal values. ```gdb print/x "eax = " $eax "\necx = " $ecx "\n" ``` ```output eax = xxxxxx ecx = yyyyyy ``` -------------------------------- ### task_get_emulation_vector Source: https://ftp.gnu.org/old-gnu/Manuals/machinfo-0.3/html_mono/mach.html Gets the user-level handler entry points for all emulated system calls. ```APIDOC ## task_get_emulation_vector ### Description Gets the user-level handler entry points for all emulated system calls. ### Function Signature kern_return_t task_get_emulation_vector(mach_port_t task, int *vector_start, emulation_vector_t *emulation_vector, mach_msg_type_number_t *emulation_vectorCnt) ### Parameters - **task** (mach_port_t) - Required - The task for which to get the emulation vector. - **vector_start** (int *) - Required - Output parameter: the starting system call number. - **emulation_vector** (emulation_vector_t *) - Required - Output parameter: the array of handler entry points. - **emulation_vectorCnt** (mach_msg_type_number_t *) - Required - Output parameter: the number of entries in the vector. ### Return Value kern_return_t - The return status. ``` -------------------------------- ### vm_allocate Source: https://ftp.gnu.org/old-gnu/Manuals/machinfo-0.3/html_mono/mach.html Allocates a region of virtual memory in the specified task's address space. The starting address is given by address, and the size is given by size. If anywhere is false, memory is allocated at the given address (rounded down to a page boundary); if true, the address is ignored and memory is allocated anywhere. The actual allocated address is returned in address. Returns KERN_SUCCESS on success, KERN_INVALID_ADDRESS if an illegal address is specified, and KERN_NO_SPACE if there is not enough space. ```APIDOC ## vm_allocate ### Description Allocates a region of virtual memory in the specified task's address space. The starting address is given by address, and the size is given by size. If anywhere is false, memory is allocated at the given address (rounded down to a page boundary); if true, the address is ignored and memory is allocated anywhere. The actual allocated address is returned in address. Returns KERN_SUCCESS on success, KERN_INVALID_ADDRESS if an illegal address is specified, and KERN_NO_SPACE if there is not enough space. ### Function Signature ```c kern_return_t vm_allocate(mach_port_t target_task, vm_address_t *address, vm_size_t size, boolean_t anywhere) ``` ### Parameters - **target_task** (mach_port_t) - Required - The task in whose address space the memory is to be allocated. Use `mach_task_self()` to allocate in the caller's address space. - **address** (vm_address_t *) - Required - On input, the desired starting address if `anywhere` is false. On output, the actual address where memory was allocated. If `anywhere` is true, the input value is ignored. - **size** (vm_size_t) - Required - The number of bytes to allocate. The system rounds this up to an integral number of virtual pages. - **anywhere** (boolean_t) - Required - If false, attempt to allocate at the given address. If true, ignore the input address and allocate anywhere. ### Return Values - **KERN_SUCCESS** - Memory was successfully allocated. - **KERN_INVALID_ADDRESS** - An illegal address was specified. - **KERN_NO_SPACE** - There was not enough space to satisfy the request. ### Notes - The physical memory is not actually allocated until the new virtual memory is referenced. - The kernel rounds all addresses down to the nearest page boundary and all memory sizes up to the nearest page size. - The global variable `vm_page_size` contains the page size. - Initially, pages are protected to allow all forms of access and are inherited in child tasks as a copy. Use `vm_protect` and `vm_inherit` to change these properties. - The allocated region is always zero-filled. ``` -------------------------------- ### Set breakpoint conditions to count page faults with cond Source: https://ftp.gnu.org/old-gnu/Manuals/machinfo-0.3/html_mono/mach.html Example showing how to use cond to set breakpoint conditions and commands. It prints page fault counts from xxx_start to xxx_end in task7. The commands list is executed when the condition is true and the breakpoint count becomes zero; a continue command stops the list execution and resumes the thread. ```ddb set $work0 0 break/Tu xxx_start $task7.0 cond #1 (1) set $work0 1; set $work1 0; cont break/T vm_fault $task7.0 cond #2 ($work0) set $work1 ($work1+1); cont break/Tu xxx_end $task7.0 cond #3 ($work0) print $work1 " faults\n"; set $work0 0 cont ``` -------------------------------- ### swtch_pri Source: https://ftp.gnu.org/old-gnu/Manuals/machinfo-0.3/html_mono/mach.html XXX FIXME - No documentation provided. ```APIDOC ## swtch_pri ### Description XXX FIXME - No documentation provided. ### Function Signature boolean_t swtch_pri(int priority) ### Parameters - **priority** (int) - Required - Priority value (purpose not documented). ``` -------------------------------- ### thread_get_state Source: https://ftp.gnu.org/old-gnu/Manuals/machinfo-0.3/html_mono/mach.html Gets the state of a thread. ```APIDOC ## thread_get_state ### Description Gets the state of a thread. ### Function Signature `kern_return_t thread_get_state(thread_t thread, thread_state_flavor_t flavor, thread_state_t old_state, mach_msg_type_number_t *old_state_count)` ### Parameters - **thread** (thread_t) - Required - The thread. - **flavor** (thread_state_flavor_t) - Required - The flavor of state. - **old_state** (thread_state_t) - Required - Pointer to the state buffer. - **old_state_count** (mach_msg_type_number_t *) - Required - Pointer to the count. ### Return Value - **kern_return_t** - Success or error code. ``` -------------------------------- ### thread_max_priority Source: https://ftp.gnu.org/old-gnu/Manuals/machinfo-0.3/html_mono/mach.html Gets the maximum priority of a thread. ```APIDOC ## thread_max_priority ### Description Gets the maximum priority of a thread. ### Function Signature `kern_return_t thread_max_priority(thread_t thread, int *max_priority)` ### Parameters - **thread** (thread_t) - Required - The thread. - **max_priority** (int *) - Required - Pointer to the maximum priority. ### Return Value - **kern_return_t** - Success or error code. ``` -------------------------------- ### host_get_boot_info Source: https://ftp.gnu.org/old-gnu/Manuals/machinfo-0.3/html_mono/mach.html Returns the boot-time information string supplied by the operator to the kernel executing on the specified host. ```APIDOC ## host_get_boot_info ### Description Returns the boot-time information string supplied by the operator to the kernel executing on the specified host. The string is stored in the provided buffer and may be truncated if longer than KERNEL_BOOT_INFO_MAX. ### Function Signature kern_return_t host_get_boot_info(mach_port_t host_priv, kernel_boot_info_t boot_info) ### Parameters - **host_priv** (mach_port_t) - Required - The host privilege port for which to retrieve boot info. - **boot_info** (kernel_boot_info_t) - Required - Buffer where the boot-time information string will be stored. Should be dimensioned using KERNEL_BOOT_INFO_MAX if kernel_boot_info_t is not used. ### Return Value - **KERN_SUCCESS** - On success. - **KERN_INVALID_ARGUMENT** - If host_priv is not a valid send right to a host privilege port. - **KERN_INVALID_ADDRESS** - If boot_info points to inaccessible memory. ### Notes If the boot-time information string is longer than KERNEL_BOOT_INFO_MAX, the result is truncated and not necessarily null-terminated. ``` -------------------------------- ### thread_get_special_port Source: https://ftp.gnu.org/old-gnu/Manuals/machinfo-0.3/html_mono/mach.html Gets a special port of a thread. ```APIDOC ## thread_get_special_port ### Description Gets a special port of a thread. ### Function Signature `kern_return_t thread_get_special_port(thread_t thread, int which_port, mach_port_t *special_port)` ### Parameters - **thread** (thread_t) - Required - The thread. - **which_port** (int) - Required - The special port identifier. - **special_port** (mach_port_t *) - Required - Pointer to the special port. ### Return Value - **kern_return_t** - Success or error code. ``` -------------------------------- ### swtch Source: https://ftp.gnu.org/old-gnu/Manuals/machinfo-0.3/html_mono/mach.html XXX FIXME - No documentation provided. ```APIDOC ## swtch ### Description XXX FIXME - No documentation provided. ### Function Signature boolean_t swtch() ``` -------------------------------- ### thread_get_kernel_port Source: https://ftp.gnu.org/old-gnu/Manuals/machinfo-0.3/html_mono/mach.html Gets the kernel port of a thread. ```APIDOC ## thread_get_kernel_port ### Description Gets the kernel port of a thread. ### Function Signature `kern_return_t thread_get_kernel_port(thread_t thread, mach_port_t *kernel_port)` ### Parameters - **thread** (thread_t) - Required - The thread. - **kernel_port** (mach_port_t *) - Required - Pointer to the kernel port. ### Return Value - **kern_return_t** - Success or error code. ``` -------------------------------- ### host_get_boot_info Source: https://ftp.gnu.org/old-gnu/Manuals/machinfo-0.3/html_mono/mach.html Returns boot information for the host. This function retrieves the boot arguments and other boot-related information. ```APIDOC ## host_get_boot_info ### Description Returns boot information for the host. This function retrieves the boot arguments and other boot-related information. ### Function host_get_boot_info ### Parameters - **host** (host_t) - Required - The host for which to get boot info. - **boot_info** (kernel_boot_info_t) - Required - Output: the boot information. ### Return Value Returns kern_return_t indicating success or error. ### Example ```c kernel_boot_info_t boot_info; kern_return_t kr = host_get_boot_info(mach_host_self(), boot_info); ``` ``` -------------------------------- ### Compile the kernel with make Source: https://ftp.gnu.org/old-gnu/Manuals/machinfo-0.3/html_mono/mach.html Run this command in the source directory to compile the GNU Mach kernel. Requires GNU C compiler and MiG. ```shell make ``` -------------------------------- ### thread_get_exception_port Source: https://ftp.gnu.org/old-gnu/Manuals/machinfo-0.3/html_mono/mach.html Gets the exception port of a thread. ```APIDOC ## thread_get_exception_port ### Description Gets the exception port of a thread. ### Function Signature `kern_return_t thread_get_exception_port(thread_t thread, mach_port_t *exception_port)` ### Parameters - **thread** (thread_t) - Required - The thread. - **exception_port** (mach_port_t *) - Required - Pointer to the exception port. ### Return Value - **kern_return_t** - Success or error code. ``` -------------------------------- ### device_open Source: https://ftp.gnu.org/old-gnu/Manuals/machinfo-0.3/html_mono/mach.html Opens a device by name and returns a port to it. Increments the open count and invokes the open handler if the count was zero. ```APIDOC ## device_open ### Description Opens the device specified by name and returns a port to it in device. The open count for the device is incremented by one. If the open count was 0, the open handler for the device is invoked. ### Function Signature kern_return_t device_open(mach_port_t master_port, dev_mode_t mode, dev_name_t name, mach_port_t *device) ### Parameters - **master_port** (mach_port_t) - Required - Must hold the master device port. - **mode** (dev_mode_t) - Required - The open mode. It is a bitwise-or of the following constants: - D_READ - Request read access for the device. - D_WRITE - Request write access for the device. - D_NODELAY - Do not delay an open. - **name** (dev_name_t) - Required - Specifies the device to open, a string up to 128 characters long. - **device** (mach_port_t*) - Required - On success, returns a port to the opened device. ### Return Value - **kern_return_t** - Returns D_SUCCESS if the device was successfully opened, D_INVALID_OPERATION if master_port is not the master device port, D_WOULD_BLOCK if the device is busy and D_NOWAIT was specified in mode, D_ALREADY_OPEN if the device is already open in an incompatible mode, and D_NO_SUCH_DEVICE if name does not denote a known device. ``` -------------------------------- ### task_get_special_port Source: https://ftp.gnu.org/old-gnu/Manuals/machinfo-0.3/html_mono/mach.html Gets a special port of a task. ```APIDOC ## task_get_special_port ### Description Gets a special port of a task. ### Function Signature `kern_return_t task_get_special_port(task_t task, int which_port, mach_port_t *special_port)` ### Parameters - **task** (task_t) - Required - The task. - **which_port** (int) - Required - The special port identifier. - **special_port** (mach_port_t *) - Required - Pointer to the special port. ### Return Value - **kern_return_t** - Success or error code. ``` -------------------------------- ### task_get_kernel_port Source: https://ftp.gnu.org/old-gnu/Manuals/machinfo-0.3/html_mono/mach.html Gets the kernel port of a task. ```APIDOC ## task_get_kernel_port ### Description Gets the kernel port of a task. ### Function Signature `kern_return_t task_get_kernel_port(task_t task, mach_port_t *kernel_port)` ### Parameters - **task** (task_t) - Required - The task. - **kernel_port** (mach_port_t *) - Required - Pointer to the kernel port. ### Return Value - **kern_return_t** - Success or error code. ``` -------------------------------- ### task_get_exception_port Source: https://ftp.gnu.org/old-gnu/Manuals/machinfo-0.3/html_mono/mach.html Gets the exception port of a task. ```APIDOC ## task_get_exception_port ### Description Gets the exception port of a task. ### Function Signature `kern_return_t task_get_exception_port(task_t task, mach_port_t *exception_port)` ### Parameters - **task** (task_t) - Required - The task. - **exception_port** (mach_port_t *) - Required - Pointer to the exception port. ### Return Value - **kern_return_t** - Success or error code. ``` -------------------------------- ### memory_object_data_initialize Source: https://ftp.gnu.org/old-gnu/Manuals/machinfo-0.3/html_mono/mach.html Provides the memory manager with initial data for a kernel-created memory object. If the memory manager already has been supplied data (by a previous memory_object_data_initialize or memory_object_data_return), then this data should be ignored. Otherwise, this call behaves exactly as does memory_object_data_return on memory objects created by the kernel via memory_object_create. ```APIDOC ## memory_object_data_initialize ### Description Provides the memory manager with initial data for a kernel-created memory object. If the memory manager already has been supplied data (by a previous `memory_object_data_initialize` or `memory_object_data_return`), then this data should be ignored. Otherwise, this call behaves exactly as does `memory_object_data_return` on memory objects created by the kernel via `memory_object_create` and thus will only be made to default memory managers. This call will not be made on objects created via `memory_object_copy`. ### Function Signature ```c kern_return_t memory_object_data_initialize(mach_port_t memory_object, mach_port_t memory_control, vm_offset_t offset, vm_offset_t data, vm_size_t data_count); ``` ### Parameters - **memory_object** (mach_port_t) - Required - The memory object for which data is being provided. - **memory_control** (mach_port_t) - Required - The memory control port associated with the memory object. - **offset** (vm_offset_t) - Required - The offset within the memory object where the data begins. - **data** (vm_offset_t) - Required - The data to be provided. - **data_count** (vm_size_t) - Required - The number of bytes of data being provided. ### Return Value - **KERN_SUCCESS** - The function should return `KERN_SUCCESS`. ``` -------------------------------- ### task_get_emulation_vector Source: https://ftp.gnu.org/old-gnu/Manuals/machinfo-0.3/html_mono/mach.html Gets the emulation vector of a task. ```APIDOC ## task_get_emulation_vector ### Description Gets the emulation vector of a task. ### Function Signature `kern_return_t task_get_emulation_vector(task_t task, int *vector_start, emulation_vector_t *vector, mach_msg_type_number_t *count)` ### Parameters - **task** (task_t) - Required - The task. - **vector_start** (int *) - Required - Pointer to the start of the vector. - **vector** (emulation_vector_t *) - Required - Pointer to the vector. - **count** (mach_msg_type_number_t *) - Required - Pointer to the count. ### Return Value - **kern_return_t** - Success or error code. ``` -------------------------------- ### task_create Source: https://ftp.gnu.org/old-gnu/Manuals/machinfo-0.3/html_mono/mach.html Creates a new task. ```APIDOC ## task_create ### Description Creates a new task. ### Function Signature `kern_return_t task_create(task_t parent_task, boolean_t inherit_memory, task_t *child_task)` ### Parameters - **parent_task** (task_t) - Required - The parent task. - **inherit_memory** (boolean_t) - Required - Whether to inherit the parent's memory. - **child_task** (task_t *) - Required - Pointer to the new task. ### Return Value - **kern_return_t** - Success or error code. ``` -------------------------------- ### task_get_bootstrap_port Source: https://ftp.gnu.org/old-gnu/Manuals/machinfo-0.3/html_mono/mach.html Gets the bootstrap port of a task. ```APIDOC ## task_get_bootstrap_port ### Description Gets the bootstrap port of a task. ### Function Signature `kern_return_t task_get_bootstrap_port(task_t task, mach_port_t *bootstrap_port)` ### Parameters - **task** (task_t) - Required - The task. - **bootstrap_port** (mach_port_t *) - Required - Pointer to the bootstrap port. ### Return Value - **kern_return_t** - Success or error code. ``` -------------------------------- ### task_create Source: https://ftp.gnu.org/old-gnu/Manuals/machinfo-0.3/html_mono/mach.html Creates a new task from a parent task, optionally inheriting memory. Returns a send right to the new task's kernel port. ```APIDOC ## task_create ### Description Creates a new task from parent_task. The child task acquires shared or copied parts of the parent's address space if inherit_memory is set, otherwise it gets an empty address space. The child task initially contains no threads. ### Function Signature kern_return_t task_create(mach_port_t parent_task, boolean_t inherit_memory, mach_port_t *child_task) ### Parameters - **parent_task** (mach_port_t) - Required - The task port of the parent task. - **inherit_memory** (boolean_t) - Required - If set, the child task's address space is built from the parent task according to its memory inheritance values; otherwise, the child task is given an empty address space. - **child_task** (mach_port_t *) - Required - On success, receives a send right to the new task's kernel port. ### Return Value - **KERN_SUCCESS** - If a new task has been created. - **KERN_INVALID_ARGUMENT** - If parent_task is not a valid task port. - **KERN_RESOURCE_SHORTAGE** - If some critical kernel resource is unavailable. ### Notes The child task gets the three special ports created or copied for it at task creation. The TASK_KERNEL_PORT is created and send rights for it are given to the child and returned to the caller. The TASK_BOOTSTRAP_PORT and TASK_EXCEPTION_PORT are inherited from the parent task. The new task can get send rights to these ports with the call task_get_special_port. ``` -------------------------------- ### thread_get_sampled_pcs Source: https://ftp.gnu.org/old-gnu/Manuals/machinfo-0.3/html_mono/mach.html Gets the sampled program counters of a thread. ```APIDOC ## thread_get_sampled_pcs ### Description Gets the sampled program counters of a thread. ### Function Signature `kern_return_t thread_get_sampled_pcs(thread_t thread, mach_pc_sampling_options_t *options, mach_msg_type_number_t *count, pc_samples_t *samples, mach_msg_type_number_t *sample_count)` ### Parameters - **thread** (thread_t) - Required - The thread. - **options** (mach_pc_sampling_options_t *) - Required - Sampling options. - **count** (mach_msg_type_number_t *) - Required - Number of options. - **samples** (pc_samples_t *) - Required - Pointer to the samples. - **sample_count** (mach_msg_type_number_t *) - Required - Pointer to the sample count. ### Return Value - **kern_return_t** - Success or error code. ``` -------------------------------- ### thread_get_assignment Source: https://ftp.gnu.org/old-gnu/Manuals/machinfo-0.3/html_mono/mach.html Gets the processor set assignment of a thread. ```APIDOC ## thread_get_assignment ### Description Gets the processor set assignment of a thread. ### Function Signature `kern_return_t thread_get_assignment(thread_t thread, processor_set_t *pset)` ### Parameters - **thread** (thread_t) - Required - The thread. - **pset** (processor_set_t *) - Required - Pointer to the processor set. ### Return Value - **kern_return_t** - Success or error code. ``` -------------------------------- ### task_get_sampled_pcs Source: https://ftp.gnu.org/old-gnu/Manuals/machinfo-0.3/html_mono/mach.html Gets the sampled program counters of a task. ```APIDOC ## task_get_sampled_pcs ### Description Gets the sampled program counters of a task. ### Function Signature `kern_return_t task_get_sampled_pcs(task_t task, mach_pc_sampling_options_t *options, mach_msg_type_number_t *count, pc_samples_t *samples, mach_msg_type_number_t *sample_count)` ### Parameters - **task** (task_t) - Required - The task. - **options** (mach_pc_sampling_options_t *) - Required - Sampling options. - **count** (mach_msg_type_number_t *) - Required - Number of options. - **samples** (pc_samples_t *) - Required - Pointer to the samples. - **sample_count** (mach_msg_type_number_t *) - Required - Pointer to the sample count. ### Return Value - **kern_return_t** - Success or error code. ``` -------------------------------- ### Device Interface Source: https://ftp.gnu.org/old-gnu/Manuals/machinfo-0.3/html_mono/mach.html The GNU Mach microkernel provides a device interface for user space programs to access hardware devices. Devices are opened via the device master port, and operations are performed via remote procedure calls to the device port. ```APIDOC ## Device Interface ### Description The GNU Mach microkernel provides a simple device interface that allows user space programs to access underlying hardware devices. ### Device Names - Each device has a unique name, a string up to 127 characters long. ### Opening a Device - To open a device, the device master port must be supplied. - The device master port is only available through the bootstrap port. - Anyone with control over the device master port can use all hardware devices. ### Device Ports - For each device opened, a port is created that represents the device. - Operations on the device are implemented as remote procedure calls to the device port. ### Data Transfer - Each device provides a sequence of records. - The length of a record is specific to the device. - Data can be transferred "out-of-band" or "inband". ``` -------------------------------- ### task_get_assignment Source: https://ftp.gnu.org/old-gnu/Manuals/machinfo-0.3/html_mono/mach.html Gets the processor set assignment of a task. ```APIDOC ## task_get_assignment ### Description Gets the processor set assignment of a task. ### Function Signature `kern_return_t task_get_assignment(task_t task, processor_set_t *pset)` ### Parameters - **task** (task_t) - Required - The task. - **pset** (processor_set_t *) - Required - Pointer to the processor set. ### Return Value - **kern_return_t** - Success or error code. ``` -------------------------------- ### host_info Source: https://ftp.gnu.org/old-gnu/Manuals/machinfo-0.3/html_mono/mach.html Returns information about the host. This function retrieves general information about the host system. ```APIDOC ## host_info ### Description Returns information about the host. This function retrieves general information about the host system. ### Function host_info ### Parameters - **host** (host_t) - Required - The host for which to get information. - **flavor** (host_flavor_t) - Required - The type of information to retrieve. - **info** (host_info_t) - Required - Output: the information. - **count** (mach_msg_type_number_t*) - Required - Input/Output: the size of the info buffer. ### Return Value Returns kern_return_t indicating success or error. ### Example ```c host_basic_info_data_t info; mach_msg_type_number_t count = HOST_BASIC_INFO_COUNT; kern_return_t kr = host_info(mach_host_self(), HOST_BASIC_INFO, (host_info_t)&info, &count); ``` ``` -------------------------------- ### host_get_time Source: https://ftp.gnu.org/old-gnu/Manuals/machinfo-0.3/html_mono/mach.html Gets the current time as seen by the specified host. ```APIDOC ## host_get_time ### Description Gets the current time as seen by the specified host. On success, the time passed since the epoch is returned in current_time. ### Function Signature kern_return_t host_get_time(mach_port_t host, time_value_t *current_time) ### Parameters - **host** (mach_port_t) - Required - The host port for which to get the current time. - **current_time** (time_value_t *) - Required - Pointer to a time_value_t structure where the current time will be stored. ### Return Value - **KERN_SUCCESS** - On success. - **KERN_INVALID_ARGUMENT** - If host is not a valid send right to a host port. - **KERN_INVALID_ADDRESS** - If current_time points to inaccessible memory. ``` -------------------------------- ### device_open_request and ds_device_open_reply Source: https://ftp.gnu.org/old-gnu/Manuals/machinfo-0.3/html_mono/mach.html Asynchronous form of device_open. device_open_request performs the open request, and ds_device_open_reply is the reply message sent by the kernel. ```APIDOC ## device_open_request ### Description Performs an asynchronous open request. The caller must supply a reply port to which the ds_device_open_reply message is sent by the kernel when the open has been performed. ### Function Signature kern_return_t device_open_request(mach_port_t master_port, mach_port_t reply_port, dev_mode_t mode, dev_name_t name) ### Parameters - **master_port** (mach_port_t) - Required - Must hold the master device port. - **reply_port** (mach_port_t) - Required - Port to which the reply message is sent. - **mode** (dev_mode_t) - Required - The open mode. It is a bitwise-or of the following constants: - D_READ - Request read access for the device. - D_WRITE - Request write access for the device. - D_NODELAY - Do not delay an open. - **name** (dev_name_t) - Required - Specifies the device to open, a string up to 128 characters long. ### Return Value - **kern_return_t** - Returns KERN_SUCCESS if no error occurs. Only message transmission errors apply. ## ds_device_open_reply ### Description Reply message sent by the kernel to the reply port after an asynchronous open request. Contains the return code and the device port. ### Function Signature kern_return_t ds_device_open_reply(mach_port_t reply_port, kern_return_t return, mach_port_t *device) ### Parameters - **reply_port** (mach_port_t) - Required - The port to which the reply is sent. - **return** (kern_return_t) - Required - The return value of the open operation. - **device** (mach_port_t*) - Required - The port to the opened device. ### Return Value - **kern_return_t** - Returns KERN_SUCCESS if no error occurs. Only message transmission errors apply. ```