?
Solved

Accessing the AT controller

Posted on 1997-07-29
6
Medium Priority
?
180 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 3
6 Comments
 
LVL 1

Accepted Solution

by:
FuzzyLogic earned 400 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
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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: 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.

Question has a verified solution.

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

Hello everybody This Article will show you how to validate number with TEdit control, What's the TEdit control? TEdit is a standard Windows edit control on a form, it allows to user to write, read and copy/paste single line of text. Usua…
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…
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…
Sometimes it takes a new vantage point, apart from our everyday security practices, to truly see our Active Directory (AD) vulnerabilities. We get used to implementing the same techniques and checking the same areas for a breach. This pattern can re…
Suggested Courses

752 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