Recent

Author Topic: Creating an ATA Disk Driver  (Read 3518 times)

Gizmo

  • Hero Member
  • *****
  • Posts: 688
Creating an ATA Disk Driver
« on: November 06, 2015, 01:39:27 pm »
Hi

I need a more native way for my program to "talk" to hard disks (partly for the reasons in thsi linked thread, amongst others : http://forum.lazarus.freepascal.org/index.php/topic,29987.msg190306.html#msg190306). i.e. instead of using WinAPI calls like CreateFileW and so on, that rely on what the OS understands of the hardware, I actually need to ask the disks ATA controller questions and get the answers directly. This means I need to write (or find) a disk driver that I can distribute with my program.

Other than this (http://wiki.lazarus.freepascal.org/Target_NativeNT) and a few articles about existing keyboard, mouse and video card driver units, info seems to be a little slim. I have a copy of the 2005 ATA specifications, but working out how the various flags in that specification correspond to writing of a driver with FPC, I have no idea.

Does anyone have any links to either projects that teach you the basics of writing hardware drivers, existing disk drivers with accompanying API (not sure if I could use this: https://github.com/zero-point/diskdriver) or any general advice on achieving this.

Yes : I know it will not be easy. Yes, I know it will mean bit level values and so on. Yes, I know it's not a task for someone who has never done it before. But we have to start somewhere. Thus my question.

Ted
Lazarus 2.0.4 and fpc 3.0.4 - Linux Mint 19 LTS, Windows 10 64 and Mac OSX Catlina
Useful Page to remember : http://wiki.freepascal.org/Cross_compiling#From_Linux_x64_to_Linux_i386

engkin

  • Hero Member
  • *****
  • Posts: 2513
Re: Creating an ATA Disk Driver
« Reply #1 on: November 06, 2015, 02:26:21 pm »

Gizmo

  • Hero Member
  • *****
  • Posts: 688
Re: Creating an ATA Disk Driver
« Reply #2 on: November 06, 2015, 03:43:37 pm »
Thanks Engkin...a useful link.

The documentation is a bit "limited" though. It seems like it's an overall kit for developing drivers for anything using Delphi. But working out how you use it to create a specific driver for a disk, or a printer, or a video card, or whatever, will take some working out.

It's also quite old now - 5 years since 0.0.0.4 release.

I'd have hoped in this day and age there might be a more active project, with more instructive guidance?
Lazarus 2.0.4 and fpc 3.0.4 - Linux Mint 19 LTS, Windows 10 64 and Mac OSX Catlina
Useful Page to remember : http://wiki.freepascal.org/Cross_compiling#From_Linux_x64_to_Linux_i386

PascalDragon

  • Hero Member
  • *****
  • Posts: 712
  • Compiler Developer
Re: Creating an ATA Disk Driver
« Reply #3 on: November 13, 2015, 03:34:12 pm »
For what you want to do writing a driver is way overkill (see my answer in your other thread), especially since you need to tell Windows to load your driver for the ATA controller. If you only have one controller then you'd need your driver to be good enough to successfully boot Windows. Not a good idea...
For writing Windows drivers in FPC the NativeNT target is indeed the right choice (though right now it only supports 32-bit x86). Regarding tutorials I'd suggest you to look at C tutorials since most NT drivers are written in C. The more modern frameworks (like the Kernel Mode Driver Framework) might be a bit more complicated, I've only tested to write a simple, legacy style HelloWorld driver in FPC.

Regards,
Sven