Hi list,

I don't know if this is the correct list to ask this question. If not, please 
give me a pointer.

Other SmartCard interfaces are built into an external reader (mostly connected 
via USB or serial line). My SmartCard interface is built into a SoC processor 
running a regular Linux based system. I have written a small kernel driver to 
gain access to the hardware (the interface logic) and also a driver for 
openct to make userland happy. So, all software components (application, 
opensc, openct, driver, SmartCard interface, SmartCard) are running on the 
same system.
Are there other people out there who are also using SmartCards in such a way? 
So, does it makes sense to support this kind of connection in openct and/or 
the kernel?
I asked on the kernel maillist and the most important thing is to define an 
API used between any userland application and the kernel driver to control 
the interface to the SmartCard (the communication itself is handled with 
simple read()/write()).
But I'm new to SmartCards and don't know yet, what's required in such an API 
to control all interface features to SmartCards (and my hardware is limited 
to only switch on/off and reset the card, changing to various communication 
parameter and running the communication itself).

What else must a generic API to the kernel handle, to control all features of 
SmartCards interfaces? Attached my current approach to define some IOCTLs to 
control the interface to the SmartCard.

Regards,
Juergen
/*
 *  Copyright (C) 2010 Juergen Beisert <ker...@pengutronix.de>
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 */

#ifndef _LINUX_SIMCARD_H
#define _LINUX_SIMCARD_H

#include <linux/ioctl.h>
#include <linux/types.h>

/* ioctl encodings */
#define SIM_IOCTL_BASE 'X'

#define SIMIOC_GET_PRESENSE     _IOR(SIM_IOCTL_BASE, 1, int)
/* Return values */
# define SIM_PRESENT_REMOVED     0
# define SIM_PRESENT_DETECTED    1
# define SIM_PRESENT_OPERATIONAL 2

#define SIMIOC_GET_ATR		_IO(SIM_IOCTL_BASE, 2)

/* configuration of the interface */
#define SIMIOC_GET_PARAM        _IOR(SIM_IOCTL_BASE, 4, struct sim_param)
#define SIMIOC_SET_PARAM        _IOW(SIM_IOCTL_BASE, 5, struct sim_param)

/* ISO7816-3 conventions sim_param.convention */
#define SIM_CONVENTION_DIRECT 0
#define SIM_CONVENTION_INVERSE  1

/* ISO7816-3 protocols sim_param.T */
#define SIM_PROTOCOL_T0         0
#define SIM_PROTOCOL_T1         1

/* for sim_param.csm */
#define SIM_CLOCKSTOP_ON_0      0
#define SIM_CLOCKSTOP_ON_1      1

struct sim_param {
        unsigned char convention;
        unsigned char FI;       /* clock rate F index */
        unsigned char DI;       /* devider D index */
        unsigned char N;        /* extra guard time in ETUs (xmit): 0...254 or 255 */
        unsigned char T;        /* Protocoll to be used on the line */
        unsigned char csm;
        unsigned long card_clock; /* main card clock in Hz */
};

#define SIMIOC_POWER            _IOW(SIM_IOCTL_BASE, 7, int)
# define SIM_POWER_ON 1
# define SIM_POWER_OFF 0

#define SIMIOC_WARM_RESET       _IOW(SIM_IOCTL_BASE, 9, int)
# define SIM_WARM_RESET_HIGH 1
# define SIM_WARM_RESET_LOW 0

#define SIMIOC_LOCK		_IOW(SIM_IOCTL_BASE, 11, int)
# define SIM_LOCKED 1
# define SIM_UNLOCKED 0

#define SIMIOC_CLOCKMODE	_IOW (SIM_IOCTL_BASE, 13, int)
# define SIM_CLOCK_STOPPED 1
# define SIM_CLOCK_RUNNING 0

#endif /* _LINUX_SIMCARD_H */
_______________________________________________
opensc-devel mailing list
opensc-devel@lists.opensc-project.org
http://www.opensc-project.org/mailman/listinfo/opensc-devel

Reply via email to