* GNAT x86 Port Access
@ 2003-10-01 1:16 Jeff C,
0 siblings, 0 replies; only message in thread
From: Jeff C, @ 2003-10-01 1:16 UTC (permalink / 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;
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2003-10-01 1:16 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-10-01 1:16 GNAT x86 Port Access Jeff C,
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox