summaryrefslogtreecommitdiff
path: root/libopie2/opiecore/linux/opcmciasystem.cpp
Unidiff
Diffstat (limited to 'libopie2/opiecore/linux/opcmciasystem.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--libopie2/opiecore/linux/opcmciasystem.cpp125
1 files changed, 76 insertions, 49 deletions
diff --git a/libopie2/opiecore/linux/opcmciasystem.cpp b/libopie2/opiecore/linux/opcmciasystem.cpp
index 0f7ff46..929e289 100644
--- a/libopie2/opiecore/linux/opcmciasystem.cpp
+++ b/libopie2/opiecore/linux/opcmciasystem.cpp
@@ -172,9 +172,7 @@ OPcmciaSocket::OPcmciaSocket( int major, int socket, QObject* parent, const char
172 :QObject( parent, name ), _major( major ), _socket( socket ) 172 :QObject( parent, name ), _major( major ), _socket( socket )
173{ 173{
174 qDebug( "OPcmciaSocket::OPcmciaSocket()" ); 174 qDebug( "OPcmciaSocket::OPcmciaSocket()" );
175
176 init(); 175 init();
177 buildInformation();
178} 176}
179 177
180 178
@@ -211,41 +209,12 @@ OPcmciaSocket::~OPcmciaSocket()
211 } 209 }
212} 210}
213 211
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 */
241}
242
243/* internal */ void OPcmciaSocket::cleanup() 212/* internal */ void OPcmciaSocket::cleanup()
244{ 213{
245 // close control socket 214 // close control socket
246} 215}
247 216
248/* internal */ bool OPcmciaSocket::getTuple( cisdata_t tuple ) 217/* internal */ bool OPcmciaSocket::getTuple( cisdata_t tuple ) const
249{ 218{
250 _ioctlarg.tuple.DesiredTuple = tuple; 219 _ioctlarg.tuple.DesiredTuple = tuple;
251 _ioctlarg.tuple.Attributes = TUPLE_RETURN_COMMON; 220 _ioctlarg.tuple.Attributes = TUPLE_RETURN_COMMON;
@@ -266,7 +235,7 @@ OPcmciaSocket::~OPcmciaSocket()
266 return false; 235 return false;
267 } 236 }
268 237
269 result = ::ioctl(_fd, DS_PARSE_TUPLE, &_ioctlarg); 238 result = ::ioctl( _fd, DS_PARSE_TUPLE, &_ioctlarg );
270 if ( result != 0 ) 239 if ( result != 0 )
271 { 240 {
272 qWarning( "OPcmciaSocket::getTuple() - DS_PARSE_TUPLE failed (%s)", strerror( errno ) ); 241 qWarning( "OPcmciaSocket::getTuple() - DS_PARSE_TUPLE failed (%s)", strerror( errno ) );
@@ -277,12 +246,6 @@ OPcmciaSocket::~OPcmciaSocket()
277} 246}
278 247
279 248
280/* internal */ bool OPcmciaSocket::command( const QString& cmd )
281{
282 QString cmdline = QString().sprintf( "cardctl %s %d &", (const char*) cmd, _socket );
283 ::system( (const char*) cmdline );
284}
285
286int OPcmciaSocket::number() const 249int OPcmciaSocket::number() const
287{ 250{
288 return _socket; 251 return _socket;
@@ -295,6 +258,25 @@ QString OPcmciaSocket::identity() const
295} 258}
296 259
297 260
261const OPcmciaSocket::OPcmciaSocketCardStatus OPcmciaSocket::status() const
262{
263 cs_status_t cs_status;
264 cs_status.Function = 0;
265 int result = ::ioctl( _fd, DS_GET_STATUS, &cs_status );
266 if ( result != 0 )
267 {
268 qWarning( "OPcmciaSocket::status() - DS_GET_STATUS failed (%s)", strerror( errno ) );
269 return Unknown;
270 }
271 else
272 {
273 qDebug( " card status = 0x%08x", cs_status.CardState );
274 qDebug( " socket status = 0x%08x", cs_status.SocketState );
275 return (OPcmciaSocket::OPcmciaSocketCardStatus) (cs_status.CardState + cs_status.SocketState);
276 }
277}
278
279
298bool OPcmciaSocket::isUnsupported() const 280bool OPcmciaSocket::isUnsupported() const
299{ 281{
300 return ( strcmp( name(), "unsupported card" ) == 0 ); 282 return ( strcmp( name(), "unsupported card" ) == 0 );
@@ -303,46 +285,66 @@ bool OPcmciaSocket::isUnsupported() const
303 285
304bool OPcmciaSocket::isEmpty() const 286bool OPcmciaSocket::isEmpty() const
305{ 287{
306 return ( strcmp( name(), "empty" ) == 0 ); 288 return ! status() && ( Occupied || OccupiedCardBus );
307} 289}
308 290
309 291
310bool OPcmciaSocket::isSuspended() const 292bool OPcmciaSocket::isSuspended() const
311{ 293{
312 //FIXME 294 return status() && Suspended;
313 return false;
314} 295}
315 296
297
316bool OPcmciaSocket::eject() 298bool OPcmciaSocket::eject()
317{ 299{
318 return command( "eject" ); 300 return ::ioctl( _fd, DS_EJECT_CARD );
319} 301}
320 302
303
321bool OPcmciaSocket::insert() 304bool OPcmciaSocket::insert()
322{ 305{
323 return command( "insert" ); 306 return ::ioctl( _fd, DS_INSERT_CARD );
324} 307}
325 308
309
326bool OPcmciaSocket::suspend() 310bool OPcmciaSocket::suspend()
327{ 311{
328 return command( "suspend" ); 312 return ::ioctl( _fd, DS_SUSPEND_CARD );
329} 313}
330 314
315
331bool OPcmciaSocket::resume() 316bool OPcmciaSocket::resume()
332{ 317{
333 return command( "resume"); 318 return ::ioctl( _fd, DS_RESUME_CARD );
334} 319}
335 320
321
336bool OPcmciaSocket::reset() 322bool OPcmciaSocket::reset()
337{ 323{
338 return command( "reset"); 324 return ::ioctl( _fd, DS_RESET_CARD );
339} 325}
340 326
341const QStringList& OPcmciaSocket::productIdentity() const 327
328QStringList OPcmciaSocket::productIdentity() const
342{ 329{
343 return _productId; 330 QStringList list;
331 cistpl_vers_1_t *vers = &_ioctlarg.tuple_parse.parse.version_1;
332 if ( getTuple( CISTPL_VERS_1 ) )
333 {
334 for ( int i = 0; i < CISTPL_VERS_1_MAX_PROD_STRINGS; ++i )
335 {
336 qDebug( " PRODID = '%s'", vers->str+vers->ofs[i] );
337 list += vers->str+vers->ofs[i];
338 }
339 }
340 else
341 {
342 list += "<unknown>";
343 }
344 return list;
344} 345}
345 346
347
346#if 0 348#if 0
347const QPair& OPcmciaSocket::manufacturerIdentity() const 349const QPair& OPcmciaSocket::manufacturerIdentity() const
348{ 350{
@@ -350,3 +352,28 @@ const QPair& OPcmciaSocket::manufacturerIdentity() const
350} 352}
351#endif 353#endif
352 354
355
356QString OPcmciaSocket::function() const
357{
358 cistpl_funcid_t *funcid = &_ioctlarg.tuple_parse.parse.funcid;
359 if ( getTuple( CISTPL_FUNCID ) )
360 {
361 switch ( funcid->func )
362 {
363 case 0: return "Multifunction"; break;
364 case 1: return "Memory"; break;
365 case 2: return "Serial"; break;
366 case 3: return "Parallel"; break;
367 case 4: return "Fixed Disk"; break;
368 case 5: return "Video"; break;
369 case 6: return "Network"; break;
370 case 7: return "AIMS"; break;
371 case 8: return "SCSI"; break;
372 default: return "<unknown>"; break;
373 }
374 }
375 else
376 {
377 return "<unknown>";
378 }
379}