The Design and Implementation of the FreeBSD Operating System, Second Edition
Now available: The Design and Implementation of the FreeBSD Operating System (Second Edition)


[ source navigation ] [ diff markup ] [ identifier search ] [ freetext search ] [ file search ] [ list types ] [ track identifier ]

FreeBSD/Linux Kernel Cross Reference
sys/libkern/libkern/kxld.h

Version: -  FREEBSD  -  FREEBSD-13-STABLE  -  FREEBSD-13-0  -  FREEBSD-12-STABLE  -  FREEBSD-12-0  -  FREEBSD-11-STABLE  -  FREEBSD-11-0  -  FREEBSD-10-STABLE  -  FREEBSD-10-0  -  FREEBSD-9-STABLE  -  FREEBSD-9-0  -  FREEBSD-8-STABLE  -  FREEBSD-8-0  -  FREEBSD-7-STABLE  -  FREEBSD-7-0  -  FREEBSD-6-STABLE  -  FREEBSD-6-0  -  FREEBSD-5-STABLE  -  FREEBSD-5-0  -  FREEBSD-4-STABLE  -  FREEBSD-3-STABLE  -  FREEBSD22  -  l41  -  OPENBSD  -  linux-2.6  -  MK84  -  PLAN9  -  xnu-8792 
SearchContext: -  none  -  3  -  10 

    1 /*
    2  * Copyright (c) 2007-2008 Apple Inc. All rights reserved.
    3  *
    4  * @APPLE_OSREFERENCE_LICENSE_HEADER_START@
    5  * 
    6  * This file contains Original Code and/or Modifications of Original Code
    7  * as defined in and that are subject to the Apple Public Source License
    8  * Version 2.0 (the 'License'). You may not use this file except in
    9  * compliance with the License. The rights granted to you under the License
   10  * may not be used to create, or enable the creation or redistribution of,
   11  * unlawful or unlicensed copies of an Apple operating system, or to
   12  * circumvent, violate, or enable the circumvention or violation of, any
   13  * terms of an Apple operating system software license agreement.
   14  * 
   15  * Please obtain a copy of the License at
   16  * http://www.opensource.apple.com/apsl/ and read it before using this file.
   17  * 
   18  * The Original Code and all software distributed under the License are
   19  * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
   20  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
   21  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
   22  * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
   23  * Please see the License for the specific language governing rights and
   24  * limitations under the License.
   25  * 
   26  * @APPLE_OSREFERENCE_LICENSE_HEADER_END@
   27  */
   28 #ifndef _KXLD_H
   29 #define _KXLD_H
   30 
   31 #include <sys/types.h>
   32 #include <mach/boolean.h>       // boolean_t
   33 #include <mach/kern_return.h>   // kern_return_t
   34 #include <mach/machine.h>       // cpu_type_t and cpu_subtype_t
   35 #include <mach/vm_types.h>
   36 
   37 #include "kxld_types.h"
   38 
   39 /*******************************************************************************
   40 * API
   41 *******************************************************************************/
   42 
   43 /*******************************************************************************
   44 * Creates a state object for the linker.  A context must be created for each
   45 * link thread and destroyed at the end of the thread's life.  A context should
   46 * be reused for all links occuring in that link thread.
   47 *   context             Returns a pointer to the new context object
   48 *   allocate callback   Callback to allocate memory for the linked kext
   49 *   log_callback        Callback for all kxld logging output
   50 *   flags               Flags to control the behavior of kxld
   51 *   cputype             The target arch's CPU type (0 for host arch)
   52 *   cpusubtype          The target arch's CPU subtype (0 for host subtype)
   53 *******************************************************************************/
   54 kern_return_t kxld_create_context(
   55     KXLDContext **context, 
   56     KXLDAllocateCallback allocate_callback,
   57     KXLDLoggingCallback log_callback,
   58     KXLDFlags flags,
   59     cpu_type_t cputype,
   60     cpu_subtype_t cpusubtype)
   61     __attribute__((nonnull(1,2),visibility("default")));
   62 
   63 /*******************************************************************************
   64 * Destroys a link context and frees all associated memory.  Should be called at
   65 * the end of a link thread's life.
   66 *******************************************************************************/
   67 void kxld_destroy_context(
   68     KXLDContext *context)
   69     __attribute__((nonnull,visibility("default")));
   70 
   71 /*******************************************************************************
   72 * Links a kext against its dependencies, using a callback to allocate the memory 
   73 * at which it will be located.
   74 * NOTE: The object data itself must be mmapped with PROT_WRITE and MAP_PRIVATE
   75 *   context             The KXLDContext object for the current link thread.
   76 *   file                The kext object file read into memory.
   77 *                       Supported formats: Mach-O, Mach-O64, Fat.
   78 *   size                The size of the kext in memory.  Must be nonzero.
   79 *   name                The name, usually the bundle identifier, of the kext
   80 *   callback_data       Data that is to be passed to the callback functions.
   81 *   deps                An array of pointers to the link state of kexts upon 
   82 *                       which this kext is dependent.
   83 *   ndeps               Number of entries in the 'deps' array.
   84 *   linked_object       If this is not null, it will be set to the address of 
   85 *                       the linked kext object.  If the address provided by the 
   86 *                       kxld_alloc_callback is considered writable, this pointer 
   87 *                       will be set to that address.  Otherwise, the linked
   88 *                       object will be written to a temporary buffer that should
   89 *                       be freed by the caller.
   90 *   kmod_info_kern      Kernel address of the kmod_info_t structure.
   91 *   link_state          If this is not null, it will be set to the address of a
   92 *                       block of memory that contains state generated by the
   93 *                       linking process for use by links of dependent kexts.  
   94 *                       The link state object is serialized and can be written
   95 *                       directly to disk.  This memory should be freed by the 
   96 *                       caller when no longer needed.
   97 *   link_state_size     The size of the returned link state buffer.
   98 *   symbol_file         If this is not null, it will be set to the address of a
   99 *                       buffer containing a Mach-O symbol file that may be
  100 *                       written to disk.  This should be freed by the caller
  101 *                       when no longer needed.
  102 *                       Note: symbol files are never generated in the kernel
  103 *   symbol_file_size    The size of the returned symbol file buffer.
  104 *******************************************************************************/
  105 kern_return_t kxld_link_file(
  106     KXLDContext *context,
  107     u_char *file,
  108     u_long size,
  109     const char *name,
  110     void *callback_data,
  111     u_char **deps,
  112     u_int ndeps,
  113     u_char **linked_object,
  114     kxld_addr_t *kmod_info_kern,
  115     u_char **link_state,
  116     u_long *link_state_size,
  117     u_char **symbol_file,
  118     u_long *symbol_file_size)
  119     __attribute__((nonnull(1, 2), visibility("default")));
  120 
  121 /*******************************************************************************
  122 *******************************************************************************/
  123 boolean_t kxld_validate_copyright_string(const char *str)
  124     __attribute__((pure, nonnull, visibility("default")));
  125 
  126 #endif // _KXLD_H_
  127 

Cache object: 0d1bc8529953f8cf49ced4329343ce7a


[ source navigation ] [ diff markup ] [ identifier search ] [ freetext search ] [ file search ] [ list types ] [ track identifier ]


This page is part of the FreeBSD/Linux Linux Kernel Cross-Reference, and was automatically generated using a modified version of the LXR engine.