~ubuntu-branches/debian/lenny/fpc/lenny

« back to all changes in this revision

Viewing changes to rtl/emx/ports.pas

  • Committer: Bazaar Package Importer
  • Author(s): Mazen Neifer, Torsten Werner, Mazen Neifer
  • Date: 2008-05-17 17:12:11 UTC
  • mfrom: (3.1.9 intrepid)
  • Revision ID: james.westby@ubuntu.com-20080517171211-9qi33xhd9evfa0kg
Tags: 2.2.0-dfsg1-9
[ Torsten Werner ]
* Add Mazen Neifer to Uploaders field.

[ Mazen Neifer ]
* Moved FPC sources into a version dependent directory from /usr/share/fpcsrc
  to /usr/share/fpcsrc/${FPCVERSION}. This allow installing more than on FPC
  release.
* Fixed far call issue in compiler preventing building huge binearies.
  (closes: #477743)
* Updated building dependencies, recomennded and suggested packages.
* Moved fppkg to fp-utils as it is just a helper tool and is not required by
  compiler.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
{
2
 
    $Id: ports.pas,v 1.3 2003/12/26 22:20:44 hajny Exp $
3
 
    This file is part of the Free Pascal run time library.
4
 
    Copyright (c) 1999-2000 by the Free Pascal development team.
5
 
 
6
 
    These files adds support for TP styled port accesses (port[],
7
 
    portw[] and portl[] constructs) using Delphi classes.
8
 
 
9
 
    See the file COPYING.FPC, included in this distribution,
10
 
    for details about the copyright.
11
 
 
12
 
    This program is distributed in the hope that it will be useful,
13
 
    but WITHOUT ANY WARRANTY; without even the implied warranty of
14
 
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
15
 
 
16
 
 **********************************************************************}
17
 
 
18
 
(*
19
 
  Warning:
20
 
  1) You have to enable port access in your CONFIG.SYS (IOPL directive),
21
 
     either globally (IOPL=YES), or just for particular application/-s with
22
 
     a need for port access (IOPL=app_name1, appname2, ...).
23
 
  2) Once you access some port, access to this port is enabled all the time
24
 
     for all EMX applications until EMX.DLL is unloaded from memory (i.e.
25
 
     all applications using this library finish).
26
 
*)
27
 
    
28
 
unit Ports;
29
 
 
30
 
{ This unit uses classes so ObjFpc mode is required. }
31
 
{$Mode ObjFpc}
32
 
 
33
 
interface
34
 
    
35
 
type
36
 
 TPort = class
37
 
  protected
38
 
   procedure WritePort (P: word; Data: byte);
39
 
   function ReadPort (P: word): byte;
40
 
  public
41
 
   property PP [W: word]: byte read readport write writeport; default;
42
 
 end;
43
 
 
44
 
 TPortW = class
45
 
  protected
46
 
   procedure WritePort (P: word; Data: word);
47
 
   function ReadPort (P: word): word;
48
 
  public
49
 
   property PP [W: word]: word read readport write writeport; default;
50
 
 end;
51
 
 
52
 
 TPortL = class
53
 
  protected
54
 
   procedure WritePort (P: word; Data: longint);
55
 
   function ReadPort (P: word): longint;
56
 
  public
57
 
   property PP [W: word]: longint read readport write writeport; default;
58
 
 end;
59
 
 
60
 
 { Non-instantiated vars. As yet, they don't have to be instantiated,
61
 
   because neither member variables nor virtual methods are accessed }
62
 
 
63
 
var
64
 
 Port, PortB: TPort;
65
 
 PortW: TPortW;
66
 
 PortL: TPortL;
67
 
 
68
 
implementation
69
 
 
70
 
{Import syscall to call it nicely from assembler procedures.}
71
 
 
72
 
procedure syscall; external name '___SYSCALL';
73
 
 
74
 
{$AsmMode ATT}
75
 
 
76
 
procedure TPort.WritePort (P: word; Data: byte); assembler;
77
 
asm
78
 
 xorl %ecx, %ecx
79
 
{$IFDEF REGCALL}
80
 
 movw %ax, %cx
81
 
 pushl %edx
82
 
 pushl %ecx
83
 
{$ELSE REGCALL}
84
 
 movw P, %cx
85
 
{$ENDIF REGCALL}
86
 
 movl %ecx, %edx
87
 
 movw $0x7F12, %ax
88
 
 call syscall
89
 
{$IFDEF REGCALL}
90
 
 popl %edx
91
 
 popl %eax
92
 
{$ELSE REGCALL}
93
 
 movw P, %dx
94
 
 movb Data, %al
95
 
{$ENDIF REGCALL}
96
 
 outb %al, %dx
97
 
end {['eax', 'ecx', 'edx']};
98
 
 
99
 
function TPort.ReadPort (P: word): byte; assembler;
100
 
asm
101
 
 xorl %ecx, %ecx
102
 
{$IFDEF REGCALL}
103
 
 movw %ax, %cx
104
 
{$ELSE REGCALL}
105
 
 movw P, %cx
106
 
 pushl %ecx
107
 
{$ENDIF REGCALL}
108
 
 movl %ecx, %edx
109
 
 movw $0x7F12, %ax
110
 
 call syscall
111
 
{$IFDEF REGCALL}
112
 
 popl %edx
113
 
{$ELSE REGCALL}
114
 
 movw P, %dx
115
 
{$ENDIF REGCALL}
116
 
 inb %dx, %al
117
 
end {['eax', 'ecx', 'edx']};
118
 
 
119
 
procedure TPortW.WritePort (P: word; Data : word); assembler;
120
 
asm
121
 
 xorl %ecx, %ecx
122
 
{$IFDEF REGCALL}
123
 
 movw %ax, %cx
124
 
 pushl %edx
125
 
 pushl %ecx
126
 
{$ELSE REGCALL}
127
 
 movw P, %cx
128
 
{$ENDIF REGCALL}
129
 
 movl %ecx, %edx
130
 
 movw $0x7F12, %ax
131
 
 call syscall
132
 
{$IFDEF REGCALL}
133
 
 popl %edx
134
 
 popl %eax
135
 
{$ELSE REGCALL}
136
 
 movw P, %dx
137
 
 movw Data, %ax
138
 
{$ENDIF REGCALL}
139
 
 outw %ax, %dx
140
 
end {['eax', 'ecx', 'edx']};
141
 
 
142
 
function TPortW.ReadPort (P: word): word; assembler;
143
 
asm
144
 
 xorl %ecx, %ecx
145
 
{$IFDEF REGCALL}
146
 
 movw %ax, %cx
147
 
 pushl %ecx
148
 
{$ELSE REGCALL}
149
 
 movw P, %cx
150
 
{$ENDIF REGCALL}
151
 
 movl %ecx, %edx
152
 
 movw $0x7F12, %ax
153
 
 call syscall
154
 
{$IFDEF REGCALL}
155
 
 popl %edx
156
 
{$ELSE REGCALL}
157
 
 movw P, %dx
158
 
{$ENDIF REGCALL}
159
 
 inw %dx, %ax
160
 
end {['eax', 'ecx', 'edx']};
161
 
 
162
 
procedure TPortL.WritePort (P: word; Data: longint); assembler;
163
 
asm
164
 
 xorl %ecx, %ecx
165
 
{$IFDEF REGCALL}
166
 
 movw %ax, %cx
167
 
 pushl %edx
168
 
 pushl %ecx
169
 
{$ELSE REGCALL}
170
 
 movw P, %cx
171
 
{$ENDIF REGCALL}
172
 
 movl %ecx, %edx
173
 
 movw $0x7F12, %ax
174
 
 call syscall
175
 
{$IFDEF REGCALL}
176
 
 popl %edx
177
 
 popl %eax
178
 
{$ELSE REGCALL}
179
 
 movw P, %dx
180
 
 movl Data, %eax
181
 
{$ENDIF REGCALL}
182
 
 outl %eax, %dx
183
 
end {['eax', 'ecx', 'edx']};
184
 
 
185
 
function TPortL.ReadPort (P: word): longint; assembler;
186
 
asm
187
 
 xorl %ecx, %ecx
188
 
{$IFDEF REGCALL}
189
 
 movw %ax, %cx
190
 
 pushl %ecx
191
 
{$ELSE REGCALL}
192
 
 movw P, %cx
193
 
{$ENDIF REGCALL}
194
 
 movl %ecx, %edx
195
 
 movw $0x7F12, %ax
196
 
 call syscall
197
 
{$IFDEF REGCALL}
198
 
 popl %edx
199
 
{$ELSE REGCALL}
200
 
 movw P, %dx
201
 
{$ENDIF REGCALL}
202
 
 inl %dx, %eax
203
 
end {['eax', 'ecx', 'edx']};
204
 
 
205
 
end.
206
 
 
207
 
{
208
 
  $Log: ports.pas,v $
209
 
  Revision 1.3  2003/12/26 22:20:44  hajny
210
 
    * regcall fixes
211
 
 
212
 
  Revision 1.2  2003/10/07 21:33:24  hajny
213
 
    * stdcall fixes and asm routines cleanup
214
 
 
215
 
  Revision 1.1  2002/11/17 16:22:54  hajny
216
 
    + RTL for emx target
217
 
 
218
 
  Revision 1.2  2002/09/07 16:01:25  peter
219
 
    * old logs removed and tabs fixed
220
 
 
221
 
}