Solved

Accessing the AT controller

Posted on 1997-07-29
6
177 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
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

Secure Your Active Directory - April 20, 2017

Active Directory plays a critical role in your company’s IT infrastructure and keeping it secure in today’s hacker-infested world is a must.
Microsoft published 300+ pages of guidance, but who has the time, money, and resources to implement? Register now to find an easier way.

Question has a verified solution.

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

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…
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…
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…
In an interesting question (https://www.experts-exchange.com/questions/29008360/) here at Experts Exchange, a member asked how to split a single image into multiple images. The primary usage for this is to place many photographs on a flatbed scanner…

680 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