This commit is contained in:
Attilio Rao 2011-06-24 16:35:40 +00:00
commit de138ec703
176 changed files with 3083 additions and 1423 deletions

View File

@ -71,7 +71,6 @@ __FBSDID("$FreeBSD$");
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <string.h>
#include <unistd.h>
#include "extern.h"

View File

@ -55,7 +55,6 @@ __FBSDID("$FreeBSD$");
*/
#include <sys/cdefs.h>
#include <sys/types.h>
#include <stdio.h>
#include <stdlib.h>

View File

@ -9973,6 +9973,13 @@ do_t_rbit (void)
inst.instruction |= inst.operands[1].reg << 16;
}
static void
do_t_rd_rm (void)
{
inst.instruction |= inst.operands[0].reg << 8;
inst.instruction |= inst.operands[1].reg;
}
static void
do_t_rev (void)
{
@ -14901,6 +14908,9 @@ static const struct asm_opcode insns[] =
TCE(rsb, 0600000, ebc00000, 3, (RR, oRR, SH), arit, t_rsb),
TC3(rsbs, 0700000, ebd00000, 3, (RR, oRR, SH), arit, t_rsb),
TCE(rrx, 1a00060, ea4f0030, 2, (RR, RR), rd_rm, t_rd_rm),
TCE(rrxs, 1b00060, ea5f0030, 2, (RR, RR), rd_rm, t_rd_rm),
#undef THUMB_VARIANT
#define THUMB_VARIANT &arm_ext_v6
TCE(cpy, 1a00000, 4600, 2, (RR, RR), rd_rm, t_cpy),

View File

@ -94,7 +94,7 @@ ifconfig_up()
# ifconfig_IF
ifconfig_args=`ifconfig_getargs $1`
if [ -n "${ifconfig_args}" ]; then
ifconfig $1 ${ifconfig_args}
eval ifconfig $1 ${ifconfig_args}
_cfg=0
fi

View File

@ -83,7 +83,7 @@
<flags>IEEE80211_CHAN_HT20</flags>
</band>
<band>
<freqband ref="F1_2412_2462"/>
<freqband ref="H4_2412_2462"/>
<maxpower>30</maxpower>
<flags>IEEE80211_CHAN_G</flags>
<flags>IEEE80211_CHAN_HT40</flags>
@ -96,7 +96,7 @@
<flags>IEEE80211_CHAN_HT20</flags>
</band>
<band>
<freqband ref="F1_5180_5240"/>
<freqband ref="H4_5180_5240"/>
<maxpower>17</maxpower>
<flags>IEEE80211_CHAN_HT40</flags>
</band>
@ -106,7 +106,7 @@
<flags>IEEE80211_CHAN_HT20</flags>
</band>
<band>
<freqband ref="F1_5745_5805"/>
<freqband ref="H4_5745_5805"/>
<maxpower>23</maxpower>
<flags>IEEE80211_CHAN_HT40</flags>
</band>
@ -137,6 +137,12 @@
<freqband ref="F1_5180_5240"/>
<maxpower>17</maxpower>
</band>
<band>
<freqband ref="F1_5260_5320"/>
<maxpower>20</maxpower>
<flags>IEEE80211_CHAN_PASSIVE</flags>
<flags>IEEE80211_CHAN_DFS</flags>
</band>
<band>
<freqband ref="F1_5745_5805"/>
<maxpower>23</maxpower>
@ -175,6 +181,20 @@
<maxpower>17</maxpower>
<flags>IEEE80211_CHAN_HT40</flags>
</band>
<band>
<freqband ref="F1_5260_5320"/>
<maxpower>20</maxpower>
<flags>IEEE80211_CHAN_HT20</flags>
<flags>IEEE80211_CHAN_PASSIVE</flags>
<flags>IEEE80211_CHAN_DFS</flags>
</band>
<band>
<freqband ref="H4_5260_5320"/>
<maxpower>20</maxpower>
<flags>IEEE80211_CHAN_HT40</flags>
<flags>IEEE80211_CHAN_PASSIVE</flags>
<flags>IEEE80211_CHAN_DFS</flags>
</band>
<band>
<freqband ref="F1_5745_5805"/>
<maxpower>23</maxpower>
@ -231,7 +251,7 @@
<flags>IEEE80211_CHAN_HT20</flags>
</band>
<band>
<freqband ref="F1_2412_2462"/>
<freqband ref="H4_2412_2462"/>
<maxpower>30</maxpower>
<flags>IEEE80211_CHAN_G</flags>
<flags>IEEE80211_CHAN_HT40</flags>

View File

@ -64,13 +64,13 @@ struct tftp_handle;
static int tftp_open(const char *path, struct open_file *f);
static int tftp_close(struct open_file *f);
static void tftp_parse_oack(struct tftp_handle *h, char *buf, size_t len);
static int tftp_parse_oack(struct tftp_handle *h, char *buf, size_t len);
static int tftp_read(struct open_file *f, void *buf, size_t size, size_t *resid);
static int tftp_write(struct open_file *f, void *buf, size_t size, size_t *resid);
static off_t tftp_seek(struct open_file *f, off_t offset, int where);
static int tftp_set_blksize(struct tftp_handle *h, const char *str);
static int tftp_stat(struct open_file *f, struct stat *sb);
static ssize_t sendrecv_tftp(struct tftp_handle *h,
static ssize_t sendrecv_tftp(struct tftp_handle *h,
ssize_t (*sproc)(struct iodesc *, void *, size_t),
void *sbuf, size_t ssize,
ssize_t (*rproc)(struct tftp_handle *h, void *, ssize_t, time_t, unsigned short *),
@ -93,7 +93,7 @@ static int tftpport = 2000;
static int is_open = 0;
/*
* The legacy TFTP_BLKSIZE value was 512.
* The legacy TFTP_BLKSIZE value was SEGSIZE(512).
* TFTP_REQUESTED_BLKSIZE of 1428 is (Ethernet MTU, less the TFTP, UDP and
* IP header lengths).
*/
@ -102,7 +102,7 @@ static int is_open = 0;
/*
* Choose a blksize big enough so we can test with Ethernet
* Jumbo frames in the future.
*/
*/
#define TFTP_MAX_BLKSIZE 9008
struct tftp_handle {
@ -113,7 +113,7 @@ struct tftp_handle {
int off;
char *path; /* saved for re-requests */
unsigned int tftp_blksize;
unsigned long tftp_tsize;
unsigned long tftp_tsize;
struct {
u_char header[HEADER_SIZE];
struct tftphdr t;
@ -121,7 +121,8 @@ struct tftp_handle {
} __packed __aligned(4) lastdata;
};
static const int tftperrors[8] = {
#define TFTP_MAX_ERRCODE EOPTNEG
static const int tftperrors[TFTP_MAX_ERRCODE + 1] = {
0, /* ??? */
ENOENT,
EPERM,
@ -129,10 +130,57 @@ static const int tftperrors[8] = {
EINVAL, /* ??? */
EINVAL, /* ??? */
EEXIST,
EINVAL /* ??? */
EINVAL, /* ??? */
EINVAL, /* Option negotiation failed. */
};
static ssize_t
static int tftp_getnextblock(struct tftp_handle *h);
/* send error message back. */
static void
tftp_senderr(struct tftp_handle *h, u_short errcode, const char *msg)
{
struct {
u_char header[HEADER_SIZE];
struct tftphdr t;
u_char space[63]; /* +1 from t */
} __packed __aligned(4) wbuf;
char *wtail;
int len;
len = strlen(msg);
if (len > sizeof(wbuf.space))
len = sizeof(wbuf.space);
wbuf.t.th_opcode = htons((u_short) ERROR);
wbuf.t.th_code = htons(errcode);
wtail = wbuf.t.th_msg;
bcopy(msg, wtail, len);
wtail[len] = '\0';
wtail += len + 1;
sendudp(h->iodesc, &wbuf.t, wtail - (char *) &wbuf.t);
}
static void
tftp_sendack(struct tftp_handle *h)
{
struct {
u_char header[HEADER_SIZE];
struct tftphdr t;
} __packed __aligned(4) wbuf;
char *wtail;
wbuf.t.th_opcode = htons((u_short) ACK);
wtail = (char *) &wbuf.t.th_block;
wbuf.t.th_block = htons((u_short) h->currblock);
wtail += 2;
sendudp(h->iodesc, &wbuf.t, wtail - (char *) &wbuf.t);
}
static ssize_t
recvtftp(struct tftp_handle *h, void *pkt, ssize_t len, time_t tleft,
unsigned short *rtype)
{
@ -170,7 +218,7 @@ recvtftp(struct tftp_handle *h, void *pkt, ssize_t len, time_t tleft,
return got;
}
case ERROR:
if ((unsigned) ntohs(t->th_code) >= 8) {
if ((unsigned) ntohs(t->th_code) > TFTP_MAX_ERRCODE) {
printf("illegal tftp error %d\n", ntohs(t->th_code));
errno = EIO;
} else {
@ -182,14 +230,30 @@ recvtftp(struct tftp_handle *h, void *pkt, ssize_t len, time_t tleft,
return (-1);
case OACK: {
struct udphdr *uh;
int tftp_oack_len = len - sizeof(t->th_opcode);
tftp_parse_oack(h, t->th_u.tu_stuff, tftp_oack_len);
int tftp_oack_len;
/*
* Unexpected OACK. TFTP transfer already in progress.
* Drop the pkt.
*/
if (d->xid != 1) {
return (-1);
}
/*
* Remember which port this OACK came from,
* because we need to send the ACK back to it.
* Remember which port this OACK came from, because we need
* to send the ACK or errors back to it.
*/
uh = (struct udphdr *) pkt - 1;
d->destport = uh->uh_sport;
/* Parse options ACK-ed by the server. */
tftp_oack_len = len - sizeof(t->th_opcode);
if (tftp_parse_oack(h, t->th_u.tu_stuff, tftp_oack_len) != 0) {
tftp_senderr(h, EOPTNEG, "Malformed OACK");
errno = EIO;
return (-1);
}
return (0);
}
default:
@ -201,7 +265,7 @@ recvtftp(struct tftp_handle *h, void *pkt, ssize_t len, time_t tleft,
}
/* send request, expect first block (or error) */
static int
static int
tftp_makereq(struct tftp_handle *h)
{
struct {
@ -250,26 +314,28 @@ tftp_makereq(struct tftp_handle *h)
h->iodesc->destport = htons(IPPORT_TFTP);
h->iodesc->xid = 1; /* expected block */
h->currblock = 0;
h->islastblock = 0;
h->validsize = 0;
res = sendrecv_tftp(h, &sendudp, &wbuf.t, wtail - (char *) &wbuf.t,
&recvtftp, t, sizeof(*t) + h->tftp_blksize, &rtype);
if (rtype == OACK) {
wbuf.t.th_opcode = htons((u_short)ACK);
wtail = (char *) &wbuf.t.th_block;
wbuf.t.th_block = htons(0);
wtail += 2;
rtype = 0;
res = sendrecv_tftp(h, &sendudp, &wbuf.t, wtail - (char *) &wbuf.t,
&recvtftp, t, sizeof(*t) + h->tftp_blksize, &rtype);
}
if (rtype == OACK)
return (tftp_getnextblock(h));
/* Server ignored our blksize request, revert to TFTP default. */
h->tftp_blksize = SEGSIZE;
switch (rtype) {
case DATA: {
h->currblock = 1;
h->validsize = res;
h->islastblock = 0;
if (res < h->tftp_blksize)
if (res < h->tftp_blksize) {
h->islastblock = 1; /* very short file */
tftp_sendack(h);
}
return (0);
}
case ERROR:
@ -320,7 +386,7 @@ tftp_getnextblock(struct tftp_handle *h)
return (0);
}
static int
static int
tftp_open(const char *path, struct open_file *f)
{
struct tftp_handle *tftpfile;
@ -365,7 +431,7 @@ tftp_open(const char *path, struct open_file *f)
return (0);
}
static int
static int
tftp_read(struct open_file *f, void *addr, size_t size,
size_t *resid /* out */)
{
@ -381,9 +447,11 @@ tftp_read(struct open_file *f, void *addr, size_t size,
needblock = tftpfile->off / tftpfile->tftp_blksize + 1;
if (tftpfile->currblock > needblock) /* seek backwards */
if (tftpfile->currblock > needblock) { /* seek backwards */
tftp_senderr(tftpfile, 0, "No error: read aborted");
tftp_makereq(tftpfile); /* no error check, it worked
* for open */
}
while (tftpfile->currblock < needblock) {
int res;
@ -452,7 +520,7 @@ tftp_close(struct open_file *f)
return (0);
}
static int
static int
tftp_write(struct open_file *f __unused, void *start __unused, size_t size __unused,
size_t *resid __unused /* out */)
{
@ -473,7 +541,7 @@ tftp_stat(struct open_file *f, struct stat *sb)
return (0);
}
static off_t
static off_t
tftp_seek(struct open_file *f, off_t offset, int where)
{
struct tftp_handle *tftpfile;
@ -494,7 +562,7 @@ tftp_seek(struct open_file *f, off_t offset, int where)
}
static ssize_t
sendrecv_tftp(struct tftp_handle *h,
sendrecv_tftp(struct tftp_handle *h,
ssize_t (*sproc)(struct iodesc *, void *, size_t),
void *sbuf, size_t ssize,
ssize_t (*rproc)(struct tftp_handle *, void *, ssize_t, time_t, unsigned short *),
@ -562,9 +630,9 @@ tftp_set_blksize(struct tftp_handle *h, const char *str)
/*
* Only accept blksize value if it is numeric.
* RFC2348 specifies that acceptable valuesare 8-65464
* 8-65464 . Let's choose a limit less than MAXRSPACE
*/
* RFC2348 specifies that acceptable values are 8-65464.
* Let's choose a limit less than MAXRSPACE.
*/
if (*endptr == '\0' && new_blksize >= 8
&& new_blksize <= TFTP_MAX_BLKSIZE) {
h->tftp_blksize = new_blksize;
@ -597,13 +665,12 @@ tftp_set_blksize(struct tftp_handle *h, const char *str)
* optN, valueN
* The final option/value acknowledgment pair.
*/
static void
static int
tftp_parse_oack(struct tftp_handle *h, char *buf, size_t len)
{
/*
* We parse the OACK strings into an array
* of name-value pairs.
*
*/
char *tftp_options[128] = { 0 };
char *val = buf;
@ -612,18 +679,22 @@ tftp_parse_oack(struct tftp_handle *h, char *buf, size_t len)
int blksize_is_set = 0;
int tsize = 0;
while ( option_idx < 128 && i < len ) {
if (buf[i] == '\0') {
if (&buf[i] > val) {
tftp_options[option_idx] = val;
val = &buf[i] + 1;
++option_idx;
}
}
++i;
unsigned int orig_blksize;
while (option_idx < 128 && i < len) {
if (buf[i] == '\0') {
if (&buf[i] > val) {
tftp_options[option_idx] = val;
val = &buf[i] + 1;
++option_idx;
}
}
++i;
}
/* Save the block size we requested for sanity check later. */
orig_blksize = h->tftp_blksize;
/*
* Parse individual TFTP options.
* * "blksize" is specified in RFC2348.
@ -631,27 +702,37 @@ tftp_parse_oack(struct tftp_handle *h, char *buf, size_t len)
*/
for (i = 0; i < option_idx; i += 2) {
if (strcasecmp(tftp_options[i], "blksize") == 0) {
if (i + 1 < option_idx) {
if (i + 1 < option_idx)
blksize_is_set =
tftp_set_blksize(h, tftp_options[i + 1]);
}
} else if (strcasecmp(tftp_options[i], "tsize") == 0) {
if (i + 1 < option_idx) {
if (i + 1 < option_idx)
tsize = strtol(tftp_options[i + 1], (char **)NULL, 10);
}
} else {
/* Do not allow any options we did not expect to be ACKed. */
printf("unexpected tftp option '%s'\n", tftp_options[i]);
return (-1);
}
}
if (!blksize_is_set) {
/*
* If TFTP blksize was not set, try defaulting
* to the legacy TFTP blksize of 512
* to the legacy TFTP blksize of SEGSIZE(512)
*/
h->tftp_blksize = 512;
h->tftp_blksize = SEGSIZE;
} else if (h->tftp_blksize > orig_blksize) {
/*
* Server should not be proposing block sizes that
* exceed what we said we can handle.
*/
printf("unexpected blksize %u\n", h->tftp_blksize);
return (-1);
}
#ifdef TFTP_DEBUG
printf("tftp_blksize: %u\n", h->tftp_blksize);
printf("tftp_tsize: %lu\n", h->tftp_tsize);
#endif
return 0;
}

View File

@ -22,7 +22,7 @@ MLINKS+= libusb.3 usb.3
# libusb 0.1 compat
INCS+= usb.h
SRCS+= libusb20_compat01.c
SRCS+= libusb01.c
# libusb 1.0 compat
INCS+= libusb.h
@ -184,6 +184,8 @@ MLINKS += libusb20.3 libusb20_dev_get_device_desc.3
MLINKS += libusb20.3 libusb20_dev_alloc_config.3
MLINKS += libusb20.3 libusb20_dev_alloc.3
MLINKS += libusb20.3 libusb20_dev_get_address.3
MLINKS += libusb20.3 libusb20_dev_get_parent_address.3
MLINKS += libusb20.3 libusb20_dev_get_parent_port.3
MLINKS += libusb20.3 libusb20_dev_get_bus_number.3
MLINKS += libusb20.3 libusb20_dev_get_mode.3
MLINKS += libusb20.3 libusb20_dev_get_speed.3

View File

@ -159,6 +159,10 @@ USB access library (libusb -lusb)
.Ft uint8_t
.Fn libusb20_dev_get_address "struct libusb20_device *pdev"
.Ft uint8_t
.Fn libusb20_dev_get_parent_address "struct libusb20_device *pdev"
.Ft uint8_t
.Fn libusb20_dev_get_parent_port "struct libusb20_device *pdev"
.Ft uint8_t
.Fn libusb20_dev_get_bus_number "struct libusb20_device *pdev"
.Ft uint8_t
.Fn libusb20_dev_get_mode "struct libusb20_device *pdev"
@ -756,12 +760,31 @@ is an internal function to allocate a new USB device.
.Fn libusb20_dev_get_address
returns the internal and not necessarily the real
hardware address of the given USB device.
Valid addresses start at one.
.
.Pp
.
.Fn libusb20_dev_get_parent_address
returns the internal and not necessarily the real hardware address of
the given parent USB HUB device.
This value is zero for the root HUB which usually has a device address
equal to one.
Valid addresses start at one.
.
.Pp
.
.Fn libusb20_dev_get_parent_port
returns the port number on the parent USB HUB device.
This value is zero for the root HUB which usually has a device address
equal to one.
Valid port numbers start at one.
.
.Pp
.
.Fn libusb20_dev_get_bus_number
returns the internal bus number which the given USB
device belongs to.
Valid bus numbers start at zero.
.
.Pp
.

View File

@ -1056,6 +1056,18 @@ libusb20_dev_get_address(struct libusb20_device *pdev)
return (pdev->device_address);
}
uint8_t
libusb20_dev_get_parent_address(struct libusb20_device *pdev)
{
return (pdev->parent_address);
}
uint8_t
libusb20_dev_get_parent_port(struct libusb20_device *pdev)
{
return (pdev->parent_port);
}
uint8_t
libusb20_dev_get_bus_number(struct libusb20_device *pdev)
{

View File

@ -262,6 +262,8 @@ struct LIBUSB20_DEVICE_DESC_DECODED *libusb20_dev_get_device_desc(struct libusb2
struct libusb20_config *libusb20_dev_alloc_config(struct libusb20_device *pdev, uint8_t config_index);
struct libusb20_device *libusb20_dev_alloc(void);
uint8_t libusb20_dev_get_address(struct libusb20_device *pdev);
uint8_t libusb20_dev_get_parent_address(struct libusb20_device *pdev);
uint8_t libusb20_dev_get_parent_port(struct libusb20_device *pdev);
uint8_t libusb20_dev_get_bus_number(struct libusb20_device *pdev);
uint8_t libusb20_dev_get_mode(struct libusb20_device *pdev);
uint8_t libusb20_dev_get_speed(struct libusb20_device *pdev);

View File

@ -226,6 +226,8 @@ struct libusb20_device {
uint8_t usb_mode;
uint8_t usb_speed;
uint8_t is_opened;
uint8_t parent_address;
uint8_t parent_port;
char usb_desc[96];
};

View File

@ -195,6 +195,11 @@ ugen20_enumerate(struct libusb20_device *pdev, const char *id)
break;
}
/* get parent HUB index and port */
pdev->parent_address = devinfo.udi_hubindex;
pdev->parent_port = devinfo.udi_hubport;
/* generate a nice description for printout */
snprintf(pdev->usb_desc, sizeof(pdev->usb_desc),

View File

@ -1191,9 +1191,9 @@ end_login(void)
ftpd_logwtmp(wtmpid, NULL, NULL);
pw = NULL;
#ifdef LOGIN_CAP
setusercontext(NULL, getpwuid(0), 0,
LOGIN_SETPRIORITY|LOGIN_SETRESOURCES|LOGIN_SETUMASK|
LOGIN_SETMAC);
setusercontext(NULL, getpwuid(0), 0, LOGIN_SETALL & ~(LOGIN_SETLOGIN |
LOGIN_SETUSER | LOGIN_SETGROUP | LOGIN_SETPATH |
LOGIN_SETENV));
#endif
#ifdef USE_PAM
if (pamh) {
@ -1465,9 +1465,8 @@ skip:
return;
}
}
setusercontext(lc, pw, 0,
LOGIN_SETLOGIN|LOGIN_SETGROUP|LOGIN_SETPRIORITY|
LOGIN_SETRESOURCES|LOGIN_SETUMASK|LOGIN_SETMAC);
setusercontext(lc, pw, 0, LOGIN_SETALL &
~(LOGIN_SETUSER | LOGIN_SETPATH | LOGIN_SETENV));
#else
setlogin(pw->pw_name);
(void) initgroups(pw->pw_name, pw->pw_gid);

View File

@ -27,6 +27,8 @@
__FBSDID("$FreeBSD$");
#include <sys/types.h>
#include <sys/ioctl.h>
#include <sys/socket.h>
#include <sys/stat.h>
#include <netinet/in.h>
@ -249,9 +251,34 @@ read_close(void)
}
int
synchnet(int peer __unused)
{
/* When an error has occurred, it is possible that the two sides
* are out of synch. Ie: that what I think is the other side's
* response to packet N is really their response to packet N-1.
*
* So, to try to prevent that, we flush all the input queued up
* for us on the network connection on our host.
*
* We return the number of packets we flushed (mostly for reporting
* when trace is active).
*/
return 0;
int
synchnet(int peer) /* socket to flush */
{
int i, j = 0;
char rbuf[MAXPKTSIZE];
struct sockaddr_storage from;
socklen_t fromlen;
while (1) {
(void) ioctl(peer, FIONREAD, &i);
if (i) {
j++;
fromlen = sizeof from;
(void) recvfrom(peer, rbuf, sizeof (rbuf), 0,
(struct sockaddr *)&from, &fromlen);
} else {
return(j);
}
}
}

View File

@ -32,7 +32,7 @@
.\" @(#)tftpd.8 8.1 (Berkeley) 6/4/93
.\" $FreeBSD$
.\"
.Dd September 14, 2000
.Dd June 22, 2011
.Dt TFTPD 8
.Os
.Sh NAME
@ -150,9 +150,27 @@ compatible format string for the creation of the suffix if
.Fl W
is specified.
By default the string "%Y%m%d" is used.
.It Fl d
.It Fl d, d Ar [value]
Enables debug output.
If specified twice, it will log DATA and ACK packets too.
If
.Ar value
is not specified, then the debug level is increased by one
for each instance of
.Fl d
which is specified.
.Pp
If
.Ar value
is specified, then the debug level is set to
.Ar value .
The debug level is a bitmask implemented in
.Pa src/libexec/tftpd/tftp-utils.h .
Valid values are 0 (DEBUG_NONE), 1 (DEBUG_PACKETS), 2, (DEBUG_SIMPLE),
4 (DEBUG_OPTIONS), and 8 (DEBUG_ACCESS). Multiple debug values can be combined
in the bitmask by logically OR'ing the values. For example, specifying
.Fl d
.Ar 15
will enable all the debug values.
.It Fl l
Log all requests using
.Xr syslog 3
@ -217,12 +235,34 @@ option.
.Xr services 5 ,
.Xr syslog.conf 5 ,
.Xr inetd 8
.Pp
The following RFC's are supported:
.Rs
.%A K. R. Sollins
RFC 1350
.%T The TFTP Protocol (Revision 2)
.%D July 1992
.%O RFC 1350, STD 33
.Re
.Rs
RFC 2347
.%T TFTP Option Extension
.Re
.Rs
RFC 2348
.%T TFTP Blocksize Option
.Re
.Rs
RFC 2349
.%T TFTP Timeout Interval and Transfer Size Options
.Re
.Pp
The non-standard
.Cm rollover
and
.Cm blksize2
TFTP options are mentioned here:
.Rs
.%T Extending TFTP
.%U http://www.compuphase.com/tftp.htm
.Re
.Sh HISTORY
The
.Nm
@ -253,9 +293,15 @@ was introduced in
support for the TFTP Blocksize Option (RFC2348) and the blksize2 option
was introduced in
.Fx 7.4 .
.Pp
Edwin Groothuis <edwin@FreeBSD.org> performed a major rewrite of the
.Nm
and
.Xr tftp 1
code to support RFC2348.
.Sh NOTES
Files larger than 33488896 octets (65535 blocks) cannot be transferred
without client and server supporting the the TFTP blocksize option (RFC2348),
without client and server supporting the TFTP blocksize option (RFC2348),
or the non-standard TFTP rollover option.
.Pp
Many tftp clients will not transfer files over 16744448 octets (32767 blocks).

View File

@ -184,8 +184,7 @@
<para>Lists of locations that mirror &os; can be found in the
<ulink
url="&url.books.handbook;/mirrors-ftp.html">FTP
Sites</ulink> section of the Handbook, or on the <ulink
url="http://mirrorlist.FreeBSD.org/"></ulink> Web pages.
Sites</ulink> section of the Handbook.
Finding a close (in networking terms) mirror from which to
download the distribution is highly recommended.</para>

View File

@ -36,8 +36,8 @@
<!-- The manpaths for man page references -->
<!ENTITY release.man.url "http://www.FreeBSD.org/cgi/man.cgi">
<!ENTITY release.manpath.xorg "7.4">
<!ENTITY release.manpath.netbsd "5.0.1">
<!ENTITY release.manpath.xorg "7.5.1">
<!ENTITY release.manpath.netbsd "5.1">
<!ENTITY release.manpath.freebsd-ports "Ports">
<!ENTITY release.manpath.freebsd "9-current">

View File

@ -738,7 +738,8 @@ ipfw_config_nat(int ac, char **av)
char *id, *buf, **av1, *end;
size_t len;
av++; ac--;
av++;
ac--;
/* Nat id. */
if (ac == 0)
errx(EX_DATAERR, "missing nat id");
@ -746,7 +747,8 @@ ipfw_config_nat(int ac, char **av)
i = (int)strtol(id, &end, 0);
if (i <= 0 || *end != '\0')
errx(EX_DATAERR, "illegal nat id: %s", id);
av++; ac--;
av++;
ac--;
if (ac == 0)
errx(EX_DATAERR, "missing option");
@ -755,11 +757,13 @@ ipfw_config_nat(int ac, char **av)
av1 = av;
while (ac1 > 0) {
tok = match_token(nat_params, *av1);
ac1--; av1++;
ac1--;
av1++;
switch (tok) {
case TOK_IP:
case TOK_IF:
ac1--; av1++;
ac1--;
av1++;
break;
case TOK_ALOG:
case TOK_DENY_INC:
@ -775,18 +779,22 @@ ipfw_config_nat(int ac, char **av)
errx(EX_DATAERR, "redirect_addr: "
"not enough arguments");
len += estimate_redir_addr(&ac1, &av1);
av1 += 2; ac1 -= 2;
av1 += 2;
ac1 -= 2;
break;
case TOK_REDIR_PORT:
if (ac1 < 3)
errx(EX_DATAERR, "redirect_port: "
"not enough arguments");
av1++; ac1--;
av1++;
ac1--;
len += estimate_redir_port(&ac1, &av1);
av1 += 2; ac1 -= 2;
av1 += 2;
ac1 -= 2;
/* Skip optional remoteIP/port */
if (ac1 != 0 && isdigit(**av1)) {
av1++; ac1--;
av1++;
ac1--;
}
break;
case TOK_REDIR_PROTO:
@ -794,13 +802,16 @@ ipfw_config_nat(int ac, char **av)
errx(EX_DATAERR, "redirect_proto: "
"not enough arguments");
len += sizeof(struct cfg_redir);
av1 += 2; ac1 -= 2;
av1 += 2;
ac1 -= 2;
/* Skip optional remoteIP/port */
if (ac1 != 0 && isdigit(**av1)) {
av1++; ac1--;
av1++;
ac1--;
}
if (ac1 != 0 && isdigit(**av1)) {
av1++; ac1--;
av1++;
ac1--;
}
break;
default:
@ -819,7 +830,8 @@ ipfw_config_nat(int ac, char **av)
while (ac > 0) {
tok = match_token(nat_params, *av);
ac--; av++;
ac--;
av++;
switch (tok) {
case TOK_IP:
if (ac == 0)
@ -827,13 +839,15 @@ ipfw_config_nat(int ac, char **av)
if (!inet_aton(av[0], &(n->ip)))
errx(EX_DATAERR, "bad ip address ``%s''",
av[0]);
ac--; av++;
ac--;
av++;
break;
case TOK_IF:
if (ac == 0)
errx(EX_DATAERR, "missing option");
set_addr_dynamic(av[0], n);
ac--; av++;
ac--;
av++;
break;
case TOK_ALOG:
n->mode |= PKT_ALIAS_LOG;
@ -912,7 +926,8 @@ ipfw_show_nat(int ac, char **av)
data = NULL;
frule = 0;
lrule = IPFW_DEFAULT_RULE; /* max ipfw rule number */
ac--; av++;
ac--;
av++;
if (co.test_only)
return;

View File

@ -66,7 +66,6 @@ __FBSDID("$FreeBSD$");
#include <sys/param.h>
#include <sys/disk.h>
#include <sys/kerneldump.h>
#include <sys/param.h>
#include <sys/mount.h>
#include <sys/stat.h>
#include <errno.h>

View File

@ -34,7 +34,7 @@
.\"
.\" $FreeBSD$
.\"
.Dd August 4, 2006
.Dd June 23, 2011
.Dt NG_ETHER 4
.Os
.Sh NAME
@ -183,7 +183,6 @@ Detach from underlying Ethernet interface and shut down node.
Upon receipt of the
.Dv NGM_SHUTDOWN
control message, all hooks are disconnected, promiscuous mode is disabled,
and the source address override flag is re-enabled,
but the node is not removed.
Node can be shut down only using
.Dv NGM_ETHER_DETACH

View File

@ -1,44 +1,6 @@
/*-
* Copyright (c) 1997, Stefan Esser <se@freebsd.org>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice unmodified, this list of conditions, and the following
* disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* $FreeBSD$
*
* This file is in the public domain.
*/
/* $FreeBSD$ */
#define CONF1_ADDR_PORT 0x0cf8
#define CONF1_DATA_PORT 0x0cfc
#define CONF1_ENABLE 0x80000000ul
#define CONF1_ENABLE_CHK 0x80000000ul
#define CONF1_ENABLE_MSK 0x7f000000ul
#define CONF1_ENABLE_CHK1 0xff000001ul
#define CONF1_ENABLE_MSK1 0x80000001ul
#define CONF1_ENABLE_RES1 0x80000000ul
u_long hostb_alloc_start(int type, u_long start, u_long end, u_long count);
int pcie_cfgregopen(uint64_t base, uint8_t minbus, uint8_t maxbus);
int pci_cfgregopen(void);
u_int32_t pci_cfgregread(int bus, int slot, int func, int reg, int bytes);
void pci_cfgregwrite(int bus, int slot, int func, int reg, u_int32_t data, int bytes);
#include <x86/pci_cfgreg.h>

View File

@ -1,435 +0,0 @@
/*-
* Copyright (c) 1997, Stefan Esser <se@freebsd.org>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice unmodified, this list of conditions, and the following
* disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include <sys/cdefs.h>
__FBSDID("$FreeBSD$");
#include "opt_cpu.h"
#include <sys/param.h>
#include <sys/systm.h>
#include <sys/bus.h>
#include <sys/kernel.h>
#include <sys/malloc.h>
#include <sys/module.h>
#include <sys/rman.h>
#include <sys/sysctl.h>
#include <dev/pci/pcivar.h>
#include <dev/pci/pcireg.h>
#include <dev/pci/pcib_private.h>
#include <isa/isavar.h>
#include <machine/legacyvar.h>
#include <machine/pci_cfgreg.h>
#include <machine/resource.h>
#include "pcib_if.h"
int
legacy_pcib_maxslots(device_t dev)
{
return 31;
}
/* read configuration space register */
uint32_t
legacy_pcib_read_config(device_t dev, u_int bus, u_int slot, u_int func,
u_int reg, int bytes)
{
return(pci_cfgregread(bus, slot, func, reg, bytes));
}
/* write configuration space register */
void
legacy_pcib_write_config(device_t dev, u_int bus, u_int slot, u_int func,
u_int reg, uint32_t data, int bytes)
{
pci_cfgregwrite(bus, slot, func, reg, data, bytes);
}
/* route interrupt */
static int
legacy_pcib_route_interrupt(device_t pcib, device_t dev, int pin)
{
/* No routing possible */
return (PCI_INVALID_IRQ);
}
/* Pass MSI requests up to the nexus. */
static int
legacy_pcib_alloc_msi(device_t pcib, device_t dev, int count, int maxcount,
int *irqs)
{
device_t bus;
bus = device_get_parent(pcib);
return (PCIB_ALLOC_MSI(device_get_parent(bus), dev, count, maxcount,
irqs));
}
static int
legacy_pcib_alloc_msix(device_t pcib, device_t dev, int *irq)
{
device_t bus;
bus = device_get_parent(pcib);
return (PCIB_ALLOC_MSIX(device_get_parent(bus), dev, irq));
}
static int
legacy_pcib_map_msi(device_t pcib, device_t dev, int irq, uint64_t *addr,
uint32_t *data)
{
device_t bus;
bus = device_get_parent(pcib);
return (PCIB_MAP_MSI(device_get_parent(bus), dev, irq, addr, data));
}
static const char *
legacy_pcib_is_host_bridge(int bus, int slot, int func,
uint32_t id, uint8_t class, uint8_t subclass,
uint8_t *busnum)
{
const char *s = NULL;
*busnum = 0;
if (class == PCIC_BRIDGE && subclass == PCIS_BRIDGE_HOST)
s = "Host to PCI bridge";
return s;
}
/*
* Scan the first pci bus for host-pci bridges and add pcib instances
* to the nexus for each bridge.
*/
static void
legacy_pcib_identify(driver_t *driver, device_t parent)
{
int bus, slot, func;
uint8_t hdrtype;
int found = 0;
int pcifunchigh;
int found824xx = 0;
int found_orion = 0;
device_t child;
devclass_t pci_devclass;
if (pci_cfgregopen() == 0)
return;
/*
* Check to see if we haven't already had a PCI bus added
* via some other means. If we have, bail since otherwise
* we're going to end up duplicating it.
*/
if ((pci_devclass = devclass_find("pci")) &&
devclass_get_device(pci_devclass, 0))
return;
bus = 0;
retry:
for (slot = 0; slot <= PCI_SLOTMAX; slot++) {
func = 0;
hdrtype = legacy_pcib_read_config(0, bus, slot, func,
PCIR_HDRTYPE, 1);
/*
* When enumerating bus devices, the standard says that
* one should check the header type and ignore the slots whose
* header types that the software doesn't know about. We use
* this to filter out devices.
*/
if ((hdrtype & PCIM_HDRTYPE) > PCI_MAXHDRTYPE)
continue;
if ((hdrtype & PCIM_MFDEV) &&
(!found_orion || hdrtype != 0xff))
pcifunchigh = PCI_FUNCMAX;
else
pcifunchigh = 0;
for (func = 0; func <= pcifunchigh; func++) {
/*
* Read the IDs and class from the device.
*/
uint32_t id;
uint8_t class, subclass, busnum;
const char *s;
device_t *devs;
int ndevs, i;
id = legacy_pcib_read_config(0, bus, slot, func,
PCIR_DEVVENDOR, 4);
if (id == -1)
continue;
class = legacy_pcib_read_config(0, bus, slot, func,
PCIR_CLASS, 1);
subclass = legacy_pcib_read_config(0, bus, slot, func,
PCIR_SUBCLASS, 1);
s = legacy_pcib_is_host_bridge(bus, slot, func,
id, class, subclass,
&busnum);
if (s == NULL)
continue;
/*
* Check to see if the physical bus has already
* been seen. Eg: hybrid 32 and 64 bit host
* bridges to the same logical bus.
*/
if (device_get_children(parent, &devs, &ndevs) == 0) {
for (i = 0; s != NULL && i < ndevs; i++) {
if (strcmp(device_get_name(devs[i]),
"pcib") != 0)
continue;
if (legacy_get_pcibus(devs[i]) == busnum)
s = NULL;
}
free(devs, M_TEMP);
}
if (s == NULL)
continue;
/*
* Add at priority 100 to make sure we
* go after any motherboard resources
*/
child = BUS_ADD_CHILD(parent, 100,
"pcib", busnum);
device_set_desc(child, s);
legacy_set_pcibus(child, busnum);
found = 1;
if (id == 0x12258086)
found824xx = 1;
if (id == 0x84c48086)
found_orion = 1;
}
}
if (found824xx && bus == 0) {
bus++;
goto retry;
}
/*
* Make sure we add at least one bridge since some old
* hardware doesn't actually have a host-pci bridge device.
* Note that pci_cfgregopen() thinks we have PCI devices..
*/
if (!found) {
if (bootverbose)
printf(
"legacy_pcib_identify: no bridge found, adding pcib0 anyway\n");
child = BUS_ADD_CHILD(parent, 100, "pcib", 0);
legacy_set_pcibus(child, 0);
}
}
static int
legacy_pcib_probe(device_t dev)
{
if (pci_cfgregopen() == 0)
return ENXIO;
return -100;
}
static int
legacy_pcib_attach(device_t dev)
{
int bus;
bus = pcib_get_bus(dev);
device_add_child(dev, "pci", bus);
return bus_generic_attach(dev);
}
int
legacy_pcib_read_ivar(device_t dev, device_t child, int which,
uintptr_t *result)
{
switch (which) {
case PCIB_IVAR_DOMAIN:
*result = 0;
return 0;
case PCIB_IVAR_BUS:
*result = legacy_get_pcibus(dev);
return 0;
}
return ENOENT;
}
int
legacy_pcib_write_ivar(device_t dev, device_t child, int which,
uintptr_t value)
{
switch (which) {
case PCIB_IVAR_DOMAIN:
return EINVAL;
case PCIB_IVAR_BUS:
legacy_set_pcibus(dev, value);
return 0;
}
return ENOENT;
}
/*
* Helper routine for x86 Host-PCI bridge driver resource allocation.
* This is used to adjust the start address of wildcard allocation
* requests to avoid low addresses that are known to be problematic.
*
* If no memory preference is given, use upper 32MB slot most BIOSes
* use for their memory window. This is typically only used on older
* laptops that don't have PCI busses behind a PCI bridge, so assuming
* > 32MB is likely OK.
*
* However, this can cause problems for other chipsets, so we make
* this tunable by hw.pci.host_mem_start.
*/
SYSCTL_DECL(_hw_pci);
static unsigned long host_mem_start = 0x80000000;
TUNABLE_ULONG("hw.pci.host_mem_start", &host_mem_start);
SYSCTL_ULONG(_hw_pci, OID_AUTO, host_mem_start, CTLFLAG_RDTUN, &host_mem_start,
0, "Limit the host bridge memory to being above this address.");
u_long
hostb_alloc_start(int type, u_long start, u_long end, u_long count)
{
if (start + count - 1 != end) {
if (type == SYS_RES_MEMORY && start < host_mem_start)
start = host_mem_start;
if (type == SYS_RES_IOPORT && start < 0x1000)
start = 0x1000;
}
return (start);
}
struct resource *
legacy_pcib_alloc_resource(device_t dev, device_t child, int type, int *rid,
u_long start, u_long end, u_long count, u_int flags)
{
start = hostb_alloc_start(type, start, end, count);
return (bus_generic_alloc_resource(dev, child, type, rid, start, end,
count, flags));
}
static device_method_t legacy_pcib_methods[] = {
/* Device interface */
DEVMETHOD(device_identify, legacy_pcib_identify),
DEVMETHOD(device_probe, legacy_pcib_probe),
DEVMETHOD(device_attach, legacy_pcib_attach),
DEVMETHOD(device_shutdown, bus_generic_shutdown),
DEVMETHOD(device_suspend, bus_generic_suspend),
DEVMETHOD(device_resume, bus_generic_resume),
/* Bus interface */
DEVMETHOD(bus_print_child, bus_generic_print_child),
DEVMETHOD(bus_read_ivar, legacy_pcib_read_ivar),
DEVMETHOD(bus_write_ivar, legacy_pcib_write_ivar),
DEVMETHOD(bus_alloc_resource, legacy_pcib_alloc_resource),
DEVMETHOD(bus_adjust_resource, bus_generic_adjust_resource),
DEVMETHOD(bus_release_resource, bus_generic_release_resource),
DEVMETHOD(bus_activate_resource, bus_generic_activate_resource),
DEVMETHOD(bus_deactivate_resource, bus_generic_deactivate_resource),
DEVMETHOD(bus_setup_intr, bus_generic_setup_intr),
DEVMETHOD(bus_teardown_intr, bus_generic_teardown_intr),
/* pcib interface */
DEVMETHOD(pcib_maxslots, legacy_pcib_maxslots),
DEVMETHOD(pcib_read_config, legacy_pcib_read_config),
DEVMETHOD(pcib_write_config, legacy_pcib_write_config),
DEVMETHOD(pcib_route_interrupt, legacy_pcib_route_interrupt),
DEVMETHOD(pcib_alloc_msi, legacy_pcib_alloc_msi),
DEVMETHOD(pcib_release_msi, pcib_release_msi),
DEVMETHOD(pcib_alloc_msix, legacy_pcib_alloc_msix),
DEVMETHOD(pcib_release_msix, pcib_release_msix),
DEVMETHOD(pcib_map_msi, legacy_pcib_map_msi),
{ 0, 0 }
};
static devclass_t hostb_devclass;
DEFINE_CLASS_0(pcib, legacy_pcib_driver, legacy_pcib_methods, 1);
DRIVER_MODULE(pcib, legacy, legacy_pcib_driver, hostb_devclass, 0, 0);
/*
* Install placeholder to claim the resources owned by the
* PCI bus interface. This could be used to extract the
* config space registers in the extreme case where the PnP
* ID is available and the PCI BIOS isn't, but for now we just
* eat the PnP ID and do nothing else.
*
* XXX we should silence this probe, as it will generally confuse
* people.
*/
static struct isa_pnp_id pcibus_pnp_ids[] = {
{ 0x030ad041 /* PNP0A03 */, "PCI Bus" },
{ 0x080ad041 /* PNP0A08 */, "PCIe Bus" },
{ 0 }
};
static int
pcibus_pnp_probe(device_t dev)
{
int result;
if ((result = ISA_PNP_PROBE(device_get_parent(dev), dev, pcibus_pnp_ids)) <= 0)
device_quiet(dev);
return(result);
}
static int
pcibus_pnp_attach(device_t dev)
{
return(0);
}
static device_method_t pcibus_pnp_methods[] = {
/* Device interface */
DEVMETHOD(device_probe, pcibus_pnp_probe),
DEVMETHOD(device_attach, pcibus_pnp_attach),
DEVMETHOD(device_detach, bus_generic_detach),
DEVMETHOD(device_shutdown, bus_generic_shutdown),
DEVMETHOD(device_suspend, bus_generic_suspend),
DEVMETHOD(device_resume, bus_generic_resume),
{ 0, 0 }
};
static devclass_t pcibus_pnp_devclass;
DEFINE_CLASS_0(pcibus_pnp, pcibus_pnp_driver, pcibus_pnp_methods, 1);
DRIVER_MODULE(pcibus_pnp, isa, pcibus_pnp_driver, pcibus_pnp_devclass, 0, 0);

View File

@ -16,7 +16,6 @@
*/
/* Memory Locations */
.set MEM_REL,0x700 # Relocation address
.set MEM_ARG,0x900 # Arguments
.set MEM_ORG,0x7c00 # Origin
.set MEM_BUF,0x8000 # Load area
@ -90,15 +89,6 @@ main: cld # String ops inc
mov %cx,%ds # data
mov %cx,%ss # Set up
mov $start,%sp # stack
/*
* Relocate ourself to MEM_REL. Since %cx == 0, the inc %ch sets
* %cx == 0x100.
*/
mov %sp,%si # Source
mov $MEM_REL,%di # Destination
incb %ch # Word count
rep # Copy
movsw # code
/*
* If we are on a hard drive, then load the MBR and look for the first
* FreeBSD slice. We use the fake partition entry below that points to
@ -106,11 +96,12 @@ main: cld # String ops inc
* FreeBSD slice. The second pass looks for the first non-active FreeBSD
* slice if the first one fails.
*/
mov $part4,%si # Partition
mov $part4,%si # Dummy partition
cmpb $0x80,%dl # Hard drive?
jb main.4 # No
movb $0x1,%dh # Block count
callw nread # Read MBR
xor %eax,%eax # Read MBR
movl $MEM_BUF,%ebx # from first
callw nread # sector
mov $0x1,%cx # Two passes
main.1: mov $MEM_BUF+PRT_OFF,%si # Partition table
movb $0x1,%dh # Partition
@ -139,52 +130,51 @@ main.4: xor %dx,%dx # Partition:drive
/*
* Ok, we have a slice and drive in %dx now, so use that to locate and
* load boot2. %si references the start of the slice we are looking
* for, so go ahead and load up the 64 sectors starting at sector 1024
* for, so go ahead and load up the 128 sectors starting at sector 1024
* (i.e. after the two vdev labels). We don't have do anything fancy
* here to allow for an extra copy of boot1 and a partition table
* (compare to this section of the UFS bootstrap) so we just load it
* all at 0x8000. The first part of boot2 is BTX, which wants to run
* all at 0x9000. The first part of boot2 is BTX, which wants to run
* at 0x9000. The boot2.bin binary starts right after the end of BTX,
* so we have to figure out where the start of it is and then move the
* binary to 0xc000. After we have moved the client, we relocate BTX
* itself to 0x9000 - doing it in this order means that none of the
* memcpy regions overlap which would corrupt the copy. Normally, BTX
* clients start at MEM_USR, or 0xa000, but when we use btxld to
* create zfsboot2, we use an entry point of 0x2000. That entry point is
* relative to MEM_USR; thus boot2.bin starts at 0xc000.
* binary to 0xc000. Normally, BTX clients start at MEM_USR, or 0xa000,
* but when we use btxld to create zfsboot2, we use an entry point of
* 0x2000. That entry point is relative to MEM_USR; thus boot2.bin
* starts at 0xc000.
*
* The load area and the target area for the client overlap so we have
* to use a decrementing string move. We also play segment register
* games with the destination address for the move so that the client
* can be larger than 16k (which would overflow the zero segment since
* the client starts at 0xc000). Relocating BTX is easy since the load
* area and target area do not overlap.
* the client starts at 0xc000).
*/
main.5: mov %dx,MEM_ARG # Save args
movb $NSECT,%dh # Sector count
mov $NSECT,%cx # Sector count
movl $1024,%eax # Offset to boot2
callw nread.1 # Read disk
main.6: mov $MEM_BUF,%si # BTX (before reloc)
mov 0xa(%si),%bx # Get BTX length and set
mov $MEM_BTX,%ebx # Destination buffer
main.6: pushal # Save params
callw nread # Read disk
popal # Restore
incl %eax # Advance to
add $SIZ_SEC,%ebx # next sector
loop main.6 # If not last, read another
mov MEM_BTX+0xa,%bx # Get BTX length
mov $NSECT*SIZ_SEC-1,%di # Size of load area (less one)
mov %di,%si # End of load
add $MEM_BUF,%si # area
mov %di,%si # End of load area, 0x9000 rel
sub %bx,%di # End of client, 0xc000 rel
mov %di,%cx # Size of
inc %cx # client
mov $(MEM_BTX)>>4,%dx # Segment
mov %dx,%ds # addressing 0x9000
mov $(MEM_USR+2*SIZ_PAG)>>4,%dx # Segment
mov %dx,%es # addressing 0xc000
std # Move with decrement
rep # Relocate
movsb # client
mov %ds,%dx # Back to
mov %dx,%es # zero segment
mov $MEM_BUF,%si # BTX (before reloc)
mov $MEM_BTX,%di # BTX
mov %bx,%cx # Get BTX length
cld # Increment this time
rep # Relocate
movsb # BTX
cld # Back to increment
xor %dx,%dx # Back
mov %ds,%dx # to zero
mov %dx,%es # segment
/*
* Enable A20 so we can access memory above 1 meg.
@ -211,32 +201,35 @@ seta20.3: sti # Enable interrupts
/*
* Trampoline used to call read from within zfsldr. Sets up an EDD
* packet on the stack and passes it to read.
* packet on the stack and passes it to read. We assume that the
* destination address is always segment-aligned.
*
* %eax - int - LBA to read in relative to partition start
* %ebx - ptr - destination address
* %dl - byte - drive to read from
* %dh - byte - num sectors to read
* %si - ptr - MBR partition entry
*/
nread: xor %eax,%eax # Sector offset in partition
nread.1: xor %ecx,%ecx # Get
nread: xor %ecx,%ecx # Get
addl 0x8(%si),%eax # LBA
adc $0,%ecx
pushl %ecx # Starting absolute block
pushl %eax # block number
push %es # Address of
push $MEM_BUF # transfer buffer
xor %ax,%ax # Number of
movb %dh,%al # blocks to
push %ax # transfer
shr $4,%ebx # Convert to segment
push %bx # Address of
push $0 # transfer buffer
push $0x1 # Read 1 sector
push $0x10 # Size of packet
mov %sp,%bp # Packet pointer
callw read # Read from disk
jc nread.1 # If error, fail
lea 0x10(%bp),%sp # Clear stack
jnc return # If success, return
mov $msg_read,%si # Otherwise, set the error
# message and fall through to
# the error routine
ret # If success, return
nread.1: mov %ah,%al # Format
mov $read_err,%di # error
call hex8 # code
mov $msg_read,%si # Set the error message and
# fall through to the error
# routine
/*
* Print out the error message pointed to by %ds:(%si) followed
* by a prompt, wait for a keypress, and then reboot the machine.
@ -258,14 +251,6 @@ putstr: lodsb # Get char
testb %al,%al # End of string?
jne putstr.0 # No
/*
* Overused return code. ereturn is used to return an error from the
* read function. Since we assume putstr succeeds, we (ab)use the
* same code when we return from putstr.
*/
ereturn: movb $0x1,%ah # Invalid
stc # argument
return: retw # To caller
/*
* Reads sectors from the disk. If EDD is enabled, then check if it is
* installed and use it if it is. If it is not installed or not enabled, then
@ -294,14 +279,30 @@ read: cmpb $0x80,%dl # Hard drive?
retw # To caller
read.1: mov $msg_chs,%si
jmp error
msg_chs: .asciz "CHS not supported"
/*
* AL to hex, saving the result to [EDI].
*/
hex8: push %ax # Save
shrb $0x4,%al # Do upper
call hex8.1 # 4
pop %ax # Restore
hex8.1: andb $0xf,%al # Get lower 4
cmpb $0xa,%al # Convert
sbbb $0x69,%al # to hex
das # digit
orb $0x20,%al # To lower case
stosb # Save char
ret # (Recursive)
/* Messages */
msg_read: .asciz "Read"
msg_part: .asciz "Boot"
msg_chs: .asciz "CHS not supported"
msg_read: .ascii "Read error: "
read_err: .asciz "XX"
msg_part: .asciz "Boot error"
prompt: .asciz " error\r\n"
prompt: .asciz "\r\n"
.org PRT_OFF,0x90

View File

@ -1600,6 +1600,34 @@ ata_device_transport(struct cam_path *path)
xpt_action((union ccb *)&cts);
}
static void
ata_dev_advinfo(union ccb *start_ccb)
{
struct cam_ed *device;
struct ccb_dev_advinfo *cdai;
off_t amt;
start_ccb->ccb_h.status = CAM_REQ_INVALID;
device = start_ccb->ccb_h.path->device;
cdai = &start_ccb->cdai;
switch(cdai->buftype) {
case CDAI_TYPE_SERIAL_NUM:
if (cdai->flags & CDAI_FLAG_STORE)
break;
start_ccb->ccb_h.status = CAM_REQ_CMP;
cdai->provsiz = device->serial_num_len;
if (device->serial_num_len == 0)
break;
amt = device->serial_num_len;
if (cdai->provsiz > cdai->bufsiz)
amt = cdai->bufsiz;
memcpy(cdai->buf, device->serial_num, amt);
break;
default:
break;
}
}
static void
ata_action(union ccb *start_ccb)
{
@ -1650,7 +1678,13 @@ ata_action(union ccb *start_ccb)
xpt_done(start_ccb);
break;
}
/* FALLTHROUGH */
xpt_action_default(start_ccb);
break;
}
case XPT_DEV_ADVINFO:
{
ata_dev_advinfo(start_ccb);
break;
}
default:
xpt_action_default(start_ccb);

View File

@ -2440,12 +2440,13 @@ scsi_dev_advinfo(union ccb *start_ccb)
struct ccb_dev_advinfo *cdai;
off_t amt;
start_ccb->ccb_h.status = CAM_REQ_INVALID;
device = start_ccb->ccb_h.path->device;
cdai = &start_ccb->cdai;
switch(cdai->buftype) {
case CDAI_TYPE_SCSI_DEVID:
if (cdai->flags & CDAI_FLAG_STORE)
break;
return;
cdai->provsiz = device->device_id_len;
if (device->device_id_len == 0)
break;
@ -2456,7 +2457,7 @@ scsi_dev_advinfo(union ccb *start_ccb)
break;
case CDAI_TYPE_SERIAL_NUM:
if (cdai->flags & CDAI_FLAG_STORE)
break;
return;
cdai->provsiz = device->serial_num_len;
if (device->serial_num_len == 0)
break;
@ -2490,7 +2491,7 @@ scsi_dev_advinfo(union ccb *start_ccb)
}
break;
default:
break;
return;
}
start_ccb->ccb_h.status = CAM_REQ_CMP;

View File

@ -1991,8 +1991,12 @@ dev/usb/quirk/usb_quirk.c optional usb
#
# USB templates
#
dev/usb/template/usb_template.c optional usb_template
dev/usb/template/usb_template.c optional usb_template
dev/usb/template/usb_template_audio.c optional usb_template
dev/usb/template/usb_template_cdce.c optional usb_template
dev/usb/template/usb_template_kbd.c optional usb_template
dev/usb/template/usb_template_modem.c optional usb_template
dev/usb/template/usb_template_mouse.c optional usb_template
dev/usb/template/usb_template_msc.c optional usb_template
dev/usb/template/usb_template_mtp.c optional usb_template
#

View File

@ -128,7 +128,6 @@ amd64/amd64/trap.c standard
amd64/amd64/uio_machdep.c standard
amd64/amd64/uma_machdep.c standard
amd64/amd64/vm_machdep.c standard
amd64/pci/pci_bus.c optional pci
amd64/pci/pci_cfgreg.c optional pci
crypto/aesni/aesencdec_amd64.S optional aesni
crypto/aesni/aeskeys_amd64.S optional aesni
@ -315,7 +314,8 @@ x86/isa/isa.c standard
x86/isa/isa_dma.c standard
x86/isa/nmi.c standard
x86/isa/orm.c optional isa
x86/pci/qpi.c standard
x86/pci/pci_bus.c optional pci
x86/pci/qpi.c optional pci
x86/x86/busdma_machdep.c standard
x86/x86/dump_machdep.c standard
x86/x86/io_apic.c standard

View File

@ -352,7 +352,6 @@ i386/linux/linux_support.s optional compat_linux \
dependency "linux_assym.h"
i386/linux/linux_sysent.c optional compat_linux
i386/linux/linux_sysvec.c optional compat_linux
i386/pci/pci_bus.c optional pci
i386/pci/pci_cfgreg.c optional pci
i386/pci/pci_pir.c optional pci
i386/svr4/svr4_locore.s optional compat_svr4 \
@ -405,7 +404,8 @@ x86/isa/isa.c optional isa
x86/isa/isa_dma.c optional isa
x86/isa/nmi.c standard
x86/isa/orm.c optional isa
x86/pci/qpi.c standard
x86/pci/pci_bus.c optional pci
x86/pci/qpi.c optional pci
x86/x86/busdma_machdep.c standard
x86/x86/dump_machdep.c standard
x86/x86/io_apic.c optional apic

View File

@ -199,7 +199,6 @@ i386/linux/linux_support.s optional compat_linux \
dependency "linux_assym.h"
i386/linux/linux_sysent.c optional compat_linux
i386/linux/linux_sysvec.c optional compat_linux
i386/pci/pci_bus.c optional pci
i386/pci/pci_cfgreg.c optional pci
i386/pci/pci_pir.c optional pci
i386/svr4/svr4_locore.s optional compat_svr4 \
@ -249,6 +248,7 @@ pc98/pc98/pc98_machdep.c standard
x86/isa/atpic.c optional atpic
x86/isa/clock.c standard
x86/isa/isa.c optional isa
x86/pci/pci_bus.c optional pci
x86/x86/busdma_machdep.c standard
x86/x86/dump_machdep.c standard
x86/x86/io_apic.c optional apic

View File

@ -1244,7 +1244,7 @@ acpi_alloc_resource(device_t bus, device_t child, int type, int *rid,
/*
* First attempt at allocating the resource. For direct children,
* use resource_list_alloc() to handle reserved resources. For
* other dveices, pass the request up to our parent.
* other devices, pass the request up to our parent.
*/
if (bus == device_get_parent(child)) {
ad = device_get_ivars(child);

View File

@ -856,8 +856,10 @@ acpi_cpu_cx_list(struct acpi_cpu_softc *sc)
sbuf_printf(&sb, "C%d/%d ", i + 1, sc->cpu_cx_states[i].trans_lat);
if (sc->cpu_cx_states[i].type < ACPI_STATE_C3)
sc->cpu_non_c3 = i;
#ifndef __ia64__
else
cpu_can_deep_sleep = 1;
#endif
}
sbuf_trim(&sb);
sbuf_finish(&sb);

View File

@ -76,33 +76,6 @@ extern void DO_HALDEBUG(struct ath_hal *ah, u_int mask, const char* fmt, ...);
/* NB: put this here instead of the driver to avoid circular references */
SYSCTL_NODE(_hw, OID_AUTO, ath, CTLFLAG_RD, 0, "Atheros driver parameters");
SYSCTL_NODE(_hw_ath, OID_AUTO, hal, CTLFLAG_RD, 0, "Atheros HAL parameters");
#ifdef AH_DEBUG
int ath_hal_debug = 0;
SYSCTL_INT(_hw_ath_hal, OID_AUTO, debug, CTLFLAG_RW, &ath_hal_debug,
0, "Atheros HAL debugging printfs");
TUNABLE_INT("hw.ath.hal.debug", &ath_hal_debug);
#endif /* AH_DEBUG */
int ath_hal_ar5416_biasadj = 0;
SYSCTL_INT(_hw_ath_hal, OID_AUTO, ar5416_biasadj, CTLFLAG_RW,
&ath_hal_ar5416_biasadj, 0, "Enable 2ghz AR5416 direction sensitivity"
" bias adjust");
/* NB: these are deprecated; they exist for now for compatibility */
int ath_hal_dma_beacon_response_time = 2; /* in TU's */
SYSCTL_INT(_hw_ath_hal, OID_AUTO, dma_brt, CTLFLAG_RW,
&ath_hal_dma_beacon_response_time, 0,
"Atheros HAL DMA beacon response time");
int ath_hal_sw_beacon_response_time = 10; /* in TU's */
SYSCTL_INT(_hw_ath_hal, OID_AUTO, sw_brt, CTLFLAG_RW,
&ath_hal_sw_beacon_response_time, 0,
"Atheros HAL software beacon response time");
int ath_hal_additional_swba_backoff = 0; /* in TU's */
SYSCTL_INT(_hw_ath_hal, OID_AUTO, swba_backoff, CTLFLAG_RW,
&ath_hal_additional_swba_backoff, 0,
"Atheros HAL additional SWBA backoff time");
MALLOC_DEFINE(M_ATH_HAL, "ath_hal", "ath hal data");
@ -146,7 +119,7 @@ ath_hal_ether_sprintf(const u_int8_t *mac)
void
DO_HALDEBUG(struct ath_hal *ah, u_int mask, const char* fmt, ...)
{
if ((mask == HAL_DEBUG_UNMASKABLE) || (ath_hal_debug & mask)) {
if ((mask == HAL_DEBUG_UNMASKABLE) || (ah->ah_config.ah_debug & mask)) {
__va_list ap;
va_start(ap, fmt);
ath_hal_vprintf(ah, fmt, ap);
@ -174,6 +147,8 @@ DO_HALDEBUG(struct ath_hal *ah, u_int mask, const char* fmt, ...)
#include <sys/pcpu.h>
#include <dev/ath/ath_hal/ah_decode.h>
SYSCTL_NODE(_hw_ath, OID_AUTO, hal, CTLFLAG_RD, 0, "Atheros HAL parameters");
static struct alq *ath_hal_alq;
static int ath_hal_alq_emitdev; /* need to emit DEVICE record */
static u_int ath_hal_alq_lost; /* count of lost records */

View File

@ -756,6 +756,17 @@ struct dfs_event {
};
typedef struct dfs_event HAL_DFS_EVENT;
typedef struct
{
int ah_debug; /* only used if AH_DEBUG is defined */
int ah_ar5416_biasadj; /* enable AR2133 radio specific bias fiddling */
/* NB: these are deprecated; they exist for now for compatibility */
int ah_dma_beacon_response_time;/* in TU's */
int ah_sw_beacon_response_time; /* in TU's */
int ah_additional_swba_backoff; /* in TU's */
}HAL_OPS_CONFIG;
/*
* Hardware Access Layer (HAL) API.
*
@ -784,6 +795,7 @@ struct ath_hal {
uint16_t *ah_eepromdata; /* eeprom buffer, if needed */
HAL_OPS_CONFIG ah_config;
const HAL_RATE_TABLE *__ahdecl(*ah_getRateTable)(struct ath_hal *,
u_int mode);
void __ahdecl(*ah_detach)(struct ath_hal*);

View File

@ -475,12 +475,6 @@ isBigEndian(void)
#define OS_A_REG_RMW_FIELD(_a, _r, _f, _v) \
do { OS_REG_WRITE(_a, _r, (OS_REG_READ(_a, _r) &~ (_f)) | (((_v) << _f##_S) & (_f))) ; OS_DELAY(100); } while (0)
/* system-configurable parameters */
extern int ath_hal_dma_beacon_response_time; /* in TU's */
extern int ath_hal_sw_beacon_response_time; /* in TU's */
extern int ath_hal_additional_swba_backoff; /* in TU's */
extern int ath_hal_ar5416_biasadj; /* 1 or 0 */
/* wait for the register contents to have the specified value */
extern HAL_BOOL ath_hal_wait(struct ath_hal *, u_int reg,
uint32_t mask, uint32_t val);
@ -504,11 +498,29 @@ extern void ath_hal_free(void *);
/* common debugging interfaces */
#ifdef AH_DEBUG
#include "ah_debug.h"
extern int ath_hal_debug;
extern int ath_hal_debug; /* Global debug flags */
/*
* This is used for global debugging, when ahp doesn't yet have the
* related debugging state. For example, during probe/attach.
*/
#define HALDEBUG_G(_ah, __m, ...) \
do { \
if ((__m) == HAL_DEBUG_UNMASKABLE || \
ath_hal_debug & (__m)) { \
DO_HALDEBUG((_ah), (__m), __VA_ARGS__); \
} \
} while (0);
/*
* This is used for local debugging, when ahp isn't NULL and
* thus may have debug flags set.
*/
#define HALDEBUG(_ah, __m, ...) \
do { \
if ((__m) == HAL_DEBUG_UNMASKABLE || \
(ath_hal_debug & (__m))) { \
ath_hal_debug & (__m) || \
(_ah)->ah_config.ah_debug & (__m)) { \
DO_HALDEBUG((_ah), (__m), __VA_ARGS__); \
} \
} while(0);
@ -517,6 +529,7 @@ extern void DO_HALDEBUG(struct ath_hal *ah, u_int mask, const char* fmt, ...)
__printflike(3,4);
#else
#define HALDEBUG(_ah, __m, _fmt, ...)
#define HALDEBUG_G(_ah, __m, _fmt, ...)
#endif /* AH_DEBUG */
/*

View File

@ -167,7 +167,7 @@ isEepromValid(struct ath_hal *ah)
if (regDomainPairs[i].regDmnEnum == rd)
return AH_TRUE;
}
HALDEBUG(ah, HAL_DEBUG_REGDOMAIN,
HALDEBUG_G(ah, HAL_DEBUG_REGDOMAIN,
"%s: invalid regulatory domain/country code 0x%x\n", __func__, rd);
return AH_FALSE;
}
@ -609,7 +609,7 @@ ath_hal_mapgsm(int sku, int freq)
return 1544 + freq;
if (sku == SKU_SR9)
return 3344 - freq;
HALDEBUG(AH_NULL, HAL_DEBUG_ANY,
HALDEBUG_G(AH_NULL, HAL_DEBUG_ANY,
"%s: cannot map freq %u unknown gsm sku %u\n",
__func__, freq, sku);
return freq;

View File

@ -181,14 +181,14 @@ ar5210Attach(uint16_t devid, HAL_SOFTC sc, HAL_BUS_TAG st, HAL_BUS_HANDLE sh,
HAL_STATUS ecode;
int i;
HALDEBUG(AH_NULL, HAL_DEBUG_ATTACH,
HALDEBUG_G(AH_NULL, HAL_DEBUG_ATTACH,
"%s: devid 0x%x sc %p st %p sh %p\n", __func__, devid,
sc, (void*) st, (void*) sh);
/* NB: memory is returned zero'd */
ahp = ath_hal_malloc(sizeof (struct ath_hal_5210));
if (ahp == AH_NULL) {
HALDEBUG(AH_NULL, HAL_DEBUG_ANY,
HALDEBUG_G(AH_NULL, HAL_DEBUG_ANY,
"%s: no memory for state block\n", __func__);
ecode = HAL_ENOMEM;
goto bad;

View File

@ -56,9 +56,9 @@ ar5210BeaconInit(struct ath_hal *ah,
if (AH_PRIVATE(ah)->ah_opmode != HAL_M_STA) {
bt.bt_nextdba = (next_beacon -
ath_hal_dma_beacon_response_time) << 3; /* 1/8 TU */
ah->ah_config.ah_dma_beacon_response_time) << 3; /* 1/8 TU */
bt.bt_nextswba = (next_beacon -
ath_hal_sw_beacon_response_time) << 3; /* 1/8 TU */
ah->ah_config.ah_sw_beacon_response_time) << 3; /* 1/8 TU */
/*
* The SWBA interrupt is not used for beacons in ad hoc mode
* as we don't yet support ATIMs. So since the beacon never

View File

@ -200,13 +200,13 @@ ar5211Attach(uint16_t devid, HAL_SOFTC sc,
uint16_t eeval;
HAL_STATUS ecode;
HALDEBUG(AH_NULL, HAL_DEBUG_ATTACH, "%s: sc %p st %p sh %p\n",
HALDEBUG_G(AH_NULL, HAL_DEBUG_ATTACH, "%s: sc %p st %p sh %p\n",
__func__, sc, (void*) st, (void*) sh);
/* NB: memory is returned zero'd */
ahp = ath_hal_malloc(sizeof (struct ath_hal_5211));
if (ahp == AH_NULL) {
HALDEBUG(AH_NULL, HAL_DEBUG_ANY,
HALDEBUG_G(AH_NULL, HAL_DEBUG_ANY,
"%s: cannot allocate memory for state block\n", __func__);
ecode = HAL_ENOMEM;
goto bad;

View File

@ -71,9 +71,9 @@ ar5211BeaconInit(struct ath_hal *ah,
case HAL_M_IBSS:
case HAL_M_HOSTAP:
bt.bt_nextdba = (next_beacon -
ath_hal_dma_beacon_response_time) << 3; /* 1/8 TU */
ah->ah_config.ah_dma_beacon_response_time) << 3; /* 1/8 TU */
bt.bt_nextswba = (next_beacon -
ath_hal_sw_beacon_response_time) << 3; /* 1/8 TU */
ah->ah_config.ah_sw_beacon_response_time) << 3; /* 1/8 TU */
break;
}
/*

View File

@ -345,8 +345,9 @@ ar5211ResetTxQueue(struct ath_hal *ah, u_int q)
| AR_Q_MISC_CBR_INCR_DIS0 | AR_Q_MISC_RDYTIME_EXP_POLICY);
value = (ahp->ah_beaconInterval
- (ath_hal_sw_beacon_response_time - ath_hal_dma_beacon_response_time)
- ath_hal_additional_swba_backoff) * 1024;
- (ah->ah_config.ah_sw_beacon_response_time
- ah->ah_config.ah_dma_beacon_response_time)
- ah->ah_config.ah_additional_swba_backoff) * 1024;
OS_REG_WRITE(ah, AR_QRDYTIMECFG(q), value | AR_Q_RDYTIMECFG_EN);
/* Configure DCU for CAB */

View File

@ -611,7 +611,7 @@ getFullPwrTable(uint16_t numPcdacs, uint16_t *pcdacs, int16_t *power, int16_t ma
uint16_t idxR = 1;
if (numPcdacs < 2) {
HALDEBUG(AH_NULL, HAL_DEBUG_ANY,
HALDEBUG_G(AH_NULL, HAL_DEBUG_ANY,
"%s: at least 2 pcdac values needed [%d]\n",
__func__, numPcdacs);
return AH_FALSE;

View File

@ -317,13 +317,13 @@ ar5212Attach(uint16_t devid, HAL_SOFTC sc,
uint16_t eeval;
HAL_STATUS ecode;
HALDEBUG(AH_NULL, HAL_DEBUG_ATTACH, "%s: sc %p st %p sh %p\n",
HALDEBUG_G(AH_NULL, HAL_DEBUG_ATTACH, "%s: sc %p st %p sh %p\n",
__func__, sc, (void*) st, (void*) sh);
/* NB: memory is returned zero'd */
ahp = ath_hal_malloc(sizeof (struct ath_hal_5212));
if (ahp == AH_NULL) {
HALDEBUG(AH_NULL, HAL_DEBUG_ANY,
HALDEBUG_G(AH_NULL, HAL_DEBUG_ANY,
"%s: cannot allocate memory for state block\n", __func__);
*status = HAL_ENOMEM;
return AH_NULL;

View File

@ -84,9 +84,9 @@ ar5212BeaconInit(struct ath_hal *ah,
case HAL_M_HOSTAP:
case HAL_M_IBSS:
bt.bt_nextdba = (next_beacon -
ath_hal_dma_beacon_response_time) << 3; /* 1/8 TU */
ah->ah_config.ah_dma_beacon_response_time) << 3; /* 1/8 TU */
bt.bt_nextswba = (next_beacon -
ath_hal_sw_beacon_response_time) << 3; /* 1/8 TU */
ah->ah_config.ah_sw_beacon_response_time) << 3; /* 1/8 TU */
break;
}
/*

View File

@ -416,9 +416,9 @@ ar5212ResetTxQueue(struct ath_hal *ah, u_int q)
* here solely for backwards compatibility.
*/
value = (ahp->ah_beaconInterval
- (ath_hal_sw_beacon_response_time -
ath_hal_dma_beacon_response_time)
- ath_hal_additional_swba_backoff) * 1024;
- (ah->ah_config.ah_sw_beacon_response_time -
ah->ah_config.ah_dma_beacon_response_time)
- ah->ah_config.ah_additional_swba_backoff) * 1024;
OS_REG_WRITE(ah, AR_QRDYTIMECFG(q), value | AR_Q_RDYTIMECFG_ENA);
}
dmisc |= SM(AR_D_MISC_ARB_LOCKOUT_CNTRL_GLOBAL,

View File

@ -71,13 +71,13 @@ ar5312Attach(uint16_t devid, HAL_SOFTC sc,
uint16_t eeval;
HAL_STATUS ecode;
HALDEBUG(AH_NULL, HAL_DEBUG_ATTACH, "%s: sc %p st %p sh %p\n",
HALDEBUG_G(AH_NULL, HAL_DEBUG_ATTACH, "%s: sc %p st %p sh %p\n",
__func__, sc, st, (void*) sh);
/* NB: memory is returned zero'd */
ahp = ath_hal_malloc(sizeof (struct ath_hal_5212));
if (ahp == AH_NULL) {
HALDEBUG(AH_NULL, HAL_DEBUG_ANY,
HALDEBUG_G(AH_NULL, HAL_DEBUG_ANY,
"%s: cannot allocate memory for state block\n", __func__);
*status = HAL_ENOMEM;
return AH_NULL;

View File

@ -185,7 +185,7 @@ ar2133SetChannel(struct ath_hal *ah, const struct ieee80211_channel *chan)
}
/* Workaround for hw bug - AR5416 specific */
if (AR_SREV_OWL(ah) && ath_hal_ar5416_biasadj)
if (AR_SREV_OWL(ah) && ah->ah_config.ah_ar5416_biasadj)
ar2133ForceBias(ah, freq);
reg32 = (channelSel << 8) | (aModeRefSel << 2) | (bModeSynth << 1) |

View File

@ -241,7 +241,7 @@ ar5416Attach(uint16_t devid, HAL_SOFTC sc,
HAL_STATUS ecode;
HAL_BOOL rfStatus;
HALDEBUG(AH_NULL, HAL_DEBUG_ATTACH, "%s: sc %p st %p sh %p\n",
HALDEBUG_G(AH_NULL, HAL_DEBUG_ATTACH, "%s: sc %p st %p sh %p\n",
__func__, sc, (void*) st, (void*) sh);
/* NB: memory is returned zero'd */
@ -250,7 +250,7 @@ ar5416Attach(uint16_t devid, HAL_SOFTC sc,
sizeof(ar5416Addac)
);
if (ahp5416 == AH_NULL) {
HALDEBUG(AH_NULL, HAL_DEBUG_ANY,
HALDEBUG_G(AH_NULL, HAL_DEBUG_ANY,
"%s: cannot allocate memory for state block\n", __func__);
*status = HAL_ENOMEM;
return AH_NULL;

View File

@ -93,9 +93,9 @@ ar5416BeaconInit(struct ath_hal *ah,
/* fall thru... */
case HAL_M_HOSTAP:
bt.bt_nextdba = (next_beacon -
ath_hal_dma_beacon_response_time) << 3; /* 1/8 TU */
ah->ah_config.ah_dma_beacon_response_time) << 3; /* 1/8 TU */
bt.bt_nextswba = (next_beacon -
ath_hal_sw_beacon_response_time) << 3; /* 1/8 TU */
ah->ah_config.ah_sw_beacon_response_time) << 3; /* 1/8 TU */
bt.bt_flags |= AR_TIMER_MODE_TBTT
| AR_TIMER_MODE_DBA
| AR_TIMER_MODE_SWBA;

View File

@ -288,7 +288,7 @@ ar5416SetQuiet(struct ath_hal *ah, uint32_t period, uint32_t duration,
nextStart_us += OS_REG_READ(ah, AR_TSF_L32);
}
if (flag & HAL_QUIET_ADD_SWBA_RESP_TIME) {
nextStart_us += ath_hal_sw_beacon_response_time;
nextStart_us += ah->ah_config.ah_sw_beacon_response_time;
}
OS_REG_RMW_FIELD(ah, AR_QUIET1, AR_QUIET1_QUIET_ACK_CTS_ENABLE, 1);
OS_REG_WRITE(ah, AR_QUIET2, SM(duration, AR_QUIET2_QUIET_DUR));

View File

@ -1035,9 +1035,9 @@ ar5416ResetTxQueue(struct ath_hal *ah, u_int q)
* here solely for backwards compatibility.
*/
value = (ahp->ah_beaconInterval
- (ath_hal_sw_beacon_response_time -
ath_hal_dma_beacon_response_time)
- ath_hal_additional_swba_backoff) * 1024;
- (ah->ah_config.ah_sw_beacon_response_time -
ah->ah_config.ah_dma_beacon_response_time)
- ah->ah_config.ah_additional_swba_backoff) * 1024;
OS_REG_WRITE(ah, AR_QRDYTIMECFG(q), value | AR_Q_RDYTIMECFG_ENA);
}
dmisc |= SM(AR_D_MISC_ARB_LOCKOUT_CNTRL_GLOBAL,

View File

@ -78,13 +78,13 @@ ar9130Attach(uint16_t devid, HAL_SOFTC sc,
HAL_STATUS ecode;
HAL_BOOL rfStatus;
HALDEBUG(AH_NULL, HAL_DEBUG_ATTACH, "%s: sc %p st %p sh %p\n",
HALDEBUG_G(AH_NULL, HAL_DEBUG_ATTACH, "%s: sc %p st %p sh %p\n",
__func__, sc, (void*) st, (void*) sh);
/* NB: memory is returned zero'd */
ahp5416 = ath_hal_malloc(sizeof (struct ath_hal_5416));
if (ahp5416 == AH_NULL) {
HALDEBUG(AH_NULL, HAL_DEBUG_ANY,
HALDEBUG_G(AH_NULL, HAL_DEBUG_ANY,
"%s: cannot allocate memory for state block\n", __func__);
*status = HAL_ENOMEM;
return AH_NULL;

View File

@ -101,13 +101,13 @@ ar9160Attach(uint16_t devid, HAL_SOFTC sc,
HAL_STATUS ecode;
HAL_BOOL rfStatus;
HALDEBUG(AH_NULL, HAL_DEBUG_ATTACH, "%s: sc %p st %p sh %p\n",
HALDEBUG_G(AH_NULL, HAL_DEBUG_ATTACH, "%s: sc %p st %p sh %p\n",
__func__, sc, (void*) st, (void*) sh);
/* NB: memory is returned zero'd */
ahp5416 = ath_hal_malloc(sizeof (struct ath_hal_5416));
if (ahp5416 == AH_NULL) {
HALDEBUG(AH_NULL, HAL_DEBUG_ANY,
HALDEBUG_G(AH_NULL, HAL_DEBUG_ANY,
"%s: cannot allocate memory for state block\n", __func__);
*status = HAL_ENOMEM;
return AH_NULL;

View File

@ -120,13 +120,13 @@ ar9280Attach(uint16_t devid, HAL_SOFTC sc,
int8_t pwr_table_offset;
uint8_t pwr;
HALDEBUG(AH_NULL, HAL_DEBUG_ATTACH, "%s: sc %p st %p sh %p\n",
HALDEBUG_G(AH_NULL, HAL_DEBUG_ATTACH, "%s: sc %p st %p sh %p\n",
__func__, sc, (void*) st, (void*) sh);
/* NB: memory is returned zero'd */
ahp9280 = ath_hal_malloc(sizeof (struct ath_hal_9280));
if (ahp9280 == AH_NULL) {
HALDEBUG(AH_NULL, HAL_DEBUG_ANY,
HALDEBUG_G(AH_NULL, HAL_DEBUG_ANY,
"%s: cannot allocate memory for state block\n", __func__);
*status = HAL_ENOMEM;
return AH_NULL;

View File

@ -118,13 +118,13 @@ ar9285Attach(uint16_t devid, HAL_SOFTC sc,
HAL_STATUS ecode;
HAL_BOOL rfStatus;
HALDEBUG(AH_NULL, HAL_DEBUG_ATTACH, "%s: sc %p st %p sh %p\n",
HALDEBUG_G(AH_NULL, HAL_DEBUG_ATTACH, "%s: sc %p st %p sh %p\n",
__func__, sc, (void*) st, (void*) sh);
/* NB: memory is returned zero'd */
ahp9285 = ath_hal_malloc(sizeof (struct ath_hal_9285));
if (ahp9285 == AH_NULL) {
HALDEBUG(AH_NULL, HAL_DEBUG_ANY,
HALDEBUG_G(AH_NULL, HAL_DEBUG_ANY,
"%s: cannot allocate memory for state block\n", __func__);
*status = HAL_ENOMEM;
return AH_NULL;

View File

@ -119,13 +119,13 @@ ar9287Attach(uint16_t devid, HAL_SOFTC sc,
HAL_BOOL rfStatus;
int8_t pwr_table_offset;
HALDEBUG(AH_NULL, HAL_DEBUG_ATTACH, "%s: sc %p st %p sh %p\n",
HALDEBUG_G(AH_NULL, HAL_DEBUG_ATTACH, "%s: sc %p st %p sh %p\n",
__func__, sc, (void*) st, (void*) sh);
/* NB: memory is returned zero'd */
ahp9287 = ath_hal_malloc(sizeof (struct ath_hal_9287));
if (ahp9287 == AH_NULL) {
HALDEBUG(AH_NULL, HAL_DEBUG_ANY,
HALDEBUG_G(AH_NULL, HAL_DEBUG_ANY,
"%s: cannot allocate memory for state block\n", __func__);
*status = HAL_ENOMEM;
return AH_NULL;

View File

@ -738,6 +738,7 @@ ath_attach(u_int16_t devid, struct ath_softc *sc)
*/
ath_sysctlattach(sc);
ath_sysctl_stats_attach(sc);
ath_sysctl_hal_attach(sc);
if (bootverbose)
ieee80211_announce(ic);

View File

@ -719,3 +719,43 @@ ath_sysctl_stats_attach(struct ath_softc *sc)
/* Attach the RX phy error array */
ath_sysctl_stats_attach_rxphyerr(sc, child);
}
/*
* This doesn't necessarily belong here (because it's HAL related, not
* driver related).
*/
void
ath_sysctl_hal_attach(struct ath_softc *sc)
{
struct sysctl_oid *tree = device_get_sysctl_tree(sc->sc_dev);
struct sysctl_ctx_list *ctx = device_get_sysctl_ctx(sc->sc_dev);
struct sysctl_oid_list *child = SYSCTL_CHILDREN(tree);
tree = SYSCTL_ADD_NODE(ctx, child, OID_AUTO, "hal", CTLFLAG_RD,
NULL, "Atheros HAL parameters");
child = SYSCTL_CHILDREN(tree);
sc->sc_ah->ah_config.ah_debug = 0;
SYSCTL_ADD_INT(ctx, child, OID_AUTO, "debug", CTLFLAG_RW,
&sc->sc_ah->ah_config.ah_debug, 0, "Atheros HAL debugging printfs");
sc->sc_ah->ah_config.ah_ar5416_biasadj = 0;
SYSCTL_ADD_INT(ctx, child, OID_AUTO, "ar5416_biasadj", CTLFLAG_RW,
&sc->sc_ah->ah_config.ah_ar5416_biasadj, 0,
"Enable 2ghz AR5416 direction sensitivity bias adjust");
sc->sc_ah->ah_config.ah_dma_beacon_response_time = 2;
SYSCTL_ADD_INT(ctx, child, OID_AUTO, "dma_brt", CTLFLAG_RW,
&sc->sc_ah->ah_config.ah_dma_beacon_response_time, 0,
"Atheros HAL DMA beacon response time");
sc->sc_ah->ah_config.ah_sw_beacon_response_time = 10;
SYSCTL_ADD_INT(ctx, child, OID_AUTO, "sw_brt", CTLFLAG_RW,
&sc->sc_ah->ah_config.ah_sw_beacon_response_time, 0,
"Atheros HAL software beacon response time");
sc->sc_ah->ah_config.ah_additional_swba_backoff = 0;
SYSCTL_ADD_INT(ctx, child, OID_AUTO, "swba_backoff", CTLFLAG_RW,
&sc->sc_ah->ah_config.ah_additional_swba_backoff, 0,
"Atheros HAL additional SWBA backoff time");
}

View File

@ -34,5 +34,5 @@
extern void ath_sysctlattach(struct ath_softc *);
extern void ath_sysctl_stats_attach(struct ath_softc *sc);
extern void ath_sysctl_hal_attach(struct ath_softc *sc);
#endif

View File

@ -346,6 +346,10 @@ TUNABLE_INT("hw.igb.hdr_split", &igb_header_split);
static int igb_num_queues = 0;
TUNABLE_INT("hw.igb.num_queues", &igb_num_queues);
/* How many packets rxeof tries to clean at a time */
static int igb_rx_process_limit = 100;
TUNABLE_INT("hw.igb.rx_process_limit", &igb_rx_process_limit);
/*********************************************************************
* Device identification routine
*
@ -465,7 +469,7 @@ igb_attach(device_t dev)
/* Sysctl for limiting the amount of work done in the taskqueue */
igb_set_sysctl_value(adapter, "rx_processing_limit",
"max number of rx packets to process",
&adapter->rx_process_limit, 100);
&adapter->rx_process_limit, igb_rx_process_limit);
/*
* Validate number of transmit and receive descriptors. It

View File

@ -531,6 +531,15 @@ static driver_t uaudio_driver = {
.size = sizeof(struct uaudio_softc),
};
static const STRUCT_USB_HOST_ID __used uaudio_devs[] = {
/* Generic USB audio class match */
{USB_IFACE_CLASS(UICLASS_AUDIO),
USB_IFACE_SUBCLASS(UISUBCLASS_AUDIOCONTROL),},
/* Generic USB MIDI class match */
{USB_IFACE_CLASS(UICLASS_AUDIO),
USB_IFACE_SUBCLASS(UISUBCLASS_MIDISTREAM),},
};
static int
uaudio_probe(device_t dev)
{

View File

@ -240,7 +240,7 @@ struct atp_dev_params {
},
};
static const struct usb_device_id atp_devs[] = {
static const STRUCT_USB_HOST_ID atp_devs[] = {
/* Core Duo MacBook & MacBook Pro */
{ USB_VPI(USB_VENDOR_APPLE, 0x0217, ATP_DEV_PARAMS_0) },
{ USB_VPI(USB_VENDOR_APPLE, 0x0218, ATP_DEV_PARAMS_0) },

View File

@ -607,29 +607,33 @@ uhid_ioctl(struct usb_fifo *fifo, u_long cmd, void *addr,
return (error);
}
static const STRUCT_USB_HOST_ID uhid_devs[] = {
/* generic HID class */
{USB_IFACE_CLASS(UICLASS_HID),},
/* the Xbox 360 gamepad doesn't use the HID class */
{USB_IFACE_CLASS(UICLASS_VENDOR),
USB_IFACE_SUBCLASS(UISUBCLASS_XBOX360_CONTROLLER),
USB_IFACE_PROTOCOL(UIPROTO_XBOX360_GAMEPAD),},
};
static int
uhid_probe(device_t dev)
{
struct usb_attach_arg *uaa = device_get_ivars(dev);
int error;
DPRINTFN(11, "\n");
if (uaa->usb_mode != USB_MODE_HOST) {
if (uaa->usb_mode != USB_MODE_HOST)
return (ENXIO);
}
if (uaa->info.bInterfaceClass != UICLASS_HID) {
/* the Xbox 360 gamepad doesn't use the HID class */
error = usbd_lookup_id_by_uaa(uhid_devs, sizeof(uhid_devs), uaa);
if (error)
return (error);
if ((uaa->info.bInterfaceClass != UICLASS_VENDOR) ||
(uaa->info.bInterfaceSubClass != UISUBCLASS_XBOX360_CONTROLLER) ||
(uaa->info.bInterfaceProtocol != UIPROTO_XBOX360_GAMEPAD)) {
return (ENXIO);
}
}
if (usb_test_quirk(uaa, UQ_HID_IGNORE)) {
if (usb_test_quirk(uaa, UQ_HID_IGNORE))
return (ENXIO);
}
return (BUS_PROBE_GENERIC);
}

View File

@ -110,7 +110,7 @@ SYSCTL_INT(_hw_usb_aue, OID_AUTO, debug, CTLFLAG_RW, &aue_debug, 0,
/*
* Various supported device vendors/products.
*/
static const struct usb_device_id aue_devs[] = {
static const STRUCT_USB_HOST_ID aue_devs[] = {
#define AUE_DEV(v,p,i) { USB_VPI(USB_VENDOR_##v, USB_PRODUCT_##v##_##p, i) }
AUE_DEV(3COM, 3C460B, AUE_FLAG_PII),
AUE_DEV(ABOCOM, DSB650TX_PNA, 0),

View File

@ -133,7 +133,7 @@ SYSCTL_INT(_hw_usb_axe, OID_AUTO, debug, CTLFLAG_RW, &axe_debug, 0,
/*
* Various supported device vendors/products.
*/
static const struct usb_device_id axe_devs[] = {
static const STRUCT_USB_HOST_ID axe_devs[] = {
#define AXE_DEV(v,p,i) { USB_VPI(USB_VENDOR_##v, USB_PRODUCT_##v##_##p, i) }
AXE_DEV(ABOCOM, UF200, 0),
AXE_DEV(ACERCM, EP1427X2, 0),

View File

@ -263,7 +263,7 @@ static const struct usb_ether_methods cdce_ue_methods = {
.ue_setpromisc = cdce_setpromisc,
};
static const struct usb_device_id cdce_devs[] = {
static const STRUCT_USB_HOST_ID cdce_host_devs[] = {
{USB_VPI(USB_VENDOR_ACERLABS, USB_PRODUCT_ACERLABS_M5632, CDCE_FLAG_NO_UNION)},
{USB_VPI(USB_VENDOR_AMBIT, USB_PRODUCT_AMBIT_NTL_250, CDCE_FLAG_NO_UNION)},
{USB_VPI(USB_VENDOR_COMPAQ, USB_PRODUCT_COMPAQ_IPAQLINUX, CDCE_FLAG_NO_UNION)},
@ -277,7 +277,9 @@ static const struct usb_device_id cdce_devs[] = {
{USB_VPI(USB_VENDOR_SHARP, USB_PRODUCT_SHARP_SLA300, CDCE_FLAG_ZAURUS | CDCE_FLAG_NO_UNION)},
{USB_VPI(USB_VENDOR_SHARP, USB_PRODUCT_SHARP_SLC700, CDCE_FLAG_ZAURUS | CDCE_FLAG_NO_UNION)},
{USB_VPI(USB_VENDOR_SHARP, USB_PRODUCT_SHARP_SLC750, CDCE_FLAG_ZAURUS | CDCE_FLAG_NO_UNION)},
};
static const STRUCT_USB_DUAL_ID cdce_dual_devs[] = {
{USB_IF_CSI(UICLASS_CDC, UISUBCLASS_ETHERNET_NETWORKING_CONTROL_MODEL, 0)},
{USB_IF_CSI(UICLASS_CDC, UISUBCLASS_MOBILE_DIRECT_LINE_MODEL, 0)},
{USB_IF_CSI(UICLASS_CDC, UISUBCLASS_NETWORK_CONTROL_MODEL, 0)},
@ -472,8 +474,12 @@ static int
cdce_probe(device_t dev)
{
struct usb_attach_arg *uaa = device_get_ivars(dev);
int error;
return (usbd_lookup_id_by_uaa(cdce_devs, sizeof(cdce_devs), uaa));
error = usbd_lookup_id_by_uaa(cdce_host_devs, sizeof(cdce_host_devs), uaa);
if (error)
error = usbd_lookup_id_by_uaa(cdce_dual_devs, sizeof(cdce_dual_devs), uaa);
return (error);
}
static void

View File

@ -88,7 +88,7 @@ __FBSDID("$FreeBSD$");
/* Belkin F5U111 adapter covered by NETMATE entry */
static const struct usb_device_id cue_devs[] = {
static const STRUCT_USB_HOST_ID cue_devs[] = {
#define CUE_DEV(v,p) { USB_VP(USB_VENDOR_##v, USB_PRODUCT_##v##_##p) }
CUE_DEV(CATC, NETMATE),
CUE_DEV(CATC, NETMATE2),

View File

@ -148,7 +148,7 @@ static const struct usb_ether_methods ipheth_ue_methods = {
USB_IFACE_CLASS(c), USB_IFACE_SUBCLASS(sc), \
USB_IFACE_PROTOCOL(pt)
static const struct usb_device_id ipheth_devs[] = {
static const STRUCT_USB_HOST_ID ipheth_devs[] = {
{IPHETH_ID(USB_VENDOR_APPLE, USB_PRODUCT_APPLE_IPHONE,
IPHETH_USBINTF_CLASS, IPHETH_USBINTF_SUBCLASS,
IPHETH_USBINTF_PROTO)},

View File

@ -100,7 +100,7 @@ __FBSDID("$FreeBSD$");
/*
* Various supported device vendors/products.
*/
static const struct usb_device_id kue_devs[] = {
static const STRUCT_USB_HOST_ID kue_devs[] = {
#define KUE_DEV(v,p) { USB_VP(USB_VENDOR_##v, USB_PRODUCT_##v##_##p) }
KUE_DEV(3COM, 3C19250),
KUE_DEV(3COM, 3C460),

View File

@ -146,7 +146,7 @@ SYSCTL_INT(_hw_usb_mos, OID_AUTO, debug, CTLFLAG_RW, &mos_debug, 0,
/* Various supported device vendors/products. */
static const struct usb_device_id mos_devs[] = {
static const STRUCT_USB_HOST_ID mos_devs[] = {
{USB_VPI(USB_VENDOR_MOSCHIP, USB_PRODUCT_MOSCHIP_MCS7730, MCS7730)},
{USB_VPI(USB_VENDOR_MOSCHIP, USB_PRODUCT_MOSCHIP_MCS7830, MCS7830)},
{USB_VPI(USB_VENDOR_SITECOMEU, USB_PRODUCT_SITECOMEU_LN030, MCS7830)},

View File

@ -108,7 +108,7 @@ SYSCTL_INT(_hw_usb_rue, OID_AUTO, debug, CTLFLAG_RW,
* Various supported device vendors/products.
*/
static const struct usb_device_id rue_devs[] = {
static const STRUCT_USB_HOST_ID rue_devs[] = {
{USB_VPI(USB_VENDOR_MELCO, USB_PRODUCT_MELCO_LUAKTX, 0)},
{USB_VPI(USB_VENDOR_REALTEK, USB_PRODUCT_REALTEK_USBKR100, 0)},
{USB_VPI(USB_VENDOR_OQO, USB_PRODUCT_OQO_ETHER01, 0)},

View File

@ -199,7 +199,7 @@ SYSCTL_INT(_hw_usb_udav, OID_AUTO, debug, CTLFLAG_RW, &udav_debug, 0,
#define UDAV_CLRBIT(sc, reg, x) \
udav_csr_write1(sc, reg, udav_csr_read1(sc, reg) & ~(x))
static const struct usb_device_id udav_devs[] = {
static const STRUCT_USB_HOST_ID udav_devs[] = {
/* ShanTou DM9601 USB NIC */
{USB_VPI(USB_VENDOR_SHANTOU, USB_PRODUCT_SHANTOU_DM9601, 0)},
/* ShanTou ST268 USB NIC */

View File

@ -247,7 +247,7 @@ static char *uhso_port_type_sysctl[] = {
/* ifnet device unit allocations */
static struct unrhdr *uhso_ifnet_unit = NULL;
static const struct usb_device_id uhso_devs[] = {
static const STRUCT_USB_HOST_ID uhso_devs[] = {
#define UHSO_DEV(v,p,i) { USB_VPI(USB_VENDOR_##v, USB_PRODUCT_##v##_##p, i) }
/* Option GlobeSurfer iCON 7.2 */
UHSO_DEV(OPTION, GSICON72, UHSO_STATIC_IFACE),

View File

@ -182,7 +182,7 @@ MODULE_DEPEND(u3g, ucom, 1, 1, 1);
MODULE_DEPEND(u3g, usb, 1, 1, 1);
MODULE_VERSION(u3g, 1);
static const struct usb_device_id u3g_devs[] = {
static const STRUCT_USB_HOST_ID u3g_devs[] = {
#define U3G_DEV(v,p,i) { USB_VPI(USB_VENDOR_##v, USB_PRODUCT_##v##_##p, i) }
U3G_DEV(ACERP, H10, 0),
U3G_DEV(AIRPLUS, MCD650, 0),

View File

@ -170,7 +170,7 @@ MODULE_DEPEND(uark, ucom, 1, 1, 1);
MODULE_DEPEND(uark, usb, 1, 1, 1);
MODULE_VERSION(uark, 1);
static const struct usb_device_id uark_devs[] = {
static const STRUCT_USB_HOST_ID uark_devs[] = {
{USB_VPI(USB_VENDOR_ARKMICRO, USB_PRODUCT_ARKMICRO_ARK3116, 0)},
};

View File

@ -239,7 +239,7 @@ static const struct ucom_callback ubsa_callback = {
.ucom_poll = &ubsa_poll,
};
static const struct usb_device_id ubsa_devs[] = {
static const STRUCT_USB_HOST_ID ubsa_devs[] = {
/* AnyData ADU-500A */
{USB_VPI(USB_VENDOR_ANYDATA, USB_PRODUCT_ANYDATA_ADU_500A, 0)},
/* AnyData ADU-E100A/H */

View File

@ -204,7 +204,7 @@ static const struct uchcom_divider_record dividers[] =
#define NUM_DIVIDERS (sizeof (dividers) / sizeof (dividers[0]))
static const struct usb_device_id uchcom_devs[] = {
static const STRUCT_USB_HOST_ID uchcom_devs[] = {
{USB_VPI(USB_VENDOR_WCH, USB_PRODUCT_WCH_CH341SER, 0)},
{USB_VPI(USB_VENDOR_WCH2, USB_PRODUCT_WCH2_CH341SER, 0)},
};

View File

@ -180,7 +180,7 @@ MODULE_VERSION(ucycom, 1);
/*
* Supported devices
*/
static const struct usb_device_id ucycom_devs[] = {
static const STRUCT_USB_HOST_ID ucycom_devs[] = {
{USB_VPI(USB_VENDOR_DELORME, USB_PRODUCT_DELORME_EARTHMATE, MODEL_CY7C64013)},
};

View File

@ -206,7 +206,7 @@ MODULE_DEPEND(uftdi, ucom, 1, 1, 1);
MODULE_DEPEND(uftdi, usb, 1, 1, 1);
MODULE_VERSION(uftdi, 1);
static struct usb_device_id uftdi_devs[] = {
static STRUCT_USB_HOST_ID uftdi_devs[] = {
#define UFTDI_DEV(v,p,t) \
{ USB_VPI(USB_VENDOR_##v, USB_PRODUCT_##v##_##p, UFTDI_TYPE_##t) }
UFTDI_DEV(ATMEL, STK541, 8U232AM),

View File

@ -154,7 +154,7 @@ MODULE_DEPEND(ugensa, ucom, 1, 1, 1);
MODULE_DEPEND(ugensa, usb, 1, 1, 1);
MODULE_VERSION(ugensa, 1);
static const struct usb_device_id ugensa_devs[] = {
static const STRUCT_USB_HOST_ID ugensa_devs[] = {
{USB_VPI(USB_VENDOR_AIRPRIME, USB_PRODUCT_AIRPRIME_PC5220, 0)},
{USB_VPI(USB_VENDOR_CMOTECH, USB_PRODUCT_CMOTECH_CDMA_MODEM1, 0)},
{USB_VPI(USB_VENDOR_KYOCERA2, USB_PRODUCT_KYOCERA2_CDMA_MSM_K, 0)},

View File

@ -153,7 +153,7 @@ static const struct ucom_callback uipaq_callback = {
* support the same hardware. Numeric values are used where no usbdevs
* entries exist.
*/
static const struct usb_device_id uipaq_devs[] = {
static const STRUCT_USB_HOST_ID uipaq_devs[] = {
/* Socket USB Sync */
{USB_VPI(0x0104, 0x00be, 0)},
/* USB Sync 0301 */

View File

@ -483,24 +483,39 @@ ulpt_ioctl(struct usb_fifo *fifo, u_long cmd, void *data,
return (ENODEV);
}
static const STRUCT_USB_HOST_ID ulpt_devs[] = {
/* Uni-directional USB printer */
{USB_IFACE_CLASS(UICLASS_PRINTER),
USB_IFACE_SUBCLASS(UISUBCLASS_PRINTER),
USB_IFACE_PROTOCOL(UIPROTO_PRINTER_UNI)},
/* Bi-directional USB printer */
{USB_IFACE_CLASS(UICLASS_PRINTER),
USB_IFACE_SUBCLASS(UISUBCLASS_PRINTER),
USB_IFACE_PROTOCOL(UIPROTO_PRINTER_BI)},
/* 1284 USB printer */
{USB_IFACE_CLASS(UICLASS_PRINTER),
USB_IFACE_SUBCLASS(UISUBCLASS_PRINTER),
USB_IFACE_PROTOCOL(UIPROTO_PRINTER_1284)},
};
static int
ulpt_probe(device_t dev)
{
struct usb_attach_arg *uaa = device_get_ivars(dev);
int error;
DPRINTFN(11, "\n");
if (uaa->usb_mode != USB_MODE_HOST) {
if (uaa->usb_mode != USB_MODE_HOST)
return (ENXIO);
}
if ((uaa->info.bInterfaceClass == UICLASS_PRINTER) &&
(uaa->info.bInterfaceSubClass == UISUBCLASS_PRINTER) &&
((uaa->info.bInterfaceProtocol == UIPROTO_PRINTER_UNI) ||
(uaa->info.bInterfaceProtocol == UIPROTO_PRINTER_BI) ||
(uaa->info.bInterfaceProtocol == UIPROTO_PRINTER_1284))) {
return (0);
}
return (ENXIO);
error = usbd_lookup_id_by_uaa(ulpt_devs, sizeof(ulpt_devs), uaa);
if (error)
return (error);
return (BUS_PROBE_GENERIC);
}
static int

View File

@ -253,7 +253,7 @@ static struct ucom_callback umcs7840_callback = {
.ucom_poll = &umcs7840_poll,
};
static const struct usb_device_id umcs7840_devs[] = {
static const STRUCT_USB_HOST_ID umcs7840_devs[] = {
{USB_VPI(USB_VENDOR_MOSCHIP, USB_PRODUCT_MOSCHIP_MCS7820, 0)},
{USB_VPI(USB_VENDOR_MOSCHIP, USB_PRODUCT_MOSCHIP_MCS7840, 0)},
};

View File

@ -192,7 +192,7 @@ static const struct ucom_callback umct_callback = {
.ucom_poll = &umct_poll,
};
static const struct usb_device_id umct_devs[] = {
static const STRUCT_USB_HOST_ID umct_devs[] = {
{USB_VPI(USB_VENDOR_MCT, USB_PRODUCT_MCT_USB232, 0)},
{USB_VPI(USB_VENDOR_MCT, USB_PRODUCT_MCT_SITECOM_USB232, 0)},
{USB_VPI(USB_VENDOR_MCT, USB_PRODUCT_MCT_DU_H3SP_USB232, 0)},

View File

@ -123,7 +123,7 @@ SYSCTL_INT(_hw_usb_umodem, OID_AUTO, debug, CTLFLAG_RW,
&umodem_debug, 0, "Debug level");
#endif
static const struct usb_device_id umodem_devs[] = {
static const STRUCT_USB_HOST_ID umodem_devs[] = {
/* Generic Modem class match */
{USB_IFACE_CLASS(UICLASS_CDC),
USB_IFACE_SUBCLASS(UISUBCLASS_ABSTRACT_CONTROL_MODEL),

View File

@ -280,7 +280,7 @@ MODULE_DEPEND(umoscom, ucom, 1, 1, 1);
MODULE_DEPEND(umoscom, usb, 1, 1, 1);
MODULE_VERSION(umoscom, 1);
static const struct usb_device_id umoscom_devs[] = {
static const STRUCT_USB_HOST_ID umoscom_devs[] = {
{USB_VPI(USB_VENDOR_MOSCHIP, USB_PRODUCT_MOSCHIP_MCS7703, 0)}
};

View File

@ -247,7 +247,7 @@ static struct ucom_callback uplcom_callback = {
#define UPLCOM_DEV(v,p) \
{ USB_VENDOR(USB_VENDOR_##v), USB_PRODUCT(USB_PRODUCT_##v##_##p) }
static const struct usb_device_id uplcom_devs[] = {
static const STRUCT_USB_HOST_ID uplcom_devs[] = {
UPLCOM_DEV(ACERP, S81), /* BenQ S81 phone */
UPLCOM_DEV(ADLINK, ND6530), /* ADLINK ND-6530 USB-Serial */
UPLCOM_DEV(ALCATEL, OT535), /* Alcatel One Touch 535/735 */

View File

@ -173,7 +173,7 @@ static struct ucom_callback uslcom_callback = {
.ucom_poll = &uslcom_poll,
};
static const struct usb_device_id uslcom_devs[] = {
static const STRUCT_USB_HOST_ID uslcom_devs[] = {
#define USLCOM_DEV(v,p) { USB_VP(USB_VENDOR_##v, USB_PRODUCT_##v##_##p) }
USLCOM_DEV(BALTECH, CARDREADER),
USLCOM_DEV(CLIPSAL, 5500PCU),

View File

@ -253,7 +253,7 @@ MODULE_DEPEND(uvisor, ucom, 1, 1, 1);
MODULE_DEPEND(uvisor, usb, 1, 1, 1);
MODULE_VERSION(uvisor, 1);
static const struct usb_device_id uvisor_devs[] = {
static const STRUCT_USB_HOST_ID uvisor_devs[] = {
#define UVISOR_DEV(v,p,i) { USB_VPI(USB_VENDOR_##v, USB_PRODUCT_##v##_##p, i) }
UVISOR_DEV(ACEECA, MEZ1000, UVISOR_FLAG_PALM4),
UVISOR_DEV(ALPHASMART, DANA_SYNC, UVISOR_FLAG_PALM4),

View File

@ -233,7 +233,7 @@ static const struct ucom_callback uvscom_callback = {
.ucom_poll = &uvscom_poll,
};
static const struct usb_device_id uvscom_devs[] = {
static const STRUCT_USB_HOST_ID uvscom_devs[] = {
/* SUNTAC U-Cable type A4 */
{USB_VPI(USB_VENDOR_SUNTAC, USB_PRODUCT_SUNTAC_AS144L4, 0)},
/* SUNTAC U-Cable type D2 */

View File

@ -721,6 +721,11 @@ MODULE_VERSION(umass, 1);
* USB device probe/attach/detach
*/
static const STRUCT_USB_HOST_ID __used umass_devs[] = {
/* generic mass storage class */
{USB_IFACE_CLASS(UICLASS_MASS),},
};
static uint16_t
umass_get_proto(struct usb_interface *iface)
{

View File

@ -49,6 +49,7 @@
#include <sys/priv.h>
#include <dev/usb/usb.h>
#include <dev/usb/usb_ioctl.h>
#include <dev/usb/usbdi.h>
#include <dev/usb/usbdi_util.h>
#include "usbdevs.h"
@ -141,6 +142,31 @@ usb_make_raw_desc(struct usb_temp_setup *temp,
ud->bSlaveInterface[0] +=
temp->bInterfaceNumber;
}
/* check if we have got an interface association descriptor */
if ((raw[0] >= sizeof(struct usb_interface_assoc_descriptor)) &&
(raw[1] == UDESC_IFACE_ASSOC)) {
struct usb_interface_assoc_descriptor *iad = (void *)dst;
/* update the interface number */
iad->bFirstInterface +=
temp->bInterfaceNumber;
}
/* check if we have got a call management descriptor */
if ((raw[0] >= sizeof(struct usb_cdc_cm_descriptor)) &&
(raw[1] == UDESC_CS_INTERFACE) &&
(raw[2] == UDESCSUB_CDC_CM)) {
struct usb_cdc_cm_descriptor *ccd = (void *)dst;
/* update the interface number */
ccd->bDataInterface +=
temp->bInterfaceNumber;
}
}
temp->size += len;
}
@ -476,6 +502,10 @@ usb_make_device_desc(struct usb_temp_setup *temp,
USETW(utd->udd.bcdUSB, 0x0250);
utd->udd.bMaxPacketSize = 255; /* 512 bytes */
break;
case USB_SPEED_SUPER:
USETW(utd->udd.bcdUSB, 0x0300);
utd->udd.bMaxPacketSize = 9; /* 2**9 = 512 bytes */
break;
default:
temp->err = USB_ERR_INVAL;
break;
@ -1303,15 +1333,27 @@ usb_temp_setup_by_index(struct usb_device *udev, uint16_t index)
usb_error_t err;
switch (index) {
case 0:
case USB_TEMP_MSC:
err = usb_temp_setup(udev, &usb_template_msc);
break;
case 1:
case USB_TEMP_CDCE:
err = usb_temp_setup(udev, &usb_template_cdce);
break;
case 2:
case USB_TEMP_MTP:
err = usb_temp_setup(udev, &usb_template_mtp);
break;
case USB_TEMP_MODEM:
err = usb_temp_setup(udev, &usb_template_modem);
break;
case USB_TEMP_AUDIO:
err = usb_temp_setup(udev, &usb_template_audio);
break;
case USB_TEMP_KBD:
err = usb_temp_setup(udev, &usb_template_kbd);
break;
case USB_TEMP_MOUSE:
err = usb_temp_setup(udev, &usb_template_mouse);
break;
default:
return (USB_ERR_INVAL);
}

View File

@ -30,6 +30,10 @@
#ifndef _USB_TEMPLATE_H_
#define _USB_TEMPLATE_H_
#ifndef USB_TEMPLATE_VENDOR
#define USB_TEMPLATE_VENDOR 0x0001
#endif
typedef const void *(usb_temp_get_string_desc_t)(uint16_t lang_id, uint8_t string_index);
typedef const void *(usb_temp_get_vendor_desc_t)(const struct usb_device_request *req, uint16_t *plen);
@ -94,10 +98,14 @@ struct usb_temp_data {
/* prototypes */
extern const struct usb_temp_device_desc usb_template_audio;
extern const struct usb_temp_device_desc usb_template_cdce;
extern const struct usb_temp_device_desc usb_template_msc; /* Mass Storage Class */
extern const struct usb_temp_device_desc usb_template_mtp; /* Message Transfer
* Protocol */
extern const struct usb_temp_device_desc usb_template_kbd;
extern const struct usb_temp_device_desc usb_template_modem;
extern const struct usb_temp_device_desc usb_template_mouse;
extern const struct usb_temp_device_desc usb_template_msc;
extern const struct usb_temp_device_desc usb_template_mtp;
usb_error_t usb_temp_setup(struct usb_device *,
const struct usb_temp_device_desc *);
void usb_temp_unsetup(struct usb_device *);

View File

@ -0,0 +1,405 @@
#include <sys/cdefs.h>
__FBSDID("$FreeBSD$");
/*-
* Copyright (c) 2010 Hans Petter Selasky. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
/*
* This file contains the USB template for an USB Audio Device.
*/
#include <sys/stdint.h>
#include <sys/stddef.h>
#include <sys/param.h>
#include <sys/queue.h>
#include <sys/types.h>
#include <sys/systm.h>
#include <sys/kernel.h>
#include <sys/bus.h>
#include <sys/module.h>
#include <sys/lock.h>
#include <sys/mutex.h>
#include <sys/condvar.h>
#include <sys/sysctl.h>
#include <sys/sx.h>
#include <sys/unistd.h>
#include <sys/callout.h>
#include <sys/malloc.h>
#include <sys/priv.h>
#include <dev/usb/usb.h>
#include <dev/usb/usbdi.h>
#include <dev/usb/usb_cdc.h>
#include <dev/usb/template/usb_template.h>
enum {
INDEX_AUDIO_LANG,
INDEX_AUDIO_MIXER,
INDEX_AUDIO_RECORD,
INDEX_AUDIO_PLAYBACK,
INDEX_AUDIO_PRODUCT,
INDEX_AUDIO_MAX,
};
#define STRING_LANG \
0x09, 0x04, /* American English */
#define STRING_AUDIO_PRODUCT \
'A', 0, 'u', 0, 'd', 0, 'i', 0, 'o', 0, ' ', 0, \
'T', 0, 'e', 0, 's', 0, 't', 0, ' ', 0, \
'D', 0, 'e', 0, 'v', 0, 'i', 0, 'c', 0, 'e', 0, ' ', 0,
#define STRING_AUDIO_MIXER \
'M', 0, 'i', 0, 'x', 0, 'e', 0, 'r', 0, ' ', 0, \
'i', 0, 'n', 0, 't', 0, 'e', 0, 'r', 0, 'f', 0, 'a', 0, 'c', 0, 'e', 0,
#define STRING_AUDIO_RECORD \
'R', 0, 'e', 0, 'c', 0, 'o', 0, 'r', 0, 'd', 0, ' ', 0, \
'i', 0, 'n', 0, 't', 0, 'e', 0, 'r', 0, 'f', 0, 'a', 0, 'c', 0, 'e', 0,
#define STRING_AUDIO_PLAYBACK \
'P', 0, 'l', 0, 'a', 0, 'y', 0, 'b', 0, 'a', 0, 'c', 0, 'k', 0, ' ', 0, \
'i', 0, 'n', 0, 't', 0, 'e', 0, 'r', 0, 'f', 0, 'a', 0, 'c', 0, 'e', 0,
/* make the real string descriptors */
USB_MAKE_STRING_DESC(STRING_LANG, string_lang);
USB_MAKE_STRING_DESC(STRING_AUDIO_MIXER, string_audio_mixer);
USB_MAKE_STRING_DESC(STRING_AUDIO_RECORD, string_audio_record);
USB_MAKE_STRING_DESC(STRING_AUDIO_PLAYBACK, string_audio_playback);
USB_MAKE_STRING_DESC(STRING_AUDIO_PRODUCT, string_audio_product);
/* prototypes */
/*
* Audio Mixer description structures
*
* Some of the audio descriptors were dumped
* from a Creative Labs USB audio device.
*/
static const uint8_t audio_raw_desc_0[] = {
0x0a, 0x24, 0x01, 0x00, 0x01, 0xa9, 0x00, 0x02,
0x01, 0x02
};
static const uint8_t audio_raw_desc_1[] = {
0x0c, 0x24, 0x02, 0x01, 0x01, 0x01, 0x00, 0x02,
0x03, 0x00, 0x00, 0x00
};
static const uint8_t audio_raw_desc_2[] = {
0x0c, 0x24, 0x02, 0x02, 0x01, 0x02, 0x00, 0x02,
0x03, 0x00, 0x00, 0x00
};
static const uint8_t audio_raw_desc_3[] = {
0x0c, 0x24, 0x02, 0x03, 0x03, 0x06, 0x00, 0x02,
0x03, 0x00, 0x00, 0x00
};
static const uint8_t audio_raw_desc_4[] = {
0x0c, 0x24, 0x02, 0x04, 0x05, 0x06, 0x00, 0x02,
0x03, 0x00, 0x00, 0x00
};
static const uint8_t audio_raw_desc_5[] = {
0x09, 0x24, 0x03, 0x05, 0x05, 0x06, 0x00, 0x01,
0x00
};
static const uint8_t audio_raw_desc_6[] = {
0x09, 0x24, 0x03, 0x06, 0x01, 0x03, 0x00, 0x09,
0x00
};
static const uint8_t audio_raw_desc_7[] = {
0x09, 0x24, 0x03, 0x07, 0x01, 0x01, 0x00, 0x08,
0x00
};
static const uint8_t audio_raw_desc_8[] = {
0x09, 0x24, 0x05, 0x08, 0x03, 0x0a, 0x0b, 0x0c,
0x00
};
static const uint8_t audio_raw_desc_9[] = {
0x0a, 0x24, 0x06, 0x09, 0x0f, 0x01, 0x01, 0x02,
0x02, 0x00
};
static const uint8_t audio_raw_desc_10[] = {
0x0a, 0x24, 0x06, 0x0a, 0x02, 0x01, 0x43, 0x00,
0x00, 0x00
};
static const uint8_t audio_raw_desc_11[] = {
0x0a, 0x24, 0x06, 0x0b, 0x03, 0x01, 0x01, 0x02,
0x02, 0x00
};
static const uint8_t audio_raw_desc_12[] = {
0x0a, 0x24, 0x06, 0x0c, 0x04, 0x01, 0x01, 0x00,
0x00, 0x00
};
static const uint8_t audio_raw_desc_13[] = {
0x0a, 0x24, 0x06, 0x0d, 0x02, 0x01, 0x03, 0x00,
0x00, 0x00
};
static const uint8_t audio_raw_desc_14[] = {
0x0a, 0x24, 0x06, 0x0e, 0x03, 0x01, 0x01, 0x02,
0x02, 0x00
};
static const uint8_t audio_raw_desc_15[] = {
0x0f, 0x24, 0x04, 0x0f, 0x03, 0x01, 0x0d, 0x0e,
0x02, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00
};
static const void *audio_raw_iface_0_desc[] = {
audio_raw_desc_0,
audio_raw_desc_1,
audio_raw_desc_2,
audio_raw_desc_3,
audio_raw_desc_4,
audio_raw_desc_5,
audio_raw_desc_6,
audio_raw_desc_7,
audio_raw_desc_8,
audio_raw_desc_9,
audio_raw_desc_10,
audio_raw_desc_11,
audio_raw_desc_12,
audio_raw_desc_13,
audio_raw_desc_14,
audio_raw_desc_15,
NULL,
};
static const struct usb_temp_interface_desc audio_iface_0 = {
.ppEndpoints = NULL, /* no endpoints */
.ppRawDesc = audio_raw_iface_0_desc,
.bInterfaceClass = 1,
.bInterfaceSubClass = 1,
.bInterfaceProtocol = 0,
.iInterface = INDEX_AUDIO_MIXER,
};
static const uint8_t audio_raw_desc_20[] = {
0x07, 0x24, 0x01, 0x01, 0x03, 0x01, 0x00
};
static const uint8_t audio_raw_desc_21[] = {
0x0b, 0x24, 0x02, 0x01, 0x02, 0x02, 0x10, 0x01,
/* 48kHz */
0x80, 0xbb, 0x00
};
static const uint8_t audio_raw_desc_22[] = {
0x07, 0x25, 0x01, 0x00, 0x01, 0x04, 0x00
};
static const void *audio_raw_iface_1_desc[] = {
audio_raw_desc_20,
audio_raw_desc_21,
NULL,
};
static const void *audio_raw_ep_1_desc[] = {
audio_raw_desc_22,
NULL,
};
static const struct usb_temp_packet_size audio_isoc_mps = {
.mps[USB_SPEED_FULL] = 0xC8,
.mps[USB_SPEED_HIGH] = 0xC8,
};
static const struct usb_temp_interval audio_isoc_interval = {
.bInterval[USB_SPEED_FULL] = 1, /* 1:1 */
.bInterval[USB_SPEED_HIGH] = 4, /* 1:8 */
};
static const struct usb_temp_endpoint_desc audio_isoc_out_ep = {
.ppRawDesc = audio_raw_ep_1_desc,
.pPacketSize = &audio_isoc_mps,
.pIntervals = &audio_isoc_interval,
.bEndpointAddress = UE_DIR_OUT,
.bmAttributes = UE_ISOCHRONOUS | UE_ISO_ADAPT,
};
static const struct usb_temp_endpoint_desc *audio_iface_1_ep[] = {
&audio_isoc_out_ep,
NULL,
};
static const struct usb_temp_interface_desc audio_iface_1_alt_0 = {
.ppEndpoints = NULL, /* no endpoints */
.ppRawDesc = NULL, /* no raw descriptors */
.bInterfaceClass = 1,
.bInterfaceSubClass = 2,
.bInterfaceProtocol = 0,
.iInterface = INDEX_AUDIO_PLAYBACK,
};
static const struct usb_temp_interface_desc audio_iface_1_alt_1 = {
.ppEndpoints = audio_iface_1_ep,
.ppRawDesc = audio_raw_iface_1_desc,
.bInterfaceClass = 1,
.bInterfaceSubClass = 2,
.bInterfaceProtocol = 0,
.iInterface = INDEX_AUDIO_PLAYBACK,
.isAltInterface = 1, /* this is an alternate setting */
};
static const uint8_t audio_raw_desc_30[] = {
0x07, 0x24, 0x01, 0x07, 0x01, 0x01, 0x00
};
static const uint8_t audio_raw_desc_31[] = {
0x0b, 0x24, 0x02, 0x01, 0x02, 0x02, 0x10, 0x01,
/* 48kHz */
0x80, 0xbb, 0x00
};
static const uint8_t audio_raw_desc_32[] = {
0x07, 0x25, 0x01, 0x01, 0x00, 0x00, 0x00
};
static const void *audio_raw_iface_2_desc[] = {
audio_raw_desc_30,
audio_raw_desc_31,
NULL,
};
static const void *audio_raw_ep_2_desc[] = {
audio_raw_desc_32,
NULL,
};
static const struct usb_temp_endpoint_desc audio_isoc_in_ep = {
.ppRawDesc = audio_raw_ep_2_desc,
.pPacketSize = &audio_isoc_mps,
.pIntervals = &audio_isoc_interval,
.bEndpointAddress = UE_DIR_IN,
.bmAttributes = UE_ISOCHRONOUS | UE_ISO_ADAPT,
};
static const struct usb_temp_endpoint_desc *audio_iface_2_ep[] = {
&audio_isoc_in_ep,
NULL,
};
static const struct usb_temp_interface_desc audio_iface_2_alt_0 = {
.ppEndpoints = NULL, /* no endpoints */
.ppRawDesc = NULL, /* no raw descriptors */
.bInterfaceClass = 1,
.bInterfaceSubClass = 2,
.bInterfaceProtocol = 0,
.iInterface = INDEX_AUDIO_RECORD,
};
static const struct usb_temp_interface_desc audio_iface_2_alt_1 = {
.ppEndpoints = audio_iface_2_ep,
.ppRawDesc = audio_raw_iface_2_desc,
.bInterfaceClass = 1,
.bInterfaceSubClass = 2,
.bInterfaceProtocol = 0,
.iInterface = INDEX_AUDIO_RECORD,
.isAltInterface = 1, /* this is an alternate setting */
};
static const struct usb_temp_interface_desc *audio_interfaces[] = {
&audio_iface_0,
&audio_iface_1_alt_0,
&audio_iface_1_alt_1,
&audio_iface_2_alt_0,
&audio_iface_2_alt_1,
NULL,
};
static const struct usb_temp_config_desc audio_config_desc = {
.ppIfaceDesc = audio_interfaces,
.bmAttributes = UC_BUS_POWERED,
.bMaxPower = 25, /* 50 mA */
.iConfiguration = INDEX_AUDIO_PRODUCT,
};
static const struct usb_temp_config_desc *audio_configs[] = {
&audio_config_desc,
NULL,
};
static usb_temp_get_string_desc_t audio_get_string_desc;
const struct usb_temp_device_desc usb_template_audio = {
.getStringDesc = &audio_get_string_desc,
.ppConfigDesc = audio_configs,
.idVendor = USB_TEMPLATE_VENDOR,
.idProduct = 0x000A,
.bcdDevice = 0x0100,
.bDeviceClass = UDCLASS_COMM,
.bDeviceSubClass = 0,
.bDeviceProtocol = 0,
.iManufacturer = 0,
.iProduct = INDEX_AUDIO_PRODUCT,
.iSerialNumber = 0,
};
/*------------------------------------------------------------------------*
* audio_get_string_desc
*
* Return values:
* NULL: Failure. No such string.
* Else: Success. Pointer to string descriptor is returned.
*------------------------------------------------------------------------*/
static const void *
audio_get_string_desc(uint16_t lang_id, uint8_t string_index)
{
static const void *ptr[INDEX_AUDIO_MAX] = {
[INDEX_AUDIO_LANG] = &string_lang,
[INDEX_AUDIO_MIXER] = &string_audio_mixer,
[INDEX_AUDIO_RECORD] = &string_audio_record,
[INDEX_AUDIO_PLAYBACK] = &string_audio_playback,
[INDEX_AUDIO_PRODUCT] = &string_audio_product,
};
if (string_index == 0) {
return (&string_lang);
}
if (lang_id != 0x0409) {
return (NULL);
}
if (string_index < INDEX_AUDIO_MAX) {
return (ptr[string_index]);
}
return (NULL);
}

View File

@ -264,7 +264,7 @@ static const struct usb_temp_config_desc *eth_configs[] = {
const struct usb_temp_device_desc usb_template_cdce = {
.getStringDesc = &eth_get_string_desc,
.ppConfigDesc = eth_configs,
.idVendor = 0x0001,
.idVendor = USB_TEMPLATE_VENDOR,
.idProduct = 0x0001,
.bcdDevice = 0x0100,
.bDeviceClass = UDCLASS_COMM,

View File

@ -0,0 +1,224 @@
#include <sys/cdefs.h>
__FBSDID("$FreeBSD$");
/*-
* Copyright (c) 2010 Hans Petter Selasky. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
/*
* This file contains the USB template for an USB Keyboard Device.
*/
#include <sys/stdint.h>
#include <sys/stddef.h>
#include <sys/param.h>
#include <sys/queue.h>
#include <sys/types.h>
#include <sys/systm.h>
#include <sys/kernel.h>
#include <sys/bus.h>
#include <sys/module.h>
#include <sys/lock.h>
#include <sys/mutex.h>
#include <sys/condvar.h>
#include <sys/sysctl.h>
#include <sys/sx.h>
#include <sys/unistd.h>
#include <sys/callout.h>
#include <sys/malloc.h>
#include <sys/priv.h>
#include <dev/usb/usb.h>
#include <dev/usb/usbdi.h>
#include <dev/usb/usb_cdc.h>
#include <dev/usb/template/usb_template.h>
enum {
INDEX_LANG,
INDEX_KEYBOARD,
INDEX_PRODUCT,
INDEX_MAX,
};
#define STRING_LANG \
0x09, 0x04, /* American English */
#define STRING_PRODUCT \
'K', 0, 'e', 0, 'y', 0, 'b', 0, 'o', 0, 'a', 0, 'r', 0, 'd', 0, ' ', 0, \
'T', 0, 'e', 0, 's', 0, 't', 0, ' ', 0, \
'D', 0, 'e', 0, 'v', 0, 'i', 0, 'c', 0, 'e', 0, ' ', 0,
#define STRING_KEYBOARD \
'K', 0, 'e', 0, 'y', 0, 'b', 0, 'o', 0, 'a', 0, 'r', 0, 'd', 0, ' ', 0, \
'i', 0, 'n', 0, 't', 0, 'e', 0, 'r', 0, 'f', 0, 'a', 0, 'c', 0, 'e', 0,
/* make the real string descriptors */
USB_MAKE_STRING_DESC(STRING_LANG, string_lang);
USB_MAKE_STRING_DESC(STRING_KEYBOARD, string_keyboard);
USB_MAKE_STRING_DESC(STRING_PRODUCT, string_product);
/* prototypes */
static const struct usb_temp_packet_size keyboard_intr_mps = {
.mps[USB_SPEED_LOW] = 16,
.mps[USB_SPEED_FULL] = 16,
.mps[USB_SPEED_HIGH] = 16,
};
static const struct usb_temp_interval keyboard_intr_interval = {
.bInterval[USB_SPEED_LOW] = 2, /* ms */
.bInterval[USB_SPEED_FULL] = 2,
.bInterval[USB_SPEED_HIGH] = 2 * 8,
};
/* The following HID descriptor was dumped from a HP keyboard. */
static uint8_t keyboard_hid_descriptor[] = {
0x05, 0x01, 0x09, 0x06, 0xa1, 0x01, 0x05, 0x07,
0x19, 0xe0, 0x29, 0xe7, 0x15, 0x00, 0x25, 0x01,
0x75, 0x01, 0x95, 0x08, 0x81, 0x02, 0x95, 0x01,
0x75, 0x08, 0x81, 0x01, 0x95, 0x03, 0x75, 0x01,
0x05, 0x08, 0x19, 0x01, 0x29, 0x03, 0x91, 0x02,
0x95, 0x05, 0x75, 0x01, 0x91, 0x01, 0x95, 0x06,
0x75, 0x08, 0x15, 0x00, 0x26, 0xff, 0x00, 0x05,
0x07, 0x19, 0x00, 0x2a, 0xff, 0x00, 0x81, 0x00,
0xc0
};
static const struct usb_temp_endpoint_desc keyboard_ep_0 = {
.ppRawDesc = NULL, /* no raw descriptors */
.pPacketSize = &keyboard_intr_mps,
.pIntervals = &keyboard_intr_interval,
.bEndpointAddress = UE_DIR_IN,
.bmAttributes = UE_INTERRUPT,
};
static const struct usb_temp_endpoint_desc *keyboard_endpoints[] = {
&keyboard_ep_0,
NULL,
};
static const uint8_t keyboard_raw_desc[] = {
0x09, 0x21, 0x10, 0x01, 0x00, 0x01, 0x22, sizeof(keyboard_hid_descriptor),
0x00
};
static const void *keyboard_iface_0_desc[] = {
keyboard_raw_desc,
NULL,
};
static const struct usb_temp_interface_desc keyboard_iface_0 = {
.ppRawDesc = keyboard_iface_0_desc,
.ppEndpoints = keyboard_endpoints,
.bInterfaceClass = 3,
.bInterfaceSubClass = 1,
.bInterfaceProtocol = 1,
.iInterface = INDEX_KEYBOARD,
};
static const struct usb_temp_interface_desc *keyboard_interfaces[] = {
&keyboard_iface_0,
NULL,
};
static const struct usb_temp_config_desc keyboard_config_desc = {
.ppIfaceDesc = keyboard_interfaces,
.bmAttributes = UC_BUS_POWERED,
.bMaxPower = 25, /* 50 mA */
.iConfiguration = INDEX_PRODUCT,
};
static const struct usb_temp_config_desc *keyboard_configs[] = {
&keyboard_config_desc,
NULL,
};
static usb_temp_get_string_desc_t keyboard_get_string_desc;
static usb_temp_get_vendor_desc_t keyboard_get_vendor_desc;
const struct usb_temp_device_desc usb_template_kbd = {
.getStringDesc = &keyboard_get_string_desc,
.getVendorDesc = &keyboard_get_vendor_desc,
.ppConfigDesc = keyboard_configs,
.idVendor = USB_TEMPLATE_VENDOR,
.idProduct = 0x00CB,
.bcdDevice = 0x0100,
.bDeviceClass = UDCLASS_COMM,
.bDeviceSubClass = 0,
.bDeviceProtocol = 0,
.iManufacturer = 0,
.iProduct = INDEX_PRODUCT,
.iSerialNumber = 0,
};
/*------------------------------------------------------------------------*
* keyboard_get_vendor_desc
*
* Return values:
* NULL: Failure. No such vendor descriptor.
* Else: Success. Pointer to vendor descriptor is returned.
*------------------------------------------------------------------------*/
static const void *
keyboard_get_vendor_desc(const struct usb_device_request *req, uint16_t *plen)
{
if ((req->bmRequestType == 0x81) && (req->bRequest == 0x06) &&
(req->wValue[0] == 0x00) && (req->wValue[1] == 0x22) &&
(req->wIndex[1] == 0) && (req->wIndex[0] == 0)) {
*plen = sizeof(keyboard_hid_descriptor);
return (keyboard_hid_descriptor);
}
return (NULL);
}
/*------------------------------------------------------------------------*
* keyboard_get_string_desc
*
* Return values:
* NULL: Failure. No such string.
* Else: Success. Pointer to string descriptor is returned.
*------------------------------------------------------------------------*/
static const void *
keyboard_get_string_desc(uint16_t lang_id, uint8_t string_index)
{
static const void *ptr[INDEX_MAX] = {
[INDEX_LANG] = &string_lang,
[INDEX_KEYBOARD] = &string_keyboard,
[INDEX_PRODUCT] = &string_product,
};
if (string_index == 0) {
return (&string_lang);
}
if (lang_id != 0x0409) {
return (NULL);
}
if (string_index < INDEX_MAX) {
return (ptr[string_index]);
}
return (NULL);
}

View File

@ -0,0 +1,252 @@
#include <sys/cdefs.h>
__FBSDID("$FreeBSD$");
/*-
* Copyright (c) 2010 Hans Petter Selasky. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
/*
* This file contains the USB template for an USB Modem Device.
*/
#include <sys/stdint.h>
#include <sys/stddef.h>
#include <sys/param.h>
#include <sys/queue.h>
#include <sys/types.h>
#include <sys/systm.h>
#include <sys/kernel.h>
#include <sys/bus.h>
#include <sys/module.h>
#include <sys/lock.h>
#include <sys/mutex.h>
#include <sys/condvar.h>
#include <sys/sysctl.h>
#include <sys/sx.h>
#include <sys/unistd.h>
#include <sys/callout.h>
#include <sys/malloc.h>
#include <sys/priv.h>
#include <dev/usb/usb.h>
#include <dev/usb/usbdi.h>
#include <dev/usb/usb_cdc.h>
#include <dev/usb/template/usb_template.h>
enum {
INDEX_LANG,
INDEX_MODEM,
INDEX_PRODUCT,
INDEX_MAX,
};
#define STRING_LANG \
0x09, 0x04, /* American English */
#define STRING_PRODUCT \
'M', 0, 'o', 0, 'd', 0, 'e', 0, 'm', 0, ' ', 0, \
'T', 0, 'e', 0, 's', 0, 't', 0, ' ', 0, \
'D', 0, 'e', 0, 'v', 0, 'i', 0, 'c', 0, 'e', 0, ' ', 0,
#define STRING_MODEM \
'M', 0, 'o', 0, 'd', 0, 'e', 0, 'm', 0, ' ', 0, \
'i', 0, 'n', 0, 't', 0, 'e', 0, 'r', 0, 'f', 0, 'a', 0, 'c', 0, 'e', 0,
/* make the real string descriptors */
USB_MAKE_STRING_DESC(STRING_LANG, string_lang);
USB_MAKE_STRING_DESC(STRING_MODEM, string_modem);
USB_MAKE_STRING_DESC(STRING_PRODUCT, string_product);
#define MODEM_IFACE_0 0
#define MODEM_IFACE_1 1
/* prototypes */
static const struct usb_temp_packet_size modem_bulk_mps = {
.mps[USB_SPEED_LOW] = 8,
.mps[USB_SPEED_FULL] = 64,
.mps[USB_SPEED_HIGH] = 512,
};
static const struct usb_temp_packet_size modem_intr_mps = {
.mps[USB_SPEED_LOW] = 8,
.mps[USB_SPEED_FULL] = 8,
.mps[USB_SPEED_HIGH] = 8,
};
static const struct usb_temp_interval modem_intr_interval = {
.bInterval[USB_SPEED_LOW] = 10,
.bInterval[USB_SPEED_FULL] = 10,
.bInterval[USB_SPEED_HIGH] = 10 * 8,
};
static const struct usb_temp_endpoint_desc modem_ep_0 = {
.pPacketSize = &modem_intr_mps,
.pIntervals = &modem_intr_interval,
.bEndpointAddress = UE_DIR_IN,
.bmAttributes = UE_INTERRUPT,
};
static const struct usb_temp_endpoint_desc modem_ep_1 = {
.pPacketSize = &modem_bulk_mps,
.bEndpointAddress = UE_DIR_OUT,
.bmAttributes = UE_BULK,
};
static const struct usb_temp_endpoint_desc modem_ep_2 = {
.pPacketSize = &modem_bulk_mps,
.bEndpointAddress = UE_DIR_IN,
.bmAttributes = UE_BULK,
};
static const struct usb_temp_endpoint_desc *modem_iface_0_ep[] = {
&modem_ep_0,
NULL,
};
static const struct usb_temp_endpoint_desc *modem_iface_1_ep[] = {
&modem_ep_1,
&modem_ep_2,
NULL,
};
static const uint8_t modem_raw_desc_0[] = {
0x05, 0x24, 0x00, 0x10, 0x01
};
static const uint8_t modem_raw_desc_1[] = {
0x05, 0x24, 0x06, MODEM_IFACE_0, MODEM_IFACE_1
};
static const uint8_t modem_raw_desc_2[] = {
0x05, 0x24, 0x01, 0x03, MODEM_IFACE_1
};
static const uint8_t modem_raw_desc_3[] = {
0x04, 0x24, 0x02, 0x07
};
static const void *modem_iface_0_desc[] = {
&modem_raw_desc_0,
&modem_raw_desc_1,
&modem_raw_desc_2,
&modem_raw_desc_3,
NULL,
};
static const struct usb_temp_interface_desc modem_iface_0 = {
.ppRawDesc = modem_iface_0_desc,
.ppEndpoints = modem_iface_0_ep,
.bInterfaceClass = 2,
.bInterfaceSubClass = 2,
.bInterfaceProtocol = 1,
.iInterface = INDEX_MODEM,
};
static const struct usb_temp_interface_desc modem_iface_1 = {
.ppEndpoints = modem_iface_1_ep,
.bInterfaceClass = 10,
.bInterfaceSubClass = 0,
.bInterfaceProtocol = 0,
.iInterface = INDEX_MODEM,
};
static const struct usb_temp_interface_desc *modem_interfaces[] = {
&modem_iface_0,
&modem_iface_1,
NULL,
};
static const struct usb_temp_config_desc modem_config_desc = {
.ppIfaceDesc = modem_interfaces,
.bmAttributes = UC_BUS_POWERED,
.bMaxPower = 25, /* 50 mA */
.iConfiguration = INDEX_PRODUCT,
};
static const struct usb_temp_config_desc *modem_configs[] = {
&modem_config_desc,
NULL,
};
static usb_temp_get_string_desc_t modem_get_string_desc;
static usb_temp_get_vendor_desc_t modem_get_vendor_desc;
const struct usb_temp_device_desc usb_template_modem = {
.getStringDesc = &modem_get_string_desc,
.getVendorDesc = &modem_get_vendor_desc,
.ppConfigDesc = modem_configs,
.idVendor = USB_TEMPLATE_VENDOR,
.idProduct = 0x000E,
.bcdDevice = 0x0100,
.bDeviceClass = UDCLASS_COMM,
.bDeviceSubClass = 0,
.bDeviceProtocol = 0,
.iManufacturer = 0,
.iProduct = INDEX_PRODUCT,
.iSerialNumber = 0,
};
/*------------------------------------------------------------------------*
* modem_get_vendor_desc
*
* Return values:
* NULL: Failure. No such vendor descriptor.
* Else: Success. Pointer to vendor descriptor is returned.
*------------------------------------------------------------------------*/
static const void *
modem_get_vendor_desc(const struct usb_device_request *req, uint16_t *plen)
{
return (NULL);
}
/*------------------------------------------------------------------------*
* modem_get_string_desc
*
* Return values:
* NULL: Failure. No such string.
* Else: Success. Pointer to string descriptor is returned.
*------------------------------------------------------------------------*/
static const void *
modem_get_string_desc(uint16_t lang_id, uint8_t string_index)
{
static const void *ptr[INDEX_MAX] = {
[INDEX_LANG] = &string_lang,
[INDEX_MODEM] = &string_modem,
[INDEX_PRODUCT] = &string_product,
};
if (string_index == 0) {
return (&string_lang);
}
if (lang_id != 0x0409) {
return (NULL);
}
if (string_index < INDEX_MAX) {
return (ptr[string_index]);
}
return (NULL);
}

View File

@ -0,0 +1,222 @@
#include <sys/cdefs.h>
__FBSDID("$FreeBSD$");
/*-
* Copyright (c) 2010 Hans Petter Selasky. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
/*
* This file contains the USB template for an USB Mouse Device.
*/
#include <sys/stdint.h>
#include <sys/stddef.h>
#include <sys/param.h>
#include <sys/queue.h>
#include <sys/types.h>
#include <sys/systm.h>
#include <sys/kernel.h>
#include <sys/bus.h>
#include <sys/module.h>
#include <sys/lock.h>
#include <sys/mutex.h>
#include <sys/condvar.h>
#include <sys/sysctl.h>
#include <sys/sx.h>
#include <sys/unistd.h>
#include <sys/callout.h>
#include <sys/malloc.h>
#include <sys/priv.h>
#include <dev/usb/usb.h>
#include <dev/usb/usbdi.h>
#include <dev/usb/usb_cdc.h>
#include <dev/usb/template/usb_template.h>
enum {
INDEX_LANG,
INDEX_MOUSE,
INDEX_PRODUCT,
INDEX_MAX,
};
#define STRING_LANG \
0x09, 0x04, /* American English */
#define STRING_PRODUCT \
'M', 0, 'o', 0, 'u', 0, 's', 0, 'e', 0, ' ', 0, \
'T', 0, 'e', 0, 's', 0, 't', 0, ' ', 0, \
'D', 0, 'e', 0, 'v', 0, 'i', 0, 'c', 0, 'e', 0,
#define STRING_MOUSE \
'M', 0, 'o', 0, 'u', 0, 's', 0, 'e', 0, ' ', 0, \
'i', 0, 'n', 0, 't', 0, 'e', 0, 'r', 0, 'f', 0, 'a', 0, 'c', 0, 'e', 0,
/* make the real string descriptors */
USB_MAKE_STRING_DESC(STRING_LANG, string_lang);
USB_MAKE_STRING_DESC(STRING_MOUSE, string_mouse);
USB_MAKE_STRING_DESC(STRING_PRODUCT, string_product);
/* prototypes */
/* The following HID descriptor was dumped from a HP mouse. */
static uint8_t mouse_hid_descriptor[] = {
0x05, 0x01, 0x09, 0x02, 0xa1, 0x01, 0x09, 0x01,
0xa1, 0x00, 0x05, 0x09, 0x19, 0x01, 0x29, 0x03,
0x15, 0x00, 0x25, 0x01, 0x95, 0x03, 0x75, 0x01,
0x81, 0x02, 0x95, 0x05, 0x81, 0x03, 0x05, 0x01,
0x09, 0x30, 0x09, 0x31, 0x09, 0x38, 0x15, 0x81,
0x25, 0x7f, 0x75, 0x08, 0x95, 0x03, 0x81, 0x06,
0xc0, 0xc0
};
static const struct usb_temp_packet_size mouse_intr_mps = {
.mps[USB_SPEED_LOW] = 8,
.mps[USB_SPEED_FULL] = 8,
.mps[USB_SPEED_HIGH] = 8,
};
static const struct usb_temp_interval mouse_intr_interval = {
.bInterval[USB_SPEED_LOW] = 2,
.bInterval[USB_SPEED_FULL] = 2,
.bInterval[USB_SPEED_HIGH] = 2 * 8,
};
static const struct usb_temp_endpoint_desc mouse_ep_0 = {
.ppRawDesc = NULL, /* no raw descriptors */
.pPacketSize = &mouse_intr_mps,
.pIntervals = &mouse_intr_interval,
.bEndpointAddress = UE_DIR_IN,
.bmAttributes = UE_INTERRUPT,
};
static const struct usb_temp_endpoint_desc *mouse_endpoints[] = {
&mouse_ep_0,
NULL,
};
static const uint8_t mouse_raw_desc[] = {
0x09, 0x21, 0x10, 0x01, 0x00, 0x01, 0x22, sizeof(mouse_hid_descriptor),
0x00
};
static const void *mouse_iface_0_desc[] = {
mouse_raw_desc,
NULL,
};
static const struct usb_temp_interface_desc mouse_iface_0 = {
.ppRawDesc = mouse_iface_0_desc,
.ppEndpoints = mouse_endpoints,
.bInterfaceClass = 3,
.bInterfaceSubClass = 1,
.bInterfaceProtocol = 2,
.iInterface = INDEX_MOUSE,
};
static const struct usb_temp_interface_desc *mouse_interfaces[] = {
&mouse_iface_0,
NULL,
};
static const struct usb_temp_config_desc mouse_config_desc = {
.ppIfaceDesc = mouse_interfaces,
.bmAttributes = UC_BUS_POWERED,
.bMaxPower = 25, /* 50 mA */
.iConfiguration = INDEX_PRODUCT,
};
static const struct usb_temp_config_desc *mouse_configs[] = {
&mouse_config_desc,
NULL,
};
static usb_temp_get_string_desc_t mouse_get_string_desc;
static usb_temp_get_vendor_desc_t mouse_get_vendor_desc;
const struct usb_temp_device_desc usb_template_mouse = {
.getStringDesc = &mouse_get_string_desc,
.getVendorDesc = &mouse_get_vendor_desc,
.ppConfigDesc = mouse_configs,
.idVendor = USB_TEMPLATE_VENDOR,
.idProduct = 0x00AE,
.bcdDevice = 0x0100,
.bDeviceClass = UDCLASS_COMM,
.bDeviceSubClass = 0,
.bDeviceProtocol = 0,
.iManufacturer = 0,
.iProduct = INDEX_PRODUCT,
.iSerialNumber = 0,
};
/*------------------------------------------------------------------------*
* mouse_get_vendor_desc
*
* Return values:
* NULL: Failure. No such vendor descriptor.
* Else: Success. Pointer to vendor descriptor is returned.
*------------------------------------------------------------------------*/
static const void *
mouse_get_vendor_desc(const struct usb_device_request *req, uint16_t *plen)
{
if ((req->bmRequestType == 0x81) && (req->bRequest == 0x06) &&
(req->wValue[0] == 0x00) && (req->wValue[1] == 0x22) &&
(req->wIndex[1] == 0) && (req->wIndex[0] == 0)) {
*plen = sizeof(mouse_hid_descriptor);
return (mouse_hid_descriptor);
}
return (NULL);
}
/*------------------------------------------------------------------------*
* mouse_get_string_desc
*
* Return values:
* NULL: Failure. No such string.
* Else: Success. Pointer to string descriptor is returned.
*------------------------------------------------------------------------*/
static const void *
mouse_get_string_desc(uint16_t lang_id, uint8_t string_index)
{
static const void *ptr[INDEX_MAX] = {
[INDEX_LANG] = &string_lang,
[INDEX_MOUSE] = &string_mouse,
[INDEX_PRODUCT] = &string_product,
};
if (string_index == 0) {
return (&string_lang);
}
if (lang_id != 0x0409) {
return (NULL);
}
if (string_index < INDEX_MAX) {
return (ptr[string_index]);
}
return (NULL);
}

View File

@ -173,8 +173,8 @@ static const struct usb_temp_config_desc *msc_configs[] = {
const struct usb_temp_device_desc usb_template_msc = {
.getStringDesc = &msc_get_string_desc,
.ppConfigDesc = msc_configs,
.idVendor = 0x0001,
.idProduct = 0x0001,
.idVendor = USB_TEMPLATE_VENDOR,
.idProduct = 0x0012,
.bcdDevice = 0x0100,
.bDeviceClass = UDCLASS_COMM,
.bDeviceSubClass = 0,

View File

@ -191,8 +191,8 @@ const struct usb_temp_device_desc usb_template_mtp = {
.getStringDesc = &mtp_get_string_desc,
.getVendorDesc = &mtp_get_vendor_desc,
.ppConfigDesc = mtp_configs,
.idVendor = 0x0001,
.idProduct = 0x0001,
.idVendor = USB_TEMPLATE_VENDOR,
.idProduct = 0x0011,
.bcdDevice = 0x0100,
.bDeviceClass = 0,
.bDeviceSubClass = 0,

Some files were not shown because too many files have changed in this diff Show More