Staging: add ced1401 USB driver
This was imported from the http://pub.ist.ac.at/~schloegl/src/ced1401/.git git repo at the request of Alois. The driver originally came from Cambridge Electronic Design Ltd and was authored by Greg P Smith and others, but Alois did the maintance work to get it into a semi-building state and pushed to get it into the main kernel tree here. Cc: Alois Schlögl <alois.schloegl@ist.ac.at> Cc: Greg P. Smith <greg@ced.co.uk> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
parent
57991b6bfc
commit
2eae6bdc12
12
drivers/staging/ced1401/Makefile
Normal file
12
drivers/staging/ced1401/Makefile
Normal file
|
@ -0,0 +1,12 @@
|
|||
obj-m := cedusb.o
|
||||
cedusb-objs := usb1401.o ced_ioc.o
|
||||
KDIR := /lib/modules/$(shell uname -r)/build
|
||||
PWD := $(shell pwd)
|
||||
KBUILD_EXTRA_SYMBOLS := $(PWD)
|
||||
EXTRA_CFLAGS = -I$(HOME)/src/ced1401
|
||||
all:
|
||||
$(MAKE) -C $(KDIR) SUBDIRS=$(PWD) modules
|
||||
|
||||
clean:
|
||||
$(MAKE) -C $(KDIR) SUBDIRS=$(PWD) clean
|
||||
|
1461
drivers/staging/ced1401/ced_ioc.c
Normal file
1461
drivers/staging/ced1401/ced_ioc.c
Normal file
File diff suppressed because it is too large
Load diff
232
drivers/staging/ced1401/ced_ioctl.h
Normal file
232
drivers/staging/ced1401/ced_ioctl.h
Normal file
|
@ -0,0 +1,232 @@
|
|||
/* ced_ioctl.h
|
||||
IOCTL calls for the CED1401 driver
|
||||
Copyright (C) 2010 Cambridge Electronic Design Ltd
|
||||
Author Greg P Smith (greg@ced.co.uk)
|
||||
|
||||
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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
#ifndef __CED_IOCTL_H__
|
||||
#define __CED_IOCTL_H__
|
||||
#include <asm/ioctl.h>
|
||||
|
||||
/// dma modes, only MODE_CHAR and MODE_LINEAR are used in this driver
|
||||
#define MODE_CHAR 0
|
||||
#define MODE_LINEAR 1
|
||||
|
||||
/****************************************************************************
|
||||
** TypeDefs
|
||||
*****************************************************************************/
|
||||
|
||||
typedef unsigned short TBLOCKENTRY; // index the blk transfer table 0-7
|
||||
|
||||
typedef struct TransferDesc
|
||||
{
|
||||
long long lpvBuff; // address of transfer area (for 64 or 32 bit)
|
||||
unsigned int dwLength; // length of the area
|
||||
TBLOCKENTRY wAreaNum; // number of transfer area to set up
|
||||
short eSize; // element size - is tohost flag for circular
|
||||
} TRANSFERDESC;
|
||||
|
||||
typedef TRANSFERDESC* LPTRANSFERDESC;
|
||||
|
||||
typedef struct TransferEvent
|
||||
{
|
||||
unsigned int dwStart; // offset into the area
|
||||
unsigned int dwLength; // length of the region
|
||||
unsigned short wAreaNum; // the area number
|
||||
unsigned short wFlags; // bit 0 set for toHost
|
||||
int iSetEvent; // could be dummy in LINUX
|
||||
} TRANSFEREVENT;
|
||||
|
||||
#define MAX_TRANSFER_SIZE 0x4000 /* Maximum data bytes per IRP */
|
||||
#define MAX_AREA_LENGTH 0x100000 /* Maximum size of transfer area */
|
||||
#define MAX_TRANSAREAS 8 /* definitions for dma set up */
|
||||
|
||||
typedef struct TGetSelfTest
|
||||
{
|
||||
int code; // self-test error code
|
||||
int x,y; // additional information
|
||||
} TGET_SELFTEST;
|
||||
|
||||
/// Debug block used for several commands. Not all fields are used for all commands.
|
||||
typedef struct TDbgBlock
|
||||
{
|
||||
int iAddr; // the address in the 1401
|
||||
int iRepeats; // number of repeats
|
||||
int iWidth; // width in bytes 1, 2, 4
|
||||
int iDefault; // default value
|
||||
int iMask; // mask to apply
|
||||
int iData; // data for poke, result for peek
|
||||
} TDBGBLOCK;
|
||||
|
||||
/// Used to collect information about a circular block from the device driver
|
||||
typedef struct TCircBlock
|
||||
{
|
||||
unsigned int nArea; // the area to collect information from
|
||||
unsigned int dwOffset; // offset into the area to the available block
|
||||
unsigned int dwSize; // size of the area
|
||||
} TCIRCBLOCK;
|
||||
|
||||
/// Used to clollect the 1401 status
|
||||
typedef struct TCSBlock
|
||||
{
|
||||
unsigned int uiState;
|
||||
unsigned int uiError;
|
||||
} TCSBLOCK;
|
||||
|
||||
// As seen by the user, an ioctl call looks like:
|
||||
// int ioctl(int fd, unsigned long cmd, char* argp);
|
||||
// We will then have all sorts of variants on this that can be used
|
||||
// to pass stuff to our driver. We will generate macros for each type
|
||||
// of call so as to provide some sort of type safety in the calling:
|
||||
#define CED_MAGIC_IOC 0xce
|
||||
|
||||
// NBNB: READ and WRITE are from the point of view of the device, not user.
|
||||
typedef struct ced_ioc_string
|
||||
{
|
||||
int nChars;
|
||||
char buffer[256];
|
||||
} CED_IOC_STRING;
|
||||
|
||||
#define IOCTL_CED_SENDSTRING(n) _IOC(_IOC_WRITE, CED_MAGIC_IOC, 2, n)
|
||||
|
||||
#define IOCTL_CED_RESET1401 _IO(CED_MAGIC_IOC, 3)
|
||||
#define IOCTL_CED_GETCHAR _IO(CED_MAGIC_IOC, 4)
|
||||
#define IOCTL_CED_SENDCHAR _IO(CED_MAGIC_IOC, 5)
|
||||
#define IOCTL_CED_STAT1401 _IO(CED_MAGIC_IOC, 6)
|
||||
#define IOCTL_CED_LINECOUNT _IO(CED_MAGIC_IOC, 7)
|
||||
#define IOCTL_CED_GETSTRING(nMax) _IOC(_IOC_READ, CED_MAGIC_IOC, 8, nMax)
|
||||
|
||||
#define IOCTL_CED_SETTRANSFER _IOW(CED_MAGIC_IOC, 11, TRANSFERDESC)
|
||||
#define IOCTL_CED_UNSETTRANSFER _IO(CED_MAGIC_IOC, 12)
|
||||
#define IOCTL_CED_SETEVENT _IOW(CED_MAGIC_IOC,13, TRANSFEREVENT)
|
||||
#define IOCTL_CED_GETOUTBUFSPACE _IO(CED_MAGIC_IOC, 14)
|
||||
#define IOCTL_CED_GETBASEADDRESS _IO(CED_MAGIC_IOC, 15)
|
||||
#define IOCTL_CED_GETDRIVERREVISION _IO(CED_MAGIC_IOC, 16)
|
||||
|
||||
#define IOCTL_CED_GETTRANSFER _IOR(CED_MAGIC_IOC,17, TGET_TX_BLOCK)
|
||||
#define IOCTL_CED_KILLIO1401 _IO(CED_MAGIC_IOC,18)
|
||||
#define IOCTL_CED_BLKTRANSSTATE _IO(CED_MAGIC_IOC,19)
|
||||
|
||||
#define IOCTL_CED_STATEOF1401 _IO(CED_MAGIC_IOC,23)
|
||||
#define IOCTL_CED_GRAB1401 _IO(CED_MAGIC_IOC,25)
|
||||
#define IOCTL_CED_FREE1401 _IO(CED_MAGIC_IOC,26)
|
||||
#define IOCTL_CED_STARTSELFTEST _IO(CED_MAGIC_IOC,31)
|
||||
#define IOCTL_CED_CHECKSELFTEST _IOR(CED_MAGIC_IOC,32, TGET_SELFTEST)
|
||||
#define IOCTL_CED_TYPEOF1401 _IO(CED_MAGIC_IOC,33)
|
||||
#define IOCTL_CED_TRANSFERFLAGS _IO(CED_MAGIC_IOC,34)
|
||||
|
||||
#define IOCTL_CED_DBGPEEK _IOW(CED_MAGIC_IOC,35, TDBGBLOCK)
|
||||
#define IOCTL_CED_DBGPOKE _IOW(CED_MAGIC_IOC,36, TDBGBLOCK)
|
||||
#define IOCTL_CED_DBGRAMPDATA _IOW(CED_MAGIC_IOC,37, TDBGBLOCK)
|
||||
#define IOCTL_CED_DBGRAMPADDR _IOW(CED_MAGIC_IOC,38, TDBGBLOCK)
|
||||
#define IOCTL_CED_DBGGETDATA _IOR(CED_MAGIC_IOC,39, TDBGBLOCK)
|
||||
#define IOCTL_CED_DBGSTOPLOOP _IO(CED_MAGIC_IOC,40)
|
||||
#define IOCTL_CED_FULLRESET _IO(CED_MAGIC_IOC,41)
|
||||
#define IOCTL_CED_SETCIRCULAR _IOW(CED_MAGIC_IOC,42, TRANSFERDESC)
|
||||
#define IOCTL_CED_GETCIRCBLOCK _IOWR(CED_MAGIC_IOC,43, TCIRCBLOCK)
|
||||
#define IOCTL_CED_FREECIRCBLOCK _IOWR(CED_MAGIC_IOC,44, TCIRCBLOCK)
|
||||
#define IOCTL_CED_WAITEVENT _IO(CED_MAGIC_IOC, 45)
|
||||
#define IOCTL_CED_TESTEVENT _IO(CED_MAGIC_IOC, 46)
|
||||
|
||||
#ifndef __KERNEL__
|
||||
// If nothing said about return value, it is a U14ERR_... error code (U14ERR_NOERROR for none)
|
||||
inline int CED_SendString(int fh, const char* szText, int n){return ioctl(fh, IOCTL_CED_SENDSTRING(n), szText);}
|
||||
|
||||
inline int CED_Reset1401(int fh){return ioctl(fh, IOCTL_CED_RESET1401);}
|
||||
|
||||
inline int CED_GetChar(int fh){return ioctl(fh, IOCTL_CED_GETCHAR);}
|
||||
// Return the singe character or a -ve error code.
|
||||
|
||||
inline int CED_Stat1401(int fh){return ioctl(fh, IOCTL_CED_STAT1401);}
|
||||
// Return character count in input buffer
|
||||
|
||||
inline int CED_SendChar(int fh, char c){return ioctl(fh, IOCTL_CED_SENDCHAR, c);}
|
||||
|
||||
inline int CED_LineCount(int fh){return ioctl(fh, IOCTL_CED_LINECOUNT);}
|
||||
|
||||
inline int CED_GetString(int fh, char* szText, int nMax){return ioctl(fh, IOCTL_CED_GETSTRING(nMax), szText);}
|
||||
// return the count of characters returned. If the string was terminated by CR or 0, then the 0 is part
|
||||
// of the count. Otherwise, we will add a zero if there is room, but it is not included in the count.
|
||||
// The return value is 0 if there was nothing to read.
|
||||
|
||||
inline int CED_GetOutBufSpace(int fh){return ioctl(fh, IOCTL_CED_GETOUTBUFSPACE);}
|
||||
// returns space in the output buffer.
|
||||
|
||||
inline int CED_GetBaseAddress(int fh){return ioctl(fh, IOCTL_CED_GETBASEADDRESS);}
|
||||
// This always returns -1 as not implemented.
|
||||
|
||||
inline int CED_GetDriverRevision(int fh){return ioctl(fh, IOCTL_CED_GETDRIVERREVISION);}
|
||||
// returns the major revision <<16 | minor revision.
|
||||
|
||||
inline int CED_SetTransfer(int fh, TRANSFERDESC* pTD){return ioctl(fh, IOCTL_CED_SETTRANSFER, pTD);}
|
||||
|
||||
inline int CED_UnsetTransfer(int fh, int nArea){return ioctl(fh, IOCTL_CED_UNSETTRANSFER, nArea);}
|
||||
|
||||
inline int CED_SetEvent(int fh, TRANSFEREVENT* pTE){return ioctl(fh, IOCTL_CED_SETEVENT, pTE);}
|
||||
|
||||
inline int CED_GetTransfer(int fh, TGET_TX_BLOCK* pTX){return ioctl(fh, IOCTL_CED_GETTRANSFER, pTX);}
|
||||
|
||||
inline int CED_KillIO1401(int fh){return ioctl(fh, IOCTL_CED_KILLIO1401);}
|
||||
|
||||
inline int CED_BlkTransState(int fh){return ioctl(fh, IOCTL_CED_BLKTRANSSTATE);}
|
||||
// returns 0 if no active DMA, 1 if active
|
||||
|
||||
inline int CED_StateOf1401(int fh){return ioctl(fh, IOCTL_CED_STATEOF1401);}
|
||||
|
||||
inline int CED_Grab1401(int fh){return ioctl(fh, IOCTL_CED_GRAB1401);}
|
||||
inline int CED_Free1401(int fh){return ioctl(fh, IOCTL_CED_FREE1401);}
|
||||
|
||||
inline int CED_StartSelfTest(int fh){return ioctl(fh, IOCTL_CED_STARTSELFTEST);}
|
||||
inline int CED_CheckSelfTest(int fh, TGET_SELFTEST* pGST){return ioctl(fh, IOCTL_CED_CHECKSELFTEST, pGST);}
|
||||
|
||||
inline int CED_TypeOf1401(int fh){return ioctl(fh, IOCTL_CED_TYPEOF1401);}
|
||||
inline int CED_TransferFlags(int fh){return ioctl(fh, IOCTL_CED_TRANSFERFLAGS);}
|
||||
|
||||
inline int CED_DbgPeek(int fh, TDBGBLOCK* pDB){return ioctl(fh, IOCTL_CED_DBGPEEK, pDB);}
|
||||
inline int CED_DbgPoke(int fh, TDBGBLOCK* pDB){return ioctl(fh, IOCTL_CED_DBGPOKE, pDB);}
|
||||
inline int CED_DbgRampData(int fh, TDBGBLOCK* pDB){return ioctl(fh, IOCTL_CED_DBGRAMPDATA, pDB);}
|
||||
inline int CED_DbgRampAddr(int fh, TDBGBLOCK* pDB){return ioctl(fh, IOCTL_CED_DBGRAMPADDR, pDB);}
|
||||
inline int CED_DbgGetData(int fh, TDBGBLOCK* pDB){return ioctl(fh, IOCTL_CED_DBGGETDATA, pDB);}
|
||||
inline int CED_DbgStopLoop(int fh){return ioctl(fh, IOCTL_CED_DBGSTOPLOOP);}
|
||||
|
||||
inline int CED_FullReset(int fh){return ioctl(fh, IOCTL_CED_FULLRESET);}
|
||||
|
||||
inline int CED_SetCircular(int fh, TRANSFERDESC* pTD){return ioctl(fh, IOCTL_CED_SETCIRCULAR, pTD);}
|
||||
inline int CED_GetCircBlock(int fh, TCIRCBLOCK* pCB){return ioctl(fh, IOCTL_CED_GETCIRCBLOCK, pCB);}
|
||||
inline int CED_FreeCircBlock(int fh, TCIRCBLOCK* pCB){return ioctl(fh, IOCTL_CED_FREECIRCBLOCK, pCB);}
|
||||
|
||||
inline int CED_WaitEvent(int fh, int nArea, int msTimeOut){return ioctl(fh, IOCTL_CED_WAITEVENT, (nArea & 0xff)|(msTimeOut << 8));}
|
||||
inline int CED_TestEvent(int fh, int nArea){return ioctl(fh, IOCTL_CED_TESTEVENT, nArea);}
|
||||
#endif
|
||||
|
||||
#ifdef NOTWANTEDYET
|
||||
#define IOCTL_CED_REGCALLBACK _IO(CED_MAGIC_IOC,9) // Not used
|
||||
#define IOCTL_CED_GETMONITORBUF _IO(CED_MAGIC_IOC,10) // Not used
|
||||
|
||||
#define IOCTL_CED_BYTECOUNT _IO(CED_MAGIC_IOC,20) // Not used
|
||||
#define IOCTL_CED_ZEROBLOCKCOUNT _IO(CED_MAGIC_IOC,21) // Not used
|
||||
#define IOCTL_CED_STOPCIRCULAR _IO(CED_MAGIC_IOC,22) // Not used
|
||||
|
||||
#define IOCTL_CED_REGISTERS1401 _IO(CED_MAGIC_IOC,24) // Not used
|
||||
#define IOCTL_CED_STEP1401 _IO(CED_MAGIC_IOC,27) // Not used
|
||||
#define IOCTL_CED_SET1401REGISTERS _IO(CED_MAGIC_IOC,28) // Not used
|
||||
#define IOCTL_CED_STEPTILL1401 _IO(CED_MAGIC_IOC,29) // Not used
|
||||
#define IOCTL_CED_SETORIN _IO(CED_MAGIC_IOC,30) // Not used
|
||||
|
||||
#endif
|
||||
|
||||
// __CED_IOCTL_H__
|
||||
#endif
|
127
drivers/staging/ced1401/machine.h
Normal file
127
drivers/staging/ced1401/machine.h
Normal file
|
@ -0,0 +1,127 @@
|
|||
/*****************************************************************************
|
||||
**
|
||||
** machine.h
|
||||
**
|
||||
** Copyright (c) Cambridge Electronic Design Limited 1991,1992,2010
|
||||
**
|
||||
** 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
**
|
||||
** Contact CED: Cambridge Electronic Design Limited, Science Park, Milton Road
|
||||
** Cambridge, CB6 0FE.
|
||||
** www.ced.co.uk
|
||||
** greg@ced.co.uk
|
||||
**
|
||||
** This file is included at the start of 'C' or 'C++' source file to define
|
||||
** things for cross-platform/compiler interoperability. This used to deal with
|
||||
** MSDOS/16-bit stuff, but this was all removed in Decemeber 2010. There are
|
||||
** three things to consider: Windows, LINUX, mac OSX (BSD Unix) and 32 vs 64
|
||||
** bit. At the time of writing (DEC 2010) there is a consensus on the following
|
||||
** and their unsigned equivalents:
|
||||
**
|
||||
** type bits
|
||||
** char 8
|
||||
** short 16
|
||||
** int 32
|
||||
** long long 64
|
||||
**
|
||||
** long is a problem as it is always 64 bits on linux/unix and is always 32 bits
|
||||
** on windows.
|
||||
** On windows, we define _IS_WINDOWS_ and one of WIN32 or WIN64.
|
||||
** On linux we define LINUX
|
||||
** On Max OSX we define MACOSX
|
||||
**
|
||||
*/
|
||||
|
||||
#ifndef __MACHINE_H__
|
||||
#define __MACHINE_H__
|
||||
#ifndef __KERNEL__
|
||||
#include <float.h>
|
||||
#include <limits.h>
|
||||
#endif
|
||||
|
||||
/*
|
||||
** The initial section is to identify the operating system
|
||||
*/
|
||||
#if (defined(__linux__) || defined(_linux) || defined(__linux)) && !defined(LINUX)
|
||||
#define LINUX 1
|
||||
#endif
|
||||
|
||||
#if (defined(__WIN32__) || defined(_WIN32)) && !defined(WIN32)
|
||||
#define WIN32 1
|
||||
#endif
|
||||
|
||||
#if defined(__APPLE__)
|
||||
#define MACOSX
|
||||
#endif
|
||||
|
||||
#if defined(_WIN64)
|
||||
#undef WIN32
|
||||
#undef WIN64
|
||||
#define WIN64 1
|
||||
#endif
|
||||
|
||||
#if defined(WIN32) || defined(WIN64)
|
||||
#define _IS_WINDOWS_ 1
|
||||
#endif
|
||||
|
||||
#if defined(LINUX) || defined(MAXOSX)
|
||||
#define FAR
|
||||
|
||||
typedef int BOOL; // To match Windows
|
||||
typedef char * LPSTR;
|
||||
typedef const char * LPCSTR;
|
||||
typedef unsigned short WORD;
|
||||
typedef unsigned int DWORD;
|
||||
typedef unsigned char BYTE;
|
||||
typedef BYTE BOOLEAN;
|
||||
typedef unsigned char UCHAR;
|
||||
#define __packed __attribute__((packed))
|
||||
typedef BYTE * LPBYTE;
|
||||
#define HIWORD(x) (WORD)(((x)>>16) & 0xffff)
|
||||
#define LOWORD(x) (WORD)((x) & 0xffff)
|
||||
#endif
|
||||
|
||||
#ifdef _IS_WINDOWS_
|
||||
#include <windows.h>
|
||||
#define __packed
|
||||
#endif
|
||||
|
||||
/*
|
||||
** Sort out the DllExport and DllImport macros. The GCC compiler has its own
|
||||
** syntax for this, though it also supports the MS specific __declspec() as
|
||||
** a synonym.
|
||||
*/
|
||||
#ifdef GNUC
|
||||
#define DllExport __attribute__((dllexport))
|
||||
#define DllImport __attribute__((dllimport))
|
||||
#endif
|
||||
|
||||
#ifndef DllExport
|
||||
#ifdef _IS_WINDOWS_
|
||||
#define DllExport __declspec(dllexport)
|
||||
#define DllImport __declspec(dllimport)
|
||||
#else
|
||||
#define DllExport
|
||||
#define DllImport
|
||||
#endif
|
||||
#endif /* _IS_WINDOWS_ */
|
||||
|
||||
|
||||
#ifndef TRUE
|
||||
#define TRUE 1
|
||||
#define FALSE 0
|
||||
#endif
|
||||
|
||||
#endif
|
1597
drivers/staging/ced1401/usb1401.c
Normal file
1597
drivers/staging/ced1401/usb1401.c
Normal file
File diff suppressed because it is too large
Load diff
249
drivers/staging/ced1401/usb1401.h
Normal file
249
drivers/staging/ced1401/usb1401.h
Normal file
|
@ -0,0 +1,249 @@
|
|||
/* usb1401.h
|
||||
Header file for the CED 1401 USB device driver for Linux
|
||||
Copyright (C) 2010 Cambridge Electronic Design Ltd
|
||||
Author Greg P Smith (greg@ced.co.uk)
|
||||
|
||||
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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
#ifndef __USB1401_H__
|
||||
#define __USB1401_H__
|
||||
#include "use1401.h"
|
||||
#include "ced_ioctl.h"
|
||||
|
||||
#ifndef UINT
|
||||
#define UINT unsigned int
|
||||
#endif
|
||||
|
||||
/// Device type codes, but these don't need to be extended - a succession is assumed
|
||||
/// These are set for usb from the bcdDevice field (suitably mangled). Future devices
|
||||
/// will be added in order of device creation to the list, so the names here are just
|
||||
/// to help use remember which device is which. The U14ERR_... values follow the same
|
||||
/// pattern for modern devices.
|
||||
#define TYPEUNKNOWN -1 // dont know
|
||||
#define TYPE1401 0 // standard 1401
|
||||
#define TYPEPLUS 1 // 1401 plus
|
||||
#define TYPEU1401 2 // u1401
|
||||
#define TYPEPOWER 3 // Power1401
|
||||
#define TYPEU14012 4 // u1401 mkII
|
||||
#define TYPEPOWER2 5 // Power1401 mk II
|
||||
#define TYPEMICRO3 6 // Micro1401-3
|
||||
#define TYPEPOWER3 7 // Power1401-3
|
||||
|
||||
/// Some useful defines of constants. DONT FORGET to change the version in the
|
||||
/// resources whenever you change it here!.
|
||||
#define DRIVERMAJREV 2 // driver revision level major (match windows)
|
||||
#define DRIVERMINREV 0 // driver revision level minor
|
||||
|
||||
/// Definitions of the various block transfer command codes
|
||||
#define TM_EXTTOHOST 8 // extended tohost
|
||||
#define TM_EXTTO1401 9 // extended to1401
|
||||
|
||||
/// Definitions of values in usbReqtype. Used in sorting out setup actions
|
||||
#define H_TO_D 0x00
|
||||
#define D_TO_H 0x80
|
||||
#define VENDOR 0x40
|
||||
#define DEVREQ 0x00
|
||||
#define INTREQ 0x01
|
||||
#define ENDREQ 0x02
|
||||
|
||||
/// Definition of values in usbRequest, again used to sort out setup
|
||||
#define GET_STATUS 0x00
|
||||
#define CLEAR_FEATURE 0x01
|
||||
#define SET_FEATURE 0x03
|
||||
#define SET_ADDRESS 0x05
|
||||
#define GET_DESC 0x06
|
||||
#define SET_DESC 0x07
|
||||
#define GET_CONF 0x08
|
||||
#define SET_CONF 0x09
|
||||
#define GET_INTERFACE 0x0a
|
||||
#define SET_INTERFACE 0x0b
|
||||
#define SYNCH_FRAME 0x0c
|
||||
|
||||
/// Definitions of the various debug command codes understood by the 1401. These
|
||||
/// are used in various vendor-specific commands to achieve the desired effect
|
||||
#define DB_GRAB 0x50 /* Grab is a NOP for USB */
|
||||
#define DB_FREE 0x51 /* Free is a NOP for the USB */
|
||||
#define DB_SETADD 0x52 /* Set debug address (double) */
|
||||
#define DB_SELFTEST 0x53 /* Start self test */
|
||||
#define DB_SETMASK 0x54 /* Set enable mask (double) */
|
||||
#define DB_SETDEF 0x55 /* Set default mask (double) */
|
||||
#define DB_PEEK 0x56 /* Peek address, save result */
|
||||
#define DB_POKE 0x57 /* Poke address with data (double) */
|
||||
#define DB_RAMPD 0x58 /* Ramp data at debug address */
|
||||
#define DB_RAMPA 0x59 /* Ramp address bus */
|
||||
#define DB_REPEATS 0x5A /* Set repeats for operations (double) */
|
||||
#define DB_WIDTH 0x5B /* Set width for operations (byte) */
|
||||
#define DB_DATA 0x5C /* Get 4-byte data read by PEEK */
|
||||
#define DB_CHARS 0x5D /* Send chars via EP0 control write */
|
||||
|
||||
#define CR_CHAR 0x0D /* The carriage return character */
|
||||
#define CR_CHAR_80 0x8d /* and with bit 7 set */
|
||||
|
||||
/// A structure holding information about a block of memory for use in circular transfers
|
||||
typedef struct circBlk
|
||||
{
|
||||
volatile UINT dwOffset; /* Offset within area of block start */
|
||||
volatile UINT dwSize; /* Size of the block, in bytes (0 = unused) */
|
||||
} CIRCBLK;
|
||||
|
||||
/// A structure holding all of the information about a transfer area - an area of
|
||||
/// memory set up for use either as a source or destination in DMA transfers.
|
||||
typedef struct transarea
|
||||
{
|
||||
void* lpvBuff; // User address of xfer area saved for completeness
|
||||
UINT dwBaseOffset; // offset to start of xfer area in first page
|
||||
UINT dwLength; // Length of xfer area, in bytes
|
||||
struct page **pPages; // Points at array of locked down pages
|
||||
int nPages; // number of pages that are locked down
|
||||
bool bUsed; // Is this structure in use?
|
||||
bool bCircular; // Is this area for circular transfers?
|
||||
bool bCircToHost; // Flag for direction of circular transfer
|
||||
bool bEventToHost; // Set event on transfer to host?
|
||||
int iWakeUp; // Set 1 on event, cleared by TestEvent()
|
||||
UINT dwEventSt; // Defines section within xfer area for...
|
||||
UINT dwEventSz; // ...notification by the event SZ is 0 if unset
|
||||
CIRCBLK aBlocks[2]; // Info on a pair of circular blocks
|
||||
wait_queue_head_t wqEvent; // The wait queue for events in this area MUST BE LAST
|
||||
} TRANSAREA;
|
||||
|
||||
/// The DMADESC structure is used to hold information on the transfer in progress. It
|
||||
/// is set up by ReadDMAInfo, using information sent by the 1401 in an escape sequence.
|
||||
typedef struct dmadesc
|
||||
{
|
||||
unsigned short wTransType; /* transfer type as TM_xxx above */
|
||||
unsigned short wIdent; /* identifier word */
|
||||
unsigned int dwSize; /* bytes to transfer */
|
||||
unsigned int dwOffset; /* offset into transfer area for trans */
|
||||
bool bOutWard; /* true when data is going TO 1401 */
|
||||
} DMADESC;
|
||||
|
||||
#define INBUF_SZ 256 /* input buffer size */
|
||||
#define OUTBUF_SZ 256 /* output buffer size */
|
||||
#define STAGED_SZ 0x10000 // size of coherent buffer for staged transfers
|
||||
|
||||
/// Structure to hold all of our device specific stuff. We are making this as similar as we
|
||||
/// can to the Windows driver to help in our understanding of what is going on.
|
||||
typedef struct _DEVICE_EXTENSION
|
||||
{
|
||||
char inputBuffer[INBUF_SZ]; /* The two buffers */
|
||||
char outputBuffer[OUTBUF_SZ]; /* accessed by the host functions */
|
||||
volatile unsigned int dwNumInput; /* num of chars in input buffer */
|
||||
volatile unsigned int dwInBuffGet; /* where to get from input buffer */
|
||||
volatile unsigned int dwInBuffPut; /* where to put into input buffer */
|
||||
volatile unsigned int dwNumOutput; /* num of chars in output buffer */
|
||||
volatile unsigned int dwOutBuffGet; /* where to get from output buffer*/
|
||||
volatile unsigned int dwOutBuffPut; /* where to put into output buffer*/
|
||||
|
||||
volatile bool bSendCharsPending; /* Flag to indicate sendchar active */
|
||||
volatile bool bReadCharsPending; /* Flag to indicate a read is primed */
|
||||
char* pCoherCharOut; /* special aligned buffer for chars to 1401 */
|
||||
struct urb* pUrbCharOut; /* urb used for chars to 1401 */
|
||||
char* pCoherCharIn; /* special aligned buffer for chars to host */
|
||||
struct urb* pUrbCharIn; /* urb used for chars to host */
|
||||
|
||||
spinlock_t charOutLock; /* to protect the outputBuffer and outputting */
|
||||
spinlock_t charInLock; /* to protect the inputBuffer and char reads */
|
||||
__u8 bInterval; /* Interrupt end point interval */
|
||||
|
||||
volatile unsigned int dwDMAFlag; /* state of DMA */
|
||||
TRANSAREA rTransDef[MAX_TRANSAREAS];/* transfer area info */
|
||||
volatile DMADESC rDMAInfo; // info on current DMA transfer
|
||||
volatile bool bXFerWaiting; // Flag set if DMA transfer stalled
|
||||
volatile bool bInDrawDown; // Flag that we want to halt transfers
|
||||
|
||||
// Parameters relating to a block read\write that is in progress. Some of these values
|
||||
// are equivalent to values in rDMAInfo. The values here are those in use, while those
|
||||
// in rDMAInfo are those recieved from the 1401 via an escape sequence. If another
|
||||
// escape sequence arrives before the previous xfer ends, rDMAInfo values are updated while these
|
||||
// are used to finish off the current transfer.
|
||||
volatile short StagedId; // The transfer area id for this transfer
|
||||
volatile bool StagedRead; // Flag TRUE for read from 1401, FALSE for write
|
||||
volatile unsigned int StagedLength; // Total length of this transfer
|
||||
volatile unsigned int StagedOffset; // Offset within memory area for transfer start
|
||||
volatile unsigned int StagedDone; // Bytes transferred so far
|
||||
volatile bool bStagedUrbPending; // Flag to indicate active
|
||||
char* pCoherStagedIO; // buffer used for block transfers
|
||||
struct urb* pStagedUrb; // The URB to use
|
||||
spinlock_t stagedLock; // protects ReadWriteMem() and circular buffer stuff
|
||||
|
||||
short s1401Type; // type of 1401 attached
|
||||
short sCurrentState; // current error state
|
||||
bool bIsUSB2; // type of the interface we connect to
|
||||
bool bForceReset; // Flag to make sure we get a real reset
|
||||
__u32 statBuf[2]; // buffer for 1401 state info
|
||||
|
||||
unsigned long ulSelfTestTime; // used to timeout self test
|
||||
|
||||
int nPipes; // Should be 3 or 4 depending on 1401 usb chip
|
||||
int bPipeError[4]; // set non-zero if an error on one of the pipe
|
||||
__u8 epAddr[4]; // addresses of the 3/4 end points
|
||||
|
||||
struct usb_device *udev; // the usb device for this device
|
||||
struct usb_interface *interface; // the interface for this device, NULL if removed
|
||||
struct usb_anchor submitted; // in case we need to retract our submissions
|
||||
struct mutex io_mutex; // synchronize I/O with disconnect, one user-mode caller at a time
|
||||
|
||||
int errors; // the last request tanked
|
||||
int open_count; // count the number of openers
|
||||
spinlock_t err_lock; // lock for errors
|
||||
struct kref kref;
|
||||
}DEVICE_EXTENSION, *PDEVICE_EXTENSION;
|
||||
#define to_DEVICE_EXTENSION(d) container_of(d, DEVICE_EXTENSION, kref)
|
||||
|
||||
/// Definitions of routimes used between compilation object files
|
||||
// in usb1401.c
|
||||
extern int Allowi(DEVICE_EXTENSION* pdx, bool bInCallback);
|
||||
extern int SendChars(DEVICE_EXTENSION* pdx);
|
||||
extern void ced_draw_down(DEVICE_EXTENSION *pdx);
|
||||
extern int ReadWriteMem(DEVICE_EXTENSION *pdx, bool Read, unsigned short wIdent,
|
||||
unsigned int dwOffs, unsigned int dwLen);
|
||||
|
||||
// in ced_ioc.c
|
||||
extern int ClearArea(DEVICE_EXTENSION *pdx, int nArea);
|
||||
extern int SendString(DEVICE_EXTENSION* pdx, const char __user* pData, unsigned int n);
|
||||
extern int SendChar(DEVICE_EXTENSION *pdx, char c);
|
||||
extern int Get1401State(DEVICE_EXTENSION* pdx, __u32* state, __u32* error);
|
||||
extern int ReadWrite_Cancel(DEVICE_EXTENSION *pdx);
|
||||
extern bool Is1401(DEVICE_EXTENSION* pdx);
|
||||
extern bool QuickCheck(DEVICE_EXTENSION* pdx, bool bTestBuff, bool bCanReset);
|
||||
extern int Reset1401(DEVICE_EXTENSION *pdx);
|
||||
extern int GetChar(DEVICE_EXTENSION *pdx);
|
||||
extern int GetString(DEVICE_EXTENSION *pdx, char __user* pUser, int n);
|
||||
extern int SetTransfer(DEVICE_EXTENSION *pdx, TRANSFERDESC __user *pTD);
|
||||
extern int UnsetTransfer(DEVICE_EXTENSION *pdx, int nArea);
|
||||
extern int SetEvent(DEVICE_EXTENSION *pdx, TRANSFEREVENT __user*pTE);
|
||||
extern int Stat1401(DEVICE_EXTENSION *pdx);
|
||||
extern int LineCount(DEVICE_EXTENSION *pdx);
|
||||
extern int GetOutBufSpace(DEVICE_EXTENSION *pdx);
|
||||
extern int GetTransfer(DEVICE_EXTENSION *pdx, TGET_TX_BLOCK __user *pGTB);
|
||||
extern int KillIO1401(DEVICE_EXTENSION *pdx);
|
||||
extern int BlkTransState(DEVICE_EXTENSION *pdx);
|
||||
extern int StateOf1401(DEVICE_EXTENSION *pdx);
|
||||
extern int StartSelfTest(DEVICE_EXTENSION *pdx);
|
||||
extern int CheckSelfTest(DEVICE_EXTENSION *pdx, TGET_SELFTEST __user *pGST);
|
||||
extern int TypeOf1401(DEVICE_EXTENSION *pdx);
|
||||
extern int TransferFlags(DEVICE_EXTENSION *pdx);
|
||||
extern int DbgPeek(DEVICE_EXTENSION *pdx, TDBGBLOCK __user* pDB);
|
||||
extern int DbgPoke(DEVICE_EXTENSION *pdx, TDBGBLOCK __user *pDB);
|
||||
extern int DbgRampData(DEVICE_EXTENSION *pdx, TDBGBLOCK __user *pDB);
|
||||
extern int DbgRampAddr(DEVICE_EXTENSION *pdx, TDBGBLOCK __user *pDB);
|
||||
extern int DbgGetData(DEVICE_EXTENSION *pdx, TDBGBLOCK __user *pDB);
|
||||
extern int DbgStopLoop(DEVICE_EXTENSION *pdx);
|
||||
extern int SetCircular(DEVICE_EXTENSION *pdx, TRANSFERDESC __user *pTD);
|
||||
extern int GetCircBlock(DEVICE_EXTENSION *pdx, TCIRCBLOCK __user* pCB);
|
||||
extern int FreeCircBlock(DEVICE_EXTENSION *pdx, TCIRCBLOCK __user* pCB);
|
||||
extern int WaitEvent(DEVICE_EXTENSION *pdx, int nArea, int msTimeOut);
|
||||
extern int TestEvent(DEVICE_EXTENSION *pdx, int nArea);
|
||||
#endif
|
287
drivers/staging/ced1401/use1401.h
Normal file
287
drivers/staging/ced1401/use1401.h
Normal file
|
@ -0,0 +1,287 @@
|
|||
/****************************************************************************
|
||||
** use1401.h
|
||||
** Copyright (C) Cambridge Electronic Design Ltd, 1992-2010
|
||||
** Authors: Paul Cox, Tim Bergel, Greg Smith
|
||||
** See CVS for revisions.
|
||||
**
|
||||
** Because the size of a long is different between 32-bit and 64-bit on some
|
||||
** systems, we avoid this in this interface.
|
||||
****************************************************************************/
|
||||
#ifndef __USE1401_H__
|
||||
#define __USE1401_H__
|
||||
#include "machine.h"
|
||||
|
||||
// Some definitions to make things compatible. If you want to use Use1401 directly
|
||||
// from a Windows program you should define U14_NOT_DLL, in which case you also
|
||||
// MUST make sure that your application startup code calls U14InitLib().
|
||||
// DLL_USE1401 is defined when you are building the Use1401 dll, not otherwise.
|
||||
#ifdef _IS_WINDOWS_
|
||||
#ifndef U14_NOT_DLL
|
||||
#ifdef DLL_USE1401
|
||||
#define U14API(retType) retType DllExport __stdcall
|
||||
#else
|
||||
#define U14API(retType) retType DllImport __stdcall
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#define U14ERRBASE -500
|
||||
#define U14LONG long
|
||||
#endif
|
||||
|
||||
#ifdef LINUX
|
||||
#define U14ERRBASE -1000
|
||||
#define U14LONG int
|
||||
#endif
|
||||
|
||||
#ifdef _QT
|
||||
#ifndef U14_NOT_DLL
|
||||
#undef U14API
|
||||
#define U14API(retType) retType __declspec(dllimport) __stdcall
|
||||
#endif
|
||||
#undef U14LONG
|
||||
#define U14LONG int
|
||||
#endif
|
||||
|
||||
#ifndef U14API
|
||||
#define U14API(retType) retType
|
||||
#endif
|
||||
|
||||
#ifndef U14LONG
|
||||
#define U14LONG long
|
||||
#endif
|
||||
|
||||
/// Error codes: We need them here as user space can see them.
|
||||
#define U14ERR_NOERROR 0 // no problems
|
||||
|
||||
/// Device error codes, but these don't need to be extended - a succession is assumed
|
||||
#define U14ERR_STD 4 // standard 1401 connected
|
||||
#define U14ERR_U1401 5 // u1401 connected
|
||||
#define U14ERR_PLUS 6 // 1401 plus connected
|
||||
#define U14ERR_POWER 7 // Power1401 connected
|
||||
#define U14ERR_U14012 8 // u1401 mkII connected
|
||||
#define U14ERR_POWER2 9
|
||||
#define U14ERR_U14013 10
|
||||
#define U14ERR_POWER3 11
|
||||
|
||||
/// NBNB Error numbers need shifting as some linux error codes start at 512
|
||||
#define U14ERR(n) (n+U14ERRBASE)
|
||||
#define U14ERR_OFF U14ERR(0) /* 1401 there but switched off */
|
||||
#define U14ERR_NC U14ERR(-1) /* 1401 not connected */
|
||||
#define U14ERR_ILL U14ERR(-2) /* if present it is ill */
|
||||
#define U14ERR_NOIF U14ERR(-3) /* I/F card missing */
|
||||
#define U14ERR_TIME U14ERR(-4) /* 1401 failed to come ready */
|
||||
#define U14ERR_BADSW U14ERR(-5) /* I/F card bad switches */
|
||||
#define U14ERR_PTIME U14ERR(-6) /* 1401plus failed to come ready */
|
||||
#define U14ERR_NOINT U14ERR(-7) /* couldn't grab the int vector */
|
||||
#define U14ERR_INUSE U14ERR(-8) /* 1401 is already in use */
|
||||
#define U14ERR_NODMA U14ERR(-9) /* couldn't get DMA channel */
|
||||
#define U14ERR_BADHAND U14ERR(-10) /* handle provided was bad */
|
||||
#define U14ERR_BAD1401NUM U14ERR(-11) /* 1401 number provided was bad */
|
||||
|
||||
#define U14ERR_NO_SUCH_FN U14ERR(-20) /* no such function */
|
||||
#define U14ERR_NO_SUCH_SUBFN U14ERR(-21) /* no such sub function */
|
||||
#define U14ERR_NOOUT U14ERR(-22) /* no room in output buffer */
|
||||
#define U14ERR_NOIN U14ERR(-23) /* no input in buffer */
|
||||
#define U14ERR_STRLEN U14ERR(-24) /* string longer than buffer */
|
||||
#define U14ERR_ERR_STRLEN U14ERR(-24) /* string longer than buffer */
|
||||
#define U14ERR_LOCKFAIL U14ERR(-25) /* failed to lock memory */
|
||||
#define U14ERR_UNLOCKFAIL U14ERR(-26) /* failed to unlock memory */
|
||||
#define U14ERR_ALREADYSET U14ERR(-27) /* area already set up */
|
||||
#define U14ERR_NOTSET U14ERR(-28) /* area not set up */
|
||||
#define U14ERR_BADAREA U14ERR(-29) /* illegal area number */
|
||||
#define U14ERR_FAIL U14ERR(-30) /* we failed for some other reason*/
|
||||
|
||||
#define U14ERR_NOFILE U14ERR(-40) /* command file not found */
|
||||
#define U14ERR_READERR U14ERR(-41) /* error reading command file */
|
||||
#define U14ERR_UNKNOWN U14ERR(-42) /* unknown command */
|
||||
#define U14ERR_HOSTSPACE U14ERR(-43) /* not enough host space to load */
|
||||
#define U14ERR_LOCKERR U14ERR(-44) /* could not lock resource/command*/
|
||||
#define U14ERR_CLOADERR U14ERR(-45) /* CLOAD command failed */
|
||||
|
||||
#define U14ERR_TOXXXERR U14ERR(-60) /* tohost/1401 failed */
|
||||
#define U14ERR_NO386ENH U14ERR(-80) /* not 386 enhanced mode */
|
||||
#define U14ERR_NO1401DRIV U14ERR(-81) /* no device driver */
|
||||
#define U14ERR_DRIVTOOOLD U14ERR(-82) /* device driver too old */
|
||||
|
||||
#define U14ERR_TIMEOUT U14ERR(-90) /* timeout occurred */
|
||||
|
||||
#define U14ERR_BUFF_SMALL U14ERR(-100) /* buffer for getstring too small */
|
||||
#define U14ERR_CBALREADY U14ERR(-101) /* there is already a callback */
|
||||
#define U14ERR_BADDEREG U14ERR(-102) /* bad parameter to deregcallback */
|
||||
#define U14ERR_NOMEMORY U14ERR(-103) /* no memory for allocation */
|
||||
|
||||
#define U14ERR_DRIVCOMMS U14ERR(-110) /* failed talking to driver */
|
||||
#define U14ERR_OUTOFMEMORY U14ERR(-111) /* needed memory and couldnt get it*/
|
||||
|
||||
/// 1401 type codes.
|
||||
#define U14TYPE1401 0 /* standard 1401 */
|
||||
#define U14TYPEPLUS 1 /* 1401 plus */
|
||||
#define U14TYPEU1401 2 /* u1401 */
|
||||
#define U14TYPEPOWER 3 /* power1401 */
|
||||
#define U14TYPEU14012 4 /* u1401 mk II */
|
||||
#define U14TYPEPOWER2 5 /* power1401 mk II */
|
||||
#define U14TYPEU14013 6 /* u1401-3 */
|
||||
#define U14TYPEPOWER3 7 /* power1401-3 */
|
||||
#define U14TYPEUNKNOWN -1 /* dont know */
|
||||
|
||||
/// Transfer flags to allow driver capabilities to be interrogated
|
||||
|
||||
/// Constants for transfer flags
|
||||
#define U14TF_USEDMA 1 /* Transfer flag for use DMA */
|
||||
#define U14TF_MULTIA 2 /* Transfer flag for multi areas */
|
||||
#define U14TF_FIFO 4 /* for FIFO interface card */
|
||||
#define U14TF_USB2 8 /* for USB2 interface and 1401 */
|
||||
#define U14TF_NOTIFY 16 /* for event notifications */
|
||||
#define U14TF_SHORT 32 /* for PCI can short cycle */
|
||||
#define U14TF_PCI2 64 /* for new PCI card 1401-70 */
|
||||
#define U14TF_CIRCTH 128 /* Circular-mode to host */
|
||||
#define U14TF_DIAG 256 /* Diagnostics/debug functions */
|
||||
#define U14TF_CIRC14 512 /* Circular-mode to 1401 */
|
||||
|
||||
/// Definitions of element sizes for DMA transfers - to allow byte-swapping
|
||||
#define ESZBYTES 0 /* BYTE element size value */
|
||||
#define ESZWORDS 1 /* WORD element size value */
|
||||
#define ESZLONGS 2 /* long element size value */
|
||||
#define ESZUNKNOWN 0 /* unknown element size value */
|
||||
|
||||
/// These define required access types for the debug/diagnostics function
|
||||
#define BYTE_SIZE 1 /* 8-bit access */
|
||||
#define WORD_SIZE 2 /* 16-bit access */
|
||||
#define LONG_SIZE 3 /* 32-bit access */
|
||||
|
||||
/// Stuff used by U14_GetTransfer
|
||||
#define GET_TX_MAXENTRIES 257 /* (max length / page size + 1) */
|
||||
|
||||
#ifdef _IS_WINDOWS_
|
||||
#pragma pack(1)
|
||||
|
||||
typedef struct /* used for U14_GetTransfer results */
|
||||
{ /* Info on a single mapped block */
|
||||
U14LONG physical;
|
||||
U14LONG size;
|
||||
} TXENTRY;
|
||||
|
||||
typedef struct TGetTxBlock /* used for U14_GetTransfer results */
|
||||
{ /* matches structure in VXD */
|
||||
U14LONG size;
|
||||
U14LONG linear;
|
||||
short seg;
|
||||
short reserved;
|
||||
short avail; /* number of available entries */
|
||||
short used; /* number of used entries */
|
||||
TXENTRY entries[GET_TX_MAXENTRIES]; /* Array of mapped block info */
|
||||
} TGET_TX_BLOCK;
|
||||
|
||||
typedef TGET_TX_BLOCK *LPGET_TX_BLOCK;
|
||||
|
||||
#pragma pack()
|
||||
#endif
|
||||
|
||||
#ifdef LINUX
|
||||
typedef struct /* used for U14_GetTransfer results */
|
||||
{ /* Info on a single mapped block */
|
||||
long long physical;
|
||||
long size;
|
||||
} TXENTRY;
|
||||
|
||||
typedef struct TGetTxBlock /* used for U14_GetTransfer results */
|
||||
{ /* matches structure in VXD */
|
||||
long long linear; /* linear address */
|
||||
long size; /* total size of the mapped area, holds id when called */
|
||||
short seg; /* segment of the address for Win16 */
|
||||
short reserved;
|
||||
short avail; /* number of available entries */
|
||||
short used; /* number of used entries */
|
||||
TXENTRY entries[GET_TX_MAXENTRIES]; /* Array of mapped block info */
|
||||
} TGET_TX_BLOCK;
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
U14API(int) U14WhenToTimeOut(short hand); // when to timeout in ms
|
||||
U14API(short) U14PassedTime(int iTime); // non-zero if iTime passed
|
||||
|
||||
U14API(short) U14LastErrCode(short hand);
|
||||
|
||||
U14API(short) U14Open1401(short n1401);
|
||||
U14API(short) U14Close1401(short hand);
|
||||
U14API(short) U14Reset1401(short hand);
|
||||
U14API(short) U14ForceReset(short hand);
|
||||
U14API(short) U14TypeOf1401(short hand);
|
||||
U14API(short) U14NameOf1401(short hand, char* pBuf, WORD wMax);
|
||||
|
||||
U14API(short) U14Stat1401(short hand);
|
||||
U14API(short) U14CharCount(short hand);
|
||||
U14API(short) U14LineCount(short hand);
|
||||
|
||||
U14API(short) U14SendString(short hand, const char* pString);
|
||||
U14API(short) U14GetString(short hand, char* pBuffer, WORD wMaxLen);
|
||||
U14API(short) U14SendChar(short hand, char cChar);
|
||||
U14API(short) U14GetChar(short hand, char* pcChar);
|
||||
|
||||
U14API(short) U14LdCmd(short hand, const char* command);
|
||||
U14API(DWORD) U14Ld(short hand, const char* vl, const char* str);
|
||||
|
||||
U14API(short) U14SetTransArea(short hand, WORD wArea, void *pvBuff,
|
||||
DWORD dwLength, short eSz);
|
||||
U14API(short) U14UnSetTransfer(short hand, WORD wArea);
|
||||
U14API(short) U14SetTransferEvent(short hand, WORD wArea, BOOL bEvent,
|
||||
BOOL bToHost, DWORD dwStart, DWORD dwLength);
|
||||
U14API(int) U14TestTransferEvent(short hand, WORD wArea);
|
||||
U14API(int) U14WaitTransferEvent(short hand, WORD wArea, int msTimeOut);
|
||||
U14API(short) U14GetTransfer(short hand, TGET_TX_BLOCK *pTransBlock);
|
||||
|
||||
U14API(short) U14ToHost(short hand, char* pAddrHost,DWORD dwSize,DWORD dw1401,
|
||||
short eSz);
|
||||
U14API(short) U14To1401(short hand, const char* pAddrHost,DWORD dwSize,DWORD dw1401,
|
||||
short eSz);
|
||||
|
||||
U14API(short) U14SetCircular(short hand, WORD wArea, BOOL bToHost, void *pvBuff,
|
||||
DWORD dwLength);
|
||||
|
||||
U14API(int) U14GetCircBlk(short hand, WORD wArea, DWORD *pdwOffs);
|
||||
U14API(int) U14FreeCircBlk(short hand, WORD wArea, DWORD dwOffs, DWORD dwSize,
|
||||
DWORD *pdwOffs);
|
||||
|
||||
U14API(short) U14StrToLongs(const char* pszBuff, U14LONG *palNums, short sMaxLongs);
|
||||
U14API(short) U14LongsFrom1401(short hand, U14LONG *palBuff, short sMaxLongs);
|
||||
|
||||
U14API(void) U14SetTimeout(short hand, int lTimeout);
|
||||
U14API(int) U14GetTimeout(short hand);
|
||||
U14API(short) U14OutBufSpace(short hand);
|
||||
U14API(int) U14BaseAddr1401(short hand);
|
||||
U14API(int) U14DriverVersion(short hand);
|
||||
U14API(int) U14DriverType(short hand);
|
||||
U14API(short) U14DriverName(short hand, char* pBuf, WORD wMax);
|
||||
U14API(short) U14GetUserMemorySize(short hand, DWORD *pMemorySize);
|
||||
U14API(short) U14KillIO1401(short hand);
|
||||
|
||||
U14API(short) U14BlkTransState(short hand);
|
||||
U14API(short) U14StateOf1401(short hand);
|
||||
|
||||
U14API(short) U14Grab1401(short hand);
|
||||
U14API(short) U14Free1401(short hand);
|
||||
U14API(short) U14Peek1401(short hand, DWORD dwAddr, int nSize, int nRepeats);
|
||||
U14API(short) U14Poke1401(short hand, DWORD dwAddr, DWORD dwValue, int nSize, int nRepeats);
|
||||
U14API(short) U14Ramp1401(short hand, DWORD dwAddr, DWORD dwDef, DWORD dwEnable, int nSize, int nRepeats);
|
||||
U14API(short) U14RampAddr(short hand, DWORD dwDef, DWORD dwEnable, int nSize, int nRepeats);
|
||||
U14API(short) U14StopDebugLoop(short hand);
|
||||
U14API(short) U14GetDebugData(short hand, U14LONG *plValue);
|
||||
|
||||
U14API(short) U14StartSelfTest(short hand);
|
||||
U14API(short) U14CheckSelfTest(short hand, U14LONG *pData);
|
||||
U14API(short) U14TransferFlags(short hand);
|
||||
U14API(void) U14GetErrorString(short nErr, char* pStr, WORD wMax);
|
||||
U14API(int) U14MonitorRev(short hand);
|
||||
U14API(void) U14CloseAll(void);
|
||||
|
||||
U14API(short) U14WorkingSet(DWORD dwMinKb, DWORD dwMaxKb);
|
||||
U14API(int) U14InitLib(void);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* End of ifndef __USE1401_H__ */
|
301
drivers/staging/ced1401/use14_ioc.h
Normal file
301
drivers/staging/ced1401/use14_ioc.h
Normal file
|
@ -0,0 +1,301 @@
|
|||
/* use14_ioc.h
|
||||
** definitions of use1401 module stuff that is shared between use1401 and the driver.
|
||||
** Copyright (C) Cambridge Electronic Design Limited 2010
|
||||
** Author Greg P Smith
|
||||
************************************************************************************/
|
||||
#ifndef __USE14_IOC_H__
|
||||
#define __USE14_IOC_H__
|
||||
|
||||
#define MAX_TRANSAREAS 8 /* The number of transfer areas supported by driver */
|
||||
|
||||
#define i386
|
||||
#include "winioctl.h" /* needed so we can access driver */
|
||||
|
||||
/*
|
||||
** Defines for IOCTL functions to ask driver to perform. These must be matched
|
||||
** in both use1401 and in the driver. The IOCTL code contains a command
|
||||
** identifier, plus other information about the device, the type of access
|
||||
** with which the file must have been opened, and the type of buffering.
|
||||
** The IOCTL function codes from 0x80 to 0xFF are for developer use.
|
||||
*/
|
||||
#define FILE_DEVICE_CED1401 0x8001
|
||||
#define FNNUMBASE 0x800
|
||||
|
||||
#define U14_OPEN1401 CTL_CODE( FILE_DEVICE_CED1401, \
|
||||
FNNUMBASE, \
|
||||
METHOD_BUFFERED, \
|
||||
FILE_ANY_ACCESS)
|
||||
|
||||
#define U14_CLOSE1401 CTL_CODE( FILE_DEVICE_CED1401, \
|
||||
FNNUMBASE+1, \
|
||||
METHOD_BUFFERED, \
|
||||
FILE_ANY_ACCESS)
|
||||
|
||||
#define U14_SENDSTRING CTL_CODE( FILE_DEVICE_CED1401, \
|
||||
FNNUMBASE+2, \
|
||||
METHOD_BUFFERED, \
|
||||
FILE_ANY_ACCESS)
|
||||
|
||||
#define U14_RESET1401 CTL_CODE( FILE_DEVICE_CED1401, \
|
||||
FNNUMBASE+3, \
|
||||
METHOD_BUFFERED, \
|
||||
FILE_ANY_ACCESS)
|
||||
|
||||
#define U14_GETCHAR CTL_CODE( FILE_DEVICE_CED1401, \
|
||||
FNNUMBASE+4, \
|
||||
METHOD_BUFFERED, \
|
||||
FILE_ANY_ACCESS)
|
||||
|
||||
#define U14_SENDCHAR CTL_CODE( FILE_DEVICE_CED1401, \
|
||||
FNNUMBASE+5, \
|
||||
METHOD_BUFFERED, \
|
||||
FILE_ANY_ACCESS)
|
||||
|
||||
#define U14_STAT1401 CTL_CODE( FILE_DEVICE_CED1401, \
|
||||
FNNUMBASE+6, \
|
||||
METHOD_BUFFERED, \
|
||||
FILE_ANY_ACCESS)
|
||||
|
||||
#define U14_LINECOUNT CTL_CODE( FILE_DEVICE_CED1401, \
|
||||
FNNUMBASE+7, \
|
||||
METHOD_BUFFERED, \
|
||||
FILE_ANY_ACCESS)
|
||||
|
||||
#define U14_GETSTRING CTL_CODE( FILE_DEVICE_CED1401, \
|
||||
FNNUMBASE+8, \
|
||||
METHOD_BUFFERED, \
|
||||
FILE_ANY_ACCESS)
|
||||
|
||||
#define U14_REGCALLBACK CTL_CODE( FILE_DEVICE_CED1401, \
|
||||
FNNUMBASE+9, \
|
||||
METHOD_BUFFERED, \
|
||||
FILE_ANY_ACCESS)
|
||||
|
||||
#define U14_GETMONITORBUF CTL_CODE( FILE_DEVICE_CED1401, \
|
||||
FNNUMBASE+10, \
|
||||
METHOD_BUFFERED, \
|
||||
FILE_ANY_ACCESS)
|
||||
|
||||
#define U14_SETTRANSFER CTL_CODE( FILE_DEVICE_CED1401, \
|
||||
FNNUMBASE+11, \
|
||||
METHOD_BUFFERED, \
|
||||
FILE_ANY_ACCESS)
|
||||
|
||||
#define U14_UNSETTRANSFER CTL_CODE( FILE_DEVICE_CED1401, \
|
||||
FNNUMBASE+12, \
|
||||
METHOD_BUFFERED, \
|
||||
FILE_ANY_ACCESS)
|
||||
|
||||
#define U14_SETTRANSEVENT CTL_CODE( FILE_DEVICE_CED1401, \
|
||||
FNNUMBASE+13, \
|
||||
METHOD_BUFFERED, \
|
||||
FILE_ANY_ACCESS)
|
||||
|
||||
#define U14_GETOUTBUFSPACE CTL_CODE( FILE_DEVICE_CED1401, \
|
||||
FNNUMBASE+14, \
|
||||
METHOD_BUFFERED, \
|
||||
FILE_ANY_ACCESS)
|
||||
|
||||
#define U14_GETBASEADDRESS CTL_CODE( FILE_DEVICE_CED1401, \
|
||||
FNNUMBASE+15, \
|
||||
METHOD_BUFFERED, \
|
||||
FILE_ANY_ACCESS)
|
||||
|
||||
#define U14_GETDRIVERREVISION CTL_CODE( FILE_DEVICE_CED1401, \
|
||||
FNNUMBASE+16, \
|
||||
METHOD_BUFFERED, \
|
||||
FILE_ANY_ACCESS)
|
||||
|
||||
#define U14_GETTRANSFER CTL_CODE( FILE_DEVICE_CED1401, \
|
||||
FNNUMBASE+17, \
|
||||
METHOD_BUFFERED, \
|
||||
FILE_ANY_ACCESS)
|
||||
|
||||
#define U14_KILLIO1401 CTL_CODE( FILE_DEVICE_CED1401, \
|
||||
FNNUMBASE+18, \
|
||||
METHOD_BUFFERED, \
|
||||
FILE_ANY_ACCESS)
|
||||
|
||||
#define U14_BLKTRANSSTATE CTL_CODE( FILE_DEVICE_CED1401, \
|
||||
FNNUMBASE+19, \
|
||||
METHOD_BUFFERED, \
|
||||
FILE_ANY_ACCESS)
|
||||
|
||||
#define U14_BYTECOUNT CTL_CODE( FILE_DEVICE_CED1401, \
|
||||
FNNUMBASE+20, \
|
||||
METHOD_BUFFERED, \
|
||||
FILE_ANY_ACCESS)
|
||||
|
||||
#define U14_ZEROBLOCKCOUNT CTL_CODE( FILE_DEVICE_CED1401, \
|
||||
FNNUMBASE+21, \
|
||||
METHOD_BUFFERED, \
|
||||
FILE_ANY_ACCESS)
|
||||
|
||||
#define U14_STOPCIRCULAR CTL_CODE( FILE_DEVICE_CED1401, \
|
||||
FNNUMBASE+22, \
|
||||
METHOD_BUFFERED, \
|
||||
FILE_ANY_ACCESS)
|
||||
|
||||
#define U14_STATEOF1401 CTL_CODE( FILE_DEVICE_CED1401, \
|
||||
FNNUMBASE+23, \
|
||||
METHOD_BUFFERED, \
|
||||
FILE_ANY_ACCESS)
|
||||
|
||||
#define U14_REGISTERS1401 CTL_CODE( FILE_DEVICE_CED1401, \
|
||||
FNNUMBASE+24, \
|
||||
METHOD_BUFFERED, \
|
||||
FILE_ANY_ACCESS)
|
||||
|
||||
#define U14_GRAB1401 CTL_CODE( FILE_DEVICE_CED1401, \
|
||||
FNNUMBASE+25, \
|
||||
METHOD_BUFFERED, \
|
||||
FILE_ANY_ACCESS)
|
||||
|
||||
#define U14_FREE1401 CTL_CODE( FILE_DEVICE_CED1401, \
|
||||
FNNUMBASE+26, \
|
||||
METHOD_BUFFERED, \
|
||||
FILE_ANY_ACCESS)
|
||||
|
||||
#define U14_STEP1401 CTL_CODE( FILE_DEVICE_CED1401, \
|
||||
FNNUMBASE+27, \
|
||||
METHOD_BUFFERED, \
|
||||
FILE_ANY_ACCESS)
|
||||
|
||||
#define U14_SET1401REGISTERS CTL_CODE( FILE_DEVICE_CED1401, \
|
||||
FNNUMBASE+28, \
|
||||
METHOD_BUFFERED, \
|
||||
FILE_ANY_ACCESS)
|
||||
|
||||
#define U14_STEPTILL1401 CTL_CODE( FILE_DEVICE_CED1401, \
|
||||
FNNUMBASE+29, \
|
||||
METHOD_BUFFERED, \
|
||||
FILE_ANY_ACCESS)
|
||||
|
||||
#define U14_SETORIN CTL_CODE( FILE_DEVICE_CED1401, \
|
||||
FNNUMBASE+30, \
|
||||
METHOD_BUFFERED, \
|
||||
FILE_ANY_ACCESS)
|
||||
|
||||
#define U14_STARTSELFTEST CTL_CODE( FILE_DEVICE_CED1401, \
|
||||
FNNUMBASE+31, \
|
||||
METHOD_BUFFERED, \
|
||||
FILE_ANY_ACCESS)
|
||||
|
||||
#define U14_CHECKSELFTEST CTL_CODE( FILE_DEVICE_CED1401, \
|
||||
FNNUMBASE+32, \
|
||||
METHOD_BUFFERED, \
|
||||
FILE_ANY_ACCESS)
|
||||
|
||||
#define U14_TYPEOF1401 CTL_CODE( FILE_DEVICE_CED1401, \
|
||||
FNNUMBASE+33, \
|
||||
METHOD_BUFFERED, \
|
||||
FILE_ANY_ACCESS)
|
||||
|
||||
#define U14_TRANSFERFLAGS CTL_CODE( FILE_DEVICE_CED1401, \
|
||||
FNNUMBASE+34, \
|
||||
METHOD_BUFFERED, \
|
||||
FILE_ANY_ACCESS)
|
||||
|
||||
#define U14_DBGPEEK CTL_CODE( FILE_DEVICE_CED1401, \
|
||||
FNNUMBASE+35, \
|
||||
METHOD_BUFFERED, \
|
||||
FILE_ANY_ACCESS)
|
||||
|
||||
#define U14_DBGPOKE CTL_CODE( FILE_DEVICE_CED1401, \
|
||||
FNNUMBASE+36, \
|
||||
METHOD_BUFFERED, \
|
||||
FILE_ANY_ACCESS)
|
||||
|
||||
#define U14_DBGRAMPDATA CTL_CODE( FILE_DEVICE_CED1401, \
|
||||
FNNUMBASE+37, \
|
||||
METHOD_BUFFERED, \
|
||||
FILE_ANY_ACCESS)
|
||||
|
||||
#define U14_DBGRAMPADDR CTL_CODE( FILE_DEVICE_CED1401, \
|
||||
FNNUMBASE+38, \
|
||||
METHOD_BUFFERED, \
|
||||
FILE_ANY_ACCESS)
|
||||
|
||||
#define U14_DBGGETDATA CTL_CODE( FILE_DEVICE_CED1401, \
|
||||
FNNUMBASE+39, \
|
||||
METHOD_BUFFERED, \
|
||||
FILE_ANY_ACCESS)
|
||||
|
||||
#define U14_DBGSTOPLOOP CTL_CODE( FILE_DEVICE_CED1401, \
|
||||
FNNUMBASE+40, \
|
||||
METHOD_BUFFERED, \
|
||||
FILE_ANY_ACCESS)
|
||||
|
||||
#define U14_FULLRESET CTL_CODE( FILE_DEVICE_CED1401, \
|
||||
FNNUMBASE+41, \
|
||||
METHOD_BUFFERED, \
|
||||
FILE_ANY_ACCESS)
|
||||
|
||||
#define U14_SETCIRCULAR CTL_CODE( FILE_DEVICE_CED1401, \
|
||||
FNNUMBASE+42, \
|
||||
METHOD_BUFFERED, \
|
||||
FILE_ANY_ACCESS)
|
||||
|
||||
#define U14_GETCIRCBLK CTL_CODE( FILE_DEVICE_CED1401, \
|
||||
FNNUMBASE+43, \
|
||||
METHOD_BUFFERED, \
|
||||
FILE_ANY_ACCESS)
|
||||
|
||||
#define U14_FREECIRCBLK CTL_CODE( FILE_DEVICE_CED1401, \
|
||||
FNNUMBASE+44, \
|
||||
METHOD_BUFFERED, \
|
||||
FILE_ANY_ACCESS)
|
||||
|
||||
//--------------- Structures that are shared with the driver -------------
|
||||
#pragma pack(1)
|
||||
|
||||
typedef struct /* used for get/set standard 1401 registers */
|
||||
{
|
||||
short sPC;
|
||||
char A;
|
||||
char X;
|
||||
char Y;
|
||||
char stat;
|
||||
char rubbish;
|
||||
} T1401REGISTERS;
|
||||
|
||||
typedef union /* to communicate with 1401 driver status & control funcs */
|
||||
{
|
||||
char chrs[22];
|
||||
short ints[11];
|
||||
long longs[5];
|
||||
T1401REGISTERS registers;
|
||||
} TCSBLOCK;
|
||||
|
||||
typedef TCSBLOCK* LPTCSBLOCK;
|
||||
|
||||
typedef struct paramBlk
|
||||
{
|
||||
short sState;
|
||||
TCSBLOCK csBlock;
|
||||
} PARAMBLK;
|
||||
|
||||
typedef PARAMBLK* PPARAMBLK;
|
||||
|
||||
typedef struct TransferDesc /* Structure and type for SetTransArea */
|
||||
{
|
||||
WORD wArea; /* number of transfer area to set up */
|
||||
void FAR * lpvBuff; /* address of transfer area */
|
||||
DWORD dwLength; /* length of area to set up */
|
||||
short eSize; /* size to move (for swapping on MAC) */
|
||||
} TRANSFERDESC;
|
||||
|
||||
typedef TRANSFERDESC FAR * LPTRANSFERDESC;
|
||||
|
||||
/* This is the structure used to set up a transfer area */
|
||||
typedef struct VXTransferDesc /* use1401.c and use1432x.x use only */
|
||||
{
|
||||
WORD wArea; /* number of transfer area to set up */
|
||||
WORD wAddrSel; /* 16 bit selector for area */
|
||||
DWORD dwAddrOfs; /* 32 bit offset for area start */
|
||||
DWORD dwLength; /* length of area to set up */
|
||||
} VXTRANSFERDESC;
|
||||
|
||||
#pragma pack()
|
||||
|
||||
#endif
|
3035
drivers/staging/ced1401/userspace/use1401.c
Normal file
3035
drivers/staging/ced1401/userspace/use1401.c
Normal file
File diff suppressed because it is too large
Load diff
Loading…
Reference in a new issue