direct IO - Programmers Heaven

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

direct IO

softmansoftman Posts: 157Member
Hi!

I wrote a component, which retrives the bios data, like bios serial number, hdd, fdd settings, etc. The component reads directly from BIOS memory, using inline assembly. Here is a part of the code, (if I remember right) which reads the bios ,and put data into an array, in the components constructor:

[code]
constructor GetBiosInfo.Create(Owner: TComponent);
var
i,r : byte;
data : array[0..128] of byte;
begin
inherited Create(Owner); // Initialize inherited parts
r := 0; // allocate r in memory
for i:= 0 to 128 do
begin;
asm
xor ah,ah // clear accumlator
mov al,i // set required byte number
cli // clear interrupt
out $070,al // set register
nop
nop
nop // wait for output take place
in al,$071 // get bios data
mov r,al // set r as required byte
sti // reset interrupts
end;
data[i] := r;
end;
end;
[/code]


This function works well on windows 95, and 98 plattforms, but cannot work on XP, because I get a privileged instruction exception. I think the reason is the Protected mode differs in windows XP, and does not allow sti, cli, in and out.

Any idea, how else could I read bios data, if I do not really want to set any windows 98 emulation mode for my prog. I was searching for windows API functions, but I could not found any implementation.

Any help would be appriciated


Comments

  • MasterijnMasterijn Posts: 188Member
    : Hi!
    :
    : I wrote a component, which retrives the bios data, like bios serial number, hdd, fdd settings, etc. The component reads directly from BIOS memory, using inline assembly. Here is a part of the code, (if I remember right) which reads the bios ,and put data into an array, in the components constructor:
    :
    : [code]
    : constructor GetBiosInfo.Create(Owner: TComponent);
    : var
    : i,r : byte;
    : data : array[0..128] of byte;
    : begin
    : inherited Create(Owner); // Initialize inherited parts
    : r := 0; // allocate r in memory
    : for i:= 0 to 128 do
    : begin;
    : asm
    : xor ah,ah // clear accumlator
    : mov al,i // set required byte number
    : cli // clear interrupt
    : out $070,al // set register
    : nop
    : nop
    : nop // wait for output take place
    : in al,$071 // get bios data
    : mov r,al // set r as required byte
    : sti // reset interrupts
    : end;
    : data[i] := r;
    : end;
    : end;
    : [/code]
    :
    :
    : This function works well on windows 95, and 98 plattforms, but cannot work on XP, because I get a privileged instruction exception. I think the reason is the Protected mode differs in windows XP, and does not allow sti, cli, in and out.
    :
    : Any idea, how else could I read bios data, if I do not really want to set any windows 98 emulation mode for my prog. I was searching for windows API functions, but I could not found any implementation.
    :
    : Any help would be appriciated
    :
    :
    :
    Only kernel-drivers can access hardware this way or execute privilleged instructions. You could search for a driver that can deliver such services.


  • softmansoftman Posts: 157Member
    Thank you, I'll try searching for a driver!

    softman

    : : Hi!
    : :
    : : I wrote a component, which retrives the bios data, like bios serial number, hdd, fdd settings, etc. The component reads directly from BIOS memory, using inline assembly. Here is a part of the code, (if I remember right) which reads the bios ,and put data into an array, in the components constructor:
    : :
    : : [code]
    : : constructor GetBiosInfo.Create(Owner: TComponent);
    : : var
    : : i,r : byte;
    : : data : array[0..128] of byte;
    : : begin
    : : inherited Create(Owner); // Initialize inherited parts
    : : r := 0; // allocate r in memory
    : : for i:= 0 to 128 do
    : : begin;
    : : asm
    : : xor ah,ah // clear accumlator
    : : mov al,i // set required byte number
    : : cli // clear interrupt
    : : out $070,al // set register
    : : nop
    : : nop
    : : nop // wait for output take place
    : : in al,$071 // get bios data
    : : mov r,al // set r as required byte
    : : sti // reset interrupts
    : : end;
    : : data[i] := r;
    : : end;
    : : end;
    : : [/code]
    : :
    : :
    : : This function works well on windows 95, and 98 plattforms, but cannot work on XP, because I get a privileged instruction exception. I think the reason is the Protected mode differs in windows XP, and does not allow sti, cli, in and out.
    : :
    : : Any idea, how else could I read bios data, if I do not really want to set any windows 98 emulation mode for my prog. I was searching for windows API functions, but I could not found any implementation.
    : :
    : : Any help would be appriciated
    : :
    : :
    : :
    : Only kernel-drivers can access hardware this way or execute privilleged instructions. You could search for a driver that can deliver such services.
    :
    :
    :

Sign In or Register to comment.