Device driver support. More...
Data Structures | |
struct | _NUTDEVICE |
Device structure. More... | |
struct | _NUTVIRTUALDEVICE |
Virtual device structure. More... | |
struct | _IFSTREAM |
Stream interface information structure. More... | |
struct | _NUTFILE |
File structure. More... | |
Defines | |
#define | IFTYP_RAM 0 |
RAM device. | |
#define | IFTYP_ROM 1 |
ROM device. | |
#define | IFTYP_STREAM 2 |
Stream device. | |
#define | IFTYP_NET 3 |
Net device. | |
#define | IFTYP_TCPSOCK 4 |
TCP socket. | |
#define | IFTYP_CHAR 5 |
Character stream device. | |
#define | IFTYP_CAN 6 |
CAN device. | |
#define | IFTYP_BLKIO 7 |
Block I/O device. | |
#define | IFTYP_FS 16 |
file system device | |
#define | NUTFILE_EOF ((NUTFILE *)(-1)) |
Typedefs | |
typedef struct _NUTDEVICE | NUTDEVICE |
Device structure type. | |
typedef struct _NUTVIRTUALDEVICE | NUTVIRTUALDEVICE |
Device structure type. | |
typedef struct _IFSTREAM | IFSTREAM |
Stream interface type. | |
typedef struct _NUTFILE | NUTFILE |
File structure type. | |
Functions | |
NUTDEVICE * | NutDeviceLookup (const char *name) |
Find device entry by name. | |
NUTDEVICE * | NutDeviceLookupType (NUTDEVICE *dev, uint_fast8_t type) |
Find device entry by type. | |
int | NutRegisterDevice (NUTDEVICE *dev, uintptr_t base, uint8_t irq) |
Register and initialize a device. | |
int | NullIOCTL (NUTDEVICE *dev, int req, void *conf) |
Perform control functions. | |
Variables | |
NUTDEVICE * | nutDeviceList = 0 |
Linked list of all registered devices. | |
NUTDEVICE | devNull |
Null device information structure. |
Device driver support.
#define IFTYP_RAM 0 |
RAM device.
#define IFTYP_ROM 1 |
ROM device.
#define IFTYP_STREAM 2 |
Stream device.
Referenced by AceInit(), and UartAvrInit().
#define IFTYP_NET 3 |
Net device.
Referenced by AhdlcAt91IOCtl(), AhdlcAvrIOCtl(), NutDhcpIfConfig(), NutIpOutput(), NutNetIfAddMcastAddr(), NutNetIfConfig2(), and NutNetIfDelMcastAddr().
#define IFTYP_TCPSOCK 4 |
TCP socket.
Referenced by NutTcpCreateSocket().
#define IFTYP_CHAR 5 |
Character stream device.
Referenced by AhdlcAt91IOCtl(), and AhdlcAvrIOCtl().
#define IFTYP_CAN 6 |
CAN device.
#define IFTYP_BLKIO 7 |
Block I/O device.
#define IFTYP_FS 16 |
file system device
Referenced by MmCardMount(), NutBlockDeviceOpen(), and SpiMmcMount().
#define NUTFILE_EOF ((NUTFILE *)(-1)) |
Referenced by AceOpen(), AhdlcAt91Close(), AhdlcAt91Open(), AhdlcAvrClose(), AhdlcAvrOpen(), MmCardMount(), NutBlockDeviceOpen(), PhatDirCreate(), PhatDirDelEntry(), PhatDirEntryStatus(), PhatDirOpen(), PhatDirOpenParent(), PhatDirRemove(), PhatDirRenameEntry(), PhatFileClose(), PhatFileOpen(), RawFsFileOpen(), Spi7SegOpen(), SpiMmcMount(), TermClose(), TermOpen(), UartAvrOpen(), UsartClose(), and UsartOpen().
typedef struct _NUTDEVICE NUTDEVICE |
Device structure type.
typedef struct _NUTVIRTUALDEVICE NUTVIRTUALDEVICE |
Device structure type.
NUTDEVICE* NutDeviceLookup | ( | const char * | name | ) |
Find device entry by name.
name | Unique device name. |
References _NUTDEVICE::dev_name, _NUTDEVICE::dev_next, NULL, NUTASSERT, and strcmp().
Referenced by _open(), NutBlockDeviceOpen(), NutDhcpIfConfig(), NutNetIfAddMcastAddr(), NutNetIfConfig2(), NutNetIfDelMcastAddr(), NutRegisterDevice(), opendir(), rename(), stat(), and upnp_Init().
NUTDEVICE* NutDeviceLookupType | ( | NUTDEVICE * | dev, |
uint_fast8_t | type | ||
) |
Find device entry by type.
dev | Pointer to the device returned by the last call. Set to NULL to start searching at the first entry. |
type | Device type. May be any of the following: |
References _NUTDEVICE::dev_next, _NUTDEVICE::dev_type, NULL, and nutDeviceList.
Referenced by NutBlockDeviceOpen().
Register and initialize a device.
Initializes the device and adds it to the system device list. Applications should call this function during initialization for each device they intend to use.
dev | Pointer to the NUTDEVICE structure, which is provided by the device driver. This structure contains a hardware device name, which must be unique among all registered devices. Drivers may operate in a different mode using the same hardware, like interrupt driven or polling UART drivers. Only one of those drivers can be registered, because they specify the same hardware device name. |
base | Hardware base address of this device. Set to 0, if the device driver has a fixed hardware address. |
irq | Hardware interrupt used by this device. Set to 0, if the device driver doesn't support configurable interupts. |
References _NUTDEVICE::dev_base, _NUTDEVICE::dev_init, _NUTDEVICE::dev_irq, _NUTDEVICE::dev_name, _NUTDEVICE::dev_next, NULL, NUTASSERT, nutDeviceList, NutDeviceLookup(), and rc.
Referenced by InitDebugDevice(), main(), NutRegisterOwiBus_Uart(), and NutRegisterSpiDevice().
int NullIOCTL | ( | NUTDEVICE * | dev, |
int | req, | ||
void * | conf | ||
) |
Perform control functions.
This function is called by the ioctl() function of the C runtime library.
dev | Identifies the device that receives the device-control function. |
req | Requested control function. We do return ok for any function |
conf | Points to a buffer that contains any data required for the given control function or receives data from that function. |
NUTDEVICE* nutDeviceList = 0 |
Linked list of all registered devices.
Referenced by MmCardMount(), NutDeviceLookupType(), NutIpOutput(), NutRegisterDevice(), and SpiMmcMount().