]>
Commit | Line | Data |
---|---|---|
1c79356b A |
1 | /* |
2 | * Copyright (c) 1999 Apple Computer, Inc. All rights reserved. | |
3 | * | |
b0d623f7 | 4 | * @APPLE_LICENSE_HEADER_START@ |
1c79356b | 5 | * |
2d21ac55 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 | |
b0d623f7 A |
9 | * compliance with the License. Please obtain a copy of the License at |
10 | * http://www.opensource.apple.com/apsl/ and read it before using this | |
11 | * file. | |
8f6c56a5 A |
12 | * |
13 | * The Original Code and all software distributed under the License are | |
2d21ac55 | 14 | * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER |
8f6c56a5 A |
15 | * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, |
16 | * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, | |
2d21ac55 A |
17 | * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. |
18 | * Please see the License for the specific language governing rights and | |
19 | * limitations under the License. | |
8f6c56a5 | 20 | * |
b0d623f7 | 21 | * @APPLE_LICENSE_HEADER_END@ |
1c79356b A |
22 | */ |
23 | ||
24 | #ifndef _MACHO_KLD_H_ | |
25 | #define _MACHO_KLD_H_ | |
26 | ||
27 | #include <mach-o/loader.h> | |
28 | #include <stdarg.h> | |
29 | ||
30 | /* | |
b0d623f7 | 31 | * These API's are in libkld. Both kextload(8) and /mach_kernel should |
1c79356b A |
32 | * link with -lkld and then ld(1) will expand -lkld to libkld.dylib or |
33 | * libkld.a depending on if -dynamic or -static is in effect. | |
55e303ae A |
34 | * |
35 | * Note: we are using the __DYNAMIC__ flag to indicate user space kernel | |
36 | * linking and __STATIC__ as a synonym of KERNEL. | |
1c79356b A |
37 | */ |
38 | ||
39 | /* | |
40 | * Note that you must supply the following function for error reporting when | |
41 | * using any of the functions listed here. | |
42 | */ | |
43 | extern void kld_error_vprintf(const char *format, va_list ap); | |
44 | ||
45 | /* | |
b0d623f7 | 46 | * These two are only in libkld.dylib for use by kextload(8) (user code compiled |
1c79356b A |
47 | * with the default -dynamic). |
48 | */ | |
49 | #ifdef __DYNAMIC__ | |
b0d623f7 | 50 | extern long kld_load_basefile( |
1c79356b A |
51 | const char *base_filename); |
52 | ||
53 | /* Note: this takes only one object file name */ | |
b0d623f7 | 54 | extern long kld_load( |
1c79356b A |
55 | struct mach_header **header_addr, |
56 | const char *object_filename, | |
57 | const char *output_filename); | |
55e303ae | 58 | |
b0d623f7 | 59 | extern long kld_load_from_memory( |
55e303ae A |
60 | struct mach_header **header_addr, |
61 | const char *object_name, | |
62 | char *object_addr, | |
63 | long object_size, | |
64 | const char *output_filename); | |
1c79356b A |
65 | #endif /* __DYNAMIC__ */ |
66 | ||
67 | /* | |
b0d623f7 | 68 | * This one is only in libkld.a use by /mach_kernel (kernel code compiled with |
1c79356b A |
69 | * -static). |
70 | */ | |
71 | #ifdef __STATIC__ | |
72 | /* Note: this api does not write an output file */ | |
b0d623f7 | 73 | extern long kld_load_from_memory( |
1c79356b A |
74 | struct mach_header **header_addr, |
75 | const char *object_name, | |
76 | char *object_addr, | |
77 | long object_size); | |
78 | #endif /* __STATIC__ */ | |
79 | ||
b0d623f7 | 80 | extern long kld_load_basefile_from_memory( |
55e303ae A |
81 | const char *base_filename, |
82 | char *base_addr, | |
83 | long base_size); | |
84 | ||
b0d623f7 | 85 | extern long kld_unload_all( |
1c79356b A |
86 | long deallocate_sets); |
87 | ||
b0d623f7 | 88 | extern long kld_lookup( |
1c79356b A |
89 | const char *symbol_name, |
90 | unsigned long *value); | |
91 | ||
b0d623f7 | 92 | extern long kld_forget_symbol( |
1c79356b A |
93 | const char *symbol_name); |
94 | ||
b0d623f7 | 95 | extern void kld_address_func( |
1c79356b A |
96 | unsigned long (*func)(unsigned long size, unsigned long headers_size)); |
97 | ||
55e303ae A |
98 | #define KLD_STRIP_ALL 0x00000000 |
99 | #define KLD_STRIP_NONE 0x00000001 | |
100 | ||
b0d623f7 | 101 | extern void kld_set_link_options( |
55e303ae A |
102 | unsigned long link_options); |
103 | ||
1c79356b | 104 | #endif /* _MACHO_KLD_H_ */ |