/*
* @file hv_drv_UsbPortingOsTypes.h
* @brief Header file of usb adapting to os about types self define.
*
* @author HiView SoC Software Team
* @version 1.0.0
* @date 2022-06-15
*/

#ifndef __HV_DRV_USB_PORTING_OS_TYPES_H
#define __HV_DRV_USB_PORTING_OS_TYPES_H

#include "hv_drv_UsbPortingTypes.h"


typedef u32             OS_ADDRWORD;
typedef u32             os_dir;
typedef u64             u64;
typedef unsigned int    os_mode_t;
typedef unsigned short  nlink_t;
typedef long            off_t;
typedef unsigned short  gid_t;
typedef unsigned short  uid_t;
typedef int             pid_t;
typedef u32             os_ucount32;
typedef u16             os_ucount16;

#define OSARC_ALIGNMENT 8

struct os_timespec {
    time_t      tv_sec;
    long        tv_nsec;
};

#define OS_CHECK_DATA_PTRC(ptr)
#define OSPKG_FILEIO_DIRENT_DTYPE
#define OS_REPORT_RETURN()
#define OSNUM_FILEIO_IOVEC_MAX 64

#define NAME_MAX 64
#define SSIZE_MAX 32767

struct dirent {
#ifdef OSPKG_FILEIO_DIRENT_DTYPE
    os_mode_t      d_type; // Only supported with FATFS, RAMFS, ROMFS,
#endif
    char        d_name[NAME_MAX+1];
};

#define __THROW

#define PATH_MAX 255

#define OPEN_MAX 64

#define OSNUM_FILEIO_FSTAB_MAX 2
#define OSNUM_FILEIO_MTAB_MAX 4

#define OS_HAL_TABLE_TYPE

#define OSNUM_FILEIO_NFD 16

#define OSNUM_FILEIO_NFILE 16

#define OS_REPORT_FUNCTYPE(xx)

#define OS_MACRO_START do {
#define OS_MACRO_END   } while (0)
#define OS_EMPTY_STATEMENT OS_MACRO_START OS_MACRO_END
#define OS_REPORT_RETVAL( _value_ )

typedef int os_errno;


/* CONSTANT DEFINITIONS */

/* If adding to this list, you must also update strerror() with its text
 * If there is a common error of the same purpose on Unix, try and use its
 * name and number. If not, use one above 200 to prevent future conflicts
 *
 * Do not use negative numbers, so that functions can return positive on
 * success and -ESOMETHING on error, and it all works consistently.
*/


//=============================================================================
// Synchronization modes
// These values are filled into the syncmode fields of the above structures
// and define the synchronization protocol used when accessing the object in
// question.

#define OS_SYNCMODE_NONE               (0)     // no locking required

#define OS_SYNCMODE_FILE_FILESYSTEM    0x0002  // lock fs during file ops
#define OS_SYNCMODE_FILE_MOUNTPOINT    0x0004  // lock mte during file ops
#define OS_SYNCMODE_IO_FILE            0x0010  // lock file during io ops
#define OS_SYNCMODE_IO_FILESYSTEM      0x0020  // lock fs during io ops
#define OS_SYNCMODE_IO_MOUNTPOINT      0x0040  // lock mte during io ops
#define OS_SYNCMODE_SOCK_FILE          0x0100  // lock socket during socket ops
#define OS_SYNCMODE_SOCK_NETSTACK      0x0800  // lock netstack during socket ops

#define OS_SYNCMODE_IO_SHIFT           (4)     // shift for IO to file bits
#define OS_SYNCMODE_SOCK_SHIFT         (8)     // shift for sock to file bits


#define OS_IO_GET_CONFIG_DISK_INFO     0x700

#define OS_IO_SET_CONFIG_DISK_MOUNT    0x781
#define OS_IO_SET_CONFIG_DISK_UMOUNT   0x782

#endif
