Profil supprimé | Petit set de 4 fichiers qui vont bien...
Code :
-- Provide parallel ports address on Compatible IBM PC package Pp is LP0 : constant := 16#0278#; LP1 : constant := 16#0378#; LP2 : constant := 16#03BC#; type Message_Type is (Data, Status, Ctrl); end Pp;
|
Code :
-- Provide Gnu/Linux basic function to obtain desired IO permissions. with Interfaces.C; use Interfaces; package Pp.Ioperm is function Ioperm(From : in C.Unsigned_Long; Num : in C.Unsigned_Long; Tuen_On : in C.Int) return C.Int; pragma Import(C, Ioperm, "ioperm" ); end Pp.Ioperm;
|
Code :
-- Provide tow basic function to read and write value to parallel port. with Interfaces; generic LP : Interfaces.Unsigned_16; package Pp.Pp_Io is use Interfaces; procedure Put(Msg : in Message_Type; Value : in Unsigned_8); procedure Get(Msg : in Message_Type; Value : out Unsigned_8); end Pp.Pp_Io;
|
Code :
with System.Machine_Code; use System.Machine_Code; package body Pp.Pp_Io is use Interfaces, Ascii; procedure Put(Msg : in Message_Type; Value : in Unsigned_8) is begin Asm("mov %1, %%al" & LF & HT & "mov %0, %%dx" & LF & HT & "out %%al, %%dx", Inputs => (Unsigned_16'Asm_Input ("g", LP+Message_Type'Pos(Msg)), Unsigned_8'Asm_Input ("a", Value)), Volatile => True); end Put; procedure Get(Msg : in Message_Type; Value : out Unsigned_8) is begin Asm("mov %1,%%dx" & LF & HT & "in %%dx,%%al" & LF & HT & "mov %0, %%al", Inputs => (Unsigned_16'Asm_Input ("g", LP+Message_Type'Pos(Msg))), Outputs => Unsigned_8'Asm_Output ("=a", Value), Volatile => True); end Get; end Pp.Pp_Io;
|
Et un programme de test :
Code :
with Interfaces.C; use interfaces; with Text_Io, Ada.Integer_Text_Io; use Ada; with Pp.Ioperm, Pp.Pp_Io; use Pp; procedure Pp_Test is package Lpt1 is new Pp.Pp_Io(Pp.LP1); Value : Unsigned_8 := 0; Errno : C.Int := Pp.Ioperm.Ioperm(PP.LP1, 3, 1); begin if C."/="(Errno, 0) then raise Program_Error; end if; Lpt1.Put(Data, 128); delay 3.0; Lpt1.get(Data, Value); Text_Io.Put("Value = " ); Integer_Text_Io.Put(integer(Value), Base => 16); Text_Io.New_Line; delay 3.0; Lpt1.Put(Data, 0); Lpt1.get(Data, Value); Text_Io.Put("Value = " ); Integer_Text_Io.Put(integer(Value), Base => 16); Text_Io.New_Line; Errno := Pp.Ioperm.Ioperm(PP.LP1, 3, 0); end Pp_Test;
|
Edit, j'espère avoir apporté toute les correction qui s'imposaient. Message édité par Profil supprimé le 14-11-2011 à 21:16:27
|