From: "Jeff C," <nolongersafeto@userealemailsniff.com>
Subject: GNAT x86 Port Access
Date: Wed, 01 Oct 2003 01:16:40 GMT
Date: 2003-10-01T01:16:40+00:00 [thread overview]
Message-ID: <YVpeb.642486$Ho3.133082@sccrnsc03> (raw)
A few days ago there was a thread about doing x86 IO port access. I
eventually dug out my old laptop and found
a little (very little) package I wrote to do this. It is only setup to do
byte IO on the ports . It WILL NOT WORK under
windows 2000, NT, XP or any OS that limits the instructions that user land
applications can use. I have used
this under windows 98 with success.
with Interfaces;
package PC_IO_Port_Access is
--------------------------------------------------------------------------
----
--
-- PROCEDURE/FUNCTION: Inportb
--
-- PURPOSE: Performs a byte read of the given IO port address.
--
-- NOTES: None
--
--------------------------------------------------------------------------
----
function Inportb (
Port_Address : in Interfaces.Unsigned_16 )
return Interfaces.Unsigned_8;
--------------------------------------------------------------------------
----
--
-- PROCEDURE/FUNCTION: Outportb
--
-- PURPOSE: Writes the given value to the given port address.
--
-- NOTES: None
--
--------------------------------------------------------------------------
----
procedure Outportb (
Port_Address : in Interfaces.Unsigned_16;
Value : in Interfaces.Unsigned_8 );
end PC_IO_Port_Access;
with Machine_Code;
use Machine_Code;
package body PC_IO_Port_Access is
--------------------------------------------------------------------------
----
--
-- PROCEDURE/FUNCTION: Inportb
--
-- PURPOSE: Performs a byte read of the given IO port address.
--
-- NOTES: None
--
--------------------------------------------------------------------------
----
function Inportb (
Port_Address : in Interfaces.Unsigned_16 )
return Interfaces.Unsigned_8 is
Return_Value : Interfaces.Unsigned_8;
begin
Asm ("inb %1 %0", -- %%dx %%al",
Interfaces.Unsigned_8'Asm_Output ("=a", Return_Value),
Interfaces.Unsigned_16'Asm_Input("d", Port_Address));
return Return_Value;
end Inportb;
--------------------------------------------------------------------------
----
--
-- PROCEDURE/FUNCTION: Outportb
--
-- PURPOSE: Writes the given value to the given port address.
--
-- NOTES: None
--
-----------------------------------------------------------------------
procedure Outportb (
Port_Address : in Interfaces.Unsigned_16;
Value : in Interfaces.Unsigned_8 ) is
begin
Asm (Template => "outb %1 %0", -- %%dx %%al",
Inputs => (Interfaces.Unsigned_8'
Asm_Input ("a", Value),Interfaces.Unsigned_16'Asm_Input("d",
Port_Address)));
end OutPortb;
end PC_IO_Port_Access;
reply other threads:[~2003-10-01 1:16 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox