Diffstat (limited to 'libopie2/opiecore/linux/opcmciasystem.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | libopie2/opiecore/linux/opcmciasystem.cpp | 125 |
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 | |||
@@ -171,11 +171,9 @@ OPcmciaSystem::CardIterator OPcmciaSystem::iterator() const | |||
171 | OPcmciaSocket::OPcmciaSocket( int major, int socket, QObject* parent, const char* name ) | 171 | OPcmciaSocket::OPcmciaSocket( int major, int socket, QObject* parent, const char* name ) |
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 | ||
181 | OPcmciaSocket::~OPcmciaSocket() | 179 | OPcmciaSocket::~OPcmciaSocket() |
@@ -210,43 +208,14 @@ OPcmciaSocket::~OPcmciaSocket() | |||
210 | } | 208 | } |
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; |
252 | _ioctlarg.tuple.TupleOffset = 0; | 221 | _ioctlarg.tuple.TupleOffset = 0; |
@@ -265,9 +234,9 @@ OPcmciaSocket::~OPcmciaSocket() | |||
265 | qWarning( "OPcmciaSocket::getTuple() - DS_GET_TUPLE_DATA failed (%s)", strerror( errno ) ); | 234 | qWarning( "OPcmciaSocket::getTuple() - DS_GET_TUPLE_DATA failed (%s)", strerror( errno ) ); |
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 ) ); |
273 | return false; | 242 | return false; |
@@ -276,14 +245,8 @@ OPcmciaSocket::~OPcmciaSocket() | |||
276 | return true; | 245 | return true; |
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 | |||
286 | int OPcmciaSocket::number() const | 249 | int OPcmciaSocket::number() const |
287 | { | 250 | { |
288 | return _socket; | 251 | return _socket; |
289 | } | 252 | } |
@@ -294,59 +257,123 @@ QString OPcmciaSocket::identity() const | |||
294 | return ( strcmp( name(), "empty" ) == 0 ) ? "<Empty Socket>" : name(); | 257 | return ( strcmp( name(), "empty" ) == 0 ) ? "<Empty Socket>" : name(); |
295 | } | 258 | } |
296 | 259 | ||
297 | 260 | ||
261 | const 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 | |||
298 | bool OPcmciaSocket::isUnsupported() const | 280 | bool OPcmciaSocket::isUnsupported() const |
299 | { | 281 | { |
300 | return ( strcmp( name(), "unsupported card" ) == 0 ); | 282 | return ( strcmp( name(), "unsupported card" ) == 0 ); |
301 | } | 283 | } |
302 | 284 | ||
303 | 285 | ||
304 | bool OPcmciaSocket::isEmpty() const | 286 | bool OPcmciaSocket::isEmpty() const |
305 | { | 287 | { |
306 | return ( strcmp( name(), "empty" ) == 0 ); | 288 | return ! status() && ( Occupied || OccupiedCardBus ); |
307 | } | 289 | } |
308 | 290 | ||
309 | 291 | ||
310 | bool OPcmciaSocket::isSuspended() const | 292 | bool OPcmciaSocket::isSuspended() const |
311 | { | 293 | { |
312 | //FIXME | 294 | return status() && Suspended; |
313 | return false; | ||
314 | } | 295 | } |
315 | 296 | ||
297 | |||
316 | bool OPcmciaSocket::eject() | 298 | bool OPcmciaSocket::eject() |
317 | { | 299 | { |
318 | return command( "eject" ); | 300 | return ::ioctl( _fd, DS_EJECT_CARD ); |
319 | } | 301 | } |
320 | 302 | ||
303 | |||
321 | bool OPcmciaSocket::insert() | 304 | bool OPcmciaSocket::insert() |
322 | { | 305 | { |
323 | return command( "insert" ); | 306 | return ::ioctl( _fd, DS_INSERT_CARD ); |
324 | } | 307 | } |
325 | 308 | ||
309 | |||
326 | bool OPcmciaSocket::suspend() | 310 | bool OPcmciaSocket::suspend() |
327 | { | 311 | { |
328 | return command( "suspend" ); | 312 | return ::ioctl( _fd, DS_SUSPEND_CARD ); |
329 | } | 313 | } |
330 | 314 | ||
315 | |||
331 | bool OPcmciaSocket::resume() | 316 | bool OPcmciaSocket::resume() |
332 | { | 317 | { |
333 | return command( "resume"); | 318 | return ::ioctl( _fd, DS_RESUME_CARD ); |
334 | } | 319 | } |
335 | 320 | ||
321 | |||
336 | bool OPcmciaSocket::reset() | 322 | bool OPcmciaSocket::reset() |
337 | { | 323 | { |
338 | return command( "reset"); | 324 | return ::ioctl( _fd, DS_RESET_CARD ); |
339 | } | 325 | } |
340 | 326 | ||
341 | const QStringList& OPcmciaSocket::productIdentity() const | 327 | |
328 | QStringList 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 |
347 | const QPair& OPcmciaSocket::manufacturerIdentity() const | 349 | const QPair& OPcmciaSocket::manufacturerIdentity() const |
348 | { | 350 | { |
349 | return _manufId; | 351 | return _manufId; |
350 | } | 352 | } |
351 | #endif | 353 | #endif |
352 | 354 | ||
355 | |||
356 | QString 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 | } | ||