-Barrelfish offers a simple \acs{vfs} layer for accessing different filesystems.\r
-blockdevfs adds a further layer to facilitate exporting of file-like objects to\r
-the filesystem layer. There is no restriction on the nature of these files,\r
-apart from having to be of a fixed size.\r
-\r
-The backends of blockdevfs can expose an arbitrary number of filenames. The\r
-filenames from different backends are combined to form the root directory of\r
-the blockdevfs filesystem. \acs{vfs} calls are mapped to the corresponding backend.\r
-The filesystem only consists of a single directory with no nested directories.\r
-Files cannot be created nor deleted or truncated.\r
-\r
-\section{Datastructures}\r
-\r
-blockdevfs keeps a very simple doubly-linked list of directory entries. These\r
-entries contain a file name, file position, file size, backend type and backend\r
-handle. blockdevfs does not enforce any kind of order in this list. Therefore,\r
-enumerating the contents of the blockdevfs root directory will yield the files\r
-registered by blockdevfs backends in the order they were added to blockdevfs.\r
-When routing \acs{vfs} calls to the right backend, the number stored in backend type\r
-is used as an index into the \lstinline+backends+ array holding function\r
-pointers to the backend's operations.\r
-\r
-Figure \ref{fig:blockdevfs_list} shows how the directory structure looks like\r
-with two entries. \lstinline+prev+ and \lstinline+next+ are used to implement\r
-the linked list. \lstinline+path+ holds a pointer to the filename.\r
-\lstinline+size+ contains the size of the file in bytes. \lstinline+type+ is\r
-either $0$ for the \emph{libahci} backend or $1$ for the Flounder-based\r
-backend. \lstinline+backend_handle+ points to an internal handle private to the\r
-backend. \lstinline+open+ is a boolean value indicating if the file has been\r
-opened already.\r
-\r
-blockdevfs backends must use the \lstinline+blockdev_append_entry+ function to\r
-register files they export.\r
-\r
-\begin{figure}[ht]\r
-\centering\r
-\includegraphics[width=.7\textwidth]{blockdevfs_list.pdf}\r
-\caption{Directory entries of blockdevfs}\r
-\label{fig:blockdevfs_list}\r
-\end{figure}\r
-\r
-\section{Backend API}\r
-\r
-blockdevfs only exports \lstinline+blockdev_append_entry+ which can be used by\r
-backends to register their exported files. A backend can choose the\r
-\lstinline+backend_handle+ freely. This handle will be passed as an argument to\r
-all \acs{vfs} related functions.\r
-\r
-For standard \acs{vfs} operations, backends need to provide these four functions:\r
-\r
-\begin{itemize}\r
- \item \lstinline+open(void *handle)+ to open an exported file. The backend does not have to check or manipulate any blockdevfs-specific structures. blockdevfs ensures that only one client has a file open concurrently.\r
- \item \lstinline+close(void *handle)+ to close a previously opened file. As with open, blockdevfs takes care of manipulating its structures.\r
- \item \lstinline+read(void *handle, size_t pos, void *buffer, size_t bytes,+\\\r
- \lstinline+ size_t *bytes_read)+ to read from the file corresponding to the handle.\r
- \item \lstinline+write(void *handle, size_t pos, void *buffer, size_t bytes,+\\\r
- \lstinline+ size_t *bytes_written)+ to write to the file corresponding to the handle.\r
- \item \lstinline+flush(void *handle)+ to flush all data of the file\r
- correpsonding to the handle to persistent storage.\r
-\end{itemize}\r
-\r
-All functions are supplied with the backend-handle associated with the\r
-corresponding file.\r
-\r
-\section{Usage}\r
-\r
-blockdevfs can by mounted by issuing \verb+mount mountpoint blockdevfs://+ and\r
-does not accept any further parameters.\r
-\r
-Upon mounting, blockdevfs initializes its backends which in turn populate the\r
-list of directory entries. Listing the directory contents will yield any\r
-attached disk drives and report their sizes.\r
-\r
-\section{Backends}\r
-\r
-Currently the block device file system has two backends. One backend uses\r
-libahci stand-alone and the other backend uses the Flounder-generated \ac{ata}\r
-interface. The backends are named the \emph{ahci} and \emph{ata} backend\r
-respectively.\r
-\r
-As both these backends expose the same devices (namely any \ac{sata} disks\r
-attached to the \ac{ahci} controller), the file names for the devices are\r
-composed of the backend name and the device's unique id, e.g. \emph{ahci0} and\r
-\emph{ata0} for the device with unique id $0$. Keep in mind that \emph{ahcid}\r
-prevents concurrent access, therefore you can't open the respective \emph{ata}\r
-and \emph{ahci} devices at the same time.\r
-\r
-\subsection{AHCI Backend}\r
-\r
-The \ac{ahci} blockdevfs backend implements the open and close commands by\r
-calling the corresponding functions in libahci (\ahciinit and\r
-\lstinline+ahci_close+) and implements read and write by allocating a \acs{dma}\r
-buffer using \lstinline+ahci_dma_region_alloc+, constructing an appropriate\r
-\ac{fis} and calling \issuecmd. The read implementation updates the\r
-\lstinline+rx_vtbl.command_completed+ pointer to point to\r
-\lstinline+rx_read_command_completed_cb+. That function then uses\r
-\lstinline+ahci_dma_region_copy_out+ to copy the read bytes from the \acs{dma}\r
-buffer to the user buffer, frees the \acs{dma} buffer, and calls the user\r
-continuation. The write implementation copies the bytes that need to be written\r
-to the \acs{dma} buffer (using \lstinline+ahci_dma_region_copy_in+) and updates\r
-the \lstinline+rx_vtbl.command_completed+ pointer to point to\r
-\lstinline+rx_write_command_completed_cb+ which frees the \acs{dma} buffer and\r
-calls the user continuation. Flush is implemented by issuing the {\tt FLUSH\r
-CACHE} \ac{ata} command which flushes the on-disk cache to the harddisk proper.\r
-\r
-\subsection{ATA Backend}\r
-\r
-The \ac{ata} blockdevfs backend implements the open command by initializing an\r
-\acs{rpc} client to the \lstinline+ata_rw28+ Flounder \acs{ahci} interface. The\r
-close command just calls \verb+ahci_+ \verb+close+ so that a subsequent open-call\r
-on the same blockdevfs file is successful. The read, write and flush commands\r
-are easy to implement using the \acs{rpc} client to the Flounder \acs{ahci}\r
-interface by just calling the \lstinline+read_dma+, \lstinline+write_dma+ and\r
-\lstinline+flush_cache+ functions in the \acs{rpc} function table.\r
-\r
-\section{Restrictions}\r
-\r
-As blockdevfs is only intended to provide a simple way for \acs{vfs} aware\r
-applications (e.g. fish) it has several restrictions:\r
-\r
-\begin{itemize}\r
- \item The size of the files should not change. Although a backend might change\r
- the size stored in the handle dynamically, blockdevfs is not geared\r
- towards this.\r
- \item Subdirectories are not supported.\r
- \item Only one client can have a file open.\r
- \item Files cannot be removed, neither by the user nor by the backend.\r
-\end{itemize}\r
-\r
-\section{VFS adaptation}\r
-\r
-In order to ensure that data written to a block device really gets written to\r
-the hard disk, we added a new \acs{vfs} call, namely \lstinline+vfs_flush+,\r
-which is used to flush the hard disk's volatile cache. \lstinline+vfs_flush+\r
-returns \lstinline+VFS_ERR_NOT_IMPLEMENTED+ for \acs{vfs} backends that have no\r
-handler for flush in their \lstinline+struct vfs_ops+ table.\r
-\r
+Barrelfish offers a simple \acs{vfs} layer for accessing different filesystems.
+blockdevfs adds a further layer to facilitate exporting of file-like objects to
+the filesystem layer. There is no restriction on the nature of these files,
+apart from having to be of a fixed size.
+
+The backends of blockdevfs can expose an arbitrary number of filenames. The
+filenames from different backends are combined to form the root directory of
+the blockdevfs filesystem. \acs{vfs} calls are mapped to the corresponding backend.
+The filesystem only consists of a single directory with no nested directories.
+Files cannot be created nor deleted or truncated.
+
+\section{Datastructures}
+
+blockdevfs keeps a very simple doubly-linked list of directory entries. These
+entries contain a file name, file position, file size, backend type and backend
+handle. blockdevfs does not enforce any kind of order in this list. Therefore,
+enumerating the contents of the blockdevfs root directory will yield the files
+registered by blockdevfs backends in the order they were added to blockdevfs.
+When routing \acs{vfs} calls to the right backend, the number stored in backend type
+is used as an index into the \lstinline+backends+ array holding function
+pointers to the backend's operations.
+
+Figure \ref{fig:blockdevfs_list} shows how the directory structure looks like
+with two entries. \lstinline+prev+ and \lstinline+next+ are used to implement
+the linked list. \lstinline+path+ holds a pointer to the filename.
+\lstinline+size+ contains the size of the file in bytes. \lstinline+type+ is
+either $0$ for the \emph{libahci} backend or $1$ for the Flounder-based
+backend. \lstinline+backend_handle+ points to an internal handle private to the
+backend. \lstinline+open+ is a boolean value indicating if the file has been
+opened already.
+
+blockdevfs backends must use the \lstinline+blockdev_append_entry+ function to
+register files they export.
+
+\begin{figure}[ht]
+\centering
+\includegraphics[width=.7\textwidth]{blockdevfs_list.pdf}
+\caption{Directory entries of blockdevfs}
+\label{fig:blockdevfs_list}
+\end{figure}
+
+\section{Backend API}
+
+blockdevfs only exports \lstinline+blockdev_append_entry+ which can be used by
+backends to register their exported files. A backend can choose the
+\lstinline+backend_handle+ freely. This handle will be passed as an argument to
+all \acs{vfs} related functions.
+
+For standard \acs{vfs} operations, backends need to provide these four functions:
+
+\begin{itemize}
+ \item \lstinline+open(void *handle)+ to open an exported file. The backend does not have to check or manipulate any blockdevfs-specific structures. blockdevfs ensures that only one client has a file open concurrently.
+ \item \lstinline+close(void *handle)+ to close a previously opened file. As with open, blockdevfs takes care of manipulating its structures.
+ \item \lstinline+read(void *handle, size_t pos, void *buffer, size_t bytes,+\\
+ \lstinline+ size_t *bytes_read)+ to read from the file corresponding to the handle.
+ \item \lstinline+write(void *handle, size_t pos, void *buffer, size_t bytes,+\\
+ \lstinline+ size_t *bytes_written)+ to write to the file corresponding to the handle.
+ \item \lstinline+flush(void *handle)+ to flush all data of the file
+ correpsonding to the handle to persistent storage.
+\end{itemize}
+
+All functions are supplied with the backend-handle associated with the
+corresponding file.
+
+\section{Usage}
+
+blockdevfs can by mounted by issuing \verb+mount mountpoint blockdevfs://+ and
+does not accept any further parameters.
+
+Upon mounting, blockdevfs initializes its backends which in turn populate the
+list of directory entries. Listing the directory contents will yield any
+attached disk drives and report their sizes.
+
+\section{Backends}
+
+Currently the block device file system has two backends. One backend uses
+libahci stand-alone and the other backend uses the Flounder-generated \ac{ata}
+interface. The backends are named the \emph{ahci} and \emph{ata} backend
+respectively.
+
+As both these backends expose the same devices (namely any \ac{sata} disks
+attached to the \ac{ahci} controller), the file names for the devices are
+composed of the backend name and the device's unique id, e.g. \emph{ahci0} and
+\emph{ata0} for the device with unique id $0$. Keep in mind that \emph{ahcid}
+prevents concurrent access, therefore you can't open the respective \emph{ata}
+and \emph{ahci} devices at the same time.
+
+\subsection{AHCI Backend}
+
+The \ac{ahci} blockdevfs backend implements the open and close commands by
+calling the corresponding functions in libahci (\ahciinit and
+\lstinline+ahci_close+) and implements read and write by allocating a \acs{dma}
+buffer using \lstinline+ahci_dma_region_alloc+, constructing an appropriate
+\ac{fis} and calling \issuecmd. The read implementation updates the
+\lstinline+rx_vtbl.command_completed+ pointer to point to
+\lstinline+rx_read_command_completed_cb+. That function then uses
+\lstinline+ahci_dma_region_copy_out+ to copy the read bytes from the \acs{dma}
+buffer to the user buffer, frees the \acs{dma} buffer, and calls the user
+continuation. The write implementation copies the bytes that need to be written
+to the \acs{dma} buffer (using \lstinline+ahci_dma_region_copy_in+) and updates
+the \lstinline+rx_vtbl.command_completed+ pointer to point to
+\lstinline+rx_write_command_completed_cb+ which frees the \acs{dma} buffer and
+calls the user continuation. Flush is implemented by issuing the {\tt FLUSH
+CACHE} \ac{ata} command which flushes the on-disk cache to the harddisk proper.
+
+\subsection{ATA Backend}
+
+The \ac{ata} blockdevfs backend implements the open command by initializing an
+\acs{rpc} client to the \lstinline+ata_rw28+ Flounder \acs{ahci} interface. The
+close command just calls \verb+ahci_+ \verb+close+ so that a subsequent open-call
+on the same blockdevfs file is successful. The read, write and flush commands
+are easy to implement using the \acs{rpc} client to the Flounder \acs{ahci}
+interface by just calling the \lstinline+read_dma+, \lstinline+write_dma+ and
+\lstinline+flush_cache+ functions in the \acs{rpc} function table.
+
+\section{Restrictions}
+
+As blockdevfs is only intended to provide a simple way for \acs{vfs} aware
+applications (e.g. fish) it has several restrictions:
+
+\begin{itemize}
+ \item The size of the files should not change. Although a backend might change
+ the size stored in the handle dynamically, blockdevfs is not geared
+ towards this.
+ \item Subdirectories are not supported.
+ \item Only one client can have a file open.
+ \item Files cannot be removed, neither by the user nor by the backend.
+\end{itemize}
+
+\section{VFS adaptation}
+
+In order to ensure that data written to a block device really gets written to
+the hard disk, we added a new \acs{vfs} call, namely \lstinline+vfs_flush+,
+which is used to flush the hard disk's volatile cache. \lstinline+vfs_flush+
+returns \lstinline+VFS_ERR_NOT_IMPLEMENTED+ for \acs{vfs} backends that have no
+handler for flush in their \lstinline+struct vfs_ops+ table.
+
-The \ac{ahci} is a standard by Intel that defines a common API for \ac{sata}\r
-and SAS host bus adapters. In order to provide backwards-compatibility,\r
-\ac{ahci} specifies modes for both legacy IDE emulation and a standardized\r
-\ac{ahci} interface. \r
-\r
-\ac{ahci} only implements the transport aspect of the communication with\r
-devices. Commands are still transferred as specified in the \ac{ata}/\ac{atapi}\r
-standards.\r
-\r
-\section{ATA/ATAPI/SATA}\r
-\r
-The \ac{ata} standard specifies an interface for connecting several types of\r
-storage devices, including devices with removable media. \ac{atapi} provides an\r
-extension to allow \ac{ata} to transmit \acs{scsi} commands.\r
-\r
-Commands that can be sent to \ac{ata} devices are specified in the \ac{acs}\r
-specifications. Commands in particular interest for this lab project are the\r
-\texttt{IDENTIFY}, \texttt{READ DMA}, \texttt{WRITE DMA} and \texttt{FLUSH\r
-CACHE} commands.\r
-\r
-The way these commands are sent to the device is specified in the respective\r
-specification, for example the \ac{sata} or \ac{pata} specifications.\r
-\r
-\subsection{SATA}\r
-\r
-The \ac{sata} standard specifies the layout of the command \acp{fis} that\r
-encapsulate traditional ATA commands as well as all the lower layers of the\r
-interface to the disk, such as the physical layer.\r
-\r
-Figure \ref{fig:h2d_fis} shows the structure of an example \ac{fis}. A Host to\r
-Device Register \ac{fis} can be used to send commands to the disk. The command\r
-value is specified by \ac{ata}. The \ac{fis} contains additional values such as\r
-\ac{lba} and sector count.\r
-\r
-\begin{figure}[ht]\r
-\centering\r
-\includegraphics[width=.7\textwidth]{h2d_fis.pdf}\r
-\caption{Host to Device Register FIS \cite[p.~336]{sata_2.6}}\r
-\label{fig:h2d_fis}\r
-\end{figure}\r
-\r
-\section{AHCI}\r
-\r
-\subsection{Memory Registers}\r
-\r
-While the \acs{pci} base address register 0-4 may contain pointers to address\r
-spaces for legacy IDE emulation, \ac{bar} 5 contains the address of the\r
-\ac{hba}'s memory mapped registers. As shown in figure \ref{fig:hba_mem}, this\r
-address space is divided into two areas: global registers for control of the\r
-\ac{hba} and registers for up to 32 ports. A port can be attached to either a\r
-device or a port multiplier. In this lab project, we focus on device handling\r
-and ignore port multipliers.\r
-\r
-\begin{figure}[ht]\r
-\centering\r
-\includegraphics[width=.7\textwidth]{hba_mem.png}\r
-\caption{HBA Memory Space Usage \cite[p.~33]{ahci_1.3}}\r
-\label{fig:hba_mem}\r
-\end{figure}\r
-\r
-Every port area (\autoref{fig:port_mem}) contains further control registers and\r
-pointers to the memory regions for the command list and receive \ac{fis} area.\r
-Each of these pointers is a 64-bit value (32-bit for \acp{hba} that don't\r
-support 64-bit addressing) stored in two port registers.\r
-\r
-\begin{figure}[ht]\r
-\centering\r
-\includegraphics[width=.9\textwidth]{pmem_overview.pdf}\r
-\caption{Port System Memory Structure adapted from \cite[p.~34]{ahci_1.3}}\r
-\label{fig:port_mem}\r
-\end{figure}\r
-\r
-\subsection{Received FIS Area}\r
-\r
-The received \ac{fis} area serves as an area where copies of the \acp{fis}\r
-received from the device are stored. The \ac{hba} will copy all incoming\r
-\acp{fis} to the appropriate region of the \ac{rfis} area. If the \ac{hba}\r
-receives an unkown \ac{fis} it is copied to the Unknown \ac{fis} region if it\r
-is at most 64 bytes long. If the \ac{hba} receives an unknown \ac{fis} that is\r
-longer than 64 bytes, it will be considered illegal.\r
-\r
-\begin{figure}[ht]\r
-\centering\r
-\includegraphics[width=.8\textwidth]{rfis_area.pdf}\r
-\caption{Received FIS Organization, adapted from \cite[p.~35]{ahci_1.3}}\r
-\label{fig:rfis_mem}\r
-\end{figure}\r
-\r
-\r
-\subsection{Commands}\r
-\r
-A command list (\autoref{fig:command_list}) contains 32 command headers, which\r
-each contain the metadata for a single command.\r
-\r
-Commands can be issued to the device by constructing a command header\r
-containing a reference to a command table and further metadata for the command\r
-to be issued.\r
-\r
-\begin{figure}[ht]\r
-\centering\r
-\includegraphics[width=.8\textwidth]{command_list_structure.png}\r
-\caption{Command List Structure \cite[p.~36]{ahci_1.3}}\r
-\label{fig:command_list}\r
-\end{figure}\r
-\r
-The command table (\autoref{fig:command_table}) contains the command \ac{fis}\r
-itself and an optional number of physical region descriptors specifying chunks\r
-of main memory in form of a scatter-gather list.\r
-\r
-\begin{figure}[ht]\r
-\centering\r
-\includegraphics[width=.8\textwidth]{command_table.png}\r
-\caption{Command Table \cite[p.~39]{ahci_1.3}}\r
-\label{fig:command_table}\r
-\end{figure}\r
-\r
-Commands are issued by setting the corresponding bit in the command issue\r
-register. Upon command completion, the bit is cleared and if enabled, an\r
-interrupt is triggered.\r
-\r
+The \ac{ahci} is a standard by Intel that defines a common API for \ac{sata}
+and SAS host bus adapters. In order to provide backwards-compatibility,
+\ac{ahci} specifies modes for both legacy IDE emulation and a standardized
+\ac{ahci} interface.
+
+\ac{ahci} only implements the transport aspect of the communication with
+devices. Commands are still transferred as specified in the \ac{ata}/\ac{atapi}
+standards.
+
+\section{ATA/ATAPI/SATA}
+
+The \ac{ata} standard specifies an interface for connecting several types of
+storage devices, including devices with removable media. \ac{atapi} provides an
+extension to allow \ac{ata} to transmit \acs{scsi} commands.
+
+Commands that can be sent to \ac{ata} devices are specified in the \ac{acs}
+specifications. Commands in particular interest for this lab project are the
+\texttt{IDENTIFY}, \texttt{READ DMA}, \texttt{WRITE DMA} and \texttt{FLUSH
+CACHE} commands.
+
+The way these commands are sent to the device is specified in the respective
+specification, for example the \ac{sata} or \ac{pata} specifications.
+
+\subsection{SATA}
+
+The \ac{sata} standard specifies the layout of the command \acp{fis} that
+encapsulate traditional ATA commands as well as all the lower layers of the
+interface to the disk, such as the physical layer.
+
+Figure \ref{fig:h2d_fis} shows the structure of an example \ac{fis}. A Host to
+Device Register \ac{fis} can be used to send commands to the disk. The command
+value is specified by \ac{ata}. The \ac{fis} contains additional values such as
+\ac{lba} and sector count.
+
+\begin{figure}[ht]
+\centering
+\includegraphics[width=.7\textwidth]{h2d_fis.pdf}
+\caption{Host to Device Register FIS \cite[p.~336]{sata_2.6}}
+\label{fig:h2d_fis}
+\end{figure}
+
+\section{AHCI}
+
+\subsection{Memory Registers}
+
+While the \acs{pci} base address register 0-4 may contain pointers to address
+spaces for legacy IDE emulation, \ac{bar} 5 contains the address of the
+\ac{hba}'s memory mapped registers. As shown in figure \ref{fig:hba_mem}, this
+address space is divided into two areas: global registers for control of the
+\ac{hba} and registers for up to 32 ports. A port can be attached to either a
+device or a port multiplier. In this lab project, we focus on device handling
+and ignore port multipliers.
+
+\begin{figure}[ht]
+\centering
+\includegraphics[width=.7\textwidth]{hba_mem.png}
+\caption{HBA Memory Space Usage \cite[p.~33]{ahci_1.3}}
+\label{fig:hba_mem}
+\end{figure}
+
+Every port area (\autoref{fig:port_mem}) contains further control registers and
+pointers to the memory regions for the command list and receive \ac{fis} area.
+Each of these pointers is a 64-bit value (32-bit for \acp{hba} that don't
+support 64-bit addressing) stored in two port registers.
+
+\begin{figure}[ht]
+\centering
+\includegraphics[width=.9\textwidth]{pmem_overview.pdf}
+\caption{Port System Memory Structure adapted from \cite[p.~34]{ahci_1.3}}
+\label{fig:port_mem}
+\end{figure}
+
+\subsection{Received FIS Area}
+
+The received \ac{fis} area serves as an area where copies of the \acp{fis}
+received from the device are stored. The \ac{hba} will copy all incoming
+\acp{fis} to the appropriate region of the \ac{rfis} area. If the \ac{hba}
+receives an unkown \ac{fis} it is copied to the Unknown \ac{fis} region if it
+is at most 64 bytes long. If the \ac{hba} receives an unknown \ac{fis} that is
+longer than 64 bytes, it will be considered illegal.
+
+\begin{figure}[ht]
+\centering
+\includegraphics[width=.8\textwidth]{rfis_area.pdf}
+\caption{Received FIS Organization, adapted from \cite[p.~35]{ahci_1.3}}
+\label{fig:rfis_mem}
+\end{figure}
+
+
+\subsection{Commands}
+
+A command list (\autoref{fig:command_list}) contains 32 command headers, which
+each contain the metadata for a single command.
+
+Commands can be issued to the device by constructing a command header
+containing a reference to a command table and further metadata for the command
+to be issued.
+
+\begin{figure}[ht]
+\centering
+\includegraphics[width=.8\textwidth]{command_list_structure.png}
+\caption{Command List Structure \cite[p.~36]{ahci_1.3}}
+\label{fig:command_list}
+\end{figure}
+
+The command table (\autoref{fig:command_table}) contains the command \ac{fis}
+itself and an optional number of physical region descriptors specifying chunks
+of main memory in form of a scatter-gather list.
+
+\begin{figure}[ht]
+\centering
+\includegraphics[width=.8\textwidth]{command_table.png}
+\caption{Command Table \cite[p.~39]{ahci_1.3}}
+\label{fig:command_table}
+\end{figure}
+
+Commands are issued by setting the corresponding bit in the command issue
+register. Upon command completion, the bit is cleared and if enabled, an
+interrupt is triggered.
+
-/*\r
- * Copyright (c) 1992, 1993\r
- * The Regents of the University of California. All rights reserved.\r
- *\r
- * Redistribution and use in source and binary forms, with or without\r
- * modification, are permitted provided that the following conditions\r
- * are met:\r
- * 1. Redistributions of source code must retain the above copyright\r
- * notice, this list of conditions and the following disclaimer.\r
- * 2. Redistributions in binary form must reproduce the above copyright\r
- * notice, this list of conditions and the following disclaimer in the\r
- * documentation and/or other materials provided with the distribution.\r
- * 3. Neither the name of the University nor the names of its contributors\r
- * may be used to endorse or promote products derived from this software\r
- * without specific prior written permission.\r
- *\r
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND\r
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\r
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE\r
- * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE\r
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL\r
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS\r
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)\r
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT\r
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY\r
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF\r
- * SUCH DAMAGE.\r
- *\r
- * @(#)float.h 8.1 (Berkeley) 6/10/93\r
- */\r
-\r
-#ifndef _ARM_FLOAT_H_\r
-#define _ARM_FLOAT_H_\r
-\r
-#include <sys/cdefs.h>\r
-\r
-#ifndef FLT_ROUNDS\r
-__BEGIN_DECLS\r
-extern int __flt_rounds(void);\r
-__END_DECLS\r
-#define FLT_ROUNDS -1 /* __flt_rounds() */\r
-#endif\r
-\r
-#define FLT_EVAL_METHOD (-1) /* XXX */\r
-\r
-#define LDBL_MANT_DIG 64\r
-#define LDBL_EPSILON 1.0842021724855044340E-19L\r
-#define LDBL_DIG 18\r
-#define LDBL_MIN_EXP (-16381)\r
-#define LDBL_MIN 1.6810515715560467531E-4932L\r
-#define LDBL_MIN_10_EXP (-4931)\r
-#define LDBL_MAX_EXP 16384\r
-#define LDBL_MAX 1.1897314953572317650E+4932L\r
-#define LDBL_MAX_10_EXP 4932\r
-\r
-#define FLT_RADIX 2 /* b */\r
-\r
-#define FLT_MANT_DIG 24 /* p */\r
-#define FLT_EPSILON 1.19209290E-7F /* b**(1-p) */\r
-#define FLT_DIG 6 /* floor((p-1)*log10(b))+(b == 10) */\r
-#define FLT_MIN_EXP (-125) /* emin */\r
-#define FLT_MIN 1.17549435E-38F /* b**(emin-1) */\r
-#define FLT_MIN_10_EXP (-37) /* ceil(log10(b**(emin-1))) */\r
-#define FLT_MAX_EXP 128 /* emax */\r
-#define FLT_MAX 3.40282347E+38F /* (1-b**(-p))*b**emax */\r
-#define FLT_MAX_10_EXP 38 /* floor(log10((1-b**(-p))*b**emax)) */\r
-\r
-#define DBL_MANT_DIG 53\r
-#define DBL_EPSILON 2.2204460492503131E-16\r
-#define DBL_DIG 15\r
-#define DBL_MIN_EXP (-1021)\r
-#define DBL_MIN 2.2250738585072014E-308\r
-#define DBL_MIN_10_EXP (-307)\r
-#define DBL_MAX_EXP 1024\r
-#define DBL_MAX 1.7976931348623157E+308\r
-#define DBL_MAX_10_EXP 308\r
-\r
-#define DECIMAL_DIG 17 /* ceil((1+p*log10(b))-(b==10) */\r
-\r
-#endif /* !_ARM_FLOAT_H_ */\r
+/*
+ * Copyright (c) 1992, 1993
+ * The Regents of the University of California. 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.
+ * 3. Neither the name of the University nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS 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 REGENTS 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.
+ *
+ * @(#)float.h 8.1 (Berkeley) 6/10/93
+ */
+
+#ifndef _ARM_FLOAT_H_
+#define _ARM_FLOAT_H_
+
+#include <sys/cdefs.h>
+
+#ifndef FLT_ROUNDS
+__BEGIN_DECLS
+extern int __flt_rounds(void);
+__END_DECLS
+#define FLT_ROUNDS -1 /* __flt_rounds() */
+#endif
+
+#define FLT_EVAL_METHOD (-1) /* XXX */
+
+#define LDBL_MANT_DIG 64
+#define LDBL_EPSILON 1.0842021724855044340E-19L
+#define LDBL_DIG 18
+#define LDBL_MIN_EXP (-16381)
+#define LDBL_MIN 1.6810515715560467531E-4932L
+#define LDBL_MIN_10_EXP (-4931)
+#define LDBL_MAX_EXP 16384
+#define LDBL_MAX 1.1897314953572317650E+4932L
+#define LDBL_MAX_10_EXP 4932
+
+#define FLT_RADIX 2 /* b */
+
+#define FLT_MANT_DIG 24 /* p */
+#define FLT_EPSILON 1.19209290E-7F /* b**(1-p) */
+#define FLT_DIG 6 /* floor((p-1)*log10(b))+(b == 10) */
+#define FLT_MIN_EXP (-125) /* emin */
+#define FLT_MIN 1.17549435E-38F /* b**(emin-1) */
+#define FLT_MIN_10_EXP (-37) /* ceil(log10(b**(emin-1))) */
+#define FLT_MAX_EXP 128 /* emax */
+#define FLT_MAX 3.40282347E+38F /* (1-b**(-p))*b**emax */
+#define FLT_MAX_10_EXP 38 /* floor(log10((1-b**(-p))*b**emax)) */
+
+#define DBL_MANT_DIG 53
+#define DBL_EPSILON 2.2204460492503131E-16
+#define DBL_DIG 15
+#define DBL_MIN_EXP (-1021)
+#define DBL_MIN 2.2250738585072014E-308
+#define DBL_MIN_10_EXP (-307)
+#define DBL_MAX_EXP 1024
+#define DBL_MAX 1.7976931348623157E+308
+#define DBL_MAX_10_EXP 308
+
+#define DECIMAL_DIG 17 /* ceil((1+p*log10(b))-(b==10) */
+
+#endif /* !_ARM_FLOAT_H_ */
-/*-\r
- * Copyright (c) 2002, 2003 David Schultz <das@FreeBSD.ORG>\r
- * All rights reserved.\r
- *\r
- * Redistribution and use in source and binary forms, with or without\r
- * modification, are permitted provided that the following conditions\r
- * are met:\r
- * 1. Redistributions of source code must retain the above copyright\r
- * notice, this list of conditions and the following disclaimer.\r
- * 2. Redistributions in binary form must reproduce the above copyright\r
- * notice, this list of conditions and the following disclaimer in the\r
- * documentation and/or other materials provided with the distribution.\r
- *\r
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND\r
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\r
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE\r
- * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE\r
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL\r
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS\r
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)\r
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT\r
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY\r
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF\r
- * SUCH DAMAGE.\r
- *\r
- * $FreeBSD$\r
- */\r
-\r
-#if defined(__VFP_FP__)\r
-#define _IEEE_WORD_ORDER _BYTE_ORDER\r
-#else\r
-#define _IEEE_WORD_ORDER _BIG_ENDIAN\r
-#endif\r
-\r
-union IEEEl2bits {\r
- long double e;\r
- struct {\r
-#if _BYTE_ORDER == _LITTLE_ENDIAN\r
-#if _IEEE_WORD_ORDER == _LITTLE_ENDIAN\r
- unsigned int manl :32;\r
-#endif\r
- unsigned int manh :20;\r
- unsigned int exp :11;\r
- unsigned int sign :1;\r
-#if _IEEE_WORD_ORDER == _BIG_ENDIAN\r
- unsigned int manl :32;\r
-#endif\r
-#else /* _BYTE_ORDER == _LITTLE_ENDIAN */\r
- unsigned int sign :1;\r
- unsigned int exp :11;\r
- unsigned int manh :20;\r
- unsigned int manl :32;\r
-#endif\r
- } bits;\r
-};\r
-\r
-#define LDBL_NBIT 0\r
-#define mask_nbit_l(u) ((void)0)\r
-\r
-#define LDBL_MANH_SIZE 32\r
-#define LDBL_MANL_SIZE 32\r
-\r
-#define LDBL_TO_ARRAY32(u, a) do { \\r
- (a)[0] = (uint32_t)(u).bits.manl; \\r
- (a)[1] = (uint32_t)(u).bits.manh; \\r
-} while(0)\r
-\r
+/*-
+ * Copyright (c) 2002, 2003 David Schultz <das@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, 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.
+ *
+ * $FreeBSD$
+ */
+
+#if defined(__VFP_FP__)
+#define _IEEE_WORD_ORDER _BYTE_ORDER
+#else
+#define _IEEE_WORD_ORDER _BIG_ENDIAN
+#endif
+
+union IEEEl2bits {
+ long double e;
+ struct {
+#if _BYTE_ORDER == _LITTLE_ENDIAN
+#if _IEEE_WORD_ORDER == _LITTLE_ENDIAN
+ unsigned int manl :32;
+#endif
+ unsigned int manh :20;
+ unsigned int exp :11;
+ unsigned int sign :1;
+#if _IEEE_WORD_ORDER == _BIG_ENDIAN
+ unsigned int manl :32;
+#endif
+#else /* _BYTE_ORDER == _LITTLE_ENDIAN */
+ unsigned int sign :1;
+ unsigned int exp :11;
+ unsigned int manh :20;
+ unsigned int manl :32;
+#endif
+ } bits;
+};
+
+#define LDBL_NBIT 0
+#define mask_nbit_l(u) ((void)0)
+
+#define LDBL_MANH_SIZE 32
+#define LDBL_MANL_SIZE 32
+
+#define LDBL_TO_ARRAY32(u, a) do { \
+ (a)[0] = (uint32_t)(u).bits.manl; \
+ (a)[1] = (uint32_t)(u).bits.manh; \
+} while(0)
+
-/* $NetBSD: float.h,v 1.6 2005/12/11 12:16:47 christos Exp $ */\r
-/* $NetBSD: float_ieee754.h,v 1.8 2005/12/11 12:25:20 christos Exp $ */\r
-\r
-/*\r
- * Copyright (c) 1992, 1993\r
- * The Regents of the University of California. All rights reserved.\r
- *\r
- * Redistribution and use in source and binary forms, with or without\r
- * modification, are permitted provided that the following conditions\r
- * are met:\r
- * 1. Redistributions of source code must retain the above copyright\r
- * notice, this list of conditions and the following disclaimer.\r
- * 2. Redistributions in binary form must reproduce the above copyright\r
- * notice, this list of conditions and the following disclaimer in the\r
- * documentation and/or other materials provided with the distribution.\r
- * 3. Neither the name of the University nor the names of its contributors\r
- * may be used to endorse or promote products derived from this software\r
- * without specific prior written permission.\r
- *\r
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND\r
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\r
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE\r
- * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE\r
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL\r
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS\r
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)\r
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT\r
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY\r
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF\r
- * SUCH DAMAGE.\r
- *\r
- * @(#)float.h 8.1 (Berkeley) 6/10/93\r
- */\r
-\r
-#ifndef _ARM_FLOAT_H_\r
-#define _ARM_FLOAT_H_\r
-\r
-#include <sys/cdefs.h>\r
-\r
-#ifndef FLT_ROUNDS\r
-__BEGIN_DECLS\r
-extern int __flt_rounds(void);\r
-__END_DECLS\r
-#define FLT_ROUNDS -1 /* __flt_rounds() */\r
-#endif\r
-\r
-#define FLT_EVAL_METHOD (-1) /* XXX */\r
-\r
-#define LDBL_MANT_DIG 64\r
-#define LDBL_EPSILON 1.0842021724855044340E-19L\r
-#define LDBL_DIG 18\r
-#define LDBL_MIN_EXP (-16381)\r
-#define LDBL_MIN 1.6810515715560467531E-4932L\r
-#define LDBL_MIN_10_EXP (-4931)\r
-#define LDBL_MAX_EXP 16384\r
-#define LDBL_MAX 1.1897314953572317650E+4932L\r
-#define LDBL_MAX_10_EXP 4932\r
-\r
-#define FLT_RADIX 2 /* b */\r
-\r
-#define FLT_MANT_DIG 24 /* p */\r
-#define FLT_EPSILON 1.19209290E-7F /* b**(1-p) */\r
-#define FLT_DIG 6 /* floor((p-1)*log10(b))+(b == 10) */\r
-#define FLT_MIN_EXP (-125) /* emin */\r
-#define FLT_MIN 1.17549435E-38F /* b**(emin-1) */\r
-#define FLT_MIN_10_EXP (-37) /* ceil(log10(b**(emin-1))) */\r
-#define FLT_MAX_EXP 128 /* emax */\r
-#define FLT_MAX 3.40282347E+38F /* (1-b**(-p))*b**emax */\r
-#define FLT_MAX_10_EXP 38 /* floor(log10((1-b**(-p))*b**emax)) */\r
-\r
-#define DBL_MANT_DIG 53\r
-#define DBL_EPSILON 2.2204460492503131E-16\r
-#define DBL_DIG 15\r
-#define DBL_MIN_EXP (-1021)\r
-#define DBL_MIN 2.2250738585072014E-308\r
-#define DBL_MIN_10_EXP (-307)\r
-#define DBL_MAX_EXP 1024\r
-#define DBL_MAX 1.7976931348623157E+308\r
-#define DBL_MAX_10_EXP 308\r
-\r
-#define DECIMAL_DIG 17 /* ceil((1+p*log10(b))-(b==10) */\r
-\r
-#endif /* !_ARM_FLOAT_H_ */\r
+/* $NetBSD: float.h,v 1.6 2005/12/11 12:16:47 christos Exp $ */
+/* $NetBSD: float_ieee754.h,v 1.8 2005/12/11 12:25:20 christos Exp $ */
+
+/*
+ * Copyright (c) 1992, 1993
+ * The Regents of the University of California. 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.
+ * 3. Neither the name of the University nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS 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 REGENTS 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.
+ *
+ * @(#)float.h 8.1 (Berkeley) 6/10/93
+ */
+
+#ifndef _ARM_FLOAT_H_
+#define _ARM_FLOAT_H_
+
+#include <sys/cdefs.h>
+
+#ifndef FLT_ROUNDS
+__BEGIN_DECLS
+extern int __flt_rounds(void);
+__END_DECLS
+#define FLT_ROUNDS -1 /* __flt_rounds() */
+#endif
+
+#define FLT_EVAL_METHOD (-1) /* XXX */
+
+#define LDBL_MANT_DIG 64
+#define LDBL_EPSILON 1.0842021724855044340E-19L
+#define LDBL_DIG 18
+#define LDBL_MIN_EXP (-16381)
+#define LDBL_MIN 1.6810515715560467531E-4932L
+#define LDBL_MIN_10_EXP (-4931)
+#define LDBL_MAX_EXP 16384
+#define LDBL_MAX 1.1897314953572317650E+4932L
+#define LDBL_MAX_10_EXP 4932
+
+#define FLT_RADIX 2 /* b */
+
+#define FLT_MANT_DIG 24 /* p */
+#define FLT_EPSILON 1.19209290E-7F /* b**(1-p) */
+#define FLT_DIG 6 /* floor((p-1)*log10(b))+(b == 10) */
+#define FLT_MIN_EXP (-125) /* emin */
+#define FLT_MIN 1.17549435E-38F /* b**(emin-1) */
+#define FLT_MIN_10_EXP (-37) /* ceil(log10(b**(emin-1))) */
+#define FLT_MAX_EXP 128 /* emax */
+#define FLT_MAX 3.40282347E+38F /* (1-b**(-p))*b**emax */
+#define FLT_MAX_10_EXP 38 /* floor(log10((1-b**(-p))*b**emax)) */
+
+#define DBL_MANT_DIG 53
+#define DBL_EPSILON 2.2204460492503131E-16
+#define DBL_DIG 15
+#define DBL_MIN_EXP (-1021)
+#define DBL_MIN 2.2250738585072014E-308
+#define DBL_MIN_10_EXP (-307)
+#define DBL_MAX_EXP 1024
+#define DBL_MAX 1.7976931348623157E+308
+#define DBL_MAX_10_EXP 308
+
+#define DECIMAL_DIG 17 /* ceil((1+p*log10(b))-(b==10) */
+
+#endif /* !_ARM_FLOAT_H_ */
-/*-\r
- * Copyright (c) 1988, 1993\r
- * The Regents of the University of California. All rights reserved.\r
- *\r
- * Redistribution and use in source and binary forms, with or without\r
- * modification, are permitted provided that the following conditions\r
- * are met:\r
- * 1. Redistributions of source code must retain the above copyright\r
- * notice, this list of conditions and the following disclaimer.\r
- * 2. Redistributions in binary form must reproduce the above copyright\r
- * notice, this list of conditions and the following disclaimer in the\r
- * documentation and/or other materials provided with the distribution.\r
- * 4. Neither the name of the University nor the names of its contributors\r
- * may be used to endorse or promote products derived from this software\r
- * without specific prior written permission.\r
- *\r
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND\r
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\r
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE\r
- * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE\r
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL\r
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS\r
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)\r
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT\r
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY\r
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF\r
- * SUCH DAMAGE.\r
- *\r
- * @(#)limits.h 8.3 (Berkeley) 1/4/94\r
- * $FreeBSD$\r
- */\r
-\r
-#ifndef _MACHINE__LIMITS_H_\r
-#define _MACHINE__LIMITS_H_\r
-\r
-/*\r
- * According to ANSI (section 2.2.4.2), the values below must be usable by\r
- * #if preprocessing directives. Additionally, the expression must have the\r
- * same type as would an expression that is an object of the corresponding\r
- * type converted according to the integral promotions. The subtraction for\r
- * INT_MIN, etc., is so the value is not unsigned; e.g., 0x80000000 is an\r
- * unsigned int for 32-bit two's complement ANSI compilers (section 3.1.3.2).\r
- * These numbers are for the default configuration of gcc. They work for\r
- * some other compilers as well, but this should not be depended on.\r
- */\r
-\r
-#define __CHAR_BIT 8 /* number of bits in a char */\r
-\r
-#define __SCHAR_MAX 0x7f /* max value for a signed char */\r
-#define __SCHAR_MIN (-0x7f - 1) /* min value for a signed char */\r
-\r
-#define __UCHAR_MAX 0xff /* max value for an unsigned char */\r
-\r
-#define __USHRT_MAX 0xffff /* max value for an unsigned short */\r
-#define __SHRT_MAX 0x7fff /* max value for a short */\r
-#define __SHRT_MIN (-0x7fff - 1) /* min value for a short */\r
-\r
-#define __UINT_MAX 0xffffffffU /* max value for an unsigned int */\r
-#define __INT_MAX 0x7fffffff /* max value for an int */\r
-#define __INT_MIN (-0x7fffffff - 1) /* min value for an int */\r
-\r
-/* Bad hack for gcc configured to give 64-bit longs. */\r
-#ifdef _LARGE_LONG\r
-#define __ULONG_MAX 0xffffffffffffffffUL\r
-#define __LONG_MAX 0x7fffffffffffffffL\r
-#define __LONG_MIN (-0x7fffffffffffffffL - 1)\r
-#else\r
-#define __ULONG_MAX 0xffffffffUL /* max value for an unsigned long */\r
-#define __LONG_MAX 0x7fffffffL /* max value for a long */\r
-#define __LONG_MIN (-0x7fffffffL - 1) /* min value for a long */\r
-#endif\r
-\r
- /* max value for an unsigned long long */\r
-#define __ULLONG_MAX 0xffffffffffffffffULL\r
-#define __LLONG_MAX 0x7fffffffffffffffLL /* max value for a long long */\r
-#define __LLONG_MIN (-0x7fffffffffffffffLL - 1) /* min for a long long */\r
-\r
-#define __SSIZE_MAX __INT_MAX /* max value for a ssize_t */\r
-\r
-#define __SIZE_T_MAX __UINT_MAX /* max value for a size_t */\r
-\r
-#define __OFF_MAX __LLONG_MAX /* max value for a off_t */\r
-#define __OFF_MIN __LLONG_MIN /* min value for a off_t */\r
-\r
-/* Quads and long longs are the same size. Ensure they stay in sync. */\r
-#define __UQUAD_MAX __ULLONG_MAX /* max value for a uquad_t */\r
-#define __QUAD_MAX __LLONG_MAX /* max value for a quad_t */\r
-#define __QUAD_MIN __LLONG_MIN /* min value for a quad_t */\r
-\r
-#ifdef _LARGE_LONG\r
-#define __LONG_BIT 64\r
-#else\r
-#define __LONG_BIT 32\r
-#endif\r
-#define __WORD_BIT 32\r
-\r
-/* Minimum signal stack size. */\r
-#define __MINSIGSTKSZ (1024 * 4)\r
-\r
-#endif /* !_MACHINE__LIMITS_H_ */\r
+/*-
+ * Copyright (c) 1988, 1993
+ * The Regents of the University of California. 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.
+ * 4. Neither the name of the University nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS 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 REGENTS 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.
+ *
+ * @(#)limits.h 8.3 (Berkeley) 1/4/94
+ * $FreeBSD$
+ */
+
+#ifndef _MACHINE__LIMITS_H_
+#define _MACHINE__LIMITS_H_
+
+/*
+ * According to ANSI (section 2.2.4.2), the values below must be usable by
+ * #if preprocessing directives. Additionally, the expression must have the
+ * same type as would an expression that is an object of the corresponding
+ * type converted according to the integral promotions. The subtraction for
+ * INT_MIN, etc., is so the value is not unsigned; e.g., 0x80000000 is an
+ * unsigned int for 32-bit two's complement ANSI compilers (section 3.1.3.2).
+ * These numbers are for the default configuration of gcc. They work for
+ * some other compilers as well, but this should not be depended on.
+ */
+
+#define __CHAR_BIT 8 /* number of bits in a char */
+
+#define __SCHAR_MAX 0x7f /* max value for a signed char */
+#define __SCHAR_MIN (-0x7f - 1) /* min value for a signed char */
+
+#define __UCHAR_MAX 0xff /* max value for an unsigned char */
+
+#define __USHRT_MAX 0xffff /* max value for an unsigned short */
+#define __SHRT_MAX 0x7fff /* max value for a short */
+#define __SHRT_MIN (-0x7fff - 1) /* min value for a short */
+
+#define __UINT_MAX 0xffffffffU /* max value for an unsigned int */
+#define __INT_MAX 0x7fffffff /* max value for an int */
+#define __INT_MIN (-0x7fffffff - 1) /* min value for an int */
+
+/* Bad hack for gcc configured to give 64-bit longs. */
+#ifdef _LARGE_LONG
+#define __ULONG_MAX 0xffffffffffffffffUL
+#define __LONG_MAX 0x7fffffffffffffffL
+#define __LONG_MIN (-0x7fffffffffffffffL - 1)
+#else
+#define __ULONG_MAX 0xffffffffUL /* max value for an unsigned long */
+#define __LONG_MAX 0x7fffffffL /* max value for a long */
+#define __LONG_MIN (-0x7fffffffL - 1) /* min value for a long */
+#endif
+
+ /* max value for an unsigned long long */
+#define __ULLONG_MAX 0xffffffffffffffffULL
+#define __LLONG_MAX 0x7fffffffffffffffLL /* max value for a long long */
+#define __LLONG_MIN (-0x7fffffffffffffffLL - 1) /* min for a long long */
+
+#define __SSIZE_MAX __INT_MAX /* max value for a ssize_t */
+
+#define __SIZE_T_MAX __UINT_MAX /* max value for a size_t */
+
+#define __OFF_MAX __LLONG_MAX /* max value for a off_t */
+#define __OFF_MIN __LLONG_MIN /* min value for a off_t */
+
+/* Quads and long longs are the same size. Ensure they stay in sync. */
+#define __UQUAD_MAX __ULLONG_MAX /* max value for a uquad_t */
+#define __QUAD_MAX __LLONG_MAX /* max value for a quad_t */
+#define __QUAD_MIN __LLONG_MIN /* min value for a quad_t */
+
+#ifdef _LARGE_LONG
+#define __LONG_BIT 64
+#else
+#define __LONG_BIT 32
+#endif
+#define __WORD_BIT 32
+
+/* Minimum signal stack size. */
+#define __MINSIGSTKSZ (1024 * 4)
+
+#endif /* !_MACHINE__LIMITS_H_ */
-/*-\r
- * Copyright (c) 2001 David E. O'Brien\r
- *\r
- * Redistribution and use in source and binary forms, with or without\r
- * modification, are permitted provided that the following conditions\r
- * are met:\r
- * 1. Redistributions of source code must retain the above copyright\r
- * notice, this list of conditions and the following disclaimer.\r
- * 2. Redistributions in binary form must reproduce the above copyright\r
- * notice, this list of conditions and the following disclaimer in the\r
- * documentation and/or other materials provided with the distribution.\r
- * 3. Neither the name of the University nor the names of its contributors\r
- * may be used to endorse or promote products derived from this software\r
- * without specific prior written permission.\r
- *\r
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND\r
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\r
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE\r
- * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE\r
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL\r
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS\r
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)\r
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT\r
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY\r
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF\r
- * SUCH DAMAGE.\r
- *\r
- * @(#)endian.h 8.1 (Berkeley) 6/10/93\r
- * $NetBSD: endian.h,v 1.7 1999/08/21 05:53:51 simonb Exp $\r
- * $FreeBSD$\r
- */\r
-\r
-#ifndef _ENDIAN_H_\r
-#define _ENDIAN_H_\r
-\r
-#include <sys/_types.h>\r
-\r
-/*\r
- * Definitions for byte order, according to byte significance from low\r
- * address to high.\r
- */\r
-#define _LITTLE_ENDIAN 1234 /* LSB first: i386, vax */\r
-#define _BIG_ENDIAN 4321 /* MSB first: 68000, ibm, net */\r
-#define _PDP_ENDIAN 3412 /* LSB first in word, MSW first in long */\r
-\r
-#ifdef __ARMEB__\r
-#define _BYTE_ORDER _BIG_ENDIAN\r
-#else\r
-#define _BYTE_ORDER _LITTLE_ENDIAN\r
-#endif /* __ARMEB__ */\r
-\r
-#if __BSD_VISIBLE\r
-#define LITTLE_ENDIAN _LITTLE_ENDIAN\r
-#define BIG_ENDIAN _BIG_ENDIAN\r
-#define PDP_ENDIAN _PDP_ENDIAN\r
-#define BYTE_ORDER _BYTE_ORDER\r
-#endif\r
-\r
-#ifdef __ARMEB__\r
-#define _QUAD_HIGHWORD 0\r
-#define _QUAD_LOWWORD 1\r
-#define __ntohl(x) ((__uint32_t)(x))\r
-#define __ntohs(x) ((__uint16_t)(x))\r
-#define __htonl(x) ((__uint32_t)(x))\r
-#define __htons(x) ((__uint16_t)(x))\r
-#else\r
-#define _QUAD_HIGHWORD 1\r
-#define _QUAD_LOWWORD 0\r
-#define __ntohl(x) (__bswap32(x))\r
-#define __ntohs(x) (__bswap16(x))\r
-#define __htonl(x) (__bswap32(x))\r
-#define __htons(x) (__bswap16(x))\r
-#endif /* __ARMEB__ */\r
-\r
-static __inline __uint64_t\r
-__bswap64(__uint64_t _x)\r
-{\r
-\r
- return ((_x >> 56) | ((_x >> 40) & 0xff00) | ((_x >> 24) & 0xff0000) |\r
- ((_x >> 8) & 0xff000000) | ((_x << 8) & ((__uint64_t)0xff << 32)) |\r
- ((_x << 24) & ((__uint64_t)0xff << 40)) | \r
- ((_x << 40) & ((__uint64_t)0xff << 48)) | ((_x << 56)));\r
-}\r
-\r
-static __inline __uint32_t\r
-__bswap32_var(__uint32_t v)\r
-{\r
- __uint32_t t1;\r
-\r
- __asm __volatile("eor %1, %0, %0, ror #16\n"\r
- "bic %1, %1, #0x00ff0000\n"\r
- "mov %0, %0, ror #8\n"\r
- "eor %0, %0, %1, lsr #8\n"\r
- : "+r" (v), "=r" (t1));\r
- \r
- return (v);\r
-}\r
-\r
-static __inline __uint16_t\r
-__bswap16_var(__uint16_t v)\r
-{\r
- __uint32_t ret = v & 0xffff;\r
-\r
- __asm __volatile(\r
- "mov %0, %0, ror #8\n"\r
- "orr %0, %0, %0, lsr #16\n"\r
- "bic %0, %0, %0, lsl #16"\r
- : "+r" (ret));\r
- \r
- return ((__uint16_t)ret);\r
-} \r
-\r
-#ifdef __OPTIMIZE__\r
-\r
-#define __bswap32_constant(x) \\r
- ((((x) & 0xff000000U) >> 24) | \\r
- (((x) & 0x00ff0000U) >> 8) | \\r
- (((x) & 0x0000ff00U) << 8) | \\r
- (((x) & 0x000000ffU) << 24))\r
-\r
-#define __bswap16_constant(x) \\r
- ((((x) & 0xff00) >> 8) | \\r
- (((x) & 0x00ff) << 8))\r
-\r
-#define __bswap16(x) \\r
- ((__uint16_t)(__builtin_constant_p(x) ? \\r
- __bswap16_constant(x) : \\r
- __bswap16_var(x)))\r
-\r
-#define __bswap32(x) \\r
- ((__uint32_t)(__builtin_constant_p(x) ? \\r
- __bswap32_constant(x) : \\r
- __bswap32_var(x)))\r
-\r
-#else\r
-#define __bswap16(x) __bswap16_var(x)\r
-#define __bswap32(x) __bswap32_var(x)\r
-\r
-#endif /* __OPTIMIZE__ */\r
-#endif /* !_ENDIAN_H_ */\r
-\r
+/*-
+ * Copyright (c) 2001 David E. O'Brien
+ *
+ * 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.
+ * 3. Neither the name of the University nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS 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 REGENTS 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.
+ *
+ * @(#)endian.h 8.1 (Berkeley) 6/10/93
+ * $NetBSD: endian.h,v 1.7 1999/08/21 05:53:51 simonb Exp $
+ * $FreeBSD$
+ */
+
+#ifndef _ENDIAN_H_
+#define _ENDIAN_H_
+
+#include <sys/_types.h>
+
+/*
+ * Definitions for byte order, according to byte significance from low
+ * address to high.
+ */
+#define _LITTLE_ENDIAN 1234 /* LSB first: i386, vax */
+#define _BIG_ENDIAN 4321 /* MSB first: 68000, ibm, net */
+#define _PDP_ENDIAN 3412 /* LSB first in word, MSW first in long */
+
+#ifdef __ARMEB__
+#define _BYTE_ORDER _BIG_ENDIAN
+#else
+#define _BYTE_ORDER _LITTLE_ENDIAN
+#endif /* __ARMEB__ */
+
+#if __BSD_VISIBLE
+#define LITTLE_ENDIAN _LITTLE_ENDIAN
+#define BIG_ENDIAN _BIG_ENDIAN
+#define PDP_ENDIAN _PDP_ENDIAN
+#define BYTE_ORDER _BYTE_ORDER
+#endif
+
+#ifdef __ARMEB__
+#define _QUAD_HIGHWORD 0
+#define _QUAD_LOWWORD 1
+#define __ntohl(x) ((__uint32_t)(x))
+#define __ntohs(x) ((__uint16_t)(x))
+#define __htonl(x) ((__uint32_t)(x))
+#define __htons(x) ((__uint16_t)(x))
+#else
+#define _QUAD_HIGHWORD 1
+#define _QUAD_LOWWORD 0
+#define __ntohl(x) (__bswap32(x))
+#define __ntohs(x) (__bswap16(x))
+#define __htonl(x) (__bswap32(x))
+#define __htons(x) (__bswap16(x))
+#endif /* __ARMEB__ */
+
+static __inline __uint64_t
+__bswap64(__uint64_t _x)
+{
+
+ return ((_x >> 56) | ((_x >> 40) & 0xff00) | ((_x >> 24) & 0xff0000) |
+ ((_x >> 8) & 0xff000000) | ((_x << 8) & ((__uint64_t)0xff << 32)) |
+ ((_x << 24) & ((__uint64_t)0xff << 40)) |
+ ((_x << 40) & ((__uint64_t)0xff << 48)) | ((_x << 56)));
+}
+
+static __inline __uint32_t
+__bswap32_var(__uint32_t v)
+{
+ __uint32_t t1;
+
+ __asm __volatile("eor %1, %0, %0, ror #16\n"
+ "bic %1, %1, #0x00ff0000\n"
+ "mov %0, %0, ror #8\n"
+ "eor %0, %0, %1, lsr #8\n"
+ : "+r" (v), "=r" (t1));
+
+ return (v);
+}
+
+static __inline __uint16_t
+__bswap16_var(__uint16_t v)
+{
+ __uint32_t ret = v & 0xffff;
+
+ __asm __volatile(
+ "mov %0, %0, ror #8\n"
+ "orr %0, %0, %0, lsr #16\n"
+ "bic %0, %0, %0, lsl #16"
+ : "+r" (ret));
+
+ return ((__uint16_t)ret);
+}
+
+#ifdef __OPTIMIZE__
+
+#define __bswap32_constant(x) \
+ ((((x) & 0xff000000U) >> 24) | \
+ (((x) & 0x00ff0000U) >> 8) | \
+ (((x) & 0x0000ff00U) << 8) | \
+ (((x) & 0x000000ffU) << 24))
+
+#define __bswap16_constant(x) \
+ ((((x) & 0xff00) >> 8) | \
+ (((x) & 0x00ff) << 8))
+
+#define __bswap16(x) \
+ ((__uint16_t)(__builtin_constant_p(x) ? \
+ __bswap16_constant(x) : \
+ __bswap16_var(x)))
+
+#define __bswap32(x) \
+ ((__uint32_t)(__builtin_constant_p(x) ? \
+ __bswap32_constant(x) : \
+ __bswap32_var(x)))
+
+#else
+#define __bswap16(x) __bswap16_var(x)
+#define __bswap32(x) __bswap32_var(x)
+
+#endif /* __OPTIMIZE__ */
+#endif /* !_ENDIAN_H_ */
+
-/*-\r
- * Copyright (c) 1988, 1993\r
- * The Regents of the University of California. All rights reserved.\r
- *\r
- * Redistribution and use in source and binary forms, with or without\r
- * modification, are permitted provided that the following conditions\r
- * are met:\r
- * 1. Redistributions of source code must retain the above copyright\r
- * notice, this list of conditions and the following disclaimer.\r
- * 2. Redistributions in binary form must reproduce the above copyright\r
- * notice, this list of conditions and the following disclaimer in the\r
- * documentation and/or other materials provided with the distribution.\r
- * 4. Neither the name of the University nor the names of its contributors\r
- * may be used to endorse or promote products derived from this software\r
- * without specific prior written permission.\r
- *\r
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND\r
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\r
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE\r
- * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE\r
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL\r
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS\r
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)\r
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT\r
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY\r
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF\r
- * SUCH DAMAGE.\r
- *\r
- * @(#)limits.h 8.3 (Berkeley) 1/4/94\r
- * $FreeBSD$\r
- */\r
-\r
-#ifndef _MACHINE__LIMITS_H_\r
-#define _MACHINE__LIMITS_H_\r
-\r
-/*\r
- * According to ANSI (section 2.2.4.2), the values below must be usable by\r
- * #if preprocessing directives. Additionally, the expression must have the\r
- * same type as would an expression that is an object of the corresponding\r
- * type converted according to the integral promotions. The subtraction for\r
- * INT_MIN, etc., is so the value is not unsigned; e.g., 0x80000000 is an\r
- * unsigned int for 32-bit two's complement ANSI compilers (section 3.1.3.2).\r
- * These numbers are for the default configuration of gcc. They work for\r
- * some other compilers as well, but this should not be depended on.\r
- */\r
-\r
-#define __CHAR_BIT 8 /* number of bits in a char */\r
-\r
-#define __SCHAR_MAX 0x7f /* max value for a signed char */\r
-#define __SCHAR_MIN (-0x7f - 1) /* min value for a signed char */\r
-\r
-#define __UCHAR_MAX 0xff /* max value for an unsigned char */\r
-\r
-#define __USHRT_MAX 0xffff /* max value for an unsigned short */\r
-#define __SHRT_MAX 0x7fff /* max value for a short */\r
-#define __SHRT_MIN (-0x7fff - 1) /* min value for a short */\r
-\r
-#define __UINT_MAX 0xffffffffU /* max value for an unsigned int */\r
-#define __INT_MAX 0x7fffffff /* max value for an int */\r
-#define __INT_MIN (-0x7fffffff - 1) /* min value for an int */\r
-\r
-/* Bad hack for gcc configured to give 64-bit longs. */\r
-#ifdef _LARGE_LONG\r
-#define __ULONG_MAX 0xffffffffffffffffUL\r
-#define __LONG_MAX 0x7fffffffffffffffL\r
-#define __LONG_MIN (-0x7fffffffffffffffL - 1)\r
-#else\r
-#define __ULONG_MAX 0xffffffffUL /* max value for an unsigned long */\r
-#define __LONG_MAX 0x7fffffffL /* max value for a long */\r
-#define __LONG_MIN (-0x7fffffffL - 1) /* min value for a long */\r
-#endif\r
-\r
- /* max value for an unsigned long long */\r
-#define __ULLONG_MAX 0xffffffffffffffffULL\r
-#define __LLONG_MAX 0x7fffffffffffffffLL /* max value for a long long */\r
-#define __LLONG_MIN (-0x7fffffffffffffffLL - 1) /* min for a long long */\r
-\r
-#define __SSIZE_MAX __INT_MAX /* max value for a ssize_t */\r
-\r
-#define __SIZE_T_MAX __UINT_MAX /* max value for a size_t */\r
-\r
-#define __OFF_MAX __LLONG_MAX /* max value for a off_t */\r
-#define __OFF_MIN __LLONG_MIN /* min value for a off_t */\r
-\r
-/* Quads and long longs are the same size. Ensure they stay in sync. */\r
-#define __UQUAD_MAX __ULLONG_MAX /* max value for a uquad_t */\r
-#define __QUAD_MAX __LLONG_MAX /* max value for a quad_t */\r
-#define __QUAD_MIN __LLONG_MIN /* min value for a quad_t */\r
-\r
-#ifdef _LARGE_LONG\r
-#define __LONG_BIT 64\r
-#else\r
-#define __LONG_BIT 32\r
-#endif\r
-#define __WORD_BIT 32\r
-\r
-/* Minimum signal stack size. */\r
-#define __MINSIGSTKSZ (1024 * 4)\r
-\r
-#endif /* !_MACHINE__LIMITS_H_ */\r
+/*-
+ * Copyright (c) 1988, 1993
+ * The Regents of the University of California. 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.
+ * 4. Neither the name of the University nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS 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 REGENTS 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.
+ *
+ * @(#)limits.h 8.3 (Berkeley) 1/4/94
+ * $FreeBSD$
+ */
+
+#ifndef _MACHINE__LIMITS_H_
+#define _MACHINE__LIMITS_H_
+
+/*
+ * According to ANSI (section 2.2.4.2), the values below must be usable by
+ * #if preprocessing directives. Additionally, the expression must have the
+ * same type as would an expression that is an object of the corresponding
+ * type converted according to the integral promotions. The subtraction for
+ * INT_MIN, etc., is so the value is not unsigned; e.g., 0x80000000 is an
+ * unsigned int for 32-bit two's complement ANSI compilers (section 3.1.3.2).
+ * These numbers are for the default configuration of gcc. They work for
+ * some other compilers as well, but this should not be depended on.
+ */
+
+#define __CHAR_BIT 8 /* number of bits in a char */
+
+#define __SCHAR_MAX 0x7f /* max value for a signed char */
+#define __SCHAR_MIN (-0x7f - 1) /* min value for a signed char */
+
+#define __UCHAR_MAX 0xff /* max value for an unsigned char */
+
+#define __USHRT_MAX 0xffff /* max value for an unsigned short */
+#define __SHRT_MAX 0x7fff /* max value for a short */
+#define __SHRT_MIN (-0x7fff - 1) /* min value for a short */
+
+#define __UINT_MAX 0xffffffffU /* max value for an unsigned int */
+#define __INT_MAX 0x7fffffff /* max value for an int */
+#define __INT_MIN (-0x7fffffff - 1) /* min value for an int */
+
+/* Bad hack for gcc configured to give 64-bit longs. */
+#ifdef _LARGE_LONG
+#define __ULONG_MAX 0xffffffffffffffffUL
+#define __LONG_MAX 0x7fffffffffffffffL
+#define __LONG_MIN (-0x7fffffffffffffffL - 1)
+#else
+#define __ULONG_MAX 0xffffffffUL /* max value for an unsigned long */
+#define __LONG_MAX 0x7fffffffL /* max value for a long */
+#define __LONG_MIN (-0x7fffffffL - 1) /* min value for a long */
+#endif
+
+ /* max value for an unsigned long long */
+#define __ULLONG_MAX 0xffffffffffffffffULL
+#define __LLONG_MAX 0x7fffffffffffffffLL /* max value for a long long */
+#define __LLONG_MIN (-0x7fffffffffffffffLL - 1) /* min for a long long */
+
+#define __SSIZE_MAX __INT_MAX /* max value for a ssize_t */
+
+#define __SIZE_T_MAX __UINT_MAX /* max value for a size_t */
+
+#define __OFF_MAX __LLONG_MAX /* max value for a off_t */
+#define __OFF_MIN __LLONG_MIN /* min value for a off_t */
+
+/* Quads and long longs are the same size. Ensure they stay in sync. */
+#define __UQUAD_MAX __ULLONG_MAX /* max value for a uquad_t */
+#define __QUAD_MAX __LLONG_MAX /* max value for a quad_t */
+#define __QUAD_MIN __LLONG_MIN /* min value for a quad_t */
+
+#ifdef _LARGE_LONG
+#define __LONG_BIT 64
+#else
+#define __LONG_BIT 32
+#endif
+#define __WORD_BIT 32
+
+/* Minimum signal stack size. */
+#define __MINSIGSTKSZ (1024 * 4)
+
+#endif /* !_MACHINE__LIMITS_H_ */
-/**\r
- * \file\r
- * \brief Barrelfish collections library hash table\r
- */\r
-/*\r
- * Copyright (c) 2010, ETH Zurich.\r
- * All rights reserved.\r
- *\r
- * This file is distributed under the terms in the attached LICENSE file.\r
- * If you do not find this file, copies can be found by writing to:\r
- * ETH Zurich D-INFK, Haldeneggsteig 4, CH-8092 Zurich. Attn: Systems Group.\r
- */\r
-\r
-#ifndef _HASH_TABLE_H_\r
-#define _HASH_TABLE_H_\r
-\r
-#include "collections/list.h"\r
-\r
-/*\r
- * a simple hash table. \r
- */\r
-\r
-typedef void (* collections_hash_data_free)(void *);\r
-\r
-typedef struct _collections_hash_table {\r
- // number of buckets in the table.\r
- int num_buckets;\r
-\r
- // pointer to the buckets.\r
- collections_listnode **buckets;\r
-\r
- // total number of elements in the table.\r
- uint32_t num_elems;\r
-\r
- // function that knows how to free inserted data resources\r
- collections_hash_data_free data_free;\r
-\r
- // a pointer to keep track of \r
- // traversing the hash table\r
- int32_t cur_bucket_num;\r
-} collections_hash_table;\r
-\r
-/*\r
- * Structure of a hash table element.\r
- */\r
-typedef struct _collections_hash_elem {\r
-\r
- uint64_t key;\r
-\r
- void *data;\r
-} collections_hash_elem;\r
-\r
-#define NUM_BUCKETS 1013\r
-\r
-#ifdef __cplusplus\r
-extern "C" {\r
-#endif // __cplusplus\r
-\r
-\r
-/*\r
- * functions ...\r
- */\r
-void collections_hash_create(collections_hash_table **t, collections_hash_data_free f);\r
-void collections_hash_create_with_buckets(collections_hash_table **t, int num_buckets, collections_hash_data_free f);\r
-void collections_hash_release(collections_hash_table *t);\r
-void collections_hash_insert(collections_hash_table *t, uint64_t key, void *data);\r
-void* collections_hash_find(collections_hash_table *t, uint64_t key);\r
-void collections_hash_delete(collections_hash_table *t, uint64_t key);\r
-uint32_t collections_hash_size(collections_hash_table *t);\r
-int32_t collections_hash_traverse_start(collections_hash_table* t);\r
-void* collections_hash_traverse_next(collections_hash_table* t, uint64_t *key);\r
-int32_t collections_hash_traverse_end(collections_hash_table* t);\r
-\r
-/*\r
- * Visitor function: returns 0 when visit should be considered finish.\r
- */\r
-typedef int (*collections_hash_visitor_func)(uint64_t key, void *data, void *arg);\r
-\r
-/*\r
- * Apply function to all elements in hash table or until function indicates\r
- * function application should stop.\r
- *\r
- * Returns non-zero if all elements in table visited, 0 otherwise.\r
- */\r
-int collections_hash_visit(collections_hash_table *t, collections_hash_visitor_func collections_hash_visitor, void *arg);\r
-\r
-#ifdef __cplusplus\r
-}\r
-#endif // __cplusplus\r
-\r
-#endif\r
+/**
+ * \file
+ * \brief Barrelfish collections library hash table
+ */
+/*
+ * Copyright (c) 2010, ETH Zurich.
+ * All rights reserved.
+ *
+ * This file is distributed under the terms in the attached LICENSE file.
+ * If you do not find this file, copies can be found by writing to:
+ * ETH Zurich D-INFK, Haldeneggsteig 4, CH-8092 Zurich. Attn: Systems Group.
+ */
+
+#ifndef _HASH_TABLE_H_
+#define _HASH_TABLE_H_
+
+#include "collections/list.h"
+
+/*
+ * a simple hash table.
+ */
+
+typedef void (* collections_hash_data_free)(void *);
+
+typedef struct _collections_hash_table {
+ // number of buckets in the table.
+ int num_buckets;
+
+ // pointer to the buckets.
+ collections_listnode **buckets;
+
+ // total number of elements in the table.
+ uint32_t num_elems;
+
+ // function that knows how to free inserted data resources
+ collections_hash_data_free data_free;
+
+ // a pointer to keep track of
+ // traversing the hash table
+ int32_t cur_bucket_num;
+} collections_hash_table;
+
+/*
+ * Structure of a hash table element.
+ */
+typedef struct _collections_hash_elem {
+
+ uint64_t key;
+
+ void *data;
+} collections_hash_elem;
+
+#define NUM_BUCKETS 1013
+
+#ifdef __cplusplus
+extern "C" {
+#endif // __cplusplus
+
+
+/*
+ * functions ...
+ */
+void collections_hash_create(collections_hash_table **t, collections_hash_data_free f);
+void collections_hash_create_with_buckets(collections_hash_table **t, int num_buckets, collections_hash_data_free f);
+void collections_hash_release(collections_hash_table *t);
+void collections_hash_insert(collections_hash_table *t, uint64_t key, void *data);
+void* collections_hash_find(collections_hash_table *t, uint64_t key);
+void collections_hash_delete(collections_hash_table *t, uint64_t key);
+uint32_t collections_hash_size(collections_hash_table *t);
+int32_t collections_hash_traverse_start(collections_hash_table* t);
+void* collections_hash_traverse_next(collections_hash_table* t, uint64_t *key);
+int32_t collections_hash_traverse_end(collections_hash_table* t);
+
+/*
+ * Visitor function: returns 0 when visit should be considered finish.
+ */
+typedef int (*collections_hash_visitor_func)(uint64_t key, void *data, void *arg);
+
+/*
+ * Apply function to all elements in hash table or until function indicates
+ * function application should stop.
+ *
+ * Returns non-zero if all elements in table visited, 0 otherwise.
+ */
+int collections_hash_visit(collections_hash_table *t, collections_hash_visitor_func collections_hash_visitor, void *arg);
+
+#ifdef __cplusplus
+}
+#endif // __cplusplus
+
+#endif
-/**\r
- * \brief this file contains definitions for the the USB HID class\r
- */\r
-\r
-/*\r
- * Copyright (c) 2007-2013 ETH Zurich.\r
- * All rights reserved.\r
- *\r
- * This file is distributed under the terms in the attached LICENSE file.\r
- * If you do not find this file, copies can be found by writing to:\r
- * ETH Zurich D-INFK, Haldeneggsteig 4, CH-8092 Zurich. Attn: Systems Group.\r
- */\r
-\r
-#ifndef LIBUSB_CLASS_HID_H_\r
-#define LIBUSB_CLASS_HID_H_\r
-\r
-#include <usb/usb_descriptor.h>\r
-\r
-#define USB_HID_CLASS_CODE 0x3\r
-#define USB_HID_SUBCLASS_CODE_BOOT 0x1\r
-#define USB_HID_PROTOCOL_NONE 0x0\r
-#define USB_HID_PROTOCOL_KEYBOARD 0x1\r
-#define USB_HID_PROTOCOL_MOUSE 0x2\r
-\r
-/*\r
- * USB HID class descriptor types\r
- */\r
-\r
-/// Descriptor type for the HID\r
-#define USB_DESCRIPTOR_TYPE_HID 0x21\r
-\r
-/// Descriptor type for HID report\r
-#define USB_DESCRIPTOR_TYPE_REPORT 0x22\r
-\r
-/// descriptor type for HID physical\r
-#define USB_DESCRIPTOR_TYPE_PHYSICAL 0x23\r
-\r
-/*\r
- * HID class specific request types\r
- */\r
-\r
-#define USB_HID_REQUEST_GET_REPORT 0x01\r
-#define USB_HID_REQUEST_SET_REPORT 0x09\r
-\r
-#define USB_HID_REQUEST_GET_IDLE 0x02\r
-#define USB_HID_REQUEST_SET_IDLE 0x0A\r
-\r
-#define USB_HID_REQUEST_GET_PROTOCOL 0x03\r
-#define USB_HID_REQUEST_SET_PROTOCOL 0x0B\r
-\r
-#define USB_HID_REQUEST_GET_DESCRIPTOR 0x06\r
-#define USB_HID_REQUEST_SET_DESCRIPTOR 0x07\r
-\r
-/**\r
- * struct definition for a HID descriptor type\r
- * XXX: the length cannot be an uint16, because of alignment issues\r
- */\r
-struct usb_hid_dtype {\r
- uint8_t bDescriptorType; ///< the type of the optional descriptor\r
- uint8_t wDescriptorLength[2]; ///< the size of the optional descriptor\r
-}__attribute__((packed));\r
-\r
-/// type definition of the HID descriptor type\r
-typedef struct usb_hid_dtype usb_hid_dtype_t;\r
-\r
-/// makro definition for getting the length of a descriptor type\r
-#define USB_HID_DTYPE_GET_LEN(_d) \\r
- ((_d)->wDescriptorLength[0] | ((uint16_t)((_d)->wDescriptorLength[1] << 8)))\r
-\r
-/**\r
- * USB HID Descriptor Type\r
- * Device Class Definition for HID Devices, Section 6.2.1\r
- *\r
- * Note: This descriptor is of variable size, the last field descriptors\r
- * contains the information of at least one descriptor (i.e. the report\r
- * descriptor)\r
- */\r
-struct usb_hid_descriptor {\r
- uint8_t bLength; ///< the total size in bytes of this descr\r
- uint8_t bDescriptorType; ///< constant, specifying the HID descr type\r
- uint16_t bcdHID; ///< HID class specific release version\r
- uint8_t bCountryCode; ///< country code for localized hardware\r
- uint8_t bNumDescriptors; ///< the number of class descriptors > 1\r
- usb_hid_dtype_t descriptors[1]; ///< subordinate descriptors\r
-}__attribute__((packed));\r
-\r
-/// USB HID descriptor type\r
-typedef struct usb_hid_descriptor usb_hid_descriptor_t;\r
-\r
-/// calcualtes the size of the HID descriptor\r
-#define USB_HID_DESCRIPTOR_SIZE(n) (9+((n)*3))\r
-\r
-/*\r
- * -------------------------------------------------------------------------\r
- * USB HID class report items\r
- * -------------------------------------------------------------------------\r
- */\r
-\r
-#define USB_HID_REPORT_INPUT 0x01\r
-#define USB_HID_REPORT_OUTPUT 0x02\r
-#define USB_HID_REPORT_FEATURE 0x03\r
-\r
-/*\r
- * some flags\r
- */\r
-#define USB_HID_IO_CONST 0x001\r
-#define USB_HID_IO_VARIABLE 0x002\r
-#define USB_HID_IO_RELATIVE 0x004\r
-#define USB_HID_IO_WRAP 0x008\r
-#define USB_HID_IO_NONLINEAR 0x010\r
-#define USB_HID_IO_NOPREF 0x020\r
-#define USB_HID_IO_NULLSTATE 0x040\r
-#define USB_HID_IO_VOLATILE 0x080\r
-#define USB_HID_IO_BUFBYTES 0x100\r
-\r
-/// enumeration representing the type of the report item\r
-enum usb_hid_kind {\r
- USB_HID_KIND_INPUT = 0, ///< input report\r
- USB_HID_KIND_OUTPUT = 1, ///< output report\r
- USB_HID_KIND_FEATURE = 2, ///< feature report\r
- USB_HID_KIND_COLLECTION = 3, ///< collection start\r
- USB_HID_KIND_ENDCOLLECTION = 4, ///< collection end\r
-};\r
-\r
-/// struct definition for report id - position association\r
-struct usb_hid_pos_data {\r
- int32_t rid; ///< report id\r
- uint32_t position; ///< position\r
-};\r
-\r
-/// struct definition for storing information about the HID item in an report\r
-struct usb_hid_location {\r
- uint32_t size; ///< the size of one item element\r
- uint32_t count; ///< the number of elements in this location\r
- uint32_t position; ///< the position within the report\r
-};\r
-\r
-/// This struct represents an item in a USB report\r
-struct usb_hid_item {\r
- /* Global */\r
- int32_t _usage_page; ///<\r
- int32_t logical_minimum; ///<\r
- int32_t logical_maximum; ///<\r
- int32_t physical_minimum; ///<\r
- int32_t physical_maximum; ///<\r
- int32_t unit_exponent; ///<\r
- int32_t unit; ///<\r
- int32_t report_ID; ///<\r
- /* Local */\r
- int32_t usage; ///<\r
- int32_t usage_minimum; ///<\r
- int32_t usage_maximum; ///<\r
- int32_t designator_index; ///<\r
- int32_t designator_minimum; ///<\r
- int32_t designator_maximum; ///<\r
- int32_t string_index; ///<\r
- int32_t string_minimum; ///<\r
- int32_t string_maximum; ///<\r
- int32_t set_delimiter; ///<\r
- /* Misc */\r
- int32_t collection; ///<\r
- int32_t collevel; ///<\r
- enum usb_hid_kind kind; ///<\r
- uint32_t flags; ///<\r
- /* Location */\r
- struct usb_hid_location loc; ///<\r
-};\r
-\r
-/*\r
- * definitions for parsing the report descriptors\r
- */\r
-\r
-#define USB_HID_MAXUSAGE 64\r
-#define USB_HID_MAXPUSH 4\r
-#define USB_HID_MAXID 16\r
-\r
-/**\r
- * this structure is used for storing the necessary data when parsing\r
- * USB HID reports\r
- */\r
-struct usb_hid_data {\r
- const uint8_t *start;\r
- const uint8_t *end;\r
- const uint8_t *p;\r
- struct usb_hid_item cur[USB_HID_MAXPUSH];\r
- struct usb_hid_pos_data last_pos[USB_HID_MAXID];\r
- int32_t usages_min[USB_HID_MAXUSAGE];\r
- int32_t usages_max[USB_HID_MAXUSAGE];\r
- int32_t usage_last; /* last seen usage */\r
- uint32_t loc_size; /* last seen size */\r
- uint32_t loc_count; /* last seen count */\r
- uint8_t kindset; /* we have 5 kinds so 8 bits are enough */\r
- uint8_t pushlevel; /* current pushlevel */\r
- uint8_t ncount; /* end usage item count */\r
- uint8_t icount; /* current usage item count */\r
- uint8_t nusage; /* end "usages_min/max" index */\r
- uint8_t iusage; /* current "usages_min/max" index */\r
- uint8_t ousage; /* current "usages_min/max" offset */\r
- uint8_t susage; /* usage set flags */\r
-};\r
-\r
-#define USB_HID_REQUEST_TYPE_WRITE 0xA1\r
-#define USB_HID_REQUEST_TYPE_READ 0x21\r
-\r
-#define USB_HID_REQUEST_VALUE_IN 0x01\r
-#define USB_HID_REQUEST_VALUE_OUT 0x02\r
-#define USB_HID_REQUEST_VALUE_FEATURE 0x03\r
-\r
-/*\r
- * -------------------------------------------------------------------------\r
- * Country Codes\r
- * -------------------------------------------------------------------------\r
- */\r
-\r
-#define USB_HID_COUNTRY_DEFAULT 0\r
-#define USB_HID_COUNTRY_ARABIC 1\r
-#define USB_HID_COUNTRY_BELGIAN 2\r
-#define USB_HID_COUNTRY_CANADIAN 3\r
-#define USB_HID_COUNTRY_CANADIAN_FRENCH 4\r
-#define USB_HID_COUNTRY_CZECH 5\r
-#define USB_HID_COUNTRY_DANISH 6\r
-#define USB_HID_COUNTRY_FINNISH 7\r
-#define USB_HID_COUNTRY_FRENCH 8\r
-#define USB_HID_COUNTRY_GERMAN 9\r
-#define USB_HID_COUNTRY_GREEK 10\r
-#define USB_HID_COUNTRY_HEBREW 11\r
-#define USB_HID_COUNTRY_HUNGARY 12\r
-#define USB_HID_COUNTRY_INTERNATIONAL 13\r
-#define USB_HID_COUNTRY_ITALIAN 14\r
-#define USB_HID_COUNTRY_JAPAN 15\r
-#define USB_HID_COUNTRY_KOREAN 16\r
-#define USB_HID_COUNTRY_LATIN 17\r
-#define USB_HID_COUNTRY_DUTCH 18\r
-#define USB_HID_COUNTRY_NORWEGIAN 19\r
-#define USB_HID_COUNTRY_PERSIAN 20\r
-#define USB_HID_COUNTRY_POLAND 21\r
-#define USB_HID_COUNTRY_PORTUGUESE 22\r
-#define USB_HID_COUNTRY_RUSSIA 23\r
-#define USB_HID_COUNTRY_SLOVAKIA 24\r
-#define USB_HID_COUNTRY_SPANISH 25\r
-#define USB_HID_COUNTRY_SWEDISH 26\r
-#define USB_HID_COUNTRY_SWISS_FRENCH 27\r
-#define USB_HID_COUNTRY_SWISS_GERMAN 28\r
-#define USB_HID_COUNTRY_SWITZERLAND 29\r
-#define USB_HID_COUNTRY_TAIWAN 30\r
-#define USB_HID_COUNTRY_TURKISH_Q 31\r
-#define USB_HID_COUNTRY_UK 32\r
-#define USB_HID_COUNTRY_US 33\r
-#define USB_HID_COUNTRY_YUGOSLAVIA 34\r
-#define USB_HID_COUNTRY_TURKISH_F 35\r
-// other 36-255 reserved\r
-\r
-/*\r
- * -------------------------------------------------------------------------\r
- * USB HID Physical Designator Values\r
- *\r
- * This defines specify which part of the human body\r
- * triggered the input.\r
- *\r
- * e.g. the hand or finger\r
- * -------------------------------------------------------------------------\r
- */\r
-#define USB_HID_DESIGNATOR_NONE 0x00\r
-#define USB_HID_DESIGNATOR_HAND 0x01\r
-#define USB_HID_DESIGNATOR_EYEBALL 0x02\r
-#define USB_HID_DESIGNATOR_EYEBROW 0x03\r
-#define USB_HID_DESIGNATOR_EYELID 0x04\r
-#define USB_HID_DESIGNATOR_EAR 0x05\r
-#define USB_HID_DESIGNATOR_NOSE 0x06\r
-#define USB_HID_DESIGNATOR_MOUTH 0x07\r
-#define USB_HID_DESIGNATOR_UPPER_LIP 0x08\r
-#define USB_HID_DESIGNATOR_LOWER_LIP 0x09\r
-#define USB_HID_DESIGNATOR_JAW 0x0A\r
-#define USB_HID_DESIGNATOR_NECK 0x0B\r
-#define USB_HID_DESIGNATOR_UPPER_ARM 0x0C\r
-#define USB_HID_DESIGNATOR_ELBOW 0x0D\r
-#define USB_HID_DESIGNATOR_FOREARM 0x0E\r
-#define USB_HID_DESIGNATOR_WRIST 0x0F\r
-#define USB_HID_DESIGNATOR_PALM 0x10\r
-#define USB_HID_DESIGNATOR_THUMB 0x11\r
-#define USB_HID_DESIGNATOR_I_FINGER 0x12\r
-#define USB_HID_DESIGNATOR_M_FINGER 0x13\r
-#define USB_HID_DESIGNATOR_R_FINGER 0x14\r
-#define USB_HID_DESIGNATOR_L_FINGER 0x15\r
-#define USB_HID_DESIGNATOR_HEAD 0x16\r
-#define USB_HID_DESIGNATOR_SHOULDER 0x17\r
-#define USB_HID_DESIGNATOR_HIP 0x18\r
-#define USB_HID_DESIGNATOR_WAIST 0x19\r
-#define USB_HID_DESIGNATOR_THIGH 0x1A\r
-#define USB_HID_DESIGNATOR_KNEE 0x1B\r
-#define USB_HID_DESIGNATOR_CALF 0x1C\r
-#define USB_HID_DESIGNATOR_ANKLE 0x1D\r
-#define USB_HID_DESIGNATOR_FOOT 0x1E\r
-#define USB_HID_DESIGNATOR_HEEL 0x1F\r
-#define USB_HID_DESIGNATOR_BALL_FOOT 0x20\r
-#define USB_HID_DESIGNATOR_BIG_TOE 0x21\r
-#define USB_HID_DESIGNATOR_TOE_2 0x22\r
-#define USB_HID_DESIGNATOR_TOE_3 0x23\r
-#define USB_HID_DESIGNATOR_TOE_4 0x24\r
-#define USB_HID_DESIGNATOR_TOE_5 0x25\r
-#define USB_HID_DESIGNATOR_BROW 0x26\r
-#define USB_HID_DESIGNATOR_CHEEK 0x27\r
-/* 28-FF reserved */\r
-\r
-/*\r
- * -------------------------------------------------------------------------\r
- * USB HID Physical Qualifier Fields\r
- *\r
- * This values represent which of the possible multiple input\r
- * designators triggered the input.\r
- *\r
- * e.g. right or left hand\r
- * -------------------------------------------------------------------------\r
- */\r
-#define USB_HID_PHYSICAL_QUALIFIER_NONE 0x0\r
-#define USB_HID_PHYSICAL_QUALIFIER_RIGHT 0x1\r
-#define USB_HID_PHYSICAL_QUALIFIER_LEFT 0x2\r
-#define USB_HID_PHYSICAL_QUALIFIER_BOTH 0x3\r
-#define USB_HID_PHYSICAL_QUALIFIER_EITHER 0x4\r
-#define USB_HID_PHYSICAL_QUALIFIER_CENTER 0x5\r
-#define USB_HID_PHYSICAL_QUALIFIER_RESERVED 0x6\r
-#define USB_HID_PHYSICAL_QUALIFIER_RESERVED_ 0x7\r
-\r
-/*\r
- * -------------------------------------------------------------------------\r
- * USB HID Usages\r
- * -------------------------------------------------------------------------\r
- */\r
-#define USB_HID_USAGE_UNDEFINED 0x0000\r
-#define USB_HID_USAGE_GENERIC_DESKTOP 0x0001\r
-#define USB_HID_USAGE_SIMULATION 0x0002\r
-#define USB_HID_USAGE_VR_CONTROLS 0x0003\r
-#define USB_HID_USAGE_SPORTS_CONTROLS 0x0004\r
-#define USB_HID_USAGE_GAMING_CONTROLS 0x0005\r
-#define USB_HID_USAGE_KEYBOARD 0x0007\r
-#define USB_HID_USAGE_LEDS 0x0008\r
-#define USB_HID_USAGE_BUTTON 0x0009\r
-#define USB_HID_USAGE_ORDINALS 0x000a\r
-#define USB_HID_USAGE_TELEPHONY 0x000b\r
-#define USB_HID_USAGE_CONSUMER 0x000c\r
-#define USB_HID_USAGE_DIGITIZERS 0x000d\r
-#define USB_HID_USAGE_PHYSICAL_IFACE 0x000e\r
-#define USB_HID_USAGE_UNICODE 0x0010\r
-#define USB_HID_USAGE_ALPHANUM_DISPLAY 0x0014\r
-#define USB_HID_USAGE_MONITOR 0x0080\r
-#define USB_HID_USAGE_MONITOR_ENUM_VAL 0x0081\r
-#define USB_HID_USAGE_VESA_VC 0x0082\r
-#define USB_HID_USAGE_VESA_CMD 0x0083\r
-#define USB_HID_USAGE_POWER 0x0084\r
-#define USB_HID_USAGE_BATTERY_SYSTEM 0x0085\r
-#define USB_HID_USAGE_BARCODE_SCANNER 0x008b\r
-#define USB_HID_USAGE_SCALE 0x008c\r
-#define USB_HID_USAGE_CAMERA_CONTROL 0x0090\r
-#define USB_HID_USAGE_ARCADE 0x0091\r
-#define USB_HID_USAGE_MICROSOFT 0xff00\r
-\r
-/* Usages, generic desktop */\r
-#define USB_HID_USAGE_POINTER 0x0001\r
-#define USB_HID_USAGE_MOUSE 0x0002\r
-#define USB_HID_USAGE_JOYSTICK 0x0004\r
-#define USB_HID_USAGE_GAME_PAD 0x0005\r
-#define USB_HID_USAGE_DKEYBOARD 0x0006\r
-#define USB_HID_USAGE_KEYPAD 0x0007\r
-#define USB_HID_USAGE_X 0x0030\r
-#define USB_HID_USAGE_Y 0x0031\r
-#define USB_HID_USAGE_Z 0x0032\r
-#define USB_HID_USAGE_RX 0x0033\r
-#define USB_HID_USAGE_RY 0x0034\r
-#define USB_HID_USAGE_RZ 0x0035\r
-#define USB_HID_USAGE_SLIDER 0x0036\r
-#define USB_HID_USAGE_DIAL 0x0037\r
-#define USB_HID_USAGE_WHEEL 0x0038\r
-#define USB_HID_USAGE_HAT_SWITCH 0x0039\r
-#define USB_HID_USAGE_COUNTED_BUFFER 0x003a\r
-#define USB_HID_USAGE_BYTE_COUNT 0x003b\r
-#define USB_HID_USAGE_MOTION_WAKEUP 0x003c\r
-#define USB_HID_USAGE_VX 0x0040\r
-#define USB_HID_USAGE_VY 0x0041\r
-#define USB_HID_USAGE_VZ 0x0042\r
-#define USB_HID_USAGE_VBRX 0x0043\r
-#define USB_HID_USAGE_VBRY 0x0044\r
-#define USB_HID_USAGE_VBRZ 0x0045\r
-#define USB_HID_USAGE_VNO 0x0046\r
-#define USB_HID_USAGE_TWHEEL 0x0048\r
-#define USB_HID_USAGE_SYSTEM_CONTROL 0x0080\r
-#define USB_HID_USAGE_SYSTEM_POWER_DOWN 0x0081\r
-#define USB_HID_USAGE_SYSTEM_SLEEP 0x0082\r
-#define USB_HID_USAGE_SYSTEM_WAKEUP 0x0083\r
-#define USB_HID_USAGE_SYSTEM_CONTEXT_MENU 0x0084\r
-#define USB_HID_USAGE_SYSTEM_MAIN_MENU 0x0085\r
-#define USB_HID_USAGE_SYSTEM_APP_MENU 0x0086\r
-#define USB_HID_USAGE_SYSTEM_MENU_HELP 0x0087\r
-#define USB_HID_USAGE_SYSTEM_MENU_EXIT 0x0088\r
-#define USB_HID_USAGE_SYSTEM_MENU_SELECT 0x0089\r
-#define USB_HID_USAGE_SYSTEM_MENU_RIGHT 0x008a\r
-#define USB_HID_USAGE_SYSTEM_MENU_LEFT 0x008b\r
-#define USB_HID_USAGE_SYSTEM_MENU_UP 0x008c\r
-#define USB_HID_USAGE_SYSTEM_MENU_DOWN 0x008d\r
-#define USB_HID_USAGE_APPLE_EJECT 0x00b8\r
-\r
-/* Usages Digitizers */\r
-#define USB_HID_USAGE_UNDEFINED 0x0000\r
-#define USB_HID_USAGE_TIP_PRESSURE 0x0030\r
-#define USB_HID_USAGE_BARREL_PRESSURE 0x0031\r
-#define USB_HID_USAGE_IN_RANGE 0x0032\r
-#define USB_HID_USAGE_TOUCH 0x0033\r
-#define USB_HID_USAGE_UNTOUCH 0x0034\r
-#define USB_HID_USAGE_TAP 0x0035\r
-#define USB_HID_USAGE_QUALITY 0x0036\r
-#define USB_HID_USAGE_DATA_VALID 0x0037\r
-#define USB_HID_USAGE_TRANSDUCER_INDEX 0x0038\r
-#define USB_HID_USAGE_TABLET_FKEYS 0x0039\r
-#define USB_HID_USAGE_PROGRAM_CHANGE_KEYS 0x003a\r
-#define USB_HID_USAGE_BATTERY_STRENGTH 0x003b\r
-#define USB_HID_USAGE_INVERT 0x003c\r
-#define USB_HID_USAGE_X_TILT 0x003d\r
-#define USB_HID_USAGE_Y_TILT 0x003e\r
-#define USB_HID_USAGE_AZIMUTH 0x003f\r
-#define USB_HID_USAGE_ALTITUDE 0x0040\r
-#define USB_HID_USAGE_TWIST 0x0041\r
-#define USB_HID_USAGE_TIP_SWITCH 0x0042\r
-#define USB_HID_USAGE_SEC_TIP_SWITCH 0x0043\r
-#define USB_HID_USAGE_BARREL_SWITCH 0x0044\r
-#define USB_HID_USAGE_ERASER 0x0045\r
-#define USB_HID_USAGE_TABLET_PICK 0x0046\r
-\r
-/* Usages, Consumer */\r
-#define USB_HID_USAGE_AC_PAN 0x0238\r
-\r
-/// Macro for combining two usages\r
-#define USB_HID_USAGE_COMBINE(x,y) (((x) << 16) | (y))\r
-\r
-struct usb_hid_data *usb_hid_start_parse(const void *d, uint32_t len,\r
- int32_t kindset);\r
-\r
-void usb_hid_end_parse(struct usb_hid_data *s);\r
-\r
-int32_t usb_hid_get_item(struct usb_hid_data *s, struct usb_hid_item *h);\r
-\r
-int32_t usb_hid_report_size(const void *buf, uint32_t len, enum usb_hid_kind k,\r
- uint8_t *id);\r
-\r
-int32_t usb_hid_locate(const void *desc, uint32_t size, uint32_t usage,\r
- enum usb_hid_kind kind, uint8_t index, struct usb_hid_location *loc,\r
- uint32_t *flags, uint8_t *id);\r
-\r
-int32_t usb_hid_get_data(const uint8_t *buf, uint32_t len,\r
- struct usb_hid_location *loc);\r
-\r
-uint32_t usb_hid_get_data_unsigned(const uint8_t *buf, uint32_t len,\r
- struct usb_hid_location *loc);\r
-\r
-void usb_hid_put_data_unsigned(uint8_t *buf, uint32_t len,\r
- struct usb_hid_location *loc, uint32_t value);\r
-\r
-int32_t usb_hid_is_collection(const void *desc, uint32_t size, uint32_t usage);\r
-\r
-struct usb_hid_descriptor *usb_hid_get_descriptor_from_usb(\r
- struct usb_config_descriptor *cd, struct usb_interface_descriptor *id);\r
-\r
-usb_error_t usb_hid_get_hid_descriptor(struct usb_hid_descriptor **ret_desc,\r
- uint16_t *ret_size, uint8_t iface_index);\r
-\r
-usb_error_t usb_hid_get_report_descriptor(struct usb_hid_descriptor **d,\r
- uint16_t size, uint8_t iface);\r
-\r
-usb_error_t usb_hid_set_idle(uint8_t iface, uint8_t duration, uint8_t id);\r
-\r
-#endif /* LIBUSB_CLASS_HID_H_ */\r
-\r
+/**
+ * \brief this file contains definitions for the the USB HID class
+ */
+
+/*
+ * Copyright (c) 2007-2013 ETH Zurich.
+ * All rights reserved.
+ *
+ * This file is distributed under the terms in the attached LICENSE file.
+ * If you do not find this file, copies can be found by writing to:
+ * ETH Zurich D-INFK, Haldeneggsteig 4, CH-8092 Zurich. Attn: Systems Group.
+ */
+
+#ifndef LIBUSB_CLASS_HID_H_
+#define LIBUSB_CLASS_HID_H_
+
+#include <usb/usb_descriptor.h>
+
+#define USB_HID_CLASS_CODE 0x3
+#define USB_HID_SUBCLASS_CODE_BOOT 0x1
+#define USB_HID_PROTOCOL_NONE 0x0
+#define USB_HID_PROTOCOL_KEYBOARD 0x1
+#define USB_HID_PROTOCOL_MOUSE 0x2
+
+/*
+ * USB HID class descriptor types
+ */
+
+/// Descriptor type for the HID
+#define USB_DESCRIPTOR_TYPE_HID 0x21
+
+/// Descriptor type for HID report
+#define USB_DESCRIPTOR_TYPE_REPORT 0x22
+
+/// descriptor type for HID physical
+#define USB_DESCRIPTOR_TYPE_PHYSICAL 0x23
+
+/*
+ * HID class specific request types
+ */
+
+#define USB_HID_REQUEST_GET_REPORT 0x01
+#define USB_HID_REQUEST_SET_REPORT 0x09
+
+#define USB_HID_REQUEST_GET_IDLE 0x02
+#define USB_HID_REQUEST_SET_IDLE 0x0A
+
+#define USB_HID_REQUEST_GET_PROTOCOL 0x03
+#define USB_HID_REQUEST_SET_PROTOCOL 0x0B
+
+#define USB_HID_REQUEST_GET_DESCRIPTOR 0x06
+#define USB_HID_REQUEST_SET_DESCRIPTOR 0x07
+
+/**
+ * struct definition for a HID descriptor type
+ * XXX: the length cannot be an uint16, because of alignment issues
+ */
+struct usb_hid_dtype {
+ uint8_t bDescriptorType; ///< the type of the optional descriptor
+ uint8_t wDescriptorLength[2]; ///< the size of the optional descriptor
+}__attribute__((packed));
+
+/// type definition of the HID descriptor type
+typedef struct usb_hid_dtype usb_hid_dtype_t;
+
+/// makro definition for getting the length of a descriptor type
+#define USB_HID_DTYPE_GET_LEN(_d) \
+ ((_d)->wDescriptorLength[0] | ((uint16_t)((_d)->wDescriptorLength[1] << 8)))
+
+/**
+ * USB HID Descriptor Type
+ * Device Class Definition for HID Devices, Section 6.2.1
+ *
+ * Note: This descriptor is of variable size, the last field descriptors
+ * contains the information of at least one descriptor (i.e. the report
+ * descriptor)
+ */
+struct usb_hid_descriptor {
+ uint8_t bLength; ///< the total size in bytes of this descr
+ uint8_t bDescriptorType; ///< constant, specifying the HID descr type
+ uint16_t bcdHID; ///< HID class specific release version
+ uint8_t bCountryCode; ///< country code for localized hardware
+ uint8_t bNumDescriptors; ///< the number of class descriptors > 1
+ usb_hid_dtype_t descriptors[1]; ///< subordinate descriptors
+}__attribute__((packed));
+
+/// USB HID descriptor type
+typedef struct usb_hid_descriptor usb_hid_descriptor_t;
+
+/// calcualtes the size of the HID descriptor
+#define USB_HID_DESCRIPTOR_SIZE(n) (9+((n)*3))
+
+/*
+ * -------------------------------------------------------------------------
+ * USB HID class report items
+ * -------------------------------------------------------------------------
+ */
+
+#define USB_HID_REPORT_INPUT 0x01
+#define USB_HID_REPORT_OUTPUT 0x02
+#define USB_HID_REPORT_FEATURE 0x03
+
+/*
+ * some flags
+ */
+#define USB_HID_IO_CONST 0x001
+#define USB_HID_IO_VARIABLE 0x002
+#define USB_HID_IO_RELATIVE 0x004
+#define USB_HID_IO_WRAP 0x008
+#define USB_HID_IO_NONLINEAR 0x010
+#define USB_HID_IO_NOPREF 0x020
+#define USB_HID_IO_NULLSTATE 0x040
+#define USB_HID_IO_VOLATILE 0x080
+#define USB_HID_IO_BUFBYTES 0x100
+
+/// enumeration representing the type of the report item
+enum usb_hid_kind {
+ USB_HID_KIND_INPUT = 0, ///< input report
+ USB_HID_KIND_OUTPUT = 1, ///< output report
+ USB_HID_KIND_FEATURE = 2, ///< feature report
+ USB_HID_KIND_COLLECTION = 3, ///< collection start
+ USB_HID_KIND_ENDCOLLECTION = 4, ///< collection end
+};
+
+/// struct definition for report id - position association
+struct usb_hid_pos_data {
+ int32_t rid; ///< report id
+ uint32_t position; ///< position
+};
+
+/// struct definition for storing information about the HID item in an report
+struct usb_hid_location {
+ uint32_t size; ///< the size of one item element
+ uint32_t count; ///< the number of elements in this location
+ uint32_t position; ///< the position within the report
+};
+
+/// This struct represents an item in a USB report
+struct usb_hid_item {
+ /* Global */
+ int32_t _usage_page; ///<
+ int32_t logical_minimum; ///<
+ int32_t logical_maximum; ///<
+ int32_t physical_minimum; ///<
+ int32_t physical_maximum; ///<
+ int32_t unit_exponent; ///<
+ int32_t unit; ///<
+ int32_t report_ID; ///<
+ /* Local */
+ int32_t usage; ///<
+ int32_t usage_minimum; ///<
+ int32_t usage_maximum; ///<
+ int32_t designator_index; ///<
+ int32_t designator_minimum; ///<
+ int32_t designator_maximum; ///<
+ int32_t string_index; ///<
+ int32_t string_minimum; ///<
+ int32_t string_maximum; ///<
+ int32_t set_delimiter; ///<
+ /* Misc */
+ int32_t collection; ///<
+ int32_t collevel; ///<
+ enum usb_hid_kind kind; ///<
+ uint32_t flags; ///<
+ /* Location */
+ struct usb_hid_location loc; ///<
+};
+
+/*
+ * definitions for parsing the report descriptors
+ */
+
+#define USB_HID_MAXUSAGE 64
+#define USB_HID_MAXPUSH 4
+#define USB_HID_MAXID 16
+
+/**
+ * this structure is used for storing the necessary data when parsing
+ * USB HID reports
+ */
+struct usb_hid_data {
+ const uint8_t *start;
+ const uint8_t *end;
+ const uint8_t *p;
+ struct usb_hid_item cur[USB_HID_MAXPUSH];
+ struct usb_hid_pos_data last_pos[USB_HID_MAXID];
+ int32_t usages_min[USB_HID_MAXUSAGE];
+ int32_t usages_max[USB_HID_MAXUSAGE];
+ int32_t usage_last; /* last seen usage */
+ uint32_t loc_size; /* last seen size */
+ uint32_t loc_count; /* last seen count */
+ uint8_t kindset; /* we have 5 kinds so 8 bits are enough */
+ uint8_t pushlevel; /* current pushlevel */
+ uint8_t ncount; /* end usage item count */
+ uint8_t icount; /* current usage item count */
+ uint8_t nusage; /* end "usages_min/max" index */
+ uint8_t iusage; /* current "usages_min/max" index */
+ uint8_t ousage; /* current "usages_min/max" offset */
+ uint8_t susage; /* usage set flags */
+};
+
+#define USB_HID_REQUEST_TYPE_WRITE 0xA1
+#define USB_HID_REQUEST_TYPE_READ 0x21
+
+#define USB_HID_REQUEST_VALUE_IN 0x01
+#define USB_HID_REQUEST_VALUE_OUT 0x02
+#define USB_HID_REQUEST_VALUE_FEATURE 0x03
+
+/*
+ * -------------------------------------------------------------------------
+ * Country Codes
+ * -------------------------------------------------------------------------
+ */
+
+#define USB_HID_COUNTRY_DEFAULT 0
+#define USB_HID_COUNTRY_ARABIC 1
+#define USB_HID_COUNTRY_BELGIAN 2
+#define USB_HID_COUNTRY_CANADIAN 3
+#define USB_HID_COUNTRY_CANADIAN_FRENCH 4
+#define USB_HID_COUNTRY_CZECH 5
+#define USB_HID_COUNTRY_DANISH 6
+#define USB_HID_COUNTRY_FINNISH 7
+#define USB_HID_COUNTRY_FRENCH 8
+#define USB_HID_COUNTRY_GERMAN 9
+#define USB_HID_COUNTRY_GREEK 10
+#define USB_HID_COUNTRY_HEBREW 11
+#define USB_HID_COUNTRY_HUNGARY 12
+#define USB_HID_COUNTRY_INTERNATIONAL 13
+#define USB_HID_COUNTRY_ITALIAN 14
+#define USB_HID_COUNTRY_JAPAN 15
+#define USB_HID_COUNTRY_KOREAN 16
+#define USB_HID_COUNTRY_LATIN 17
+#define USB_HID_COUNTRY_DUTCH 18
+#define USB_HID_COUNTRY_NORWEGIAN 19
+#define USB_HID_COUNTRY_PERSIAN 20
+#define USB_HID_COUNTRY_POLAND 21
+#define USB_HID_COUNTRY_PORTUGUESE 22
+#define USB_HID_COUNTRY_RUSSIA 23
+#define USB_HID_COUNTRY_SLOVAKIA 24
+#define USB_HID_COUNTRY_SPANISH 25
+#define USB_HID_COUNTRY_SWEDISH 26
+#define USB_HID_COUNTRY_SWISS_FRENCH 27
+#define USB_HID_COUNTRY_SWISS_GERMAN 28
+#define USB_HID_COUNTRY_SWITZERLAND 29
+#define USB_HID_COUNTRY_TAIWAN 30
+#define USB_HID_COUNTRY_TURKISH_Q 31
+#define USB_HID_COUNTRY_UK 32
+#define USB_HID_COUNTRY_US 33
+#define USB_HID_COUNTRY_YUGOSLAVIA 34
+#define USB_HID_COUNTRY_TURKISH_F 35
+// other 36-255 reserved
+
+/*
+ * -------------------------------------------------------------------------
+ * USB HID Physical Designator Values
+ *
+ * This defines specify which part of the human body
+ * triggered the input.
+ *
+ * e.g. the hand or finger
+ * -------------------------------------------------------------------------
+ */
+#define USB_HID_DESIGNATOR_NONE 0x00
+#define USB_HID_DESIGNATOR_HAND 0x01
+#define USB_HID_DESIGNATOR_EYEBALL 0x02
+#define USB_HID_DESIGNATOR_EYEBROW 0x03
+#define USB_HID_DESIGNATOR_EYELID 0x04
+#define USB_HID_DESIGNATOR_EAR 0x05
+#define USB_HID_DESIGNATOR_NOSE 0x06
+#define USB_HID_DESIGNATOR_MOUTH 0x07
+#define USB_HID_DESIGNATOR_UPPER_LIP 0x08
+#define USB_HID_DESIGNATOR_LOWER_LIP 0x09
+#define USB_HID_DESIGNATOR_JAW 0x0A
+#define USB_HID_DESIGNATOR_NECK 0x0B
+#define USB_HID_DESIGNATOR_UPPER_ARM 0x0C
+#define USB_HID_DESIGNATOR_ELBOW 0x0D
+#define USB_HID_DESIGNATOR_FOREARM 0x0E
+#define USB_HID_DESIGNATOR_WRIST 0x0F
+#define USB_HID_DESIGNATOR_PALM 0x10
+#define USB_HID_DESIGNATOR_THUMB 0x11
+#define USB_HID_DESIGNATOR_I_FINGER 0x12
+#define USB_HID_DESIGNATOR_M_FINGER 0x13
+#define USB_HID_DESIGNATOR_R_FINGER 0x14
+#define USB_HID_DESIGNATOR_L_FINGER 0x15
+#define USB_HID_DESIGNATOR_HEAD 0x16
+#define USB_HID_DESIGNATOR_SHOULDER 0x17
+#define USB_HID_DESIGNATOR_HIP 0x18
+#define USB_HID_DESIGNATOR_WAIST 0x19
+#define USB_HID_DESIGNATOR_THIGH 0x1A
+#define USB_HID_DESIGNATOR_KNEE 0x1B
+#define USB_HID_DESIGNATOR_CALF 0x1C
+#define USB_HID_DESIGNATOR_ANKLE 0x1D
+#define USB_HID_DESIGNATOR_FOOT 0x1E
+#define USB_HID_DESIGNATOR_HEEL 0x1F
+#define USB_HID_DESIGNATOR_BALL_FOOT 0x20
+#define USB_HID_DESIGNATOR_BIG_TOE 0x21
+#define USB_HID_DESIGNATOR_TOE_2 0x22
+#define USB_HID_DESIGNATOR_TOE_3 0x23
+#define USB_HID_DESIGNATOR_TOE_4 0x24
+#define USB_HID_DESIGNATOR_TOE_5 0x25
+#define USB_HID_DESIGNATOR_BROW 0x26
+#define USB_HID_DESIGNATOR_CHEEK 0x27
+/* 28-FF reserved */
+
+/*
+ * -------------------------------------------------------------------------
+ * USB HID Physical Qualifier Fields
+ *
+ * This values represent which of the possible multiple input
+ * designators triggered the input.
+ *
+ * e.g. right or left hand
+ * -------------------------------------------------------------------------
+ */
+#define USB_HID_PHYSICAL_QUALIFIER_NONE 0x0
+#define USB_HID_PHYSICAL_QUALIFIER_RIGHT 0x1
+#define USB_HID_PHYSICAL_QUALIFIER_LEFT 0x2
+#define USB_HID_PHYSICAL_QUALIFIER_BOTH 0x3
+#define USB_HID_PHYSICAL_QUALIFIER_EITHER 0x4
+#define USB_HID_PHYSICAL_QUALIFIER_CENTER 0x5
+#define USB_HID_PHYSICAL_QUALIFIER_RESERVED 0x6
+#define USB_HID_PHYSICAL_QUALIFIER_RESERVED_ 0x7
+
+/*
+ * -------------------------------------------------------------------------
+ * USB HID Usages
+ * -------------------------------------------------------------------------
+ */
+#define USB_HID_USAGE_UNDEFINED 0x0000
+#define USB_HID_USAGE_GENERIC_DESKTOP 0x0001
+#define USB_HID_USAGE_SIMULATION 0x0002
+#define USB_HID_USAGE_VR_CONTROLS 0x0003
+#define USB_HID_USAGE_SPORTS_CONTROLS 0x0004
+#define USB_HID_USAGE_GAMING_CONTROLS 0x0005
+#define USB_HID_USAGE_KEYBOARD 0x0007
+#define USB_HID_USAGE_LEDS 0x0008
+#define USB_HID_USAGE_BUTTON 0x0009
+#define USB_HID_USAGE_ORDINALS 0x000a
+#define USB_HID_USAGE_TELEPHONY 0x000b
+#define USB_HID_USAGE_CONSUMER 0x000c
+#define USB_HID_USAGE_DIGITIZERS 0x000d
+#define USB_HID_USAGE_PHYSICAL_IFACE 0x000e
+#define USB_HID_USAGE_UNICODE 0x0010
+#define USB_HID_USAGE_ALPHANUM_DISPLAY 0x0014
+#define USB_HID_USAGE_MONITOR 0x0080
+#define USB_HID_USAGE_MONITOR_ENUM_VAL 0x0081
+#define USB_HID_USAGE_VESA_VC 0x0082
+#define USB_HID_USAGE_VESA_CMD 0x0083
+#define USB_HID_USAGE_POWER 0x0084
+#define USB_HID_USAGE_BATTERY_SYSTEM 0x0085
+#define USB_HID_USAGE_BARCODE_SCANNER 0x008b
+#define USB_HID_USAGE_SCALE 0x008c
+#define USB_HID_USAGE_CAMERA_CONTROL 0x0090
+#define USB_HID_USAGE_ARCADE 0x0091
+#define USB_HID_USAGE_MICROSOFT 0xff00
+
+/* Usages, generic desktop */
+#define USB_HID_USAGE_POINTER 0x0001
+#define USB_HID_USAGE_MOUSE 0x0002
+#define USB_HID_USAGE_JOYSTICK 0x0004
+#define USB_HID_USAGE_GAME_PAD 0x0005
+#define USB_HID_USAGE_DKEYBOARD 0x0006
+#define USB_HID_USAGE_KEYPAD 0x0007
+#define USB_HID_USAGE_X 0x0030
+#define USB_HID_USAGE_Y 0x0031
+#define USB_HID_USAGE_Z 0x0032
+#define USB_HID_USAGE_RX 0x0033
+#define USB_HID_USAGE_RY 0x0034
+#define USB_HID_USAGE_RZ 0x0035
+#define USB_HID_USAGE_SLIDER 0x0036
+#define USB_HID_USAGE_DIAL 0x0037
+#define USB_HID_USAGE_WHEEL 0x0038
+#define USB_HID_USAGE_HAT_SWITCH 0x0039
+#define USB_HID_USAGE_COUNTED_BUFFER 0x003a
+#define USB_HID_USAGE_BYTE_COUNT 0x003b
+#define USB_HID_USAGE_MOTION_WAKEUP 0x003c
+#define USB_HID_USAGE_VX 0x0040
+#define USB_HID_USAGE_VY 0x0041
+#define USB_HID_USAGE_VZ 0x0042
+#define USB_HID_USAGE_VBRX 0x0043
+#define USB_HID_USAGE_VBRY 0x0044
+#define USB_HID_USAGE_VBRZ 0x0045
+#define USB_HID_USAGE_VNO 0x0046
+#define USB_HID_USAGE_TWHEEL 0x0048
+#define USB_HID_USAGE_SYSTEM_CONTROL 0x0080
+#define USB_HID_USAGE_SYSTEM_POWER_DOWN 0x0081
+#define USB_HID_USAGE_SYSTEM_SLEEP 0x0082
+#define USB_HID_USAGE_SYSTEM_WAKEUP 0x0083
+#define USB_HID_USAGE_SYSTEM_CONTEXT_MENU 0x0084
+#define USB_HID_USAGE_SYSTEM_MAIN_MENU 0x0085
+#define USB_HID_USAGE_SYSTEM_APP_MENU 0x0086
+#define USB_HID_USAGE_SYSTEM_MENU_HELP 0x0087
+#define USB_HID_USAGE_SYSTEM_MENU_EXIT 0x0088
+#define USB_HID_USAGE_SYSTEM_MENU_SELECT 0x0089
+#define USB_HID_USAGE_SYSTEM_MENU_RIGHT 0x008a
+#define USB_HID_USAGE_SYSTEM_MENU_LEFT 0x008b
+#define USB_HID_USAGE_SYSTEM_MENU_UP 0x008c
+#define USB_HID_USAGE_SYSTEM_MENU_DOWN 0x008d
+#define USB_HID_USAGE_APPLE_EJECT 0x00b8
+
+/* Usages Digitizers */
+#define USB_HID_USAGE_UNDEFINED 0x0000
+#define USB_HID_USAGE_TIP_PRESSURE 0x0030
+#define USB_HID_USAGE_BARREL_PRESSURE 0x0031
+#define USB_HID_USAGE_IN_RANGE 0x0032
+#define USB_HID_USAGE_TOUCH 0x0033
+#define USB_HID_USAGE_UNTOUCH 0x0034
+#define USB_HID_USAGE_TAP 0x0035
+#define USB_HID_USAGE_QUALITY 0x0036
+#define USB_HID_USAGE_DATA_VALID 0x0037
+#define USB_HID_USAGE_TRANSDUCER_INDEX 0x0038
+#define USB_HID_USAGE_TABLET_FKEYS 0x0039
+#define USB_HID_USAGE_PROGRAM_CHANGE_KEYS 0x003a
+#define USB_HID_USAGE_BATTERY_STRENGTH 0x003b
+#define USB_HID_USAGE_INVERT 0x003c
+#define USB_HID_USAGE_X_TILT 0x003d
+#define USB_HID_USAGE_Y_TILT 0x003e
+#define USB_HID_USAGE_AZIMUTH 0x003f
+#define USB_HID_USAGE_ALTITUDE 0x0040
+#define USB_HID_USAGE_TWIST 0x0041
+#define USB_HID_USAGE_TIP_SWITCH 0x0042
+#define USB_HID_USAGE_SEC_TIP_SWITCH 0x0043
+#define USB_HID_USAGE_BARREL_SWITCH 0x0044
+#define USB_HID_USAGE_ERASER 0x0045
+#define USB_HID_USAGE_TABLET_PICK 0x0046
+
+/* Usages, Consumer */
+#define USB_HID_USAGE_AC_PAN 0x0238
+
+/// Macro for combining two usages
+#define USB_HID_USAGE_COMBINE(x,y) (((x) << 16) | (y))
+
+struct usb_hid_data *usb_hid_start_parse(const void *d, uint32_t len,
+ int32_t kindset);
+
+void usb_hid_end_parse(struct usb_hid_data *s);
+
+int32_t usb_hid_get_item(struct usb_hid_data *s, struct usb_hid_item *h);
+
+int32_t usb_hid_report_size(const void *buf, uint32_t len, enum usb_hid_kind k,
+ uint8_t *id);
+
+int32_t usb_hid_locate(const void *desc, uint32_t size, uint32_t usage,
+ enum usb_hid_kind kind, uint8_t index, struct usb_hid_location *loc,
+ uint32_t *flags, uint8_t *id);
+
+int32_t usb_hid_get_data(const uint8_t *buf, uint32_t len,
+ struct usb_hid_location *loc);
+
+uint32_t usb_hid_get_data_unsigned(const uint8_t *buf, uint32_t len,
+ struct usb_hid_location *loc);
+
+void usb_hid_put_data_unsigned(uint8_t *buf, uint32_t len,
+ struct usb_hid_location *loc, uint32_t value);
+
+int32_t usb_hid_is_collection(const void *desc, uint32_t size, uint32_t usage);
+
+struct usb_hid_descriptor *usb_hid_get_descriptor_from_usb(
+ struct usb_config_descriptor *cd, struct usb_interface_descriptor *id);
+
+usb_error_t usb_hid_get_hid_descriptor(struct usb_hid_descriptor **ret_desc,
+ uint16_t *ret_size, uint8_t iface_index);
+
+usb_error_t usb_hid_get_report_descriptor(struct usb_hid_descriptor **d,
+ uint16_t size, uint8_t iface);
+
+usb_error_t usb_hid_set_idle(uint8_t iface, uint8_t duration, uint8_t id);
+
+#endif /* LIBUSB_CLASS_HID_H_ */
+
-/**\r
- * \brief This file contains all the device driver related information and\r
- * function prototypes for the USB hub class.\r
- */\r
-\r
-/*\r
- * Copyright (c) 2007-2013 ETH Zurich.\r
- * All rights reserved.\r
- *\r
- * This file is distributed under the terms in the attached LICENSE file.\r
- * If you do not find this file, copies can be found by writing to:\r
- * ETH Zurich D-INFK, Haldeneggsteig 4, CH-8092 Zurich. Attn: Systems Group.\r
- */\r
-\r
-/**\r
- * ==========================================================================\r
- * Note: This mirrors the usb_hub.h in the USB manager, without the direct\r
- * references to the transfers and devices, but with the identifiers\r
- * instead\r
- * ==========================================================================\r
- */\r
-\r
-#ifndef LIBUSB_CLASS_HUB_H\r
-#define LIBUSB_CLASS_HUB_H\r
-\r
-/// the hub descriptor type value\r
-#define USB_DESCRIPTOR_TYPE_HUB 0x29\r
-\r
-/// the maximum depth in the USB tree\r
-#define USB_HUB_MAX_DEPTH 5\r
-\r
-/// the interval of the interrupt transfer\r
-#define USB_HUB_INTR_INTERVAL 250\r
-\r
-/// the number of transfers of the usb hub (just one)\r
-#define USB_HUB_NUM_TRANSFERS 1\r
-\r
-/**\r
- * defines the characteristics of a hub as part of the hub descriptor\r
- */\r
-struct usb_hub_characteristics {\r
- uint8_t _reserved; ///< reserved, should be zero\r
- uint8_t port_indicator :1; ///< are port indicators allowed\r
- uint8_t tt_think_time :2; ///< transaction translator think time\r
- uint8_t protection_mode :2; ///< over current protection mode\r
- uint8_t compound_device :1; ///< flag indicating if it is a compund device\r
- uint8_t power_mode :2; ///< logical power switching modes\r
-};\r
-\r
-/// usb hub characteristics type\r
-typedef struct usb_hub_characteristics usb_hub_characteristics_t;\r
-\r
-/*\r
- * usb_hub_characteristics.power_mode\r
- */\r
-\r
-/// usb hub logical power switching mode: treat all ports at once\r
-#define USB_HUB_POWER_GANGED 0\r
-\r
-/// usb hub logical power switching mode: treat all ports individual\r
-#define USB_HUB_POWER_INDIVIDUAL 1\r
-\r
-/// usb hub logical power switching mode: no power switching\r
-#define USB_HUB_POWER_NO_SWITCH 2\r
-\r
-/*\r
- * usb_bub_characteristics.protection_mode\r
- */\r
-\r
-/// over-current status is reported on a global (aggregated) base\r
-#define USB_HUB_PROTECTION_GLOBAL 0\r
-\r
-/// over-current status is reported on a per port basis\r
-#define USB_HUB_PROTECTION_INDIVIDUAL 1\r
-\r
-/// over current status is not reported\r
-#define USB_HUB_PROTECTION_NONE 2\r
-\r
-/*\r
- * usb_hub_characteristics.tt_think_time\r
- */\r
-\r
-/// think time is 8ms\r
-#define USB_HUB_TT_TIME_8 0\r
-\r
-/// think time is 16ms\r
-#define USB_HUB_TT_TIME_16 1\r
-\r
-/// think time is 24ms\r
-#define USB_HUB_TT_TIME_24 2\r
-\r
-/// think time is 32ms\r
-#define USB_HUB_TT_TIME_32 3\r
-\r
-//// Returns the delay from power on to power good in ms\r
-#define USB_HUB_POWER_ON_DELAY(hub) (hub->bPwrOn2PwrGood*2)\r
-\r
-/**\r
- * ------------------------------------------------------------------------\r
- * USB Hub Class Descriptor (USB Specification, Rev 2.0, Section 11.23.2.1 )\r
- * ------------------------------------------------------------------------\r
- * The device descriptor for USB hub class devices.\r
- */\r
-struct usb_hub_descriptor {\r
- uint8_t bDescLength; ///< the length of the descriptor in bytes\r
- uint8_t bDescriptorType; ///< the descriptor type (0x29)\r
- uint8_t bNbrPorts; ///< the number of ports\r
- struct usb_hub_characteristics wHubCharacteristics; ///> hub characteristics\r
- uint8_t bPwrOn2PwrGood; ///< time from power on till accessible (2ms)\r
- uint8_t bHubContrCurrent; ///< max power requirements of the hub (mA)\r
- uint8_t bDeviceRemovable[32]; ///< device removable bitmap (byte granularity)\r
-};\r
-\r
-// The maximum supported ports\r
-#define USB_HUB_MAX_PORTS 255\r
-\r
-// checks if the device at port is removable\r
-#define USB_HUB_DEVICE_REMOVABLE(desc, port) \\r
- (!(((desc)->DeviceRemovable[(i)/8] >> ((i) % 8)) & 1))\r
-\r
-// size definition\r
-#define USB_HUB_DESCRIPTOR_MIN_SIZE 8\r
-\r
-/**\r
- * ------------------------------------------------------------------------\r
- * USB Hub Status (USB Specification, Rev 2.0, Table 11-19 )\r
- * ------------------------------------------------------------------------\r
- * The hub status struct is returned when querying the hub with the\r
- * usb_hub_get_hub_status() request.\r
- */\r
-struct usb_hub_status {\r
- uint16_t _reserved :14; ///< unused, should be zero\r
- uint8_t local_power_source :1; ///< local or external power source\r
- uint8_t over_current :1; ///< the ports are draining too much power\r
- uint16_t _reserved_ :14; ///< unused, should be zero\r
- uint8_t local_power_change :1; ///< indicates a change in local power source\r
- uint8_t over_current_change :1; ///< indicates a change in over current\r
-};\r
-\r
-/// usb hub status type\r
-typedef struct usb_hub_status usb_hub_status_t;\r
-\r
-/// check if the hub has a power supply\r
-#define USB_HUB_STATUS_HAS_POWERSUPPLY(st) (st->local_power_source == 0)\r
-\r
-/**\r
- * ------------------------------------------------------------------------\r
- * USB Hub Port Status (USB Specification, Rev 2.0, Table 11-19 )\r
- * ------------------------------------------------------------------------\r
- * The hub status struct is returned when querying a hub port with the\r
- * usb_hub_get_port_status() request.\r
- *\r
- * The bit locations in the wPortStatus and wPortChange fields correspond\r
- * in a one-to-one fashion where applicable.\r
- *\r
- * USB Specification Rev 2.0, Section 11.24.2.7.1, gives a detailed description\r
- */\r
-struct usb_hub_port_status {\r
- struct {\r
- uint8_t connection :1; ///< there is a device connected to the port\r
- uint8_t enabled :1; ///< the port is enabled\r
- uint8_t suspend :1; ///< device on that port is suspended\r
- uint8_t over_current :1; ///< a over current condition happened\r
- uint8_t reset :1; ///< is set when host wants to reset device\r
- uint8_t link_state :3; ///< USB 3.0, unused, set to zero\r
- uint8_t power_state :1; ///< local power control state\r
- uint8_t is_ls :1; ///< attached devices is a low speed device\r
- uint8_t is_hs :1; ///< attached device is a high speed device\r
- uint8_t test_mode :1; ///< port operates is in test mode\r
- uint8_t indicator :1; ///< set if indicator color is sw controlled\r
- uint8_t _reserved :2; ///< unused, set to zero\r
- uint8_t device_mode :1; ///< impl specific\r
- } wPortStatus; ///< port status flags\r
- struct {\r
- uint8_t connect :1; ///< the current connect status has changed\r
- uint8_t disabled :1; ///< the port got disabled to an error\r
- uint8_t resumed :1; ///< the device resume procedure is completed\r
- uint8_t over_current :1; ///< there is a change in over_current status\r
- uint8_t is_reset :1; ///< the reset procedure on the port is complete\r
- uint8_t bh_is_reset :1;\r
- uint8_t linkstate :1;\r
- uint8_t configerr :1;\r
- uint16_t _reserved :8; ///< unused, set to zero\r
- } wPortChange; ///< port change flags\r
-};\r
-\r
-/**\r
- * this structure represent a port on an USB hub\r
- */\r
-struct usb_hub_port {\r
- uint8_t restarts; ///< the number of restarts on this hub\r
- uint8_t device_address; ///< the address of the attached device\r
- usb_mode_t usb_mode; ///< the mode host or device mode\r
-};\r
-\r
-/// US hub port type\r
-typedef struct usb_hub_port usb_hub_port_t;\r
-\r
-/// the maximum number of restarts of a USB hub port\r
-#define USB_HUB_MAX_RESTARTS 5\r
-\r
-/**\r
- * this structure defines how many bites are left in a 1ms USB time slot\r
- * for full-speed isochronus schedules\r
- */\r
-struct usb_hub_schedule {\r
- uint16_t total_bytes; ///< the total bytes of the isoc schedule\r
- uint8_t frame_bytes; ///< the bytes in this USB frame\r
- uint8_t frame_slot; ///< the slot of this USB frame\r
-};\r
-\r
-\r
-/// type definition for the different hub protocols\r
-typedef enum usb_hub_protocol {\r
- USB_HUB_FSHUB,\r
- USB_HUB_HSHUB_SINGLE_TT,\r
- USB_HUB_HSHUB_MULTI_TT,\r
- USB_HUB_SSHUB\r
-} usb_hub_protocol;\r
-\r
-#define USB_HUB_MAX_ISOC 128\r
-#define USB_HUB_MAX_UFRAMES 8\r
-\r
-/**\r
- * Struct containing all the relevant information for an USB hub\r
- * The a usb_device sets its hub field if it is a hub.\r
- */\r
-struct usb_hub {\r
- usb_hub_status_t status;\r
- struct usb_hub_schedule schedule[USB_HUB_MAX_ISOC];\r
- uint8_t device_address;\r
- uint16_t uframe_usage[USB_HUB_MAX_UFRAMES];\r
- uint16_t portpower;\r
- uint8_t isoc_last;\r
- uint8_t num_ports;\r
- usb_hub_protocol protocol;\r
- usb_hub_port_t ports[0];\r
- usb_xfer_id_t xferids[USB_HUB_NUM_TRANSFERS];\r
- char name[32];\r
-};\r
-\r
-/*\r
- * device class codes\r
- */\r
-#define USB_HUB_CLASS_CODE 0x09\r
-#define USB_HUB_SUBCLASS_CODE 0x00\r
-#define USB_HUB_PROTOCOL_FSHUB 0x00\r
-#define USB_HUB_PROTOCOL_HSHUBSTT 0x01\r
-#define USB_HUB_PROTOCOL_HSHUBMTT 0x02\r
-#define USB_HUB_PROTOCOL_SSHUB 0x03\r
-\r
-/*\r
- * interface class code\r
- */\r
-#define USB_HUB_IFACE_CLASS_CODE 0x09\r
-#define USB_HUB_IFACE_SUBCLASS_CODE 0x00\r
-#define USB_HUB_IFACE_PROTOCOL_FSHUB 0x00\r
-#define USB_HUB_IFACE_PROTOCOL_HSHUBSTT 0x00 /* Yes, same as previous */\r
-#define USB_HUB_IFACE_PROTOCOL_HSHUBMTT 0x01\r
-\r
-/*\r
- * USB Hub Class Specific Request Codes\r
- * (USB Specification, Rev 2.0, Table 11.16)\r
- */\r
-#define USB_HUB_REQ_GET_STATUS 0\r
-#define USB_HUB_REQ_CLEAR_FEATURE 1\r
-#define USB_HUB_REQ_SET_FEATURE 3\r
-#define USB_HUB_REQ_GET_DESCRIPTOR 6\r
-#define USB_HUB_REQ_SET_DESCRIPTOR 7\r
-#define USB_HUB_REQ_CLEAR_TT_BUFFER 8\r
-#define USB_HUB_REQ_RESET_TT 9\r
-#define USB_HUB_REQ_GET_TT_STATE 10\r
-#define USB_HUB_REQ_STOP_TT 11\r
-\r
-/*\r
- * USB Hub Class Specific Request Codes\r
- * (USB Specification, Rev 2.0, Table 11.17)\r
- */\r
-#define USB_HUB_FEATURE_C_HUB_LOCAL_POWER 0\r
-#define USB_HUB_FEATURE_C_HUB_OVER_CURRENT 1\r
-#define USB_HUB_FEATURE_PORT_CONNECTION 0\r
-#define USB_HUB_FEATURE_PORT_ENABLE 1\r
-#define USB_HUB_FEATURE_PORT_SUSPEND 2\r
-#define USB_HUB_FEATURE_PORT_OVER_CURRENT 3\r
-#define USB_HUB_FEATURE_PORT_RESET 4\r
-#define USB_HUB_FEATURE_PORT_POWER 8\r
-#define USB_HUB_FEATURE_PORT_LOW_SPEED 9\r
-#define USB_HUB_FEATURE_C_PORT_CONNECTION 16\r
-#define USB_HUB_FEATURE_C_PORT_ENABLE 17\r
-#define USB_HUB_FEATURE_C_PORT_SUSPEND 18\r
-#define USB_HUB_FEATURE_C_PORT_OVER_CURRENT 19\r
-#define USB_HUB_FEATURE_C_PORT_RESET 20\r
-#define USB_HUB_FEATURE_PORT_TEST 21\r
-#define USB_HUB_FEATURE_PORT_INDICATOR 22\r
-\r
-usb_error_t usb_hub_clear_hub_feature(uint16_t feature);\r
-\r
-usb_error_t usb_hub_clear_port_feature(uint16_t feature, uint8_t sel,\r
- uint8_t port);\r
-\r
-usb_error_t usb_hub_clear_tt_buffer(uint8_t dev_addr, uint8_t ep_num,\r
- uint8_t ep_type,uint8_t direction, uint16_t tt_port);\r
-\r
-usb_error_t usb_hub_get_hub_status(struct usb_hub_status *ret_status);\r
-\r
-usb_error_t usb_hub_get_port_status(uint16_t port,\r
- struct usb_hub_port_status *ret_status);\r
-\r
-usb_error_t usb_hub_reset_tt(uint16_t port);\r
-\r
-usb_error_t usb_hub_set_hub_feature(uint16_t feature);\r
-\r
-usb_error_t usb_hub_set_port_feature(uint16_t feature, uint8_t selector,\r
- uint8_t port);\r
-\r
-usb_error_t usb_hub_get_tt_state(uint16_t flags, uint16_t port,\r
- uint16_t max_length, uint16_t ret_length, void **ret_state);\r
-\r
-usb_error_t usb_hub_stop_tt(uint16_t port);\r
-\r
-usb_error_t usb_hub_get_hub_descriptor(uint16_t max_length,\r
- struct usb_hub_descriptor **ret_desc);\r
-\r
-usb_error_t usb_hub_set_hub_descriptor(uint16_t desc_length,\r
- struct usb_hub_descriptor *desc);\r
-\r
-#endif\r
+/**
+ * \brief This file contains all the device driver related information and
+ * function prototypes for the USB hub class.
+ */
+
+/*
+ * Copyright (c) 2007-2013 ETH Zurich.
+ * All rights reserved.
+ *
+ * This file is distributed under the terms in the attached LICENSE file.
+ * If you do not find this file, copies can be found by writing to:
+ * ETH Zurich D-INFK, Haldeneggsteig 4, CH-8092 Zurich. Attn: Systems Group.
+ */
+
+/**
+ * ==========================================================================
+ * Note: This mirrors the usb_hub.h in the USB manager, without the direct
+ * references to the transfers and devices, but with the identifiers
+ * instead
+ * ==========================================================================
+ */
+
+#ifndef LIBUSB_CLASS_HUB_H
+#define LIBUSB_CLASS_HUB_H
+
+/// the hub descriptor type value
+#define USB_DESCRIPTOR_TYPE_HUB 0x29
+
+/// the maximum depth in the USB tree
+#define USB_HUB_MAX_DEPTH 5
+
+/// the interval of the interrupt transfer
+#define USB_HUB_INTR_INTERVAL 250
+
+/// the number of transfers of the usb hub (just one)
+#define USB_HUB_NUM_TRANSFERS 1
+
+/**
+ * defines the characteristics of a hub as part of the hub descriptor
+ */
+struct usb_hub_characteristics {
+ uint8_t _reserved; ///< reserved, should be zero
+ uint8_t port_indicator :1; ///< are port indicators allowed
+ uint8_t tt_think_time :2; ///< transaction translator think time
+ uint8_t protection_mode :2; ///< over current protection mode
+ uint8_t compound_device :1; ///< flag indicating if it is a compund device
+ uint8_t power_mode :2; ///< logical power switching modes
+};
+
+/// usb hub characteristics type
+typedef struct usb_hub_characteristics usb_hub_characteristics_t;
+
+/*
+ * usb_hub_characteristics.power_mode
+ */
+
+/// usb hub logical power switching mode: treat all ports at once
+#define USB_HUB_POWER_GANGED 0
+
+/// usb hub logical power switching mode: treat all ports individual
+#define USB_HUB_POWER_INDIVIDUAL 1
+
+/// usb hub logical power switching mode: no power switching
+#define USB_HUB_POWER_NO_SWITCH 2
+
+/*
+ * usb_bub_characteristics.protection_mode
+ */
+
+/// over-current status is reported on a global (aggregated) base
+#define USB_HUB_PROTECTION_GLOBAL 0
+
+/// over-current status is reported on a per port basis
+#define USB_HUB_PROTECTION_INDIVIDUAL 1
+
+/// over current status is not reported
+#define USB_HUB_PROTECTION_NONE 2
+
+/*
+ * usb_hub_characteristics.tt_think_time
+ */
+
+/// think time is 8ms
+#define USB_HUB_TT_TIME_8 0
+
+/// think time is 16ms
+#define USB_HUB_TT_TIME_16 1
+
+/// think time is 24ms
+#define USB_HUB_TT_TIME_24 2
+
+/// think time is 32ms
+#define USB_HUB_TT_TIME_32 3
+
+//// Returns the delay from power on to power good in ms
+#define USB_HUB_POWER_ON_DELAY(hub) (hub->bPwrOn2PwrGood*2)
+
+/**
+ * ------------------------------------------------------------------------
+ * USB Hub Class Descriptor (USB Specification, Rev 2.0, Section 11.23.2.1 )
+ * ------------------------------------------------------------------------
+ * The device descriptor for USB hub class devices.
+ */
+struct usb_hub_descriptor {
+ uint8_t bDescLength; ///< the length of the descriptor in bytes
+ uint8_t bDescriptorType; ///< the descriptor type (0x29)
+ uint8_t bNbrPorts; ///< the number of ports
+ struct usb_hub_characteristics wHubCharacteristics; ///> hub characteristics
+ uint8_t bPwrOn2PwrGood; ///< time from power on till accessible (2ms)
+ uint8_t bHubContrCurrent; ///< max power requirements of the hub (mA)
+ uint8_t bDeviceRemovable[32]; ///< device removable bitmap (byte granularity)
+};
+
+// The maximum supported ports
+#define USB_HUB_MAX_PORTS 255
+
+// checks if the device at port is removable
+#define USB_HUB_DEVICE_REMOVABLE(desc, port) \
+ (!(((desc)->DeviceRemovable[(i)/8] >> ((i) % 8)) & 1))
+
+// size definition
+#define USB_HUB_DESCRIPTOR_MIN_SIZE 8
+
+/**
+ * ------------------------------------------------------------------------
+ * USB Hub Status (USB Specification, Rev 2.0, Table 11-19 )
+ * ------------------------------------------------------------------------
+ * The hub status struct is returned when querying the hub with the
+ * usb_hub_get_hub_status() request.
+ */
+struct usb_hub_status {
+ uint16_t _reserved :14; ///< unused, should be zero
+ uint8_t local_power_source :1; ///< local or external power source
+ uint8_t over_current :1; ///< the ports are draining too much power
+ uint16_t _reserved_ :14; ///< unused, should be zero
+ uint8_t local_power_change :1; ///< indicates a change in local power source
+ uint8_t over_current_change :1; ///< indicates a change in over current
+};
+
+/// usb hub status type
+typedef struct usb_hub_status usb_hub_status_t;
+
+/// check if the hub has a power supply
+#define USB_HUB_STATUS_HAS_POWERSUPPLY(st) (st->local_power_source == 0)
+
+/**
+ * ------------------------------------------------------------------------
+ * USB Hub Port Status (USB Specification, Rev 2.0, Table 11-19 )
+ * ------------------------------------------------------------------------
+ * The hub status struct is returned when querying a hub port with the
+ * usb_hub_get_port_status() request.
+ *
+ * The bit locations in the wPortStatus and wPortChange fields correspond
+ * in a one-to-one fashion where applicable.
+ *
+ * USB Specification Rev 2.0, Section 11.24.2.7.1, gives a detailed description
+ */
+struct usb_hub_port_status {
+ struct {
+ uint8_t connection :1; ///< there is a device connected to the port
+ uint8_t enabled :1; ///< the port is enabled
+ uint8_t suspend :1; ///< device on that port is suspended
+ uint8_t over_current :1; ///< a over current condition happened
+ uint8_t reset :1; ///< is set when host wants to reset device
+ uint8_t link_state :3; ///< USB 3.0, unused, set to zero
+ uint8_t power_state :1; ///< local power control state
+ uint8_t is_ls :1; ///< attached devices is a low speed device
+ uint8_t is_hs :1; ///< attached device is a high speed device
+ uint8_t test_mode :1; ///< port operates is in test mode
+ uint8_t indicator :1; ///< set if indicator color is sw controlled
+ uint8_t _reserved :2; ///< unused, set to zero
+ uint8_t device_mode :1; ///< impl specific
+ } wPortStatus; ///< port status flags
+ struct {
+ uint8_t connect :1; ///< the current connect status has changed
+ uint8_t disabled :1; ///< the port got disabled to an error
+ uint8_t resumed :1; ///< the device resume procedure is completed
+ uint8_t over_current :1; ///< there is a change in over_current status
+ uint8_t is_reset :1; ///< the reset procedure on the port is complete
+ uint8_t bh_is_reset :1;
+ uint8_t linkstate :1;
+ uint8_t configerr :1;
+ uint16_t _reserved :8; ///< unused, set to zero
+ } wPortChange; ///< port change flags
+};
+
+/**
+ * this structure represent a port on an USB hub
+ */
+struct usb_hub_port {
+ uint8_t restarts; ///< the number of restarts on this hub
+ uint8_t device_address; ///< the address of the attached device
+ usb_mode_t usb_mode; ///< the mode host or device mode
+};
+
+/// US hub port type
+typedef struct usb_hub_port usb_hub_port_t;
+
+/// the maximum number of restarts of a USB hub port
+#define USB_HUB_MAX_RESTARTS 5
+
+/**
+ * this structure defines how many bites are left in a 1ms USB time slot
+ * for full-speed isochronus schedules
+ */
+struct usb_hub_schedule {
+ uint16_t total_bytes; ///< the total bytes of the isoc schedule
+ uint8_t frame_bytes; ///< the bytes in this USB frame
+ uint8_t frame_slot; ///< the slot of this USB frame
+};
+
+
+/// type definition for the different hub protocols
+typedef enum usb_hub_protocol {
+ USB_HUB_FSHUB,
+ USB_HUB_HSHUB_SINGLE_TT,
+ USB_HUB_HSHUB_MULTI_TT,
+ USB_HUB_SSHUB
+} usb_hub_protocol;
+
+#define USB_HUB_MAX_ISOC 128
+#define USB_HUB_MAX_UFRAMES 8
+
+/**
+ * Struct containing all the relevant information for an USB hub
+ * The a usb_device sets its hub field if it is a hub.
+ */
+struct usb_hub {
+ usb_hub_status_t status;
+ struct usb_hub_schedule schedule[USB_HUB_MAX_ISOC];
+ uint8_t device_address;
+ uint16_t uframe_usage[USB_HUB_MAX_UFRAMES];
+ uint16_t portpower;
+ uint8_t isoc_last;
+ uint8_t num_ports;
+ usb_hub_protocol protocol;
+ usb_hub_port_t ports[0];
+ usb_xfer_id_t xferids[USB_HUB_NUM_TRANSFERS];
+ char name[32];
+};
+
+/*
+ * device class codes
+ */
+#define USB_HUB_CLASS_CODE 0x09
+#define USB_HUB_SUBCLASS_CODE 0x00
+#define USB_HUB_PROTOCOL_FSHUB 0x00
+#define USB_HUB_PROTOCOL_HSHUBSTT 0x01
+#define USB_HUB_PROTOCOL_HSHUBMTT 0x02
+#define USB_HUB_PROTOCOL_SSHUB 0x03
+
+/*
+ * interface class code
+ */
+#define USB_HUB_IFACE_CLASS_CODE 0x09
+#define USB_HUB_IFACE_SUBCLASS_CODE 0x00
+#define USB_HUB_IFACE_PROTOCOL_FSHUB 0x00
+#define USB_HUB_IFACE_PROTOCOL_HSHUBSTT 0x00 /* Yes, same as previous */
+#define USB_HUB_IFACE_PROTOCOL_HSHUBMTT 0x01
+
+/*
+ * USB Hub Class Specific Request Codes
+ * (USB Specification, Rev 2.0, Table 11.16)
+ */
+#define USB_HUB_REQ_GET_STATUS 0
+#define USB_HUB_REQ_CLEAR_FEATURE 1
+#define USB_HUB_REQ_SET_FEATURE 3
+#define USB_HUB_REQ_GET_DESCRIPTOR 6
+#define USB_HUB_REQ_SET_DESCRIPTOR 7
+#define USB_HUB_REQ_CLEAR_TT_BUFFER 8
+#define USB_HUB_REQ_RESET_TT 9
+#define USB_HUB_REQ_GET_TT_STATE 10
+#define USB_HUB_REQ_STOP_TT 11
+
+/*
+ * USB Hub Class Specific Request Codes
+ * (USB Specification, Rev 2.0, Table 11.17)
+ */
+#define USB_HUB_FEATURE_C_HUB_LOCAL_POWER 0
+#define USB_HUB_FEATURE_C_HUB_OVER_CURRENT 1
+#define USB_HUB_FEATURE_PORT_CONNECTION 0
+#define USB_HUB_FEATURE_PORT_ENABLE 1
+#define USB_HUB_FEATURE_PORT_SUSPEND 2
+#define USB_HUB_FEATURE_PORT_OVER_CURRENT 3
+#define USB_HUB_FEATURE_PORT_RESET 4
+#define USB_HUB_FEATURE_PORT_POWER 8
+#define USB_HUB_FEATURE_PORT_LOW_SPEED 9
+#define USB_HUB_FEATURE_C_PORT_CONNECTION 16
+#define USB_HUB_FEATURE_C_PORT_ENABLE 17
+#define USB_HUB_FEATURE_C_PORT_SUSPEND 18
+#define USB_HUB_FEATURE_C_PORT_OVER_CURRENT 19
+#define USB_HUB_FEATURE_C_PORT_RESET 20
+#define USB_HUB_FEATURE_PORT_TEST 21
+#define USB_HUB_FEATURE_PORT_INDICATOR 22
+
+usb_error_t usb_hub_clear_hub_feature(uint16_t feature);
+
+usb_error_t usb_hub_clear_port_feature(uint16_t feature, uint8_t sel,
+ uint8_t port);
+
+usb_error_t usb_hub_clear_tt_buffer(uint8_t dev_addr, uint8_t ep_num,
+ uint8_t ep_type,uint8_t direction, uint16_t tt_port);
+
+usb_error_t usb_hub_get_hub_status(struct usb_hub_status *ret_status);
+
+usb_error_t usb_hub_get_port_status(uint16_t port,
+ struct usb_hub_port_status *ret_status);
+
+usb_error_t usb_hub_reset_tt(uint16_t port);
+
+usb_error_t usb_hub_set_hub_feature(uint16_t feature);
+
+usb_error_t usb_hub_set_port_feature(uint16_t feature, uint8_t selector,
+ uint8_t port);
+
+usb_error_t usb_hub_get_tt_state(uint16_t flags, uint16_t port,
+ uint16_t max_length, uint16_t ret_length, void **ret_state);
+
+usb_error_t usb_hub_stop_tt(uint16_t port);
+
+usb_error_t usb_hub_get_hub_descriptor(uint16_t max_length,
+ struct usb_hub_descriptor **ret_desc);
+
+usb_error_t usb_hub_set_hub_descriptor(uint16_t desc_length,
+ struct usb_hub_descriptor *desc);
+
+#endif
-/**\r
- * \brief this file contains general declarations for the USB\r
- */\r
-\r
-/* Copyright (c) 2007-2013 ETH Zurich.\r
- * All rights reserved.\r
- *\r
- * This file is distributed under the terms in the attached LICENSE file.\r
- * If you do not find this file, copies can be found by writing to:\r
- * ETH Zurich D-INFK, Haldeneggsteig 4, CH-8092 Zurich. Attn: Systems Group.\r
- */\r
-\r
-#ifndef LIBUSB_USB_H_\r
-#define LIBUSB_USB_H_\r
-\r
-#include <stdio.h>\r
-#include <usb/usb_error.h>\r
-#include <usb/usb_descriptor.h>\r
-\r
-#include <barrelfish/deferred.h>\r
-\r
-/// definition for the USB\r
-#define USB_MANAGER_SERVICE "usb_manager_service_name"\r
-\r
-/**\r
- * enumeration of the differente USB modes.\r
- * Currently only the HOST mode is supported\r
- */\r
-typedef enum usb_mode {\r
- USB_MODE_HOST,\r
- USB_MODE_DEVICE,\r
- USB_MODE_DUAL\r
-} usb_mode_t;\r
-#define USB_MODE_MAX (USB_MODE_DUAL+1)\r
-\r
-\r
-/**\r
- * The USB device speed enumeration describes all possible USB speed\r
- * settings for a device.\r
- */\r
-typedef enum usb_speed {\r
- USB_SPEED_VARIABLE,\r
- USB_SPEED_LOW,\r
- USB_SPEED_FULL,\r
- USB_SPEED_HIGH,\r
- USB_SPEED_SUPER,\r
-} usb_speed_t;\r
-\r
-#define USB_SPEED_MAX (USB_SPEED_SUPER+1)\r
-\r
-/// typedef for the host controller versions\r
-typedef enum usb_hc_version {\r
- USB_UHCI=0x0100,\r
- USB_OHCI=0x0110,\r
- USB_EHCI=0x0200,\r
- USB_XHCI=0x0300\r
-} usb_hc_version_t;\r
-\r
-/// typedef for the different USB revisions\r
-typedef enum usb_revision {\r
- USB_REV_UNKNOWN,\r
- USB_REV_PRE_1_0,\r
- USB_REV_1_0,\r
- USB_REV_1_1,\r
- USB_REV_2_0,\r
- USB_REV_2_5,\r
- USB_REV_3_0\r
-} usb_revision_t;\r
-\r
-/// typedef for the different usb transfer / endpoint types\r
-typedef enum usb_type {\r
- USB_TYPE_CTRL = 0,\r
- USB_TYPE_ISOC,\r
- USB_TYPE_BULK,\r
- USB_TYPE_INTR\r
-} usb_type_t;\r
-\r
-\r
-/// typedef for the different power modes of an usb device\r
-typedef enum usb_power {\r
- USB_POWER_MODE_OFF = 0,\r
- USB_POWER_MODE_ON = 1,\r
- USB_POWER_MODE_SAVE = 2,\r
- USB_POWER_MODE_SUSPEND = 3,\r
- USB_POWER_MODE_RESUME = 4\r
-} usb_power_t;\r
-\r
-/// the maximum power consumption in mA\r
-#define USB_POWER_MAX 500\r
-\r
-/// the minimum power requirements in mA\r
-#define USB_POWER_MIN 100\r
-\r
-/// the USB physical address type\r
-typedef volatile uintptr_t usb_paddr_t;\r
-\r
-/// definition for the default configuration value\r
-#define USB_CONFIGURATION_DEFAULT 1\r
-\r
-/// definition if the USB\r
-#define USB_CONFIGURATION_UNCONFIGURED 0xFF\r
-\r
-/// generic usb status\r
-struct usb_status {\r
- uint16_t wStatus;\r
-};\r
-typedef struct usb_status usb_status_t;\r
-\r
-#define USB_STATUS_SELF_POWERED 0x0001;\r
-#define USB_STATUS_REMOTE_WAKEUP 0x0002;\r
-#define USB_STATUS_EP_HALT 0x0001;\r
-\r
-/*\r
- * Specific delays\r
- */\r
-#define USB_DELAY_PORT_RESET 10\r
-#define USB_DELAY_PORT_ROOT_RESET 50\r
-#define USB_DELAY_PORT_RECOVERY 10\r
-#define USB_DELAY_PORT_POWERUP 100\r
-#define USB_DELAY_PORT_RESUME 20\r
-#define USB_DELAY_SET_ADDRESS 2\r
-#define USB_DELAY_RESUME 100\r
-#define USB_DELAY_WAIT 10\r
-#define USB_DELAY_RECOVERY 10\r
-\r
-/*\r
- * debug message control\r
- */\r
-\r
-#define USB_DEBUG(x...) debug_printf(x)\r
-//#define USB_DEBUG(x...)\r
-\r
-//#define USB_DEBUG_XFER(x...) USB_DEBUG(x)\r
-#define USB_DEBUG_XFER(x...)\r
-\r
-#define USB_DEBUG_HC(x...) USB_DEBUG(x)\r
-//#define USB_DEBUG_HC(x...)\r
-\r
-//#define USB_DEBUG_XFER_HC(x...) USB_DEBUG(x)\r
-#define USB_DEBUG_XFER_HC(x...)\r
-\r
-//#define USB_DEBUG_REQ(x...) USB_DEBUG(x)\r
-#define USB_DEBUG_REQ(x...)\r
-\r
-//#define USB_DEBUG_DEV(x...) USB_DEBUG(x)\r
-#define USB_DEBUG_DEV(x...)\r
-\r
-//#define USB_DEBUG_TR_ENTER USB_DEBUG(">> %s()\n", __func__)\r
-#define USB_DEBUG_TR_ENTER\r
-\r
-//#define USB_DEBUG_TR_RETURN USB_DEBUG("<< %s() return\n", __func__)\r
-#define USB_DEBUG_TR_RETURN\r
-\r
-#define USB_DEBUG_TR(x...) USB_DEBUG(x)\r
-\r
-#define USB_DEBUG_DRIVER(x...) USB_DEBUG(x)\r
-//#define USB_DEBUG_DRIVER(x...)\r
-\r
-//#define USB_DEBUG_MEM(x...) USB_DEBUG(x)\r
-#define USB_DEBUG_MEM(x...)\r
-\r
-#define USB_DEBUG_IDC(x...)\r
-//#define USB_DEBUG_IDC(x...) USB_DEBUG(x)\r
-\r
-//#define USB_DEBUG_HID(x...) debug_printf(x)\r
-#define USB_DEBUG_HID(x...)\r
-\r
-/*\r
- * Wait a specific amount of milliseconds. This is a replacement for the USB_WAIT macro.\r
- *\r
- * \param ms Milliseconds to wait\r
- *\r
- * \return the error value from barrelfish_usleep\r
- */\r
-static inline errval_t lib_usb_wait(uint32_t ms) {\r
- return barrelfish_usleep(1000 * ms);\r
-}\r
-\r
-typedef void (*lib_usb_callback)(void *st, usb_error_t err);\r
-\r
-usb_error_t usb_lib_init(uint16_t init_config, lib_usb_callback cb, void* st);\r
-\r
-#endif\r
+/**
+ * \brief this file contains general declarations for the USB
+ */
+
+/* Copyright (c) 2007-2013 ETH Zurich.
+ * All rights reserved.
+ *
+ * This file is distributed under the terms in the attached LICENSE file.
+ * If you do not find this file, copies can be found by writing to:
+ * ETH Zurich D-INFK, Haldeneggsteig 4, CH-8092 Zurich. Attn: Systems Group.
+ */
+
+#ifndef LIBUSB_USB_H_
+#define LIBUSB_USB_H_
+
+#include <stdio.h>
+#include <usb/usb_error.h>
+#include <usb/usb_descriptor.h>
+
+#include <barrelfish/deferred.h>
+
+/// definition for the USB
+#define USB_MANAGER_SERVICE "usb_manager_service_name"
+
+/**
+ * enumeration of the differente USB modes.
+ * Currently only the HOST mode is supported
+ */
+typedef enum usb_mode {
+ USB_MODE_HOST,
+ USB_MODE_DEVICE,
+ USB_MODE_DUAL
+} usb_mode_t;
+#define USB_MODE_MAX (USB_MODE_DUAL+1)
+
+
+/**
+ * The USB device speed enumeration describes all possible USB speed
+ * settings for a device.
+ */
+typedef enum usb_speed {
+ USB_SPEED_VARIABLE,
+ USB_SPEED_LOW,
+ USB_SPEED_FULL,
+ USB_SPEED_HIGH,
+ USB_SPEED_SUPER,
+} usb_speed_t;
+
+#define USB_SPEED_MAX (USB_SPEED_SUPER+1)
+
+/// typedef for the host controller versions
+typedef enum usb_hc_version {
+ USB_UHCI=0x0100,
+ USB_OHCI=0x0110,
+ USB_EHCI=0x0200,
+ USB_XHCI=0x0300
+} usb_hc_version_t;
+
+/// typedef for the different USB revisions
+typedef enum usb_revision {
+ USB_REV_UNKNOWN,
+ USB_REV_PRE_1_0,
+ USB_REV_1_0,
+ USB_REV_1_1,
+ USB_REV_2_0,
+ USB_REV_2_5,
+ USB_REV_3_0
+} usb_revision_t;
+
+/// typedef for the different usb transfer / endpoint types
+typedef enum usb_type {
+ USB_TYPE_CTRL = 0,
+ USB_TYPE_ISOC,
+ USB_TYPE_BULK,
+ USB_TYPE_INTR
+} usb_type_t;
+
+
+/// typedef for the different power modes of an usb device
+typedef enum usb_power {
+ USB_POWER_MODE_OFF = 0,
+ USB_POWER_MODE_ON = 1,
+ USB_POWER_MODE_SAVE = 2,
+ USB_POWER_MODE_SUSPEND = 3,
+ USB_POWER_MODE_RESUME = 4
+} usb_power_t;
+
+/// the maximum power consumption in mA
+#define USB_POWER_MAX 500
+
+/// the minimum power requirements in mA
+#define USB_POWER_MIN 100
+
+/// the USB physical address type
+typedef volatile uintptr_t usb_paddr_t;
+
+/// definition for the default configuration value
+#define USB_CONFIGURATION_DEFAULT 1
+
+/// definition if the USB
+#define USB_CONFIGURATION_UNCONFIGURED 0xFF
+
+/// generic usb status
+struct usb_status {
+ uint16_t wStatus;
+};
+typedef struct usb_status usb_status_t;
+
+#define USB_STATUS_SELF_POWERED 0x0001;
+#define USB_STATUS_REMOTE_WAKEUP 0x0002;
+#define USB_STATUS_EP_HALT 0x0001;
+
+/*
+ * Specific delays
+ */
+#define USB_DELAY_PORT_RESET 10
+#define USB_DELAY_PORT_ROOT_RESET 50
+#define USB_DELAY_PORT_RECOVERY 10
+#define USB_DELAY_PORT_POWERUP 100
+#define USB_DELAY_PORT_RESUME 20
+#define USB_DELAY_SET_ADDRESS 2
+#define USB_DELAY_RESUME 100
+#define USB_DELAY_WAIT 10
+#define USB_DELAY_RECOVERY 10
+
+/*
+ * debug message control
+ */
+
+#define USB_DEBUG(x...) debug_printf(x)
+//#define USB_DEBUG(x...)
+
+//#define USB_DEBUG_XFER(x...) USB_DEBUG(x)
+#define USB_DEBUG_XFER(x...)
+
+#define USB_DEBUG_HC(x...) USB_DEBUG(x)
+//#define USB_DEBUG_HC(x...)
+
+//#define USB_DEBUG_XFER_HC(x...) USB_DEBUG(x)
+#define USB_DEBUG_XFER_HC(x...)
+
+//#define USB_DEBUG_REQ(x...) USB_DEBUG(x)
+#define USB_DEBUG_REQ(x...)
+
+//#define USB_DEBUG_DEV(x...) USB_DEBUG(x)
+#define USB_DEBUG_DEV(x...)
+
+//#define USB_DEBUG_TR_ENTER USB_DEBUG(">> %s()\n", __func__)
+#define USB_DEBUG_TR_ENTER
+
+//#define USB_DEBUG_TR_RETURN USB_DEBUG("<< %s() return\n", __func__)
+#define USB_DEBUG_TR_RETURN
+
+#define USB_DEBUG_TR(x...) USB_DEBUG(x)
+
+#define USB_DEBUG_DRIVER(x...) USB_DEBUG(x)
+//#define USB_DEBUG_DRIVER(x...)
+
+//#define USB_DEBUG_MEM(x...) USB_DEBUG(x)
+#define USB_DEBUG_MEM(x...)
+
+#define USB_DEBUG_IDC(x...)
+//#define USB_DEBUG_IDC(x...) USB_DEBUG(x)
+
+//#define USB_DEBUG_HID(x...) debug_printf(x)
+#define USB_DEBUG_HID(x...)
+
+/*
+ * Wait a specific amount of milliseconds. This is a replacement for the USB_WAIT macro.
+ *
+ * \param ms Milliseconds to wait
+ *
+ * \return the error value from barrelfish_usleep
+ */
+static inline errval_t lib_usb_wait(uint32_t ms) {
+ return barrelfish_usleep(1000 * ms);
+}
+
+typedef void (*lib_usb_callback)(void *st, usb_error_t err);
+
+usb_error_t usb_lib_init(uint16_t init_config, lib_usb_callback cb, void* st);
+
+#endif
-/**\r
- * \brief this file contains definitions for the standard USB descriptors\r
- */\r
-\r
-/*\r
- * Copyright (c) 2007-2013 ETH Zurich.\r
- * All rights reserved.\r
- *\r
- * This file is distributed under the terms in the attached LICENSE file.\r
- * If you do not find this file, copies can be found by writing to:\r
- * ETH Zurich D-INFK, Haldeneggsteig 4, CH-8092 Zurich. Attn: Systems Group.\r
- */\r
-\r
-#ifndef _USB_DESCRIPTOR_H_\r
-#define _USB_DESCRIPTOR_H_\r
-\r
-#include <stdint.h>\r
-\r
-//USB descriptor codes (USB Specification, Rev 2.0, Table 9.5)\r
-#define USB_DESCRIPTOR_TYPE_DEVICE 1\r
-#define USB_DESCRIPTOR_TYPE_CONFIG 2\r
-#define USB_DESCRIPTOR_TYPE_STRING 3\r
-#define USB_DESCRIPTOR_TYPE_INTERFACE 4\r
-#define USB_DESCRIPTOR_TYPE_ENDPOINT 5\r
-#define USB_DESCRIPTOR_TYPE_DEVICE_QUALIFIER 6\r
-#define USB_DESCRIPTOR_TYPE_OTHER_SPEED_CONFIG 7\r
-#define USB_DESCRIPTOR_TYPE_INTERFACE_POWER 8\r
-#define USB_DESCRIPTOR_TYPE_OTG 9\r
-\r
-// USB Specification Release Numbers\r
-#define USB_RELEASE_NUMBER_10 0x0100\r
-#define USB_RELEASE_NUMBER_11 0x0110\r
-#define USB_RELEASE_NUMBER_20 0x0200\r
-#define USB_RELEASE_NUMBER_25 0x0250\r
-#define USB_RELEASE_NUMBER_30 0x0300\r
-\r
-// USB release number masks\r
-#define USB_RELEASE_NUMBER_MAJOR 0xFF00\r
-#define USB_RELEASE_NUMBER_MINOR 0x00F0\r
-#define USB_RELEASE_NUMBER_SUB 0x000F\r
-\r
-/**\r
- * ------------------------------------------------------------------------\r
- * USB Generic Descriptor\r
- * ------------------------------------------------------------------------\r
- */\r
-struct usb_descriptor {\r
- uint8_t bLength; ///< the length of this descriptor\r
- uint8_t bDescriptorType; ///< the type of this descriptor\r
- uint8_t bDescriptorSubType; ///< the subtype of this descritpor\r
-}__attribute__((packed));\r
-\r
-/// type definition for the generic descriptor\r
-typedef struct usb_descriptor usb_descriptor_t;\r
-\r
-/**\r
- * ------------------------------------------------------------------------\r
- * USB Device Descriptor (USB Specification, Rev 2.0, Section 9.6.1)\r
- * ------------------------------------------------------------------------\r
- * General and global information about an USB device. Each USB device\r
- * has exactly one usb_device_descriptor.\r
- */\r
-struct usb_device_descriptor {\r
- uint8_t bLength; ///< the length of the descriptor (18 bytes)\r
- uint8_t bDescriptorType; ///< always USB_DESCRIPTOR_TYPE_DEVICE\r
- uint16_t bcdUSB; ///< the USB revision number\r
- uint8_t bDeviceClass; ///< device class code (defined by USB-IF)\r
- uint8_t bDeviceSubClass; ///< device sub class code (defined by USB-IF)\r
- uint8_t bDeviceProtocol; ///< specific protocol used by this device\r
- uint8_t bMaxPacketSize0; ///< the max packet size of endpoint 0\r
- uint16_t idVendor; ///< the vendor ID\r
- uint16_t idProduct; ///< the product ID\r
- uint16_t bcdDevice; ///< the revision of the device\r
- uint8_t iManufacturer; ///< string index of the manufacturer\r
- uint8_t iProduct; ///< string index of the product\r
- uint8_t iSerialNumber; ///< string index of the serial number\r
- uint8_t bNumConfigurations; ///< the number of configurations\r
-};\r
-\r
-/// type definition of the device descriptor\r
-typedef struct usb_device_descriptor usb_device_descriptor_t;\r
-\r
-/// size information of the device descriptor\r
-#define USB_DEVICE_DESCRIPTOR_SIZE 18\r
-\r
-/**\r
- * ------------------------------------------------------------------------\r
- * USB Device Qualifier Descriptor (USB Specification, Rev 2.0, Section 9.6.2)\r
- * ------------------------------------------------------------------------\r
- * This descriptor contains information about a high-speed capable device\r
- * that would change, if the device is operating at other speed:\r
- * - device runs at full speed -> descriptor returns values for high speed.\r
- */\r
-struct usb_device_qualifier_descriptor {\r
- uint8_t bLength; ///< should be 10 bytes\r
- uint8_t bDescriptorType; ///< always USB_DESCRIPTOR_TYPE_DEVICE_QUALIFIER\r
- uint16_t bcdUSB; ///< the USB revision\r
- uint8_t bDeviceClass; ///< USB device class code (defined by USB-IF)\r
- uint8_t bDeviceSubClass; ///< SB Device subclass code (defined by USB-IF)\r
- uint8_t bDeviceProtocol; ///< the device protocol to be used\r
- uint8_t bMaxPacketSize0; ///< maximum packet size of endpoint 0\r
- uint8_t bNumConfigurations; ///< the number of configurations\r
- uint8_t bReserved; ///< always zero\r
-}__attribute__((packed));\r
-\r
-/// type definition of the qualifier descriptor\r
-typedef struct usb_device_qualifier_descriptor usb_device_qualifier_descriptor_t;\r
-\r
-// size information of the device qualifier descriptor\r
-#define USB_DEVICE_QUALIFIER_DESCRIPTOR_SIZE 10\r
-\r
-/**\r
- * ------------------------------------------------------------------------\r
- * USB Configuration Descriptor (USB Specification, Rev 2.0, Section 9.6.3)\r
- * ------------------------------------------------------------------------\r
- * This descriptor contains information about a specific device\r
- * configuration. The bConfigurationValue is used as a parameter to\r
- * SetConfiguration().\r
- *\r
- * wTotalLength: the size of the entire configuration:\r
- * config descriptor + interfaces + endpoints\r
- * Each USB device has one or more configuration descriptors\r
- */\r
-struct usb_config_descriptor {\r
- uint8_t bLength; ///< length of the descriptor in bytes\r
- uint8_t bDescriptorType; ///< always USB_DESCRIPTOR_TYPE_CONFIG\r
- uint16_t wTotalLength; ///< total length of this descritpor\r
- uint8_t bNumInterfaces; ///< the number of interfaces in this config\r
- uint8_t bConfigurationValue; ///< parameter for SetConfiguration()\r
- uint8_t iConfiguration; ///< string index of this configuration\r
- uint8_t bmAttributes; ///< configuration characteristics\r
- uint8_t bMaxPower; ///< the maximum power consumption (2mA steps)\r
-}__attribute__((packed));\r
-\r
-typedef struct usb_config_descriptor usb_config_descriptor_t;\r
-\r
-// size information of the configuration descriptor\r
-#define USB_CONFIG_DESCRIPTOR_SIZE 9\r
-\r
-// values for the bit map\r
-#define USB_CONFIG_SELF_POWERED 0x40\r
-#define USB_CONFIG_REMOTE_WAKEUP 0x20\r
-#define USB_CONFIG_BUS_POWERED 0x80\r
-\r
-/**\r
- * ------------------------------------------------------------------------\r
- * USB Interface Descriptor (USB Specification, Rev 2.0, Section 9.6.5)\r
- * ------------------------------------------------------------------------\r
- * This descriptor contains information about a specific interface within\r
- * an USB configuration. The interface descriptor defines an unique set\r
- * of endpoints within the configuration.\r
- *\r
- * Interface descriptors cannot directly be accesses by Get/SetDescriptor(),\r
- * they are returned as a part of the configuration descriptor.\r
- */\r
-struct usb_interface_descriptor {\r
- uint8_t bLength; ///< should be 9 bytes\r
- uint8_t bDescriptorType; ///< always USB_DESCRIPTOR_TYPE_INTERFACE\r
- uint8_t bInterfaceNumber; ///< number of this interface within the config\r
- uint8_t bAlternateSetting; ///< the alternate setting\r
- uint8_t bNumEndpoints; ///< number of used endpoints in this interface\r
- uint8_t bInterfaceClass; ///< interface class code (assigned by USB-IF)\r
- uint8_t bInterfaceSubClass; ///< interface subclass code (assigned by USB-IF)\r
- uint8_t bInterfaceProtocol; ///< protocol code (qualified by class/subclass)\r
- uint8_t iInterface; ///< string index describing this interface\r
-}__attribute__((packed));\r
-\r
-/// type definition for the interface descriptor\r
-typedef struct usb_interface_descriptor usb_interface_descriptor_t;\r
-\r
-// size information about the interface descriptor\r
-#define USB_INTERFACE_DESCRIPTOR_SIZE 9\r
-\r
-\r
-struct usb_endpoint_address {\r
- uint8_t ep_number :4; ///< the endpoint number\r
- uint8_t _reserved :3; ///< should be zero\r
- uint8_t direction :1; ///< direction, either IN or OUT\r
-};\r
-typedef struct usb_endpoint_address usb_endpoint_address_t;\r
-\r
-struct usb_endpoint_attributes {\r
- uint8_t xfer_type :2; ///< the type of this endpoint\r
- uint8_t sync_type :2; ///< for isochronus only\r
- uint8_t usage_type :2; ///< for isochronous only\r
- uint8_t _unused :2; ///< should be zero\r
-};\r
-typedef struct usb_endpoint_attributes usb_endpoint_attributes_t;\r
-\r
-/**\r
- * ------------------------------------------------------------------------\r
- * USB Endpoint Descriptor (USB Specification, Rev 2.0, Section 9.6.6)\r
- * ------------------------------------------------------------------------\r
- * This descriptor contains information about one endpoint for an interface.\r
- * Endpoint descriptors are always returned as part of the configuration\r
- * Information by GetConfiguration().\r
- *\r
- * Each endpoint has its own endpoint descriptor.\r
- */\r
-struct usb_endpoint_descriptor {\r
- uint8_t bLength; ///< should be 9 bytes\r
- uint8_t bDescriptorType; ///< always USB_DESCRIPTOR_TYPE_ENDPOINT\r
- usb_endpoint_address_t bEndpointAddress;\r
- usb_endpoint_attributes_t bmAttributes;\r
- uint16_t wMaxPacketSize; ///< maximum packet size for this endpoint\r
- uint8_t bInterval; ///< interval for polling in (micro)frames\r
-}__attribute__((packed));\r
-\r
-typedef struct usb_endpoint_descriptor usb_endpoint_descriptor_t;\r
-\r
-// size information of endpoint descriptor\r
-#define USB_ENDPOINT_DESCRIPTOR_SIZE 9\r
-\r
-/// used for endpoint lookup\r
-#define USB_ENDPOINT_ADDRESS_ANY 0xFF\r
-\r
-// endpoint directions\r
-#define USB_ENDPOINT_DIRECTION_OUT 0x00\r
-#define USB_ENDPOINT_DIRECTION_IN 0x01\r
-#define USB_ENDPOINT_DIRECTION_ANY 0xFF\r
-\r
-// endpoint types\r
-#define USB_ENDPOINT_TYPE_CONTROL 0x00\r
-#define USB_ENDPOINT_TYPE_ISOCHR 0x01\r
-#define USB_ENDPOINT_TYPE_BULK 0x02\r
-#define USB_ENDPOINT_TYPE_INTR 0x03\r
-#define USB_ENDPOINT_TYPE_ANY 0xFF\r
-\r
-// endpoint synchronization for isochronus transfers\r
-#define USB_ENDPOINT_SYNC_NON_ISO 0x00\r
-#define USB_ENDPOINT_SYNC_NONE 0x00\r
-#define USB_ENDPOINT_SYNC_ASYNC 0x04\r
-#define USB_ENDPOINT_SYNC_ADAPT 0x08\r
-#define USB_ENDPOINT_SYNC_SYNC 0x0A\r
-\r
-// endpoint usages for isochronus transfers\r
-#define USB_ENDPOINT_USAGE_NON_ISO 0x00\r
-#define USB_ENDPOINT_USAGE_DATA 0x00\r
-#define USB_ENDPOINT_USAGE_FEEDBACK 0x10\r
-#define USB_ENDPOINT_USAGE_IMPLICIT 0x20\r
-#define USB_ENDPOINT_USAGE_RESERVED 0x30\r
-\r
-/**\r
- * ------------------------------------------------------------------------\r
- * USB String Descriptor (USB Specification, Rev 2.0, Section 9.6.7)\r
- * ------------------------------------------------------------------------\r
- * String descriptors contains string describing certain elements of other\r
- * USB descriptors. String descriptors are optional. All references to\r
- * string descriptors are set to zero if they are not implemented by\r
- * the device\r
- *\r
- * The strings are encoded using UNICODE and are NOT null terminated.\r
- */\r
-struct usb_string_descriptor_languages {\r
- uint8_t bLength; ///< length of the descriptor in bytes\r
- uint8_t bDescriptorType; ///< always USB_DESCRIPTOR_TYPE_STRING\r
- uint16_t wLangID[128]; ///< language ID code\r
-}__attribute__((packed));\r
-\r
-typedef struct usb_string_descriptor_languages usb_string_descriptor_languages_t;\r
-\r
-struct usb_string_descriptor {\r
- uint8_t bLength; ///< length of the descriptor in bytes\r
- uint8_t bDescriptorType; ///< always USB_DESCRIPTOR_TYPE_STRING\r
- char bString[256]; ///< char array containing the string (not null term.)\r
-}__attribute__((packed));\r
-\r
-typedef struct usb_string_descriptor usb_string_descriptor_t;\r
-\r
-#define USB_STRING_GET_ELEMENT_COUNT(sd) ((sd->bLength -2 )/2)\r
-#define USB_STRING_GET_STRLEN(sd) ((sd->bLength -2 ))\r
-\r
-/**\r
- * ------------------------------------------------------------------------\r
- * USB Generic Descriptor\r
- * ------------------------------------------------------------------------\r
- * This descriptor is used to supply the device driver with all the necessary\r
- * information upon initialization and connection to the usb manager.\r
- *\r
- * A request for a configuration descriptor returns the configuration\r
- * descriptor, all interface descriptors, and endpoint descriptors for all of\r
- * the interfaces in a single request. The first interface descriptor follows\r
- * the configuration descriptor. The endpoint descriptors for the first\r
- * interface follow the first interface descriptor. If there are additional\r
- * interfaces, their interface descriptor and endpoint descriptors follow the\r
- * first interface’s endpoint descriptors.\r
- */\r
-struct usb_generic_descriptor {\r
- struct usb_device_descriptor device;\r
- struct usb_config_descriptor config;\r
- struct usb_interface_descriptor iface[1];\r
- struct usb_endpoint_descriptor endpoint[1];\r
-};\r
-\r
-typedef struct usb_generic_descriptor usb_generic_descriptor_t;\r
-\r
-#endif\r
+/**
+ * \brief this file contains definitions for the standard USB descriptors
+ */
+
+/*
+ * Copyright (c) 2007-2013 ETH Zurich.
+ * All rights reserved.
+ *
+ * This file is distributed under the terms in the attached LICENSE file.
+ * If you do not find this file, copies can be found by writing to:
+ * ETH Zurich D-INFK, Haldeneggsteig 4, CH-8092 Zurich. Attn: Systems Group.
+ */
+
+#ifndef _USB_DESCRIPTOR_H_
+#define _USB_DESCRIPTOR_H_
+
+#include <stdint.h>
+
+//USB descriptor codes (USB Specification, Rev 2.0, Table 9.5)
+#define USB_DESCRIPTOR_TYPE_DEVICE 1
+#define USB_DESCRIPTOR_TYPE_CONFIG 2
+#define USB_DESCRIPTOR_TYPE_STRING 3
+#define USB_DESCRIPTOR_TYPE_INTERFACE 4
+#define USB_DESCRIPTOR_TYPE_ENDPOINT 5
+#define USB_DESCRIPTOR_TYPE_DEVICE_QUALIFIER 6
+#define USB_DESCRIPTOR_TYPE_OTHER_SPEED_CONFIG 7
+#define USB_DESCRIPTOR_TYPE_INTERFACE_POWER 8
+#define USB_DESCRIPTOR_TYPE_OTG 9
+
+// USB Specification Release Numbers
+#define USB_RELEASE_NUMBER_10 0x0100
+#define USB_RELEASE_NUMBER_11 0x0110
+#define USB_RELEASE_NUMBER_20 0x0200
+#define USB_RELEASE_NUMBER_25 0x0250
+#define USB_RELEASE_NUMBER_30 0x0300
+
+// USB release number masks
+#define USB_RELEASE_NUMBER_MAJOR 0xFF00
+#define USB_RELEASE_NUMBER_MINOR 0x00F0
+#define USB_RELEASE_NUMBER_SUB 0x000F
+
+/**
+ * ------------------------------------------------------------------------
+ * USB Generic Descriptor
+ * ------------------------------------------------------------------------
+ */
+struct usb_descriptor {
+ uint8_t bLength; ///< the length of this descriptor
+ uint8_t bDescriptorType; ///< the type of this descriptor
+ uint8_t bDescriptorSubType; ///< the subtype of this descritpor
+}__attribute__((packed));
+
+/// type definition for the generic descriptor
+typedef struct usb_descriptor usb_descriptor_t;
+
+/**
+ * ------------------------------------------------------------------------
+ * USB Device Descriptor (USB Specification, Rev 2.0, Section 9.6.1)
+ * ------------------------------------------------------------------------
+ * General and global information about an USB device. Each USB device
+ * has exactly one usb_device_descriptor.
+ */
+struct usb_device_descriptor {
+ uint8_t bLength; ///< the length of the descriptor (18 bytes)
+ uint8_t bDescriptorType; ///< always USB_DESCRIPTOR_TYPE_DEVICE
+ uint16_t bcdUSB; ///< the USB revision number
+ uint8_t bDeviceClass; ///< device class code (defined by USB-IF)
+ uint8_t bDeviceSubClass; ///< device sub class code (defined by USB-IF)
+ uint8_t bDeviceProtocol; ///< specific protocol used by this device
+ uint8_t bMaxPacketSize0; ///< the max packet size of endpoint 0
+ uint16_t idVendor; ///< the vendor ID
+ uint16_t idProduct; ///< the product ID
+ uint16_t bcdDevice; ///< the revision of the device
+ uint8_t iManufacturer; ///< string index of the manufacturer
+ uint8_t iProduct; ///< string index of the product
+ uint8_t iSerialNumber; ///< string index of the serial number
+ uint8_t bNumConfigurations; ///< the number of configurations
+};
+
+/// type definition of the device descriptor
+typedef struct usb_device_descriptor usb_device_descriptor_t;
+
+/// size information of the device descriptor
+#define USB_DEVICE_DESCRIPTOR_SIZE 18
+
+/**
+ * ------------------------------------------------------------------------
+ * USB Device Qualifier Descriptor (USB Specification, Rev 2.0, Section 9.6.2)
+ * ------------------------------------------------------------------------
+ * This descriptor contains information about a high-speed capable device
+ * that would change, if the device is operating at other speed:
+ * - device runs at full speed -> descriptor returns values for high speed.
+ */
+struct usb_device_qualifier_descriptor {
+ uint8_t bLength; ///< should be 10 bytes
+ uint8_t bDescriptorType; ///< always USB_DESCRIPTOR_TYPE_DEVICE_QUALIFIER
+ uint16_t bcdUSB; ///< the USB revision
+ uint8_t bDeviceClass; ///< USB device class code (defined by USB-IF)
+ uint8_t bDeviceSubClass; ///< SB Device subclass code (defined by USB-IF)
+ uint8_t bDeviceProtocol; ///< the device protocol to be used
+ uint8_t bMaxPacketSize0; ///< maximum packet size of endpoint 0
+ uint8_t bNumConfigurations; ///< the number of configurations
+ uint8_t bReserved; ///< always zero
+}__attribute__((packed));
+
+/// type definition of the qualifier descriptor
+typedef struct usb_device_qualifier_descriptor usb_device_qualifier_descriptor_t;
+
+// size information of the device qualifier descriptor
+#define USB_DEVICE_QUALIFIER_DESCRIPTOR_SIZE 10
+
+/**
+ * ------------------------------------------------------------------------
+ * USB Configuration Descriptor (USB Specification, Rev 2.0, Section 9.6.3)
+ * ------------------------------------------------------------------------
+ * This descriptor contains information about a specific device
+ * configuration. The bConfigurationValue is used as a parameter to
+ * SetConfiguration().
+ *
+ * wTotalLength: the size of the entire configuration:
+ * config descriptor + interfaces + endpoints
+ * Each USB device has one or more configuration descriptors
+ */
+struct usb_config_descriptor {
+ uint8_t bLength; ///< length of the descriptor in bytes
+ uint8_t bDescriptorType; ///< always USB_DESCRIPTOR_TYPE_CONFIG
+ uint16_t wTotalLength; ///< total length of this descritpor
+ uint8_t bNumInterfaces; ///< the number of interfaces in this config
+ uint8_t bConfigurationValue; ///< parameter for SetConfiguration()
+ uint8_t iConfiguration; ///< string index of this configuration
+ uint8_t bmAttributes; ///< configuration characteristics
+ uint8_t bMaxPower; ///< the maximum power consumption (2mA steps)
+}__attribute__((packed));
+
+typedef struct usb_config_descriptor usb_config_descriptor_t;
+
+// size information of the configuration descriptor
+#define USB_CONFIG_DESCRIPTOR_SIZE 9
+
+// values for the bit map
+#define USB_CONFIG_SELF_POWERED 0x40
+#define USB_CONFIG_REMOTE_WAKEUP 0x20
+#define USB_CONFIG_BUS_POWERED 0x80
+
+/**
+ * ------------------------------------------------------------------------
+ * USB Interface Descriptor (USB Specification, Rev 2.0, Section 9.6.5)
+ * ------------------------------------------------------------------------
+ * This descriptor contains information about a specific interface within
+ * an USB configuration. The interface descriptor defines an unique set
+ * of endpoints within the configuration.
+ *
+ * Interface descriptors cannot directly be accesses by Get/SetDescriptor(),
+ * they are returned as a part of the configuration descriptor.
+ */
+struct usb_interface_descriptor {
+ uint8_t bLength; ///< should be 9 bytes
+ uint8_t bDescriptorType; ///< always USB_DESCRIPTOR_TYPE_INTERFACE
+ uint8_t bInterfaceNumber; ///< number of this interface within the config
+ uint8_t bAlternateSetting; ///< the alternate setting
+ uint8_t bNumEndpoints; ///< number of used endpoints in this interface
+ uint8_t bInterfaceClass; ///< interface class code (assigned by USB-IF)
+ uint8_t bInterfaceSubClass; ///< interface subclass code (assigned by USB-IF)
+ uint8_t bInterfaceProtocol; ///< protocol code (qualified by class/subclass)
+ uint8_t iInterface; ///< string index describing this interface
+}__attribute__((packed));
+
+/// type definition for the interface descriptor
+typedef struct usb_interface_descriptor usb_interface_descriptor_t;
+
+// size information about the interface descriptor
+#define USB_INTERFACE_DESCRIPTOR_SIZE 9
+
+
+struct usb_endpoint_address {
+ uint8_t ep_number :4; ///< the endpoint number
+ uint8_t _reserved :3; ///< should be zero
+ uint8_t direction :1; ///< direction, either IN or OUT
+};
+typedef struct usb_endpoint_address usb_endpoint_address_t;
+
+struct usb_endpoint_attributes {
+ uint8_t xfer_type :2; ///< the type of this endpoint
+ uint8_t sync_type :2; ///< for isochronus only
+ uint8_t usage_type :2; ///< for isochronous only
+ uint8_t _unused :2; ///< should be zero
+};
+typedef struct usb_endpoint_attributes usb_endpoint_attributes_t;
+
+/**
+ * ------------------------------------------------------------------------
+ * USB Endpoint Descriptor (USB Specification, Rev 2.0, Section 9.6.6)
+ * ------------------------------------------------------------------------
+ * This descriptor contains information about one endpoint for an interface.
+ * Endpoint descriptors are always returned as part of the configuration
+ * Information by GetConfiguration().
+ *
+ * Each endpoint has its own endpoint descriptor.
+ */
+struct usb_endpoint_descriptor {
+ uint8_t bLength; ///< should be 9 bytes
+ uint8_t bDescriptorType; ///< always USB_DESCRIPTOR_TYPE_ENDPOINT
+ usb_endpoint_address_t bEndpointAddress;
+ usb_endpoint_attributes_t bmAttributes;
+ uint16_t wMaxPacketSize; ///< maximum packet size for this endpoint
+ uint8_t bInterval; ///< interval for polling in (micro)frames
+}__attribute__((packed));
+
+typedef struct usb_endpoint_descriptor usb_endpoint_descriptor_t;
+
+// size information of endpoint descriptor
+#define USB_ENDPOINT_DESCRIPTOR_SIZE 9
+
+/// used for endpoint lookup
+#define USB_ENDPOINT_ADDRESS_ANY 0xFF
+
+// endpoint directions
+#define USB_ENDPOINT_DIRECTION_OUT 0x00
+#define USB_ENDPOINT_DIRECTION_IN 0x01
+#define USB_ENDPOINT_DIRECTION_ANY 0xFF
+
+// endpoint types
+#define USB_ENDPOINT_TYPE_CONTROL 0x00
+#define USB_ENDPOINT_TYPE_ISOCHR 0x01
+#define USB_ENDPOINT_TYPE_BULK 0x02
+#define USB_ENDPOINT_TYPE_INTR 0x03
+#define USB_ENDPOINT_TYPE_ANY 0xFF
+
+// endpoint synchronization for isochronus transfers
+#define USB_ENDPOINT_SYNC_NON_ISO 0x00
+#define USB_ENDPOINT_SYNC_NONE 0x00
+#define USB_ENDPOINT_SYNC_ASYNC 0x04
+#define USB_ENDPOINT_SYNC_ADAPT 0x08
+#define USB_ENDPOINT_SYNC_SYNC 0x0A
+
+// endpoint usages for isochronus transfers
+#define USB_ENDPOINT_USAGE_NON_ISO 0x00
+#define USB_ENDPOINT_USAGE_DATA 0x00
+#define USB_ENDPOINT_USAGE_FEEDBACK 0x10
+#define USB_ENDPOINT_USAGE_IMPLICIT 0x20
+#define USB_ENDPOINT_USAGE_RESERVED 0x30
+
+/**
+ * ------------------------------------------------------------------------
+ * USB String Descriptor (USB Specification, Rev 2.0, Section 9.6.7)
+ * ------------------------------------------------------------------------
+ * String descriptors contains string describing certain elements of other
+ * USB descriptors. String descriptors are optional. All references to
+ * string descriptors are set to zero if they are not implemented by
+ * the device
+ *
+ * The strings are encoded using UNICODE and are NOT null terminated.
+ */
+struct usb_string_descriptor_languages {
+ uint8_t bLength; ///< length of the descriptor in bytes
+ uint8_t bDescriptorType; ///< always USB_DESCRIPTOR_TYPE_STRING
+ uint16_t wLangID[128]; ///< language ID code
+}__attribute__((packed));
+
+typedef struct usb_string_descriptor_languages usb_string_descriptor_languages_t;
+
+struct usb_string_descriptor {
+ uint8_t bLength; ///< length of the descriptor in bytes
+ uint8_t bDescriptorType; ///< always USB_DESCRIPTOR_TYPE_STRING
+ char bString[256]; ///< char array containing the string (not null term.)
+}__attribute__((packed));
+
+typedef struct usb_string_descriptor usb_string_descriptor_t;
+
+#define USB_STRING_GET_ELEMENT_COUNT(sd) ((sd->bLength -2 )/2)
+#define USB_STRING_GET_STRLEN(sd) ((sd->bLength -2 ))
+
+/**
+ * ------------------------------------------------------------------------
+ * USB Generic Descriptor
+ * ------------------------------------------------------------------------
+ * This descriptor is used to supply the device driver with all the necessary
+ * information upon initialization and connection to the usb manager.
+ *
+ * A request for a configuration descriptor returns the configuration
+ * descriptor, all interface descriptors, and endpoint descriptors for all of
+ * the interfaces in a single request. The first interface descriptor follows
+ * the configuration descriptor. The endpoint descriptors for the first
+ * interface follow the first interface descriptor. If there are additional
+ * interfaces, their interface descriptor and endpoint descriptors follow the
+ * first interface’s endpoint descriptors.
+ */
+struct usb_generic_descriptor {
+ struct usb_device_descriptor device;
+ struct usb_config_descriptor config;
+ struct usb_interface_descriptor iface[1];
+ struct usb_endpoint_descriptor endpoint[1];
+};
+
+typedef struct usb_generic_descriptor usb_generic_descriptor_t;
+
+#endif
-/**\r
- * \brief this file contains device related definitions for the USB client driver\r
- */\r
-\r
-/*\r
- * Copyright (c) 2007-2013 ETH Zurich.\r
- * All rights reserved.\r
- *\r
- * This file is distributed under the terms in the attached LICENSE file.\r
- * If you do not find this file, copies can be found by writing to:\r
- * ETH Zurich D-INFK, Haldeneggsteig 4, CH-8092 Zurich. Attn: Systems Group.\r
- */\r
-\r
-#ifndef LIBUSB_DEVICE_H\r
-#define LIBUSB_DEVICE_H\r
-\r
-/**\r
- * ------------------------------------------------------------------------\r
- * USB Endpoint\r
- * ------------------------------------------------------------------------\r
- * This data structure defines an USB tendpoint reflecting the state on a\r
- * physical endpoint on the device.\r
- */\r
-struct usb_endpoint\r
-{\r
- uint8_t ep_direction; ///< the direction of this endpoint\r
- uint8_t ep_number; ///< the endpoint number\r
- uint8_t ep_type; ///< the type of this endpoint\r
- uint8_t ep_usage; ///< for isochronus only: usage\r
- uint8_t ep_sync; ///< for isochronus only: sync field\r
- struct usb_interface *iface; ///< the parent interface\r
- uint8_t iface_index; ///< the interface index\r
-};\r
-\r
-/// endpoint status flag for usb_status_t\r
-#define USB_ENDPOINT_STATUS_HALT 0x0001\r
-\r
-/// the USB control endpoint\r
-#define USB_ENDPOINT_CONTROL 0\r
-\r
-/// the maximum number of endpoints\r
-#define USB_ENDPOINT_MAX 32\r
-\r
-/**\r
- * ------------------------------------------------------------------------\r
- * USB Interface\r
- * ------------------------------------------------------------------------\r
- * This data structure defines an USB tendpoint reflecting the state on a\r
- * physical endpoint on the device.\r
- *\r
- * Fields:\r
- * - descriptor pointer to the interface descriptor\r
- * - alt_setting alternative setting for this iface\r
- * - iface_index interface index of this interface\r
- * - device pointer to the device\r
- * - num_endpoints the number of endpoints for this interface\r
- * - endpoints array of pointer to the endpoints of this iface\r
- */\r
-struct usb_interface\r
-{\r
- uint8_t alt_setting; ///< alternative settings\r
- uint8_t parent_iface_index; ///< the parent interface index\r
- uint8_t iface_number; ///< interface number of this interface\r
- uint8_t iface_class; ///< the interface class code\r
- uint8_t iface_subclass; ///< the interface subclass code\r
- uint8_t iface_protocol; ///< the interface protocol\r
- uint8_t num_endpoints; ///< the number of endpoints in this iface\r
- uint8_t config; ///< the configuration value\r
- struct usb_endpoint endpoints[USB_ENDPOINT_MAX];\r
-};\r
-\r
-/// used for lookups\r
-#define USB_INTERFACE_INDEX_ANY 0xFF\r
-\r
-/**\r
- * this struct represents a device for the client drivers\r
- */\r
-struct usb_device {\r
- struct usb_interface *ifaces; ///< the interfaces of the current config\r
- struct usb_endpoint *endpoints; ///< the endpoints of the current config\r
- struct usb_config_descriptor *config_desc; ///< configuration descriptor\r
- uint8_t dev_class; ///< device class code\r
- uint8_t dev_subclass; ///< device sub class code\r
- uint8_t dev_protocol; ///< device protocol\r
- uint16_t vendor; ///< vendor id\r
- uint16_t product; ///< product id\r
- uint16_t version; ///< the device version\r
- uint8_t iface_max; ///< maximum interfaces\r
- uint8_t ep_max; ///< maximum endpoints\r
- uint8_t num_config; ///< the number of configurations\r
- uint8_t current_config; ///< the current active configuration\r
-};\r
-\r
-typedef struct usb_device usb_device_t;\r
-\r
-\r
-/*\r
- * Prototypes\r
- */\r
-void usb_device_init(void *desc);\r
-\r
-uint8_t usb_device_get_num_config(void);\r
-\r
-struct usb_interface *usb_device_get_iface(uint8_t iface);\r
-\r
-usb_error_t usb_device_get_iface_count(uint8_t *ret_count);\r
-\r
-usb_error_t usb_device_get_speed(usb_speed_t *ret_speed);\r
-\r
-usb_error_t usb_device_state(void);\r
-\r
-struct usb_config_descriptor *usb_device_get_cfg_desc(void);\r
-\r
-usb_error_t usb_device_suspend(void);\r
-\r
-usb_error_t usb_device_resume(void);\r
-\r
-usb_error_t usb_device_powersave(void);\r
-\r
-#endif /* USB_DEVICE_H_ */\r
+/**
+ * \brief this file contains device related definitions for the USB client driver
+ */
+
+/*
+ * Copyright (c) 2007-2013 ETH Zurich.
+ * All rights reserved.
+ *
+ * This file is distributed under the terms in the attached LICENSE file.
+ * If you do not find this file, copies can be found by writing to:
+ * ETH Zurich D-INFK, Haldeneggsteig 4, CH-8092 Zurich. Attn: Systems Group.
+ */
+
+#ifndef LIBUSB_DEVICE_H
+#define LIBUSB_DEVICE_H
+
+/**
+ * ------------------------------------------------------------------------
+ * USB Endpoint
+ * ------------------------------------------------------------------------
+ * This data structure defines an USB tendpoint reflecting the state on a
+ * physical endpoint on the device.
+ */
+struct usb_endpoint
+{
+ uint8_t ep_direction; ///< the direction of this endpoint
+ uint8_t ep_number; ///< the endpoint number
+ uint8_t ep_type; ///< the type of this endpoint
+ uint8_t ep_usage; ///< for isochronus only: usage
+ uint8_t ep_sync; ///< for isochronus only: sync field
+ struct usb_interface *iface; ///< the parent interface
+ uint8_t iface_index; ///< the interface index
+};
+
+/// endpoint status flag for usb_status_t
+#define USB_ENDPOINT_STATUS_HALT 0x0001
+
+/// the USB control endpoint
+#define USB_ENDPOINT_CONTROL 0
+
+/// the maximum number of endpoints
+#define USB_ENDPOINT_MAX 32
+
+/**
+ * ------------------------------------------------------------------------
+ * USB Interface
+ * ------------------------------------------------------------------------
+ * This data structure defines an USB tendpoint reflecting the state on a
+ * physical endpoint on the device.
+ *
+ * Fields:
+ * - descriptor pointer to the interface descriptor
+ * - alt_setting alternative setting for this iface
+ * - iface_index interface index of this interface
+ * - device pointer to the device
+ * - num_endpoints the number of endpoints for this interface
+ * - endpoints array of pointer to the endpoints of this iface
+ */
+struct usb_interface
+{
+ uint8_t alt_setting; ///< alternative settings
+ uint8_t parent_iface_index; ///< the parent interface index
+ uint8_t iface_number; ///< interface number of this interface
+ uint8_t iface_class; ///< the interface class code
+ uint8_t iface_subclass; ///< the interface subclass code
+ uint8_t iface_protocol; ///< the interface protocol
+ uint8_t num_endpoints; ///< the number of endpoints in this iface
+ uint8_t config; ///< the configuration value
+ struct usb_endpoint endpoints[USB_ENDPOINT_MAX];
+};
+
+/// used for lookups
+#define USB_INTERFACE_INDEX_ANY 0xFF
+
+/**
+ * this struct represents a device for the client drivers
+ */
+struct usb_device {
+ struct usb_interface *ifaces; ///< the interfaces of the current config
+ struct usb_endpoint *endpoints; ///< the endpoints of the current config
+ struct usb_config_descriptor *config_desc; ///< configuration descriptor
+ uint8_t dev_class; ///< device class code
+ uint8_t dev_subclass; ///< device sub class code
+ uint8_t dev_protocol; ///< device protocol
+ uint16_t vendor; ///< vendor id
+ uint16_t product; ///< product id
+ uint16_t version; ///< the device version
+ uint8_t iface_max; ///< maximum interfaces
+ uint8_t ep_max; ///< maximum endpoints
+ uint8_t num_config; ///< the number of configurations
+ uint8_t current_config; ///< the current active configuration
+};
+
+typedef struct usb_device usb_device_t;
+
+
+/*
+ * Prototypes
+ */
+void usb_device_init(void *desc);
+
+uint8_t usb_device_get_num_config(void);
+
+struct usb_interface *usb_device_get_iface(uint8_t iface);
+
+usb_error_t usb_device_get_iface_count(uint8_t *ret_count);
+
+usb_error_t usb_device_get_speed(usb_speed_t *ret_speed);
+
+usb_error_t usb_device_state(void);
+
+struct usb_config_descriptor *usb_device_get_cfg_desc(void);
+
+usb_error_t usb_device_suspend(void);
+
+usb_error_t usb_device_resume(void);
+
+usb_error_t usb_device_powersave(void);
+
+#endif /* USB_DEVICE_H_ */
-/**\r
- * \brief this file contains the USB error codes\r
- */\r
-/*\r
- * Copyright (c) 2007-2013 ETH Zurich.\r
- * All rights reserved.\r
- *\r
- * This file is distributed under the terms in the attached LICENSE file.\r
- * If you do not find this file, copies can be found by writing to:\r
- * ETH Zurich D-INFK, Haldeneggsteig 4, CH-8092 Zurich. Attn: Systems Group.\r
- */\r
-\r
-#ifndef _USB_ERROR_H_\r
-#define _USB_ERROR_H_\r
-\r
-\r
-typedef enum {\r
- USB_ERR_OK = 0,\r
- USB_ERR_PENDING_REQUESTS, /* 1 */\r
- USB_ERR_NOT_STARTED, /* 2 */\r
- USB_ERR_INVAL, /* 3 */\r
- USB_ERR_NOMEM, /* 4 */\r
- USB_ERR_CANCELLED, /* 5 */\r
- USB_ERR_BAD_ADDRESS, /* 6 */\r
- USB_ERR_BAD_BUFSIZE, /* 7 */\r
- USB_ERR_BAD_FLAG, /* 8 */\r
- USB_ERR_NO_CALLBACK, /* 9 */\r
- USB_ERR_IN_USE, /* 10 */\r
- USB_ERR_NO_ADDR, /* 11 */\r
- USB_ERR_NO_PIPE, /* 12 */\r
- USB_ERR_ZERO_NFRAMES, /* 13 */\r
- USB_ERR_ZERO_MAXP, /* 14 */\r
- USB_ERR_SET_ADDR_FAILED, /* 15 */\r
- USB_ERR_NO_POWER, /* 16 */\r
- USB_ERR_TOO_DEEP, /* 17 */\r
- USB_ERR_IOERROR, /* 18 */\r
- USB_ERR_NOT_CONFIGURED, /* 19 */\r
- USB_ERR_TIMEOUT, /* 20 */\r
- USB_ERR_SHORT_XFER, /* 21 */\r
- USB_ERR_STALLED, /* 22 */\r
- USB_ERR_INTERRUPTED, /* 23 */\r
- USB_ERR_DMA_LOAD_FAILED, /* 24 */\r
- USB_ERR_BAD_CONTEXT, /* 25 */\r
- USB_ERR_NO_ROOT_HUB, /* 26 */\r
- USB_ERR_NO_INTR_THREAD, /* 27 */\r
- USB_ERR_NOT_LOCKED, /* 28 */\r
- USB_ERR_BAD_REQUEST, /* 29 */\r
- USB_ERR_IDC, /* 30 */\r
- USB_ERR_MAX\r
-} usb_error_t;\r
-\r
-\r
-const char* usb_get_error_string(usb_error_t errno);\r
-\r
-#endif\r
+/**
+ * \brief this file contains the USB error codes
+ */
+/*
+ * Copyright (c) 2007-2013 ETH Zurich.
+ * All rights reserved.
+ *
+ * This file is distributed under the terms in the attached LICENSE file.
+ * If you do not find this file, copies can be found by writing to:
+ * ETH Zurich D-INFK, Haldeneggsteig 4, CH-8092 Zurich. Attn: Systems Group.
+ */
+
+#ifndef _USB_ERROR_H_
+#define _USB_ERROR_H_
+
+
+typedef enum {
+ USB_ERR_OK = 0,
+ USB_ERR_PENDING_REQUESTS, /* 1 */
+ USB_ERR_NOT_STARTED, /* 2 */
+ USB_ERR_INVAL, /* 3 */
+ USB_ERR_NOMEM, /* 4 */
+ USB_ERR_CANCELLED, /* 5 */
+ USB_ERR_BAD_ADDRESS, /* 6 */
+ USB_ERR_BAD_BUFSIZE, /* 7 */
+ USB_ERR_BAD_FLAG, /* 8 */
+ USB_ERR_NO_CALLBACK, /* 9 */
+ USB_ERR_IN_USE, /* 10 */
+ USB_ERR_NO_ADDR, /* 11 */
+ USB_ERR_NO_PIPE, /* 12 */
+ USB_ERR_ZERO_NFRAMES, /* 13 */
+ USB_ERR_ZERO_MAXP, /* 14 */
+ USB_ERR_SET_ADDR_FAILED, /* 15 */
+ USB_ERR_NO_POWER, /* 16 */
+ USB_ERR_TOO_DEEP, /* 17 */
+ USB_ERR_IOERROR, /* 18 */
+ USB_ERR_NOT_CONFIGURED, /* 19 */
+ USB_ERR_TIMEOUT, /* 20 */
+ USB_ERR_SHORT_XFER, /* 21 */
+ USB_ERR_STALLED, /* 22 */
+ USB_ERR_INTERRUPTED, /* 23 */
+ USB_ERR_DMA_LOAD_FAILED, /* 24 */
+ USB_ERR_BAD_CONTEXT, /* 25 */
+ USB_ERR_NO_ROOT_HUB, /* 26 */
+ USB_ERR_NO_INTR_THREAD, /* 27 */
+ USB_ERR_NOT_LOCKED, /* 28 */
+ USB_ERR_BAD_REQUEST, /* 29 */
+ USB_ERR_IDC, /* 30 */
+ USB_ERR_MAX
+} usb_error_t;
+
+
+const char* usb_get_error_string(usb_error_t errno);
+
+#endif
-/*\r
- * Copyright (c) 2007-2013 ETH Zurich.\r
- * All rights reserved.\r
- *\r
- * This file is distributed under the terms in the attached LICENSE file.\r
- * If you do not find this file, copies can be found by writing to:\r
- * ETH Zurich D-INFK, Haldeneggsteig 4, CH-8092 Zurich. Attn: Systems Group.\r
- */\r
-\r
-\r
-/**\r
- * =======================================================================\r
- * This file contains data structures and methods for issuing USB device\r
- * requests on a specific device.\r
- * =======================================================================\r
- */\r
-\r
-#ifndef _LIB_USB_REQUEST_H\r
-#define _LIB_USB_REQUEST_H\r
-\r
-#include <barrelfish/barrelfish.h>\r
-\r
-#include <usb/usb.h>\r
-#include <usb/usb_descriptor.h>\r
-#include <usb/usb_error.h>\r
-\r
-\r
-struct usb_request_type {\r
- uint8_t recipient : 5; // device, interface, endpoint...\r
- uint8_t type : 2; // standard, class, vendor\r
- uint8_t direction : 1; // host2device or device2host\r
-};\r
-typedef struct usb_request_type usb_request_type_t;\r
-\r
-/**\r
- * ------------------------------------------------------------------------\r
- * USB Device Request (USB Specification, Rev 2.0, Section 9.4)\r
- * ------------------------------------------------------------------------\r
- * This datastructures defines a 8 byte setup packet used to send a request\r
- * over the device's default control pipe\r
- */\r
-struct usb_device_request {\r
- usb_request_type_t bType; ///< recipient\r
- uint8_t bRequest; ///< request identifier\r
- uint16_t wValue; ///< parameter depending on the request\r
- uint16_t wIndex; ///< interface / endpoint index\r
- uint16_t wLength; ///< number of bytes in the data stage\r
-}__packed;\r
-\r
-typedef struct usb_device_request usb_device_request_t;\r
-\r
-// values for the request recipents\r
-#define USB_REQUEST_RECIPIENT_MASK 0x1F\r
-#define USB_REQUEST_RECIPIENT_DEVICE 0\r
-#define USB_REQUEST_RECIPIENT_INTERFACE 1\r
-#define USB_REQUEST_RECIPIENT_ENDPOINT 2\r
-#define USB_REQUEST_RECIPIENT_OTHER 3\r
-\r
-// the direction of the request: host to device or device to host\r
-#define USB_REQUEST_WRITE 0\r
-#define USB_REQUEST_READ 1\r
-\r
-// type of the request.\r
-#define USB_REQUEST_TYPE_STANDARD 0\r
-#define USB_REQUEST_TYPE_CLASS 1\r
-#define USB_REQUEST_TYPE_VENDOR 2\r
-#define USB_REQUEST_TYPE_RESERVED 3\r
-\r
-// masks for the index field depending on the recipent (interface or endpoint)\r
-#define USB_REQUEST_INDEX_IF_NUM 0x00FF\r
-#define USB_REQUEST_INDEX_EP_NUM 0x000F\r
-#define USB_REQUEST_INDEX_DIRECTION 0x0080\r
-\r
-#define USB_REQUEST_GET_EP(req) \\r
- (req->wIndex & USB_REQUEST_INDEX_EP_NUM)\r
-#define USB_REQUEST_GET_IF(req) \\r
- (req->wIndex & USB_REQUEST_INDEX_IF_NUM)\r
-#define USB_REQUEST_GET_DIR(req) \\r
- ((req->wIndex & USB_REQUEST_INDEX_DIRECTION) >> 8)\r
-\r
-//USB Device Request Codes (USB Specification, Rev 2.0, Table 9.4)\r
-#define USB_REQUEST_GET_STATUS 0\r
-#define USB_REQUEST_CLEAR_FEATURE 1\r
-#define USB_REQUEST_SET_FEATURE 3\r
-#define USB_REQUEST_SET_ADDRESS 5\r
-#define USB_REQUEST_GET_DESCRIPTOR 6\r
-#define USB_REQUEST_SET_DESCRIPTOR 7\r
-#define USB_REQUEST_GET_CONFIG 8\r
-#define USB_REQUEST_SET_CONFIG 9\r
-#define USB_REQUEST_GET_INTERFACE 10\r
-#define USB_REQUEST_SET_INTERFACE 11\r
-#define USB_REQUEST_SYNCH_FRAME 12\r
-\r
-// feature selectors (used with SET_FEATURE requests)\r
-#define USB_REQUEST_FEATURE_REMOTE_WAKEUP 1\r
-#define USB_REQUEST_FEATURE_ENDPOINT_HALT 0\r
-#define USB_REQUEST_FEATURE_TEST_MODE 2\r
-\r
-// status request reply\r
-#define USB_REQUEST_STATUS_SELF_POWERED 0x0001\r
-#define USB_REQUEST_STATUS_REMOTE_WAKEUP 0x0002\r
-#define USB_REQUEST_STATUS_EP_HALT 0x0001\r
-#define USB_DEVICE_IS_SELFPOWERED(status) \\r
- (status & USB_REQUEST_STATUS_SELF_POWERED)\r
-#define USB_DEVICE_CAN_REMOTE_WAKEUP(status) \\r
- (status & USB_REQUEST_STATUS_REMOTE_WAKEUP)\r
-#define USB_EP_STATUS_HALTED(status) \\r
- (status & USB_REQUEST_STATUS_EP_HALT)\r
-\r
-/* FLAGS */\r
-#define USB_REQUEST_FLAG_IGNORE_SHORT_XFER 0x01\r
-#define USB_REQUEST_FLAG_DELAY_STATUS 0x02\r
-#define USB_REQUEST_FLAG_USER_DATA 0x04\r
-\r
-/*\r
- * =======================================================================\r
- * Standard Device Requests (USB Reference Section 9.4)\r
- * =======================================================================\r
- */\r
-\r
-usb_error_t usb_clear_feature(uint8_t recipient, uint8_t recipient_index,\r
- uint16_t feature);\r
-\r
-usb_error_t usb_get_configuration(uint8_t *ret_config);\r
-\r
-usb_error_t usb_get_descriptor(uint8_t desc_type, uint8_t desc_index,\r
- uint16_t lang, void **ret_desc, uint16_t *ret_length);\r
-\r
-usb_error_t usb_get_device_descriptor(struct usb_device_descriptor *ret_desc);\r
-\r
-usb_error_t usb_get_config_descriptor(uint8_t config_index,\r
- struct usb_config_descriptor *ret_desc);\r
-\r
-usb_error_t usb_get_iface_descriptor(uint8_t iface_index,\r
- struct usb_config_descriptor *ret_desc);\r
-\r
-usb_error_t usb_get_ep_descriptor(uint8_t ep_index,\r
- struct usb_endpoint_descriptor *ret_desc);\r
-\r
-usb_error_t usb_get_string_descriptor(uint16_t lang_id, uint8_t string_index,\r
- void *ret_desc);\r
-\r
-usb_error_t usb_get_alt_iface(uint16_t iface_number, uint8_t *ret_alt_iface);\r
-\r
-usb_error_t usb_get_status(uint8_t recipient, uint16_t recipient_index,\r
- struct usb_status *ret_status);\r
-\r
-usb_error_t usb_set_address(uint8_t device_address);\r
-\r
-usb_error_t usb_set_configuration(uint8_t config_value);\r
-\r
-usb_error_t usb_set_descriptor(uint8_t desc_type, uint8_t desc_index,\r
- uint8_t language, struct usb_descriptor *descriptor);\r
-\r
-usb_error_t usb_set_feature(uint8_t recipient, uint16_t feature, uint8_t test,\r
- uint8_t index);\r
-\r
-usb_error_t usb_set_alt_iface(uint16_t alt_setting, uint16_t interface);\r
-\r
-usb_error_t usb_synch_frame(uint8_t endpoint, uint16_t *ret_frame);\r
-\r
-\r
-/* wrappers for executing the request */\r
-usb_error_t usb_do_request(struct usb_device_request *req);\r
-\r
-usb_error_t usb_do_request_write(struct usb_device_request *req,\r
- uint16_t length, void *data);\r
-\r
-usb_error_t usb_do_request_read(struct usb_device_request *req,\r
- uint16_t *ret_length, void **ret_data);\r
-\r
-\r
-#endif\r
+/*
+ * Copyright (c) 2007-2013 ETH Zurich.
+ * All rights reserved.
+ *
+ * This file is distributed under the terms in the attached LICENSE file.
+ * If you do not find this file, copies can be found by writing to:
+ * ETH Zurich D-INFK, Haldeneggsteig 4, CH-8092 Zurich. Attn: Systems Group.
+ */
+
+
+/**
+ * =======================================================================
+ * This file contains data structures and methods for issuing USB device
+ * requests on a specific device.
+ * =======================================================================
+ */
+
+#ifndef _LIB_USB_REQUEST_H
+#define _LIB_USB_REQUEST_H
+
+#include <barrelfish/barrelfish.h>
+
+#include <usb/usb.h>
+#include <usb/usb_descriptor.h>
+#include <usb/usb_error.h>
+
+
+struct usb_request_type {
+ uint8_t recipient : 5; // device, interface, endpoint...
+ uint8_t type : 2; // standard, class, vendor
+ uint8_t direction : 1; // host2device or device2host
+};
+typedef struct usb_request_type usb_request_type_t;
+
+/**
+ * ------------------------------------------------------------------------
+ * USB Device Request (USB Specification, Rev 2.0, Section 9.4)
+ * ------------------------------------------------------------------------
+ * This datastructures defines a 8 byte setup packet used to send a request
+ * over the device's default control pipe
+ */
+struct usb_device_request {
+ usb_request_type_t bType; ///< recipient
+ uint8_t bRequest; ///< request identifier
+ uint16_t wValue; ///< parameter depending on the request
+ uint16_t wIndex; ///< interface / endpoint index
+ uint16_t wLength; ///< number of bytes in the data stage
+}__packed;
+
+typedef struct usb_device_request usb_device_request_t;
+
+// values for the request recipents
+#define USB_REQUEST_RECIPIENT_MASK 0x1F
+#define USB_REQUEST_RECIPIENT_DEVICE 0
+#define USB_REQUEST_RECIPIENT_INTERFACE 1
+#define USB_REQUEST_RECIPIENT_ENDPOINT 2
+#define USB_REQUEST_RECIPIENT_OTHER 3
+
+// the direction of the request: host to device or device to host
+#define USB_REQUEST_WRITE 0
+#define USB_REQUEST_READ 1
+
+// type of the request.
+#define USB_REQUEST_TYPE_STANDARD 0
+#define USB_REQUEST_TYPE_CLASS 1
+#define USB_REQUEST_TYPE_VENDOR 2
+#define USB_REQUEST_TYPE_RESERVED 3
+
+// masks for the index field depending on the recipent (interface or endpoint)
+#define USB_REQUEST_INDEX_IF_NUM 0x00FF
+#define USB_REQUEST_INDEX_EP_NUM 0x000F
+#define USB_REQUEST_INDEX_DIRECTION 0x0080
+
+#define USB_REQUEST_GET_EP(req) \
+ (req->wIndex & USB_REQUEST_INDEX_EP_NUM)
+#define USB_REQUEST_GET_IF(req) \
+ (req->wIndex & USB_REQUEST_INDEX_IF_NUM)
+#define USB_REQUEST_GET_DIR(req) \
+ ((req->wIndex & USB_REQUEST_INDEX_DIRECTION) >> 8)
+
+//USB Device Request Codes (USB Specification, Rev 2.0, Table 9.4)
+#define USB_REQUEST_GET_STATUS 0
+#define USB_REQUEST_CLEAR_FEATURE 1
+#define USB_REQUEST_SET_FEATURE 3
+#define USB_REQUEST_SET_ADDRESS 5
+#define USB_REQUEST_GET_DESCRIPTOR 6
+#define USB_REQUEST_SET_DESCRIPTOR 7
+#define USB_REQUEST_GET_CONFIG 8
+#define USB_REQUEST_SET_CONFIG 9
+#define USB_REQUEST_GET_INTERFACE 10
+#define USB_REQUEST_SET_INTERFACE 11
+#define USB_REQUEST_SYNCH_FRAME 12
+
+// feature selectors (used with SET_FEATURE requests)
+#define USB_REQUEST_FEATURE_REMOTE_WAKEUP 1
+#define USB_REQUEST_FEATURE_ENDPOINT_HALT 0
+#define USB_REQUEST_FEATURE_TEST_MODE 2
+
+// status request reply
+#define USB_REQUEST_STATUS_SELF_POWERED 0x0001
+#define USB_REQUEST_STATUS_REMOTE_WAKEUP 0x0002
+#define USB_REQUEST_STATUS_EP_HALT 0x0001
+#define USB_DEVICE_IS_SELFPOWERED(status) \
+ (status & USB_REQUEST_STATUS_SELF_POWERED)
+#define USB_DEVICE_CAN_REMOTE_WAKEUP(status) \
+ (status & USB_REQUEST_STATUS_REMOTE_WAKEUP)
+#define USB_EP_STATUS_HALTED(status) \
+ (status & USB_REQUEST_STATUS_EP_HALT)
+
+/* FLAGS */
+#define USB_REQUEST_FLAG_IGNORE_SHORT_XFER 0x01
+#define USB_REQUEST_FLAG_DELAY_STATUS 0x02
+#define USB_REQUEST_FLAG_USER_DATA 0x04
+
+/*
+ * =======================================================================
+ * Standard Device Requests (USB Reference Section 9.4)
+ * =======================================================================
+ */
+
+usb_error_t usb_clear_feature(uint8_t recipient, uint8_t recipient_index,
+ uint16_t feature);
+
+usb_error_t usb_get_configuration(uint8_t *ret_config);
+
+usb_error_t usb_get_descriptor(uint8_t desc_type, uint8_t desc_index,
+ uint16_t lang, void **ret_desc, uint16_t *ret_length);
+
+usb_error_t usb_get_device_descriptor(struct usb_device_descriptor *ret_desc);
+
+usb_error_t usb_get_config_descriptor(uint8_t config_index,
+ struct usb_config_descriptor *ret_desc);
+
+usb_error_t usb_get_iface_descriptor(uint8_t iface_index,
+ struct usb_config_descriptor *ret_desc);
+
+usb_error_t usb_get_ep_descriptor(uint8_t ep_index,
+ struct usb_endpoint_descriptor *ret_desc);
+
+usb_error_t usb_get_string_descriptor(uint16_t lang_id, uint8_t string_index,
+ void *ret_desc);
+
+usb_error_t usb_get_alt_iface(uint16_t iface_number, uint8_t *ret_alt_iface);
+
+usb_error_t usb_get_status(uint8_t recipient, uint16_t recipient_index,
+ struct usb_status *ret_status);
+
+usb_error_t usb_set_address(uint8_t device_address);
+
+usb_error_t usb_set_configuration(uint8_t config_value);
+
+usb_error_t usb_set_descriptor(uint8_t desc_type, uint8_t desc_index,
+ uint8_t language, struct usb_descriptor *descriptor);
+
+usb_error_t usb_set_feature(uint8_t recipient, uint16_t feature, uint8_t test,
+ uint8_t index);
+
+usb_error_t usb_set_alt_iface(uint16_t alt_setting, uint16_t interface);
+
+usb_error_t usb_synch_frame(uint8_t endpoint, uint16_t *ret_frame);
+
+
+/* wrappers for executing the request */
+usb_error_t usb_do_request(struct usb_device_request *req);
+
+usb_error_t usb_do_request_write(struct usb_device_request *req,
+ uint16_t length, void *data);
+
+usb_error_t usb_do_request_read(struct usb_device_request *req,
+ uint16_t *ret_length, void **ret_data);
+
+
+#endif
-/*\r
- * Copyright (c) 2007-2013 ETH Zurich.\r
- * All rights reserved.\r
- *\r
- * This file is distributed under the terms in the attached LICENSE file.\r
- * If you do not find this file, copies can be found by writing to:\r
- * ETH Zurich D-INFK, Haldeneggsteig 4, CH-8092 Zurich. Attn: Systems Group.\r
- */\r
-\r
-#ifndef _LIBUSB_TRANSFER_H_\r
-#define _LIBUSB_TRANSFER_H_\r
-\r
-#include <usb/usb_xfer.h>\r
-\r
-/// USB transfer id type\r
-typedef uint32_t usb_xfer_id_t;\r
-\r
-/// callback function for completed transfers\r
-typedef void (usb_transfer_cb_t)(usb_error_t err, const void *data,\r
- uint32_t data_length);\r
-\r
-// the USB control endpoint\r
-#define USB_ENDPOINT_CONTROL 0\r
-\r
-/**\r
- * this enumeration stores the different states of an USB transfer\r
- */\r
-enum usb_transfer_state {\r
- USB_TRANSFER_STATE_SETUP, ///< transfer is setup\r
- USB_TRANSFER_STATE_STALLED, ///< transfer is in stalled state\r
- USB_TRANSFER_STATE_DONE, ///< transfer is executed successfully\r
- USB_TRANSFER_STATE_ERROR, ///< transfer is in error state\r
-};\r
-\r
-/// USB transfer state type\r
-typedef enum usb_transfer_state usb_tstate_t;\r
-\r
-/**\r
- * this data structure contains the necessary data for setting up\r
- * a new USB transfer\r
- */\r
-struct usb_transfer_setup {\r
- uint32_t max_bytes; ///< maximum bytes to to transfer\r
- uint32_t max_frames; ///< the maximum bumber of frames\r
- uint32_t interval; ///< the interval for interrupt / isochr\r
- uint32_t timeout; ///< period till the transfer timeouts\r
- struct usb_xfer_flags flags; ///< some specific transfer flags\r
- uint8_t type; ///< the type of the usb pipe\r
- uint8_t direction; ///< the direction of the data transfer\r
- uint8_t endpoint; ///< the associated endpoint of the transfer\r
- uint8_t interface; ///< the itnerface to use\r
- usb_transfer_cb_t *callback; ///< the function to call upon completition\r
-};\r
-\r
-/// USB transfer setup type\r
-typedef struct usb_transfer_setup usb_transfer_setup_t;\r
-\r
-/* setting up / freeing up transfers */\r
-usb_error_t usb_transfer_setup_control(usb_transfer_setup_t *setup,\r
- usb_transfer_cb_t *done_cb, usb_xfer_id_t *ret_id);\r
-\r
-usb_error_t usb_transfer_setup_isoc(usb_transfer_setup_t *setup,\r
- usb_transfer_cb_t *done_cb, usb_xfer_id_t *ret_id);\r
-\r
-usb_error_t usb_transfer_setup_bulk(usb_transfer_setup_t *setup,\r
- usb_transfer_cb_t *done_cb, usb_xfer_id_t *ret_id);\r
-\r
-usb_error_t usb_transfer_setup_intr(usb_transfer_setup_t *setup,\r
- usb_transfer_cb_t *done_cb, usb_xfer_id_t *ret_id);\r
-\r
-usb_error_t usb_transfer_unsetup(usb_xfer_id_t tid);\r
-\r
-/* transfer control */\r
-usb_error_t usb_transfer_start(usb_xfer_id_t tid);\r
-\r
-usb_error_t usb_transfer_stop(usb_xfer_id_t tid);\r
-\r
-/* stall handling */\r
-usb_error_t usb_transfer_clear_stall(usb_xfer_id_t tid);\r
-\r
-/* state */\r
-usb_error_t usb_transfer_get_state(usb_xfer_id_t tid, usb_tstate_t *ret_state);\r
-\r
-usb_error_t usb_transfer_get_status(usb_xfer_id_t tid, uint32_t *ret_actlen,\r
- uint32_t *ret_length, uint32_t *ret_actframes, uint32_t *ret_numframes);\r
-\r
-#endif\r
+/*
+ * Copyright (c) 2007-2013 ETH Zurich.
+ * All rights reserved.
+ *
+ * This file is distributed under the terms in the attached LICENSE file.
+ * If you do not find this file, copies can be found by writing to:
+ * ETH Zurich D-INFK, Haldeneggsteig 4, CH-8092 Zurich. Attn: Systems Group.
+ */
+
+#ifndef _LIBUSB_TRANSFER_H_
+#define _LIBUSB_TRANSFER_H_
+
+#include <usb/usb_xfer.h>
+
+/// USB transfer id type
+typedef uint32_t usb_xfer_id_t;
+
+/// callback function for completed transfers
+typedef void (usb_transfer_cb_t)(usb_error_t err, const void *data,
+ uint32_t data_length);
+
+// the USB control endpoint
+#define USB_ENDPOINT_CONTROL 0
+
+/**
+ * this enumeration stores the different states of an USB transfer
+ */
+enum usb_transfer_state {
+ USB_TRANSFER_STATE_SETUP, ///< transfer is setup
+ USB_TRANSFER_STATE_STALLED, ///< transfer is in stalled state
+ USB_TRANSFER_STATE_DONE, ///< transfer is executed successfully
+ USB_TRANSFER_STATE_ERROR, ///< transfer is in error state
+};
+
+/// USB transfer state type
+typedef enum usb_transfer_state usb_tstate_t;
+
+/**
+ * this data structure contains the necessary data for setting up
+ * a new USB transfer
+ */
+struct usb_transfer_setup {
+ uint32_t max_bytes; ///< maximum bytes to to transfer
+ uint32_t max_frames; ///< the maximum bumber of frames
+ uint32_t interval; ///< the interval for interrupt / isochr
+ uint32_t timeout; ///< period till the transfer timeouts
+ struct usb_xfer_flags flags; ///< some specific transfer flags
+ uint8_t type; ///< the type of the usb pipe
+ uint8_t direction; ///< the direction of the data transfer
+ uint8_t endpoint; ///< the associated endpoint of the transfer
+ uint8_t interface; ///< the itnerface to use
+ usb_transfer_cb_t *callback; ///< the function to call upon completition
+};
+
+/// USB transfer setup type
+typedef struct usb_transfer_setup usb_transfer_setup_t;
+
+/* setting up / freeing up transfers */
+usb_error_t usb_transfer_setup_control(usb_transfer_setup_t *setup,
+ usb_transfer_cb_t *done_cb, usb_xfer_id_t *ret_id);
+
+usb_error_t usb_transfer_setup_isoc(usb_transfer_setup_t *setup,
+ usb_transfer_cb_t *done_cb, usb_xfer_id_t *ret_id);
+
+usb_error_t usb_transfer_setup_bulk(usb_transfer_setup_t *setup,
+ usb_transfer_cb_t *done_cb, usb_xfer_id_t *ret_id);
+
+usb_error_t usb_transfer_setup_intr(usb_transfer_setup_t *setup,
+ usb_transfer_cb_t *done_cb, usb_xfer_id_t *ret_id);
+
+usb_error_t usb_transfer_unsetup(usb_xfer_id_t tid);
+
+/* transfer control */
+usb_error_t usb_transfer_start(usb_xfer_id_t tid);
+
+usb_error_t usb_transfer_stop(usb_xfer_id_t tid);
+
+/* stall handling */
+usb_error_t usb_transfer_clear_stall(usb_xfer_id_t tid);
+
+/* state */
+usb_error_t usb_transfer_get_state(usb_xfer_id_t tid, usb_tstate_t *ret_state);
+
+usb_error_t usb_transfer_get_status(usb_xfer_id_t tid, uint32_t *ret_actlen,
+ uint32_t *ret_length, uint32_t *ret_actframes, uint32_t *ret_numframes);
+
+#endif
-/*\r
- * Copyright (c) 2010, ETH Zurich.\r
- * All rights reserved.\r
- *\r
- * This file is distributed under the terms in the attached LICENSE file.\r
- * If you do not find this file, copies can be found by writing to:\r
- * ETH Zurich D-INFK, Haldeneggsteig 4, CH-8092 Zurich. Attn: Systems Group.\r
- */\r
-\r
-#include <string.h>\r
-#include <stdint.h>\r
-\r
-#define LOWBITS (sizeof(uintptr_t)-1)\r
-\r
-void *memmove(void *s1, const void *s2, size_t n)\r
-{\r
- uintptr_t from = (uintptr_t)s2;\r
- uintptr_t to = (uintptr_t)s1;\r
-\r
- if (to <= from) {\r
- // Work forwards\r
-\r
- if (((from ^ to) & LOWBITS) == 0) {\r
- // They have the same alignment\r
- \r
- // Copy bytes until aligned to a word boundary\r
- while (n != 0 && ((from & LOWBITS) != 0)) {\r
- *(char *)to = *(const char *)from;\r
- from++;\r
- to++;\r
- n--;\r
- }\r
-\r
- // Copy words\r
- while(n >= sizeof(uintptr_t)) {\r
- *(uintptr_t *)to = *(const uintptr_t *)from;\r
- from += sizeof(uintptr_t);\r
- to += sizeof(uintptr_t);\r
- n -= sizeof(uintptr_t);\r
- }\r
- }\r
-\r
- // Copy (remaining) bytes\r
- while (n != 0) {\r
- *(char *)to = *(const char *)from;\r
- from++;\r
- to++;\r
- n--;\r
- }\r
- }\r
- else {\r
- // Work backwards\r
- from += n;\r
- to += n;\r
-\r
- if (((from ^ to) & LOWBITS) == 0) {\r
- // They have the same alignment\r
-\r
- // Copy bytes until aligned to a word boundary\r
- while (n != 0 && ((from & LOWBITS) != 0)) {\r
- from--;\r
- to--;\r
- *(char *)to = *(const char *)from;\r
- n--;\r
- }\r
-\r
- // Copy words\r
- while(n >= sizeof(uintptr_t)) {\r
- from -= sizeof(uintptr_t);\r
- to -= sizeof(uintptr_t);\r
- *(uintptr_t *)to = *(const uintptr_t *)from;\r
- n -= sizeof(uintptr_t);\r
- }\r
- }\r
-\r
- // Copy (remaining) bytes\r
- while (n != 0) {\r
- from--;\r
- to--;\r
- *(char *)to = *(const char *)from;\r
- n--;\r
- }\r
- }\r
- return s1;\r
-}\r
+/*
+ * Copyright (c) 2010, ETH Zurich.
+ * All rights reserved.
+ *
+ * This file is distributed under the terms in the attached LICENSE file.
+ * If you do not find this file, copies can be found by writing to:
+ * ETH Zurich D-INFK, Haldeneggsteig 4, CH-8092 Zurich. Attn: Systems Group.
+ */
+
+#include <string.h>
+#include <stdint.h>
+
+#define LOWBITS (sizeof(uintptr_t)-1)
+
+void *memmove(void *s1, const void *s2, size_t n)
+{
+ uintptr_t from = (uintptr_t)s2;
+ uintptr_t to = (uintptr_t)s1;
+
+ if (to <= from) {
+ // Work forwards
+
+ if (((from ^ to) & LOWBITS) == 0) {
+ // They have the same alignment
+
+ // Copy bytes until aligned to a word boundary
+ while (n != 0 && ((from & LOWBITS) != 0)) {
+ *(char *)to = *(const char *)from;
+ from++;
+ to++;
+ n--;
+ }
+
+ // Copy words
+ while(n >= sizeof(uintptr_t)) {
+ *(uintptr_t *)to = *(const uintptr_t *)from;
+ from += sizeof(uintptr_t);
+ to += sizeof(uintptr_t);
+ n -= sizeof(uintptr_t);
+ }
+ }
+
+ // Copy (remaining) bytes
+ while (n != 0) {
+ *(char *)to = *(const char *)from;
+ from++;
+ to++;
+ n--;
+ }
+ }
+ else {
+ // Work backwards
+ from += n;
+ to += n;
+
+ if (((from ^ to) & LOWBITS) == 0) {
+ // They have the same alignment
+
+ // Copy bytes until aligned to a word boundary
+ while (n != 0 && ((from & LOWBITS) != 0)) {
+ from--;
+ to--;
+ *(char *)to = *(const char *)from;
+ n--;
+ }
+
+ // Copy words
+ while(n >= sizeof(uintptr_t)) {
+ from -= sizeof(uintptr_t);
+ to -= sizeof(uintptr_t);
+ *(uintptr_t *)to = *(const uintptr_t *)from;
+ n -= sizeof(uintptr_t);
+ }
+ }
+
+ // Copy (remaining) bytes
+ while (n != 0) {
+ from--;
+ to--;
+ *(char *)to = *(const char *)from;
+ n--;
+ }
+ }
+ return s1;
+}
-/**\r
- * \file\r
- * \brief Barrelfish collections library hash table\r
- */\r
-/*\r
- * Copyright (c) 2010, ETH Zurich.\r
- * All rights reserved.\r
- *\r
- * This file is distributed under the terms in the attached LICENSE file.\r
- * If you do not find this file, copies can be found by writing to:\r
- * ETH Zurich D-INFK, Haldeneggsteig 4, CH-8092 Zurich. Attn: Systems Group.\r
- */\r
-\r
-#include "collections/hash_table.h"\r
-#include "inttypes.h"\r
-\r
-/******************************************************\r
- * a simple hash table implementation\r
- ******************************************************/\r
-\r
-/*\r
- * Function to identify the right element from the\r
- * linked list.\r
- */\r
-static int32_t match_key(void *data, void *arg)\r
-{\r
- collections_hash_elem *elem = (collections_hash_elem *) data;\r
- uint64_t key = *((uint64_t *)arg);\r
-\r
- return (elem->key == key);\r
-}\r
-\r
-/*\r
- * Create a hash table.\r
- */\r
-static void collections_hash_create_core(collections_hash_table **t, int num_buckets, collections_hash_data_free data_free)\r
-{\r
- int i;\r
-\r
- *t = (collections_hash_table *) malloc (sizeof(collections_hash_table));\r
- memset(*t, 0, sizeof(collections_hash_table));\r
-\r
- (*t)->num_buckets = num_buckets;\r
-\r
- // create a linked list node for each bucket\r
- (*t)->buckets = (collections_listnode **) malloc(sizeof(collections_listnode *) * num_buckets);\r
- for (i = 0; i < num_buckets; i ++) {\r
- collections_list_create(&(*t)->buckets[i], NULL);\r
- }\r
-\r
- (*t)->num_elems = 0;\r
- (*t)->data_free = data_free;\r
-\r
- // to keep track of traversing the hash table\r
- (*t)->cur_bucket_num = -1;\r
- return;\r
-}\r
-\r
-void collections_hash_create(collections_hash_table **t, collections_hash_data_free elem_free)\r
-{\r
- collections_hash_create_core(t, NUM_BUCKETS, elem_free);\r
-}\r
-\r
-void collections_hash_create_with_buckets(collections_hash_table **t, int num_buckets, collections_hash_data_free elem_free)\r
-{\r
- collections_hash_create_core(t, num_buckets, elem_free);\r
-}\r
-\r
-static int collections_hash_release_elem(void* elem, void * arg)\r
-{\r
- collections_hash_table *t = (collections_hash_table *)arg;\r
- collections_hash_elem *he = (collections_hash_elem *)elem;\r
- if (t->data_free)\r
- {\r
- t->data_free(he->data);\r
- }\r
- free(he);\r
-\r
- t->num_elems--;\r
-\r
- return 1;\r
-}\r
-\r
-// delete the entire hash table\r
-void collections_hash_release(collections_hash_table *t)\r
-{\r
- int bucket_num;\r
- int bucket_size;\r
- collections_listnode *bucket;\r
-\r
- for (bucket_num = 0; bucket_num < t->num_buckets; bucket_num ++) {\r
- uint32_t before, after;\r
- bucket = t->buckets[bucket_num];\r
- bucket_size = collections_list_size(bucket);\r
- \r
- before = t->num_elems;\r
- collections_list_visit(bucket, collections_hash_release_elem, t);\r
- after = t->num_elems;\r
- assert(before - after == bucket_size);\r
-\r
- collections_list_release(bucket);\r
- }\r
- assert(t->num_elems == 0);\r
-\r
- free(t->buckets);\r
- free(t);\r
-}\r
-\r
-static collections_hash_elem* collections_hash_find_elem(collections_hash_table *t, uint64_t key)\r
-{\r
- uint32_t bucket_num; \r
- collections_listnode *bucket; \r
- collections_hash_elem *elem;\r
-\r
- bucket_num = key % t->num_buckets;\r
- bucket = t->buckets[bucket_num];\r
- elem = (collections_hash_elem*) collections_list_find_if(bucket, match_key, &key);\r
- return elem;\r
-}\r
-\r
-/*\r
- * Inserts an element into the hash table.\r
- */\r
-void collections_hash_insert(collections_hash_table *t, uint64_t key, void *data)\r
-{\r
- uint32_t bucket_num;\r
- collections_listnode *bucket;\r
- collections_hash_elem *elem;\r
-\r
- elem = collections_hash_find_elem(t, key);\r
- if (elem != NULL) {\r
- printf("Error: key %" PRIu64 " already present in hash table %" PRIu64 "\n",\r
- key, elem->key);\r
- assert(0);\r
- return;\r
- }\r
-\r
- bucket_num = key % t->num_buckets;\r
- bucket = t->buckets[bucket_num];\r
- elem = (collections_hash_elem *) malloc(sizeof(collections_hash_elem));\r
- elem->key = key;\r
- elem->data = data;\r
- collections_list_insert(bucket, (void *)elem);\r
- t->num_elems ++;\r
-}\r
-\r
-/*\r
- * Retrieves an element from the hash table.\r
- */\r
-void *collections_hash_find(collections_hash_table *t, uint64_t key)\r
-{\r
- collections_hash_elem *he = collections_hash_find_elem(t, key);\r
- return (he) ? he->data : NULL;\r
-}\r
-\r
-/*\r
- * Removes a specific element from the table.\r
- */\r
-void collections_hash_delete(collections_hash_table *t, uint64_t key)\r
-{ \r
- uint32_t bucket_num; \r
- collections_listnode *bucket; \r
- collections_hash_elem *elem;\r
-\r
- bucket_num = key % t->num_buckets;\r
- bucket = t->buckets[bucket_num];\r
- elem = (collections_hash_elem*) collections_list_remove_if(bucket, match_key, &key);\r
- if (elem) {\r
- uint32_t n = t->num_elems;\r
- collections_hash_release_elem(elem, t);\r
- assert(1 == n - t->num_elems);\r
- }\r
- else\r
- {\r
- printf("Error: cannot find the node with key %" PRIu64 " in collections_hash_release\n", key);\r
- }\r
-}\r
-\r
-/*\r
- * Returns the number of elements in the hash table.\r
- */\r
-uint32_t collections_hash_size(collections_hash_table *t)\r
-{\r
- return (t->num_elems);\r
-}\r
-\r
-static collections_listnode* collections_hash_get_next_valid_bucket(collections_hash_table* t)\r
-{\r
- collections_listnode* bucket;\r
-\r
- do {\r
- t->cur_bucket_num ++;\r
- if (t->cur_bucket_num < t->num_buckets) {\r
- if (!t->buckets[t->cur_bucket_num]) {\r
- continue;\r
- }\r
- } else {\r
- return NULL;\r
- }\r
- } while (collections_list_size(t->buckets[t->cur_bucket_num]) <= 0);\r
-\r
- bucket = t->buckets[t->cur_bucket_num];\r
- collections_list_traverse_start(bucket);\r
-\r
- return bucket;\r
-}\r
-\r
-int32_t collections_hash_traverse_start(collections_hash_table *t)\r
-{\r
- if (t->cur_bucket_num != -1) {\r
- // if the cur_bucket_num is valid, a\r
- // traversal is already in progress.\r
- printf("Error: collections_hash_table is already opened for traversal.\n");\r
- return -1;\r
- }\r
-\r
- collections_hash_get_next_valid_bucket(t);\r
-\r
- return 1;\r
-}\r
-\r
-/*\r
- * Returns the next element in the hash table. If\r
- * a valid element is found, the key is set to the\r
- * key of the element. If there is no valid element,\r
- * returns null and key is not modified.\r
- */\r
-void* collections_hash_traverse_next(collections_hash_table* t, uint64_t *key)\r
-{\r
- if (t->cur_bucket_num == -1) {\r
- // if the cur_bucket_num is invalid, \r
- // hash traversal has not been started.\r
- printf("Error: collections_hash_table must be opened for traversal first.\n");\r
- return NULL;\r
- }\r
- \r
- if (t->cur_bucket_num >= t->num_buckets) {\r
- // all the buckets have been traversed.\r
- return NULL;\r
- } else {\r
- collections_listnode* bucket;\r
- collections_hash_elem* ret;\r
-\r
- if (t->buckets[t->cur_bucket_num]) {\r
- bucket = t->buckets[t->cur_bucket_num];\r
- ret = (collections_hash_elem*) collections_list_traverse_next(bucket);\r
-\r
- if (ret) {\r
- *key = ret->key;\r
- return ret->data;\r
- } else {\r
- // this list traversal is over.\r
- // let's close it.\r
- collections_list_traverse_end(bucket);\r
- }\r
- }\r
-\r
- bucket = collections_hash_get_next_valid_bucket(t);\r
- if (!bucket) {\r
- return NULL;\r
- } else {\r
- ret = (collections_hash_elem*) collections_list_traverse_next(bucket);\r
- assert(ret != NULL);\r
- }\r
-\r
- *key = ret->key;\r
- return ret->data;\r
- }\r
-}\r
-\r
-int32_t collections_hash_traverse_end(collections_hash_table* t)\r
-{\r
- if (t->cur_bucket_num == -1) {\r
- // if the cur_bucket_num is invalid, \r
- // hash traversal has not been started.\r
- printf("Error: collections_hash_table must be opened for traversal first.\n");\r
- return -1;\r
- }\r
-\r
- t->cur_bucket_num = -1;\r
- return 1;\r
-}\r
-\r
-struct collections_hash_visitor_tuple\r
-{\r
- collections_hash_visitor_func func;\r
- void *arg;\r
-};\r
-\r
-static int collections_hash_visit0(void* list_data, void* arg)\r
-{\r
- struct collections_hash_visitor_tuple *t = (struct collections_hash_visitor_tuple *)arg;\r
- collections_hash_elem *he = (collections_hash_elem*)list_data;\r
- return t->func(he->key, he->data, t->arg);\r
-}\r
-\r
-int collections_hash_visit(collections_hash_table* t, collections_hash_visitor_func func, void* arg)\r
-{\r
- struct collections_hash_visitor_tuple tuple = { func, arg };\r
- int i = 0;\r
- while (i < t->num_buckets)\r
- {\r
- if (collections_list_visit(t->buckets[i], collections_hash_visit0, &tuple) == 0) {\r
- break;\r
- }\r
- i++;\r
- }\r
-\r
- return (i == t->num_buckets);\r
-}\r
+/**
+ * \file
+ * \brief Barrelfish collections library hash table
+ */
+/*
+ * Copyright (c) 2010, ETH Zurich.
+ * All rights reserved.
+ *
+ * This file is distributed under the terms in the attached LICENSE file.
+ * If you do not find this file, copies can be found by writing to:
+ * ETH Zurich D-INFK, Haldeneggsteig 4, CH-8092 Zurich. Attn: Systems Group.
+ */
+
+#include "collections/hash_table.h"
+#include "inttypes.h"
+
+/******************************************************
+ * a simple hash table implementation
+ ******************************************************/
+
+/*
+ * Function to identify the right element from the
+ * linked list.
+ */
+static int32_t match_key(void *data, void *arg)
+{
+ collections_hash_elem *elem = (collections_hash_elem *) data;
+ uint64_t key = *((uint64_t *)arg);
+
+ return (elem->key == key);
+}
+
+/*
+ * Create a hash table.
+ */
+static void collections_hash_create_core(collections_hash_table **t, int num_buckets, collections_hash_data_free data_free)
+{
+ int i;
+
+ *t = (collections_hash_table *) malloc (sizeof(collections_hash_table));
+ memset(*t, 0, sizeof(collections_hash_table));
+
+ (*t)->num_buckets = num_buckets;
+
+ // create a linked list node for each bucket
+ (*t)->buckets = (collections_listnode **) malloc(sizeof(collections_listnode *) * num_buckets);
+ for (i = 0; i < num_buckets; i ++) {
+ collections_list_create(&(*t)->buckets[i], NULL);
+ }
+
+ (*t)->num_elems = 0;
+ (*t)->data_free = data_free;
+
+ // to keep track of traversing the hash table
+ (*t)->cur_bucket_num = -1;
+ return;
+}
+
+void collections_hash_create(collections_hash_table **t, collections_hash_data_free elem_free)
+{
+ collections_hash_create_core(t, NUM_BUCKETS, elem_free);
+}
+
+void collections_hash_create_with_buckets(collections_hash_table **t, int num_buckets, collections_hash_data_free elem_free)
+{
+ collections_hash_create_core(t, num_buckets, elem_free);
+}
+
+static int collections_hash_release_elem(void* elem, void * arg)
+{
+ collections_hash_table *t = (collections_hash_table *)arg;
+ collections_hash_elem *he = (collections_hash_elem *)elem;
+ if (t->data_free)
+ {
+ t->data_free(he->data);
+ }
+ free(he);
+
+ t->num_elems--;
+
+ return 1;
+}
+
+// delete the entire hash table
+void collections_hash_release(collections_hash_table *t)
+{
+ int bucket_num;
+ int bucket_size;
+ collections_listnode *bucket;
+
+ for (bucket_num = 0; bucket_num < t->num_buckets; bucket_num ++) {
+ uint32_t before, after;
+ bucket = t->buckets[bucket_num];
+ bucket_size = collections_list_size(bucket);
+
+ before = t->num_elems;
+ collections_list_visit(bucket, collections_hash_release_elem, t);
+ after = t->num_elems;
+ assert(before - after == bucket_size);
+
+ collections_list_release(bucket);
+ }
+ assert(t->num_elems == 0);
+
+ free(t->buckets);
+ free(t);
+}
+
+static collections_hash_elem* collections_hash_find_elem(collections_hash_table *t, uint64_t key)
+{
+ uint32_t bucket_num;
+ collections_listnode *bucket;
+ collections_hash_elem *elem;
+
+ bucket_num = key % t->num_buckets;
+ bucket = t->buckets[bucket_num];
+ elem = (collections_hash_elem*) collections_list_find_if(bucket, match_key, &key);
+ return elem;
+}
+
+/*
+ * Inserts an element into the hash table.
+ */
+void collections_hash_insert(collections_hash_table *t, uint64_t key, void *data)
+{
+ uint32_t bucket_num;
+ collections_listnode *bucket;
+ collections_hash_elem *elem;
+
+ elem = collections_hash_find_elem(t, key);
+ if (elem != NULL) {
+ printf("Error: key %" PRIu64 " already present in hash table %" PRIu64 "\n",
+ key, elem->key);
+ assert(0);
+ return;
+ }
+
+ bucket_num = key % t->num_buckets;
+ bucket = t->buckets[bucket_num];
+ elem = (collections_hash_elem *) malloc(sizeof(collections_hash_elem));
+ elem->key = key;
+ elem->data = data;
+ collections_list_insert(bucket, (void *)elem);
+ t->num_elems ++;
+}
+
+/*
+ * Retrieves an element from the hash table.
+ */
+void *collections_hash_find(collections_hash_table *t, uint64_t key)
+{
+ collections_hash_elem *he = collections_hash_find_elem(t, key);
+ return (he) ? he->data : NULL;
+}
+
+/*
+ * Removes a specific element from the table.
+ */
+void collections_hash_delete(collections_hash_table *t, uint64_t key)
+{
+ uint32_t bucket_num;
+ collections_listnode *bucket;
+ collections_hash_elem *elem;
+
+ bucket_num = key % t->num_buckets;
+ bucket = t->buckets[bucket_num];
+ elem = (collections_hash_elem*) collections_list_remove_if(bucket, match_key, &key);
+ if (elem) {
+ uint32_t n = t->num_elems;
+ collections_hash_release_elem(elem, t);
+ assert(1 == n - t->num_elems);
+ }
+ else
+ {
+ printf("Error: cannot find the node with key %" PRIu64 " in collections_hash_release\n", key);
+ }
+}
+
+/*
+ * Returns the number of elements in the hash table.
+ */
+uint32_t collections_hash_size(collections_hash_table *t)
+{
+ return (t->num_elems);
+}
+
+static collections_listnode* collections_hash_get_next_valid_bucket(collections_hash_table* t)
+{
+ collections_listnode* bucket;
+
+ do {
+ t->cur_bucket_num ++;
+ if (t->cur_bucket_num < t->num_buckets) {
+ if (!t->buckets[t->cur_bucket_num]) {
+ continue;
+ }
+ } else {
+ return NULL;
+ }
+ } while (collections_list_size(t->buckets[t->cur_bucket_num]) <= 0);
+
+ bucket = t->buckets[t->cur_bucket_num];
+ collections_list_traverse_start(bucket);
+
+ return bucket;
+}
+
+int32_t collections_hash_traverse_start(collections_hash_table *t)
+{
+ if (t->cur_bucket_num != -1) {
+ // if the cur_bucket_num is valid, a
+ // traversal is already in progress.
+ printf("Error: collections_hash_table is already opened for traversal.\n");
+ return -1;
+ }
+
+ collections_hash_get_next_valid_bucket(t);
+
+ return 1;
+}
+
+/*
+ * Returns the next element in the hash table. If
+ * a valid element is found, the key is set to the
+ * key of the element. If there is no valid element,
+ * returns null and key is not modified.
+ */
+void* collections_hash_traverse_next(collections_hash_table* t, uint64_t *key)
+{
+ if (t->cur_bucket_num == -1) {
+ // if the cur_bucket_num is invalid,
+ // hash traversal has not been started.
+ printf("Error: collections_hash_table must be opened for traversal first.\n");
+ return NULL;
+ }
+
+ if (t->cur_bucket_num >= t->num_buckets) {
+ // all the buckets have been traversed.
+ return NULL;
+ } else {
+ collections_listnode* bucket;
+ collections_hash_elem* ret;
+
+ if (t->buckets[t->cur_bucket_num]) {
+ bucket = t->buckets[t->cur_bucket_num];
+ ret = (collections_hash_elem*) collections_list_traverse_next(bucket);
+
+ if (ret) {
+ *key = ret->key;
+ return ret->data;
+ } else {
+ // this list traversal is over.
+ // let's close it.
+ collections_list_traverse_end(bucket);
+ }
+ }
+
+ bucket = collections_hash_get_next_valid_bucket(t);
+ if (!bucket) {
+ return NULL;
+ } else {
+ ret = (collections_hash_elem*) collections_list_traverse_next(bucket);
+ assert(ret != NULL);
+ }
+
+ *key = ret->key;
+ return ret->data;
+ }
+}
+
+int32_t collections_hash_traverse_end(collections_hash_table* t)
+{
+ if (t->cur_bucket_num == -1) {
+ // if the cur_bucket_num is invalid,
+ // hash traversal has not been started.
+ printf("Error: collections_hash_table must be opened for traversal first.\n");
+ return -1;
+ }
+
+ t->cur_bucket_num = -1;
+ return 1;
+}
+
+struct collections_hash_visitor_tuple
+{
+ collections_hash_visitor_func func;
+ void *arg;
+};
+
+static int collections_hash_visit0(void* list_data, void* arg)
+{
+ struct collections_hash_visitor_tuple *t = (struct collections_hash_visitor_tuple *)arg;
+ collections_hash_elem *he = (collections_hash_elem*)list_data;
+ return t->func(he->key, he->data, t->arg);
+}
+
+int collections_hash_visit(collections_hash_table* t, collections_hash_visitor_func func, void* arg)
+{
+ struct collections_hash_visitor_tuple tuple = { func, arg };
+ int i = 0;
+ while (i < t->num_buckets)
+ {
+ if (collections_list_visit(t->buckets[i], collections_hash_visit0, &tuple) == 0) {
+ break;
+ }
+ i++;
+ }
+
+ return (i == t->num_buckets);
+}
-HISTORY\r
-\r
-(git master)\r
-\r
- * [Enter new changes just after this line - do not remove this line]\r
-\r
-(STABLE-2.0.2)\r
-\r
- ++ New features:\r
-\r
- 2017-02-10: Dirk Ziegelmeier\r
- * Implement task #14367: Hooks need a better place to be defined:\r
- We now have a #define for a header file name that is #included in every .c\r
- file that provides hooks.\r
-\r
- ++ Bugfixes:\r
-\r
- 2017-03-08\r
- * tcp: do not keep sending SYNs when getting ACKs\r
-\r
- 2017-03-08: Joel Cunningham\r
- * tcp: Initialize ssthresh to TCP_SND_BUF (bug #50476)\r
-\r
- 2017-03-01: Simon Goldschmidt\r
- * httpd: LWIP_HTTPD_POST_MANUAL_WND: fixed double-free when httpd_post_data_recved\r
- is called nested from httpd_post_receive_data() (bug #50424)\r
-\r
- 2017-02-28: David van Moolenbroek/Simon Goldschmidt\r
- * tcp: fixed bug #50418: LWIP_EVENT_API: fix invalid calbacks for SYN_RCVD pcb\r
-\r
- 2017-02-17: Simon Goldschmidt\r
- * dns: Improved DNS_LOCAL_HOSTLIST interface (bug #50325)\r
-\r
- 2017-02-16: Simon Goldschmidt\r
- * LWIP_NETCONN_FULLDUPLEX: fixed shutdown during write (bug #50274)\r
-\r
- 2017-02-13: Simon Goldschmidt/Dirk Ziegelmeier\r
- * For tiny targtes, LWIP_RAND is optional (fix compile time checks)\r
-\r
- 2017-02-10: Simon Goldschmidt\r
- * tcp: Fixed bug #47485 (tcp_close() should not fail on memory error) by retrying\r
- to send FIN from tcp_fasttmr\r
-\r
- 2017-02-09: Simon Goldschmidt\r
- * sockets: Fixed bug #44032 (LWIP_NETCONN_FULLDUPLEX: select might work on\r
- invalid/reused socket) by not allowing to reallocate a socket that has\r
- "select_waiting != 0"\r
-\r
- 2017-02-09: Simon Goldschmidt\r
- * httpd: Fixed bug #50059 (httpd LWIP_HTTPD_SUPPORT_11_KEEPALIVE vs.\r
- LWIP_HTTPD_KILL_OLD_ON_CONNECTIONS_EXCEEDED)\r
-\r
- 2017-02-08: Dirk Ziegelmeier\r
- * Rename "IPv6 mapped IPv4 addresses" to their correct name from RFC4191:\r
- "IPv4-mapped IPv6 address"\r
-\r
- 2017-02-08: Luc Revardel\r
- * mld6.c: Fix bug #50220 (mld6_leavegroup does not send ICMP6_TYPE_MLD, even\r
- if last reporter)\r
-\r
- 2017-02-08: David van Moolenbroek\r
- * ip6.c: Patch #9250: fix source substitution in ip6_output_if()\r
-\r
- 2017-02-08: Simon Goldschmidt\r
- * tcp_out.c: Fixed bug #50090 (last_unsent->oversize_left can become wrong value\r
- in tcp_write error path)\r
-\r
- 2017-02-02: Dirk Ziegelmeier\r
- * Fix bug #50206: UDP Netconn bind to IP6_ADDR_ANY fails\r
-\r
- 2017-01-18: Dirk Ziegelmeier\r
- * Fix zero-copy RX, see bug bug #50064. PBUF_REFs were not supported as ARP requests.\r
-\r
- 2017-01-15: Axel Lin, Dirk Ziegelmeier\r
- * minor bug fixes in mqtt\r
-\r
- 2017-01-11: Knut Andre Tidemann\r
- * sockets/netconn: fix broken default ICMPv6 handling of checksums\r
-\r
-(STABLE-2.0.1)\r
-\r
- ++ New features:\r
-\r
- 2016-12-31: Simon Goldschmidt\r
- * tcp.h/.c: added function tcp_listen_with_backlog_and_err() to get the error\r
- reason when listening fails (bug #49861)\r
-\r
- 2016-12-20: Erik Andersen\r
- * Add MQTT client\r
-\r
- 2016-12-14: Jan Breuer:\r
- * opt.h, ndc.h/.c: add support for RDNSS option (as per RFC 6106)\r
-\r
- 2016-12-14: David van Moolenbroek\r
- * opt.h, nd6.c: Added LWIP_HOOK_ND6_GET_GW()\r
-\r
- 2016-12-09: Dirk Ziegelmeier\r
- * ip6_frag.c: Implemented support for LWIP_NETIF_TX_SINGLE_PBUF\r
-\r
- 2016-12-09: Simon Goldschmidt\r
- * dns.c: added one-shot multicast DNS queries\r
-\r
- 2016-11-24: Ambroz Bizjak, David van Moolenbroek\r
- * tcp_out.c: Optimize passing contiguous nocopy buffers to tcp_write (bug #46290)\r
-\r
- 2016-11-16: Dirk Ziegelmeier\r
- * sockets.c: added support for IPv6 mapped IPv4 addresses\r
-\r
- ++ Bugfixes:\r
-\r
- 2016-12-16: Thomas Mueller\r
- * api_lib.c: fixed race condition in return value of netconn_gethostbyname()\r
- (and thus also lwip_gethostbyname/_r() and lwip_getaddrinfo())\r
-\r
- 2016-12-15: David van Moolenbroek\r
- * opt.h, tcp: added LWIP_HOOK_TCP_ISN() to implement less predictable initial\r
- sequence numbers (see contrib/addons/tcp_isn for an example implementation)\r
-\r
- 2016-12-05: Dirk Ziegelmeier\r
- * fixed compiling with IPv4 disabled (IPv6 only case)\r
-\r
- 2016-11-28: Simon Goldschmidt\r
- * api_lib.c: fixed bug #49725 (send-timeout: netconn_write() can return\r
- ERR_OK without all bytes being written)\r
-\r
- 2016-11-28: Ambroz Bizjak\r
- * tcpi_in.c: fixed bug #49717 (window size in received SYN and SYN-ACK\r
- assumed scaled)\r
-\r
- 2016-11-25: Simon Goldschmidt\r
- * dhcp.c: fixed bug #49676 (Possible endless loop when parsing dhcp options)\r
-\r
- 2016-11-23: Dirk Ziegelmeier\r
- * udp.c: fixed bug #49662: multicast traffic is now only received on a UDP PCB\r
- (and therefore on a UDP socket/netconn) when the PCB is bound to IP_ADDR_ANY\r
-\r
- 2016-11-16: Dirk Ziegelmeier\r
- * *: Fixed dual-stack behaviour, IPv6 mapped IPv4 support in socket API\r
-\r
- 2016-11-14: Joel Cunningham\r
- * tcp_out.c: fixed bug #49533 (start persist timer when unsent seg can't fit\r
- in window) \r
-\r
- 2016-11-16: Roberto Barbieri Carrera\r
- * autoip.c: fixed bug #49610 (sometimes AutoIP fails to reuse the same address)\r
-\r
- 2016-11-11: Dirk Ziegelmeier\r
- * sockets.c: fixed bug #49578 (dropping multicast membership does not work\r
- with LWIP_SOCKET_OFFSET)\r
-\r
-(STABLE-2.0.0)\r
-\r
- ++ New features:\r
-\r
- 2016-07-27: Simon Goldschmidt\r
- * opt.h, timeouts.h/.c: added LWIP_TIMERS_CUSTOM to override the default\r
- implementation of timeouts\r
-\r
- 2016-07-xx: Dirk Ziegelmeier\r
- * Large overhaul of doxygen documentation\r
-\r
- 2016-04-05: Simon Goldschmidt\r
- * timers.h/.c: prepare for overriding current timeout implementation: all\r
- stack-internal caclic timers are avaliable in the lwip_cyclic_timers array\r
-\r
- 2016-03-23: Simon Goldschmidt\r
- * tcp: call accept-callback with ERR_MEM when allocating a pcb fails on\r
- passive open to inform the application about this error\r
- ATTENTION: applications have to handle NULL pcb in accept callback!\r
-\r
- 2016-02-22: Ivan Delamer\r
- * Initial 6LoWPAN support\r
-\r
- 2016-02-XX to 2016-03-XX: Dirk Ziegelmeier\r
- * Cleanup TCPIP thread sync methods in a way that it is possibe to use them\r
- in arbitrary code that needs things to be done in TCPIP thread. Used to\r
- decouple netconn, netif, ppp and 6LoWPAN from LWIP core.\r
-\r
- 2016-02-XX: Dirk Ziegelmeier\r
- * Implement dual-stack support in RAW, UDP and TCP. Add new IP address\r
- type IPADDR_ANY_TYPE for this. Netconn/Socket API: Dual-stack is\r
- automatically supported when an IPv6 netconn/socket is created.\r
-\r
- 2015-12-26: Martin Hentschel and Dirk Ziegelmeier\r
- * Rewrite SNMP agent. SNMPv2c + MIB compiler.\r
-\r
- 2015-11-12: Dirk Ziegelmeier\r
- * Decouple SNMP stack from lwIP core and move stack to apps/ directory.\r
- Breaking change: Users have to call snmp_init() now!\r
-\r
- 2015-11-12: Dirk Ziegelmeier\r
- * Implement possibility to declare private memory pools. This is useful to\r
- decouple some apps from the core (SNMP stack) or make contrib app usage\r
- simpler (httpserver_raw)\r
-\r
- 2015-10-09: Simon Goldschmidt\r
- * started to move "private" header files containing implementation details to\r
- "lwip/priv/" include directory to seperate the API from the implementation.\r
-\r
- 2015-10-07: Simon Goldschmidt\r
- * added sntp client as first "supported" application layer protocol implementation\r
- added 'apps' folder\r
-\r
- 2015-09-30: Dirk Ziegelmeier\r
- * snmp_structs.h, mib_structs.c, mib2.c: snmp: fixed ugly inheritance\r
- implementation by aggregating the "base class" (struct mib_node) in all\r
- derived node classes to get more type-safe code\r
-\r
- 2015-09-23: Simon Goldschmidt\r
- * netif.h/.c, nd6.c: task #13729: Convert netif addresses (IPv4 & IPv6) to\r
- ip_addr_t (so they can be used without conversion/temporary storage)\r
-\r
- 2015-09-08: Dirk Ziegelmeier\r
- * snmp: Separate mib2 counter/table callbacks from snmp agent. This both cleans\r
- up the code and should allow integration of a 3rd party agent/mib2. Simple\r
- counters are kept in MIB2_STATS, tree/table change function prototypes moved to\r
- snmp_mib2.h.\r
-\r
- 2015-09-03: Simon Goldschmidt\r
- * opt.h, dns.h/.c: DNS/IPv6: added support for AAAA records\r
-\r
- 2015-09-01: Simon Goldschmidt\r
- * task #12178: hardware checksum capabilities can be configured per netif\r
- (use NETIF_SET_CHECKSUM_CTRL() in your netif's init function)\r
-\r
- 2015-08-30: Simon Goldschmidt\r
- * PBUF_REF with "custom" pbufs is now supported for RX pbufs (see pcapif in\r
- contrib for an example, LWIP_SUPPORT_CUSTOM_PBUF is required)\r
-\r
- 2015-08-30: Simon Goldschmidt\r
- * support IPv4 source based routing: define LWIP_HOOK_IP4_ROUTE_SRC to point\r
- to a routing function\r
-\r
- 2015-08-05: Simon Goldschmidt\r
- * many files: allow multicast socket options IP_MULTICAST_TTL, IP_MULTICAST_IF\r
- and IP_MULTICAST_LOOP to be used without IGMP\r
-\r
- 2015-04-24: Simon Goldschmidt\r
- * dhcp.h/c, autoip.h/.c: added functions dhcp/autoip_supplied_address() to\r
- check for the source of address assignment (replacement for NETIF_FLAG_DHCP)\r
-\r
- 2015-04-10: Simon Goldschmidt\r
- * many files: task #13480: added LWIP_IPV4 define - IPv4 can be disabled,\r
- leaving an IPv6-only stack\r
-\r
- 2015-04-09: Simon Goldschmidt\r
- * nearly all files: task #12722 (improve IPv4/v6 address handling): renamed\r
- ip_addr_t to ip4_addr_t, renamed ipX_addr_t to ip_addr_t and added IP\r
- version; ip_addr_t is used for all generic IP addresses for the API,\r
- ip(4/6)_addr_t are only used internally or when initializing netifs or when\r
- calling version-related functions\r
-\r
- 2015-03-24: Simon Goldschmidt\r
- * opt.h, ip4_addr.h, ip4.c, ip6.c: loopif is not required for loopback traffic\r
- any more but passed through any netif (ENABLE_LOOPBACK has to be enabled)\r
-\r
- 2015-03-23: Simon Goldschmidt\r
- * opt.h, etharp.c: with ETHARP_TABLE_MATCH_NETIF== 1, duplicate (Auto)-IP\r
- addresses on multiple netifs should now be working correctly (if correctly\r
- addressed by routing, that is)\r
-\r
- 2015-03-23: Simon Goldschmidt\r
- * etharp.c: Stable etharp entries that are about to expire are now refreshed\r
- using unicast to prevent unnecessary broadcast. Only if no answer is received\r
- after 15 seconds, broadcast is used.\r
-\r
- 2015-03-06: Philip Gladstone\r
- * netif.h/.c: patch #8359 (Provide utility function to add an IPv6 address to\r
- an interface)\r
-\r
- 2015-03-05: Simon Goldschmidt\r
- * netif.c, ip4.c, dhcp.c, autoip.c: fixed bug #37068 (netif up/down handling\r
- is unclear): correclty separated administrative status of a netif (up/down)\r
- from 'valid address' status\r
- ATTENTION: netif_set_up() now always has to be called, even when dhcp/autoip\r
- is used!\r
-\r
- 2015-02-26: patch by TabascoEye\r
- * netif.c, udp.h/.c: fixed bug #40753 (re-bind UDP pcbs on change of IP address)\r
-\r
- 2015-02-22: chrysn, Simon Goldschmidt\r
- * *.*: Changed nearly all functions taking 'ip(X)_addr_t' pointer to take\r
- const pointers (changed user callbacks: raw_recv_fn, udp_recv_fn; changed\r
- port callbacks: netif_output_fn, netif_igmp_mac_filter_fn)\r
-\r
- 2015-02-19: Ivan Delamer\r
- * netif.h, dhcp.c: Removed unused netif flag for DHCP. The preferred way to evaluate\r
- if DHCP is active is through netif->dhcp field.\r
-\r
- 2015-02-19: Ivan Delamer\r
- * netif.h, slipif.c, ppp.c: Removed unused netif flag for point to point connections\r
-\r
- 2015-02-18: Simon Goldschmidt\r
- * api_lib.c: fixed bug #37958 "netconn API doesn't handle correctly\r
- connections half-closed by peer"\r
-\r
- 2015-02-18: Simon Goldschmidt\r
- * tcp.c: tcp_alloc() prefers killing CLOSING/LAST_ACK over active connections\r
- (see bug #39565)\r
-\r
- 2015-02-16: Claudius Zingerli, Sergio Caprile\r
- * opt.h, dhcp.h/.c: patch #8361 "Add support for NTP option in DHCP"\r
-\r
- 2015-02-14: Simon Goldschmidt\r
- * opt.h, snmp*: added support for write-access community and dedicated\r
- community for sending traps\r
-\r
- 2015-02-13: Simon Goldschmidt\r
- * opt.h, memp.c: added hook LWIP_HOOK_MEMP_AVAILABLE() to get informed when\r
- a memp pool was empty and an item is now available\r
-\r
- 2015-02-13: Simon Goldschmidt\r
- * opt.h, pbuf.h/.c, etharp.c: Added the option PBUF_LINK_ENCAPSULATION_HLEN to\r
- allocate additional header space for TX on netifs requiring additional headers\r
-\r
- 2015-02-12: chrysn\r
- * timers.h/.c: introduce sys_timeouts_sleeptime (returns the time left before\r
- the next timeout is due, for NO_SYS==1)\r
-\r
- 2015-02-11: Nick van Ijzendoorn\r
- * opt.h, sockets.h/c: patch #7702 "Include ability to increase the socket number\r
- with defined offset"\r
-\r
- 2015-02-11: Frederick Baksik\r
- * opt.h, def.h, others: patch #8423 "arch/perf.h" should be made an optional item\r
-\r
- 2015-02-11: Simon Goldschmidt\r
- * api_msg.c, opt.h: started to implement fullduplex sockets/netconns\r
- (note that this is highly unstable yet!)\r
-\r
- 2015-01-17: Simon Goldschmidt\r
- * api: allow enabling socket API without (public) netconn API - netconn API is\r
- still used by sockets, but keeping it private (static) should allow better\r
- compiler optimizations\r
-\r
- 2015-01-16: Simon Goldschmidt\r
- * tcp_in.c: fixed bug #20506 "Initial congestion window is very small" again\r
- by implementing the calculation formula from RFC3390\r
-\r
- 2014-12-10: Simon Goldschmidt\r
- * api: added option LWIP_NETCONN_SEM_PER_THREAD to use a semaphore per thread\r
- instead of using one per netconn and per select call\r
-\r
- 2014-12-08: Simon Goldschmidt\r
- * ip6.h: fixed bug #43778: IPv6 header version not set on 16-bit platform\r
- (macro IP6H_VTCFL_SET())\r
-\r
- 2014-12-08: Simon Goldschmidt\r
- * icmp.c, ip4.c, pbuf.c, udp.c, pbuf.h: task #11472 Support PBUF_REF for RX\r
- (IPv6 and IPv4/v6 reassembly might not work yet)\r
-\r
- 2014-11-06: Simon Goldschmidt\r
- * sockets.c/.h, init.c: lwip_socket_init() is not needed any more\r
- -> compatibility define\r
-\r
- 2014-09-16: Simon Goldschmidt\r
- * dns.c, opt.h: reduced ram usage by parsing DNS responses in place\r
-\r
- 2014-09-16: Simon Goldschmidt\r
- * pbuf.h/.c: added pbuf_take_at() and pbuf_put_at()\r
-\r
- 2014-09-15: Simon Goldschmidt\r
- * dns.c: added source port randomization to make the DNS client more robust\r
- (see bug #43144)\r
-\r
- 2013-09-02: Simon Goldschmidt\r
- * arch.h and many other files: added optional macros PACK_STRUCT_FLD_8() and\r
- PACK_STRUCT_FLD_S() to prevent gcc 4 from warning about struct members that\r
- do not need packing\r
-\r
- 2013-08-19: Simon Goldschmidt\r
- * netif.h: bug #42998: made NETIF_MAX_HWADDR_LEN overridable for some special\r
- networks\r
-\r
- 2013-03-17: Simon Goldschmidt (patch by Ghobad Emadi)\r
- * opt.h, etharp.c: Added LWIP_HOOK_ETHARP_GET_GW to implement IPv4 routing with\r
- multiple gateways\r
-\r
- 2013-04-20: Fatih Asici\r
- * opt.h, etharp.h/.c: patch #7993: Added support for transmitting packets\r
- with VLAN headers via hook function LWIP_HOOK_VLAN_SET and to check them\r
- via hook function LWIP_HOOK_VLAN_CHECK\r
-\r
- 2014-02-20: Simon Goldschmidt (based on patch by Artem Pisarenko)\r
- * patch #7885: modification of api modules to support FreeRTOS-MPU\r
- (don't pass stack-pointers to other threads)\r
-\r
- 2014-02-05: Simon Goldschmidt (patch by "xtian" and "alex_ab")\r
- * patch #6537/#7858: TCP window scaling support\r
-\r
- 2014-01-17: Jiri Engelthaler\r
- * icmp, icmp6, opt.h: patch #8027: Completed HW checksuming for IPv4 and\r
- IPv6 ICMP's\r
-\r
- 2012-08-22: Sylvain Rochet\r
- * New PPP stack for lwIP, developed in ppp-new branch.\r
- Based from pppd 2.4.5, released 2009-11-17, with huge changes to match\r
- code size and memory requirements for embedded devices, including:\r
- - Gluing together the previous low-level PPP code in lwIP to pppd 2.4.5, which\r
- is more or less what pppd sys-* files are, so that we get something working\r
- using the unix port.\r
- - Merged some patchs from lwIP Git repository which add interesting features\r
- or fix bugs.\r
- - Merged some patchs from Debian pppd package which add interesting features\r
- or fix bugs.\r
- - Ported PPP timeout handling to the lwIP timers system\r
- - Disabled all the PPP code using filesystem access, replaced in necessary cases\r
- to configuration variables.\r
- - Disabled all the PPP code forking processes.\r
- - Removed IPX support, lwIP does not support IPX.\r
- - Ported and improved random module from the previous PPP port.\r
- - Removed samba TDB (file-driven database) usage, because it needs a filesystem.\r
- - MS-CHAP required a DES implementation, we added the latest PolarSSL DES\r
- implementation which is under a BSD-ish license.\r
- - Also switched to PolarSSL MD4,MD5,SHA1 implementations, which are meant to be\r
- used in embedded devices with reduced memory footprint.\r
- - Removed PPP configuration file parsing support. \r
- - Added macro definition EAP_SUPPORT to make EAP support optional.\r
- - Added macro definition CHAP_SUPPORT to make CHAP support optional.\r
- - Added macro definition MSCHAP_SUPPORT to make MSCHAP support optional.\r
- - Added macro definition PAP_SUPPORT to make PAP support optional.\r
- - Cleared all Linux syscall calls.\r
- - Disabled demand support using a macro, so that it can be ported later.\r
- - Disabled ECP support using a macro, so that it can be ported later.\r
- - Disabled CCP support using a macro, so that it can be ported later.\r
- - Disabled CBCP support using a macro, so that it can be ported later.\r
- - Disabled LQR support using a macro, so that it can be ported later.\r
- - Print packet debug feature optional, through PRINTPKT_SUPPORT\r
- - Removed POSIX signal usage.\r
- - Fully ported PPPoS code from the previous port.\r
- - Fully ported PPPoE code from the previous port.\r
- - Fully ported VJ compression protocol code from the previous port.\r
- - Removed all malloc()/free() use from PPP, replaced by stack usage or PBUF.\r
- - Disabled PPP server support using a macro, so that it can be ported later.\r
- - Switched all PPP debug to lwIP debug system.\r
- - Created PPP Control Block (PPP PCB), removed PPP unit integer everywhere,\r
- removed all global variables everywhere, did everything necessary for\r
- the PPP stack to support more than one PPP session (pppd only support\r
- one session per process).\r
- - Removed the statically allocated output buffer, now using PBUF.\r
- - Improved structure size of all PPP modules, deep analyze of code to reduce\r
- variables size to the bare minimum. Switched all boolean type (char type in\r
- most architecture) to compiler generated bitfields.\r
- - Added PPP IPv6 support, glued lwIP IPv6 support to PPP.\r
- - Now using a persistent netif interface which can then be used in lwIP\r
- functions requiring a netif.\r
- - Now initializing PPP in lwip_init() function.\r
- - Reworked completely the PPP state machine, so that we don't end up in\r
- anymore in inconsistent state, especially with PPPoE.\r
- - Improved the way we handle PPP reconnection after disconnect, cleaning\r
- everything required so that we start the PPP connection again from a\r
- clean state.\r
- - Added PPP holdoff support, allow the lwIP user to wait a little bit before\r
- reconnecting, prevents connection flood, especially when using PPPoL2TP.\r
- - Added PPPoL2TP LAC support (a.k.a. UDP tunnels), adding a VPN client\r
- feature to lwIP, L2TP being a widely used tunnel protocol.\r
- - Switched all used PPP types to lwIP types (u8t, u16t, u32t, ...)\r
- - Added PPP API "sequential" thread-safe API, based from NETIFAPI.\r
-\r
- 2011-07-21: Simon Goldschmidt\r
- * sockets.c, opt.h: (bug #30185): added LWIP_FIONREAD_LINUXMODE that makes\r
- ioctl/FIONREAD return the size of the next pending datagram.\r
-\r
- 2011-05-25: Simon Goldschmidt\r
- * again nearly the whole stack, renamed ip.c to ip4.c, ip_addr.c to ip4_addr.c,\r
- combined ipv4/ipv6 inet_chksum.c, added ip.h, ip_addr.h: Combined IPv4\r
- and IPv6 code where possible, added defines to access IPv4/IPv6 in non-IP\r
- code so that the code is more readable.\r
-\r
- 2011-05-17: Patch by Ivan Delamer (only checked in by Simon Goldschmidt)\r
- * nearly the whole stack: Finally, we got decent IPv6 support, big thanks to\r
- Ivan! (this is work in progress: we're just post release anyway :-)\r
-\r
-\r
- ++ Bugfixes:\r
-\r
- 2016-08-23: Simon Goldschmidt\r
- * etharp: removed ETHARP_TRUST_IP_MAC since it is insecure and we don't need\r
- it any more after implementing unicast ARP renewal towards arp entry timeout\r
-\r
- 2016-07-20: Simon Goldschmidt\r
- * memp.h/.c: fixed bug #48442 (memp stats don't work for MEMP_MEM_MALLOC)\r
-\r
- 2016-07-21: Simon Goldschmidt (patch by Ambroz Bizjak)\r
- * tcp_in.c, tcp_out.c: fixed bug #48543 (TCP sent callback may prematurely\r
- report sent data when only part of a segment is acked) and don't include\r
- SYN/FIN in snd_buf counter\r
-\r
- 2016-07-19: Simon Goldschmidt\r
- * etharp.c: fixed bug #48477 (ARP input packet might update static entry)\r
-\r
- 2016-07-11: Simon Goldschmidt\r
- * tcp_in.c: fixed bug #48476 (TCP sent callback called wrongly due to picking\r
- up old pcb->acked\r
-\r
- 2016-06-30: Simon Goldschmidt (original patch by Fabian Koch)\r
- * tcp_in.c: fixed bug #48170 (Vulnerable to TCP RST spoofing)\r
-\r
- 2016-05-20: Dirk Ziegelmeier\r
- * sntp.h/.c: Fix return value of sntp_getserver() call to return a pointer\r
-\r
- 2016-04-05: Simon Goldschmidt (patch by Philip Gladstone)\r
- * udp.c: patch #8358: allow more combinations of listening PCB for IPv6\r
-\r
- 2016-04-05: Simon Goldschmidt\r
- * netconn/socket API: fixed bug# 43739 (Accept not reporting errors about\r
- aborted connections): netconn_accept() returns ERR_ABRT (sockets: ECONNABORTED)\r
- for aborted connections, ERR_CLSD (sockets: EINVAL) if the listening netconn\r
- is closed, which better seems to follow the standard.\r
-\r
- 2016-03-23: Florent Matignon\r
- * dhcp.c: fixed bug #38203: DHCP options are not recorded in all DHCP ack messages\r
-\r
- 2016-03-22: Simon Goldschmidt\r
- * tcp: changed accept handling to be done internally: the application does not\r
- have to call tcp_accepted() any more. Instead, when delaying accept (e.g. sockets\r
- do), call tcp_backlog_delayed()/tcp_backlog_accepted() (fixes bug #46696)\r
-\r
- 2016-03-22: Simon Goldschmidt\r
- * dns.c: ignore dns response parsing errors, only abort resolving for correct\r
- responses or error responses from correct server (bug #47459)\r
-\r
- 2016-03-17: Simon Goldschmidt\r
- * api_msg.c: fixed bug #47448 (netconn/socket leak if RST is received during close)\r
-\r
- 2016-03-17: Joel Cunningham\r
- * api_msg.c: don't fail closing a socket/netconn when failing to allocate the\r
- FIN segment; blocking the calling thread for a while is better than risking\r
- leaking a netconn/socket (see bug #46701)\r
-\r
- 2016-03-16: Joel Cunningham\r
- * tcp_out.c: reset rto timer on fast retransmission\r
-\r
- 2016-03-16: Deomid Ryabkov\r
- * tcp_out.c: fixed bug #46384 Segment size calculation bug with MSS != TCP_MSS\r
-\r
- 2016-03-05: Simon Goldschmidt\r
- * err.h/.c, sockets.c: ERR_IF is not necessarily a fatal error\r
-\r
- 2015-11-19: fix by Kerem Hadimli\r
- * sockets.c: fixed bug #46471: lwip_accept() leaks socket descriptors if new\r
- netconn was already closed because of peer behavior\r
-\r
- 2015-11-12: fix by Valery Ushakov\r
- * tcp_in.c: fixed bug #46365 tcp_accept_null() should call tcp_abort()\r
-\r
- 2015-10-02: Dirk Ziegelmeier/Simon Goldschmidt\r
- * snmp: cleaned up snmp structs API (fixed race conditions from bug #46089,\r
- reduce ram/rom usage of tables): incompatible change for private MIBs\r
-\r
- 2015-09-30: Simon Goldschmidt\r
- * ip4_addr.c: fixed bug #46072: ip4addr_aton() does not check the number range\r
- of all address parts\r
-\r
- 2015-08-28: Simon Goldschmidt\r