From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=0.5 required=5.0 tests=BAYES_00,TO_NO_BRKTS_PCNT, XPRIO autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,dcb091e03ddd8560,start X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2003-09-30 18:16:41 PST Path: archiver1.google.com!news2.google.com!newsfeed.stanford.edu!headwall.stanford.edu!newshub.sdsu.edu!tethys.csu.net!arclight.uoregon.edu!wn13feed!wn11feed!worldnet.att.net!204.127.198.203!attbi_feed3!attbi.com!sccrnsc03.POSTED!not-for-mail From: "Jeff C," Newsgroups: comp.lang.ada Subject: GNAT x86 Port Access X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2800.1158 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165 Message-ID: NNTP-Posting-Host: 66.31.4.164 X-Complaints-To: abuse@comcast.net X-Trace: sccrnsc03 1064971000 66.31.4.164 (Wed, 01 Oct 2003 01:16:40 GMT) NNTP-Posting-Date: Wed, 01 Oct 2003 01:16:40 GMT Organization: Comcast Online Date: Wed, 01 Oct 2003 01:16:40 GMT Xref: archiver1.google.com comp.lang.ada:48 Date: 2003-10-01T01:16:40+00:00 List-Id: 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;