forsyth20121205-174063a80cc13 years agoHistory
143 lines · 3.9 KB · Text
RawDownload
.TH USB 3 MPC823.SH NAMEusb \- USB device interface.SH SYNOPSYS.nf.B bind -a '#U' /dev .B /dev/usbctl.B /dev/usbdata.B /dev/usbstat.B /dev/usbaddr.B /dev/usbframe.B /dev/usbsetup.fi.SH DESCRIPTION.PPThe USB device serves a one-level directory,giving access to six files.They provide an interface to the device (slave) mode of the 823/850 USB controller,allowing an Inferno system to provide services to the USB host.The controller's endpoints are configured as follows.Endpoint 0 is the default USB control endpoint, as required by the USB standard.Endpoint 1 responds to bulk output requests from the host;endpoint 2 responds to bulk input requests from the host;endpoint 3 is unused..PPThe data file.B usbdataprovides read and write access to endpoints 1 and 2.When the file is read, it returns data written to endpoint 1 by the USB host.Data written to the file is provided in response to the host's read requestson endpoint 2.Output data is converted to packets limited to the maximum packetlength for the endpoint (see the.B maxpktcontrol request, below), which is 1023 bytes by default.Note that zero length records can be transmitted andreceived on USB..PPThe file.B usbsetupprovides read and write access to endpoint 0.When the file is read, it returnsSETUPrequests from the host.If a given request requires a reply, the reply must be written to the file(host requests will automatically be NAKd until then).Requests and replies are in binary form as defined in the USB specification,except for the reset message described below.The driver itself interprets allSET_ADDRESSrequests from the host, and sets the controller's address accordingly.That request will therefore not be visible on the.B usbsetupfile..PPA USB bus or device reset sets the controller's USB address  to zero,the USB `default address' for configuration.It also resets all data toggles to DATA0.A subsequent read of.B usbsetupwill return the following special 8-byte reset message:.IP.EXbyte 16rFF, byte 16rFF, byte 'r', byte 'e',.brbyte 's', byte 'e', byte 't', byte '\en'.EE.PPwhich does not resemble a normal SETUP message.Further reads and writes on.B usbdatawill return errors until that file has been closed and reopened..PPThe control file.B usbctlreceives textual commands to set device parameters and responses:.TP.BI maxpkt "n nb"Set the maximum packet size for endpoint.I nto.I nbbytes..I Nbmust be between 8 and 64 bytes for the control endpoint 0,and between 1 and 1023 bytes for the other endpoints.The default is 8 bytes for endpoint 0 and 1023 bytes for the others..TP.BI rdtog "n t"Set the data toggle for input in endpoint.I nto.IR t ,which must be either 0 (DATA0) or 1 (DATA1)..TP.BI stall "n"Cause endpoint.I nto respond to host IN and OUT tokens by stalling..TP.BI unstall "n"Cancel the effect of a previous.B stallrequest on endpoint.IR n ..TP.BI wrtog "n t"Set the data toggle for the next packet output by endpoint.I nto.IR t ,which must be either 0 (DATA0) or 1 (DATA1)..PPStalling an endpoint causes IN and OUTtransactions from the host to return a `stalled' error status.On the control endpoint (endpoint 0), however,SETUP transactions will still arrive on.BR usbsetup ,and the arrival of a SETUP will automatically clear the `stalled' statusfor the endpoint,allowing an application to reject acontrol request (by stalling the subsequent status transaction)without stalling the control endpoint by rejecting subsequentSETUP transactions..PPThe status file.B usbstatis a read-only file,containing one line of statistics for each endpoint, giving:endpoint number; data toggles; maximum packet size;count of input and output bytes and packets; and countsof various error conditions..PPThe read-only file.B usbaddrcontains a single number giving the current device address..PPThe read-only file.B usbframecontains a single line giving the current USB frame number..SH SOURCE.B /os/mpc/devusb.c