Solved

Accessing the AT controller

Posted on 1997-07-29
6
170 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
IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 
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

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…
In my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

744 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now