port 0.9.0-x86-linux
Sign up to get free protection for your applications and to get access to all the features.
- data/README +40 -0
- data/Rakefile +94 -0
- data/doc/classes/Port.html +232 -0
- data/doc/created.rid +1 -0
- data/doc/files/README.html +175 -0
- data/doc/files/ext/port_c.html +92 -0
- data/doc/fr_class_index.html +46 -0
- data/doc/fr_file_index.html +47 -0
- data/doc/fr_method_index.html +48 -0
- data/doc/index.html +20 -0
- data/doc/rdoc-style.css +175 -0
- data/example/time.rb +22 -0
- data/ext/Makefile +143 -0
- data/ext/Rakefile +14 -0
- data/ext/extconf.rb +2 -0
- data/ext/port.c +69 -0
- data/ext/port.o +0 -0
- data/ext/port.so +0 -0
- metadata +79 -0
data/README
ADDED
@@ -0,0 +1,40 @@
|
|
1
|
+
= Installation
|
2
|
+
|
3
|
+
=== Installing from a gem
|
4
|
+
gem install port
|
5
|
+
|
6
|
+
=== Manual installation -- if you have rake.
|
7
|
+
rake
|
8
|
+
sudo rake install
|
9
|
+
|
10
|
+
To uninstall: sudo rake uninstall
|
11
|
+
|
12
|
+
=== Manual installation -- if you do NOT have rake.
|
13
|
+
change directory to ext sub-directory.
|
14
|
+
ruby extconf.rb -> generates the Makefile.
|
15
|
+
make -> compiles the extension. Requires gcc .
|
16
|
+
copy port.so to:
|
17
|
+
/usr/lib/ruby/site_ruby/1.8/i386-linux
|
18
|
+
or another path in your ruby $LOAD_PATH .
|
19
|
+
|
20
|
+
== Usage
|
21
|
+
If installed via gem:
|
22
|
+
require 'rubygems'
|
23
|
+
require 'port'
|
24
|
+
|
25
|
+
otherwise
|
26
|
+
require 'port'
|
27
|
+
will suffice.
|
28
|
+
|
29
|
+
== Example
|
30
|
+
For an example run. time.rb as follows:
|
31
|
+
sudo ./time.rb
|
32
|
+
|
33
|
+
time.rb is in the example sub-directory. This requires root permissions to access the IO ports.
|
34
|
+
|
35
|
+
time.rb listing:
|
36
|
+
:include:example/time.rb
|
37
|
+
|
38
|
+
== Who wrote port?
|
39
|
+
Port was written by Loh Siu Yin <siuyin@beyondbroadcast.com> as he needed to
|
40
|
+
control external hardware devices and he wanted to do it from ruby.
|
data/Rakefile
ADDED
@@ -0,0 +1,94 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'rake/rdoctask'
|
3
|
+
require 'rake/gempackagetask'
|
4
|
+
|
5
|
+
task(:default => [:build])
|
6
|
+
task :package => :build
|
7
|
+
task :build => :rdoc
|
8
|
+
|
9
|
+
spec = Gem::Specification.new do |s|
|
10
|
+
s.name = 'port'
|
11
|
+
s.version = '0.9.0'
|
12
|
+
s.files = FileList['README','doc/**/*',
|
13
|
+
'Rakefile','ext/**/*','example/**/*'].to_a
|
14
|
+
s.summary = "Low-level port access from ruby on Linux."
|
15
|
+
s.has_rdoc=true
|
16
|
+
s.author="Loh Siu Yin"
|
17
|
+
s.email="siuyin@beyondbroadcast.com"
|
18
|
+
s.homepage="http://port.rubyforge.org/"
|
19
|
+
s.extensions.push 'ext/extconf.rb'
|
20
|
+
s.require_paths.push 'ext'
|
21
|
+
s.platform=Gem::Platform::CURRENT
|
22
|
+
s.rdoc_options << '--title' << 'Port - low-level port access for Linux.' <<
|
23
|
+
'--main' << 'Port' << '-S'
|
24
|
+
s.extra_rdoc_files = ['README']
|
25
|
+
s.requirements=['1. A linux x86 system.',
|
26
|
+
'2. gcc - the GNU C compiler must be installed.']
|
27
|
+
s.rubyforge_project = 'port'
|
28
|
+
end
|
29
|
+
|
30
|
+
Rake::GemPackageTask.new(spec) { |pkg|
|
31
|
+
pkg.need_tar=true
|
32
|
+
pkg.need_zip=false
|
33
|
+
}
|
34
|
+
|
35
|
+
Rake::RDocTask.new do |d|
|
36
|
+
d.title='Port - low-level port access for Linux.'
|
37
|
+
d.template='jamis.rb'
|
38
|
+
d.options= [ "-mPort", '-S']
|
39
|
+
d.rdoc_dir='doc'
|
40
|
+
d.rdoc_files.include("ext/port.c", "README")
|
41
|
+
end
|
42
|
+
|
43
|
+
desc "Clean out build artifacts."
|
44
|
+
#task :clean do
|
45
|
+
# sh "rm -rf lib/port.so lib/Makefile lib/port.o pkg port.o port.so Makefile doc"
|
46
|
+
#end
|
47
|
+
task(:clean) {
|
48
|
+
sh "rm -rf doc pkg"
|
49
|
+
Dir.chdir 'ext'
|
50
|
+
sh "rake clean"
|
51
|
+
Dir.chdir '..'
|
52
|
+
}
|
53
|
+
|
54
|
+
task(:build) {
|
55
|
+
Dir.chdir 'ext'
|
56
|
+
sh "rake"
|
57
|
+
Dir.chdir '..'
|
58
|
+
}
|
59
|
+
|
60
|
+
desc "Check for root permission."
|
61
|
+
task :root? do
|
62
|
+
ret = false
|
63
|
+
if Process::Sys.getuid == 0
|
64
|
+
ret = true
|
65
|
+
else
|
66
|
+
puts "*** ERROR: Root permissions required."
|
67
|
+
puts "run sudo rake #{ARGV[0]}"
|
68
|
+
exit
|
69
|
+
end
|
70
|
+
ret
|
71
|
+
end
|
72
|
+
|
73
|
+
desc "Install the port.so extension."
|
74
|
+
task :install => [:build,:root?] do
|
75
|
+
install_path = $LOAD_PATH.reject {|e| !e.include?('site') || !e.include?('linux')}.first
|
76
|
+
puts "installing to: #{install_path}"
|
77
|
+
sh "cp ext/port.so #{install_path}"
|
78
|
+
end
|
79
|
+
|
80
|
+
desc "Uninstall the port.so extension."
|
81
|
+
task :uninstall => :root? do
|
82
|
+
install_path = $LOAD_PATH.reject {|e| !e.include?('site') || !e.include?('linux')}.first
|
83
|
+
target = install_path + '/port.so'
|
84
|
+
if File.exists?(target)
|
85
|
+
sh "rm #{target}"
|
86
|
+
puts "port.so extension uninstalled."
|
87
|
+
end
|
88
|
+
end
|
89
|
+
|
90
|
+
desc "Sync doc with web-page at rubyforge.org."
|
91
|
+
task :syncdoc => :rdoc do
|
92
|
+
sh "rsync --delete --exclude .svn -avz doc/ siuyin@rubyforge.org:/var/www/gforge-projects/port/doc"
|
93
|
+
sh "rsync index.html siuyin@rubyforge.org:/var/www/gforge-projects/port/index.html"
|
94
|
+
end
|
@@ -0,0 +1,232 @@
|
|
1
|
+
<?xml version="1.0" encoding="iso-8859-1"?>
|
2
|
+
<!DOCTYPE html
|
3
|
+
PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
|
4
|
+
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
5
|
+
<html>
|
6
|
+
<head>
|
7
|
+
<title>Class: Port</title>
|
8
|
+
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
|
9
|
+
<link rel="stylesheet" href=".././rdoc-style.css" type="text/css" media="screen" />
|
10
|
+
|
11
|
+
<script language="JavaScript" type="text/javascript">
|
12
|
+
// <![CDATA[
|
13
|
+
|
14
|
+
function toggleSource( id )
|
15
|
+
{
|
16
|
+
var elem
|
17
|
+
var link
|
18
|
+
|
19
|
+
if( document.getElementById )
|
20
|
+
{
|
21
|
+
elem = document.getElementById( id )
|
22
|
+
link = document.getElementById( "l_" + id )
|
23
|
+
}
|
24
|
+
else if ( document.all )
|
25
|
+
{
|
26
|
+
elem = eval( "document.all." + id )
|
27
|
+
link = eval( "document.all.l_" + id )
|
28
|
+
}
|
29
|
+
else
|
30
|
+
return false;
|
31
|
+
|
32
|
+
if( elem.style.display == "block" )
|
33
|
+
{
|
34
|
+
elem.style.display = "none"
|
35
|
+
link.innerHTML = "show source"
|
36
|
+
}
|
37
|
+
else
|
38
|
+
{
|
39
|
+
elem.style.display = "block"
|
40
|
+
link.innerHTML = "hide source"
|
41
|
+
}
|
42
|
+
}
|
43
|
+
|
44
|
+
function openCode( url )
|
45
|
+
{
|
46
|
+
window.open( url, "SOURCE_CODE", "width=400,height=400,scrollbars=yes" )
|
47
|
+
}
|
48
|
+
// ]]>
|
49
|
+
</script>
|
50
|
+
</head>
|
51
|
+
|
52
|
+
<body>
|
53
|
+
<table width="100%" border='0' cellpadding='0' cellspacing='0' class='banner'><tr>
|
54
|
+
<td class="file-title"><span class="file-title-prefix">Class</span><br />Port</td>
|
55
|
+
<td align="right">
|
56
|
+
<table cellspacing=0 cellpadding=2>
|
57
|
+
<tr valign="top">
|
58
|
+
<td>In:</td>
|
59
|
+
<td>
|
60
|
+
<a href="../files/ext/port_c.html">ext/port.c</a>
|
61
|
+
</td>
|
62
|
+
</tr>
|
63
|
+
<tr>
|
64
|
+
<td>Parent:</td>
|
65
|
+
<td>
|
66
|
+
Object
|
67
|
+
</td>
|
68
|
+
</tr>
|
69
|
+
</table>
|
70
|
+
</td>
|
71
|
+
</tr>
|
72
|
+
</table>
|
73
|
+
<!-- banner header -->
|
74
|
+
|
75
|
+
<div id="bodyContent">
|
76
|
+
<div id="content">
|
77
|
+
|
78
|
+
<div class="description"><p>
|
79
|
+
<a href="Port.html">Port</a> - Ruby extension to provide low-level access
|
80
|
+
to IO ports on an x86 GNU/Linux system.
|
81
|
+
</p>
|
82
|
+
<p>
|
83
|
+
License: GPL v2 or (at your option) any later version. See <a
|
84
|
+
href="http://www.fsf.org/licensing">www.fsf.org/licensing</a> .
|
85
|
+
</p>
|
86
|
+
<p>
|
87
|
+
Copyright (C) 2008, Loh Siu Yin (siuyin@beyondbroadcast.com)
|
88
|
+
</p>
|
89
|
+
<p>
|
90
|
+
IMPORTANT NOTE: These routines require root privilege.
|
91
|
+
</p>
|
92
|
+
<pre>
|
93
|
+
Use:
|
94
|
+
sudo <your_ruby_program> or
|
95
|
+
su -l root, then run your_ruby_program.
|
96
|
+
</pre>
|
97
|
+
<p>
|
98
|
+
The <a href="../files/README.html">README</a> file provides further
|
99
|
+
details.
|
100
|
+
</p>
|
101
|
+
</div>
|
102
|
+
|
103
|
+
|
104
|
+
|
105
|
+
<div class="sectiontitle">Methods</div>
|
106
|
+
<ul>
|
107
|
+
<li><a href="#M000002">inb</a></li>
|
108
|
+
<li><a href="#M000001">iopl</a></li>
|
109
|
+
<li><a href="#M000003">outb</a></li>
|
110
|
+
</ul>
|
111
|
+
|
112
|
+
|
113
|
+
|
114
|
+
|
115
|
+
|
116
|
+
|
117
|
+
<div class="sectiontitle">Public Class methods</div>
|
118
|
+
<div class="method">
|
119
|
+
<div class="title">
|
120
|
+
<a name="M000002"></a><b>inb</b>(p1)
|
121
|
+
</div>
|
122
|
+
<div class="description">
|
123
|
+
<p>
|
124
|
+
<a href="Port.html#M000002">inb</a> - read a byte from a port.
|
125
|
+
</p>
|
126
|
+
<p>
|
127
|
+
Example:
|
128
|
+
</p>
|
129
|
+
<pre>
|
130
|
+
require 'rubygems'
|
131
|
+
require 'port'
|
132
|
+
my_byte_from_port_hex_71 = Port.inb(0x71)
|
133
|
+
</pre>
|
134
|
+
</div>
|
135
|
+
<div class="sourcecode">
|
136
|
+
<p class="source-link">[ <a href="javascript:toggleSource('M000002_source')" id="l_M000002_source">show source</a> ]</p>
|
137
|
+
<div id="M000002_source" class="dyn-source">
|
138
|
+
<pre>
|
139
|
+
/* inb - read a byte from a port.
|
140
|
+
*
|
141
|
+
* Example:
|
142
|
+
* require 'rubygems'
|
143
|
+
* require 'port'
|
144
|
+
* my_byte_from_port_hex_71 = Port.inb(0x71)
|
145
|
+
*/
|
146
|
+
static VALUE
|
147
|
+
p_inb(VALUE self, VALUE port) {
|
148
|
+
|
149
|
+
</pre>
|
150
|
+
</div>
|
151
|
+
</div>
|
152
|
+
</div>
|
153
|
+
<div class="method">
|
154
|
+
<div class="title">
|
155
|
+
<a name="M000001"></a><b>iopl</b>(p1)
|
156
|
+
</div>
|
157
|
+
<div class="description">
|
158
|
+
<p>
|
159
|
+
<a href="Port.html#M000001">iopl</a> - set IO permission level. A level of
|
160
|
+
3 is required for full read/write access to all ports.
|
161
|
+
</p>
|
162
|
+
<p>
|
163
|
+
Example:
|
164
|
+
</p>
|
165
|
+
<pre>
|
166
|
+
require 'rubygems'
|
167
|
+
require 'port'
|
168
|
+
Port.iopl(3)
|
169
|
+
</pre>
|
170
|
+
</div>
|
171
|
+
<div class="sourcecode">
|
172
|
+
<p class="source-link">[ <a href="javascript:toggleSource('M000001_source')" id="l_M000001_source">show source</a> ]</p>
|
173
|
+
<div id="M000001_source" class="dyn-source">
|
174
|
+
<pre>
|
175
|
+
/* iopl - set IO permission level.
|
176
|
+
* A level of 3 is required for full read/write access to all ports.
|
177
|
+
*
|
178
|
+
* Example:
|
179
|
+
* require 'rubygems'
|
180
|
+
* require 'port'
|
181
|
+
* Port.iopl(3)
|
182
|
+
*/
|
183
|
+
static VALUE
|
184
|
+
p_iopl(VALUE self, VALUE level) {
|
185
|
+
|
186
|
+
</pre>
|
187
|
+
</div>
|
188
|
+
</div>
|
189
|
+
</div>
|
190
|
+
<div class="method">
|
191
|
+
<div class="title">
|
192
|
+
<a name="M000003"></a><b>outb</b>(p1, p2)
|
193
|
+
</div>
|
194
|
+
<div class="description">
|
195
|
+
<p>
|
196
|
+
<a href="Port.html#M000003">outb</a> - write a byte to a port. Usage <a
|
197
|
+
href="Port.html#M000003">outb</a>(value,port)
|
198
|
+
</p>
|
199
|
+
<p>
|
200
|
+
Example: Setting port 0x71 to 123.
|
201
|
+
</p>
|
202
|
+
<pre>
|
203
|
+
require 'rubygems'
|
204
|
+
require 'port'
|
205
|
+
Port.outb(123,0x71)
|
206
|
+
</pre>
|
207
|
+
</div>
|
208
|
+
<div class="sourcecode">
|
209
|
+
<p class="source-link">[ <a href="javascript:toggleSource('M000003_source')" id="l_M000003_source">show source</a> ]</p>
|
210
|
+
<div id="M000003_source" class="dyn-source">
|
211
|
+
<pre>
|
212
|
+
/* outb - write a byte to a port.
|
213
|
+
* Usage outb(value,port)
|
214
|
+
*
|
215
|
+
* Example: Setting port 0x71 to 123.
|
216
|
+
* require 'rubygems'
|
217
|
+
* require 'port'
|
218
|
+
* Port.outb(123,0x71)
|
219
|
+
*/
|
220
|
+
static VALUE
|
221
|
+
p_outb(VALUE self, VALUE num, VALUE port) {
|
222
|
+
|
223
|
+
</pre>
|
224
|
+
</div>
|
225
|
+
</div>
|
226
|
+
</div>
|
227
|
+
</div>
|
228
|
+
|
229
|
+
</div>
|
230
|
+
|
231
|
+
</body>
|
232
|
+
</html>
|
data/doc/created.rid
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
Thu Oct 30 16:07:40 +0800 2008
|
@@ -0,0 +1,175 @@
|
|
1
|
+
<?xml version="1.0" encoding="iso-8859-1"?>
|
2
|
+
<!DOCTYPE html
|
3
|
+
PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
|
4
|
+
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
5
|
+
<html>
|
6
|
+
<head>
|
7
|
+
<title>File: README</title>
|
8
|
+
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
|
9
|
+
<link rel="stylesheet" href=".././rdoc-style.css" type="text/css" media="screen" />
|
10
|
+
|
11
|
+
<script language="JavaScript" type="text/javascript">
|
12
|
+
// <![CDATA[
|
13
|
+
|
14
|
+
function toggleSource( id )
|
15
|
+
{
|
16
|
+
var elem
|
17
|
+
var link
|
18
|
+
|
19
|
+
if( document.getElementById )
|
20
|
+
{
|
21
|
+
elem = document.getElementById( id )
|
22
|
+
link = document.getElementById( "l_" + id )
|
23
|
+
}
|
24
|
+
else if ( document.all )
|
25
|
+
{
|
26
|
+
elem = eval( "document.all." + id )
|
27
|
+
link = eval( "document.all.l_" + id )
|
28
|
+
}
|
29
|
+
else
|
30
|
+
return false;
|
31
|
+
|
32
|
+
if( elem.style.display == "block" )
|
33
|
+
{
|
34
|
+
elem.style.display = "none"
|
35
|
+
link.innerHTML = "show source"
|
36
|
+
}
|
37
|
+
else
|
38
|
+
{
|
39
|
+
elem.style.display = "block"
|
40
|
+
link.innerHTML = "hide source"
|
41
|
+
}
|
42
|
+
}
|
43
|
+
|
44
|
+
function openCode( url )
|
45
|
+
{
|
46
|
+
window.open( url, "SOURCE_CODE", "width=400,height=400,scrollbars=yes" )
|
47
|
+
}
|
48
|
+
// ]]>
|
49
|
+
</script>
|
50
|
+
</head>
|
51
|
+
|
52
|
+
<body>
|
53
|
+
<table border='0' cellpadding='0' cellspacing='0' width="100%" class='banner'>
|
54
|
+
<tr><td>
|
55
|
+
<table width="100%" border='0' cellpadding='0' cellspacing='0'><tr>
|
56
|
+
<td class="file-title" colspan="2"><span class="file-title-prefix">File</span><br />README</td>
|
57
|
+
<td align="right">
|
58
|
+
<table border='0' cellspacing="0" cellpadding="2">
|
59
|
+
<tr>
|
60
|
+
<td>Path:</td>
|
61
|
+
<td>README
|
62
|
+
</td>
|
63
|
+
</tr>
|
64
|
+
<tr>
|
65
|
+
<td>Modified:</td>
|
66
|
+
<td>Thu Oct 30 16:00:46 +0800 2008</td>
|
67
|
+
</tr>
|
68
|
+
</table>
|
69
|
+
</td></tr>
|
70
|
+
</table>
|
71
|
+
</td></tr>
|
72
|
+
</table><br>
|
73
|
+
<!-- banner header -->
|
74
|
+
|
75
|
+
<div id="bodyContent">
|
76
|
+
<div id="content">
|
77
|
+
|
78
|
+
<div class="description"><h1>Installation</h1>
|
79
|
+
<h3>Installing from a gem</h3>
|
80
|
+
<p>
|
81
|
+
gem install port
|
82
|
+
</p>
|
83
|
+
<h3>Manual installation — if you have rake.</h3>
|
84
|
+
<pre>
|
85
|
+
rake
|
86
|
+
sudo rake install
|
87
|
+
|
88
|
+
To uninstall: sudo rake uninstall
|
89
|
+
</pre>
|
90
|
+
<h3>Manual installation — if you do NOT have rake.</h3>
|
91
|
+
<pre>
|
92
|
+
change directory to ext sub-directory.
|
93
|
+
ruby extconf.rb -> generates the Makefile.
|
94
|
+
make -> compiles the extension. Requires gcc .
|
95
|
+
copy port.so to:
|
96
|
+
/usr/lib/ruby/site_ruby/1.8/i386-linux
|
97
|
+
or another path in your ruby $LOAD_PATH .
|
98
|
+
</pre>
|
99
|
+
<h2>Usage</h2>
|
100
|
+
<p>
|
101
|
+
If installed via gem:
|
102
|
+
</p>
|
103
|
+
<pre>
|
104
|
+
require 'rubygems'
|
105
|
+
require 'port'
|
106
|
+
</pre>
|
107
|
+
<p>
|
108
|
+
otherwise
|
109
|
+
</p>
|
110
|
+
<pre>
|
111
|
+
require 'port'
|
112
|
+
</pre>
|
113
|
+
<p>
|
114
|
+
will suffice.
|
115
|
+
</p>
|
116
|
+
<h2>Example</h2>
|
117
|
+
<p>
|
118
|
+
For an example run. time.rb as follows:
|
119
|
+
</p>
|
120
|
+
<pre>
|
121
|
+
sudo ./time.rb
|
122
|
+
</pre>
|
123
|
+
<p>
|
124
|
+
time.rb is in the example sub-directory. This requires root permissions to
|
125
|
+
access the IO ports.
|
126
|
+
</p>
|
127
|
+
<p>
|
128
|
+
time.rb listing:
|
129
|
+
</p>
|
130
|
+
<pre>
|
131
|
+
#!/usr/bin/env ruby
|
132
|
+
|
133
|
+
# IMPORTANT REMINDER: Yon need root authority / privilege
|
134
|
+
# to run the following.
|
135
|
+
|
136
|
+
require 'rubygems'
|
137
|
+
require 'port'
|
138
|
+
|
139
|
+
# Set IO permission level to 3 - i.e. read/write all ports.
|
140
|
+
# Set Real-Time Clock register 0x70 to 0,2,4 to read ss,hh,mm
|
141
|
+
Port.iopl 3
|
142
|
+
|
143
|
+
Port.outb 4, 0x70
|
144
|
+
hh = Port.inb 0x71
|
145
|
+
|
146
|
+
Port.outb 2, 0x70
|
147
|
+
mm = Port.inb 0x71
|
148
|
+
|
149
|
+
Port.outb 0, 0x70
|
150
|
+
ss = Port.inb 0x71
|
151
|
+
|
152
|
+
printf("Real-Time Clock time is %02x:%02x:%02x\n", hh,mm,ss)
|
153
|
+
</pre>
|
154
|
+
<h2>Who wrote port?</h2>
|
155
|
+
<p>
|
156
|
+
<a href="../classes/Port.html">Port</a> was written by Loh Siu Yin
|
157
|
+
<siuyin@beyondbroadcast.com> as he needed to control external
|
158
|
+
hardware devices and he wanted to do it from ruby.
|
159
|
+
</p>
|
160
|
+
</div>
|
161
|
+
|
162
|
+
|
163
|
+
|
164
|
+
|
165
|
+
|
166
|
+
|
167
|
+
|
168
|
+
|
169
|
+
|
170
|
+
</div>
|
171
|
+
|
172
|
+
</div>
|
173
|
+
|
174
|
+
</body>
|
175
|
+
</html>
|
@@ -0,0 +1,92 @@
|
|
1
|
+
<?xml version="1.0" encoding="iso-8859-1"?>
|
2
|
+
<!DOCTYPE html
|
3
|
+
PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
|
4
|
+
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
5
|
+
<html>
|
6
|
+
<head>
|
7
|
+
<title>File: port.c</title>
|
8
|
+
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
|
9
|
+
<link rel="stylesheet" href="../.././rdoc-style.css" type="text/css" media="screen" />
|
10
|
+
|
11
|
+
<script language="JavaScript" type="text/javascript">
|
12
|
+
// <![CDATA[
|
13
|
+
|
14
|
+
function toggleSource( id )
|
15
|
+
{
|
16
|
+
var elem
|
17
|
+
var link
|
18
|
+
|
19
|
+
if( document.getElementById )
|
20
|
+
{
|
21
|
+
elem = document.getElementById( id )
|
22
|
+
link = document.getElementById( "l_" + id )
|
23
|
+
}
|
24
|
+
else if ( document.all )
|
25
|
+
{
|
26
|
+
elem = eval( "document.all." + id )
|
27
|
+
link = eval( "document.all.l_" + id )
|
28
|
+
}
|
29
|
+
else
|
30
|
+
return false;
|
31
|
+
|
32
|
+
if( elem.style.display == "block" )
|
33
|
+
{
|
34
|
+
elem.style.display = "none"
|
35
|
+
link.innerHTML = "show source"
|
36
|
+
}
|
37
|
+
else
|
38
|
+
{
|
39
|
+
elem.style.display = "block"
|
40
|
+
link.innerHTML = "hide source"
|
41
|
+
}
|
42
|
+
}
|
43
|
+
|
44
|
+
function openCode( url )
|
45
|
+
{
|
46
|
+
window.open( url, "SOURCE_CODE", "width=400,height=400,scrollbars=yes" )
|
47
|
+
}
|
48
|
+
// ]]>
|
49
|
+
</script>
|
50
|
+
</head>
|
51
|
+
|
52
|
+
<body>
|
53
|
+
<table border='0' cellpadding='0' cellspacing='0' width="100%" class='banner'>
|
54
|
+
<tr><td>
|
55
|
+
<table width="100%" border='0' cellpadding='0' cellspacing='0'><tr>
|
56
|
+
<td class="file-title" colspan="2"><span class="file-title-prefix">File</span><br />port.c</td>
|
57
|
+
<td align="right">
|
58
|
+
<table border='0' cellspacing="0" cellpadding="2">
|
59
|
+
<tr>
|
60
|
+
<td>Path:</td>
|
61
|
+
<td>ext/port.c
|
62
|
+
</td>
|
63
|
+
</tr>
|
64
|
+
<tr>
|
65
|
+
<td>Modified:</td>
|
66
|
+
<td>Thu Oct 30 16:07:34 +0800 2008</td>
|
67
|
+
</tr>
|
68
|
+
</table>
|
69
|
+
</td></tr>
|
70
|
+
</table>
|
71
|
+
</td></tr>
|
72
|
+
</table><br>
|
73
|
+
<!-- banner header -->
|
74
|
+
|
75
|
+
<div id="bodyContent">
|
76
|
+
<div id="content">
|
77
|
+
|
78
|
+
|
79
|
+
|
80
|
+
|
81
|
+
|
82
|
+
|
83
|
+
|
84
|
+
|
85
|
+
|
86
|
+
|
87
|
+
</div>
|
88
|
+
|
89
|
+
</div>
|
90
|
+
|
91
|
+
</body>
|
92
|
+
</html>
|
@@ -0,0 +1,46 @@
|
|
1
|
+
<?xml version="1.0" encoding="iso-8859-1"?>
|
2
|
+
<!DOCTYPE html
|
3
|
+
PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
|
4
|
+
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
5
|
+
<html>
|
6
|
+
<head>
|
7
|
+
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
|
8
|
+
<style>
|
9
|
+
<!--
|
10
|
+
body {
|
11
|
+
background-color: #EEE;
|
12
|
+
font-family: "Bitstream Vera Sans", Verdana, Arial, Helvetica, sans-serif;
|
13
|
+
color: #000;
|
14
|
+
margin: 0px;
|
15
|
+
}
|
16
|
+
.banner {
|
17
|
+
background: #005;
|
18
|
+
color: #FFF;
|
19
|
+
padding: 0.2em;
|
20
|
+
font-size: small;
|
21
|
+
font-weight: bold;
|
22
|
+
text-align: center;
|
23
|
+
}
|
24
|
+
.entries {
|
25
|
+
margin: 0.25em 1em 0 1em;
|
26
|
+
font-size: x-small;
|
27
|
+
}
|
28
|
+
a {
|
29
|
+
color: #00F;
|
30
|
+
text-decoration: none;
|
31
|
+
white-space: nowrap;
|
32
|
+
}
|
33
|
+
a:hover {
|
34
|
+
color: #77F;
|
35
|
+
text-decoration: underline;
|
36
|
+
}
|
37
|
+
-->
|
38
|
+
</style>
|
39
|
+
<base target="docwin">
|
40
|
+
</head>
|
41
|
+
<body>
|
42
|
+
<div class="banner">Classes</div>
|
43
|
+
<div class="entries">
|
44
|
+
<a href="classes/Port.html">Port</a><br>
|
45
|
+
</div>
|
46
|
+
</body></html>
|
@@ -0,0 +1,47 @@
|
|
1
|
+
<?xml version="1.0" encoding="iso-8859-1"?>
|
2
|
+
<!DOCTYPE html
|
3
|
+
PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
|
4
|
+
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
5
|
+
<html>
|
6
|
+
<head>
|
7
|
+
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
|
8
|
+
<style>
|
9
|
+
<!--
|
10
|
+
body {
|
11
|
+
background-color: #EEE;
|
12
|
+
font-family: "Bitstream Vera Sans", Verdana, Arial, Helvetica, sans-serif;
|
13
|
+
color: #000;
|
14
|
+
margin: 0px;
|
15
|
+
}
|
16
|
+
.banner {
|
17
|
+
background: #005;
|
18
|
+
color: #FFF;
|
19
|
+
padding: 0.2em;
|
20
|
+
font-size: small;
|
21
|
+
font-weight: bold;
|
22
|
+
text-align: center;
|
23
|
+
}
|
24
|
+
.entries {
|
25
|
+
margin: 0.25em 1em 0 1em;
|
26
|
+
font-size: x-small;
|
27
|
+
}
|
28
|
+
a {
|
29
|
+
color: #00F;
|
30
|
+
text-decoration: none;
|
31
|
+
white-space: nowrap;
|
32
|
+
}
|
33
|
+
a:hover {
|
34
|
+
color: #77F;
|
35
|
+
text-decoration: underline;
|
36
|
+
}
|
37
|
+
-->
|
38
|
+
</style>
|
39
|
+
<base target="docwin">
|
40
|
+
</head>
|
41
|
+
<body>
|
42
|
+
<div class="banner">Files</div>
|
43
|
+
<div class="entries">
|
44
|
+
<a href="files/README.html">README</a><br>
|
45
|
+
<a href="files/ext/port_c.html">ext/port.c</a><br>
|
46
|
+
</div>
|
47
|
+
</body></html>
|
@@ -0,0 +1,48 @@
|
|
1
|
+
<?xml version="1.0" encoding="iso-8859-1"?>
|
2
|
+
<!DOCTYPE html
|
3
|
+
PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
|
4
|
+
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
5
|
+
<html>
|
6
|
+
<head>
|
7
|
+
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
|
8
|
+
<style>
|
9
|
+
<!--
|
10
|
+
body {
|
11
|
+
background-color: #EEE;
|
12
|
+
font-family: "Bitstream Vera Sans", Verdana, Arial, Helvetica, sans-serif;
|
13
|
+
color: #000;
|
14
|
+
margin: 0px;
|
15
|
+
}
|
16
|
+
.banner {
|
17
|
+
background: #005;
|
18
|
+
color: #FFF;
|
19
|
+
padding: 0.2em;
|
20
|
+
font-size: small;
|
21
|
+
font-weight: bold;
|
22
|
+
text-align: center;
|
23
|
+
}
|
24
|
+
.entries {
|
25
|
+
margin: 0.25em 1em 0 1em;
|
26
|
+
font-size: x-small;
|
27
|
+
}
|
28
|
+
a {
|
29
|
+
color: #00F;
|
30
|
+
text-decoration: none;
|
31
|
+
white-space: nowrap;
|
32
|
+
}
|
33
|
+
a:hover {
|
34
|
+
color: #77F;
|
35
|
+
text-decoration: underline;
|
36
|
+
}
|
37
|
+
-->
|
38
|
+
</style>
|
39
|
+
<base target="docwin">
|
40
|
+
</head>
|
41
|
+
<body>
|
42
|
+
<div class="banner">Methods</div>
|
43
|
+
<div class="entries">
|
44
|
+
<a href="classes/Port.html#M000002">inb (Port)</a><br>
|
45
|
+
<a href="classes/Port.html#M000001">iopl (Port)</a><br>
|
46
|
+
<a href="classes/Port.html#M000003">outb (Port)</a><br>
|
47
|
+
</div>
|
48
|
+
</body></html>
|
data/doc/index.html
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
<?xml version="1.0" encoding="iso-8859-1"?>
|
2
|
+
<!DOCTYPE html
|
3
|
+
PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
|
4
|
+
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
5
|
+
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
|
6
|
+
<head>
|
7
|
+
<title>Port - low-level port access for Linux.</title>
|
8
|
+
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
|
9
|
+
</head>
|
10
|
+
|
11
|
+
<frameset cols="20%,*">
|
12
|
+
<frameset rows="15%,35%,50%">
|
13
|
+
<frame src="fr_file_index.html" title="Files" name="Files" />
|
14
|
+
<frame src="fr_class_index.html" name="Classes" />
|
15
|
+
<frame src="fr_method_index.html" name="Methods" />
|
16
|
+
</frameset>
|
17
|
+
<frame src="classes/Port.html" name="docwin">
|
18
|
+
</frameset>
|
19
|
+
|
20
|
+
</html>
|
data/doc/rdoc-style.css
ADDED
@@ -0,0 +1,175 @@
|
|
1
|
+
a {
|
2
|
+
color: #00F;
|
3
|
+
text-decoration: none;
|
4
|
+
}
|
5
|
+
|
6
|
+
a:hover {
|
7
|
+
color: #77F;
|
8
|
+
text-decoration: underline;
|
9
|
+
}
|
10
|
+
|
11
|
+
body, td, p {
|
12
|
+
font-family: "Bitstream Vera Sans", Verdana, Arial, Helvetica, sans-serif;
|
13
|
+
background: #FFF;
|
14
|
+
color: #000;
|
15
|
+
margin: 0px;
|
16
|
+
font-size: 99%;
|
17
|
+
}
|
18
|
+
|
19
|
+
#content {
|
20
|
+
margin: 2em;
|
21
|
+
}
|
22
|
+
|
23
|
+
#description p {
|
24
|
+
margin-bottom: 0.5em;
|
25
|
+
}
|
26
|
+
|
27
|
+
.sectiontitle {
|
28
|
+
margin-top: 1em;
|
29
|
+
margin-bottom: 1em;
|
30
|
+
padding: 0.5em;
|
31
|
+
padding-left: 2em;
|
32
|
+
background: #005;
|
33
|
+
color: #FFF;
|
34
|
+
font-weight: bold;
|
35
|
+
border: 1px dotted black;
|
36
|
+
}
|
37
|
+
|
38
|
+
.attr-rw {
|
39
|
+
padding-left: 1em;
|
40
|
+
padding-right: 1em;
|
41
|
+
text-align: center;
|
42
|
+
color: #055;
|
43
|
+
}
|
44
|
+
|
45
|
+
.attr-name {
|
46
|
+
font-weight: bold;
|
47
|
+
}
|
48
|
+
|
49
|
+
.attr-desc {
|
50
|
+
}
|
51
|
+
|
52
|
+
.attr-value {
|
53
|
+
font-family: monospace;
|
54
|
+
}
|
55
|
+
|
56
|
+
.file-title-prefix {
|
57
|
+
font-size: large;
|
58
|
+
}
|
59
|
+
|
60
|
+
.file-title {
|
61
|
+
font-size: large;
|
62
|
+
font-weight: bold;
|
63
|
+
background: #005;
|
64
|
+
color: #FFF;
|
65
|
+
}
|
66
|
+
|
67
|
+
.banner {
|
68
|
+
background: #005;
|
69
|
+
color: #FFF;
|
70
|
+
border: 1px solid black;
|
71
|
+
padding: 1em;
|
72
|
+
}
|
73
|
+
|
74
|
+
.banner td {
|
75
|
+
background: transparent;
|
76
|
+
color: #FFF;
|
77
|
+
}
|
78
|
+
|
79
|
+
h1 a, h2 a, .sectiontitle a, .banner a {
|
80
|
+
color: #FF0;
|
81
|
+
}
|
82
|
+
|
83
|
+
h1 a:hover, h2 a:hover, .sectiontitle a:hover, .banner a:hover {
|
84
|
+
color: #FF7;
|
85
|
+
}
|
86
|
+
|
87
|
+
.dyn-source {
|
88
|
+
display: none;
|
89
|
+
background: #FFE;
|
90
|
+
color: #000;
|
91
|
+
border: 1px dotted black;
|
92
|
+
margin: 0.5em 2em 0.5em 2em;
|
93
|
+
padding: 0.5em;
|
94
|
+
}
|
95
|
+
|
96
|
+
.dyn-source .cmt {
|
97
|
+
color: #00F;
|
98
|
+
font-style: italic;
|
99
|
+
}
|
100
|
+
|
101
|
+
.dyn-source .kw {
|
102
|
+
color: #070;
|
103
|
+
font-weight: bold;
|
104
|
+
}
|
105
|
+
|
106
|
+
.method {
|
107
|
+
margin-left: 1em;
|
108
|
+
margin-right: 1em;
|
109
|
+
margin-bottom: 1em;
|
110
|
+
}
|
111
|
+
|
112
|
+
.description pre {
|
113
|
+
padding: 0.5em;
|
114
|
+
border: 1px dotted black;
|
115
|
+
background: #FFE;
|
116
|
+
}
|
117
|
+
|
118
|
+
.method .title {
|
119
|
+
font-family: monospace;
|
120
|
+
font-size: large;
|
121
|
+
border-bottom: 1px dashed black;
|
122
|
+
margin-bottom: 0.3em;
|
123
|
+
padding-bottom: 0.1em;
|
124
|
+
}
|
125
|
+
|
126
|
+
.method .description, .method .sourcecode {
|
127
|
+
margin-left: 1em;
|
128
|
+
}
|
129
|
+
|
130
|
+
.description p, .sourcecode p {
|
131
|
+
margin-bottom: 0.5em;
|
132
|
+
}
|
133
|
+
|
134
|
+
.method .sourcecode p.source-link {
|
135
|
+
text-indent: 0em;
|
136
|
+
margin-top: 0.5em;
|
137
|
+
}
|
138
|
+
|
139
|
+
.method .aka {
|
140
|
+
margin-top: 0.3em;
|
141
|
+
margin-left: 1em;
|
142
|
+
font-style: italic;
|
143
|
+
text-indent: 2em;
|
144
|
+
}
|
145
|
+
|
146
|
+
h1 {
|
147
|
+
padding: 1em;
|
148
|
+
border: 1px solid black;
|
149
|
+
font-size: x-large;
|
150
|
+
font-weight: bold;
|
151
|
+
color: #FFF;
|
152
|
+
background: #007;
|
153
|
+
}
|
154
|
+
|
155
|
+
h2 {
|
156
|
+
padding: 0.5em 1em 0.5em 1em;
|
157
|
+
border: 1px solid black;
|
158
|
+
font-size: large;
|
159
|
+
font-weight: bold;
|
160
|
+
color: #FFF;
|
161
|
+
background: #009;
|
162
|
+
}
|
163
|
+
|
164
|
+
h3, h4, h5, h6 {
|
165
|
+
padding: 0.2em 1em 0.2em 1em;
|
166
|
+
border: 1px dashed black;
|
167
|
+
color: #000;
|
168
|
+
background: #AAF;
|
169
|
+
}
|
170
|
+
|
171
|
+
.sourcecode > pre {
|
172
|
+
padding: 0.5em;
|
173
|
+
border: 1px dotted black;
|
174
|
+
background: #FFE;
|
175
|
+
}
|
data/example/time.rb
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
# IMPORTANT REMINDER: Yon need root authority / privilege
|
4
|
+
# to run the following.
|
5
|
+
|
6
|
+
require 'rubygems'
|
7
|
+
require 'port'
|
8
|
+
|
9
|
+
# Set IO permission level to 3 - i.e. read/write all ports.
|
10
|
+
# Set Real-Time Clock register 0x70 to 0,2,4 to read ss,hh,mm
|
11
|
+
Port.iopl 3
|
12
|
+
|
13
|
+
Port.outb 4, 0x70
|
14
|
+
hh = Port.inb 0x71
|
15
|
+
|
16
|
+
Port.outb 2, 0x70
|
17
|
+
mm = Port.inb 0x71
|
18
|
+
|
19
|
+
Port.outb 0, 0x70
|
20
|
+
ss = Port.inb 0x71
|
21
|
+
|
22
|
+
printf("Real-Time Clock time is %02x:%02x:%02x\n", hh,mm,ss)
|
data/ext/Makefile
ADDED
@@ -0,0 +1,143 @@
|
|
1
|
+
|
2
|
+
SHELL = /bin/sh
|
3
|
+
|
4
|
+
#### Start of system configuration section. ####
|
5
|
+
|
6
|
+
srcdir = .
|
7
|
+
topdir = /usr/lib/ruby/1.8/i386-linux
|
8
|
+
hdrdir = $(topdir)
|
9
|
+
VPATH = $(srcdir):$(topdir):$(hdrdir)
|
10
|
+
prefix = $(DESTDIR)/usr
|
11
|
+
exec_prefix = $(DESTDIR)/usr
|
12
|
+
sitedir = $(DESTDIR)/usr/lib/ruby/site_ruby
|
13
|
+
rubylibdir = $(prefix)/lib/ruby/$(ruby_version)
|
14
|
+
archdir = $(libdir)/ruby/$(ruby_version)/$(arch)
|
15
|
+
sbindir = $(DESTDIR)/usr/sbin
|
16
|
+
datadir = $(DESTDIR)/usr/share
|
17
|
+
includedir = $(DESTDIR)/usr/include
|
18
|
+
infodir = $(DESTDIR)/usr/share/info
|
19
|
+
sysconfdir = $(DESTDIR)/etc
|
20
|
+
mandir = $(DESTDIR)/usr/share/man
|
21
|
+
libdir = $(DESTDIR)/usr/lib
|
22
|
+
sharedstatedir = $(DESTDIR)/usr/com
|
23
|
+
oldincludedir = $(DESTDIR)/usr/include
|
24
|
+
sitearchdir = $(_fc_sitedir)/$(ruby_version)/$(sitearch)
|
25
|
+
bindir = $(DESTDIR)/usr/bin
|
26
|
+
localstatedir = $(DESTDIR)/var
|
27
|
+
sitelibdir = $(sitedir)/$(ruby_version)
|
28
|
+
libexecdir = $(DESTDIR)/usr/libexec
|
29
|
+
_fc_sitedir = $(DESTDIR)/usr/lib/ruby/site_ruby
|
30
|
+
|
31
|
+
CC = gcc
|
32
|
+
LIBRUBY = $(LIBRUBY_SO)
|
33
|
+
LIBRUBY_A = lib$(RUBY_SO_NAME)-static.a
|
34
|
+
LIBRUBYARG_SHARED = -l$(RUBY_SO_NAME)
|
35
|
+
LIBRUBYARG_STATIC = -l$(RUBY_SO_NAME)-static
|
36
|
+
|
37
|
+
RUBY_EXTCONF_H =
|
38
|
+
CFLAGS = -fPIC -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m32 -march=i386 -mtune=generic -fasynchronous-unwind-tables -Wall -fPIC
|
39
|
+
INCFLAGS = -I. -I$(topdir) -I$(hdrdir) -I$(srcdir)
|
40
|
+
CPPFLAGS =
|
41
|
+
CXXFLAGS = $(CFLAGS)
|
42
|
+
DLDFLAGS =
|
43
|
+
LDSHARED = $(CC) -shared
|
44
|
+
AR = ar
|
45
|
+
EXEEXT =
|
46
|
+
|
47
|
+
RUBY_INSTALL_NAME = ruby
|
48
|
+
RUBY_SO_NAME = ruby
|
49
|
+
arch = i386-linux
|
50
|
+
sitearch = i386-linux
|
51
|
+
ruby_version = 1.8
|
52
|
+
ruby = /usr/bin/ruby
|
53
|
+
RUBY = $(ruby)
|
54
|
+
RM = rm -f
|
55
|
+
MAKEDIRS = mkdir -p
|
56
|
+
INSTALL = /usr/bin/install -c
|
57
|
+
INSTALL_PROG = $(INSTALL) -m 0755
|
58
|
+
INSTALL_DATA = $(INSTALL) -m 644
|
59
|
+
COPY = cp
|
60
|
+
|
61
|
+
#### End of system configuration section. ####
|
62
|
+
|
63
|
+
preload =
|
64
|
+
|
65
|
+
libpath = $(libdir)
|
66
|
+
LIBPATH = -L"$(libdir)"
|
67
|
+
DEFFILE =
|
68
|
+
|
69
|
+
CLEANFILES = mkmf.log
|
70
|
+
DISTCLEANFILES =
|
71
|
+
|
72
|
+
extout =
|
73
|
+
extout_prefix =
|
74
|
+
target_prefix =
|
75
|
+
LOCAL_LIBS =
|
76
|
+
LIBS = $(LIBRUBYARG_SHARED) -lpthread -ldl -lcrypt -lm -lc
|
77
|
+
SRCS = port.c
|
78
|
+
OBJS = port.o
|
79
|
+
TARGET = port
|
80
|
+
DLLIB = $(TARGET).so
|
81
|
+
EXTSTATIC =
|
82
|
+
STATIC_LIB =
|
83
|
+
|
84
|
+
RUBYCOMMONDIR = $(sitedir)$(target_prefix)
|
85
|
+
RUBYLIBDIR = $(sitelibdir)$(target_prefix)
|
86
|
+
RUBYARCHDIR = $(sitearchdir)$(target_prefix)
|
87
|
+
|
88
|
+
TARGET_SO = $(DLLIB)
|
89
|
+
CLEANLIBS = $(TARGET).so $(TARGET).il? $(TARGET).tds $(TARGET).map
|
90
|
+
CLEANOBJS = *.o *.a *.s[ol] *.pdb *.exp *.bak
|
91
|
+
|
92
|
+
all: $(DLLIB)
|
93
|
+
static: $(STATIC_LIB)
|
94
|
+
|
95
|
+
clean:
|
96
|
+
@-$(RM) $(CLEANLIBS) $(CLEANOBJS) $(CLEANFILES)
|
97
|
+
|
98
|
+
distclean: clean
|
99
|
+
@-$(RM) Makefile $(RUBY_EXTCONF_H) conftest.* mkmf.log
|
100
|
+
@-$(RM) core ruby$(EXEEXT) *~ $(DISTCLEANFILES)
|
101
|
+
|
102
|
+
realclean: distclean
|
103
|
+
install: install-so install-rb
|
104
|
+
|
105
|
+
install-so: $(RUBYARCHDIR)
|
106
|
+
install-so: $(RUBYARCHDIR)/$(DLLIB)
|
107
|
+
$(RUBYARCHDIR)/$(DLLIB): $(DLLIB)
|
108
|
+
$(INSTALL_PROG) $(DLLIB) $(RUBYARCHDIR)
|
109
|
+
install-rb: pre-install-rb install-rb-default
|
110
|
+
install-rb-default: pre-install-rb-default
|
111
|
+
pre-install-rb: Makefile
|
112
|
+
pre-install-rb-default: Makefile
|
113
|
+
$(RUBYARCHDIR):
|
114
|
+
$(MAKEDIRS) $@
|
115
|
+
|
116
|
+
site-install: site-install-so site-install-rb
|
117
|
+
site-install-so: install-so
|
118
|
+
site-install-rb: install-rb
|
119
|
+
|
120
|
+
.SUFFIXES: .c .m .cc .cxx .cpp .C .o
|
121
|
+
|
122
|
+
.cc.o:
|
123
|
+
$(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) -c $<
|
124
|
+
|
125
|
+
.cxx.o:
|
126
|
+
$(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) -c $<
|
127
|
+
|
128
|
+
.cpp.o:
|
129
|
+
$(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) -c $<
|
130
|
+
|
131
|
+
.C.o:
|
132
|
+
$(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) -c $<
|
133
|
+
|
134
|
+
.c.o:
|
135
|
+
$(CC) $(INCFLAGS) $(CPPFLAGS) $(CFLAGS) -c $<
|
136
|
+
|
137
|
+
$(DLLIB): $(OBJS)
|
138
|
+
@-$(RM) $@
|
139
|
+
$(LDSHARED) $(DLDFLAGS) $(LIBPATH) -o $@ $(OBJS) $(LOCAL_LIBS) $(LIBS)
|
140
|
+
|
141
|
+
|
142
|
+
|
143
|
+
$(OBJS): ruby.h defines.h
|
data/ext/Rakefile
ADDED
data/ext/extconf.rb
ADDED
data/ext/port.c
ADDED
@@ -0,0 +1,69 @@
|
|
1
|
+
#include <ruby.h>
|
2
|
+
#include <sys/io.h>
|
3
|
+
|
4
|
+
|
5
|
+
|
6
|
+
/* iopl - set IO permission level.
|
7
|
+
* A level of 3 is required for full read/write access to all ports.
|
8
|
+
*
|
9
|
+
* Example:
|
10
|
+
* require 'rubygems'
|
11
|
+
* require 'port'
|
12
|
+
* Port.iopl(3)
|
13
|
+
*/
|
14
|
+
static VALUE
|
15
|
+
p_iopl(VALUE self, VALUE level) {
|
16
|
+
return INT2NUM(iopl(NUM2INT(level)));
|
17
|
+
}
|
18
|
+
|
19
|
+
/* inb - read a byte from a port.
|
20
|
+
*
|
21
|
+
* Example:
|
22
|
+
* require 'rubygems'
|
23
|
+
* require 'port'
|
24
|
+
* my_byte_from_port_hex_71 = Port.inb(0x71)
|
25
|
+
*/
|
26
|
+
static VALUE
|
27
|
+
p_inb(VALUE self, VALUE port) {
|
28
|
+
return INT2NUM(inb(NUM2INT(port)));
|
29
|
+
}
|
30
|
+
|
31
|
+
/* outb - write a byte to a port.
|
32
|
+
* Usage outb(value,port)
|
33
|
+
*
|
34
|
+
* Example: Setting port 0x71 to 123.
|
35
|
+
* require 'rubygems'
|
36
|
+
* require 'port'
|
37
|
+
* Port.outb(123,0x71)
|
38
|
+
*/
|
39
|
+
static VALUE
|
40
|
+
p_outb(VALUE self, VALUE num, VALUE port) {
|
41
|
+
outb(NUM2INT(num),NUM2INT(port));
|
42
|
+
return Qnil;
|
43
|
+
}
|
44
|
+
|
45
|
+
|
46
|
+
/* Init_port - startup routine loaded when require 'port' is
|
47
|
+
* issued within ruby.
|
48
|
+
*/
|
49
|
+
VALUE cPort;
|
50
|
+
|
51
|
+
/* Port - Ruby extension to provide low-level
|
52
|
+
* access to IO ports on an x86 GNU/Linux system.
|
53
|
+
*
|
54
|
+
* License: GPL v2 or (at your option) any later version. See http://www.fsf.org/licensing .
|
55
|
+
*
|
56
|
+
* Copyright (C) 2008, Loh Siu Yin (siuyin@beyondbroadcast.com)
|
57
|
+
*
|
58
|
+
* IMPORTANT NOTE: These routines require root privilege.
|
59
|
+
* Use:
|
60
|
+
* sudo <your_ruby_program> or
|
61
|
+
* su -l root, then run your_ruby_program.
|
62
|
+
* The README[link:files/README.html] file provides further details.
|
63
|
+
*/
|
64
|
+
void Init_port() {
|
65
|
+
cPort = rb_define_class("Port", rb_cObject);
|
66
|
+
rb_define_singleton_method(cPort, "iopl", p_iopl, 1);
|
67
|
+
rb_define_singleton_method(cPort, "inb", p_inb, 1);
|
68
|
+
rb_define_singleton_method(cPort, "outb", p_outb, 2);
|
69
|
+
}
|
data/ext/port.o
ADDED
Binary file
|
data/ext/port.so
ADDED
Binary file
|
metadata
ADDED
@@ -0,0 +1,79 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: port
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.9.0
|
5
|
+
platform: x86-linux
|
6
|
+
authors:
|
7
|
+
- Loh Siu Yin
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
|
12
|
+
date: 2008-10-30 00:00:00 +08:00
|
13
|
+
default_executable:
|
14
|
+
dependencies: []
|
15
|
+
|
16
|
+
description:
|
17
|
+
email: siuyin@beyondbroadcast.com
|
18
|
+
executables: []
|
19
|
+
|
20
|
+
extensions:
|
21
|
+
- ext/extconf.rb
|
22
|
+
extra_rdoc_files:
|
23
|
+
- README
|
24
|
+
files:
|
25
|
+
- README
|
26
|
+
- doc/index.html
|
27
|
+
- doc/created.rid
|
28
|
+
- doc/fr_file_index.html
|
29
|
+
- doc/rdoc-style.css
|
30
|
+
- doc/fr_class_index.html
|
31
|
+
- doc/fr_method_index.html
|
32
|
+
- doc/files
|
33
|
+
- doc/classes
|
34
|
+
- doc/files/ext
|
35
|
+
- doc/files/README.html
|
36
|
+
- doc/files/ext/port_c.html
|
37
|
+
- doc/classes/Port.html
|
38
|
+
- Rakefile
|
39
|
+
- ext/port.o
|
40
|
+
- ext/port.so
|
41
|
+
- ext/extconf.rb
|
42
|
+
- ext/Makefile
|
43
|
+
- ext/port.c
|
44
|
+
- ext/Rakefile
|
45
|
+
- example/time.rb
|
46
|
+
has_rdoc: true
|
47
|
+
homepage: http://port.rubyforge.org/
|
48
|
+
post_install_message:
|
49
|
+
rdoc_options:
|
50
|
+
- --title
|
51
|
+
- Port - low-level port access for Linux.
|
52
|
+
- --main
|
53
|
+
- Port
|
54
|
+
- -S
|
55
|
+
require_paths:
|
56
|
+
- lib
|
57
|
+
- ext
|
58
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
59
|
+
requirements:
|
60
|
+
- - ">="
|
61
|
+
- !ruby/object:Gem::Version
|
62
|
+
version: "0"
|
63
|
+
version:
|
64
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ">="
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: "0"
|
69
|
+
version:
|
70
|
+
requirements:
|
71
|
+
- 1. A linux x86 system.
|
72
|
+
- 2. gcc - the GNU C compiler must be installed.
|
73
|
+
rubyforge_project: port
|
74
|
+
rubygems_version: 1.3.0
|
75
|
+
signing_key:
|
76
|
+
specification_version: 2
|
77
|
+
summary: Low-level port access from ruby on Linux.
|
78
|
+
test_files: []
|
79
|
+
|