⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 io.h

📁 56f8300E系列dsp的BOOTloader
💻 H
字号:
/*******************************************************************************
*
* Motorola Inc.
* (c) Copyright 2002 Motorola, Inc.
* ALL RIGHTS RESERVED.
*
* $Element: /project/dsp568_sdk/sdk/src/dsp56838evm/nos/include/io.h $ 
* $Author: saa $ 
* $Revision: /main/2 $ 
* $VOB: /project/dsp568_sdk $ 
* $OS: solaris $ 
*
* Description:  POSIX interface support to peripheral devices
*
* Notes:          
*
******************************************************************************/


#ifndef __IO_H
#define __IO_H


#include "port.h"

#include "stdlib.h"

#ifdef __cplusplus
extern "C" {
#endif



/* values for OFlags */

#define O_RDONLY   0x0001 
#define O_WRONLY   0x0002
#define O_RDWR     0x0003
#define O_NONBLOCK 0x0008 /* non blocking I/O */
#define O_BLOCK    0x0000 /* blocking I/O */


typedef void DEV_HEADER;

#define IO_OFFSET( iotype, mem ) ((int)&((iotype*)0)->mem)

typedef const struct 
{
	ssize_t  (*pRead)(handle_t hndl, void *buf, size_t);
	ssize_t  (*pWrite)(handle_t hndl, const void *buf, size_t len);
	int      (*pClose)(handle_t hndl);
	UWord16  (*pIoctl[1])(handle_t hndl, UWord16 Cmd, unsigned long params );
} io_sInterface;


enum  io_offsets {
    io_read_off = IO_OFFSET(io_sInterface, pRead ),
    io_write_off = IO_OFFSET(io_sInterface, pWrite ),
    io_close_off = IO_OFFSET(io_sInterface, pClose ),
    io_ioctl0_off = IO_OFFSET(io_sInterface, pIoctl[0] )
};


struct io_sDevice {
    handle_t (*pOpen)(const char *pName, int OFlags, ...);
    int tag_name;
    handle_t (*pPreOpen)(const char *pName, int OFlags, ...);
    unsigned int rname;
#if 0
    unsigned long base_name;
    char ext_name[2];
#endif
} ;

enum  device_offsets {
    dev_open = IO_OFFSET( struct io_sDevice, pOpen ),
    dev_tag_name = IO_OFFSET( struct io_sDevice, tag_name ),
    dev_preopen = IO_OFFSET( struct io_sDevice, pPreOpen ),
    dev_rname = IO_OFFSET( struct io_sDevice, rname ),
};




#define IO_NULL_DEVICE_HANDLE ((io_sDevice *) -1)
#define IO_INVALID_HANDLE ((handle_t) -1)



handle_t open(const char *pName, int OFlags, ...);


/*****************************************************************************
*
* IOCTL
*
* Implementation Status:
*     IMPLEMENTED
*
* Semantics:
*     The function ioctl() provides for control over opened I/O devices. 
*     The argument FileDesc is a file descriptor that is associated with 
*     the I/O device. Most requests are passed on to the driver for handling.
*
*     The available values for Cmd are defined by the I/O device driver.
*
* Return Value: 
*     Upon successful completion, the value returned will depend on Cmd.
*     Otherwise, a value of -1 will be returned.
*
*****************************************************************************/
UWord16 ioctl( handle_t FileDesc,  UWord16 Cmd,  unsigned long params );


/*****************************************************************************
*
* CLOSE
*
* Implementation Status:
*     IMPLEMENTED
*
* Semantics:
*     The close() function will deallocate the file descriptor indicated 
*     by FileDesc.
*
* Return Value: 
*     Upon successful completion, a value of zero will be returned. Otherwise,
*     a value of -1 will be returned.
*
*****************************************************************************/
UWord16 close(handle_t FileDesc);



/*****************************************************************************
*
* WRITE
*
* Implementation Status:
*     IMPLEMENTED
*
* Semantics:
*     The write() function will attempt to write NBytes bytes from the 
*     buffer pointed to by pBuffer to the file associated with the open 
*     file descriptor, FileDesc.
*
*    If O_NONBLOCK is clear, write() will block the calling thread until 
*    all data is written. Upon exit, it will return NBytes.
*
*    If O_NONBLOCK is set, write() will write what it can and return the 
*    number of bytes written. Otherwise, it will return -1.
*
* Return Value: 
*    Upon successful completion, write() will return an integer indicating 
*    the number of bytes actually written. Otherwise, it will return a 
*    value of -1.
*
*****************************************************************************/
ssize_t write(handle_t FileDesc, const void * pBuffer, size_t NBytes);



/*****************************************************************************
*
* READ
*
* Implementation Status:
*     IMPLEMENTED
*
* Semantics:
*     The read() function will attempt to read NBytes bytes from the file   
*     associated with the open file descriptor, FileDesc, into the buffer 
*     pointed to by pBuffer.
*
*     If NBytes is zero, the read() function will return zero and will have
*     no other results.
*
*     Upon successful completion, the read() function will return the number 
*     of bytes actually read and placed in the buffer.
*
*     When attempting to read a file and no data currently available:
*        (1) If O_NONBLOCK is set, read() will return -1.
*        (2) If O_NONBLACK is clear, read() will block the calling thread 
*            until some data is available.
*        (3) The use of the O_NONBLOCK flag has no effect if there is some 
*            data available.
*
* Return Value: 
*     Upon successful completion, read() will return an integer indicating 
*     the number of bytes actually read. Otherwise, read() will return a 
*     value of -1.
*
*****************************************************************************/
ssize_t read(handle_t FileDesc,  void * pBuffer, size_t NBytes);



/*****************************************************************************/
unsigned long no_preOpen(const char *pName, int OFlags, ...);
handle_t no_open(const char *pName, int OFlags, ...);
unsigned int no_ioctl( handle_t FileDesc,  unsigned long params );
int no_close( handle_t FileDesc);
ssize_t no_write(handle_t FileDesc, const void * pBuffer, size_t NBytes);
ssize_t no_read(handle_t FileDesc,  void * pBuffer, size_t NBytes);


#ifdef __cplusplus
}
#endif

#endif

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -