first usable version of kernel and commands

After an year of hard work, this is a first "usable" version of Jehanne.
This commit is contained in:
2016-11-25 16:18:40 +00:00
parent 391252a059
commit 38aca7a581
3989 changed files with 406697 additions and 1909 deletions

93
sys/include/usb/audio.h Normal file
View File

@@ -0,0 +1,93 @@
/*
* This file is part of the UCB release of Plan 9. It is subject to the license
* terms in the LICENSE file found in the top-level directory of this
* distribution and at http://akaros.cs.berkeley.edu/files/Plan9License. No
* part of the UCB release of Plan 9, including this file, may be copied,
* modified, propagated, or distributed except according to the terms contained
* in the LICENSE file.
*/
enum {
master_chan = 0x00,
Speed_control = 0x00,
/* Items below are defined by USB standard: */
Mute_control = 0x01,
Volume_control = 0x02,
Bass_control = 0x03,
Mid_control = 0x04,
Treble_control = 0x05,
Equalizer_control = 0x06,
Agc_control = 0x07,
Delay_control = 0x08,
Bassboost_control = 0x09,
Loudness_control = 0x0a,
/* Items below are defined by implementation: */
Channel_control = 0x0b,
Resolution_control = 0x0c,
Ncontrol,
Selector_control = 0x0d,
sampling_freq_control = 0x01,
Audiocsp = 0x000101, /* audio.control.0 */
AUDIO_INTERFACE = 0x24,
AUDIO_ENDPOINT = 0x25,
};
#define AS_GENERAL 1
#define FORMAT_TYPE 2
#define FORMAT_SPECIFIC 3
#define PCM 1
#define PCM8 2
#define IEEE_FLOAT 3
#define ALAW 4
#define MULAW 5
#define SAMPLING_FREQ_CONTROL 0x01
typedef struct Audioalt Audioalt;
struct Audioalt {
int nchan;
int res;
int subframesize;
int minfreq, maxfreq; /* continuous freqs */
int freqs[8]; /* discrete freqs */
int caps; /* see below for meanings */
};
enum {
/* Audioalt->caps bits */
has_setspeed = 0x1, /* has a speed_set command */
has_pitchset = 0x2, /* has a pitch_set command */
has_contfreq = 0x4, /* frequency continuously variable */
has_discfreq = 0x8, /* discrete set of frequencies */
onefreq = 0x10, /* only one frequency */
maxpkt_only = 0x80, /* packets must be padded to max size */
};
typedef uint8_t byte;
extern int setrec;
extern int verbose;
extern int defaultspeed[2];
extern Dev *ad;
extern Dev *buttondev;
extern Channel *controlchan;
extern Dev *epdev[2];
void audio_interface(Dev *d, Desc *dd);
void setalt(Dev *d, int endpt, int value);
int getalt(Dev *d, int endpt);
int setspeed(int rec, int speed);
int setcontrol(int rec, char *name, int32_t *value);
int getspecialcontrol(int rec, int ctl, int req, int32_t *value);
int getcontrol(int rec, char *name, int32_t *value);
int findalt(int rec, int nchan, int res, int speed);
void getcontrols(void);
void serve(void *);
int nbchanprint(Channel *c, char *fmt, ...);
int Aconv(Fmt *fp);

View File

@@ -0,0 +1,38 @@
/*
* This file is part of the UCB release of Plan 9. It is subject to the license
* terms in the LICENSE file found in the top-level directory of this
* distribution and at http://akaros.cs.berkeley.edu/files/Plan9License. No
* part of the UCB release of Plan 9, including this file, may be copied,
* modified, propagated, or distributed except according to the terms contained
* in the LICENSE file.
*/
enum{
Undef = 0x80000000,
Play = 0,
Record = 1,
};
typedef struct Audiocontrol Audiocontrol;
struct Audiocontrol {
char *name;
uint8_t readable;
uint8_t settable;
uint8_t chans; /* 0 is master, non-zero is bitmap */
int32_t value[8]; /* 0 is master; value[0] == Undef -> all values Undef */
int32_t min, max, step;
};
extern Audiocontrol controls[2][Ncontrol];
extern int endpt[2];
extern int interface[2];
extern int featureid[2];
extern int selectorid[2];
extern int mixerid[2];
extern int buttonendpt;
int ctlparse(char *s, Audiocontrol *c, int32_t *v);
void ctlevent(void);
#pragma varargck type "A" Audiocontrol*

133
sys/include/usb/ether.h Normal file
View File

@@ -0,0 +1,133 @@
/*
* This file is part of the UCB release of Plan 9. It is subject to the license
* terms in the LICENSE file found in the top-level directory of this
* distribution and at http://akaros.cs.berkeley.edu/files/Plan9License. No
* part of the UCB release of Plan 9, including this file, may be copied,
* modified, propagated, or distributed except according to the terms contained
* in the LICENSE file.
*/
typedef struct Ether Ether;
typedef struct Etherops Etherops;
typedef struct Conn Conn;
typedef struct Cinfo Cinfo;
typedef struct Buf Buf;
typedef struct Etherpkt Etherpkt;
enum
{
/* controller ids */
Cdc = 0,
A8817x, /* Asis */
A88178,
A88179,
A88772,
S95xx, /* SMSC */
Eaddrlen = 6,
Epktlen = 1514,
Ehdrsize = 2*Eaddrlen + 2,
Maxpkt = 2000, /* no jumbo packets here */
Nconns = 8, /* max number of connections */
Nbufs = 32, /* max number of buffers */
Scether = 6, /* ethernet cdc subclass */
Fnheader = 0, /* Functions */
Fnunion = 6,
Fnether = 15,
Cdcunion = 6, /* CDC Union descriptor subtype */
};
struct Buf
{
int type;
int ndata;
uint8_t* rp;
uint8_t data[Hdrsize+Maxpkt];
};
struct Conn
{
Ref; /* one per file in use */
int nb;
int type;
int headersonly;
int prom;
Channel*rc; /* [2] of Buf* */
};
struct Etherops
{
int (*init)(Ether*, int *epin, int *epout);
int32_t (*bread)(Ether*, Buf*);
int32_t (*bwrite)(Ether*, Buf*);
int (*ctl)(Ether*, char*);
int (*promiscuous)(Ether*, int);
int (*multicast)(Ether*, uint8_t*, int);
char* (*seprintstats)(char*, char*, Ether*);
void (*free)(Ether*);
int bufsize;
char *name;
void* aux;
};
struct Ether
{
QLock;
QLock wlck; /* write one at a time */
int epinid; /* epin address */
int epoutid; /* epout address */
Dev* dev;
Dev* epin;
Dev* epout;
int cid; /* ctlr id */
int phy; /* phy id */
Ref prom; /* nb. of promiscuous conns */
int exiting; /* shutting down */
int wrexited; /* write process died */
uint8_t addr[Eaddrlen]; /* mac */
int nconns; /* nb. of entries used in... */
Conn* conns[Nconns]; /* connections */
int nabufs; /* nb. of allocated buffers */
int nbufs; /* nb. of buffers in use */
int nblock; /* nonblocking (output)? */
int nin;
int nout;
int nierrs;
int noerrs;
int mbps;
int nmcasts;
Channel*rc; /* read channel (of Buf*) */
Channel*wc; /* write channel (of Buf*) */
Channel*bc; /* free buf. chan. (of Buf*) */
Etherops;
Usbfs fs;
};
struct Cinfo
{
int vid; /* usb vendor id */
int did; /* usb device/product id */
int cid; /* controller id assigned by us */
};
struct Etherpkt
{
uint8_t d[Eaddrlen];
uint8_t s[Eaddrlen];
uint8_t type[2];
uint8_t data[1500];
};
int ethermain(Dev *dev, int argc, char **argv);
int asixreset(Ether*);
int smscreset(Ether*);
int cdcreset(Ether*);
int parseaddr(uint8_t *m, char *s);
void dumpframe(char *tag, void *p, int n);
extern Cinfo cinfo[];
extern int etherdebug;
#define deprint if(etherdebug)fprint

645
sys/include/usb/ftdi.h Normal file
View File

@@ -0,0 +1,645 @@
/*
* This file is part of the UCB release of Plan 9. It is subject to the license
* terms in the LICENSE file found in the top-level directory of this
* distribution and at http://akaros.cs.berkeley.edu/files/Plan9License. No
* part of the UCB release of Plan 9, including this file, may be copied,
* modified, propagated, or distributed except according to the terms contained
* in the LICENSE file.
*/
enum {
/* used by devices which don't provide their own Vid */
FTVid = 0x0403,
FTSheevaVid = 0x9E88,
FTSheevaDid = 0x9E8F,
FTOpenRDUltDid = 0x9E90,
FTSIODid = 0x8372, /* Product Id SIO appl'n of 8U100AX */
FT8U232AMDid = 0x6001, /* Similar device to SIO above */
FT8U232AMALTDid = 0x6006, /* FT's alternate Did for above*/
FT8U2232CDid = 0x6010, /* Dual channel device */
FTRELAISDid = 0xFA10, /* Relais device */
/* NF reader */
FTNFRICVid = 0x0DCD,
FTNFRICDid = 0x0001,
FTACTZWAVEDid = 0xF2D0, /* www.irtrans.de device */
/*
* ACT Solutions HomePro ZWave interface
* http://www.act-solutions.com/HomePro.htm)
*/
FTIRTRANSDid = 0xFC60,
/*
* www.thoughttechnology.com/ TT-USB
*/
FTTTUSBDid = 0xFF20,
/* iPlus device */
FTIPLUSDid = 0xD070,
/* www.crystalfontz.com devices */
FTXF632Did = 0xFC08, /* 632: 16x2 Character Display */
FTXF634Did = 0xFC09, /* 634: 20x4 Character Display */
FTXF547Did = 0xFC0A, /* 547: Two line Display */
FTXF633Did = 0xFC0B, /* 633: 16x2 Character Display with Keys */
FTXF631Did = 0xFC0C, /* 631: 20x2 Character Display */
FTXF635Did = 0xFC0D, /* 635: 20x4 Character Display */
FTXF640Did = 0xFC0E, /* 640: Two line Display */
FTXF642Did = 0xFC0F, /* 642: Two line Display */
/*
* Video Networks Limited / Homechoice in the UK
* use an ftdi-based device for their 1Mb broadband
*/
FTVNHCPCUSBDDid = 0xfe38,
/*
* PCDJ use ftdi based dj-controllers
* DAC-2 device http://www.pcdjhardware.com/DAC2.asp
*/
FTPCDJDAC2Did = 0xFA88,
/*
* Matrix Orbital LCD displays,
* which are the FT232BM (similar to the 8U232AM)
*/
FTMTXORB0Did = 0xFA00,
FTMTXORB1Did = 0xFA01,
FTMTXORB2Did = 0xFA02,
FTMTXORB3Did = 0xFA03,
FTMTXORB4Did = 0xFA04,
FTMTXORB5Did = 0xFA05,
FTMTXORB6Did = 0xFA06,
/* Interbiometrics USB I/O Board */
INTERBIOMVid = 0x1209,
INTERBIOMIOBRDDid = 0x1002,
INTERBIOMMINIIOBRDDid = 0x1006,
/*
* The following are the values for the Perle Systems
* UltraPort USB serial converters
*/
FTPERLEULTRAPORTDid = 0xF0C0,
/*
* Sealevel SeaLINK+ adapters.
*/
SEALEVELVid = 0x0c52,
SEALEVEL2101Did = 0x2101, /* SeaLINK+232 (2101/2105) */
SEALEVEL2102Did = 0x2102, /* SeaLINK+485 (2102) */
SEALEVEL2103Did = 0x2103, /* SeaLINK+232I (2103) */
SEALEVEL2104Did = 0x2104, /* SeaLINK+485I (2104) */
SEALEVEL22011Did = 0x2211, /* SeaPORT+2/232 (2201) Port 1 */
SEALEVEL22012Did = 0x2221, /* SeaPORT+2/232 (2201) Port 2 */
SEALEVEL22021Did = 0x2212, /* SeaPORT+2/485 (2202) Port 1 */
SEALEVEL22022Did = 0x2222, /* SeaPORT+2/485 (2202) Port 2 */
SEALEVEL22031Did = 0x2213, /* SeaPORT+2 (2203) Port 1 */
SEALEVEL22032Did = 0x2223, /* SeaPORT+2 (2203) Port 2 */
SEALEVEL24011Did = 0x2411, /* SeaPORT+4/232 (2401) Port 1 */
SEALEVEL24012Did = 0x2421, /* SeaPORT+4/232 (2401) Port 2 */
SEALEVEL24013Did = 0x2431, /* SeaPORT+4/232 (2401) Port 3 */
SEALEVEL24014Did = 0x2441, /* SeaPORT+4/232 (2401) Port 4 */
SEALEVEL24021Did = 0x2412, /* SeaPORT+4/485 (2402) Port 1 */
SEALEVEL24022Did = 0x2422, /* SeaPORT+4/485 (2402) Port 2 */
SEALEVEL24023Did = 0x2432, /* SeaPORT+4/485 (2402) Port 3 */
SEALEVEL24024Did = 0x2442, /* SeaPORT+4/485 (2402) Port 4 */
SEALEVEL24031Did = 0x2413, /* SeaPORT+4 (2403) Port 1 */
SEALEVEL24032Did = 0x2423, /* SeaPORT+4 (2403) Port 2 */
SEALEVEL24033Did = 0x2433, /* SeaPORT+4 (2403) Port 3 */
SEALEVEL24034Did = 0x2443, /* SeaPORT+4 (2403) Port 4 */
SEALEVEL28011Did = 0x2811, /* SeaLINK+8/232 (2801) Port 1 */
SEALEVEL28012Did = 0x2821, /* SeaLINK+8/232 (2801) Port 2 */
SEALEVEL28013Did = 0x2831, /* SeaLINK+8/232 (2801) Port 3 */
SEALEVEL28014Did = 0x2841, /* SeaLINK+8/232 (2801) Port 4 */
SEALEVEL28015Did = 0x2851, /* SeaLINK+8/232 (2801) Port 5 */
SEALEVEL28016Did = 0x2861, /* SeaLINK+8/232 (2801) Port 6 */
SEALEVEL28017Did = 0x2871, /* SeaLINK+8/232 (2801) Port 7 */
SEALEVEL28018Did = 0x2881, /* SeaLINK+8/232 (2801) Port 8 */
SEALEVEL28021Did = 0x2812, /* SeaLINK+8/485 (2802) Port 1 */
SEALEVEL28022Did = 0x2822, /* SeaLINK+8/485 (2802) Port 2 */
SEALEVEL28023Did = 0x2832, /* SeaLINK+8/485 (2802) Port 3 */
SEALEVEL28024Did = 0x2842, /* SeaLINK+8/485 (2802) Port 4 */
SEALEVEL28025Did = 0x2852, /* SeaLINK+8/485 (2802) Port 5 */
SEALEVEL28026Did = 0x2862, /* SeaLINK+8/485 (2802) Port 6 */
SEALEVEL28027Did = 0x2872, /* SeaLINK+8/485 (2802) Port 7 */
SEALEVEL28028Did = 0x2882, /* SeaLINK+8/485 (2802) Port 8 */
SEALEVEL28031Did = 0x2813, /* SeaLINK+8 (2803) Port 1 */
SEALEVEL28032Did = 0x2823, /* SeaLINK+8 (2803) Port 2 */
SEALEVEL28033Did = 0x2833, /* SeaLINK+8 (2803) Port 3 */
SEALEVEL28034Did = 0x2843, /* SeaLINK+8 (2803) Port 4 */
SEALEVEL28035Did = 0x2853, /* SeaLINK+8 (2803) Port 5 */
SEALEVEL28036Did = 0x2863, /* SeaLINK+8 (2803) Port 6 */
SEALEVEL28037Did = 0x2873, /* SeaLINK+8 (2803) Port 7 */
SEALEVEL28038Did = 0x2883, /* SeaLINK+8 (2803) Port 8 */
/* KOBIL Vendor ID chipcard terminals */
KOBILVid = 0x0d46,
KOBILCONVB1Did = 0x2020, /* KOBIL Konverter for B1 */
KOBILCONVKAANDid = 0x2021, /* KOBILKonverter for KAAN */
/* Icom ID-1 digital transceiver */
ICOMID1Vid = 0x0C26,
ICOMID1Did = 0x0004,
FTASKRDR400Did = 0xC991, /* ASK RDR 400 series card reader */
FTDSS20Did = 0xFC82, /* DSS-20 Sync Station for Sony Ericsson P800 */
/*
* Home Electronics (www.home-electro.com) USB gadgets
*/
FTHETIRA1Did = 0xFA78, /* Tira-1 IR transceiver */
/*
* An infrared receiver and transmitter using the 8U232AM chip
* http://www.usbuirt.com
*/
FTUSBUIRTDid = 0xF850,
FTELVUR100Did = 0xFB58, /* USB-RS232-Umsetzer (UR 100) */
FTELVUM100Did = 0xFB5A, /* USB-Modul UM 100 */
FTELVUO100Did = 0xFB5B, /* USB-Modul UO 100 */
FTELVALC8500Did = 0xF06E, /* ALC 8500 Expert */
FTELVCLI7000Did = 0xFB59, /* Computer-Light-Interface */
FTELVPPS7330Did = 0xFB5C, /* Processor-Power-Supply (PPS 7330) */
FTELVTFM100Did = 0xFB5D, /* Temperartur-Feuchte Messgeraet (TFM 100) */
FTELVUDF77Did = 0xFB5E, /* USB DCF Funkurh (UDF 77) */
FTELVUIO88Did = 0xFB5F, /* USB-I/O Interface (UIO 88) */
FTELVUAD8Did = 0xF068, /* USB-AD-Wandler (UAD 8) */
FTELVUDA7Did = 0xF069, /* USB-DA-Wandler (UDA 7) */
FTELVUSI2Did = 0xF06A, /* USB-Schrittmotoren-Interface (USI 2) */
FTELVT1100Did = 0xF06B, /* Thermometer (T 1100) */
FTELVPCD200Did = 0xF06C, /* PC-Datenlogger (PCD 200) */
FTELVULA200Did = 0xF06D, /* USB-LCD-Ansteuerung (ULA 200) */
FTELVFHZ1000PCDid= 0xF06F, /* FHZ 1000 PC */
FTELVCSI8Did = 0xE0F0, /* Computer-Schalt-Interface (CSI 8) */
FTELVEM1000DLDid= 0xE0F1, /* PC-Datenlogger fuer Energiemonitor (EM 1000 DL) */
FTELVPCK100Did = 0xE0F2, /* PC-Kabeltester (PCK 100) */
FTELVRFP500Did = 0xE0F3, /* HF-Leistungsmesser (RFP 500) */
FTELVFS20SIGDid = 0xE0F4, /* Signalgeber (FS 20 SIG) */
FTELVWS300PCDid = 0xE0F6, /* PC-Wetterstation (WS 300 PC) */
FTELVFHZ1300PCDid= 0xE0E8, /* FHZ 1300 PC */
FTELVWS500Did = 0xE0E9, /* PC-Wetterstation (WS 500) */
/*
* Definitions for ID TECH (http://www.idt-net.com) devices
*/
IDTECHVid = 0x0ACD, /* ID TECH Vendor ID */
IDTECHIDT1221UDid= 0x0300, /* IDT1221U USB to RS-232 */
/*
* Definitions for Omnidirectional Control Technology, Inc. devices
*/
OCTVid = 0x0B39, /* OCT vendor ID */
/*
* Note: OCT US101 is also rebadged as Dick Smith Electronics
* (NZ) XH6381, Dick Smith Electronics (Aus) XH6451, and SIIG
* Inc. model US2308 hardware version 1.
*/
OCTUS101Did = 0x0421, /* OCT US101 USB to RS-232 */
/*
* infrared receiver for access control with IR tags
*/
FTPIEGROUPDid = 0xF208,
/*
* Definitions for Artemis astronomical USB based cameras
* http://www.artemisccd.co.uk/
*/
FTARTEMISDid = 0xDF28, /* All Artemis Cameras */
FTATIKATK16Did = 0xDF30, /* ATIK ATK-16 Grayscale Camera */
FTATIKATK16CDid = 0xDF32, /* ATIK ATK-16C Colour Camera */
FTATIKATK16HRDid= 0xDF31, /* ATIK ATK-16HR Grayscale */
FTATIKATK16HRCDid= 0xDF33, /* ATIK ATK-16HRC Colour Camera */
/*
* Protego products
*/
PROTEGOSPECIAL1 = 0xFC70, /* special/unknown device */
PROTEGOR2X0 = 0xFC71, /* R200-USB TRNG unit (R210, R220, and R230) */
PROTEGOSPECIAL3 = 0xFC72, /* special/unknown device */
PROTEGOSPECIAL4 = 0xFC73, /* special/unknown device */
/*
* Gude Analog- und Digitalsysteme GmbH
*/
FTGUDEADSE808Did = 0xE808,
FTGUDEADSE809Did = 0xE809,
FTGUDEADSE80ADid = 0xE80A,
FTGUDEADSE80BDid = 0xE80B,
FTGUDEADSE80CDid = 0xE80C,
FTGUDEADSE80DDid = 0xE80D,
FTGUDEADSE80EDid = 0xE80E,
FTGUDEADSE80FDid = 0xE80F,
FTGUDEADSE888Did = 0xE888, /* Expert ISDN Control USB */
FTGUDEADSE889Did = 0xE889, /* USB RS-232 OptoBridge */
FTGUDEADSE88ADid = 0xE88A,
FTGUDEADSE88BDid = 0xE88B,
FTGUDEADSE88CDid = 0xE88C,
FTGUDEADSE88DDid = 0xE88D,
FTGUDEADSE88EDid = 0xE88E,
FTGUDEADSE88FDid = 0xE88F,
/*
* Linx Technologies
*/
LINXSDMUSBQSSDid= 0xF448, /* Linx SDM-USB-QS-S */
LINXMASTERDEVEL2Did= 0xF449, /* Linx Master Development.0 */
LINXFUTURE0Did = 0xF44A, /* Linx future device */
LINXFUTURE1Did = 0xF44B, /* Linx future device */
LINXFUTURE2Did = 0xF44C, /* Linx future device */
/*
* CCS Inc. ICDU/ICDU40 - the FT232BM used in a in-circuit-debugger
* unit for PIC16's/PIC18's
*/
FTCCSICDU200Did = 0xF9D0,
FTCCSICDU401Did = 0xF9D1,
/* Inside Accesso contactless reader (http://www.insidefr.com) */
INSIDEACCESSO = 0xFAD0,
/*
* Intrepid Control Systems (http://www.intrepidcs.com/)
* ValueCAN and NeoVI
*/
INTREDidVid = 0x093C,
INTREDidVALUECANDid= 0x0601,
INTREDidNEOVIDid= 0x0701,
/*
* Falcom Wireless Communications GmbH
*/
FALCOMVid = 0x0F94,
FALCOMTWISTDid = 0x0001, /* Falcom Twist USB GPRS modem */
FALCOMSAMBADid = 0x0005, /* Falcom Samba USB GPRS modem */
/*
* SUUNTO
*/
FTSUUNTOSPORTSDid= 0xF680, /* Suunto Sports instrument */
/*
* B&B Electronics
*/
BANDBVid = 0x0856, /* B&B Electronics Vendor ID */
BANDBUSOTL4Did = 0xAC01, /* USOTL4 Isolated RS-485 */
BANDBUSTL4Did = 0xAC02, /* USTL4 RS-485 Converter */
BANDBUSO9ML2Did = 0xAC03, /* USO9ML2 Isolated RS-232 */
/*
* RM Michaelides CANview USB (http://www.rmcan.com)
* CAN fieldbus interface adapter
*/
FTRMCANVIEWDid = 0xfd60,
/*
* EVER Eco Pro UPS (http://www.ever.com.pl/)
*/
EVERECOPROCDSDid = 0xe520, /* RS-232 converter */
/*
* 4N-GALAXY.DE PIDs for CAN-USB, USB-RS232, USB-RS422, USB-RS485,
* USB-TTY activ, USB-TTY passiv. Some PIDs are used by several devices
*/
FT4NGALAXYDE0Did = 0x8372,
FT4NGALAXYDE1Did = 0xF3C0,
FT4NGALAXYDE2Did = 0xF3C1,
/*
* Mobility Electronics products.
*/
MOBILITYVid = 0x1342,
MOBILITYUSBSERIALDid= 0x0202, /* EasiDock USB 200 serial */
/*
* microHAM product IDs (http://www.microham.com)
*/
FTMHAMKWDid = 0xEEE8, /* USB-KW interface */
FTMHAMYSDid = 0xEEE9, /* USB-YS interface */
FTMHAMY6Did = 0xEEEA, /* USB-Y6 interface */
FTMHAMY8Did = 0xEEEB, /* USB-Y8 interface */
FTMHAMICDid = 0xEEEC, /* USB-IC interface */
FTMHAMDB9Did = 0xEEED, /* USB-DB9 interface */
FTMHAMRS232Did = 0xEEEE, /* USB-RS232 interface */
FTMHAMY9Did = 0xEEEF, /* USB-Y9 interface */
/*
* Active Robots product ids.
*/
FTACTIVEROBOTSDid = 0xE548, /* USB comms board */
XSENSCONVERTER0Did = 0xD388,
XSENSCONVERTER1Did = 0xD389,
XSENSCONVERTER2Did = 0xD38A,
XSENSCONVERTER3Did = 0xD38B,
XSENSCONVERTER4Did = 0xD38C,
XSENSCONVERTER5Did = 0xD38D,
XSENSCONVERTER6Did = 0xD38E,
XSENSCONVERTER7Did = 0xD38F,
/*
* Xsens Technologies BV products (http://www.xsens.com).
*/
FTTERATRONIKVCPDid = 0xEC88, /* Teratronik device */
FTTERATRONIKD2XXDid = 0xEC89, /* Teratronik device */
/*
* Evolution Robotics products (http://www.evolution.com/).
*/
EVOLUTIONVid = 0xDEEE,
EVOLUTIONER1Did = 0x0300, /* ER1 Control Module */
/* Pyramid Computer GmbH */
FTPYRAMIDDid = 0xE6C8, /* Pyramid Appliance Display */
/*
* Posiflex inc retail equipment (http://www.posiflex.com.tw)
*/
POSIFLEXVid = 0x0d3a,
POSIFLEXPP7000Did= 0x0300, /* PP-7000II thermal printer */
/*
* Westrex International devices
*/
FTWESTREXMODEL777Did = 0xDC00, /* Model 777 */
FTWESTREXMODEL8900FDid = 0xDC01, /* Model 8900F */
/*
* RR-CirKits LocoBuffer USB (http://www.rr-cirkits.com)
*/
FTRRCIRKITSLOCOBUFFERDid= 0xc7d0, /* LocoBuffer USB */
FTECLOCOM1WIREDid = 0xEA90, /* COM to 1-Wire USB */
/*
* Papouch products (http://www.papouch.com/)
*/
PAPOUCHVid = 0x5050,
PAPOUCHTMUDid = 0x0400, /* TMU USB Thermometer */
/*
* ACG Identification Technologies GmbH products http://www.acg.de/
*/
FTACGHFDUALDid = 0xDD20, /* HF Dual ISO Reader (RFID) */
/*
* new high speed devices
*/
FT4232HDid = 0x6011, /* FTDI FT4232H based device */
/*
* Amontec JTAGkey (http://www.amontec.com/)
*/
AMONKEYDid = 0xCFF8,
};
/* Commands */
enum {
FTRESET = 0, /* Reset the port */
FTSETMODEMCTRL, /* Set the modem control register */
FTSETFLOWCTRL, /* Set flow control register */
FTSETBAUDRATE, /* Set baud rate */
FTSETDATA, /* Set the parameters, parity */
FTGETMODEMSTATUS, /* Retrieve current value of modem ctl */
FTSETEVENTCHAR, /* Set the event character */
FTSETERRORCHAR, /* Set the error character */
FTUNKNOWN,
FTSETLATENCYTIMER, /* Set the latency timer */
FTGETLATENCYTIMER, /* Get the latency timer */
FTSETBITMODE, /* Set bit mode */
FTGETPINS, /* Read pins state */
FTGETE2READ = 0x90, /* Read address from 128-byte I2C EEPROM */
FTSETE2WRITE, /* Write to address on 128-byte I2C EEPROM */
FTSETE2ERASE, /* Erase address on 128-byte I2C EEPROM */
};
/* Port Identifier Table, index for interfaces */
enum {
PITDEFAULT = 0, /* SIOA */
PITA, /* SIOA jtag if there is one */
};
enum {
Rftdireq = 1<<6, /* bit for type of request */
};
/*
* Commands Data size
* Sets have wLength = 0
* Gets have wValue = 0
*/
enum {
FTMODEMSTATUSSZ = 1,
FTLATENCYTIMERSZ= 1,
FTPINSSZ = 1,
FTE2READSZ = 2,
};
/*
* bRequest: FTGETE2READ
* wIndex: Address of word to read
* Data: Will return a word (2 bytes) of data from E2Address
* Results put in the I2C 128 byte EEPROM string eeprom+(2*index)
*/
/*
* bRequest: FTSETE2WRITE
* wIndex: Address of word to read
* wValue: Value of the word
* Data: Will return a word (2 bytes) of data from E2Address
*/
/*
* bRequest: FTSETE2ERASE
* Erases the EEPROM
* wIndex: 0
*/
/*
* bRequest: FTRESET
* wValue: Ctl Val
* wIndex: Port
*/
enum {
FTRESETCTLVAL = 0,
FTRESETCTLVALPURGERX = 1,
FTRESETCTLVALPURGETX = 2,
};
/*
* BmRequestType: SET
* bRequest: FTSETBAUDRATE
* wValue: BaudDivisor value - see below
* Bits 15 to 0 of the 17-bit divisor are placed in the request value.
* Bit 16 is placed in bit 0 of the request index.
*/
/* chip type */
enum {
SIO = 1,
FT8U232AM = 2,
FT232BM = 3,
FT2232C = 4,
FTKINDR = 5,
FT2232H = 6,
FT4232H = 7,
};
enum {
FTb300 = 0,
FTb600 = 1,
FTb1200 = 2,
FTb2400 = 3,
FTb4800 = 4,
FTb9600 = 5,
FTb19200 = 6,
FTb38400 = 7,
FTb57600 = 8,
FTb115200 = 9,
};
/*
* bRequest: FTSETDATA
* wValue: Data characteristics
* bits 0-7 number of data bits
* wIndex: Port
*/
enum {
FTSETDATAParNONE = 0 << 8,
FTSETDATAParODD = 1 << 8,
FTSETDATAParEVEN = 2 << 8,
FTSETDATAParMARK = 3 << 8,
FTSETDATAParSPACE = 4 << 8,
FTSETDATASTOPBITS1 = 0 << 11,
FTSETDATASTOPBITS15 = 1 << 11,
FTSETDATASTOPBITS2 = 2 << 11,
FTSETBREAK = 1 << 14,
};
/*
* bRequest: FTSETMODEMCTRL
* wValue: ControlValue (see below)
* wIndex: Port
*/
/*
* bRequest: FTSETFLOWCTRL
* wValue: Xoff/Xon
* wIndex: Protocol/Port - hIndex is protocol; lIndex is port
*/
enum {
FTDISABLEFLOWCTRL= 0,
FTRTSCTSHS = 1 << 8,
FTDTRDSRHS = 2 << 8,
FTXONXOFFHS = 4 << 8,
};
/*
* bRequest: FTGETLATENCYTIMER
* wIndex: Port
* wLength: 0
* Data: latency (on return)
*/
/*
* bRequest: FTSETBITMODE
* wIndex: Port
* either it is big bang mode, in which case
* wValue: 1 byte L is the big bang mode BIG*
* or BM is
* wValue: 1 byte bitbang mode H, 1 byte bitmask for lines L
*/
enum {
BMSERIAL = 0, /* reset, turn off bit-bang mode */
BIGBMNORMAL = 1, /* normal bit-bang mode */
BIGBMSPI = 2, /* spi bit-bang mode */
BMABM = 1<<8, /* async mode */
BMMPSSE = 2<<8,
BMSYNCBB = 4<<8, /* sync bit-bang -- 2232x and R-type */
BMMCU = 8<<8, /* MCU Host Bus -- 2232x */
BMOPTO = 0x10<<8, /* opto-isolated<<8, 2232x */
BMCBUS = 0x20<<8, /* CBUS pins of R-type chips */
BMSYNCFF = 0x40<<8, /* Single Channel Sync FIFO, 2232H only */
};
/*
* bRequest: FTSETLATENCYTIMER
* wValue: Latency (milliseconds 1-255)
* wIndex: Port
*/
enum {
FTLATENCYDEFAULT = 2,
};
/*
* BmRequestType: SET
* bRequest: FTSETEVENTCHAR
* wValue: EventChar
* wIndex: Port
* 0-7 lower bits event char
* 8 enable
*/
enum {
FTEVCHARENAB = 1<<8,
};
/*
* BmRequestType: SET
* bRequest: FTSETERRORCHAR
* wValue: Error Char
* wIndex: Port
* 0-7 lower bits event char
* 8 enable
*/
enum {
FTERRCHARENAB = 1<<8,
};
/*
* BmRequestType: GET
* bRequest: FTGETMODEMSTATUS
* wIndex: Port
* wLength: 1
* Data: Status
*/
enum {
FTCTSMASK = 0x10,
FTDSRMASK = 0x20,
FTRIMASK = 0x40,
FTRLSDMASK = 0x80,
};
enum {
/* byte 0 of in data hdr */
FTICTS = 1 << 4,
FTIDSR = 1 << 5,
FTIRI = 1 << 6,
FTIRLSD = 1 << 7, /* receive line signal detect */
/* byte 1 of in data hdr */
FTIDR = 1<<0, /* data ready */
FTIOE = 1<<1, /* overrun error */
FTIPE = 1<<2, /* parity error */
FTIFE = 1<<3, /* framing error */
FTIBI = 1<<4, /* break interrupt */
FTITHRE = 1<<5, /* xmitter holding register */
FTITEMT = 1<<6, /* xmitter empty */
FTIFIFO = 1<<7, /* error in rcv fifo */
/* byte 0 of out data hdr len does not include byte 0 */
FTOLENMSK= 0x3F,
FTOPORT = 0x80, /* must be set */
};
extern Serialops ftops;
int ftmatch(Serial *ser, char *info);

141
sys/include/usb/hid.h Normal file
View File

@@ -0,0 +1,141 @@
/*
* This file is part of the UCB release of Plan 9. It is subject to the license
* terms in the LICENSE file found in the top-level directory of this
* distribution and at http://akaros.cs.berkeley.edu/files/Plan9License. No
* part of the UCB release of Plan 9, including this file, may be copied,
* modified, propagated, or distributed except according to the terms contained
* in the LICENSE file.
*/
/*
* USB keyboard/mouse constants
*/
typedef struct Chain Chain;
typedef struct HidInterface HidInterface;
typedef struct HidRepTempl HidRepTempl;
enum {
Stack = 32 * 1024,
/* HID class subclass protocol ids */
PtrCSP = 0x020103, /* mouse.boot.hid */
KbdCSP = 0x010103, /* keyboard.boot.hid */
/* Requests */
Getproto = 0x03,
Setidle = 0x0a,
Setproto = 0x0b,
/* protocols for SET_PROTO request */
Bootproto = 0,
Reportproto = 1,
};
enum {
/* keyboard modifier bits */
Mlctrl = 0,
Mlshift = 1,
Mlalt = 2,
Mlgui = 3,
Mrctrl = 4,
Mrshift = 5,
Mralt = 6,
Mrgui = 7,
/* masks for byte[0] */
Mctrl = 1<<Mlctrl | 1<<Mrctrl,
Mshift = 1<<Mlshift | 1<<Mrshift,
Malt = 1<<Mlalt | 1<<Mralt,
Mcompose = 1<<Mlalt,
Maltgr = 1<<Mralt,
Mgui = 1<<Mlgui | 1<<Mrgui,
MaxAcc = 3, /* max. ptr acceleration */
PtrMask= 0xf, /* 4 buttons: should allow for more. */
};
/*
* Plan 9 keyboard driver constants.
*/
enum {
/* Scan codes (see kbd.c) */
SCesc1 = 0xe0, /* first of a 2-character sequence */
SCesc2 = 0xe1,
SClshift = 0x2a,
SCrshift = 0x36,
SCctrl = 0x1d,
SCcompose = 0x38,
Keyup = 0x80, /* flag bit */
Keymask = 0x7f, /* regular scan code bits */
};
int kbmain(Dev *d, int argc, char*argv[]);
enum{
MaxChLen = 64, /* bytes */
};
struct Chain {
int b; /* offset start in bits, (first full) */
int e; /* offset end in bits (first empty) */
uint8_t buf[MaxChLen];
};
#define MSK(nbits) ((1UL << (nbits)) - 1)
#define IsCut(bbits, ebits) (((ebits)/8 - (bbits)/8) > 0)
enum {
KindPad = 0,
KindButtons,
KindX,
KindY,
KindWheel,
MaxVals = 16,
MaxIfc = 8,
};
struct HidInterface {
uint32_t v[MaxVals]; /* one ulong per val should be enough */
uint8_t kind[MaxVals];
int nbits;
int count;
};
struct HidRepTempl{
int id; /* id which may not be present */
uint32_t sz; /* in bytes */
int nifcs;
HidInterface ifcs[MaxIfc];
};
enum {
/* report types */
HidReportApp = 0x01,
HidTypeUsgPg = 0x05,
HidPgButts = 0x09,
HidTypeRepSz = 0x75,
HidTypeCnt = 0x95,
HidCollection = 0xa1,
HidTypeUsg = 0x09,
HidPtr = 0x01,
HidX = 0x30,
HidY = 0x31,
HidZ = 0x32,
HidWheel = 0x38,
HidInput = 0x81,
HidReportId = 0x85,
HidReportIdPtr = 0x01,
HidEnd = 0xc0,
};
void dumpreport(HidRepTempl *templ);
int hidifcval(HidRepTempl *templ, int kind, int n);
int parsereport(HidRepTempl *templ, Chain *rep);
int parsereportdesc(HidRepTempl *temp, uint8_t *repdesc, int repsz);

187
sys/include/usb/prolific.h Normal file
View File

@@ -0,0 +1,187 @@
/*
* This file is part of the UCB release of Plan 9. It is subject to the license
* terms in the LICENSE file found in the top-level directory of this
* distribution and at http://akaros.cs.berkeley.edu/files/Plan9License. No
* part of the UCB release of Plan 9, including this file, may be copied,
* modified, propagated, or distributed except according to the terms contained
* in the LICENSE file.
*/
enum {
/* flavours of the device */
TypeH,
TypeHX,
TypeUnk,
RevH = 0x0202,
RevX = 0x0300,
RevHX = 0x0400,
Rev1 = 0x0001,
/* usbcmd parameters */
SetLineReq = 0x20,
SetCtlReq = 0x22,
BreakReq = 0x23,
BreakOn = 0xffff,
BreakOff = 0x0000,
GetLineReq = 0x21,
VendorWriteReq = 0x01, /* BUG: is this a standard request? */
VendorReadReq = 0x01,
ParamReqSz = 7,
VendorReqSz = 10,
/* status read from interrupt endpoint */
DcdStatus = 0x01,
DsrStatus = 0x02,
BreakerrStatus = 0x04,
RingStatus = 0x08,
FrerrStatus = 0x10,
ParerrStatus = 0x20,
OvererrStatus = 0x40,
CtsStatus = 0x80,
DcrGet = 0x80,
DcrSet = 0x00,
Dcr0Idx = 0x00,
Dcr0Init = 0x0001,
Dcr0HwFcH = 0x0040,
Dcr0HwFcX = 0x0060,
Dcr1Idx = 0x01,
Dcr1Init = 0x0000,
Dcr1InitH = 0x0080,
Dcr1InitX = 0x0000,
Dcr2Idx = 0x02,
Dcr2InitH = 0x0024,
Dcr2InitX = 0x0044,
PipeDSRst = 0x08,
PipeUSRst = 0x09,
};
enum {
PL2303Vid = 0x067b,
PL2303Did = 0x2303,
PL2303DidRSAQ2 = 0x04bb,
PL2303DidDCU11 = 0x1234,
PL2303DidPHAROS = 0xaaa0,
PL2303DidRSAQ3 = 0xaaa2,
PL2303DidALDIGA = 0x0611,
PL2303DidMMX = 0x0612,
PL2303DidGPRS = 0x0609,
ATENVid = 0x0557,
ATENVid2 = 0x0547,
ATENDid = 0x2008,
IODATAVid = 0x04bb,
IODATADid = 0x0a03,
IODATADidRSAQ5 = 0x0a0e,
ELCOMVid = 0x056e,
ELCOMDid = 0x5003,
ELCOMDidUCSGT = 0x5004,
ITEGNOVid = 0x0eba,
ITEGNODid = 0x1080,
ITEGNODid2080 = 0x2080,
MA620Vid = 0x0df7,
MA620Did = 0x0620,
RATOCVid = 0x0584,
RATOCDid = 0xb000,
TRIPPVid = 0x2478,
TRIPPDid = 0x2008,
RADIOSHACKVid = 0x1453,
RADIOSHACKDid = 0x4026,
DCU10Vid = 0x0731,
DCU10Did = 0x0528,
SITECOMVid = 0x6189,
SITECOMDid = 0x2068,
/* Alcatel OT535/735 USB cable */
ALCATELVid = 0x11f7,
ALCATELDid = 0x02df,
/* Samsung I330 phone cradle */
SAMSUNGVid = 0x04e8,
SAMSUNGDid = 0x8001,
SIEMENSVid = 0x11f5,
SIEMENSDidSX1 = 0x0001,
SIEMENSDidX65 = 0x0003,
SIEMENSDidX75 = 0x0004,
SIEMENSDidEF81 = 0x0005,
SYNTECHVid = 0x0745,
SYNTECHDid = 0x0001,
/* Nokia CA-42 Cable */
NOKIACA42Vid = 0x078b,
NOKIACA42Did = 0x1234,
/* CA-42 CLONE Cable www.ca-42.com chipset: Prolific Technology Inc */
CA42CA42Vid = 0x10b5,
CA42CA42Did = 0xac70,
SAGEMVid = 0x079b,
SAGEMDid = 0x0027,
/* Leadtek GPS 9531 (ID 0413:2101) */
LEADTEKVid = 0x0413,
LEADTEK9531Did = 0x2101,
/* USB GSM cable from Speed Dragon Multimedia, Ltd */
SPEEDDRAGONVid = 0x0e55,
SPEEDDRAGONDid = 0x110b,
/* DATAPILOT Universal-2 Phone Cable */
BELKINVid = 0x050d,
BELKINDid = 0x0257,
/* Belkin "F5U257" Serial Adapter */
DATAPILOTU2Vid = 0x0731,
DATAPILOTU2Did = 0x2003,
ALCORVid = 0x058F,
ALCORDid = 0x9720,
/* Willcom WS002IN Data Driver (by NetIndex Inc.) */
WS002INVid = 0x11f6,
WS002INDid = 0x2001,
/* Corega CG-USBRS232R Serial Adapter */
COREGAVid = 0x07aa,
COREGADid = 0x002a,
/* Y.C. Cable U.S.A., Inc - USB to RS-232 */
YCCABLEVid = 0x05ad,
YCCABLEDid = 0x0fba,
/* "Superial" USB - Serial */
SUPERIALVid = 0x5372,
SUPERIALDid = 0x2303,
/* Hewlett-Packard LD220-HP POS Pole Display */
HPVid = 0x03f0,
HPLD220Did = 0x3524,
};
extern Serialops plops;
int plmatch(char *info);

184
sys/include/usb/scsireq.h Normal file
View File

@@ -0,0 +1,184 @@
/*
* This file is part of the UCB release of Plan 9. It is subject to the license
* terms in the LICENSE file found in the top-level directory of this
* distribution and at http://akaros.cs.berkeley.edu/files/Plan9License. No
* part of the UCB release of Plan 9, including this file, may be copied,
* modified, propagated, or distributed except according to the terms contained
* in the LICENSE file.
*/
/*
* This is /sys/src/cmd/scuzz/scsireq.h
* changed to add more debug support, and to keep
* disk compiling without a scuzz that includes these changes.
*
* scsireq.h is also included by usb/disk and cdfs.
*/
typedef struct Umsc Umsc;
enum { /* fundamental constants/defaults */
MaxDirData = 255, /* max. direct data returned */
/*
* Because we are accessed via devmnt, we can never get i/o counts
* larger than 8216 (Msgsize and devmnt's offered iounit) - 24
* (IOHDRSZ) = 8K.
*/
Maxiosize = 8216 - IOHDRSZ, /* max. I/O transfer size */
};
typedef struct {
uint8_t *p;
int32_t count;
uint8_t write;
} ScsiPtr;
typedef struct {
int flags;
char *unit; /* unit directory */
int lun;
uint32_t lbsize;
uint64_t offset; /* in blocks of lbsize bytes */
int fd;
Umsc *umsc; /* lun */
ScsiPtr cmd;
ScsiPtr data;
int status; /* returned status */
uint8_t sense[MaxDirData]; /* returned sense data */
uint8_t inquiry[MaxDirData]; /* returned inquiry data */
int readblock; /* flag: read a block since open */
} ScsiReq;
enum { /* software flags */
Fopen = 0x0001, /* open */
Fseqdev = 0x0002, /* sequential-access device */
Fwritten = 0x0004, /* device written */
Fronly = 0x0008, /* device is read-only */
Fwormdev = 0x0010, /* write-once read-multiple device */
Fprintdev = 0x0020, /* printer */
Fbfixed = 0x0040, /* fixed block size */
Fchanger = 0x0080, /* medium-changer device */
Finqok = 0x0100, /* inquiry data is OK */
Fmode6 = 0x0200, /* use 6-byte modeselect */
Frw10 = 0x0400, /* use 10-byte read/write */
Fusb = 0x0800, /* USB transparent scsi */
};
enum {
STnomem =-4, /* buffer allocation failed */
STharderr =-3, /* controller error of some kind */
STtimeout =-2, /* bus timeout */
STok = 0, /* good */
STcheck = 0x02, /* check condition */
STcondmet = 0x04, /* condition met/good */
STbusy = 0x08, /* busy */
STintok = 0x10, /* intermediate/good */
STintcondmet = 0x14, /* intermediate/condition met/good */
STresconf = 0x18, /* reservation conflict */
STterminated = 0x22, /* command terminated */
STqfull = 0x28, /* queue full */
};
enum { /* status */
Status_SD = 0x80, /* sense-data available */
Status_SW = 0x83, /* internal software error */
Status_BADARG = 0x84, /* bad argument to request */
Status_RO = 0x85, /* device is read-only */
};
enum {
/* sense data byte 0 */
Sd0valid = 0x80, /* valid sense data present */
/* sense data byte 2 */
/* incorrect-length indicator, difference in bytes 3—6 */
Sd2ili = 0x20,
Sd2eom = 0x40, /* end of medium (tape) */
Sd2filemark = 0x80, /* at a filemark (tape) */
/* command byte 1 */
Cmd1fixed = 1, /* use fixed-length blocks */
Cmd1sili = 2, /* don't set Sd2ili */
/* limit of block #s in 24-bit ccbs */
Max24off = (1<<21) - 1, /* 2⁲ⁱ - 1 */
/* mode pages */
Allmodepages = 0x3F,
};
/* scsi device types, from the scsi standards */
enum {
Devdir, /* usually disk */
Devseq, /* usually tape */
Devprint,
Dev3,
Devworm, /* also direct, but special */
Devcd, /* also direct */
Dev6,
Devmo, /* also direct */
Devjuke,
};
/* p arguments should be of type uint8_t* */
#define GETBELONG(p) ((uint32_t)(p)[0]<<24 | (uint32_t)(p)[1]<<16 | (p)[2]<<8 | (p)[3])
#define PUTBELONG(p, ul) ((p)[0] = (ul)>>24, (p)[1] = (ul)>>16, \
(p)[2] = (ul)>>8, (p)[3] = (ul))
#define GETBE24(p) ((uint32_t)(p)[0]<<16 | (p)[1]<<8 | (p)[2])
#define PUTBE24(p, ul) ((p)[0] = (ul)>>16, (p)[1] = (ul)>>8, (p)[2] = (ul))
int32_t SRready(ScsiReq*);
int32_t SRrewind(ScsiReq*);
int32_t SRreqsense(ScsiReq*);
int32_t SRformat(ScsiReq*);
int32_t SRrblimits(ScsiReq*, uint8_t*);
int32_t SRread(ScsiReq*, void*, int32_t);
int32_t SRwrite(ScsiReq*, void*, int32_t);
int32_t SRseek(ScsiReq*, int32_t, int);
int32_t SRfilemark(ScsiReq*, uint32_t);
int32_t SRspace(ScsiReq*, uint8_t, int32_t);
int32_t SRinquiry(ScsiReq*);
int32_t SRmodeselect6(ScsiReq*, uint8_t*, int32_t);
int32_t SRmodeselect10(ScsiReq*, uint8_t*, int32_t);
int32_t SRmodesense6(ScsiReq*, uint8_t, uint8_t*, int32_t);
int32_t SRmodesense10(ScsiReq*, uint8_t, uint8_t*, int32_t);
int32_t SRstart(ScsiReq*, uint8_t);
int32_t SRrcapacity(ScsiReq*, uint8_t*);
int32_t SRrcapacity16(ScsiReq*, uint8_t*);
int32_t SRblank(ScsiReq*, uint8_t, uint8_t); /* MMC CD-R/CD-RW commands */
int32_t SRsynccache(ScsiReq*);
int32_t SRTOC(ScsiReq*, void*, int, uint8_t, uint8_t);
int32_t SRrdiscinfo(ScsiReq*, void*, int);
int32_t SRrtrackinfo(ScsiReq*, void*, int, int);
int32_t SRcdpause(ScsiReq*, int); /* MMC CD audio commands */
int32_t SRcdstop(ScsiReq*);
int32_t SRcdload(ScsiReq*, int, int);
int32_t SRcdplay(ScsiReq*, int, int32_t, int32_t);
int32_t SRcdstatus(ScsiReq*, uint8_t*, int);
int32_t SRgetconf(ScsiReq*, uint8_t*, int);
/* old CD-R/CD-RW commands */
int32_t SRfwaddr(ScsiReq*, uint8_t, uint8_t, uint8_t, uint8_t*);
int32_t SRtreserve(ScsiReq*, int32_t);
int32_t SRtinfo(ScsiReq*, uint8_t, uint8_t*);
int32_t SRwtrack(ScsiReq*, void*, int32_t, uint8_t, uint8_t);
int32_t SRmload(ScsiReq*, uint8_t);
int32_t SRfixation(ScsiReq*, uint8_t);
int32_t SReinitialise(ScsiReq*); /* CHANGER commands */
int32_t SRestatus(ScsiReq*, uint8_t, uint8_t*, int);
int32_t SRmmove(ScsiReq*, int, int, int, int);
int32_t SRrequest(ScsiReq*);
int SRclose(ScsiReq*);
int SRopenraw(ScsiReq*, char*);
int SRopen(ScsiReq*, char*);
void makesense(ScsiReq*);
int32_t umsrequest(struct Umsc*, ScsiPtr*, ScsiPtr*, int*);
void scsidebug(int);
char* scsierrmsg(int n);

135
sys/include/usb/serial.h Normal file
View File

@@ -0,0 +1,135 @@
/*
* This file is part of the UCB release of Plan 9. It is subject to the license
* terms in the LICENSE file found in the top-level directory of this
* distribution and at http://akaros.cs.berkeley.edu/files/Plan9License. No
* part of the UCB release of Plan 9, including this file, may be copied,
* modified, propagated, or distributed except according to the terms contained
* in the LICENSE file.
*/
typedef struct Serial Serial;
typedef struct Serialops Serialops;
typedef struct Serialport Serialport;
struct Serialops {
int (*seteps)(Serialport*);
int (*init)(Serialport*);
int (*getparam)(Serialport*);
int (*setparam)(Serialport*);
int (*clearpipes)(Serialport*);
int (*reset)(Serial*, Serialport*);
int (*sendlines)(Serialport*);
int (*modemctl)(Serialport*, int);
int (*setbreak)(Serialport*, int);
int (*readstatus)(Serialport*);
int (*wait4data)(Serialport*, uint8_t *, int);
int (*wait4write)(Serialport*, uint8_t *, int);
};
enum {
DataBufSz = 8*1024,
Maxifc = 16,
};
struct Serialport {
char name[32];
Serial *s; /* device we belong to */
int isjtag;
Dev *epintr; /* may not exist */
Dev *epin;
Dev *epout;
Usbfs fs;
uint8_t ctlstate;
/* serial parameters */
uint32_t baud;
int stop;
int mctl;
int parity;
int bits;
int fifo;
int limit;
int rts;
int cts;
int dsr;
int dcd;
int dtr;
int rlsd;
int64_t timer;
int blocked; /* for sw flow ctl. BUG: not implemented yet */
int nbreakerr;
int ring;
int nframeerr;
int nparityerr;
int novererr;
int enabled;
int interfc; /* interfc on the device for ftdi */
Channel *w4data;
Channel *gotdata;
Channel *readc; /* to uncouple reads, only used in ftdi... */
int ndata;
uint8_t data[DataBufSz];
};
struct Serial {
QLock;
Dev *dev; /* usb device*/
int type; /* serial model subtype */
int recover; /* # of non-fatal recovery tries */
Serialops;
int hasepintr;
int jtag; /* index of jtag interface, -1 none */
int nifcs; /* # of serial interfaces, including JTAG */
Serialport p[Maxifc];
int maxrtrans;
int maxwtrans;
int maxread;
int maxwrite;
int inhdrsz;
int outhdrsz;
int baudbase; /* for special baud base settings, see ftdi */
};
enum {
/* soft flow control chars */
CTLS = 023,
CTLQ = 021,
CtlDTR = 1,
CtlRTS = 2,
};
/*
* !hget http://lxr.linux.no/source/drivers/usb/serial/pl2303.h|htmlfmt
* !hget http://lxr.linux.no/source/drivers/usb/serial/pl2303.c|htmlfmt
*/
int serialmain(Dev *d, int argc, char *argv[]);
typedef struct Cinfo Cinfo;
struct Cinfo {
int vid; /* usb vendor id */
int did; /* usb device/product id */
int cid; /* controller id assigned by us */
};
extern Cinfo plinfo[];
extern Cinfo uconsinfo[];
extern int serialdebug;
#define dsprint if(serialdebug)fprint
int serialrecover(Serial *ser, Serialport *p, Dev *ep, char *err);
int serialreset(Serial *ser);
char *serdumpst(Serialport *p, char *buf, int bufsz);

12
sys/include/usb/silabs.h Normal file
View File

@@ -0,0 +1,12 @@
/*
* This file is part of the UCB release of Plan 9. It is subject to the license
* terms in the LICENSE file found in the top-level directory of this
* distribution and at http://akaros.cs.berkeley.edu/files/Plan9License. No
* part of the UCB release of Plan 9, including this file, may be copied,
* modified, propagated, or distributed except according to the terms contained
* in the LICENSE file.
*/
extern Serialops slops;
int slmatch(char *info);

18
sys/include/usb/ucons.h Normal file
View File

@@ -0,0 +1,18 @@
/*
* This file is part of the UCB release of Plan 9. It is subject to the license
* terms in the LICENSE file found in the top-level directory of this
* distribution and at http://akaros.cs.berkeley.edu/files/Plan9License. No
* part of the UCB release of Plan 9, including this file, may be copied,
* modified, propagated, or distributed except according to the terms contained
* in the LICENSE file.
*/
enum {
Net20DCVid = 0x0525, /* Ajays usb debug cable */
Net20DCDid = 0x127a,
};
int uconsmatch(char *info);
extern Serialops uconsops;

115
sys/include/usb/ums.h Normal file
View File

@@ -0,0 +1,115 @@
/*
* This file is part of the UCB release of Plan 9. It is subject to the license
* terms in the LICENSE file found in the top-level directory of this
* distribution and at http://akaros.cs.berkeley.edu/files/Plan9License. No
* part of the UCB release of Plan 9, including this file, may be copied,
* modified, propagated, or distributed except according to the terms contained
* in the LICENSE file.
*/
/*
* mass storage transport protocols and subclasses,
* from usb mass storage class specification overview rev 1.2
*/
typedef struct Umsc Umsc;
typedef struct Ums Ums;
typedef struct Cbw Cbw; /* command block wrapper */
typedef struct Csw Csw; /* command status wrapper */
enum
{
Protocbi = 0, /* control/bulk/interrupt; mainly floppies */
Protocb = 1, /* " with no interrupt; mainly floppies */
Protobulk = 0x50, /* bulk only */
Subrbc = 1, /* reduced blk cmds */
Subatapi = 2, /* cd/dvd using sff-8020i or mmc-2 cmd blks */
Subqic = 3, /* QIC-157 tapes */
Subufi = 4, /* floppy */
Sub8070 = 5, /* removable media, atapi-like */
Subscsi = 6, /* scsi transparent cmd set */
Subisd200 = 7, /* ISD200 ATA */
Subdev = 0xff, /* use device's value */
Umsreset = 0xFF,
Getmaxlun = 0xFE,
// Maxlun = 256,
Maxlun = 32,
CMreset = 1,
Pcmd = 0,
Pdata,
Pstatus,
CbwLen = 31,
CbwDataIn = 0x80,
CbwDataOut = 0x00,
CswLen = 13,
CswOk = 0,
CswFailed = 1,
CswPhaseErr = 2,
};
/*
* corresponds to a lun.
* these are ~600+Maxiosize bytes each; ScsiReq is not tiny.
*/
struct Umsc
{
ScsiReq;
uint64_t blocks;
int64_t capacity;
/* from setup */
char *bufp;
long off; /* offset within a block */
long nb; /* byte count */
uint8_t rawcmd[16];
uint8_t phase;
char *inq;
Ums *ums;
Usbfs fs;
char buf[Maxiosize];
};
struct Ums
{
QLock;
Dev *dev;
Dev *epin;
Dev *epout;
Umsc *lun;
uint8_t maxlun;
int seq;
int nerrs;
int wrongresidues;
};
/*
* USB transparent SCSI devices
*/
struct Cbw
{
char signature[4]; /* "USBC" */
long tag;
long datalen;
uint8_t flags;
uint8_t lun;
uint8_t len;
char command[16];
};
struct Csw
{
char signature[4]; /* "USBS" */
long tag;
long dataresidue;
uint8_t status;
};
int diskmain(Dev*, int, char**);

376
sys/include/usb/usb.h Normal file
View File

@@ -0,0 +1,376 @@
/*
* This file is part of the UCB release of Plan 9. It is subject to the license
* terms in the LICENSE file found in the top-level directory of this
* distribution and at http://akaros.cs.berkeley.edu/files/Plan9License. No
* part of the UCB release of Plan 9, including this file, may be copied,
* modified, propagated, or distributed except according to the terms contained
* in the LICENSE file.
*/
typedef struct Altc Altc;
typedef struct Conf Conf;
typedef struct DConf DConf;
typedef struct DDesc DDesc;
typedef struct DDev DDev;
typedef struct DEp DEp;
typedef struct DIface DIface;
typedef struct Desc Desc;
typedef struct Dev Dev;
typedef struct Ep Ep;
typedef struct Iface Iface;
typedef struct Usbdev Usbdev;
enum {
/* fundamental constants */
Nep = 16, /* max. endpoints per usb device & per interface */
/* tunable parameters */
Nconf = 16, /* max. configurations per usb device */
Nddesc = 8*Nep, /* max. device-specific descriptors per usb device */
Niface = 16, /* max. interfaces per configuration */
Naltc = 16, /* max. alt configurations per interface */
Uctries = 4, /* no. of tries for usbcmd */
Ucdelay = 50, /* delay before retrying */
/* request type */
Rh2d = 0<<7, /* host to device */
Rd2h = 1<<7, /* device to host */
Rstd = 0<<5, /* types */
Rclass = 1<<5,
Rvendor = 2<<5,
Rdev = 0, /* recipients */
Riface = 1,
Rep = 2, /* endpoint */
Rother = 3,
/* standard requests */
Rgetstatus = 0,
Rclearfeature = 1,
Rsetfeature = 3,
Rsetaddress = 5,
Rgetdesc = 6,
Rsetdesc = 7,
Rgetconf = 8,
Rsetconf = 9,
Rgetiface = 10,
Rsetiface = 11,
Rsynchframe = 12,
Rgetcur = 0x81,
Rgetmin = 0x82,
Rgetmax = 0x83,
Rgetres = 0x84,
Rsetcur = 0x01,
Rsetmin = 0x02,
Rsetmax = 0x03,
Rsetres = 0x04,
/* dev classes */
Clnone = 0, /* not in usb */
Claudio = 1,
Clcomms = 2,
Clhid = 3,
Clprinter = 7,
Clstorage = 8,
Clhub = 9,
Cldata = 10,
/* standard descriptor sizes */
Ddevlen = 18,
Dconflen = 9,
Difacelen = 9,
Deplen = 7,
/* descriptor types */
Ddev = 1,
Dconf = 2,
Dstr = 3,
Diface = 4,
Dep = 5,
Dreport = 0x22,
Dfunction = 0x24,
Dphysical = 0x23,
/* feature selectors */
Fdevremotewakeup = 1,
Fhalt = 0,
/* device state */
Detached = 0,
Attached,
Enabled,
Assigned,
Configured,
/* endpoint direction */
Ein = 0,
Eout,
Eboth,
/* endpoint type */
Econtrol = 0,
Eiso = 1,
Ebulk = 2,
Eintr = 3,
/* endpoint isotype */
Eunknown = 0,
Easync = 1,
Eadapt = 2,
Esync = 3,
/* config attrib */
Cbuspowered = 1<<7,
Cselfpowered = 1<<6,
Cremotewakeup = 1<<5,
/* report types */
Tmtype = 3<<2,
Tmitem = 0xF0,
Tmain = 0<<2,
Tinput = 0x80,
Toutput = 0x90,
Tfeature = 0xB0,
Tcoll = 0xA0,
Tecoll = 0xC0,
Tglobal = 1<<2,
Tusagepage = 0x00,
Tlmin = 0x10,
Tlmax = 0x20,
Tpmin = 0x30,
Tpmax = 0x40,
Tunitexp = 0x50,
Tunit = 0x60,
Trepsize = 0x70,
TrepID = 0x80,
Trepcount = 0x90,
Tpush = 0xA0,
Tpop = 0xB0,
Tlocal = 2<<2,
Tusage = 0x00,
Tumin = 0x10,
Tumax = 0x20,
Tdindex = 0x30,
Tdmin = 0x40,
Tdmax = 0x50,
Tsindex = 0x70,
Tsmin = 0x80,
Tsmax = 0x90,
Tsetdelim = 0xA0,
Treserved = 3<<2,
Tlong = 0xFE,
};
/*
* Usb device (when used for ep0s) or endpoint.
* RC: One ref because of existing, another one per ogoing I/O.
* per-driver resources (including FS if any) are released by aux
* once the last ref is gone. This may include other Devs using
* to access endpoints for actual I/O.
*/
struct Dev
{
Ref;
char* dir; /* path for the endpoint dir */
int id; /* usb id for device or ep. number */
int dfd; /* descriptor for the data file */
int cfd; /* descriptor for the control file */
int maxpkt; /* cached from usb description */
Ref nerrs; /* number of errors in requests */
Usbdev* usb; /* USB description */
void* aux; /* for the device driver */
void (*free)(void*); /* idem. to release aux */
};
/*
* device description as reported by USB (unpacked).
*/
struct Usbdev
{
uint32_t csp; /* USB class/subclass/proto */
int vid; /* vendor id */
int did; /* product (device) id */
int dno; /* device release number */
char* vendor;
char* product;
char* serial;
int vsid;
int psid;
int ssid;
int class; /* from descriptor */
int nconf; /* from descriptor */
Conf* conf[Nconf]; /* configurations */
Ep* ep[Nep]; /* all endpoints in device */
Desc* ddesc[Nddesc]; /* (raw) device specific descriptors */
};
struct Ep
{
uint8_t addr; /* endpt address, 0-15 (|0x80 if Ein) */
uint8_t dir; /* direction, Ein/Eout */
uint8_t type; /* Econtrol, Eiso, Ebulk, Eintr */
uint8_t isotype; /* Eunknown, Easync, Eadapt, Esync */
int id;
int maxpkt; /* max. packet size */
int ntds; /* nb. of Tds per µframe */
Conf* conf; /* the endpoint belongs to */
Iface* iface; /* the endpoint belongs to */
};
struct Altc
{
int attrib;
int interval;
void* aux; /* for the driver program */
};
struct Iface
{
int id; /* interface number */
uint32_t csp; /* USB class/subclass/proto */
Altc* altc[Naltc];
Ep* ep[Nep];
void* aux; /* for the driver program */
};
struct Conf
{
int cval; /* value for set configuration */
int attrib;
int milliamps; /* maximum power in this config. */
Iface* iface[Niface];
};
/*
* Device-specific descriptors.
* They show up mixed with other descriptors
* within a configuration.
* These are unknown to the library but handed to the driver.
*/
struct DDesc
{
uint8_t bLength;
uint8_t bDescriptorType;
uint8_t bbytes[1];
/* extra bytes allocated here to keep the rest of it */
};
struct Desc
{
Conf* conf; /* where this descriptor was read */
Iface* iface; /* last iface before desc in conf. */
Ep* ep; /* last endpt before desc in conf. */
Altc* altc; /* last alt.c. before desc in conf. */
DDesc data; /* unparsed standard USB descriptor */
};
/*
* layout of standard descriptor types
*/
struct DDev
{
uint8_t bLength;
uint8_t bDescriptorType;
uint8_t bcdUSB[2];
uint8_t bDevClass;
uint8_t bDevSubClass;
uint8_t bDevProtocol;
uint8_t bMaxPacketSize0;
uint8_t idVendor[2];
uint8_t idProduct[2];
uint8_t bcdDev[2];
uint8_t iManufacturer;
uint8_t iProduct;
uint8_t iSerialNumber;
uint8_t bNumConfigurations;
};
struct DConf
{
uint8_t bLength;
uint8_t bDescriptorType;
uint8_t wTotalLength[2];
uint8_t bNumInterfaces;
uint8_t bConfigurationValue;
uint8_t iConfiguration;
uint8_t bmAttributes;
uint8_t MaxPower;
};
struct DIface
{
uint8_t bLength;
uint8_t bDescriptorType;
uint8_t bInterfaceNumber;
uint8_t bAlternateSetting;
uint8_t bNumEndpoints;
uint8_t bInterfaceClass;
uint8_t bInterfaceSubClass;
uint8_t bInterfaceProtocol;
uint8_t iInterface;
};
struct DEp
{
uint8_t bLength;
uint8_t bDescriptorType;
uint8_t bEndpointAddress;
uint8_t bmAttributes;
uint8_t wMaxPacketSize[2];
uint8_t bInterval;
};
#define Class(csp) ((csp) & 0xff)
#define Subclass(csp) (((csp)>>8) & 0xff)
#define Proto(csp) (((csp)>>16) & 0xff)
#define CSP(c, s, p) ((c) | (s)<<8 | (p)<<16)
#define GET2(p) (((p)[1] & 0xFF)<<8 | ((p)[0] & 0xFF))
#define PUT2(p,v) {(p)[0] = (v); (p)[1] = (v)>>8;}
#define GET4(p) (((p)[3]&0xFF)<<24 | ((p)[2]&0xFF)<<16 | \
((p)[1]&0xFF)<<8 | ((p)[0]&0xFF))
/* These were macros. Let's start making them type safe with inline includes.
* The use of macros is a puzzle given the Ken C toolchain's inlining at link time
* abilities, but ...
*/
static inline void PUT4(uint8_t *p, uint32_t v)
{
(p)[0] = (v);
(p)[1] = (v)>>8;
(p)[2] = (v)>>16;
(p)[3] = (v)>>24;
}
#define dprint if(usbdebug)fprint
#define ddprint if(usbdebug > 1)fprint
int Ufmt(Fmt *f);
char* classname(int c);
void closedev(Dev *d);
int configdev(Dev *d);
int devctl(Dev *dev, char *fmt, ...);
void* emallocz(uint32_t size, int zero);
char* estrdup(char *s);
int matchdevcsp(char *info, void *a);
int finddevs(int (*matchf)(char*,void*), void *farg, char** dirs, int ndirs);
char* hexstr(void *a, int n);
int loaddevconf(Dev *d, int n);
int loaddevdesc(Dev *d);
char* loaddevstr(Dev *d, int sid);
Dev* opendev(char *fn);
int opendevdata(Dev *d, int mode);
Dev* openep(Dev *d, int id);
int parseconf(Usbdev *d, Conf *c, uint8_t *b, int n);
int parsedesc(Usbdev *d, Conf *c, uint8_t *b, int n);
int parsedev(Dev *xd, uint8_t *b, int n);
void startdevs(char *args, char *argv[], int argc, int (*mf)(char*,void*), void*ma, int (*df)(Dev*,int,char**));
int unstall(Dev *dev, Dev *ep, int dir);
int usbcmd(Dev *d, int type, int req, int value, int index, uint8_t *data, int count);
extern int usbdebug; /* more messages for bigger values */

70
sys/include/usb/usbfs.h Normal file
View File

@@ -0,0 +1,70 @@
/*
* This file is part of the UCB release of Plan 9. It is subject to the license
* terms in the LICENSE file found in the top-level directory of this
* distribution and at http://akaros.cs.berkeley.edu/files/Plan9License. No
* part of the UCB release of Plan 9, including this file, may be copied,
* modified, propagated, or distributed except according to the terms contained
* in the LICENSE file.
*/
typedef struct Usbfs Usbfs;
typedef struct Fid Fid;
enum
{
Hdrsize = 128, /* plenty of room for headers */
Msgsize = 8216, /* our preferred iounit (also devmnt's) */
Bufsize = Hdrsize + Msgsize,
Namesz = 40,
Errmax = 128,
ONONE = ~0, /* omode in Fid when not open */
};
struct Fid
{
int fid;
Qid qid;
int omode;
Fid* next;
void* aux;
};
struct Usbfs
{
char name[Namesz];
uint64_t qid;
Dev* dev;
void* aux;
int (*walk)(Usbfs *fs, Fid *f, char *name);
void (*clone)(Usbfs *fs, Fid *of, Fid *nf);
void (*clunk)(Usbfs *fs, Fid *f);
int (*open)(Usbfs *fs, Fid *f, int mode);
int32_t (*read)(Usbfs *fs, Fid *f, void *data, int32_t count, int64_t offset);
int32_t (*write)(Usbfs *fs, Fid*f, void *data, int32_t count, int64_t offset);
int (*stat)(Usbfs *fs, Qid q, Dir *d);
void (*end)(Usbfs *fs);
};
typedef int (*Dirgen)(Usbfs*, Qid, int, Dir*, void*);
int32_t usbreadbuf(void *data, int32_t count, int64_t offset, void *buf, int32_t n);
void usbfsadd(Usbfs *dfs);
void usbfsdel(Usbfs *dfs);
int usbdirread(Usbfs*f, Qid q, char *data, int32_t cnt, int64_t off, Dirgen gen, void *arg);
void usbfsinit(char* srv, char *mnt, Usbfs *f, int flag);
void usbfsdirdump(void);
extern char Enotfound[];
extern char Etoosmall[];
extern char Eio[];
extern char Eperm[];
extern char Ebadcall[];
extern char Ebadfid[];
extern char Einuse[];
extern char Eisopen[];
extern char Ebadctl[];
extern Usbfs usbdirfs;
extern int usbfsdebug;