summaryrefslogtreecommitdiff
authormickeyl <mickeyl>2005-05-22 21:55:59 (UTC)
committer mickeyl <mickeyl>2005-05-22 21:55:59 (UTC)
commitb153f9739d300b3bc608ea76968b818818fce1d0 (patch) (unidiff)
tree8b05eedb78f5eab6b5d49c68248da8425f09410b
parentffe68fa0d9b4eb89fe1549b5734ca6ab23c8ab62 (diff)
downloadopie-b153f9739d300b3bc608ea76968b818818fce1d0.zip
opie-b153f9739d300b3bc608ea76968b818818fce1d0.tar.gz
opie-b153f9739d300b3bc608ea76968b818818fce1d0.tar.bz2
start talking directly to pcmcia card services
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--libopie2/opiecore/linux/opcmciasystem.cpp142
-rw-r--r--libopie2/opiecore/linux/opcmciasystem.h28
-rw-r--r--libopie2/opiecore/linux_inotify.h2
-rw-r--r--libopie2/opiecore/linux_pcmcia.h1100
4 files changed, 1264 insertions, 8 deletions
diff --git a/libopie2/opiecore/linux/opcmciasystem.cpp b/libopie2/opiecore/linux/opcmciasystem.cpp
index c310b85..7bd7178 100644
--- a/libopie2/opiecore/linux/opcmciasystem.cpp
+++ b/libopie2/opiecore/linux/opcmciasystem.cpp
@@ -1,218 +1,352 @@
1/* 1/*
2                 This file is part of the Opie Project 2                 This file is part of the Opie Project
3 =. (C) 2005 Michael 'Mickey' Lauer <mickey@Vanille.de> 3 =. (C) 2005 Michael 'Mickey' Lauer <mickey@Vanille.de>
4 .=l. 4 .=l.
5           .>+-= 5           .>+-=
6 _;:,     .>    :=|. This program is free software; you can 6 _;:,     .>    :=|. This program is free software; you can
7.> <`_,   >  .   <= redistribute it and/or modify it under 7.> <`_,   >  .   <= redistribute it and/or modify it under
8:`=1 )Y*s>-.--   : the terms of the GNU Library General Public 8:`=1 )Y*s>-.--   : the terms of the GNU Library General Public
9.="- .-=="i,     .._ License as published by the Free Software 9.="- .-=="i,     .._ License as published by the Free Software
10 - .   .-<_>     .<> Foundation; version 2 of the License. 10 - .   .-<_>     .<> Foundation; version 2 of the License.
11     ._= =}       : 11     ._= =}       :
12    .%`+i>       _;_. 12    .%`+i>       _;_.
13    .i_,=:_.      -<s. This program is distributed in the hope that 13    .i_,=:_.      -<s. This program is distributed in the hope that
14     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY; 14     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
15    : ..    .:,     . . . without even the implied warranty of 15    : ..    .:,     . . . without even the implied warranty of
16    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A 16    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
17  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU 17  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU
18..}^=.=       =       ; Library General Public License for more 18..}^=.=       =       ; Library General Public License for more
19++=   -.     .`     .: details. 19++=   -.     .`     .: details.
20 :     =  ...= . :.=- 20 :     =  ...= . :.=-
21 -.   .:....=;==+<; You should have received a copy of the GNU 21 -.   .:....=;==+<; You should have received a copy of the GNU
22  -_. . .   )=.  = Library General Public License along with 22  -_. . .   )=.  = Library General Public License along with
23    --        :-=` this library; see the file COPYING.LIB. 23    --        :-=` this library; see the file COPYING.LIB.
24 If not, write to the Free Software Foundation, 24 If not, write to the Free Software Foundation,
25 Inc., 59 Temple Place - Suite 330, 25 Inc., 59 Temple Place - Suite 330,
26 Boston, MA 02111-1307, USA. 26 Boston, MA 02111-1307, USA.
27 27
28*/ 28*/
29 29
30#include "opcmciasystem.h" 30#include "opcmciasystem.h"
31using namespace Opie::Core; 31using namespace Opie::Core;
32 32
33/* OPIE */ 33/* OPIE */
34#include <opie2/odebug.h> 34#include <opie2/odebug.h>
35 35
36/* QT */ 36/* QT */
37#include <qfile.h> 37#include <qfile.h>
38#include <qtextstream.h> 38#include <qtextstream.h>
39 39
40/* STD */ 40/* STD */
41#include <errno.h> 41#include <errno.h>
42#include <fcntl.h> 42#include <fcntl.h>
43#include <string.h> 43#include <string.h>
44#include <stdlib.h> 44#include <stdlib.h>
45#include <sys/ioctl.h> 45#include <sys/ioctl.h>
46#include <sys/types.h> 46#include <sys/types.h>
47#include <sys/stat.h> 47#include <sys/stat.h>
48#include <unistd.h>
49
50#define PROC_DEVICES "/proc/devices"
48 51
49/*====================================================================================== 52/*======================================================================================
50 * OPcmciaSystem 53 * OPcmciaSystem
51 *======================================================================================*/ 54 *======================================================================================*/
52 55
53OPcmciaSystem* OPcmciaSystem::_instance = 0; 56OPcmciaSystem* OPcmciaSystem::_instance = 0;
54 57
55OPcmciaSystem::OPcmciaSystem() 58OPcmciaSystem::OPcmciaSystem()
59 :_major( 0 )
56{ 60{
57 qDebug( "OPcmciaSystem::OPcmciaSystem()" ); 61 qDebug( "OPcmciaSystem::OPcmciaSystem()" );
62
63 // get major node number out of /proc/devices
64 QFile procfile( PROC_DEVICES );
65 if ( procfile.exists() && procfile.open( IO_ReadOnly ) )
66 {
67 QTextStream devstream( &procfile );
68 devstream.readLine(); // skip header
69 while ( !devstream.atEnd() && !_major )
70 {
71 int nodenumber;
72 QString driver;
73 devstream >> nodenumber >> driver;
74 if ( driver == "pcmcia" )
75 {
76 qDebug( "OPcmciaSystem::OPcmciaSystem(): gotcha! pcmcia node number = %d", nodenumber );
77 _major = nodenumber;
78 break;
79 }
80 }
81 }
82 else
83 {
84 qWarning( "OPcmciaSystem::OPcmciaSystem() - can't open /proc/devices - continuing with limited functionality." );
85 }
86
58 synchronize(); 87 synchronize();
59} 88}
60 89
61void OPcmciaSystem::synchronize() 90void OPcmciaSystem::synchronize()
62{ 91{
63 qDebug( "OPcmciaSystem::synchronize()" ); 92 qDebug( "OPcmciaSystem::synchronize()" );
64 _interfaces.clear(); 93 _interfaces.clear();
65 94
66 //FIXME: Use cardmgr subsystem ioctls 95 //FIXME: Use cardmgr subsystem ioctls
67 96
68 QString fileName; 97 QString fileName;
69 if ( QFile::exists( "/var/run/stab" ) ) { fileName = "/var/run/stab"; } 98 if ( QFile::exists( "/var/run/stab" ) ) { fileName = "/var/run/stab"; }
70 else if ( QFile::exists( "/var/state/pcmcia/stab" ) ) { fileName = "/var/state/pcmcia/stab"; } 99 else if ( QFile::exists( "/var/state/pcmcia/stab" ) ) { fileName = "/var/state/pcmcia/stab"; }
71 else { fileName = "/var/lib/pcmcia/stab"; } 100 else { fileName = "/var/lib/pcmcia/stab"; }
72 QFile cardinfofile( fileName ); 101 QFile cardinfofile( fileName );
73 if ( !cardinfofile.exists() || !cardinfofile.open( IO_ReadOnly ) ) 102 if ( !cardinfofile.exists() || !cardinfofile.open( IO_ReadOnly ) )
74 { 103 {
75 qWarning( "pcmcia info file not found or unaccessible" ); 104 qWarning( "pcmcia info file not found or unaccessible" );
76 return; 105 return;
77 } 106 }
78 QTextStream cardinfo( &cardinfofile ); 107 QTextStream cardinfo( &cardinfofile );
79 while ( !cardinfo.atEnd() ) 108 while ( !cardinfo.atEnd() )
80 { 109 {
81 QString strSocket; 110 QString strSocket;
82 int numSocket; 111 int numSocket;
83 char colon; 112 char colon;
84 QString cardName; 113 QString cardName;
85 cardinfo >> strSocket >> numSocket >> colon; 114 cardinfo >> strSocket >> numSocket >> colon;
86 cardName = cardinfo.readLine().stripWhiteSpace(); 115 cardName = cardinfo.readLine().stripWhiteSpace();
87 qDebug( "strSocket = '%s', numSocket = '%d', colon = '%c', cardName = '%s'", (const char*) strSocket, numSocket, colon, ( const char*) cardName ); 116 qDebug( "strSocket = '%s', numSocket = '%d', colon = '%c', cardName = '%s'", (const char*) strSocket, numSocket, colon, ( const char*) cardName );
88 if ( strSocket == "Socket" && colon == ':' ) 117 if ( strSocket == "Socket" && colon == ':' )
89 { 118 {
90 _interfaces.append( new OPcmciaSocket( numSocket, this, (const char*) cardName ) ); 119 _interfaces.append( new OPcmciaSocket( _major, numSocket, this, (const char*) cardName ) );
91 } 120 }
92 else 121 else
93 { 122 {
94 continue; 123 continue;
95 } 124 }
96 } 125 }
97} 126}
98 127
99 128
100int OPcmciaSystem::count() const 129int OPcmciaSystem::count() const
101{ 130{
102 return _interfaces.count(); 131 return _interfaces.count();
103} 132}
104 133
105 134
106int OPcmciaSystem::cardCount() const 135int OPcmciaSystem::cardCount() const
107{ 136{
108 int nonEmpty = 0; 137 int nonEmpty = 0;
109 OPcmciaSystem::CardIterator it = iterator(); 138 OPcmciaSystem::CardIterator it = iterator();
110 while ( it.current() ) 139 while ( it.current() )
111 { 140 {
112 if ( !it.current()->isEmpty() ) nonEmpty++; 141 if ( !it.current()->isEmpty() ) nonEmpty++;
113 ++it; 142 ++it;
114 } 143 }
115 return nonEmpty; 144 return nonEmpty;
116} 145}
117 146
118 147
119OPcmciaSocket* OPcmciaSystem::socket( unsigned int number ) 148OPcmciaSocket* OPcmciaSystem::socket( unsigned int number )
120{ 149{
121 return _interfaces.at( number ); 150 return _interfaces.at( number );
122} 151}
123 152
124 153
125OPcmciaSystem* OPcmciaSystem::instance() 154OPcmciaSystem* OPcmciaSystem::instance()
126{ 155{
127 if ( !_instance ) _instance = new OPcmciaSystem(); 156 if ( !_instance ) _instance = new OPcmciaSystem();
128 return _instance; 157 return _instance;
129} 158}
130 159
131 160
132OPcmciaSystem::CardIterator OPcmciaSystem::iterator() const 161OPcmciaSystem::CardIterator OPcmciaSystem::iterator() const
133{ 162{
134 return OPcmciaSystem::CardIterator( _interfaces ); 163 return OPcmciaSystem::CardIterator( _interfaces );
135} 164}
136 165
137 166
138/*====================================================================================== 167/*======================================================================================
139 * OPcmciaSocket 168 * OPcmciaSocket
140 *======================================================================================*/ 169 *======================================================================================*/
141 170
142OPcmciaSocket::OPcmciaSocket( int socket, QObject* parent, const char* name ) 171OPcmciaSocket::OPcmciaSocket( int major, int socket, QObject* parent, const char* name )
143 :QObject( parent, name ), _socket( socket ) 172 :QObject( parent, name ), _major( major ), _socket( socket )
144{ 173{
145 odebug << "OPcmciaSocket::OPcmciaSocket()" << oendl; 174 qDebug( "OPcmciaSocket::OPcmciaSocket()" );
175
146 init(); 176 init();
177 buildInformation();
147} 178}
148 179
149 180
150OPcmciaSocket::~OPcmciaSocket() 181OPcmciaSocket::~OPcmciaSocket()
151{ 182{
183 qDebug( "OPcmciaSocket::~OPcmciaSocket()" );
184 cleanup();
152} 185}
153 186
154 187
155/* internal */ void OPcmciaSocket::init() 188/* internal */ void OPcmciaSocket::init()
156{ 189{
190 // open control socket and gather file descriptor
191 if ( _major )
192 {
193 dev_t dev = ::makedev( _major, _socket );
194 QString filename = QString().sprintf( "/tmp/opcmciasystem-%d", ::getpid() );
195 if ( ::mknod( (const char*) filename, ( S_IFCHR|S_IREAD|S_IWRITE ), dev ) == 0 )
196 {
197 _fd = ::open( (const char*) filename, O_RDONLY);
198 if ( !_fd )
199 {
200 qWarning( "OPcmciaSocket::init() - can't open control socket (%s)", strerror( errno ) );
201 }
202 else
203 {
204 ::unlink( (const char*) filename );
205 }
206 }
207 else
208 {
209 qWarning( "OPcmciaSocket::init() - can't create device node (%s)", strerror( errno ) );
210 }
211 }
212}
213
214/* internal */ void OPcmciaSocket::buildInformation()
215{
216 cistpl_vers_1_t *vers = &_ioctlarg.tuple_parse.parse.version_1;
217 cistpl_manfid_t *manfid = &_ioctlarg.tuple_parse.parse.manfid;
218 cistpl_funcid_t *funcid = &_ioctlarg.tuple_parse.parse.funcid;
219 config_info_t config;
220
221 if ( getTuple( CISTPL_VERS_1 ) )
222 {
223 for ( int i = 0; i < CISTPL_VERS_1_MAX_PROD_STRINGS; ++i )
224 {
225 qDebug( " PRODID = '%s'", vers->str+vers->ofs[i] );
226 _productId += vers->str+vers->ofs[i];
227 }
228 }
229 /*
230 for (i = 0; i < 4; i++)
231 printf("PRODID_%d=\"%s\"\n", i+1,
232 (i < vers->ns) ? vers->str+vers->ofs[i] : "");
233 *manfid = (cistpl_manfid_t) { 0, 0 };
234 get_tuple(fd, CISTPL_MANFID, &arg);
235 printf("MANFID=%04x,%04x\n", manfid->manf, manfid->card);
236 *funcid = (cistpl_funcid_t) { 0xff, 0xff };
237 get_tuple(fd, CISTPL_FUNCID, &arg);
238 printf("FUNCID=%d\n", funcid->func);
239 config.Function = config.ConfigBase = 0;
240 */
157} 241}
158 242
243/* internal */ void OPcmciaSocket::cleanup()
244{
245 // close control socket
246}
247
248/* internal */ bool OPcmciaSocket::getTuple( cisdata_t tuple )
249{
250 _ioctlarg.tuple.DesiredTuple = tuple;
251 _ioctlarg.tuple.Attributes = TUPLE_RETURN_COMMON;
252 _ioctlarg.tuple.TupleOffset = 0;
253
254 int result;
255 result = ::ioctl(_fd, DS_GET_FIRST_TUPLE, &_ioctlarg);
256 if ( result != 0 )
257 {
258 qWarning( "OPcmciaSocket::getTuple() - DS_GET_FIRST_TUPLE failed (%s)", strerror( errno ) );
259 return false;
260 }
261
262 result = ::ioctl(_fd, DS_GET_TUPLE_DATA, &_ioctlarg);
263 if ( result != 0 )
264 {
265 qWarning( "OPcmciaSocket::getTuple() - DS_GET_TUPLE_DATA failed (%s)", strerror( errno ) );
266 return false;
267 }
268
269 result = ::ioctl(_fd, DS_PARSE_TUPLE, &_ioctlarg);
270 if ( result != 0 )
271 {
272 qWarning( "OPcmciaSocket::getTuple() - DS_PARSE_TUPLE failed (%s)", strerror( errno ) );
273 return false;
274 }
275
276 return true;
277}
278
279
159/* internal */ bool OPcmciaSocket::command( const QString& cmd ) 280/* internal */ bool OPcmciaSocket::command( const QString& cmd )
160{ 281{
161 QString cmdline = QString().sprintf( "cardctl %s %d &", (const char*) cmd, _socket ); 282 QString cmdline = QString().sprintf( "cardctl %s %d &", (const char*) cmd, _socket );
162 ::system( (const char*) cmdline ); 283 ::system( (const char*) cmdline );
163} 284}
164 285
165int OPcmciaSocket::number() const 286int OPcmciaSocket::number() const
166{ 287{
167 return _socket; 288 return _socket;
168} 289}
169 290
170 291
171QString OPcmciaSocket::identity() const 292QString OPcmciaSocket::identity() const
172{ 293{
173 return ( strcmp( name(), "empty" ) == 0 ) ? "<Empty Socket>" : name(); 294 return ( strcmp( name(), "empty" ) == 0 ) ? "<Empty Socket>" : name();
174} 295}
175 296
176 297
177bool OPcmciaSocket::isUnsupported() const 298bool OPcmciaSocket::isUnsupported() const
178{ 299{
179 return ( strcmp( name(), "unsupported card" ) == 0 ); 300 return ( strcmp( name(), "unsupported card" ) == 0 );
180} 301}
181 302
182 303
183bool OPcmciaSocket::isEmpty() const 304bool OPcmciaSocket::isEmpty() const
184{ 305{
185 return ( strcmp( name(), "empty" ) == 0 ); 306 return ( strcmp( name(), "empty" ) == 0 );
186} 307}
187 308
188 309
189bool OPcmciaSocket::isSuspended() const 310bool OPcmciaSocket::isSuspended() const
190{ 311{
191 //FIXME 312 //FIXME
192 return false; 313 return false;
193} 314}
194 315
195bool OPcmciaSocket::eject() 316bool OPcmciaSocket::eject()
196{ 317{
197 return command( "eject" ); 318 return command( "eject" );
198} 319}
199 320
200bool OPcmciaSocket::insert() 321bool OPcmciaSocket::insert()
201{ 322{
202 return command( "insert" ); 323 return command( "insert" );
203} 324}
204 325
205bool OPcmciaSocket::suspend() 326bool OPcmciaSocket::suspend()
206{ 327{
207 return command( "suspend" ); 328 return command( "suspend" );
208} 329}
209 330
210bool OPcmciaSocket::resume() 331bool OPcmciaSocket::resume()
211{ 332{
212 return command( "resume"); 333 return command( "resume");
213} 334}
214 335
215bool OPcmciaSocket::reset() 336bool OPcmciaSocket::reset()
216{ 337{
217 return command( "reset"); 338 return command( "reset");
218} 339}
340
341const QStringList& OPcmciaSocket::productIdentity() const
342{
343 return _productId;
344}
345
346#if 0
347const QPair& OPcmciaSocket::manufacturerIdentity() const
348{
349 return _manufId;
350}
351#endif
352
diff --git a/libopie2/opiecore/linux/opcmciasystem.h b/libopie2/opiecore/linux/opcmciasystem.h
index 630a434..ef34964 100644
--- a/libopie2/opiecore/linux/opcmciasystem.h
+++ b/libopie2/opiecore/linux/opcmciasystem.h
@@ -1,180 +1,202 @@
1/* 1/*
2                 This file is part of the Opie Project 2                 This file is part of the Opie Project
3 =. (C) 2005 Michael 'Mickey' Lauer <mickey@Vanille.de> 3 =. (C) 2005 Michael 'Mickey' Lauer <mickey@Vanille.de>
4 .=l. 4 .=l.
5           .>+-= 5           .>+-=
6 _;:,     .>    :=|. This program is free software; you can 6 _;:,     .>    :=|. This program is free software; you can
7.> <`_,   >  .   <= redistribute it and/or modify it under 7.> <`_,   >  .   <= redistribute it and/or modify it under
8:`=1 )Y*s>-.--   : the terms of the GNU Library General Public 8:`=1 )Y*s>-.--   : the terms of the GNU Library General Public
9.="- .-=="i,     .._ License as published by the Free Software 9.="- .-=="i,     .._ License as published by the Free Software
10 - .   .-<_>     .<> Foundation; version 2 of the License. 10 - .   .-<_>     .<> Foundation; version 2 of the License.
11     ._= =}       : 11     ._= =}       :
12    .%`+i>       _;_. 12    .%`+i>       _;_.
13    .i_,=:_.      -<s. This program is distributed in the hope that 13    .i_,=:_.      -<s. This program is distributed in the hope that
14     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY; 14     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
15    : ..    .:,     . . . without even the implied warranty of 15    : ..    .:,     . . . without even the implied warranty of
16    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A 16    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
17  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU 17  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU
18..}^=.=       =       ; Library General Public License for more 18..}^=.=       =       ; Library General Public License for more
19++=   -.     .`     .: details. 19++=   -.     .`     .: details.
20 :     =  ...= . :.=- 20 :     =  ...= . :.=-
21 -.   .:....=;==+<; You should have received a copy of the GNU 21 -.   .:....=;==+<; You should have received a copy of the GNU
22  -_. . .   )=.  = Library General Public License along with 22  -_. . .   )=.  = Library General Public License along with
23    --        :-=` this library; see the file COPYING.LIB. 23    --        :-=` this library; see the file COPYING.LIB.
24 If not, write to the Free Software Foundation, 24 If not, write to the Free Software Foundation,
25 Inc., 59 Temple Place - Suite 330, 25 Inc., 59 Temple Place - Suite 330,
26 Boston, MA 02111-1307, USA. 26 Boston, MA 02111-1307, USA.
27 27
28*/ 28*/
29 29
30#ifndef OPCMCIASYSTEM_H 30#ifndef OPCMCIASYSTEM_H
31#define OPCMCIASYSTEM_H 31#define OPCMCIASYSTEM_H
32 32
33#include "linux_pcmcia.h"
34
33#include <qobject.h> 35#include <qobject.h>
34#include <qlist.h> 36#include <qlist.h>
35 37
36namespace Opie { 38namespace Opie {
37namespace Core { 39namespace Core {
38 40
39class OPcmciaSocket; 41class OPcmciaSocket;
40 42
41/*====================================================================================== 43/*======================================================================================
42 * OPcmciaSystem 44 * OPcmciaSystem
43 *======================================================================================*/ 45 *======================================================================================*/
44 46
45/** 47/**
46 * @brief A container class for the linux pcmcia subsystem 48 * @brief A container class for the linux pcmcia subsystem
47 * 49 *
48 * This class provides access to all available pcmcia/cf cards on your device. 50 * This class provides access to all available pcmcia/cf cards on your device.
49 * 51 *
50 * @author Michael 'Mickey' Lauer <mickey@Vanille.de> 52 * @author Michael 'Mickey' Lauer <mickey@Vanille.de>
51 */ 53 */
52class OPcmciaSystem : public QObject 54class OPcmciaSystem : public QObject
53{ 55{
54 Q_OBJECT 56 Q_OBJECT
55 57
56 public: 58 public:
57 typedef QList<OPcmciaSocket> CardList; 59 typedef QList<OPcmciaSocket> CardList;
58 typedef QListIterator<OPcmciaSocket> CardIterator; 60 typedef QListIterator<OPcmciaSocket> CardIterator;
59 61
60 public: 62 public:
61 /** 63 /**
62 * @returns the number of available sockets 64 * @returns the number of available sockets
63 */ 65 */
64 int count() const; 66 int count() const;
65 /** 67 /**
66 * @returns the number of populated sockets 68 * @returns the number of populated sockets
67 */ 69 */
68 int cardCount() const; 70 int cardCount() const;
69 /** 71 /**
70 * @returns a pointer to the (one and only) @ref OSystem instance. 72 * @returns a pointer to the (one and only) @ref OSystem instance.
71 */ 73 */
72 static OPcmciaSystem* instance(); 74 static OPcmciaSystem* instance();
73 /** 75 /**
74 * @returns an iterator usable for iterating through all sound cards. 76 * @returns an iterator usable for iterating through all sound cards.
75 */ 77 */
76 CardIterator iterator() const; 78 CardIterator iterator() const;
77 /** 79 /**
78 * @returns a pointer to the @ref OPcmciaSocket object correspinding to socket number n, or 0, if not found 80 * @returns a pointer to the @ref OPcmciaSocket object correspinding to socket number n, or 0, if not found
79 * @see OPcmciaSocket 81 * @see OPcmciaSocket
80 */ 82 */
81 OPcmciaSocket* socket( unsigned int number ); 83 OPcmciaSocket* socket( unsigned int number );
82 /** 84 /**
83 * @internal Rebuild the internal database 85 * @internal Rebuild the internal database
84 * @note Sometimes it might be useful to call this from client code, 86 * @note Sometimes it might be useful to call this from client code,
85 * e.g. after issuing a cardctl insert 87 * e.g. after issuing a cardctl insert
86 */ 88 */
87 void synchronize(); 89 void synchronize();
88 90
89 protected: 91 protected:
90 OPcmciaSystem(); 92 OPcmciaSystem();
91 93
92 private: 94 private:
93 static OPcmciaSystem* _instance; 95 static OPcmciaSystem* _instance;
94 CardList _interfaces; 96 CardList _interfaces;
97 int _major;
98
99 private:
95 class Private; 100 class Private;
96 Private *d; 101 Private *d;
97}; 102};
98 103
99 104
100/*====================================================================================== 105/*======================================================================================
101 * OPcmciaSocket 106 * OPcmciaSocket
102 *======================================================================================*/ 107 *======================================================================================*/
103 108
104class OPcmciaSocket : public QObject 109class OPcmciaSocket : public QObject
105{ 110{
106 Q_OBJECT 111 Q_OBJECT
107 112
108 public: 113 public:
109 /** 114 /**
110 * Constructor. Normally you don't create @ref OPcmciaSocket objects yourself, 115 * Constructor. Normally you don't create @ref OPcmciaSocket objects yourself,
111 * but access them via @ref OPcmciaSystem::card(). 116 * but access them via @ref OPcmciaSystem::socket().
112 */ 117 */
113 OPcmciaSocket( int socket, QObject* parent, const char* name ); 118 OPcmciaSocket( int major, int socket, QObject* parent, const char* name );
114 /** 119 /**
115 * Destructor. 120 * Destructor.
116 */ 121 */
117 virtual ~OPcmciaSocket(); 122 virtual ~OPcmciaSocket();
118 /** 123 /**
119 * @returns the corresponding socket number 124 * @returns the corresponding socket number
120 */ 125 */
121 int number() const; 126 int number() const;
122 /** 127 /**
123 * @returns the identification string of the card in this socket, or "<Empty Socket>" 128 * @returns the identification string of the card in this socket, or "<Empty Socket>"
124 */ 129 */
125 QString identity() const; 130 QString identity() const;
126 /** 131 /**
127 * @returns true, if the card is unsupported by the cardmgr 132 * @returns true, if the card is unsupported by the cardmgr
128 */ 133 */
129 bool isUnsupported() const; 134 bool isUnsupported() const;
130 /** 135 /**
131 * @returns true, if the socket is empty 136 * @returns true, if the socket is empty
132 */ 137 */
133 bool isEmpty() const; 138 bool isEmpty() const;
134 /** 139 /**
135 * @returns true, if the socket is suspended 140 * @returns true, if the socket is suspended
136 */ 141 */
137 bool isSuspended() const; 142 bool isSuspended() const;
138 /** 143 /**
139 * Eject card. @returns true, if operation succeeded 144 * Eject card. @returns true, if operation succeeded
140 * @note: This operation needs root privileges 145 * @note: This operation needs root privileges
141 */ 146 */
142 bool eject(); 147 bool eject();
143 /** 148 /**
144 * Insert card. @returns true, if operation succeeded 149 * Insert card. @returns true, if operation succeeded
145 * @note: This operation needs root privileges 150 * @note: This operation needs root privileges
146 */ 151 */
147 bool insert(); 152 bool insert();
148 /** 153 /**
149 * Suspend card. @returns true, if operation succeeded 154 * Suspend card. @returns true, if operation succeeded
150 * @note: This operation needs root privileges 155 * @note: This operation needs root privileges
151 */ 156 */
152 bool suspend(); 157 bool suspend();
153 /** 158 /**
154 * Resume card. @returns true, if operation succeeded 159 * Resume card. @returns true, if operation succeeded
155 * @note: This operation needs root privileges 160 * @note: This operation needs root privileges
156 */ 161 */
157 bool resume(); 162 bool resume();
158 /** 163 /**
159 * Reset card. @returns true, if operation succeeded 164 * Reset card. @returns true, if operation succeeded
160 * @note: This operation needs root privileges 165 * @note: This operation needs root privileges
161 */ 166 */
162 bool reset(); 167 bool reset();
168 /**
169 * @returns a list of product IDs
170 */
171 const QStringList& productIdentity() const;
172 /**
173 * @returns the manufacturer ID pair
174 */
175#if 0
176 const QPair& manufacturerIdentity() const;
177#endif
163 178
164 protected: 179 private:
180 QStringList _productId;
165 181
166 private: 182 private:
167 void init(); 183 void init();
184 void buildInformation();
185 void cleanup();
168 bool command( const QString& cmd ); 186 bool command( const QString& cmd );
187 bool getTuple( cisdata_t tuple );
188 int _major;
169 int _socket; 189 int _socket;
190 int _fd;
191 ds_ioctl_arg_t _ioctlarg;
170 192
171 private: 193 private:
172 class Private; 194 class Private;
173 Private *d; 195 Private *d;
174}; 196};
175 197
176 198
177} 199}
178} 200}
179 201
180#endif // OPCMCIASYSTEM_H 202#endif // OPCMCIASYSTEM_H
diff --git a/libopie2/opiecore/linux_inotify.h b/libopie2/opiecore/linux_inotify.h
index 7e19bb4..70e3be8 100644
--- a/libopie2/opiecore/linux_inotify.h
+++ b/libopie2/opiecore/linux_inotify.h
@@ -1,114 +1,114 @@
1/* 1/*
2 * Inode based directory notification for Linux 2 * Inode based directory notification for Linux
3 * 3 *
4 * Copyright (C) 2005 John McCutchan 4 * Copyright (C) 2005 John McCutchan
5 */ 5 */
6 6
7#ifndef _LINUX_INOTIFY_H 7#ifndef _LINUX_INOTIFY_H
8#define _LINUX_INOTIFY_H 8#define _LINUX_INOTIFY_H
9 9
10#include <sys/types.h> 10#include <sys/types.h>
11#include <linux/limits.h> 11#include <linux/limits.h>
12#include <linux/types.h> 12#include <linux/types.h>
13 13
14/* 14/*
15 * struct inotify_event - structure read from the inotify device for each event 15 * struct inotify_event - structure read from the inotify device for each event
16 * 16 *
17 * When you are watching a directory, you will receive the filename for events 17 * When you are watching a directory, you will receive the filename for events
18 * such as IN_CREATE, IN_DELETE, IN_OPEN, IN_CLOSE, ..., relative to the wd. 18 * such as IN_CREATE, IN_DELETE, IN_OPEN, IN_CLOSE, ..., relative to the wd.
19 */ 19 */
20struct inotify_event { 20struct inotify_event {
21 __s32 wd; /* watch descriptor */ 21 __s32 wd; /* watch descriptor */
22 __u32 mask; /* watch mask */ 22 __u32 mask; /* watch mask */
23 __u32 cookie; /* cookie to synchronize two events */ 23 __u32 cookie; /* cookie to synchronize two events */
24 __u32 len; /* length (including nulls) of name */ 24 __u32 len; /* length (including nulls) of name */
25 char name[0];/* stub for possible name */ 25 char name[0];/* stub for possible name */
26}; 26};
27 27
28/* 28/*
29 * struct inotify_watch_request - represents a watch request 29 * struct inotify_watch_request - represents a watch request
30 * 30 *
31 * Pass to the inotify device via the INOTIFY_WATCH ioctl 31 * Pass to the inotify device via the INOTIFY_WATCH ioctl
32 */ 32 */
33struct inotify_watch_request { 33struct inotify_watch_request {
34 char *name; /* filename name */ 34 char *name; /* filename name */
35 __u32 mask; /* event mask */ 35 __u32 mask; /* event mask */
36}; 36};
37 37
38/* the following are legal, implemented events */ 38/* the following are legal, implemented events */
39 #define IN_ACCESS 0x00000001/* File was accessed */ 39 #define IN_ACCESS 0x00000001/* File was accessed */
40 #define IN_MODIFY 0x00000002/* File was modified */ 40 #define IN_MODIFY 0x00000002/* File was modified */
41 #define IN_ATTRIB 0x00000004/* File changed attributes */ 41 #define IN_ATTRIB 0x00000004/* File changed attributes */
42 #define IN_CLOSE_WRITE 0x00000008/* Writtable file was closed */ 42 #define IN_CLOSE_WRITE 0x00000008/* Writtable file was closed */
43 #define IN_CLOSE_NOWRITE 0x00000010/* Unwrittable file closed */ 43 #define IN_CLOSE_NOWRITE 0x00000010/* Unwrittable file closed */
44 #define IN_OPEN 0x00000020/* File was opened */ 44 #define IN_OPEN 0x00000020/* File was opened */
45 #define IN_MOVED_FROM 0x00000040/* File was moved from X */ 45 #define IN_MOVED_FROM 0x00000040/* File was moved from X */
46 #define IN_MOVED_TO 0x00000080/* File was moved to Y */ 46 #define IN_MOVED_TO 0x00000080/* File was moved to Y */
47 #define IN_DELETE_SUBDIR 0x00000100/* Subdir was deleted */ 47 #define IN_DELETE_SUBDIR 0x00000100/* Subdir was deleted */
48 #define IN_DELETE_FILE 0x00000200/* Subfile was deleted */ 48 #define IN_DELETE_FILE 0x00000200/* Subfile was deleted */
49 #define IN_CREATE_SUBDIR 0x00000400/* Subdir was created */ 49 #define IN_CREATE_SUBDIR 0x00000400/* Subdir was created */
50 #define IN_CREATE_FILE 0x00000800/* Subfile was created */ 50 #define IN_CREATE_FILE 0x00000800/* Subfile was created */
51 #define IN_DELETE_SELF 0x00001000/* Self was deleted */ 51 #define IN_DELETE_SELF 0x00001000/* Self was deleted */
52 #define IN_UNMOUNT 0x00002000/* Backing fs was unmounted */ 52 #define IN_UNMOUNT 0x00002000/* Backing fs was unmounted */
53 #define IN_Q_OVERFLOW 0x00004000/* Event queued overflowed */ 53 #define IN_Q_OVERFLOW 0x00004000/* Event queued overflowed */
54 #define IN_IGNORED 0x00008000/* File was ignored */ 54 #define IN_IGNORED 0x00008000/* File was ignored */
55 55
56/* special flags */ 56/* special flags */
57 #define IN_ALL_EVENTS 0xffffffff/* All the events */ 57 #define IN_ALL_EVENTS 0xffffffff/* All the events */
58 #define IN_CLOSE (IN_CLOSE_WRITE | IN_CLOSE_NOWRITE) 58 #define IN_CLOSE (IN_CLOSE_WRITE | IN_CLOSE_NOWRITE)
59 59
60 #define INOTIFY_IOCTL_MAGIC'Q' 60 #define INOTIFY_IOCTL_MAGIC'Q'
61 #define INOTIFY_IOCTL_MAXNR2 61 #define INOTIFY_IOCTL_MAXNR2
62 62
63 #define INOTIFY_WATCH _IOR(INOTIFY_IOCTL_MAGIC, 1, struct inotify_watch_request) 63 #define INOTIFY_WATCH _IOR(INOTIFY_IOCTL_MAGIC, 1, struct inotify_watch_request)
64 #define INOTIFY_IGNORE _IOR(INOTIFY_IOCTL_MAGIC, 2, int) 64 #define INOTIFY_IGNORE _IOR(INOTIFY_IOCTL_MAGIC, 2, int)
65 65
66#ifdef __KERNEL__ 66#ifdef __KERNEL__
67 67
68#include <linux/dcache.h> 68#include <linux/dcache.h>
69#include <linux/fs.h> 69#include <linux/fs.h>
70#include <linux/config.h> 70#include <linux/config.h>
71#include <asm/atomic.h> 71#include <asm/atomic.h>
72 72
73#ifdef CONFIG_INOTIFY 73#ifdef CONFIG_INOTIFY
74 74
75extern void inotify_inode_queue_event(struct inode *, __u32, __u32, 75extern void inotify_inode_queue_event(struct inode *, __u32, __u32,
76 const char *); 76 const char *);
77extern void inotify_dentry_parent_queue_event(struct dentry *, __u32, __u32, 77extern void inotify_dentry_parent_queue_event(struct dentry *, __u32, __u32,
78 const char *); 78 const char *);
79extern void inotify_super_block_umount(struct super_block *); 79extern void inotify_super_block_umount(struct super_block *);
80extern void inotify_inode_is_dead(struct inode *); 80extern void inotify_inode_is_dead(struct inode *);
81extern u32 inotify_get_cookie(void); 81extern u32 inotify_get_cookie(void);
82 82
83#else 83#else
84 84
85static inline void inotify_inode_queue_event(struct inode *inode, 85static inline void inotify_inode_queue_event(struct inode *inode,
86 __u32 mask, __u32 cookie, 86 __u32 mask, __u32 cookie,
87 const char *filename) 87 const char *filename)
88{ 88{
89} 89}
90 90
91static inline void inotify_dentry_parent_queue_event(struct dentry *dentry, 91static inline void inotify_dentry_parent_queue_event(struct dentry *dentry,
92 __u32 mask, __u32 cookie, 92 __u32 mask, __u32 cookie,
93 const char *filename) 93 const char *filename)
94{ 94{
95} 95}
96 96
97static inline void inotify_super_block_umount(struct super_block *sb) 97static inline void inotify_super_block_umount(struct super_block *sb)
98{ 98{
99} 99}
100 100
101static inline void inotify_inode_is_dead(struct inode *inode) 101static inline void inotify_inode_is_dead(struct inode *inode)
102{ 102{
103} 103}
104 104
105static inline u32 inotify_get_cookie(void) 105static inline u32 inotify_get_cookie(void)
106{ 106{
107 return 0; 107 return 0;
108} 108}
109 109
110 #endif/* CONFIG_INOTIFY */ 110 #endif/* CONFIG_INOTIFY */
111 111
112 #endif/* __KERNEL __ */ 112 #endif/* __KERNEL __ */
113 113
114 #endif/* _LINUX_INOTIFY_H */ 114 #endif/* _LINUX_INOTIFY_H */
diff --git a/libopie2/opiecore/linux_pcmcia.h b/libopie2/opiecore/linux_pcmcia.h
new file mode 100644
index 0000000..5d84f57
--- a/dev/null
+++ b/libopie2/opiecore/linux_pcmcia.h
@@ -0,0 +1,1100 @@
1#ifndef _LINUX_PCMCIA_H
2#define _LINUX_PCMCIA_H
3
4// condensed pcmcia card services header file
5
6#ifdef __KERNEL__
7#include <linux/types.h>
8#else
9#include <sys/types.h>
10#endif
11
12#ifdef __arm__
13typedef u_int ioaddr_t;
14#else
15typedef u_short ioaddr_t;
16#endif
17
18typedef u_short socket_t;
19typedef u_int event_t;
20typedef u_char cisdata_t;
21typedef u_short page_t;
22
23struct client_t;
24typedef struct client_t *client_handle_t;
25
26struct window_t;
27typedef struct window_t *window_handle_t;
28
29struct region_t;
30typedef struct region_t *memory_handle_t;
31
32struct eraseq_t;
33typedef struct eraseq_t *eraseq_handle_t;
34
35#ifndef DEV_NAME_LEN
36#define DEV_NAME_LEN 32
37#endif
38
39typedef char dev_info_t[DEV_NAME_LEN];
40
41#define CISTPL_NULL 0x00
42#define CISTPL_DEVICE 0x01
43#define CISTPL_LONGLINK_CB 0x02
44#define CISTPL_INDIRECT 0x03
45#define CISTPL_CONFIG_CB 0x04
46#define CISTPL_CFTABLE_ENTRY_CB 0x05
47#define CISTPL_LONGLINK_MFC 0x06
48#define CISTPL_BAR 0x07
49#define CISTPL_PWR_MGMNT 0x08
50#define CISTPL_EXTDEVICE 0x09
51#define CISTPL_CHECKSUM 0x10
52#define CISTPL_LONGLINK_A 0x11
53#define CISTPL_LONGLINK_C 0x12
54#define CISTPL_LINKTARGET 0x13
55#define CISTPL_NO_LINK 0x14
56#define CISTPL_VERS_1 0x15
57#define CISTPL_ALTSTR 0x16
58#define CISTPL_DEVICE_A 0x17
59#define CISTPL_JEDEC_C 0x18
60#define CISTPL_JEDEC_A 0x19
61#define CISTPL_CONFIG 0x1a
62#define CISTPL_CFTABLE_ENTRY 0x1b
63#define CISTPL_DEVICE_OC 0x1c
64#define CISTPL_DEVICE_OA 0x1d
65#define CISTPL_DEVICE_GEO 0x1e
66#define CISTPL_DEVICE_GEO_A 0x1f
67#define CISTPL_MANFID 0x20
68#define CISTPL_FUNCID 0x21
69#define CISTPL_FUNCE 0x22
70#define CISTPL_SWIL 0x23
71#define CISTPL_END 0xff
72/* Layer 2 tuples */
73#define CISTPL_VERS_2 0x40
74#define CISTPL_FORMAT 0x41
75#define CISTPL_GEOMETRY 0x42
76#define CISTPL_BYTEORDER 0x43
77#define CISTPL_DATE 0x44
78#define CISTPL_BATTERY 0x45
79#define CISTPL_FORMAT_A 0x47
80/* Layer 3 tuples */
81#define CISTPL_ORG 0x46
82#define CISTPL_SPCL 0x90
83
84typedef struct cistpl_longlink_t {
85 u_int addr;
86} cistpl_longlink_t;
87
88typedef struct cistpl_checksum_t {
89 u_short addr;
90 u_short len;
91 u_char sum;
92} cistpl_checksum_t;
93
94#define CISTPL_MAX_FUNCTIONS 8
95#define CISTPL_MFC_ATTR 0x00
96#define CISTPL_MFC_COMMON 0x01
97
98typedef struct cistpl_longlink_mfc_t {
99 u_char nfn;
100 struct {
101 u_char space;
102 u_int addr;
103 } fn[CISTPL_MAX_FUNCTIONS];
104} cistpl_longlink_mfc_t;
105
106#define CISTPL_MAX_ALTSTR_STRINGS 4
107
108typedef struct cistpl_altstr_t {
109 u_char ns;
110 u_char ofs[CISTPL_MAX_ALTSTR_STRINGS];
111 char str[254];
112} cistpl_altstr_t;
113
114#define CISTPL_DTYPE_NULL 0x00
115#define CISTPL_DTYPE_ROM 0x01
116#define CISTPL_DTYPE_OTPROM 0x02
117#define CISTPL_DTYPE_EPROM 0x03
118#define CISTPL_DTYPE_EEPROM 0x04
119#define CISTPL_DTYPE_FLASH 0x05
120#define CISTPL_DTYPE_SRAM 0x06
121#define CISTPL_DTYPE_DRAM 0x07
122#define CISTPL_DTYPE_FUNCSPEC 0x0d
123#define CISTPL_DTYPE_EXTEND 0x0e
124
125#define CISTPL_MAX_DEVICES 4
126
127typedef struct cistpl_device_t {
128 u_char ndev;
129 struct {
130 u_char type;
131 u_char wp;
132 u_int speed;
133 u_int size;
134 } dev[CISTPL_MAX_DEVICES];
135} cistpl_device_t;
136
137#define CISTPL_DEVICE_MWAIT 0x01
138#define CISTPL_DEVICE_3VCC 0x02
139
140typedef struct cistpl_device_o_t {
141 u_char flags;
142 cistpl_device_t device;
143} cistpl_device_o_t;
144
145#define CISTPL_VERS_1_MAX_PROD_STRINGS 4
146
147typedef struct cistpl_vers_1_t {
148 u_char major;
149 u_char minor;
150 u_char ns;
151 u_char ofs[CISTPL_VERS_1_MAX_PROD_STRINGS];
152 char str[254];
153} cistpl_vers_1_t;
154
155typedef struct cistpl_jedec_t {
156 u_char nid;
157 struct {
158 u_char mfr;
159 u_char info;
160 } id[CISTPL_MAX_DEVICES];
161} cistpl_jedec_t;
162
163typedef struct cistpl_manfid_t {
164 u_short manf;
165 u_short card;
166} cistpl_manfid_t;
167
168#define CISTPL_FUNCID_MULTI 0x00
169#define CISTPL_FUNCID_MEMORY 0x01
170#define CISTPL_FUNCID_SERIAL 0x02
171#define CISTPL_FUNCID_PARALLEL 0x03
172#define CISTPL_FUNCID_FIXED 0x04
173#define CISTPL_FUNCID_VIDEO 0x05
174#define CISTPL_FUNCID_NETWORK 0x06
175#define CISTPL_FUNCID_AIMS 0x07
176#define CISTPL_FUNCID_SCSI 0x08
177
178#define CISTPL_SYSINIT_POST 0x01
179#define CISTPL_SYSINIT_ROM 0x02
180
181typedef struct cistpl_funcid_t {
182 u_char func;
183 u_char sysinit;
184} cistpl_funcid_t;
185
186typedef struct cistpl_funce_t {
187 u_char type;
188 u_char data[0];
189} cistpl_funce_t;
190
191/*======================================================================
192
193 Modem Function Extension Tuples
194
195======================================================================*/
196
197#define CISTPL_FUNCE_SERIAL_IF 0x00
198#define CISTPL_FUNCE_SERIAL_CAP 0x01
199#define CISTPL_FUNCE_SERIAL_SERV_DATA 0x02
200#define CISTPL_FUNCE_SERIAL_SERV_FAX 0x03
201#define CISTPL_FUNCE_SERIAL_SERV_VOICE 0x04
202#define CISTPL_FUNCE_SERIAL_CAP_DATA 0x05
203#define CISTPL_FUNCE_SERIAL_CAP_FAX 0x06
204#define CISTPL_FUNCE_SERIAL_CAP_VOICE 0x07
205#define CISTPL_FUNCE_SERIAL_IF_DATA 0x08
206#define CISTPL_FUNCE_SERIAL_IF_FAX 0x09
207#define CISTPL_FUNCE_SERIAL_IF_VOICE 0x0a
208
209/* UART identification */
210#define CISTPL_SERIAL_UART_8250 0x00
211#define CISTPL_SERIAL_UART_16450 0x01
212#define CISTPL_SERIAL_UART_16550 0x02
213#define CISTPL_SERIAL_UART_8251 0x03
214#define CISTPL_SERIAL_UART_8530 0x04
215#define CISTPL_SERIAL_UART_85230 0x05
216
217/* UART capabilities */
218#define CISTPL_SERIAL_UART_SPACE 0x01
219#define CISTPL_SERIAL_UART_MARK 0x02
220#define CISTPL_SERIAL_UART_ODD 0x04
221#define CISTPL_SERIAL_UART_EVEN 0x08
222#define CISTPL_SERIAL_UART_5BIT 0x01
223#define CISTPL_SERIAL_UART_6BIT 0x02
224#define CISTPL_SERIAL_UART_7BIT 0x04
225#define CISTPL_SERIAL_UART_8BIT 0x08
226#define CISTPL_SERIAL_UART_1STOP 0x10
227#define CISTPL_SERIAL_UART_MSTOP 0x20
228#define CISTPL_SERIAL_UART_2STOP 0x40
229
230typedef struct cistpl_serial_t {
231 u_char uart_type;
232 u_char uart_cap_0;
233 u_char uart_cap_1;
234} cistpl_serial_t;
235
236typedef struct cistpl_modem_cap_t {
237 u_char flow;
238 u_char cmd_buf;
239 u_char rcv_buf_0, rcv_buf_1, rcv_buf_2;
240 u_char xmit_buf_0, xmit_buf_1, xmit_buf_2;
241} cistpl_modem_cap_t;
242
243#define CISTPL_SERIAL_MOD_103 0x01
244#define CISTPL_SERIAL_MOD_V21 0x02
245#define CISTPL_SERIAL_MOD_V23 0x04
246#define CISTPL_SERIAL_MOD_V22 0x08
247#define CISTPL_SERIAL_MOD_212A 0x10
248#define CISTPL_SERIAL_MOD_V22BIS 0x20
249#define CISTPL_SERIAL_MOD_V26 0x40
250#define CISTPL_SERIAL_MOD_V26BIS 0x80
251#define CISTPL_SERIAL_MOD_V27BIS 0x01
252#define CISTPL_SERIAL_MOD_V29 0x02
253#define CISTPL_SERIAL_MOD_V32 0x04
254#define CISTPL_SERIAL_MOD_V32BIS 0x08
255#define CISTPL_SERIAL_MOD_V34 0x10
256
257#define CISTPL_SERIAL_ERR_MNP2_4 0x01
258#define CISTPL_SERIAL_ERR_V42_LAPM 0x02
259
260#define CISTPL_SERIAL_CMPR_V42BIS 0x01
261#define CISTPL_SERIAL_CMPR_MNP5 0x02
262
263#define CISTPL_SERIAL_CMD_AT1 0x01
264#define CISTPL_SERIAL_CMD_AT2 0x02
265#define CISTPL_SERIAL_CMD_AT3 0x04
266#define CISTPL_SERIAL_CMD_MNP_AT 0x08
267#define CISTPL_SERIAL_CMD_V25BIS 0x10
268#define CISTPL_SERIAL_CMD_V25A 0x20
269#define CISTPL_SERIAL_CMD_DMCL 0x40
270
271typedef struct cistpl_data_serv_t {
272 u_char max_data_0;
273 u_char max_data_1;
274 u_char modulation_0;
275 u_char modulation_1;
276 u_char error_control;
277 u_char compression;
278 u_char cmd_protocol;
279 u_char escape;
280 u_char encrypt;
281 u_char misc_features;
282 u_char ccitt_code[0];
283} cistpl_data_serv_t;
284
285typedef struct cistpl_fax_serv_t {
286 u_char max_data_0;
287 u_char max_data_1;
288 u_char modulation;
289 u_char encrypt;
290 u_char features_0;
291 u_char features_1;
292 u_char ccitt_code[0];
293} cistpl_fax_serv_t;
294
295typedef struct cistpl_voice_serv_t {
296 u_char max_data_0;
297 u_char max_data_1;
298} cistpl_voice_serv_t;
299
300/*======================================================================
301
302 LAN Function Extension Tuples
303
304======================================================================*/
305
306#define CISTPL_FUNCE_LAN_TECH 0x01
307#define CISTPL_FUNCE_LAN_SPEED 0x02
308#define CISTPL_FUNCE_LAN_MEDIA 0x03
309#define CISTPL_FUNCE_LAN_NODE_ID 0x04
310#define CISTPL_FUNCE_LAN_CONNECTOR 0x05
311
312/* LAN technologies */
313#define CISTPL_LAN_TECH_ARCNET 0x01
314#define CISTPL_LAN_TECH_ETHERNET 0x02
315#define CISTPL_LAN_TECH_TOKENRING 0x03
316#define CISTPL_LAN_TECH_LOCALTALK 0x04
317#define CISTPL_LAN_TECH_FDDI 0x05
318#define CISTPL_LAN_TECH_ATM 0x06
319#define CISTPL_LAN_TECH_WIRELESS 0x07
320
321typedef struct cistpl_lan_tech_t {
322 u_char tech;
323} cistpl_lan_tech_t;
324
325typedef struct cistpl_lan_speed_t {
326 u_int speed;
327} cistpl_lan_speed_t;
328
329/* LAN media definitions */
330#define CISTPL_LAN_MEDIA_UTP 0x01
331#define CISTPL_LAN_MEDIA_STP 0x02
332#define CISTPL_LAN_MEDIA_THIN_COAX 0x03
333#define CISTPL_LAN_MEDIA_THICK_COAX 0x04
334#define CISTPL_LAN_MEDIA_FIBER 0x05
335#define CISTPL_LAN_MEDIA_900MHZ 0x06
336#define CISTPL_LAN_MEDIA_2GHZ 0x07
337#define CISTPL_LAN_MEDIA_5GHZ 0x08
338#define CISTPL_LAN_MEDIA_DIFF_IR 0x09
339#define CISTPL_LAN_MEDIA_PTP_IR 0x0a
340
341typedef struct cistpl_lan_media_t {
342 u_char media;
343} cistpl_lan_media_t;
344
345typedef struct cistpl_lan_node_id_t {
346 u_char nb;
347 u_char id[16];
348} cistpl_lan_node_id_t;
349
350typedef struct cistpl_lan_connector_t {
351 u_char code;
352} cistpl_lan_connector_t;
353
354/*======================================================================
355
356 IDE Function Extension Tuples
357
358======================================================================*/
359
360#define CISTPL_IDE_INTERFACE 0x01
361
362typedef struct cistpl_ide_interface_t {
363 u_char interface;
364} cistpl_ide_interface_t;
365
366/* First feature byte */
367#define CISTPL_IDE_SILICON 0x04
368#define CISTPL_IDE_UNIQUE 0x08
369#define CISTPL_IDE_DUAL 0x10
370
371/* Second feature byte */
372#define CISTPL_IDE_HAS_SLEEP 0x01
373#define CISTPL_IDE_HAS_STANDBY 0x02
374#define CISTPL_IDE_HAS_IDLE 0x04
375#define CISTPL_IDE_LOW_POWER 0x08
376#define CISTPL_IDE_REG_INHIBIT 0x10
377#define CISTPL_IDE_HAS_INDEX 0x20
378#define CISTPL_IDE_IOIS16 0x40
379
380typedef struct cistpl_ide_feature_t {
381 u_char feature1;
382 u_char feature2;
383} cistpl_ide_feature_t;
384
385#define CISTPL_FUNCE_IDE_IFACE 0x01
386#define CISTPL_FUNCE_IDE_MASTER 0x02
387#define CISTPL_FUNCE_IDE_SLAVE 0x03
388
389/*======================================================================
390
391 Configuration Table Entries
392
393======================================================================*/
394
395#define CISTPL_BAR_SPACE 0x07
396#define CISTPL_BAR_SPACE_IO 0x10
397#define CISTPL_BAR_PREFETCH 0x20
398#define CISTPL_BAR_CACHEABLE 0x40
399#define CISTPL_BAR_1MEG_MAP 0x80
400
401typedef struct cistpl_bar_t {
402 u_char attr;
403 u_int size;
404} cistpl_bar_t;
405
406typedef struct cistpl_config_t {
407 u_char last_idx;
408 u_int base;
409 u_int rmask[4];
410 u_char subtuples;
411} cistpl_config_t;
412
413/* These are bits in the 'present' field, and indices in 'param' */
414#define CISTPL_POWER_VNOM 0
415#define CISTPL_POWER_VMIN 1
416#define CISTPL_POWER_VMAX 2
417#define CISTPL_POWER_ISTATIC 3
418#define CISTPL_POWER_IAVG 4
419#define CISTPL_POWER_IPEAK 5
420#define CISTPL_POWER_IDOWN 6
421
422#define CISTPL_POWER_HIGHZ_OK 0x01
423#define CISTPL_POWER_HIGHZ_REQ 0x02
424
425typedef struct cistpl_power_t {
426 u_char present;
427 u_char flags;
428 u_int param[7];
429} cistpl_power_t;
430
431typedef struct cistpl_timing_t {
432 u_int wait, waitscale;
433 u_int ready, rdyscale;
434 u_int reserved, rsvscale;
435} cistpl_timing_t;
436
437#define CISTPL_IO_LINES_MASK 0x1f
438#define CISTPL_IO_8BIT 0x20
439#define CISTPL_IO_16BIT 0x40
440#define CISTPL_IO_RANGE 0x80
441
442#define CISTPL_IO_MAX_WIN 16
443
444typedef struct cistpl_io_t {
445 u_char flags;
446 u_char nwin;
447 struct {
448 u_int base;
449 u_int len;
450 } win[CISTPL_IO_MAX_WIN];
451} cistpl_io_t;
452
453typedef struct cistpl_irq_t {
454 u_int IRQInfo1;
455 u_int IRQInfo2;
456} cistpl_irq_t;
457
458#define CISTPL_MEM_MAX_WIN 8
459
460typedef struct cistpl_mem_t {
461 u_char flags;
462 u_char nwin;
463 struct {
464 u_int len;
465 u_int card_addr;
466 u_int host_addr;
467 } win[CISTPL_MEM_MAX_WIN];
468} cistpl_mem_t;
469
470#define CISTPL_CFTABLE_DEFAULT 0x0001
471#define CISTPL_CFTABLE_BVDS 0x0002
472#define CISTPL_CFTABLE_WP 0x0004
473#define CISTPL_CFTABLE_RDYBSY 0x0008
474#define CISTPL_CFTABLE_MWAIT 0x0010
475#define CISTPL_CFTABLE_AUDIO 0x0800
476#define CISTPL_CFTABLE_READONLY 0x1000
477#define CISTPL_CFTABLE_PWRDOWN 0x2000
478
479typedef struct cistpl_cftable_entry_t {
480 u_char index;
481 u_short flags;
482 u_char interface;
483 cistpl_power_t vcc, vpp1, vpp2;
484 cistpl_timing_t timing;
485 cistpl_io_t io;
486 cistpl_irq_t irq;
487 cistpl_mem_t mem;
488 u_char subtuples;
489} cistpl_cftable_entry_t;
490
491#define CISTPL_CFTABLE_MASTER 0x000100
492#define CISTPL_CFTABLE_INVALIDATE 0x000200
493#define CISTPL_CFTABLE_VGA_PALETTE 0x000400
494#define CISTPL_CFTABLE_PARITY 0x000800
495#define CISTPL_CFTABLE_WAIT 0x001000
496#define CISTPL_CFTABLE_SERR 0x002000
497#define CISTPL_CFTABLE_FAST_BACK 0x004000
498#define CISTPL_CFTABLE_BINARY_AUDIO 0x010000
499#define CISTPL_CFTABLE_PWM_AUDIO 0x020000
500
501typedef struct cistpl_cftable_entry_cb_t {
502 u_char index;
503 u_int flags;
504 cistpl_power_t vcc, vpp1, vpp2;
505 u_char io;
506 cistpl_irq_t irq;
507 u_char mem;
508 u_char subtuples;
509} cistpl_cftable_entry_cb_t;
510
511typedef struct cistpl_device_geo_t {
512 u_char ngeo;
513 struct {
514 u_char buswidth;
515 u_int erase_block;
516 u_int read_block;
517 u_int write_block;
518 u_int partition;
519 u_int interleave;
520 } geo[CISTPL_MAX_DEVICES];
521} cistpl_device_geo_t;
522
523typedef struct cistpl_vers_2_t {
524 u_char vers;
525 u_char comply;
526 u_short dindex;
527 u_char vspec8, vspec9;
528 u_char nhdr;
529 u_char vendor, info;
530 char str[244];
531} cistpl_vers_2_t;
532
533typedef struct cistpl_org_t {
534 u_char data_org;
535 char desc[30];
536} cistpl_org_t;
537
538#define CISTPL_ORG_FS 0x00
539#define CISTPL_ORG_APPSPEC 0x01
540#define CISTPL_ORG_XIP 0x02
541
542typedef struct cistpl_format_t {
543 u_char type;
544 u_char edc;
545 u_int offset;
546 u_int length;
547} cistpl_format_t;
548
549#define CISTPL_FORMAT_DISK 0x00
550#define CISTPL_FORMAT_MEM 0x01
551
552#define CISTPL_EDC_NONE 0x00
553#define CISTPL_EDC_CKSUM 0x01
554#define CISTPL_EDC_CRC 0x02
555#define CISTPL_EDC_PCC 0x03
556
557typedef union cisparse_t {
558 cistpl_device_t device;
559 cistpl_checksum_t checksum;
560 cistpl_longlink_t longlink;
561 cistpl_longlink_mfc_t longlink_mfc;
562 cistpl_vers_1_t version_1;
563 cistpl_altstr_t altstr;
564 cistpl_jedec_t jedec;
565 cistpl_manfid_t manfid;
566 cistpl_funcid_t funcid;
567 cistpl_funce_t funce;
568 cistpl_bar_t bar;
569 cistpl_config_t config;
570 cistpl_cftable_entry_t cftable_entry;
571 cistpl_cftable_entry_cb_t cftable_entry_cb;
572 cistpl_device_geo_t device_geo;
573 cistpl_vers_2_t vers_2;
574 cistpl_org_t org;
575 cistpl_format_t format;
576} cisparse_t;
577
578typedef struct tuple_t {
579 u_int Attributes;
580 cisdata_t DesiredTuple;
581 u_int Flags; /* internal use */
582 u_int LinkOffset; /* internal use */
583 u_int CISOffset; /* internal use */
584 cisdata_t TupleCode;
585 cisdata_t TupleLink;
586 cisdata_t TupleOffset;
587 cisdata_t TupleDataMax;
588 cisdata_t TupleDataLen;
589 cisdata_t *TupleData;
590} tuple_t;
591
592/* Special cisdata_t value */
593#define RETURN_FIRST_TUPLE 0xff
594
595/* Attributes for tuple calls */
596#define TUPLE_RETURN_LINK 0x01
597#define TUPLE_RETURN_COMMON 0x02
598
599/* For ValidateCIS */
600typedef struct cisinfo_t {
601 u_int Chains;
602} cisinfo_t;
603
604#define CISTPL_MAX_CIS_SIZE 0x200
605
606/* For ReplaceCIS */
607typedef struct cisdump_t {
608 u_int Length;
609 cisdata_t Data[CISTPL_MAX_CIS_SIZE];
610} cisdump_t;
611
612#endif /* LINUX_CISTPL_H */
613
614/* For AccessConfigurationRegister */
615typedef struct conf_reg_t {
616 u_char Function;
617 u_int Action;
618 off_t Offset;
619 u_int Value;
620} conf_reg_t;
621
622/* Actions */
623#define CS_READ 1
624#define CS_WRITE 2
625
626/* for AdjustResourceInfo */
627typedef struct adjust_t {
628 u_int Action;
629 u_int Resource;
630 u_int Attributes;
631 union {
632 struct memory {
633 u_long Base;
634 u_long Size;
635 } memory;
636 struct io {
637 ioaddr_t BasePort;
638 ioaddr_t NumPorts;
639 u_int IOAddrLines;
640 } io;
641 struct irq {
642 u_int IRQ;
643 } irq;
644 } resource;
645} adjust_t;
646
647/* Action field */
648#define REMOVE_MANAGED_RESOURCE 1
649#define ADD_MANAGED_RESOURCE 2
650#define GET_FIRST_MANAGED_RESOURCE 3
651#define GET_NEXT_MANAGED_RESOURCE 4
652/* Resource field */
653#define RES_MEMORY_RANGE 1
654#define RES_IO_RANGE 2
655#define RES_IRQ 3
656/* Attribute field */
657#define RES_IRQ_TYPE 0x03
658#define RES_IRQ_TYPE_EXCLUSIVE 0
659#define RES_IRQ_TYPE_TIME 1
660#define RES_IRQ_TYPE_DYNAMIC 2
661#define RES_IRQ_CSC 0x04
662#define RES_SHARED 0x08
663#define RES_RESERVED 0x10
664#define RES_ALLOCATED 0x20
665#define RES_REMOVED 0x40
666
667typedef struct servinfo_t {
668 char Signature[2];
669 u_int Count;
670 u_int Revision;
671 u_int CSLevel;
672 char *VendorString;
673} servinfo_t;
674
675typedef struct event_callback_args_t {
676 client_handle_t client_handle;
677 void *info;
678 void *mtdrequest;
679 void *buffer;
680 void *misc;
681 void *client_data;
682 struct bus_operations *bus;
683} event_callback_args_t;
684
685/* for GetConfigurationInfo */
686typedef struct config_info_t {
687 u_char Function;
688 u_int Attributes;
689 u_int Vcc, Vpp1, Vpp2;
690 u_int IntType;
691 u_int ConfigBase;
692 u_char Status, Pin, Copy, Option, ExtStatus;
693 u_int Present;
694 u_int CardValues;
695 u_int AssignedIRQ;
696 u_int IRQAttributes;
697 ioaddr_t BasePort1;
698 ioaddr_t NumPorts1;
699 u_int Attributes1;
700 ioaddr_t BasePort2;
701 ioaddr_t NumPorts2;
702 u_int Attributes2;
703 u_int IOAddrLines;
704} config_info_t;
705
706/* For CardValues field */
707#define CV_OPTION_VALUE 0x01
708#define CV_STATUS_VALUE 0x02
709#define CV_PIN_REPLACEMENT 0x04
710#define CV_COPY_VALUE 0x08
711#define CV_EXT_STATUS 0x10
712
713/* For GetFirst/NextClient */
714typedef struct client_req_t {
715 socket_t Socket;
716 u_int Attributes;
717} client_req_t;
718
719#define CLIENT_THIS_SOCKET 0x01
720
721/* For RegisterClient */
722typedef struct client_reg_t {
723 dev_info_t *dev_info;
724 u_int Attributes;
725 u_int EventMask;
726 int (*event_handler)(event_t event, int priority,
727 event_callback_args_t *);
728 event_callback_args_t event_callback_args;
729 u_int Version;
730} client_reg_t;
731
732/* ModifyConfiguration */
733typedef struct modconf_t {
734 u_int Attributes;
735 u_int Vcc, Vpp1, Vpp2;
736} modconf_t;
737
738/* Attributes for ModifyConfiguration */
739#define CONF_IRQ_CHANGE_VALID 0x100
740#define CONF_VCC_CHANGE_VALID 0x200
741#define CONF_VPP1_CHANGE_VALID 0x400
742#define CONF_VPP2_CHANGE_VALID 0x800
743
744/* For RequestConfiguration */
745typedef struct config_req_t {
746 u_int Attributes;
747 u_int Vcc, Vpp1, Vpp2;
748 u_int IntType;
749 u_int ConfigBase;
750 u_char Status, Pin, Copy, ExtStatus;
751 u_char ConfigIndex;
752 u_int Present;
753} config_req_t;
754
755/* Attributes for RequestConfiguration */
756#define CONF_ENABLE_IRQ 0x01
757#define CONF_ENABLE_DMA 0x02
758#define CONF_ENABLE_SPKR 0x04
759#define CONF_VALID_CLIENT 0x100
760
761/* IntType field */
762#define INT_MEMORY 0x01
763#define INT_MEMORY_AND_IO 0x02
764#define INT_CARDBUS 0x04
765#define INT_ZOOMED_VIDEO 0x08
766
767/* For RequestIO and ReleaseIO */
768typedef struct io_req_t {
769 ioaddr_t BasePort1;
770 ioaddr_t NumPorts1;
771 u_int Attributes1;
772 ioaddr_t BasePort2;
773 ioaddr_t NumPorts2;
774 u_int Attributes2;
775 u_int IOAddrLines;
776} io_req_t;
777
778/* Attributes for RequestIO and ReleaseIO */
779#define IO_SHARED 0x01
780#define IO_FIRST_SHARED 0x02
781#define IO_FORCE_ALIAS_ACCESS 0x04
782#define IO_DATA_PATH_WIDTH 0x18
783#define IO_DATA_PATH_WIDTH_8 0x00
784#define IO_DATA_PATH_WIDTH_16 0x08
785#define IO_DATA_PATH_WIDTH_AUTO 0x10
786
787/* For RequestIRQ and ReleaseIRQ */
788typedef struct irq_req_t {
789 u_int Attributes;
790 u_int AssignedIRQ;
791 u_int IRQInfo1, IRQInfo2;
792 void *Handler;
793 void *Instance;
794} irq_req_t;
795
796/* Attributes for RequestIRQ and ReleaseIRQ */
797#define IRQ_TYPE 0x03
798#define IRQ_TYPE_EXCLUSIVE 0x00
799#define IRQ_TYPE_TIME 0x01
800#define IRQ_TYPE_DYNAMIC_SHARING 0x02
801#define IRQ_FORCED_PULSE 0x04
802#define IRQ_FIRST_SHARED 0x08
803#define IRQ_HANDLE_PRESENT 0x10
804#define IRQ_PULSE_ALLOCATED 0x100
805
806/* Bits in IRQInfo1 field */
807#define IRQ_MASK 0x0f
808#define IRQ_NMI_ID 0x01
809#define IRQ_IOCK_ID 0x02
810#define IRQ_BERR_ID 0x04
811#define IRQ_VEND_ID 0x08
812#define IRQ_INFO2_VALID 0x10
813#define IRQ_LEVEL_ID 0x20
814#define IRQ_PULSE_ID 0x40
815#define IRQ_SHARE_ID 0x80
816
817typedef struct eventmask_t {
818 u_int Attributes;
819 u_int EventMask;
820} eventmask_t;
821
822#define CONF_EVENT_MASK_VALID 0x01
823
824/* Configuration registers present */
825#define PRESENT_OPTION 0x001
826#define PRESENT_STATUS 0x002
827#define PRESENT_PIN_REPLACE 0x004
828#define PRESENT_COPY 0x008
829#define PRESENT_EXT_STATUS 0x010
830#define PRESENT_IOBASE_0 0x020
831#define PRESENT_IOBASE_1 0x040
832#define PRESENT_IOBASE_2 0x080
833#define PRESENT_IOBASE_3 0x100
834#define PRESENT_IOSIZE 0x200
835
836/* For GetMemPage, MapMemPage */
837typedef struct memreq_t {
838 u_int CardOffset;
839 page_t Page;
840} memreq_t;
841
842/* For ModifyWindow */
843typedef struct modwin_t {
844 u_int Attributes;
845 u_int AccessSpeed;
846} modwin_t;
847
848/* For RequestWindow */
849typedef struct win_req_t {
850 u_int Attributes;
851 u_long Base;
852 u_int Size;
853 u_int AccessSpeed;
854} win_req_t;
855
856/* Attributes for RequestWindow */
857#define WIN_ADDR_SPACE 0x0001
858#define WIN_ADDR_SPACE_MEM 0x0000
859#define WIN_ADDR_SPACE_IO 0x0001
860#define WIN_MEMORY_TYPE 0x0002
861#define WIN_MEMORY_TYPE_CM 0x0000
862#define WIN_MEMORY_TYPE_AM 0x0002
863#define WIN_ENABLE 0x0004
864#define WIN_DATA_WIDTH 0x0018
865#define WIN_DATA_WIDTH_8 0x0000
866#define WIN_DATA_WIDTH_16 0x0008
867#define WIN_DATA_WIDTH_32 0x0010
868#define WIN_PAGED 0x0020
869#define WIN_SHARED 0x0040
870#define WIN_FIRST_SHARED 0x0080
871#define WIN_USE_WAIT 0x0100
872#define WIN_STRICT_ALIGN 0x0200
873#define WIN_MAP_BELOW_1MB 0x0400
874#define WIN_PREFETCH 0x0800
875#define WIN_CACHEABLE 0x1000
876#define WIN_BAR_MASK 0xe000
877#define WIN_BAR_SHIFT 13
878
879/* Attributes for RegisterClient */
880#define INFO_MASTER_CLIENT 0x01
881#define INFO_IO_CLIENT 0x02
882#define INFO_MTD_CLIENT 0x04
883#define INFO_MEM_CLIENT 0x08
884#define MAX_NUM_CLIENTS 3
885
886#define INFO_CARD_SHARE 0x10
887#define INFO_CARD_EXCL 0x20
888
889typedef struct cs_status_t {
890 u_char Function;
891 event_t CardState;
892 event_t SocketState;
893} cs_status_t;
894
895typedef struct error_info_t {
896 int func;
897 int retcode;
898} error_info_t;
899
900/* Special stuff for binding drivers to sockets */
901typedef struct bind_req_t {
902 socket_t Socket;
903 u_char Function;
904 dev_info_t *dev_info;
905} bind_req_t;
906
907/* Flag to bind to all functions */
908#define BIND_FN_ALL 0xff
909
910typedef struct mtd_bind_t {
911 socket_t Socket;
912 u_int Attributes;
913 u_int CardOffset;
914 dev_info_t *dev_info;
915} mtd_bind_t;
916
917/* For GetFirstRegion and GetNextRegion */
918typedef struct region_info_t {
919 u_int Attributes;
920 u_int CardOffset;
921 u_int RegionSize;
922 u_int AccessSpeed;
923 u_int BlockSize;
924 u_int PartMultiple;
925 u_char JedecMfr, JedecInfo;
926 memory_handle_t next;
927} region_info_t;
928
929#define REGION_TYPE 0x0001
930#define REGION_TYPE_CM 0x0000
931#define REGION_TYPE_AM 0x0001
932#define REGION_PREFETCH 0x0008
933#define REGION_CACHEABLE 0x0010
934#define REGION_BAR_MASK 0xe000
935#define REGION_BAR_SHIFT 13
936
937/* For OpenMemory */
938typedef struct open_mem_t {
939 u_int Attributes;
940 u_int Offset;
941} open_mem_t;
942
943/* Attributes for OpenMemory */
944#define MEMORY_TYPE 0x0001
945#define MEMORY_TYPE_CM 0x0000
946#define MEMORY_TYPE_AM 0x0001
947#define MEMORY_EXCLUSIVE 0x0002
948#define MEMORY_PREFETCH 0x0008
949#define MEMORY_CACHEABLE 0x0010
950#define MEMORY_BAR_MASK 0xe000
951#define MEMORY_BAR_SHIFT 13
952
953typedef struct eraseq_entry_t {
954 memory_handle_t Handle;
955 u_char State;
956 u_int Size;
957 u_int Offset;
958 void *Optional;
959} eraseq_entry_t;
960
961typedef struct eraseq_hdr_t {
962 int QueueEntryCnt;
963 eraseq_entry_t *QueueEntryArray;
964} eraseq_hdr_t;
965
966/* Events */
967#define CS_EVENT_PRI_LOW 0
968#define CS_EVENT_PRI_HIGH 1
969
970#define CS_EVENT_WRITE_PROTECT 0x000001
971#define CS_EVENT_CARD_LOCK 0x000002
972#define CS_EVENT_CARD_INSERTION 0x000004
973#define CS_EVENT_CARD_REMOVAL 0x000008
974#define CS_EVENT_BATTERY_DEAD 0x000010
975#define CS_EVENT_BATTERY_LOW 0x000020
976#define CS_EVENT_READY_CHANGE 0x000040
977#define CS_EVENT_CARD_DETECT 0x000080
978#define CS_EVENT_RESET_REQUEST 0x000100
979#define CS_EVENT_RESET_PHYSICAL 0x000200
980#define CS_EVENT_CARD_RESET 0x000400
981#define CS_EVENT_REGISTRATION_COMPLETE 0x000800
982#define CS_EVENT_RESET_COMPLETE 0x001000
983#define CS_EVENT_PM_SUSPEND 0x002000
984#define CS_EVENT_PM_RESUME 0x004000
985#define CS_EVENT_INSERTION_REQUEST 0x008000
986#define CS_EVENT_EJECTION_REQUEST 0x010000
987#define CS_EVENT_MTD_REQUEST 0x020000
988#define CS_EVENT_ERASE_COMPLETE 0x040000
989#define CS_EVENT_REQUEST_ATTENTION 0x080000
990#define CS_EVENT_CB_DETECT 0x100000
991#define CS_EVENT_3VCARD 0x200000
992#define CS_EVENT_XVCARD 0x400000
993
994/* Return codes */
995#define CS_SUCCESS 0x00
996#define CS_BAD_ADAPTER 0x01
997#define CS_BAD_ATTRIBUTE 0x02
998#define CS_BAD_BASE 0x03
999#define CS_BAD_EDC 0x04
1000#define CS_BAD_IRQ 0x06
1001#define CS_BAD_OFFSET 0x07
1002#define CS_BAD_PAGE 0x08
1003#define CS_READ_FAILURE 0x09
1004#define CS_BAD_SIZE 0x0a
1005#define CS_BAD_SOCKET 0x0b
1006#define CS_BAD_TYPE 0x0d
1007#define CS_BAD_VCC 0x0e
1008#define CS_BAD_VPP 0x0f
1009#define CS_BAD_WINDOW 0x11
1010#define CS_WRITE_FAILURE 0x12
1011#define CS_NO_CARD 0x14
1012#define CS_UNSUPPORTED_FUNCTION 0x15
1013#define CS_UNSUPPORTED_MODE 0x16
1014#define CS_BAD_SPEED 0x17
1015#define CS_BUSY 0x18
1016#define CS_GENERAL_FAILURE 0x19
1017#define CS_WRITE_PROTECTED 0x1a
1018#define CS_BAD_ARG_LENGTH 0x1b
1019#define CS_BAD_ARGS 0x1c
1020#define CS_CONFIGURATION_LOCKED 0x1d
1021#define CS_IN_USE 0x1e
1022#define CS_NO_MORE_ITEMS 0x1f
1023#define CS_OUT_OF_RESOURCE 0x20
1024#define CS_BAD_HANDLE 0x21
1025
1026#define CS_BAD_TUPLE 0x40
1027
1028
1029
1030typedef struct tuple_parse_t {
1031 tuple_t tuple;
1032 cisdata_t data[255];
1033 cisparse_t parse;
1034} tuple_parse_t;
1035
1036typedef struct win_info_t {
1037 window_handle_thandle;
1038 win_req_t window;
1039 memreq_t map;
1040} win_info_t;
1041
1042typedef struct bind_info_t {
1043 dev_info_t dev_info;
1044 u_char function;
1045 struct dev_link_t*instance;
1046 char name[DEV_NAME_LEN];
1047 u_short major, minor;
1048 void *next;
1049} bind_info_t;
1050
1051typedef struct mtd_info_t {
1052 dev_info_t dev_info;
1053 u_int Attributes;
1054 u_int CardOffset;
1055} mtd_info_t;
1056
1057typedef union ds_ioctl_arg_t {
1058 servinfo_t servinfo;
1059 adjust_t adjust;
1060 config_info_tconfig;
1061 tuple_t tuple;
1062 tuple_parse_ttuple_parse;
1063 client_req_tclient_req;
1064 cs_status_t status;
1065 conf_reg_t conf_reg;
1066 cisinfo_t cisinfo;
1067 region_info_tregion;
1068 bind_info_t bind_info;
1069 mtd_info_t mtd_info;
1070 win_info_t win_info;
1071 cisdump_t cisdump;
1072} ds_ioctl_arg_t;
1073
1074 #define DS_GET_CARD_SERVICES_INFO_IOR ('d', 1, servinfo_t)
1075 #define DS_ADJUST_RESOURCE_INFO _IOWR('d', 2, adjust_t)
1076 #define DS_GET_CONFIGURATION_INFO_IOWR('d', 3, config_info_t)
1077 #define DS_GET_FIRST_TUPLE _IOWR('d', 4, tuple_t)
1078 #define DS_GET_NEXT_TUPLE _IOWR('d', 5, tuple_t)
1079 #define DS_GET_TUPLE_DATA _IOWR('d', 6, tuple_parse_t)
1080 #define DS_PARSE_TUPLE _IOWR('d', 7, tuple_parse_t)
1081 #define DS_RESET_CARD _IO ('d', 8)
1082 #define DS_GET_STATUS _IOWR('d', 9, cs_status_t)
1083#define DS_ACCESS_CONFIGURATION_REGISTER _IOWR('d', 10, conf_reg_t)
1084 #define DS_VALIDATE_CIS _IOR ('d', 11, cisinfo_t)
1085 #define DS_SUSPEND_CARD _IO ('d', 12)
1086 #define DS_RESUME_CARD _IO ('d', 13)
1087 #define DS_EJECT_CARD _IO ('d', 14)
1088 #define DS_INSERT_CARD _IO ('d', 15)
1089 #define DS_GET_FIRST_REGION _IOWR('d', 16, region_info_t)
1090 #define DS_GET_NEXT_REGION _IOWR('d', 17, region_info_t)
1091 #define DS_REPLACE_CIS _IOWR('d', 18, cisdump_t)
1092 #define DS_GET_FIRST_WINDOW _IOR ('d', 19, win_info_t)
1093 #define DS_GET_NEXT_WINDOW _IOWR('d', 20, win_info_t)
1094 #define DS_GET_MEM_PAGE _IOWR('d', 21, win_info_t)
1095
1096 #define DS_BIND_REQUEST _IOWR('d', 60, bind_info_t)
1097 #define DS_GET_DEVICE_INFO _IOWR('d', 61, bind_info_t)
1098 #define DS_GET_NEXT_DEVICE _IOWR('d', 62, bind_info_t)
1099 #define DS_UNBIND_REQUEST _IOW ('d', 63, bind_info_t)
1100 #define DS_BIND_MTD _IOWR('d', 64, mtd_info_t)