Author Topic: OS2AHCI interface?  (Read 18399 times)

Dariusz Piatkowski

  • Hero Member
  • *****
  • Posts: 1317
  • Karma: +26/-0
    • View Profile
OS2AHCI interface?
« on: April 13, 2020, 03:20:08 pm »
Having recently made the move from DANIS506 to AHCI I've lost some of the IDE reporting functionality that was provided through little utilities like DiskMon, or even SmartMon.

So I thought I'd take a stab at building the AHCI versions of these, first one up being DiskMon since that provides a real-time snapshot of drive's throughput and temperature metrics, and I thought it would be a good excercise to try out my current GCC environment.

Alright, so here is the thing, I know I need to 're-point' the interface to the OS2AHCI, namely something like this:

Code: [Select]
  rc = DosOpen ("\\DEV\\IBMS506$", &hDevice, &ActionTaken, 0,  FILE_SYSTEM,
OPEN_ACTION_OPEN_IF_EXISTS, OPEN_SHARE_DENYNONE |
OPEN_FLAGS_NOINHERIT | OPEN_ACCESS_READONLY, NULL);
  if (rc) exit (rc);

needs to read more along the lines of this:

Code: [Select]
  rc = DosOpen ("\\DEV\\OS2AHCI$", &hDevice, &ActionTaken, 0,  FILE_SYSTEM,
OPEN_ACTION_OPEN_IF_EXISTS, OPEN_SHARE_DENYNONE |
OPEN_FLAGS_NOINHERIT | OPEN_ACCESS_READONLY, NULL);
  if (rc) exit (rc);

But i'm guessing it's nowhere near as simple as that. I mean I did make the change, the program succeesfully built and attempting to run it locked up the machine...LOL, I was expecting that. Strangely where it locked up was on a temperature fetch, and that may be more due to the fact that DiskMon is using the SMART reporting functionality of SmartMon (or so say the comments). I'm sure it's more complicated, but that is at least my starting point.

OK, so back to the post subject line: where do I obtain the definition of OS2AHCI interface?

I guess the only thing I can compare it to are the code samples that are included with the DANIS506 stuff, and those are very clear. I found nothing on the AOS pages on this, but before I log a ticket or post to the Testers' List I thought I'd ask here first.

Thanks!

Neil Waldhauer

  • Hero Member
  • *****
  • Posts: 1024
  • Karma: +24/-0
    • View Profile
    • Blonde Guy
Re: OS2AHCI interface?
« Reply #1 on: April 13, 2020, 03:42:39 pm »
Expert consulting for ArcaOS, OS/2 and eComStation
http://www.blondeguy.com

ivan

  • Hero Member
  • *****
  • Posts: 1557
  • Karma: +17/-0
    • View Profile
Re: OS2AHCI interface?
« Reply #2 on: April 13, 2020, 04:31:57 pm »
Hi Dariusz,

It sounds as if you are looking at that which I was looking for way back last year - some way to get smartctl.exe from smartmontools to display the output of smartctl -a ahci1 without having to pipe it to a file and then read that file, in other words just like smartmon from Dani's IDE driver package.

No one came up with a way of doing that when I asked so maybe you could produce the necessary graphical interface needed.
 

Lars

  • Hero Member
  • *****
  • Posts: 1271
  • Karma: +65/-0
    • View Profile
Re: OS2AHCI interface?
« Reply #3 on: April 13, 2020, 04:46:14 pm »
There were versions of OS2AHCI.ADD that would lock up the machine when the IOCTL was called (or the driver opened, for that matter).
What version of OS2AHCI.ADD are you using ? Make sure you use version >= 2.04.
I have smartahci.exe and that seems to work, at least to the extent that it outputs some info without completely freezing the system.

Dave Yeo

  • Hero Member
  • *****
  • Posts: 4786
  • Karma: +99/-1
    • View Profile
Re: OS2AHCI interface?
« Reply #4 on: April 13, 2020, 04:49:47 pm »
Hi Ivan, just pipe it through less. Would be nice to have colour support, perhaps Dariusz can find some macros or such to enable the ANSI colours.
Code: [Select]
SMARTAHCI.EXE -a hd0 | less

Pete

  • Hero Member
  • *****
  • Posts: 1281
  • Karma: +9/-0
    • View Profile
Re: OS2AHCI interface?
« Reply #5 on: April 13, 2020, 08:20:47 pm »
Hi All

Hi Dariusz,

It sounds as if you are looking at that which I was looking for way back last year - some way to get smartctl.exe from smartmontools to display the output of smartctl -a ahci1 without having to pipe it to a file and then read that file, in other words just like smartmon from Dani's IDE driver package.

No one came up with a way of doing that when I asked so maybe you could produce the necessary graphical interface needed.


It is funny you should mention that as I started playing around with something I call PMsmartctl as a result of your post.

It is a simple frontend for smartctl and displays selected information in the Text Editor (e.exe) which gives you the option of Saving and Printing - with minimal work by me  :-)

NOTE:  Only works with http://hobbes.nmsu.edu/download/pub/os2/util/disk/smartmontools-6.6-r4424.zip

If anyone feels like testing and reporting - along with suggestions for improvement - I attach PMsmartctl_Beta_0_1.zip


Regards

Pete



David Graser

  • Hero Member
  • *****
  • Posts: 870
  • Karma: +84/-0
    • View Profile
Re: OS2AHCI interface?
« Reply #6 on: April 13, 2020, 11:44:58 pm »
Hi Pete

Works great.

Dariusz Piatkowski

  • Hero Member
  • *****
  • Posts: 1317
  • Karma: +26/-0
    • View Profile
Re: OS2AHCI interface?
« Reply #7 on: April 14, 2020, 04:20:22 am »
Hey you guys!

Awesome conversation.

So let me shed a bit more light on what I had in mind. Way waaaayyy back when, I was heavily using the HPFS386 fs, I wrote some small stuff that basically allowed me to pull a bunch of cache details. I basically wanted to learn more about the fs internals and wasn't happy with the 'cache386 /stats:d' output.

Now fast fwd a bit and currently I'm using JFS, but I've moved on to the OS2AHCI driver, v2.07.

This means that any previous disk monitoring utilities that relied on DANIS506$ to be present are no longer working.

I currently use smartmontools RPM package, which works quite fine and supports both IDE and AHCI devices:

Code: [Select]
Name        : smartmontools
Arch        : pentium4
Epoch       : 1
Version     : 7.0
Release     : 1.oc00
Size        : 1.0 M
Repo        : installed

So from that perspective I will stick with this and won't be going back to the smartmontools-6.6-r4424.zip release.

However, to convert the PMDskMon utility to AHCI mode I need to understand what needs to be changed from the current DANIS506 interface. I wish I could find where the source for the RPM release of smartmontools is, because that clearly has a working AHCI interface. But given the lack of this information I'm taking a stab at removing all S.M.A.R.T. data collection functionality from the PMDskMon utility itself first to see if simply re-pointing it to OS2AHCI$ might work.

If this fails my next step is to look at the Netlabs project page for OS2AHCI which can be found here => http://trac.netlabs.org/ahci, I will do a SVN source pull and will take a look at the driver details (for what it's worth, as I expect much of this to be over my head lol).

Eventually I'd like to actually write a new utility that really exposes all the pertinent details a storage device has. There are numerous such non-OS/2 utilities out there, so some good interfaces to pick from. More importantly I would like this to also have some of the fs specific stuff in there, so things that pertain to JFS cache for example, etc. This is a very long-term plan though, so I'm happy to see that we already have some alternatives created by our very own!!!  ;)

Dave Yeo

  • Hero Member
  • *****
  • Posts: 4786
  • Karma: +99/-1
    • View Profile
Re: OS2AHCI interface?
« Reply #8 on: April 14, 2020, 05:04:07 am »

Pete

  • Hero Member
  • *****
  • Posts: 1281
  • Karma: +9/-0
    • View Profile
Re: OS2AHCI interface?
« Reply #9 on: April 14, 2020, 11:06:07 am »
Hi All

I have just quickly tested the smartmontools-7_0-1 package (from http://rpm.netlabs.org/experimental/00/zip/smartmontools-7_0-1_oc00.zip) and, so far, it seems that PMsmartctl is happy to use that release.


Regards

Pete

Dariusz Piatkowski

  • Hero Member
  • *****
  • Posts: 1317
  • Karma: +26/-0
    • View Profile
Re: OS2AHCI interface?
« Reply #10 on: April 14, 2020, 05:20:04 pm »
Hey Pete,

Hi All

I have just quickly tested the smartmontools-7_0-1 package (from http://rpm.netlabs.org/experimental/00/zip/smartmontools-7_0-1_oc00.zip) and, so far, it seems that PMsmartctl is happy to use that release...

I just tried your app here, it comes up fine, but once it does the window is non-responsive. It is in the foreground, no information is populated, it is waiting for me to tell it where to find smartctl but I can not actually push the Browse button.

So I manually updated the INI file, this now has the app showing me active radio buttons for PATA hd0 and SATA ahci0-ahci2, but I sitll can not click anywhere in the window itself.

Hmm...strange I thought, but hey, running in SMP mode here and it's not like that hasn't been a problem here and there. So I shut off 4 of the 5 CPU cores, re-started the app and indeed things work!!! So I would guess for some reason the app is not SMP-safe...

Otherwise it looks pretty nice, looking fwd to more testing Pete!

Pete

  • Hero Member
  • *****
  • Posts: 1281
  • Karma: +9/-0
    • View Profile
Re: OS2AHCI interface?
« Reply #11 on: April 14, 2020, 06:44:53 pm »
Hi Darriusz

Seems to be SMP safe here - developed on a system with an AMD FX 4300, all 4 cores active, not had that sort of problem - so far.

If I understand you correctly this happened the first time you started PMsmartctl - you had not previously run PMsmartctl and set the location of smartctl.exe ?

I do not think there is anything that is SMP unsafe in the startup code but will have a rummage through to see if I can find possible cause(s). At first glance the only thing that stands out is that I have not explicitly initialised a couple of variables...

That could make a difference if there is some "garbage" in the location used for the variable smartctlPath as that would mean the check for smartctlPath having a value would return True which would then set the smartctlFlag indicating smartctl.exe was available triggering a call to "smartctl --scan" which could cause the startup problem.

I'll have to do a little bit of re-coding and post a new build a little later for you to try. Will also have a rummage through underlying OS/2 API calls made during startup to see if there is anything known to be SMP unsafe but I do not think there is.

Out of interest will PMsmartctl run with 4 cores enabled on your system?


Regards

Pete


Pete

  • Hero Member
  • *****
  • Posts: 1281
  • Karma: +9/-0
    • View Profile
Re: OS2AHCI interface?
« Reply #12 on: April 14, 2020, 08:55:03 pm »
Hi Darriusz

PMsmartctl_Test1.zip attached - Simply unzip over previous release and Delete existing PMsmartctl.INI file.


Regards

Pete

Dariusz Piatkowski

  • Hero Member
  • *****
  • Posts: 1317
  • Karma: +26/-0
    • View Profile
Re: OS2AHCI interface?
« Reply #13 on: April 14, 2020, 09:16:35 pm »
Hi Pete,

Alright, you brought up some good questions and re-reading my previous post I can see that my description wasn't really clear.

Let me explain how I occasionally shut OFF cpu cores here. So my machine is AMD Phenom II X6 based box. 6 cores total, but when booting with 6 the WPS locks up at the blue-screen. So I have the 6th core disabled in BIOS and that allows me to boot up just fine. Never tracked this down, may have something to do with the motherboard having built-in video chipset, along with a few other things that my OS/2 configuratoin can not use.

Anyways, I boot up with 5 cores. Now, at times I need to shut off 4 of the 5 cores. For example, ANPM when started in full 5-core SMP mode will soft-lock the WPS, only CAD gets me out, but that's a system re-boot. So to avoid that outcome I flip to 1-core mode, start ANPM and the minute the window is built I flip back to 5-core mode. Again, haven't figured this out yet, tried playing with numerous approaches such as setting the EXE to SMP-unsafe, etc. I suspect somewhere on my machine is either a DLL, or perhaps a hardware setup that's the root cause.

To do this OFF/ON flip I use setproc.exe, which is a most handy utility by Yuri Dario.

Ok, so now let me answer below...

...If I understand you correctly this happened the first time you started PMsmartctl - you had not previously run PMsmartctl and set the location of smartctl.exe ?

As long as I am in the full SMP mode, so more than a single core active this always happens. Even after I manually edited the INI file and had the correct path to the smartctl.exe file, having re-started the program I still resulted in having a frozen non-responsive window.

The only time the app actually works is when I run in the limitted 1-core mode, as described above. So basically any other time I start it again, it will only work if I'm running in that 1-core mode, all other times it goes back to the soft-lock where just the app is non responsive. I can close it down with lSwitcher's Close=>Quit and do not have to use the harsher SIGKILL.

...I do not think there is anything that is SMP unsafe in the startup code but will have a rummage through to see if I can find possible cause(s). At first glance the only thing that stands out is that I have not explicitly initialised a couple of variables...

Hmm, good to hear that it is working fine on your end. It would trully be the icing on the cake if troubleshooting this issue would allow me to also figure out why full-core SMP mode here occasinally causes the problems I see. Right now my issue is limitted to impacting just your app, it does not lock up the whole WPS as it most often does with a handful of other apps I have.

...That could make a difference if there is some "garbage" in the location used for the variable smartctlPath as that would mean the check for smartctlPath having a value would return True which would then set the smartctlFlag indicating smartctl.exe was available triggering a call to "smartctl --scan" which could cause the startup problem...

OK, so on this subject I am curious about something. Once the path to smartctl.exe is provided the app continues to do something before I hit my lock. After all, the normally grayed out PATA and SATA fields do actually un-gray and I should be able to select which device I want to pull up the information for. So in your code the lock I see must happen after this point in time, which I'm guessing happens once smartctl (perhaps?) returns some valid list of devices maybe???

...I'll have to do a little bit of re-coding and post a new build a little later for you to try. Will also have a rummage through underlying OS/2 API calls made during startup to see if there is anything known to be SMP unsafe but I do not think there is...

Since we are in the coding forum, care to share your code? i ask b/c I pulled the source for smartmontools that Dave pointed me to. There is a specific OS/2 section in there (see os_os2.cpp and os_os2.h) which I am working throught right now to understand the differences between DANIS506 and OS2AHCI, I think I may have spotted something but I'm not quite sure yet. Given that your app does successfully allow me to pick one of my AHCI devices though would imply that your code at least knows how to differentiate between them and therefore must be issuing some call to determine what device is hooked to what controller. I'd love to see that code.

...Out of interest will PMsmartctl run with 4 cores enabled on your system?...

It runs, but goes into that non-responsive mode (I call soft-lock). Othewrise, only 1-core mode allows me to actually use it normally.

ivan

  • Hero Member
  • *****
  • Posts: 1557
  • Karma: +17/-0
    • View Profile
Re: OS2AHCI interface?
« Reply #14 on: April 14, 2020, 10:24:34 pm »
Hi Pete,

Your PMsmartctl.exe works here on my Ryzen based units.  Thanks, you software guys look to be getting there, us hardware guys can only sit back and say thanks.

Only one complaint, it would be nice if the table items were shown it columns.