site_archiver@lists.apple.com Delivered-To: darwin-kernel@lists.apple.com --Nik On 17 Jun, 2009, at 06:54, Anton Altaparmakov wrote: Hi, grep host_self /path/to/kernel/sources/xnu/config/* grep OSFree /path/to/kernel/sources/xnu/config/* You get a result back like this one: Libkern.exports:_OSFree Best regards, Anton On 17 Jun 2009, at 14:28, Andrea Di Pasquale wrote: Hi guys! I'm writing my first KEXT. When i launch it, i've this problem: The code is: #include <sys/systm.h> #include <mach/mach_types.h> #include <mach/mach_host.h> #include <mach/host_info.h> #include <kern/kern_types.h> #include <kern/host.h> kern_return_t host_info_start(kmod_info_t *ki, void *d) { host_basic_info_t info; mach_msg_type_number_t count = HOST_BASIC_INFO_COUNT; kern_return_t ret; printf("KEXT has loaded!\n"); kern_return_t host_info_stop(kmod_info_t *ki, void *d) { printf("KEXT will be unloaded\n"); return (KERN_SUCCESS); } Can you help me, please? Best regards, Best regards, Anton -- Anton Altaparmakov <aia21 at cam.ac.uk> (replace at with @) Unix Support, Computing Service, University of Cambridge, CB2 3QH, UK Linux NTFS maintainer, http://www.linux-ntfs.org/ _______________________________________________ Do not post admin requests to the list. They will be ignored. Darwin-kernel mailing list (Darwin-kernel@lists.apple.com) Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/darwin-kernel/ngervae%40apple.com _______________________________________________ Do not post admin requests to the list. They will be ignored. Darwin-kernel mailing list (Darwin-kernel@lists.apple.com) Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/darwin-kernel/site_archiver%40lists.a... You can also run kextlibs on your kext to see if it can find all the OSBundleLibrary declarations you need. If it can't find a symbol, the symbol's not available in any library kext. If you need to find a kext for a specific symbol, use "kextfind -dsym <symbolname>", with the symbol as shown in the link error (C++ mangled, etc.). What makes you think that you can call the functions "host_info()" and "host_self()" from a kernel extension? The reason this is not working is because those functions cannot be called by kexts as they are not exported by the kernel. Whenever you are wondering whether a function is exported (and thus can be called form a kext) you need to look at the kernel source code in directory config (i.e. "xnu/config/") and grep in there for the function. So for example to check if host_self is exported you would do: This returns nothing thus the function is not exported. If you grep for an exported function, e.g. OSFree: Thus you need to include the com.apple.kpi.libkern OS bundle library in the Info.plist of your kext to get access to the OSFree() function. Manson:tmp spikey$ sudo kextload -vt host_info.kext kextload: resolving dependencies for kernel extensions with validation and authentication failures kextload: extension host_info.kext appears to be loadable kextload: loading extension host_info.kext kextload: sending 1 personality to the kernel kld(): Undefined symbols: _host_info _host_self kextload: kld_load_from_memory() failed for module /private/tmp/ host_info.kext/Contents/MacOS/host_info kextload: a link/load error occured for kernel extension host_info.kext link/load failed for extension host_info.kext (run kextload with -t for diagnostic output) ret = host_info(host_self(), HOST_BASIC_INFO, (host_info_t) info, &count); if (ret == KERN_FAILURE) printf("KEXT host_info() error!\n"); printf("CPU Stat:\n"); printf("=========\n"); printf("- Max CPUs: %d\n", info->max_cpus); printf("- Avaible CPUs: %d\n", info->avail_cpus); printf("- Max Physical CPUs\n", info->physical_cpu_max); printf("- Physical CPUs: %d\n", info->physical_cpu); printf("- Max Logical CPUs: %d\n", info->logical_cpu_max); printf("- Logical CPUs: %d\n", info->logical_cpu); return (ret); } -- Andrea _______________________________________________ Do not post admin requests to the list. They will be ignored. Darwin-kernel mailing list (Darwin-kernel@lists.apple.com) Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/darwin-kernel/ aia21%40cam.ac.uk This email sent to aia21@cam.ac.uk This email sent to ngervae@apple.com This email sent to site_archiver@lists.apple.com
participants (1)
-
Nik Gervae