On Sat, 28 Feb 2004, Torrey Lyons wrote: >At 7:17 PM -0800 2/28/04, Matthew Bogosian wrote: >>>... >>> >>>I'd like to ask a question, though: is it even conceivably possible to >>>use the binary code distributed with OS X 10.x in Linux? What I mean >>>is, is it possible that one could (in theory) write a wrapper for the >>>Mach-0 based code for the video drivers? Kind of like what these guys >> >have done to allow x86 Linux to use Windows wireless drivers: > >On the face of it, this is an interesting idea. I had toyed with the >idea of going the other way at one time: writing an IOKit wrapper for >Mac OS X that would allow one to use XFree86 drivers. Unfortunately, >there are a lot of issues you have not considered. > >... > >You'll actually want to be looked at KEXT's in >/System/Library/Extensions. Dylibs are dynamic shared libraries in >user land. All the drivers you want to wrap run in kernel space.
Ugh. You're right. I'm a moron. I completely ignored the fact the the drivers run in kernel space, not user space. >> >2. Find/write a Mach-0 object loader for Linux (is this necessary? >> >Linux uses ELF, and OS X uses Mach-0, right?) > >Right. Note the NetBSD guys have done this. Check out ><http://hcpnet.free.fr/applebsd.html>. Thanks for the pointer! >> >3. Identify the approprate nVidia-specific symbols in the .dylib files >>>(this probably requires some heavy reverse engineering/experimentation >>>and a lot of patience) >>> >>>4. Write the wrapper/glue code to abstract the Mach-O loader/nVidia >> >symbol calls as an XFree86 driver > >This is not really right. In fact: > >1. You'd have to provide an emulation of the environment IOKit video >drivers expect to see when they are linked into the Darwin kernel. >This would allow the driver to talk to the hardware. This is harder >then it might first appear because the IOKit is C++ based and drivers >rely on inheriting much of their functionality from other objects. >(This is part of the elegance of the IOKit.) You would likely end up >having to provide the functionality of a big chunk of the IOKit. Ugh again. I should have been able to see this as well if I had only remembered about the kernel drivers. And although I don't see any reason why this wouldn't be possible, it does seem like a fair amount of work. I can't exactly claim an extensive knowledge of the inner workings of Linux (or any) kernel modules (I once wrote /dev/zero as an exercise once about 8 years ago, but that's about it. >Since the Darwin kernel is open source you can see and use all the >IOKit kernel code. The Apple Public Source License (2.0) is both open >and free <http://www.gnu.org/philosophy/apsl.html>. Unfortunately, >you may run into license compatibility issues depending on how and >where you wanted to deploy this code. The APSL is not GPL compatible >for example. I'll be the first to admit my ignorance of the details of certain Open Source licenses, but I'm not sure I completely understand the issue(s). If the IOKit is either GPL or BSDL, I can create and publish a library with any revisions/extensions I create. Does the GPL/BSDL prohibit static linking (necessary in a kernel module I would think) to that library in a kernel module released under the APSL? Or vice versa (creating a library from the APSL code and creating a GPL'ed kernel module that statically links to it). My guess is there is probably a restriction here, but I don't know for sure. You may be right in that I would have to (effectively) re-implement the IOKit from scratch and publish it under the APSL (and create a 'dirty' Linux kernel module) unless I can convince the authors to make theirs available under multiple licenses. >2. You would also need to write your XFree86 shim-driver that >translated the standard calls from XFree86 ddx into calls appropriate >for an IOKit driver. > >Unfortunately when you were done you might not see the performance >you hoped for. The 2-D graphics model on Mac OS X and X11 are very >different. An IOKit video driver will provide no hooks to accelerate >many X11 graphics primitives. For 3-D you are at least targeting the >same API with X11 and Mac OS X (OpenGL), so performance could be >closer to ideal. Actually, the whole focus of the original thought was to gain access to 3-D hardware acceleration under OSes other than OS X running on PPC hardware. While it would further complicate matters, one might consider a hybrid of the XFree86 "nv" driver for 2-D stuff and proprietary nVidia code (through the shim driver to the bastardized Mach-0 kernel module) for 3-D stuff (my use of the word "stuff" here is to demonstrate my ignorance of where the line can be drawn if at all), if that was even possible. >>>... >>>to do? It seems like this might be a decent compromise (nVidia doesn't >>>have to release its IP, and Linux users get updates with OS X). >>>Alternatively, are there any bright independents out there who are >> >capable/willing to tackle such a daunting task? > >The biggest problem is that you are talking about a huge amount of >work without a very large payoff. There are very few people who >understand both the low level details of the X server and IOKit >driver development well enough to attempt it. True. I myself am 0-for-all of them. It might be a really cool (albeit extremely frustrating) way to learn though.... ;-) I'd certainly be a prominent pest on several developer mailing lists for a while. Ideally, I could find a few good folks who were knowledgeable enough in certain areas and who were willing to help that I wouldn't have to do everything myself. >Not to be too glib, but the obvious question would always be, "Why >not just run Mac OS X, if you are willing to use binary drivers >anyway?" XFree86 is included with every computer shipped by Apple >these days and in every retail version of the latest version of Mac >OS X. With XFree86 4.4.0 on Mac OS X, OpenGL for local X11 >applications is exactly as fast as it is for applications written >with native Mac OS X API's. Not only that, but XFree86 inherits for >free any improvements NVidia or others put into their graphics >drivers and automatically supports any new hardware that NVidia >supports on the Mac. I thought of this, but I can't shake my attraction to people having more freedom in their choice of OS while still having access to all the hardware goodies. For those folks who (for whatever reason) want to run Linux or FreeBSD (or whatever) on their 12" PowerBook, but still have 3-D hardware acceleration, I thought this might be an alternative solution to trying to get nVidia to cough up PPC kernel drivers (see http://petitiononline.com/nvppclin/petition.html). But you're right, it does sound like a daunting task. Of course, if I did take this project on, by the time I was finished, nVidia would have probably already released PPC Linux drivers. :-) For right now, it's just a pipe dream of mine, but I'll still keep poking around. Thanks very much for your response. It certainly got me thinking! --Matt _______________________________________________ Devel mailing list [EMAIL PROTECTED] http://XFree86.Org/mailman/listinfo/devel
