Solved

Accessing the AT controller

Posted on 1997-07-29
6
176 Views
Last Modified: 2010-04-03
Is there anyone who knows how to access the AT controller to recieve such fancy stuff like disk serialnumber, firmware info and disktype etc?
I'm talking direct port access according to ATA-X standard.
/thanx
0
Comment
Question by:leja
  • 3
  • 3
6 Comments
 
LVL 1

Accepted Solution

by:
FuzzyLogic earned 100 total points
ID: 1340153
Well, here it is.

I think that the problem you encountered with is that you didn't wait until the HDC finished executing your request ($EC), and therefore could not give you the desired information.

Anyway, followed by this message a WORKING program that get the information of the HDs. (The only part I'm not sure of is identifing Master/Slave HDs since I could not check that in my system - so let me know...).
However, if you give incorrect parameters, the program will _Wait_ forever in an infinit-loop (drive never ready).

The program is writen in pascal, because I started working on it when your question was in the Pascal-topic. I used some assembler in it, but I'm sure you can handle it (...).


PS.  If you want all the ports usage, check "Ralf Brown Interrup List".


       FuzzyLogic
0
 
LVL 1

Expert Comment

by:FuzzyLogic
ID: 1340154
program Idetify;

type
  BufT=array[0..$200] of byte;

var
  Buffer:BufT;
  Base:word;
  a:byte;


function PrintStr(Buffer:BufT; start,len:word):string;
  var
    a:word;
    S:string;
  begin;
    S:='';
    for a:=start to (start+len-1) do S:=S+char(Buffer[a]);
    PrintStr:=S;
  end;


procedure Wait; assembler;
  asm
    mov  dx,Base
    add  dx,7    { 01x7 - HDC status register }
@loop:
    in   al,dx
    and  al,80h
    jnz  @loop   { Loop until ready... }
  end;


begin;
  writeln;
  write('Choose HDC [1-4]: '); readln(a);
  case a of
    1: Base:=$01F0;
    2: Base:=$0170;
    3: Base:=$01E8; { I'm not sure if it works with }
    4: Base:=$0168; { the 3rd and the 4th EIDE HDC  }
    else Halt(2);
  end;

  write('Choose Drive [0-1]: '); readln(a);
  if a>1 then Halt(2);

  asm
    lea  di,Buffer
    mov  ax,ds
    mov  es,ax

    mov  dx,Base
    add  dx,1      { 01x1 - Error register        }
    in   al,dx
    and  al,7
    cmp  al,1
    jg   @Error

    call Wait

    mov  dx,Base
    add  dx,6      { 01x6 - Drive/Head            }
    in   al,dx
    cmp  a,0
    je   @Drive0
    { Drive 1 }
    or   al,00001000b
    jmp  @DriveDone
@Drive0:
    and  al,11110111b
@DriveDone:
    out  dx,al
    call Wait

    mov  dx,Base
    add  dx,7      { 01x7 - Command register      }
    mov  al,0ECh   {        EC - Identify drive   }
    out  dx,al
    call Wait

    mov  cx,0100h  { read 100h WORDs = 200h BYTEs }
    mov  dx,Base   { 01x0 - Data register         }
    cld
@ReadLoop:
    in   ax,dx
    xchg ah,al
    stosw
    loop @ReadLoop

@Error:
  end;

  writeln;
  writeln('Serial Number     : ',PrintStr(Buffer,$14,20));
  writeln('Firmware Revision : ',PrintStr(Buffer,$2E,8));
  writeln('Model Number      : ',PrintStr(Buffer,$36,40));

end.
0
 

Author Comment

by:leja
ID: 1340155
Thanx!!!

Accepting the answer as extremely excellent. You couldn't be more preemptive.
All I can say is that I was almost there but you saved me a couple of hours work:-)
Stupid of me not to think of RB's listing, have it available in my computer but doesn't use it to often I guess...

/LeJa
0
Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
LVL 1

Expert Comment

by:FuzzyLogic
ID: 1340156
Glad I could help.
0
 

Author Comment

by:leja
ID: 1340157
Have tried it on my desknote with docking station and it reported the same disk serial number and model on both drive 0 and 1 on the primary controller but it's a weird environment to work in so my guess is that it works well on any system. My second controller located in the docking station did report right values, one drive on number 0 and nothing on number 1.
Did try it under Windows 95 however and it didn't work at all but that was expected, guess I'll have to write a little miniport-driver or something for that since direct portaccess is a little bit forbidden under this OS...

Great work!
0
 

Author Comment

by:leja
ID: 1340158
Have tried it on my desknote with docking station and it reported the same disk serial number and model on both drive 0 and 1 on the primary controller but it's a weird environment to work in so my guess is that it works well on any system. My second controller located in the docking station did report right values, one drive on number 0 and nothing on number 1.
Did try it under Windows 95 however and it didn't work at all but that was expected, guess I'll have to write a little miniport-driver or something for that since direct portaccess is a little bit forbidden under this OS...

Great work!
0

Featured Post

Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Help on project with Soap 10 57
How to open a new windows chrome resized and disabled the toolbar? 3 152
How to debug For loops? 3 56
Delphi: Connect to running MS Outlook 4 120
In this tutorial I will show you how to use the Windows Speech API in Delphi. I will only cover basic functions such as text to speech and controlling the speed of the speech. SAPI Installation First you need to install the SAPI type library, th…
Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

860 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question