Porting Drivers

I found some solutions to fixing sound and touchpad issues on a macbook pro 9,2. But for FreeBSD. Is there a way for me to use FreeBSD drivers, or to recompile them for Haiku?

No, not for touchpads. The only FreeBSD drivers we can use currently is for network devices.

But that “no” all depends on how much doe you’re ready to write to get it going, of course.

Can you link to the relevant FreeBSD info? (code, documentation, bug report on their side)?

first you need to write a driver for light pen for pc when for touchpads

https://wiki.freebsd.org/Laptops/Apple_MacBookPro9%2C2

I’m more concerned about sound than touchpad. But hopefully sometime I should get everything working. Is the process for the network drivers just rewriting them? Is there a good before/after I can look at for a done driver?

What is a driver for light pen?

No, the network drivers are imported with little to no changes. There is usally a compatibility wrapper file (usually called glue.c) to do the interfacing. You can see for yourself in src/add-ons/kernel/drivers/network and compare with the corresponding FreeBSD drivers.

But this can only work for network drivers I think. Not sure if anyone has tried it with something else.

Oh. Maybe this was answered elsewhere, but how to you view the drivers? Do you have to extract them?

If you mean in source form, the answer is no, you’ll need to clone the haiku source code to view them.

if you only want to view and compare you can go here.
network\drivers\kernel\add-ons\src - haiku - Haiku’s main repository (haiku-os.org)
Then go wlan for wifi and ether for cable connected, under the eatch driver we have dev folder where the freebsd files goes

Here you can see the drivers we have HardwareInfo – Haiku (haiku-os.org), I haven’t updated for a while (last time 2019). If you look at the network drives. say “attansic_l2 (ae)” the (ae) are the FreeBSD name for it. It’s a ethernet driver so will be under our ethernet.

here you have the freebsd drivers
freebsd-src/sys/dev at main · freebsd/freebsd-src (github.com)
and you can find the ae name here

2 Likes

Thanks for those links.

Sadly, unless someone uses my disk imaging mod this is true, but not from a limitation of Mac hardware but of Haiku that I cannot solve until Haiku supports being able to load its own images into memory like Linux has the ability to do; with a Linux-based system it’s possible to bless an ESP and boot from it as a Boot Camp drive. Haiku can’t do that which frustrated me out of working on ‘Haiku on Mac’.

These are pretty common for Mac hardware with Haiku sadly (no AirPort/Wifi or audio). Far as with the display, you might be able to set a safe resolution from Haiku’s boot menu and see if you can get it to use that.

I don’t understand how these two things are related…

You can set up an EFI system partition with our bootx64.efi in it and that should work. I don’t know what “blessing” is, is that a Mac specific thing? And how it is related to “load its own images into memory”? If you have an EFI system partition, all you need is the EFI bootloader to run the EFI executable inside that (in our case, the bootloader) and we can take it from there?

Also, do there exist bugreports about this with some detailed technical explanation? Or are you just being frustrated about it but done nothing to help improve the situation in that regard?

Oh yes, I have tried to mess with syslinux, I’ve tried to create custom images and RAM disks, I have tried to recompile Haiku after modifying the boot loader, but I realize what I’ve messed with so far isn’t enough. tbh I’d have to pour more time into figuring out how to do this because I believe Haiku would need to be modified to support booting from a self-contained image to do what I want it to do — and it does not. You should know this because you develop Haiku.

And I have explained before in a thread years ago why this is useful, Haiku requires a BeFS partition in either legacy or EFI mode to run, which a Mac’s firmware cannot see and cannot boot from. Yes, I can create both a BeFS volume and an ESP, but why do I have to be stuck in the past? It’s far easier to have a volume that is natively supported, and persistent Linux distributions support this. The advantages of this are that the Mac can see the volume in its own Startup Chooser, I can boot different revisions, and upgrades and installs are very easy to do, since I don’t need to partition anything beyond making an ESP and having images on top of it. bless is a command unique to the Mac as part of OS X - 13, it’s roots go back to the classic Mac OS (where either OpenFirmware or dragging Finder and System onto a vintage system folder would bless a drive and make it a startup disk).

But I’ll add with Apple Silicon being the next generation of Macs, my motivation to get this done has honestly dropped…

Well I just don’t understand how any of this works.

syslinux and RAM disks are not supported in Haiku for this purpose and should not be needed. All you need is to start haiku_loader in a way or another, and haiku_loadeer will take care of everything else.

So, you either start it as an EFI executable (or using the old style MBR booting), or, if you have some other way to start bootloaders, you have to port it to that format in some way. We already have various different ports of the bootloader: for EFI, for MBR, for PXE booting, for OpenFirmware in both PPC and SPARC versions. We used to have a version for baremetal ARM too, but now we use the EFI version there.

So, can you provide info on what kind of format is needed for Mac systems? I assume it is not a standard EFI executable then? What is it? An ELF file, a Mach-O executable?

So, can you provide info on what kind of format is needed for Mac systems?

If I understood correctly, he is reporting the fact that you would have to create two partitions for Haiku to boot using the standard MacOS boot loader. That’s because the boot loader doesn’t understand BeFS, thus it would be unable to see the haiku_loader executable in that partition. So you would have to create a FAT partition for the sole purpose of placing haiku_loader there so that it can be started by the Mac Boot Loader and then start haiku itself from the BeFS partition.

That’s not required by other OS as the mac boot loader is able to find the efi loader in supported partition formats and thus boot the OS. So in practice he would need an EFI System Partition only for Haiku.

1 Like

Does the Macintosh boot loader manage EXT4 to load Linux directly from there? I find that surprising. Does it also do that for XFS, ReiserFS, and whatever other filesystems you may install Linux on?

He mentioned persistent Linux distributions, so I guess the partition booted by mac would be a FAT partition with inside an image that is then mounted as the Linux root? But at this point I’m just speculating :sweat_smile:

You also need an ESP if you boot macos. I don’t really see the problem?

And to clarify ESP is just a FAT partition that is marked as a boot partition either by flag (old school intel partition) or by type uuid (GPT-partition).