Has anyone here coded a Driver?

NeXT Computer, Inc. -> Intel White Hardware

Title: Has anyone here coded a Driver?
Post by: pTeK on October 03, 2023, 08:21:57 PM
Hi

 I'm looking for some advice on programming a driver. I thought my laptop had a Intel PIIX4 chipset but it seems that NetBSD added the ICH4-M code to that driver.

 NeXTSTEP 3.3 Developer Documentation HTML format (https://www.nextop.de/NeXTstep_3.3_Developer_Documentation/)
 NeXTSTEP 3.3 Developer Documentation HTML format (Hosted here) (https://www.nextcomputers.org/NeXTfiles/Docs/NeXTStep/3.3/nd/)
 Driverkit for OpenStep 4.2 with examples and PDF (https://www.nextcomputers.org/NeXTfiles/Software/OPENSTEP/Developer/DriverKit/)
 Currently I'm going through the EIDE driver source and adding notes referencing the PIIX4 datasheet that was released with Rhapsody on user @evolver56k github site at Rhapsody EIDE driver code. (https://github.com/evolver56k/Darwin-0.3/tree/master/drvEIDE-1)

 This website provides links to driver source in the *BSD releases which is a good starting point:
Intel 82801DBM (ICH4-M) IDE Controller (https://bsd-hardware.info/?id=pci:8086-24ca)

A guide to writing PCI drivers on Linux (https://www.kernel.org/doc/html/latest/PCI/pci.html)

 I have found the following two Intel PIIX4 documents:
Intel ® 82371AB PIIX4 datasheet (Document Number 290562-001) (https://www.intel.com/Assets/PDF/datasheet/290562.pdf)
82371AB (PIIX4) PCI ISA IDE Xcelerator Timing Specifications (Datasheet Addendum) (https://www.intel.com/Assets/PDF/datasheet/290548.pdf)

 and the links to my own IHC4 IDE hardware which a lot of hardware from the 2000s have:
Intel 82801DB I/O Controller Hub 4 (ICH4) (https://www.intel.com/content/dam/www/public/us/en/documents/datasheets/82801db-io-controller-hub-4-datasheet.pdf)
Intel 82801DBM I/O Controller Hub 4 Mobile (ICH4-M) (https://www.intel.com/content/dam/doc/datasheet/82801dbm-i-o-controller-hub-4-mobile-datasheet.pdf)
Intel 82801BA (ICH2), 82801AA (ICH), and 82801AB (ICH0) IDE Controller (Programmers Reference Manual) (https://datasheet.datasheetarchive.com/originals/distributors/Datasheets-14/DSA-278689.pdf)
Intel ® 82801EB (ICH5), 82801ER (ICH5R), 82801DB (ICH4), 82801CA (ICH3), 82801BA (ICH2), 82801AA (ICH), and 82801A (ICH0) IDE Controller Programmer's Reference Manual (May 2003) (https://theretroweb.com/chip/documentation/298600-004-649b055e8a3c3407208414.pdf)

Nitro's Links
https://wiki.osdev.org/PCI_IDE_Controller (https://wiki.osdev.org/PCI_IDE_Controller)
https://wiki.osdev.org/PIC (https://wiki.osdev.org/PIC)
https://wiki.osdev.org/Interrupts (https://wiki.osdev.org/Interrupts)
https://wiki.osdev.org/ATA_PIO_Mode (https://wiki.osdev.org/ATA_PIO_Mode)
https://wiki.osdev.org/ISA_DMA (https://wiki.osdev.org/ISA_DMA)
https://wiki.osdev.org/Main_Page (https://wiki.osdev.org/Main_Page)

 I realize this will be exciting as if not careful can do some serious hardware damage  ;D

 Any other useful links will be appreciated.

2023:10:26 Added Intel ® 82801EB (ICH5), 82801ER (ICH5R), 82801DB (ICH4), 82801CA (ICH3), 82801BA (ICH2), 82801AA (ICH), and 82801AB (ICH0) IDE Controller Programmer's Reference Manual (PRM May 2003)
2023:10:23 Added Intel ® 82801EB (ICH5), 82801ER (ICH5R), 82801DB (ICH4), 82801CA (ICH3), 82801BA (ICH2), 82801AA (ICH), and 82801AB (ICH0) IDE Controller Programmer's Reference Manual (PRM May 2003)
2023:10:20 Added Intel 82801BA (ICH2), 82801AA (ICH), and 82801AB (ICH0) IDE Controller Programmer's Reference Manual, July 2000 Revision 1.0
2023:10:10 Added Nitro's links.
Title: Re: Has anyone here coded a Driver?
Post by: evolver56k on October 04, 2023, 04:44:49 PM
You shouldn't need to write a driver for ICH4 chipsets, if memory serves, choosing the "dual eide" version of the driver during install should work. At one point I had DR2 running on a dell latitude pentium3 laptop, and it would have had an ICH something-or-other.
Title: Re: Has anyone here coded a Driver?
Post by: Apple2guy on October 07, 2023, 08:45:42 AM
if you want dma support you need a driver. Dual EIDE driver uses only PIO modes.
Title: Re: Has anyone here coded a Driver?
Post by: Morgon on October 07, 2023, 02:21:22 PM
Writing drivers for NeXT is not that easy as the documentation is pretty sparse and missing all the interesting parts of the classes already implemented in the kernel. There are some example drivers in the developer package but they are pretty basic and often give only hints how to reach a goal.

For a start in driver development you need the NS 3.3 developer packages as that contains the needed DriverKit which has been removed in OS developer. After that it's studying the examples and trying to figure out stuff the hard way which is not that easy as driver debugging usually needs a second PC running NeXT and a working network connection between them with a network driver which supports remote kernel debugging (e.g. my VMNet driver won't work for that).
'.

Porting current linux drivers is a bit tricky as a lot of the code in the linux kernel has been generalized and moved from the drivers to the basic kernel. Leaving only the low level hardware parts for the driver. On NeXT you have to program a lot of these things on your own as they are not part of the kernel. E.g. when I wrote the VMNet driver I used an older linux driver where some of the low level package handling was handled by the driver while it has been put in kernel for the newer driver versions.

I once had a look at the EIDE driver sources myself and decided against trying a port due to the complexity.

When I started driver development I had been lucky to stumble upon the Darwin sources of the kernel and the driver kit which gave some more insight into this (you can find them here (http://www.nextcomputers.org/NeXTfiles/Software/Virtualization/VMWare/Source)). But sometimes I even had to fall back to disassembling the existing drivers to find out some undocumented APIs.

Beside that I wish you good luck and success.

Morgon.
Title: Re: Has anyone here coded a Driver?
Post by: pTeK on October 08, 2023, 06:15:29 PM
Quote from: Apple2guy on October 07, 2023, 08:45:42 AMif you want dma support you need a driver. Dual EIDE driver uses only PIO modes.
Yes, to get that 33MB speed with PIIX4 and 33MB/66MB/100MB with the ICH4.

Quote from: Morgon on October 07, 2023, 02:21:22 PMWriting drivers for NeXT is not that easy as the documentation is pretty sparse and missing all the interesting parts of the classes already implemented in the kernel. There are some example drivers in the developer package but they are pretty basic and often give only hints how to reach a goal.

For a start in driver development you need the NS 3.3 developer packages as that contains the needed DriverKit which has been removed in OS developer. After that it's studying the examples and trying to figure out stuff the hard way which is not that easy as driver debugging usually needs a second PC running NeXT and a working network connection between them with a network driver which supports remote kernel debugging (e.g. my VMNet driver won't work for that).
'.

Porting current linux drivers is a bit tricky as a lot of the code in the linux kernel has been generalized and moved from the drivers to the basic kernel. Leaving only the low level hardware parts for the driver. On NeXT you have to program a lot of these things on your own as they are not part of the kernel. E.g. when I wrote the VMNet driver I used an older linux driver where some of the low level package handling was handled by the driver while it has been put in kernel for the newer driver versions.

I once had a look at the EIDE driver sources myself and decided against trying a port due to the complexity.

When I started driver development I had been lucky to stumble upon the Darwin sources of the kernel and the driver kit which gave some more insight into this (you can find them here (http://www.nextcomputers.org/NeXTfiles/Software/Virtualization/VMWare/Source)). But sometimes I even had to fall back to disassembling the existing drivers to find out some undocumented APIs.

Beside that I wish you good luck and success.

Morgon.
Thanks Morgon, Yeah I've done the absolute minimum at the moment, I've just added the pages to the datasheets from the Intel ® 82371AB PIIX4 datasheet (Document Number 290562-001) (284 pages max) (https://www.intel.com/Assets/PDF/datasheet/290562.pdf). I can see the overlap between the PIIX4 and the ICH4 so a lot of the code should from the the PIIX4 should be reusable.

I really am glad that Apple did release the sources it does make it a lot easier and quicker (well not for me) to to find a problem.

One of the comments in the source was something along the line of 'read the data sheets and even then expect them to be wrong' I forgot where that one was.

oh yeah my notes Page 96(284). The 284 means the datasheet that has max pages=284 which is the datasheet that is mentioned
Thanks for the positive encouragement
Title: Re: Has anyone here coded a Driver?
Post by: Rob Blessin Black Hole on October 08, 2023, 09:28:07 PM
Hello PTek:  I have installed NeXTSTEP and Openstep on a lot of Intel Boxes . 

What is your configuration? Better yet the make and model of your laptop .....

This WIKI page https://en.wikipedia.org/wiki/PIIX should help.

PS2 Keyboard and Mouse correct?  Achilles Heal USB keyboards and mice will not work for a native NeXTstep, Openstep or Rhapsody(?) install. 

Did Apple/ NeXT ever write a Rhapsody USB driver as that would rock and possibly modify it for Openstep :) pipe dream?

I'm assuming you have an ide floppy drive and are able to get the install started with an Intel boot floppy

If Yes great , then it asks to install the NeXTSTEP intel drivers disk or Openstep Drivers Disk?

A couple of questions here , this is a known good working laptop?

Does it have any other operating systems installed?

Are you going to set it up to dual boot ?

My guess is it has an internal CD or dvd rom drive?

What size hard drive , very important....?

Did you disable USB, if it has it in the bios , yep shut it off completely as it simply will not work with NeXTSTEP or Openstep for a native install so that includes trying to install from  a USB stick, no drivers exist other than a alpha driver for USB which would have been hella cool to complete as holy moly would things have been so much easier. You absolutely positively have to disable USB in the bios on all Native NeXTSTEP or Openstep Intel hardware installs.

So if you have an ISO on a USB stick burn the NeXTSTEP or Openstep Iso to CD :)

When it ask up on entering the drivers for CDrom and Hard drive on the floppy device drivers disk for a native install , their is an option for an additional floppy which would contain the drivers from the Y2k Patch CD's some of them written in 1998 and the eide dual channel driver in it is money in the bank....... make sure you get the path and syntax  needs to be spot on NeXT formatted on a NeXT system including 68K .Install the beta drivers in to a correct path on your 3rd drivers floppy as I recall it is private/Drivers/i386/   pick it for CDrom and hard drive with any luck if finds them nd boom continue with the install as prompted. Pick a 2gb partition



Title: Re: Has anyone here coded a Driver?
Post by: Nitro on October 09, 2023, 01:15:10 AM
Hope this helps.

https://wiki.osdev.org/PCI_IDE_Controller
https://wiki.osdev.org/PIC
https://wiki.osdev.org/Interrupts
https://wiki.osdev.org/ATA_PIO_Mode
https://wiki.osdev.org/ISA_DMA

https://wiki.osdev.org/Main_Page
Title: Re: Has anyone here coded a Driver?
Post by: pTeK on October 19, 2023, 02:09:56 AM
Quote from: evolver56k on October 04, 2023, 04:44:49 PMYou shouldn't need to write a driver for ICH4 chipsets, if memory serves, choosing the "dual eide" version of the driver during install should work. At one point I had DR2 running on a dell latitude pentium3 laptop, and it would have had an ICH something-or-other.
User @raynorpat seems to have a different Rhapsody EIDE driver compared to yours @evolver56k

Their one seems to have some ICHX PCI Ids added to their code:
drvEIDE/EIDE.drvproj/EIDE.lksproj/PIIX.h (https://github.com/RhapsodiOS/Kernel/blob/22ad0c8485691fcee31e57117a62a3e338868811/drvEIDE/EIDE.drvproj/EIDE.lksproj/PIIX.h#L47)
drvEIDE/EIDE.drvproj/EIDE.lksproj/IdePIIX.m (https://github.com/RhapsodiOS/Kernel/blob/22ad0c8485691fcee31e57117a62a3e338868811/drvEIDE/EIDE.drvproj/EIDE.lksproj/IdePIIX.m#L124C1-L124C1)

I don't know why ICH4 IDE hardware is failing in compatibility mode (IRQ 14/15) because it is supposed to support that by default as mentioned in the ICHX IDE Programmers Reference Manual May 2003 (Page 64 of 64). (https://theretroweb.com/chip/documentation/298600-004-649b055e8a3c3407208414.pdf)
Quote10.6 Native PCI Mode Considerations

The ICH5, ICH4 and ICH3 ATA controllers have the ability to be programmed for either Compatibility or Native PCI. The term Compatibility indicates use of fixed legacy resources, and the term Native PCI indicates use of plug-and-play resources that are all programmable through the ICH5, ICH4 and ICH3 ATA controller's PCI configuration registers.

The ICH5, ICH4 and ICH3 ATA controller's default state is compatibility mode, so the programming interface register will have the value of "0x0A." The Base Address Registers for task file access (BAR0-3) will not be programmable at this point, showing the default value of 0
Title: Re: Has anyone here coded a Driver?
Post by: raynorpat on October 19, 2023, 07:32:48 PM
Quote from: pTeK on October 19, 2023, 02:09:56 AMUser @raynorpat seems to have a different Rhapsody EIDE driver compared to yours @evolver56k

Their one seems to have some ICHX PCI Ids added to their code:
drvEIDE/EIDE.drvproj/EIDE.lksproj/PIIX.h (https://github.com/RhapsodiOS/Kernel/blob/22ad0c8485691fcee31e57117a62a3e338868811/drvEIDE/EIDE.drvproj/EIDE.lksproj/PIIX.h#L47)
drvEIDE/EIDE.drvproj/EIDE.lksproj/IdePIIX.m (https://github.com/RhapsodiOS/Kernel/blob/22ad0c8485691fcee31e57117a62a3e338868811/drvEIDE/EIDE.drvproj/EIDE.lksproj/IdePIIX.m#L124C1-L124C1)


Ah I wouldn't call it any different, I began merging some code from the early XNU EIDE driver. What's in there is just code for verifying the PCI id of the controller, nothing more unfortunately
Title: Re: Has anyone here coded a Driver?
Post by: pTeK on October 22, 2023, 03:00:59 PM
Quote from: raynorpat on October 19, 2023, 07:32:48 PMAh I wouldn't call it any different, I began merging some code from the early XNU EIDE driver. What's in there is just code for verifying the PCI id of the controller, nothing more unfortunately
Do you have a link to the XNU EIDE driver or should I just use your github repo?

Found it at https://opensource.apple.com/source/xnu/xnu-201/iokit/Drivers/ata/ (https://opensource.apple.com/source/xnu/xnu-201/iokit/Drivers/ata/)

Go to top  Forum index