]>
Commit | Line | Data |
---|---|---|
1c79356b A |
1 | /* |
2 | * Copyright (c) 1999 Apple Computer, Inc. All rights reserved. | |
3 | * | |
8f6c56a5 | 4 | * @APPLE_OSREFERENCE_LICENSE_HEADER_START@ |
1c79356b | 5 | * |
8f6c56a5 A |
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 | |
8ad349bb | 24 | * limitations under the License. |
8f6c56a5 A |
25 | * |
26 | * @APPLE_OSREFERENCE_LICENSE_HEADER_END@ | |
1c79356b A |
27 | */ |
28 | ||
29 | #ifndef _MACHO_KLD_H_ | |
30 | #define _MACHO_KLD_H_ | |
31 | ||
32 | #include <mach-o/loader.h> | |
33 | #include <stdarg.h> | |
34 | ||
35 | /* | |
36 | * These API's are in libkld. Both kmodload(8) and /mach_kernel should | |
37 | * link with -lkld and then ld(1) will expand -lkld to libkld.dylib or | |
38 | * libkld.a depending on if -dynamic or -static is in effect. | |
55e303ae A |
39 | * |
40 | * Note: we are using the __DYNAMIC__ flag to indicate user space kernel | |
41 | * linking and __STATIC__ as a synonym of KERNEL. | |
1c79356b A |
42 | */ |
43 | ||
44 | /* | |
45 | * Note that you must supply the following function for error reporting when | |
46 | * using any of the functions listed here. | |
47 | */ | |
48 | extern void kld_error_vprintf(const char *format, va_list ap); | |
49 | ||
50 | /* | |
55e303ae | 51 | * These two are only in libkld.dylib for use by kmodload(8) (user code compiled |
1c79356b A |
52 | * with the default -dynamic). |
53 | */ | |
54 | #ifdef __DYNAMIC__ | |
55 | __private_extern__ long kld_load_basefile( | |
56 | const char *base_filename); | |
57 | ||
58 | /* Note: this takes only one object file name */ | |
59 | __private_extern__ long kld_load( | |
60 | struct mach_header **header_addr, | |
61 | const char *object_filename, | |
62 | const char *output_filename); | |
55e303ae A |
63 | |
64 | __private_extern__ long kld_load_from_memory( | |
65 | struct mach_header **header_addr, | |
66 | const char *object_name, | |
67 | char *object_addr, | |
68 | long object_size, | |
69 | const char *output_filename); | |
1c79356b A |
70 | #endif /* __DYNAMIC__ */ |
71 | ||
72 | /* | |
73 | * This two are only in libkld.a use by /mach_kernel (kernel code compiled with | |
74 | * -static). | |
75 | */ | |
76 | #ifdef __STATIC__ | |
77 | /* Note: this api does not write an output file */ | |
78 | __private_extern__ long kld_load_from_memory( | |
79 | struct mach_header **header_addr, | |
80 | const char *object_name, | |
81 | char *object_addr, | |
82 | long object_size); | |
83 | #endif /* __STATIC__ */ | |
84 | ||
55e303ae A |
85 | __private_extern__ long kld_load_basefile_from_memory( |
86 | const char *base_filename, | |
87 | char *base_addr, | |
88 | long base_size); | |
89 | ||
1c79356b A |
90 | __private_extern__ long kld_unload_all( |
91 | long deallocate_sets); | |
92 | ||
93 | __private_extern__ long kld_lookup( | |
94 | const char *symbol_name, | |
95 | unsigned long *value); | |
96 | ||
97 | __private_extern__ long kld_forget_symbol( | |
98 | const char *symbol_name); | |
99 | ||
100 | __private_extern__ void kld_address_func( | |
101 | unsigned long (*func)(unsigned long size, unsigned long headers_size)); | |
102 | ||
55e303ae A |
103 | #define KLD_STRIP_ALL 0x00000000 |
104 | #define KLD_STRIP_NONE 0x00000001 | |
105 | ||
106 | __private_extern__ void kld_set_link_options( | |
107 | unsigned long link_options); | |
108 | ||
1c79356b | 109 | #endif /* _MACHO_KLD_H_ */ |