Merge pull request #4427 from mysterywolf/components

[components] auto & manual formatted
This commit is contained in:
Bernard Xiong 2021-03-16 13:53:54 +08:00 committed by GitHub
commit b12615f344
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
413 changed files with 6752 additions and 6749 deletions

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2006-2018, RT-Thread Development Team * Copyright (c) 2006-2021, RT-Thread Development Team
* *
* SPDX-License-Identifier: Apache-2.0 * SPDX-License-Identifier: Apache-2.0
* *

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2006-2018, RT-Thread Development Team * Copyright (c) 2006-2021, RT-Thread Development Team
* *
* SPDX-License-Identifier: Apache-2.0 * SPDX-License-Identifier: Apache-2.0
* *

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2006-2018, RT-Thread Development Team * Copyright (c) 2006-2021, RT-Thread Development Team
* *
* SPDX-License-Identifier: Apache-2.0 * SPDX-License-Identifier: Apache-2.0
* *

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2006-2018, RT-Thread Development Team * Copyright (c) 2006-2021, RT-Thread Development Team
* *
* SPDX-License-Identifier: Apache-2.0 * SPDX-License-Identifier: Apache-2.0
* *

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2006-2018, RT-Thread Development Team * Copyright (c) 2006-2021, RT-Thread Development Team
* *
* SPDX-License-Identifier: Apache-2.0 * SPDX-License-Identifier: Apache-2.0
* *

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2006-2018, RT-Thread Development Team * Copyright (c) 2006-2021, RT-Thread Development Team
* *
* SPDX-License-Identifier: Apache-2.0 * SPDX-License-Identifier: Apache-2.0
* *

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2006-2018, RT-Thread Development Team * Copyright (c) 2006-2021, RT-Thread Development Team
* *
* SPDX-License-Identifier: Apache-2.0 * SPDX-License-Identifier: Apache-2.0
* *

View File

@ -1,15 +1,15 @@
/* /*
* Copyright (c) 2006-2018, RT-Thread Development Team * Copyright (c) 2006-2021, RT-Thread Development Team
* *
* SPDX-License-Identifier: Apache-2.0 * SPDX-License-Identifier: Apache-2.0
* *
* Change Logs: * Change Logs:
* Date Author Notes * Date Author Notes
* 2014-12-03 Bernard Add copyright header. * 2014-12-03 Bernard Add copyright header.
* 2014-12-29 Bernard Add cplusplus initialization for ARMCC. * 2014-12-29 Bernard Add cplusplus initialization for ARMCC.
* 2016-06-28 Bernard Add _init/_fini routines for GCC. * 2016-06-28 Bernard Add _init/_fini routines for GCC.
* 2016-10-02 Bernard Add WEAK for cplusplus_system_init routine. * 2016-10-02 Bernard Add WEAK for cplusplus_system_init routine.
*/ */
#include <rtthread.h> #include <rtthread.h>

View File

@ -1,11 +1,12 @@
/* /*
* Copyright (c) 2006-2018, RT-Thread Development Team * Copyright (c) 2006-2021, RT-Thread Development Team
* *
* SPDX-License-Identifier: Apache-2.0 * SPDX-License-Identifier: Apache-2.0
* *
* Change Logs: * Change Logs:
* Date Author Notes * Date Author Notes
*/ */
#include "Mutex.h" #include "Mutex.h"
using namespace rtthread; using namespace rtthread;

View File

@ -1,11 +1,12 @@
/* /*
* Copyright (c) 2006-2018, RT-Thread Development Team * Copyright (c) 2006-2021, RT-Thread Development Team
* *
* SPDX-License-Identifier: Apache-2.0 * SPDX-License-Identifier: Apache-2.0
* *
* Change Logs: * Change Logs:
* Date Author Notes * Date Author Notes
*/ */
#include "Semaphore.h" #include "Semaphore.h"
using namespace rtthread; using namespace rtthread;

View File

@ -1,11 +1,12 @@
/* /*
* Copyright (c) 2006-2018, RT-Thread Development Team * Copyright (c) 2006-2021, RT-Thread Development Team
* *
* SPDX-License-Identifier: Apache-2.0 * SPDX-License-Identifier: Apache-2.0
* *
* Change Logs: * Change Logs:
* Date Author Notes * Date Author Notes
*/ */
#include "Thread.h" #include "Thread.h"
using namespace rtthread; using namespace rtthread;

View File

@ -1,12 +1,12 @@
/* /*
* Copyright (c) 2006-2018, RT-Thread Development Team * Copyright (c) 2006-2021, RT-Thread Development Team
* *
* SPDX-License-Identifier: Apache-2.0 * SPDX-License-Identifier: Apache-2.0
* *
* Change Logs: * Change Logs:
* Date Author Notes * Date Author Notes
* 2015-03-07 Bernard Add copyright header. * 2015-03-07 Bernard Add copyright header.
*/ */
#include <rtthread.h> #include <rtthread.h>
#include "crt.h" #include "crt.h"

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2006-2018, RT-Thread Development Team * Copyright (c) 2006-2021, RT-Thread Development Team
* *
* SPDX-License-Identifier: Apache-2.0 * SPDX-License-Identifier: Apache-2.0
* *
@ -271,7 +271,7 @@ int dfs_device_fs_getdents(struct dfs_fd *file, struct dirent *dirp, uint32_t co
if (count == 0) if (count == 0)
return -EINVAL; return -EINVAL;
for (index = 0; index < count && index + root_dirent->read_index < root_dirent->device_count; for (index = 0; index < count && index + root_dirent->read_index < root_dirent->device_count;
index ++) index ++)
{ {
object = (rt_object_t)root_dirent->devices[root_dirent->read_index + index]; object = (rt_object_t)root_dirent->devices[root_dirent->read_index + index];

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2006-2018, RT-Thread Development Team * Copyright (c) 2006-2021, RT-Thread Development Team
* *
* SPDX-License-Identifier: Apache-2.0 * SPDX-License-Identifier: Apache-2.0
* *

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2006-2018, RT-Thread Development Team * Copyright (c) 2006-2021, RT-Thread Development Team
* *
* SPDX-License-Identifier: Apache-2.0 * SPDX-License-Identifier: Apache-2.0
* *

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2006-2018, RT-Thread Development Team * Copyright (c) 2006-2021, RT-Thread Development Team
* *
* SPDX-License-Identifier: Apache-2.0 * SPDX-License-Identifier: Apache-2.0
* *

View File

@ -10,15 +10,15 @@ extern "C" {
#endif #endif
/* Status of Disk Functions */ /* Status of Disk Functions */
typedef BYTE DSTATUS; typedef BYTE DSTATUS;
/* Results of Disk Functions */ /* Results of Disk Functions */
typedef enum { typedef enum {
RES_OK = 0, /* 0: Successful */ RES_OK = 0, /* 0: Successful */
RES_ERROR, /* 1: R/W Error */ RES_ERROR, /* 1: R/W Error */
RES_WRPRT, /* 2: Write Protected */ RES_WRPRT, /* 2: Write Protected */
RES_NOTRDY, /* 3: Not Ready */ RES_NOTRDY, /* 3: Not Ready */
RES_PARERR /* 4: Invalid Parameter */ RES_PARERR /* 4: Invalid Parameter */
} DRESULT; } DRESULT;
@ -35,40 +35,40 @@ DRESULT disk_ioctl (BYTE pdrv, BYTE cmd, void* buff);
/* Disk Status Bits (DSTATUS) */ /* Disk Status Bits (DSTATUS) */
#define STA_NOINIT 0x01 /* Drive not initialized */ #define STA_NOINIT 0x01 /* Drive not initialized */
#define STA_NODISK 0x02 /* No medium in the drive */ #define STA_NODISK 0x02 /* No medium in the drive */
#define STA_PROTECT 0x04 /* Write protected */ #define STA_PROTECT 0x04 /* Write protected */
/* Command code for disk_ioctrl fucntion */ /* Command code for disk_ioctrl fucntion */
/* Generic command (Used by FatFs) */ /* Generic command (Used by FatFs) */
#define CTRL_SYNC 0 /* Complete pending write process (needed at FF_FS_READONLY == 0) */ #define CTRL_SYNC 0 /* Complete pending write process (needed at FF_FS_READONLY == 0) */
#define GET_SECTOR_COUNT 1 /* Get media size (needed at FF_USE_MKFS == 1) */ #define GET_SECTOR_COUNT 1 /* Get media size (needed at FF_USE_MKFS == 1) */
#define GET_SECTOR_SIZE 2 /* Get sector size (needed at FF_MAX_SS != FF_MIN_SS) */ #define GET_SECTOR_SIZE 2 /* Get sector size (needed at FF_MAX_SS != FF_MIN_SS) */
#define GET_BLOCK_SIZE 3 /* Get erase block size (needed at FF_USE_MKFS == 1) */ #define GET_BLOCK_SIZE 3 /* Get erase block size (needed at FF_USE_MKFS == 1) */
#define CTRL_TRIM 4 /* Inform device that the data on the block of sectors is no longer used (needed at FF_USE_TRIM == 1) */ #define CTRL_TRIM 4 /* Inform device that the data on the block of sectors is no longer used (needed at FF_USE_TRIM == 1) */
/* Generic command (Not used by FatFs) */ /* Generic command (Not used by FatFs) */
#define CTRL_POWER 5 /* Get/Set power status */ #define CTRL_POWER 5 /* Get/Set power status */
#define CTRL_LOCK 6 /* Lock/Unlock media removal */ #define CTRL_LOCK 6 /* Lock/Unlock media removal */
#define CTRL_EJECT 7 /* Eject media */ #define CTRL_EJECT 7 /* Eject media */
#define CTRL_FORMAT 8 /* Create physical format on the media */ #define CTRL_FORMAT 8 /* Create physical format on the media */
/* MMC/SDC specific ioctl command */ /* MMC/SDC specific ioctl command */
#define MMC_GET_TYPE 10 /* Get card type */ #define MMC_GET_TYPE 10 /* Get card type */
#define MMC_GET_CSD 11 /* Get CSD */ #define MMC_GET_CSD 11 /* Get CSD */
#define MMC_GET_CID 12 /* Get CID */ #define MMC_GET_CID 12 /* Get CID */
#define MMC_GET_OCR 13 /* Get OCR */ #define MMC_GET_OCR 13 /* Get OCR */
#define MMC_GET_SDSTAT 14 /* Get SD status */ #define MMC_GET_SDSTAT 14 /* Get SD status */
#define ISDIO_READ 55 /* Read data form SD iSDIO register */ #define ISDIO_READ 55 /* Read data form SD iSDIO register */
#define ISDIO_WRITE 56 /* Write data to SD iSDIO register */ #define ISDIO_WRITE 56 /* Write data to SD iSDIO register */
#define ISDIO_MRITE 57 /* Masked write data to SD iSDIO register */ #define ISDIO_MRITE 57 /* Masked write data to SD iSDIO register */
/* ATA/CF specific ioctl command */ /* ATA/CF specific ioctl command */
#define ATA_GET_REV 20 /* Get F/W revision */ #define ATA_GET_REV 20 /* Get F/W revision */
#define ATA_GET_MODEL 21 /* Get model name */ #define ATA_GET_MODEL 21 /* Get model name */
#define ATA_GET_SN 22 /* Get serial number */ #define ATA_GET_SN 22 /* Get serial number */
#ifdef __cplusplus #ifdef __cplusplus
} }

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2006-2018, RT-Thread Development Team * Copyright (c) 2006-2021, RT-Thread Development Team
* *
* SPDX-License-Identifier: Apache-2.0 * SPDX-License-Identifier: Apache-2.0
* *

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2006-2018, RT-Thread Development Team * Copyright (c) 2006-2021, RT-Thread Development Team
* *
* SPDX-License-Identifier: Apache-2.0 * SPDX-License-Identifier: Apache-2.0
* *

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2006-2018, RT-Thread Development Team * Copyright (c) 2006-2021, RT-Thread Development Team
* *
* SPDX-License-Identifier: Apache-2.0 * SPDX-License-Identifier: Apache-2.0
* *
@ -12,7 +12,7 @@
*/ */
#ifndef _MOUNT_H_RPCGEN #ifndef _MOUNT_H_RPCGEN
#define _MOUNT_H_RPCGEN #define _MOUNT_H_RPCGEN
#include <rpc/rpc.h> #include <rpc/rpc.h>
@ -23,13 +23,13 @@ extern "C" {
/* This file is copied from RFC1813 /* This file is copied from RFC1813
* Copyright 1995 Sun Micrososystems (I assume) * Copyright 1995 Sun Micrososystems (I assume)
*/ */
#define MNTPATHLEN 1024 #define MNTPATHLEN 1024
#define MNTNAMLEN 255 #define MNTNAMLEN 255
#define FHSIZE3 64 #define FHSIZE3 64
typedef struct { typedef struct {
unsigned int fhandle3_len; unsigned int fhandle3_len;
char *fhandle3_val; char *fhandle3_val;
} fhandle3; } fhandle3;
typedef char *dirpath; typedef char *dirpath;
@ -43,70 +43,70 @@ typedef struct groupnode *groups;
typedef struct mountbody *mountlist; typedef struct mountbody *mountlist;
enum mountstat3 { enum mountstat3 {
MNT3_OK = 0, MNT3_OK = 0,
MNT3ERR_PERM = 1, MNT3ERR_PERM = 1,
MNT3ERR_NOENT = 2, MNT3ERR_NOENT = 2,
MNT3ERR_IO = 5, MNT3ERR_IO = 5,
MNT3ERR_ACCES = 13, MNT3ERR_ACCES = 13,
MNT3ERR_NOTDIR = 20, MNT3ERR_NOTDIR = 20,
MNT3ERR_INVAL = 22, MNT3ERR_INVAL = 22,
MNT3ERR_NAMETOOLONG = 63, MNT3ERR_NAMETOOLONG = 63,
MNT3ERR_NOTSUPP = 10004, MNT3ERR_NOTSUPP = 10004,
MNT3ERR_SERVERFAULT = 10006 MNT3ERR_SERVERFAULT = 10006
}; };
typedef enum mountstat3 mountstat3; typedef enum mountstat3 mountstat3;
struct mountres3_ok { struct mountres3_ok {
fhandle3 fhandle; fhandle3 fhandle;
struct { struct {
unsigned int auth_flavors_len; unsigned int auth_flavors_len;
int *auth_flavors_val; int *auth_flavors_val;
} auth_flavors; } auth_flavors;
}; };
typedef struct mountres3_ok mountres3_ok; typedef struct mountres3_ok mountres3_ok;
struct mountres3 { struct mountres3 {
mountstat3 fhs_status; mountstat3 fhs_status;
union { union {
mountres3_ok mountinfo; mountres3_ok mountinfo;
} mountres3_u; } mountres3_u;
}; };
typedef struct mountres3 mountres3; typedef struct mountres3 mountres3;
struct mountbody { struct mountbody {
name ml_hostname; name ml_hostname;
dirpath ml_directory; dirpath ml_directory;
mountlist ml_next; mountlist ml_next;
}; };
typedef struct mountbody mountbody; typedef struct mountbody mountbody;
struct groupnode { struct groupnode {
name gr_name; name gr_name;
groups gr_next; groups gr_next;
}; };
typedef struct groupnode groupnode; typedef struct groupnode groupnode;
struct exportnode { struct exportnode {
dirpath ex_dir; dirpath ex_dir;
groups ex_groups; groups ex_groups;
exports ex_next; exports ex_next;
}; };
typedef struct exportnode exportnode; typedef struct exportnode exportnode;
#define MOUNT_PROGRAM 100005 #define MOUNT_PROGRAM 100005
#define MOUNT_V3 3 #define MOUNT_V3 3
#define MOUNTPROC3_NULL 0 #define MOUNTPROC3_NULL 0
extern enum clnt_stat mountproc3_null_3(void *, CLIENT *); extern enum clnt_stat mountproc3_null_3(void *, CLIENT *);
#define MOUNTPROC3_MNT 1 #define MOUNTPROC3_MNT 1
extern enum clnt_stat mountproc3_mnt_3(dirpath , mountres3 *, CLIENT *); extern enum clnt_stat mountproc3_mnt_3(dirpath , mountres3 *, CLIENT *);
#define MOUNTPROC3_DUMP 2 #define MOUNTPROC3_DUMP 2
extern enum clnt_stat mountproc3_dump_3(mountlist *, CLIENT *); extern enum clnt_stat mountproc3_dump_3(mountlist *, CLIENT *);
#define MOUNTPROC3_UMNT 3 #define MOUNTPROC3_UMNT 3
extern enum clnt_stat mountproc3_umnt_3(dirpath , void *, CLIENT *); extern enum clnt_stat mountproc3_umnt_3(dirpath , void *, CLIENT *);
#define MOUNTPROC3_UMNTALL 4 #define MOUNTPROC3_UMNTALL 4
extern enum clnt_stat mountproc3_umntall_3(void *, CLIENT *); extern enum clnt_stat mountproc3_umntall_3(void *, CLIENT *);
#define MOUNTPROC3_EXPORT 5 #define MOUNTPROC3_EXPORT 5
extern enum clnt_stat mountproc3_export_3(exports *, CLIENT *); extern enum clnt_stat mountproc3_export_3(exports *, CLIENT *);
/* the xdr functions */ /* the xdr functions */

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2006-2018, RT-Thread Development Team * Copyright (c) 2006-2021, RT-Thread Development Team
* *
* SPDX-License-Identifier: Apache-2.0 * SPDX-License-Identifier: Apache-2.0
* *
@ -23,56 +23,56 @@ typedef char* caddr_t;
/* Default timeout can be changed using clnt_control() */ /* Default timeout can be changed using clnt_control() */
static struct timeval TIMEOUT = { 25, 0 }; static struct timeval TIMEOUT = { 25, 0 };
enum clnt_stat enum clnt_stat
mountproc3_null_3(void *clnt_res, CLIENT *clnt) mountproc3_null_3(void *clnt_res, CLIENT *clnt)
{ {
return (clnt_call(clnt, MOUNTPROC3_NULL, return (clnt_call(clnt, MOUNTPROC3_NULL,
(xdrproc_t) xdr_void, (caddr_t) NULL, (xdrproc_t) xdr_void, (caddr_t) NULL,
(xdrproc_t) xdr_void, (caddr_t) clnt_res, (xdrproc_t) xdr_void, (caddr_t) clnt_res,
TIMEOUT)); TIMEOUT));
} }
enum clnt_stat enum clnt_stat
mountproc3_mnt_3(dirpath arg1, mountres3 *clnt_res, CLIENT *clnt) mountproc3_mnt_3(dirpath arg1, mountres3 *clnt_res, CLIENT *clnt)
{ {
return (clnt_call(clnt, MOUNTPROC3_MNT, return (clnt_call(clnt, MOUNTPROC3_MNT,
(xdrproc_t) xdr_dirpath, (caddr_t) &arg1, (xdrproc_t) xdr_dirpath, (caddr_t) &arg1,
(xdrproc_t) xdr_mountres3, (caddr_t) clnt_res, (xdrproc_t) xdr_mountres3, (caddr_t) clnt_res,
TIMEOUT)); TIMEOUT));
} }
enum clnt_stat enum clnt_stat
mountproc3_dump_3(mountlist *clnt_res, CLIENT *clnt) mountproc3_dump_3(mountlist *clnt_res, CLIENT *clnt)
{ {
return (clnt_call(clnt, MOUNTPROC3_DUMP, return (clnt_call(clnt, MOUNTPROC3_DUMP,
(xdrproc_t) xdr_void, (caddr_t) NULL, (xdrproc_t) xdr_void, (caddr_t) NULL,
(xdrproc_t) xdr_mountlist, (caddr_t) clnt_res, (xdrproc_t) xdr_mountlist, (caddr_t) clnt_res,
TIMEOUT)); TIMEOUT));
} }
enum clnt_stat enum clnt_stat
mountproc3_umnt_3(dirpath arg1, void *clnt_res, CLIENT *clnt) mountproc3_umnt_3(dirpath arg1, void *clnt_res, CLIENT *clnt)
{ {
return (clnt_call(clnt, MOUNTPROC3_UMNT, return (clnt_call(clnt, MOUNTPROC3_UMNT,
(xdrproc_t) xdr_dirpath, (caddr_t) &arg1, (xdrproc_t) xdr_dirpath, (caddr_t) &arg1,
(xdrproc_t) xdr_void, (caddr_t) clnt_res, (xdrproc_t) xdr_void, (caddr_t) clnt_res,
TIMEOUT)); TIMEOUT));
} }
enum clnt_stat enum clnt_stat
mountproc3_umntall_3(void *clnt_res, CLIENT *clnt) mountproc3_umntall_3(void *clnt_res, CLIENT *clnt)
{ {
return (clnt_call(clnt, MOUNTPROC3_UMNTALL, return (clnt_call(clnt, MOUNTPROC3_UMNTALL,
(xdrproc_t) xdr_void, (caddr_t) NULL, (xdrproc_t) xdr_void, (caddr_t) NULL,
(xdrproc_t) xdr_void, (caddr_t) clnt_res, (xdrproc_t) xdr_void, (caddr_t) clnt_res,
TIMEOUT)); TIMEOUT));
} }
enum clnt_stat enum clnt_stat
mountproc3_export_3(exports *clnt_res, CLIENT *clnt) mountproc3_export_3(exports *clnt_res, CLIENT *clnt)
{ {
return (clnt_call(clnt, MOUNTPROC3_EXPORT, return (clnt_call(clnt, MOUNTPROC3_EXPORT,
(xdrproc_t) xdr_void, (caddr_t) NULL, (xdrproc_t) xdr_void, (caddr_t) NULL,
(xdrproc_t) xdr_exports, (caddr_t) clnt_res, (xdrproc_t) xdr_exports, (caddr_t) clnt_res,
TIMEOUT)); TIMEOUT));
} }

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2006-2018, RT-Thread Development Team * Copyright (c) 2006-2021, RT-Thread Development Team
* *
* SPDX-License-Identifier: Apache-2.0 * SPDX-License-Identifier: Apache-2.0
* *
@ -19,124 +19,124 @@
bool_t bool_t
xdr_fhandle3(register XDR *xdrs, fhandle3 *objp) xdr_fhandle3(register XDR *xdrs, fhandle3 *objp)
{ {
if (!xdr_bytes(xdrs, (char **)&objp->fhandle3_val, (unsigned int *) &objp->fhandle3_len, FHSIZE3)) if (!xdr_bytes(xdrs, (char **)&objp->fhandle3_val, (unsigned int *) &objp->fhandle3_len, FHSIZE3))
return (FALSE); return (FALSE);
return (TRUE); return (TRUE);
} }
bool_t bool_t
xdr_dirpath(register XDR *xdrs, dirpath *objp) xdr_dirpath(register XDR *xdrs, dirpath *objp)
{ {
if (!xdr_string(xdrs, objp, MNTPATHLEN)) if (!xdr_string(xdrs, objp, MNTPATHLEN))
return (FALSE); return (FALSE);
return (TRUE); return (TRUE);
} }
bool_t bool_t
xdr_name(register XDR *xdrs, name *objp) xdr_name(register XDR *xdrs, name *objp)
{ {
if (!xdr_string(xdrs, objp, MNTNAMLEN)) if (!xdr_string(xdrs, objp, MNTNAMLEN))
return (FALSE); return (FALSE);
return (TRUE); return (TRUE);
} }
bool_t bool_t
xdr_exports(register XDR *xdrs, exports *objp) xdr_exports(register XDR *xdrs, exports *objp)
{ {
if (!xdr_pointer(xdrs, (char **)objp, sizeof (struct exportnode), (xdrproc_t) xdr_exportnode)) if (!xdr_pointer(xdrs, (char **)objp, sizeof (struct exportnode), (xdrproc_t) xdr_exportnode))
return (FALSE); return (FALSE);
return (TRUE); return (TRUE);
} }
bool_t bool_t
xdr_groups(register XDR *xdrs, groups *objp) xdr_groups(register XDR *xdrs, groups *objp)
{ {
if (!xdr_pointer(xdrs, (char **)objp, sizeof (struct groupnode), (xdrproc_t) xdr_groupnode)) if (!xdr_pointer(xdrs, (char **)objp, sizeof (struct groupnode), (xdrproc_t) xdr_groupnode))
return (FALSE); return (FALSE);
return (TRUE); return (TRUE);
} }
bool_t bool_t
xdr_mountlist(register XDR *xdrs, mountlist *objp) xdr_mountlist(register XDR *xdrs, mountlist *objp)
{ {
if (!xdr_pointer(xdrs, (char **)objp, sizeof (struct mountbody), (xdrproc_t) xdr_mountbody)) if (!xdr_pointer(xdrs, (char **)objp, sizeof (struct mountbody), (xdrproc_t) xdr_mountbody))
return (FALSE); return (FALSE);
return (TRUE); return (TRUE);
} }
bool_t bool_t
xdr_mountstat3(register XDR *xdrs, mountstat3 *objp) xdr_mountstat3(register XDR *xdrs, mountstat3 *objp)
{ {
int enum_objp; int enum_objp;
enum_objp = *objp; enum_objp = *objp;
if (!xdr_enum(xdrs, (enum_t *)&enum_objp)) if (!xdr_enum(xdrs, (enum_t *)&enum_objp))
{ {
*objp = (mountstat3)enum_objp; *objp = (mountstat3)enum_objp;
return (FALSE); return (FALSE);
} }
return (TRUE); return (TRUE);
} }
bool_t bool_t
xdr_mountres3_ok(register XDR *xdrs, mountres3_ok *objp) xdr_mountres3_ok(register XDR *xdrs, mountres3_ok *objp)
{ {
if (!xdr_fhandle3(xdrs, &objp->fhandle)) if (!xdr_fhandle3(xdrs, &objp->fhandle))
return (FALSE); return (FALSE);
if (!xdr_array(xdrs, (char **)&objp->auth_flavors.auth_flavors_val, (unsigned int *) &objp->auth_flavors.auth_flavors_len, ~0, if (!xdr_array(xdrs, (char **)&objp->auth_flavors.auth_flavors_val, (unsigned int *) &objp->auth_flavors.auth_flavors_len, ~0,
sizeof (int), (xdrproc_t) xdr_int)) sizeof (int), (xdrproc_t) xdr_int))
return (FALSE); return (FALSE);
return (TRUE); return (TRUE);
} }
bool_t bool_t
xdr_mountres3(register XDR *xdrs, mountres3 *objp) xdr_mountres3(register XDR *xdrs, mountres3 *objp)
{ {
if (!xdr_mountstat3(xdrs, &objp->fhs_status)) if (!xdr_mountstat3(xdrs, &objp->fhs_status))
return (FALSE); return (FALSE);
switch (objp->fhs_status) { switch (objp->fhs_status) {
case MNT3_OK: case MNT3_OK:
if (!xdr_mountres3_ok(xdrs, &objp->mountres3_u.mountinfo)) if (!xdr_mountres3_ok(xdrs, &objp->mountres3_u.mountinfo))
return (FALSE); return (FALSE);
break; break;
default : default :
return (FALSE); return (FALSE);
} }
return (TRUE); return (TRUE);
} }
bool_t bool_t
xdr_mountbody(register XDR *xdrs, mountbody *objp) xdr_mountbody(register XDR *xdrs, mountbody *objp)
{ {
if (!xdr_name(xdrs, &objp->ml_hostname)) if (!xdr_name(xdrs, &objp->ml_hostname))
return (FALSE); return (FALSE);
if (!xdr_dirpath(xdrs, &objp->ml_directory)) if (!xdr_dirpath(xdrs, &objp->ml_directory))
return (FALSE); return (FALSE);
if (!xdr_mountlist(xdrs, &objp->ml_next)) if (!xdr_mountlist(xdrs, &objp->ml_next))
return (FALSE); return (FALSE);
return (TRUE); return (TRUE);
} }
bool_t bool_t
xdr_groupnode(register XDR *xdrs, groupnode *objp) xdr_groupnode(register XDR *xdrs, groupnode *objp)
{ {
if (!xdr_name(xdrs, &objp->gr_name)) if (!xdr_name(xdrs, &objp->gr_name))
return (FALSE); return (FALSE);
if (!xdr_groups(xdrs, &objp->gr_next)) if (!xdr_groups(xdrs, &objp->gr_next))
return (FALSE); return (FALSE);
return (TRUE); return (TRUE);
} }
bool_t bool_t
xdr_exportnode(register XDR *xdrs, exportnode *objp) xdr_exportnode(register XDR *xdrs, exportnode *objp)
{ {
if (!xdr_dirpath(xdrs, &objp->ex_dir)) if (!xdr_dirpath(xdrs, &objp->ex_dir))
return (FALSE); return (FALSE);
if (!xdr_groups(xdrs, &objp->ex_groups)) if (!xdr_groups(xdrs, &objp->ex_groups))
return (FALSE); return (FALSE);
if (!xdr_exports(xdrs, &objp->ex_next)) if (!xdr_exports(xdrs, &objp->ex_next))
return (FALSE); return (FALSE);
return (TRUE); return (TRUE);
} }

File diff suppressed because it is too large Load Diff

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2006-2018, RT-Thread Development Team * Copyright (c) 2006-2021, RT-Thread Development Team
* *
* SPDX-License-Identifier: Apache-2.0 * SPDX-License-Identifier: Apache-2.0
* *

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2006-2018, RT-Thread Development Team * Copyright (c) 2006-2021, RT-Thread Development Team
* *
* SPDX-License-Identifier: Apache-2.0 * SPDX-License-Identifier: Apache-2.0
* *
@ -23,200 +23,200 @@ typedef char* caddr_t;
/* Default timeout can be changed using clnt_control() */ /* Default timeout can be changed using clnt_control() */
static struct timeval TIMEOUT = { 25, 0 }; static struct timeval TIMEOUT = { 25, 0 };
enum clnt_stat enum clnt_stat
nfsproc3_null_3(void *clnt_res, CLIENT *clnt) nfsproc3_null_3(void *clnt_res, CLIENT *clnt)
{ {
return (clnt_call(clnt, NFSPROC3_NULL, return (clnt_call(clnt, NFSPROC3_NULL,
(xdrproc_t) xdr_void, (caddr_t) NULL, (xdrproc_t) xdr_void, (caddr_t) NULL,
(xdrproc_t) xdr_void, (caddr_t) clnt_res, (xdrproc_t) xdr_void, (caddr_t) clnt_res,
TIMEOUT)); TIMEOUT));
} }
enum clnt_stat enum clnt_stat
nfsproc3_getattr_3(GETATTR3args arg1, GETATTR3res *clnt_res, CLIENT *clnt) nfsproc3_getattr_3(GETATTR3args arg1, GETATTR3res *clnt_res, CLIENT *clnt)
{ {
return (clnt_call(clnt, NFSPROC3_GETATTR, return (clnt_call(clnt, NFSPROC3_GETATTR,
(xdrproc_t) xdr_GETATTR3args, (caddr_t) &arg1, (xdrproc_t) xdr_GETATTR3args, (caddr_t) &arg1,
(xdrproc_t) xdr_GETATTR3res, (caddr_t) clnt_res, (xdrproc_t) xdr_GETATTR3res, (caddr_t) clnt_res,
TIMEOUT)); TIMEOUT));
} }
enum clnt_stat enum clnt_stat
nfsproc3_setattr_3(SETATTR3args arg1, SETATTR3res *clnt_res, CLIENT *clnt) nfsproc3_setattr_3(SETATTR3args arg1, SETATTR3res *clnt_res, CLIENT *clnt)
{ {
return (clnt_call(clnt, NFSPROC3_SETATTR, return (clnt_call(clnt, NFSPROC3_SETATTR,
(xdrproc_t) xdr_SETATTR3args, (caddr_t) &arg1, (xdrproc_t) xdr_SETATTR3args, (caddr_t) &arg1,
(xdrproc_t) xdr_SETATTR3res, (caddr_t) clnt_res, (xdrproc_t) xdr_SETATTR3res, (caddr_t) clnt_res,
TIMEOUT)); TIMEOUT));
} }
enum clnt_stat enum clnt_stat
nfsproc3_lookup_3(LOOKUP3args arg1, LOOKUP3res *clnt_res, CLIENT *clnt) nfsproc3_lookup_3(LOOKUP3args arg1, LOOKUP3res *clnt_res, CLIENT *clnt)
{ {
return (clnt_call(clnt, NFSPROC3_LOOKUP, return (clnt_call(clnt, NFSPROC3_LOOKUP,
(xdrproc_t) xdr_LOOKUP3args, (caddr_t) &arg1, (xdrproc_t) xdr_LOOKUP3args, (caddr_t) &arg1,
(xdrproc_t) xdr_LOOKUP3res, (caddr_t) clnt_res, (xdrproc_t) xdr_LOOKUP3res, (caddr_t) clnt_res,
TIMEOUT)); TIMEOUT));
} }
enum clnt_stat enum clnt_stat
nfsproc3_access_3(ACCESS3args arg1, ACCESS3res *clnt_res, CLIENT *clnt) nfsproc3_access_3(ACCESS3args arg1, ACCESS3res *clnt_res, CLIENT *clnt)
{ {
return (clnt_call(clnt, NFSPROC3_ACCESS, return (clnt_call(clnt, NFSPROC3_ACCESS,
(xdrproc_t) xdr_ACCESS3args, (caddr_t) &arg1, (xdrproc_t) xdr_ACCESS3args, (caddr_t) &arg1,
(xdrproc_t) xdr_ACCESS3res, (caddr_t) clnt_res, (xdrproc_t) xdr_ACCESS3res, (caddr_t) clnt_res,
TIMEOUT)); TIMEOUT));
} }
enum clnt_stat enum clnt_stat
nfsproc3_readlink_3(READLINK3args arg1, READLINK3res *clnt_res, CLIENT *clnt) nfsproc3_readlink_3(READLINK3args arg1, READLINK3res *clnt_res, CLIENT *clnt)
{ {
return (clnt_call(clnt, NFSPROC3_READLINK, return (clnt_call(clnt, NFSPROC3_READLINK,
(xdrproc_t) xdr_READLINK3args, (caddr_t) &arg1, (xdrproc_t) xdr_READLINK3args, (caddr_t) &arg1,
(xdrproc_t) xdr_READLINK3res, (caddr_t) clnt_res, (xdrproc_t) xdr_READLINK3res, (caddr_t) clnt_res,
TIMEOUT)); TIMEOUT));
} }
enum clnt_stat enum clnt_stat
nfsproc3_read_3(READ3args arg1, READ3res *clnt_res, CLIENT *clnt) nfsproc3_read_3(READ3args arg1, READ3res *clnt_res, CLIENT *clnt)
{ {
return (clnt_call(clnt, NFSPROC3_READ, return (clnt_call(clnt, NFSPROC3_READ,
(xdrproc_t) xdr_READ3args, (caddr_t) &arg1, (xdrproc_t) xdr_READ3args, (caddr_t) &arg1,
(xdrproc_t) xdr_READ3res, (caddr_t) clnt_res, (xdrproc_t) xdr_READ3res, (caddr_t) clnt_res,
TIMEOUT)); TIMEOUT));
} }
enum clnt_stat enum clnt_stat
nfsproc3_write_3(WRITE3args arg1, WRITE3res *clnt_res, CLIENT *clnt) nfsproc3_write_3(WRITE3args arg1, WRITE3res *clnt_res, CLIENT *clnt)
{ {
return (clnt_call(clnt, NFSPROC3_WRITE, return (clnt_call(clnt, NFSPROC3_WRITE,
(xdrproc_t) xdr_WRITE3args, (caddr_t) &arg1, (xdrproc_t) xdr_WRITE3args, (caddr_t) &arg1,
(xdrproc_t) xdr_WRITE3res, (caddr_t) clnt_res, (xdrproc_t) xdr_WRITE3res, (caddr_t) clnt_res,
TIMEOUT)); TIMEOUT));
} }
enum clnt_stat enum clnt_stat
nfsproc3_create_3(CREATE3args arg1, CREATE3res *clnt_res, CLIENT *clnt) nfsproc3_create_3(CREATE3args arg1, CREATE3res *clnt_res, CLIENT *clnt)
{ {
return (clnt_call(clnt, NFSPROC3_CREATE, return (clnt_call(clnt, NFSPROC3_CREATE,
(xdrproc_t) xdr_CREATE3args, (caddr_t) &arg1, (xdrproc_t) xdr_CREATE3args, (caddr_t) &arg1,
(xdrproc_t) xdr_CREATE3res, (caddr_t) clnt_res, (xdrproc_t) xdr_CREATE3res, (caddr_t) clnt_res,
TIMEOUT)); TIMEOUT));
} }
enum clnt_stat enum clnt_stat
nfsproc3_mkdir_3(MKDIR3args arg1, MKDIR3res *clnt_res, CLIENT *clnt) nfsproc3_mkdir_3(MKDIR3args arg1, MKDIR3res *clnt_res, CLIENT *clnt)
{ {
return (clnt_call(clnt, NFSPROC3_MKDIR, return (clnt_call(clnt, NFSPROC3_MKDIR,
(xdrproc_t) xdr_MKDIR3args, (caddr_t) &arg1, (xdrproc_t) xdr_MKDIR3args, (caddr_t) &arg1,
(xdrproc_t) xdr_MKDIR3res, (caddr_t) clnt_res, (xdrproc_t) xdr_MKDIR3res, (caddr_t) clnt_res,
TIMEOUT)); TIMEOUT));
} }
enum clnt_stat enum clnt_stat
nfsproc3_symlink_3(SYMLINK3args arg1, SYMLINK3res *clnt_res, CLIENT *clnt) nfsproc3_symlink_3(SYMLINK3args arg1, SYMLINK3res *clnt_res, CLIENT *clnt)
{ {
return (clnt_call(clnt, NFSPROC3_SYMLINK, return (clnt_call(clnt, NFSPROC3_SYMLINK,
(xdrproc_t) xdr_SYMLINK3args, (caddr_t) &arg1, (xdrproc_t) xdr_SYMLINK3args, (caddr_t) &arg1,
(xdrproc_t) xdr_SYMLINK3res, (caddr_t) clnt_res, (xdrproc_t) xdr_SYMLINK3res, (caddr_t) clnt_res,
TIMEOUT)); TIMEOUT));
} }
enum clnt_stat enum clnt_stat
nfsproc3_mknod_3(MKNOD3args arg1, MKNOD3res *clnt_res, CLIENT *clnt) nfsproc3_mknod_3(MKNOD3args arg1, MKNOD3res *clnt_res, CLIENT *clnt)
{ {
return (clnt_call(clnt, NFSPROC3_MKNOD, return (clnt_call(clnt, NFSPROC3_MKNOD,
(xdrproc_t) xdr_MKNOD3args, (caddr_t) &arg1, (xdrproc_t) xdr_MKNOD3args, (caddr_t) &arg1,
(xdrproc_t) xdr_MKNOD3res, (caddr_t) clnt_res, (xdrproc_t) xdr_MKNOD3res, (caddr_t) clnt_res,
TIMEOUT)); TIMEOUT));
} }
enum clnt_stat enum clnt_stat
nfsproc3_remove_3(REMOVE3args arg1, REMOVE3res *clnt_res, CLIENT *clnt) nfsproc3_remove_3(REMOVE3args arg1, REMOVE3res *clnt_res, CLIENT *clnt)
{ {
return (clnt_call(clnt, NFSPROC3_REMOVE, return (clnt_call(clnt, NFSPROC3_REMOVE,
(xdrproc_t) xdr_REMOVE3args, (caddr_t) &arg1, (xdrproc_t) xdr_REMOVE3args, (caddr_t) &arg1,
(xdrproc_t) xdr_REMOVE3res, (caddr_t) clnt_res, (xdrproc_t) xdr_REMOVE3res, (caddr_t) clnt_res,
TIMEOUT)); TIMEOUT));
} }
enum clnt_stat enum clnt_stat
nfsproc3_rmdir_3(RMDIR3args arg1, RMDIR3res *clnt_res, CLIENT *clnt) nfsproc3_rmdir_3(RMDIR3args arg1, RMDIR3res *clnt_res, CLIENT *clnt)
{ {
return (clnt_call(clnt, NFSPROC3_RMDIR, return (clnt_call(clnt, NFSPROC3_RMDIR,
(xdrproc_t) xdr_RMDIR3args, (caddr_t) &arg1, (xdrproc_t) xdr_RMDIR3args, (caddr_t) &arg1,
(xdrproc_t) xdr_RMDIR3res, (caddr_t) clnt_res, (xdrproc_t) xdr_RMDIR3res, (caddr_t) clnt_res,
TIMEOUT)); TIMEOUT));
} }
enum clnt_stat enum clnt_stat
nfsproc3_rename_3(RENAME3args arg1, RENAME3res *clnt_res, CLIENT *clnt) nfsproc3_rename_3(RENAME3args arg1, RENAME3res *clnt_res, CLIENT *clnt)
{ {
return (clnt_call(clnt, NFSPROC3_RENAME, return (clnt_call(clnt, NFSPROC3_RENAME,
(xdrproc_t) xdr_RENAME3args, (caddr_t) &arg1, (xdrproc_t) xdr_RENAME3args, (caddr_t) &arg1,
(xdrproc_t) xdr_RENAME3res, (caddr_t) clnt_res, (xdrproc_t) xdr_RENAME3res, (caddr_t) clnt_res,
TIMEOUT)); TIMEOUT));
} }
enum clnt_stat enum clnt_stat
nfsproc3_link_3(LINK3args arg1, LINK3res *clnt_res, CLIENT *clnt) nfsproc3_link_3(LINK3args arg1, LINK3res *clnt_res, CLIENT *clnt)
{ {
return (clnt_call(clnt, NFSPROC3_LINK, return (clnt_call(clnt, NFSPROC3_LINK,
(xdrproc_t) xdr_LINK3args, (caddr_t) &arg1, (xdrproc_t) xdr_LINK3args, (caddr_t) &arg1,
(xdrproc_t) xdr_LINK3res, (caddr_t) clnt_res, (xdrproc_t) xdr_LINK3res, (caddr_t) clnt_res,
TIMEOUT)); TIMEOUT));
} }
enum clnt_stat enum clnt_stat
nfsproc3_readdir_3(READDIR3args arg1, READDIR3res *clnt_res, CLIENT *clnt) nfsproc3_readdir_3(READDIR3args arg1, READDIR3res *clnt_res, CLIENT *clnt)
{ {
return (clnt_call(clnt, NFSPROC3_READDIR, return (clnt_call(clnt, NFSPROC3_READDIR,
(xdrproc_t) xdr_READDIR3args, (caddr_t) &arg1, (xdrproc_t) xdr_READDIR3args, (caddr_t) &arg1,
(xdrproc_t) xdr_READDIR3res, (caddr_t) clnt_res, (xdrproc_t) xdr_READDIR3res, (caddr_t) clnt_res,
TIMEOUT)); TIMEOUT));
} }
enum clnt_stat enum clnt_stat
nfsproc3_readdirplus_3(READDIRPLUS3args arg1, READDIRPLUS3res *clnt_res, CLIENT *clnt) nfsproc3_readdirplus_3(READDIRPLUS3args arg1, READDIRPLUS3res *clnt_res, CLIENT *clnt)
{ {
return (clnt_call(clnt, NFSPROC3_READDIRPLUS, return (clnt_call(clnt, NFSPROC3_READDIRPLUS,
(xdrproc_t) xdr_READDIRPLUS3args, (caddr_t) &arg1, (xdrproc_t) xdr_READDIRPLUS3args, (caddr_t) &arg1,
(xdrproc_t) xdr_READDIRPLUS3res, (caddr_t) clnt_res, (xdrproc_t) xdr_READDIRPLUS3res, (caddr_t) clnt_res,
TIMEOUT)); TIMEOUT));
} }
enum clnt_stat enum clnt_stat
nfsproc3_fsstat_3(FSSTAT3args arg1, FSSTAT3res *clnt_res, CLIENT *clnt) nfsproc3_fsstat_3(FSSTAT3args arg1, FSSTAT3res *clnt_res, CLIENT *clnt)
{ {
return (clnt_call(clnt, NFSPROC3_FSSTAT, return (clnt_call(clnt, NFSPROC3_FSSTAT,
(xdrproc_t) xdr_FSSTAT3args, (caddr_t) &arg1, (xdrproc_t) xdr_FSSTAT3args, (caddr_t) &arg1,
(xdrproc_t) xdr_FSSTAT3res, (caddr_t) clnt_res, (xdrproc_t) xdr_FSSTAT3res, (caddr_t) clnt_res,
TIMEOUT)); TIMEOUT));
} }
enum clnt_stat enum clnt_stat
nfsproc3_fsinfo_3(FSINFO3args arg1, FSINFO3res *clnt_res, CLIENT *clnt) nfsproc3_fsinfo_3(FSINFO3args arg1, FSINFO3res *clnt_res, CLIENT *clnt)
{ {
return (clnt_call(clnt, NFSPROC3_FSINFO, return (clnt_call(clnt, NFSPROC3_FSINFO,
(xdrproc_t) xdr_FSINFO3args, (caddr_t) &arg1, (xdrproc_t) xdr_FSINFO3args, (caddr_t) &arg1,
(xdrproc_t) xdr_FSINFO3res, (caddr_t) clnt_res, (xdrproc_t) xdr_FSINFO3res, (caddr_t) clnt_res,
TIMEOUT)); TIMEOUT));
} }
enum clnt_stat enum clnt_stat
nfsproc3_pathconf_3(PATHCONF3args arg1, PATHCONF3res *clnt_res, CLIENT *clnt) nfsproc3_pathconf_3(PATHCONF3args arg1, PATHCONF3res *clnt_res, CLIENT *clnt)
{ {
return (clnt_call(clnt, NFSPROC3_PATHCONF, return (clnt_call(clnt, NFSPROC3_PATHCONF,
(xdrproc_t) xdr_PATHCONF3args, (caddr_t) &arg1, (xdrproc_t) xdr_PATHCONF3args, (caddr_t) &arg1,
(xdrproc_t) xdr_PATHCONF3res, (caddr_t) clnt_res, (xdrproc_t) xdr_PATHCONF3res, (caddr_t) clnt_res,
TIMEOUT)); TIMEOUT));
} }
enum clnt_stat enum clnt_stat
nfsproc3_commit_3(COMMIT3args arg1, COMMIT3res *clnt_res, CLIENT *clnt) nfsproc3_commit_3(COMMIT3args arg1, COMMIT3res *clnt_res, CLIENT *clnt)
{ {
return (clnt_call(clnt, NFSPROC3_COMMIT, return (clnt_call(clnt, NFSPROC3_COMMIT,
(xdrproc_t) xdr_COMMIT3args, (caddr_t) &arg1, (xdrproc_t) xdr_COMMIT3args, (caddr_t) &arg1,
(xdrproc_t) xdr_COMMIT3res, (caddr_t) clnt_res, (xdrproc_t) xdr_COMMIT3res, (caddr_t) clnt_res,
TIMEOUT)); TIMEOUT));
} }

File diff suppressed because it is too large Load Diff

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2006-2018, RT-Thread Development Team * Copyright (c) 2006-2021, RT-Thread Development Team
* *
* SPDX-License-Identifier: Apache-2.0 * SPDX-License-Identifier: Apache-2.0
* *
@ -15,28 +15,28 @@
* Status returned from authentication check * Status returned from authentication check
*/ */
enum auth_stat { enum auth_stat {
AUTH_OK=0, AUTH_OK=0,
/* /*
* failed at remote end * failed at remote end
*/ */
AUTH_BADCRED=1, /* bogus credentials (seal broken) */ AUTH_BADCRED=1, /* bogus credentials (seal broken) */
AUTH_REJECTEDCRED=2, /* client should begin new session */ AUTH_REJECTEDCRED=2, /* client should begin new session */
AUTH_BADVERF=3, /* bogus verifier (seal broken) */ AUTH_BADVERF=3, /* bogus verifier (seal broken) */
AUTH_REJECTEDVERF=4, /* verifier expired or was replayed */ AUTH_REJECTEDVERF=4, /* verifier expired or was replayed */
AUTH_TOOWEAK=5, /* rejected due to security reasons */ AUTH_TOOWEAK=5, /* rejected due to security reasons */
/* /*
* failed locally * failed locally
*/ */
AUTH_INVALIDRESP=6, /* bogus response verifier */ AUTH_INVALIDRESP=6, /* bogus response verifier */
AUTH_FAILED=7 /* some unknown reason */ AUTH_FAILED=7 /* some unknown reason */
}; };
union des_block { union des_block {
struct { struct {
uint32_t high; uint32_t high;
uint32_t low; uint32_t low;
} key; } key;
char c[8]; char c[8];
}; };
typedef union des_block des_block; typedef union des_block des_block;
@ -44,9 +44,9 @@ typedef union des_block des_block;
* Authentication info. Opaque to client. * Authentication info. Opaque to client.
*/ */
struct opaque_auth { struct opaque_auth {
enum_t oa_flavor; /* flavor of auth */ enum_t oa_flavor; /* flavor of auth */
char* oa_base; /* address of more auth stuff */ char* oa_base; /* address of more auth stuff */
unsigned int oa_length; /* not to exceed MAX_AUTH_BYTES */ unsigned int oa_length; /* not to exceed MAX_AUTH_BYTES */
}; };
/* /*
@ -59,11 +59,11 @@ struct AUTH {
union des_block ah_key; union des_block ah_key;
struct auth_ops { struct auth_ops {
void (*ah_nextverf) (AUTH *); void (*ah_nextverf) (AUTH *);
int (*ah_marshal) (AUTH *, XDR *); /* nextverf & serialize */ int (*ah_marshal) (AUTH *, XDR *); /* nextverf & serialize */
int (*ah_validate) (AUTH *, struct opaque_auth *); int (*ah_validate) (AUTH *, struct opaque_auth *);
/* validate verifier */ /* validate verifier */
int (*ah_refresh) (AUTH *); /* refresh credentials */ int (*ah_refresh) (AUTH *); /* refresh credentials */
void (*ah_destroy) (AUTH *); /* destroy this structure */ void (*ah_destroy) (AUTH *); /* destroy this structure */
} *ah_ops; } *ah_ops;
char* ah_private; char* ah_private;
}; };
@ -75,37 +75,37 @@ extern struct opaque_auth _null_auth;
* Authentication ops. * Authentication ops.
* The ops and the auth handle provide the interface to the authenticators. * The ops and the auth handle provide the interface to the authenticators.
* *
* AUTH *auth; * AUTH *auth;
* XDR *xdrs; * XDR *xdrs;
* struct opaque_auth verf; * struct opaque_auth verf;
*/ */
#define AUTH_NEXTVERF(auth) \ #define AUTH_NEXTVERF(auth) \
((*((auth)->ah_ops->ah_nextverf))(auth)) ((*((auth)->ah_ops->ah_nextverf))(auth))
#define auth_nextverf(auth) \ #define auth_nextverf(auth) \
((*((auth)->ah_ops->ah_nextverf))(auth)) ((*((auth)->ah_ops->ah_nextverf))(auth))
#define AUTH_MARSHALL(auth, xdrs) \ #define AUTH_MARSHALL(auth, xdrs) \
((*((auth)->ah_ops->ah_marshal))(auth, xdrs)) ((*((auth)->ah_ops->ah_marshal))(auth, xdrs))
#define auth_marshall(auth, xdrs) \ #define auth_marshall(auth, xdrs) \
((*((auth)->ah_ops->ah_marshal))(auth, xdrs)) ((*((auth)->ah_ops->ah_marshal))(auth, xdrs))
#define AUTH_VALIDATE(auth, verfp) \ #define AUTH_VALIDATE(auth, verfp) \
((*((auth)->ah_ops->ah_validate))((auth), verfp)) ((*((auth)->ah_ops->ah_validate))((auth), verfp))
#define auth_validate(auth, verfp) \ #define auth_validate(auth, verfp) \
((*((auth)->ah_ops->ah_validate))((auth), verfp)) ((*((auth)->ah_ops->ah_validate))((auth), verfp))
#define AUTH_REFRESH(auth) \ #define AUTH_REFRESH(auth) \
((*((auth)->ah_ops->ah_refresh))(auth)) ((*((auth)->ah_ops->ah_refresh))(auth))
#define auth_refresh(auth) \ #define auth_refresh(auth) \
((*((auth)->ah_ops->ah_refresh))(auth)) ((*((auth)->ah_ops->ah_refresh))(auth))
#define AUTH_DESTROY(auth) \ #define AUTH_DESTROY(auth) \
((*((auth)->ah_ops->ah_destroy))(auth)) ((*((auth)->ah_ops->ah_destroy))(auth))
#define auth_destroy(auth) \ #define auth_destroy(auth) \
((*((auth)->ah_ops->ah_destroy))(auth)) ((*((auth)->ah_ops->ah_destroy))(auth))
#define MAX_AUTH_BYTES 400 #define MAX_AUTH_BYTES 400
#define MAXNETNAMELEN 255 /* maximum length of network user's name */ #define MAXNETNAMELEN 255 /* maximum length of network user's name */
AUTH *authnone_create(void); AUTH *authnone_create(void);

View File

@ -1,12 +1,12 @@
/* /*
* Copyright (c) 2006-2018, RT-Thread Development Team * Copyright (c) 2006-2021, RT-Thread Development Team
* *
* SPDX-License-Identifier: Apache-2.0 * SPDX-License-Identifier: Apache-2.0
* *
* Change Logs: * Change Logs:
* Date Author Notes * Date Author Notes
*/ */
/* @(#)auth_none.c 2.1 88/07/29 4.0 RPCSRC */ /* @(#)auth_none.c 2.1 88/07/29 4.0 RPCSRC */
/* /*
* Sun RPC is a product of Sun Microsystems, Inc. and is provided for * Sun RPC is a product of Sun Microsystems, Inc. and is provided for
* unrestricted use provided that this legend is included on all tape * unrestricted use provided that this legend is included on all tape
@ -14,23 +14,23 @@
* may copy or modify Sun RPC without charge, but are not authorized * may copy or modify Sun RPC without charge, but are not authorized
* to license or distribute it to anyone else except as part of a product or * to license or distribute it to anyone else except as part of a product or
* program developed by the user. * program developed by the user.
* *
* SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE
* WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR * WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR
* PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE. * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE.
* *
* Sun RPC is provided with no support and without any obligation on the * Sun RPC is provided with no support and without any obligation on the
* part of Sun Microsystems, Inc. to assist in its use, correction, * part of Sun Microsystems, Inc. to assist in its use, correction,
* modification or enhancement. * modification or enhancement.
* *
* SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE
* INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC
* OR ANY PART THEREOF. * OR ANY PART THEREOF.
* *
* In no event will Sun Microsystems, Inc. be liable for any lost revenue * In no event will Sun Microsystems, Inc. be liable for any lost revenue
* or profits or other special, indirect and consequential damages, even if * or profits or other special, indirect and consequential damages, even if
* Sun has been advised of the possibility of such damages. * Sun has been advised of the possibility of such damages.
* *
* Sun Microsystems, Inc. * Sun Microsystems, Inc.
* 2550 Garcia Avenue * 2550 Garcia Avenue
* Mountain View, California 94043 * Mountain View, California 94043
@ -38,15 +38,15 @@
#if !defined(lint) && defined(SCCSIDS) #if !defined(lint) && defined(SCCSIDS)
static char sccsid[] = static char sccsid[] =
"@(#)auth_none.c 1.19 87/08/11 Copyr 1984 Sun Micro"; "@(#)auth_none.c 1.19 87/08/11 Copyr 1984 Sun Micro";
#endif #endif
/* /*
* auth_none.c * auth_none.c
* Creates a client authentication handle for passing "null" * Creates a client authentication handle for passing "null"
* credentials and verifiers to remote systems. * credentials and verifiers to remote systems.
* *
* Copyright (C) 1984, Sun Microsystems, Inc. * Copyright (C) 1984, Sun Microsystems, Inc.
*/ */
#include <rpc/types.h> #include <rpc/types.h>
@ -63,55 +63,55 @@ static bool_t authnone_marshal(AUTH *client, XDR *xdrs);
struct opaque_auth _null_auth; struct opaque_auth _null_auth;
static struct auth_ops ops = { static struct auth_ops ops = {
authnone_verf, authnone_verf,
authnone_marshal, authnone_marshal,
authnone_validate, authnone_validate,
authnone_refresh, authnone_refresh,
authnone_destroy authnone_destroy
}; };
static struct authnone_private { static struct authnone_private {
AUTH no_client; AUTH no_client;
char marshalled_client[MAX_MARSHEL_SIZE]; char marshalled_client[MAX_MARSHEL_SIZE];
unsigned int mcnt; unsigned int mcnt;
} *authnone_private; } *authnone_private;
AUTH *authnone_create() AUTH *authnone_create()
{ {
register struct authnone_private *ap = authnone_private; register struct authnone_private *ap = authnone_private;
XDR xdr_stream; XDR xdr_stream;
register XDR *xdrs; register XDR *xdrs;
extern bool_t xdr_opaque_auth(XDR *xdrs, struct opaque_auth *ap); extern bool_t xdr_opaque_auth(XDR *xdrs, struct opaque_auth *ap);
if (ap == 0) { if (ap == 0) {
ap = (struct authnone_private *) rt_malloc (sizeof(*ap)); ap = (struct authnone_private *) rt_malloc (sizeof(*ap));
if (ap == 0) return NULL; if (ap == 0) return NULL;
memset(ap, 0, sizeof(*ap)); memset(ap, 0, sizeof(*ap));
authnone_private = ap; authnone_private = ap;
} }
if (!ap->mcnt) { if (!ap->mcnt) {
ap->no_client.ah_cred = ap->no_client.ah_verf = _null_auth; ap->no_client.ah_cred = ap->no_client.ah_verf = _null_auth;
ap->no_client.ah_ops = &ops; ap->no_client.ah_ops = &ops;
xdrs = &xdr_stream; xdrs = &xdr_stream;
xdrmem_create(xdrs, ap->marshalled_client, xdrmem_create(xdrs, ap->marshalled_client,
(unsigned int) MAX_MARSHEL_SIZE, XDR_ENCODE); (unsigned int) MAX_MARSHEL_SIZE, XDR_ENCODE);
(void) xdr_opaque_auth(xdrs, &ap->no_client.ah_cred); (void) xdr_opaque_auth(xdrs, &ap->no_client.ah_cred);
(void) xdr_opaque_auth(xdrs, &ap->no_client.ah_verf); (void) xdr_opaque_auth(xdrs, &ap->no_client.ah_verf);
ap->mcnt = XDR_GETPOS(xdrs); ap->mcnt = XDR_GETPOS(xdrs);
XDR_DESTROY(xdrs); XDR_DESTROY(xdrs);
} }
return (&ap->no_client); return (&ap->no_client);
} }
/*ARGSUSED*/ /*ARGSUSED*/
static bool_t authnone_marshal(AUTH *client, XDR *xdrs) static bool_t authnone_marshal(AUTH *client, XDR *xdrs)
{ {
register struct authnone_private *ap = authnone_private; register struct authnone_private *ap = authnone_private;
if (ap == 0) if (ap == 0)
return (0); return (0);
return ((*xdrs->x_ops->x_putbytes) (xdrs, return ((*xdrs->x_ops->x_putbytes) (xdrs,
ap->marshalled_client, ap->mcnt)); ap->marshalled_client, ap->mcnt));
} }
static void authnone_verf(AUTH *x) static void authnone_verf(AUTH *x)
@ -121,13 +121,13 @@ static void authnone_verf(AUTH *x)
static bool_t authnone_validate(AUTH *x, struct opaque_auth *x1) static bool_t authnone_validate(AUTH *x, struct opaque_auth *x1)
{ {
return (TRUE); return (TRUE);
} }
static bool_t authnone_refresh(AUTH *x) static bool_t authnone_refresh(AUTH *x)
{ {
return (FALSE); return (FALSE);
} }
static void authnone_destroy(AUTH *x) static void authnone_destroy(AUTH *x)

View File

@ -1,12 +1,12 @@
/* /*
* Copyright (c) 2006-2018, RT-Thread Development Team * Copyright (c) 2006-2021, RT-Thread Development Team
* *
* SPDX-License-Identifier: Apache-2.0 * SPDX-License-Identifier: Apache-2.0
* *
* Change Logs: * Change Logs:
* Date Author Notes * Date Author Notes
*/ */
/* @(#)clnt.h 2.1 88/07/29 4.0 RPCSRC; from 1.31 88/02/08 SMI*/ /* @(#)clnt.h 2.1 88/07/29 4.0 RPCSRC; from 1.31 88/02/08 SMI*/
/* /*
* Sun RPC is a product of Sun Microsystems, Inc. and is provided for * Sun RPC is a product of Sun Microsystems, Inc. and is provided for
* unrestricted use provided that this legend is included on all tape * unrestricted use provided that this legend is included on all tape
@ -43,7 +43,7 @@
*/ */
#ifndef _RPC_CLNT_H #ifndef _RPC_CLNT_H
#define _RPC_CLNT_H 1 #define _RPC_CLNT_H 1
#include <rpc/types.h> #include <rpc/types.h>
#include <rpc/auth.h> #include <rpc/auth.h>
@ -55,47 +55,47 @@
* independent) list of errors. * independent) list of errors.
*/ */
enum clnt_stat { enum clnt_stat {
RPC_SUCCESS=0, /* call succeeded */ RPC_SUCCESS=0, /* call succeeded */
/* /*
* local errors * local errors
*/ */
RPC_CANTENCODEARGS=1, /* can't encode arguments */ RPC_CANTENCODEARGS=1, /* can't encode arguments */
RPC_CANTDECODERES=2, /* can't decode results */ RPC_CANTDECODERES=2, /* can't decode results */
RPC_CANTSEND=3, /* failure in sending call */ RPC_CANTSEND=3, /* failure in sending call */
RPC_CANTRECV=4, /* failure in receiving result */ RPC_CANTRECV=4, /* failure in receiving result */
RPC_TIMEDOUT=5, /* call timed out */ RPC_TIMEDOUT=5, /* call timed out */
/* /*
* remote errors * remote errors
*/ */
RPC_VERSMISMATCH=6, /* rpc versions not compatible */ RPC_VERSMISMATCH=6, /* rpc versions not compatible */
RPC_AUTHERROR=7, /* authentication error */ RPC_AUTHERROR=7, /* authentication error */
RPC_PROGUNAVAIL=8, /* program not available */ RPC_PROGUNAVAIL=8, /* program not available */
RPC_PROGVERSMISMATCH=9, /* program version mismatched */ RPC_PROGVERSMISMATCH=9, /* program version mismatched */
RPC_PROCUNAVAIL=10, /* procedure unavailable */ RPC_PROCUNAVAIL=10, /* procedure unavailable */
RPC_CANTDECODEARGS=11, /* decode arguments error */ RPC_CANTDECODEARGS=11, /* decode arguments error */
RPC_SYSTEMERROR=12, /* generic "other problem" */ RPC_SYSTEMERROR=12, /* generic "other problem" */
RPC_NOBROADCAST = 21, /* Broadcasting not supported */ RPC_NOBROADCAST = 21, /* Broadcasting not supported */
/* /*
* callrpc & clnt_create errors * callrpc & clnt_create errors
*/ */
RPC_UNKNOWNHOST=13, /* unknown host name */ RPC_UNKNOWNHOST=13, /* unknown host name */
RPC_UNKNOWNPROTO=17, /* unknown protocol */ RPC_UNKNOWNPROTO=17, /* unknown protocol */
RPC_UNKNOWNADDR = 19, /* Remote address unknown */ RPC_UNKNOWNADDR = 19, /* Remote address unknown */
/* /*
* rpcbind errors * rpcbind errors
*/ */
RPC_RPCBFAILURE=14, /* portmapper failed in its call */ RPC_RPCBFAILURE=14, /* portmapper failed in its call */
#define RPC_PMAPFAILURE RPC_RPCBFAILURE #define RPC_PMAPFAILURE RPC_RPCBFAILURE
RPC_PROGNOTREGISTERED=15, /* remote program is not registered */ RPC_PROGNOTREGISTERED=15, /* remote program is not registered */
RPC_N2AXLATEFAILURE = 22, /* Name to addr translation failed */ RPC_N2AXLATEFAILURE = 22, /* Name to addr translation failed */
/* /*
* unspecified error * unspecified error
*/ */
RPC_FAILED=16, RPC_FAILED=16,
RPC_INTR=18, RPC_INTR=18,
RPC_TLIERROR=20, RPC_TLIERROR=20,
RPC_UDERROR=23, RPC_UDERROR=23,
/* /*
* asynchronous errors * asynchronous errors
*/ */
@ -110,21 +110,21 @@ enum clnt_stat {
struct rpc_err { struct rpc_err {
int re_status; int re_status;
union { union {
int RE_errno; /* related system error */ int RE_errno; /* related system error */
int RE_why; /* why the auth error occurred */ int RE_why; /* why the auth error occurred */
struct { struct {
unsigned long low; /* lowest verion supported */ unsigned long low; /* lowest verion supported */
unsigned long high; /* highest verion supported */ unsigned long high; /* highest verion supported */
} RE_vers; } RE_vers;
struct { /* maybe meaningful if RPC_FAILED */ struct { /* maybe meaningful if RPC_FAILED */
long s1; long s1;
long s2; long s2;
} RE_lb; /* life boot & debugging only */ } RE_lb; /* life boot & debugging only */
} ru; } ru;
#define re_errno ru.RE_errno #define re_errno ru.RE_errno
#define re_why ru.RE_why #define re_why ru.RE_why
#define re_vers ru.RE_vers #define re_vers ru.RE_vers
#define re_lb ru.RE_lb #define re_lb ru.RE_lb
}; };
@ -135,21 +135,21 @@ struct rpc_err {
*/ */
typedef struct CLIENT CLIENT; typedef struct CLIENT CLIENT;
struct CLIENT { struct CLIENT {
AUTH *cl_auth; /* authenticator */ AUTH *cl_auth; /* authenticator */
struct clnt_ops { struct clnt_ops {
enum clnt_stat (*cl_call) (CLIENT *, unsigned long, xdrproc_t, char*, xdrproc_t, enum clnt_stat (*cl_call) (CLIENT *, unsigned long, xdrproc_t, char*, xdrproc_t,
char*, struct timeval); char*, struct timeval);
/* call remote procedure */ /* call remote procedure */
void (*cl_abort) (void); /* abort a call */ void (*cl_abort) (void); /* abort a call */
void (*cl_geterr) (CLIENT *, struct rpc_err *); void (*cl_geterr) (CLIENT *, struct rpc_err *);
/* get specific error code */ /* get specific error code */
bool_t (*cl_freeres) (CLIENT *, xdrproc_t, char*); bool_t (*cl_freeres) (CLIENT *, xdrproc_t, char*);
/* frees results */ /* frees results */
void (*cl_destroy) (CLIENT *); /* destroy this structure */ void (*cl_destroy) (CLIENT *); /* destroy this structure */
bool_t (*cl_control) (CLIENT *, int, char *); bool_t (*cl_control) (CLIENT *, int, char *);
/* the ioctl() of rpc */ /* the ioctl() of rpc */
} *cl_ops; } *cl_ops;
char* cl_private; /* private stuff */ char* cl_private; /* private stuff */
}; };
@ -163,45 +163,45 @@ struct CLIENT {
/* /*
* enum clnt_stat * enum clnt_stat
* CLNT_CALL(rh, proc, xargs, argsp, xres, resp, timeout) * CLNT_CALL(rh, proc, xargs, argsp, xres, resp, timeout)
* CLIENT *rh; * CLIENT *rh;
* unsigned long proc; * unsigned long proc;
* xdrproc_t xargs; * xdrproc_t xargs;
* char* argsp; * char* argsp;
* xdrproc_t xres; * xdrproc_t xres;
* char* resp; * char* resp;
* struct timeval timeout; * struct timeval timeout;
*/ */
#define CLNT_CALL(rh, proc, xargs, argsp, xres, resp, secs) \ #define CLNT_CALL(rh, proc, xargs, argsp, xres, resp, secs) \
((*(rh)->cl_ops->cl_call)(rh, proc, xargs, argsp, xres, resp, secs)) ((*(rh)->cl_ops->cl_call)(rh, proc, xargs, argsp, xres, resp, secs))
#define clnt_call(rh, proc, xargs, argsp, xres, resp, secs) \ #define clnt_call(rh, proc, xargs, argsp, xres, resp, secs) \
((*(rh)->cl_ops->cl_call)(rh, proc, xargs, argsp, xres, resp, secs)) ((*(rh)->cl_ops->cl_call)(rh, proc, xargs, argsp, xres, resp, secs))
/* /*
* void * void
* CLNT_ABORT(rh); * CLNT_ABORT(rh);
* CLIENT *rh; * CLIENT *rh;
*/ */
#define CLNT_ABORT(rh) ((*(rh)->cl_ops->cl_abort)(rh)) #define CLNT_ABORT(rh) ((*(rh)->cl_ops->cl_abort)(rh))
#define clnt_abort(rh) ((*(rh)->cl_ops->cl_abort)(rh)) #define clnt_abort(rh) ((*(rh)->cl_ops->cl_abort)(rh))
/* /*
* struct rpc_err * struct rpc_err
* CLNT_GETERR(rh); * CLNT_GETERR(rh);
* CLIENT *rh; * CLIENT *rh;
*/ */
#define CLNT_GETERR(rh,errp) ((*(rh)->cl_ops->cl_geterr)(rh, errp)) #define CLNT_GETERR(rh,errp) ((*(rh)->cl_ops->cl_geterr)(rh, errp))
#define clnt_geterr(rh,errp) ((*(rh)->cl_ops->cl_geterr)(rh, errp)) #define clnt_geterr(rh,errp) ((*(rh)->cl_ops->cl_geterr)(rh, errp))
/* /*
* bool_t * bool_t
* CLNT_FREERES(rh, xres, resp); * CLNT_FREERES(rh, xres, resp);
* CLIENT *rh; * CLIENT *rh;
* xdrproc_t xres; * xdrproc_t xres;
* char* resp; * char* resp;
*/ */
#define CLNT_FREERES(rh,xres,resp) ((*(rh)->cl_ops->cl_freeres)(rh,xres,resp)) #define CLNT_FREERES(rh,xres,resp) ((*(rh)->cl_ops->cl_freeres)(rh,xres,resp))
#define clnt_freeres(rh,xres,resp) ((*(rh)->cl_ops->cl_freeres)(rh,xres,resp)) #define clnt_freeres(rh,xres,resp) ((*(rh)->cl_ops->cl_freeres)(rh,xres,resp))
/* /*
* bool_t * bool_t
@ -210,8 +210,8 @@ struct CLIENT {
* unsigned int request; * unsigned int request;
* char *info; * char *info;
*/ */
#define CLNT_CONTROL(cl,rq,in) ((*(cl)->cl_ops->cl_control)(cl,rq,in)) #define CLNT_CONTROL(cl,rq,in) ((*(cl)->cl_ops->cl_control)(cl,rq,in))
#define clnt_control(cl,rq,in) ((*(cl)->cl_ops->cl_control)(cl,rq,in)) #define clnt_control(cl,rq,in) ((*(cl)->cl_ops->cl_control)(cl,rq,in))
/* /*
* control operations that apply to all transports * control operations that apply to all transports
@ -239,16 +239,16 @@ struct CLIENT {
/* /*
* Connectionless only control operations * Connectionless only control operations
*/ */
#define CLSET_RETRY_TIMEOUT 4 /* set retry timeout (timeval) */ #define CLSET_RETRY_TIMEOUT 4 /* set retry timeout (timeval) */
#define CLGET_RETRY_TIMEOUT 5 /* get retry timeout (timeval) */ #define CLGET_RETRY_TIMEOUT 5 /* get retry timeout (timeval) */
/* /*
* void * void
* CLNT_DESTROY(rh); * CLNT_DESTROY(rh);
* CLIENT *rh; * CLIENT *rh;
*/ */
#define CLNT_DESTROY(rh) ((*(rh)->cl_ops->cl_destroy)(rh)) #define CLNT_DESTROY(rh) ((*(rh)->cl_ops->cl_destroy)(rh))
#define clnt_destroy(rh) ((*(rh)->cl_ops->cl_destroy)(rh)) #define clnt_destroy(rh) ((*(rh)->cl_ops->cl_destroy)(rh))
/* /*
@ -257,10 +257,10 @@ struct CLIENT {
* and network administration. * and network administration.
*/ */
#define RPCTEST_PROGRAM ((unsigned long)1) #define RPCTEST_PROGRAM ((unsigned long)1)
#define RPCTEST_VERSION ((unsigned long)1) #define RPCTEST_VERSION ((unsigned long)1)
#define RPCTEST_NULL_PROC ((unsigned long)2) #define RPCTEST_NULL_PROC ((unsigned long)2)
#define RPCTEST_NULL_BATCH_PROC ((unsigned long)3) #define RPCTEST_NULL_BATCH_PROC ((unsigned long)3)
/* /*
* By convention, procedure 0 takes null arguments and returns them * By convention, procedure 0 takes null arguments and returns them
@ -279,51 +279,51 @@ struct CLIENT {
* "unix" * "unix"
* CLIENT * * CLIENT *
* clnt_create(host, prog, vers, prot) * clnt_create(host, prog, vers, prot)
* char *host; -- hostname * char *host; -- hostname
* unsigned long prog; -- program number * unsigned long prog; -- program number
* u_ong vers; -- version number * u_ong vers; -- version number
* char *prot; -- protocol * char *prot; -- protocol
*/ */
extern CLIENT *clnt_create (const char *__host, const unsigned long __prog, extern CLIENT *clnt_create (const char *__host, const unsigned long __prog,
const unsigned long __vers, const char *__prot) const unsigned long __vers, const char *__prot)
; ;
/* /*
* UDP based rpc. * UDP based rpc.
* CLIENT * * CLIENT *
* clntudp_create(raddr, program, version, wait, sockp) * clntudp_create(raddr, program, version, wait, sockp)
* struct sockaddr_in *raddr; * struct sockaddr_in *raddr;
* unsigned long program; * unsigned long program;
* unsigned long version; * unsigned long version;
* struct timeval wait_resend; * struct timeval wait_resend;
* int *sockp; * int *sockp;
* *
* Same as above, but you specify max packet sizes. * Same as above, but you specify max packet sizes.
* CLIENT * * CLIENT *
* clntudp_bufcreate(raddr, program, version, wait, sockp, sendsz, recvsz) * clntudp_bufcreate(raddr, program, version, wait, sockp, sendsz, recvsz)
* struct sockaddr_in *raddr; * struct sockaddr_in *raddr;
* unsigned long program; * unsigned long program;
* unsigned long version; * unsigned long version;
* struct timeval wait_resend; * struct timeval wait_resend;
* int *sockp; * int *sockp;
* unsigned int sendsz; * unsigned int sendsz;
* unsigned int recvsz; * unsigned int recvsz;
*/ */
extern CLIENT *clntudp_create (struct sockaddr_in *__raddr, unsigned long __program, extern CLIENT *clntudp_create (struct sockaddr_in *__raddr, unsigned long __program,
unsigned long __version, struct timeval __wait_resend, unsigned long __version, struct timeval __wait_resend,
int *__sockp); int *__sockp);
extern CLIENT *clntudp_bufcreate (struct sockaddr_in *__raddr, extern CLIENT *clntudp_bufcreate (struct sockaddr_in *__raddr,
unsigned long __program, unsigned long __version, unsigned long __program, unsigned long __version,
struct timeval __wait_resend, int *__sockp, struct timeval __wait_resend, int *__sockp,
unsigned int __sendsz, unsigned int __recvsz); unsigned int __sendsz, unsigned int __recvsz);
extern int callrpc (const char *__host, const unsigned long __prognum, extern int callrpc (const char *__host, const unsigned long __prognum,
const unsigned long __versnum, const unsigned long __procnum, const unsigned long __versnum, const unsigned long __procnum,
const xdrproc_t __inproc, const char *__in, const xdrproc_t __inproc, const char *__in,
const xdrproc_t __outproc, char *__out); const xdrproc_t __outproc, char *__out);
#define UDPMSGSIZE 8800 /* rpc imposed limit on udp msg size */ #define UDPMSGSIZE 8800 /* rpc imposed limit on udp msg size */
#define RPCSMALLMSGSIZE 400 /* a more reasonable packet size */ #define RPCSMALLMSGSIZE 400 /* a more reasonable packet size */
void clnt_perror(CLIENT *rpch, const char *s); void clnt_perror(CLIENT *rpch, const char *s);

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2006-2018, RT-Thread Development Team * Copyright (c) 2006-2021, RT-Thread Development Team
* *
* SPDX-License-Identifier: Apache-2.0 * SPDX-License-Identifier: Apache-2.0
* *

View File

@ -1,12 +1,12 @@
/* /*
* Copyright (c) 2006-2018, RT-Thread Development Team * Copyright (c) 2006-2021, RT-Thread Development Team
* *
* SPDX-License-Identifier: Apache-2.0 * SPDX-License-Identifier: Apache-2.0
* *
* Change Logs: * Change Logs:
* Date Author Notes * Date Author Notes
*/ */
/* @(#)clnt_udp.c 2.2 88/08/01 4.0 RPCSRC */ /* @(#)clnt_udp.c 2.2 88/08/01 4.0 RPCSRC */
/* /*
* Sun RPC is a product of Sun Microsystems, Inc. and is provided for * Sun RPC is a product of Sun Microsystems, Inc. and is provided for
* unrestricted use provided that this legend is included on all tape * unrestricted use provided that this legend is included on all tape
@ -53,12 +53,12 @@ static char sccsid[] = "@(#)clnt_udp.c 1.39 87/08/11 Copyr 1984 Sun Micro";
* UDP bases client side rpc operations * UDP bases client side rpc operations
*/ */
static enum clnt_stat clntudp_call(register CLIENT *cl, /* client handle */ static enum clnt_stat clntudp_call(register CLIENT *cl, /* client handle */
unsigned long proc, /* procedure number */ unsigned long proc, /* procedure number */
xdrproc_t xargs, /* xdr routine for args */ xdrproc_t xargs, /* xdr routine for args */
char* argsp, /* pointer to args */ char* argsp, /* pointer to args */
xdrproc_t xresults, /* xdr routine for results */ xdrproc_t xresults, /* xdr routine for results */
char* resultsp, /* pointer to results */ char* resultsp, /* pointer to results */
struct timeval utimeout); struct timeval utimeout);
static void clntudp_abort(void); static void clntudp_abort(void);
static void clntudp_geterr(CLIENT *, struct rpc_err *); static void clntudp_geterr(CLIENT *, struct rpc_err *);
@ -68,12 +68,12 @@ static void clntudp_destroy(CLIENT *);
static struct clnt_ops udp_ops = static struct clnt_ops udp_ops =
{ {
clntudp_call, clntudp_call,
clntudp_abort, clntudp_abort,
clntudp_geterr, clntudp_geterr,
clntudp_freeres, clntudp_freeres,
clntudp_destroy, clntudp_destroy,
clntudp_control clntudp_control
}; };
/* /*
@ -81,19 +81,19 @@ static struct clnt_ops udp_ops =
*/ */
struct cu_data struct cu_data
{ {
int cu_sock; int cu_sock;
bool_t cu_closeit; bool_t cu_closeit;
struct sockaddr_in cu_raddr; struct sockaddr_in cu_raddr;
int cu_rlen; int cu_rlen;
struct timeval cu_wait; struct timeval cu_wait;
struct timeval cu_total; struct timeval cu_total;
struct rpc_err cu_error; struct rpc_err cu_error;
XDR cu_outxdrs; XDR cu_outxdrs;
unsigned int cu_xdrpos; unsigned int cu_xdrpos;
unsigned int cu_sendsz; unsigned int cu_sendsz;
char *cu_outbuf; char *cu_outbuf;
unsigned int cu_recvsz; unsigned int cu_recvsz;
char cu_inbuf[1]; char cu_inbuf[1];
}; };
/* /*
@ -112,241 +112,241 @@ struct cu_data
* sendsz and recvsz are the maximum allowable packet sizes that can be * sendsz and recvsz are the maximum allowable packet sizes that can be
* sent and received. * sent and received.
*/ */
CLIENT *clntudp_bufcreate(struct sockaddr_in *raddr, CLIENT *clntudp_bufcreate(struct sockaddr_in *raddr,
unsigned long program, unsigned long program,
unsigned long version, unsigned long version,
struct timeval wait, struct timeval wait,
int *sockp, int *sockp,
unsigned int sendsz, unsigned int sendsz,
unsigned int recvsz) unsigned int recvsz)
{ {
CLIENT *cl; CLIENT *cl;
register struct cu_data *cu = NULL; register struct cu_data *cu = NULL;
struct rpc_msg call_msg; struct rpc_msg call_msg;
static int xid_count = 0; static int xid_count = 0;
cl = (CLIENT *) rt_malloc (sizeof(CLIENT)); cl = (CLIENT *) rt_malloc (sizeof(CLIENT));
if (cl == NULL) if (cl == NULL)
{ {
rt_kprintf("clntudp_create: out of memory\n"); rt_kprintf("clntudp_create: out of memory\n");
goto fooy; goto fooy;
} }
sendsz = ((sendsz + 3) / 4) * 4; sendsz = ((sendsz + 3) / 4) * 4;
recvsz = ((recvsz + 3) / 4) * 4; recvsz = ((recvsz + 3) / 4) * 4;
cu = (struct cu_data *) rt_malloc (sizeof(*cu) + sendsz + recvsz); cu = (struct cu_data *) rt_malloc (sizeof(*cu) + sendsz + recvsz);
if (cu == NULL) if (cu == NULL)
{ {
rt_kprintf("clntudp_create: out of memory\n"); rt_kprintf("clntudp_create: out of memory\n");
goto fooy; goto fooy;
} }
cu->cu_outbuf = &cu->cu_inbuf[recvsz]; cu->cu_outbuf = &cu->cu_inbuf[recvsz];
if (raddr->sin_port == 0) { if (raddr->sin_port == 0) {
unsigned short port; unsigned short port;
extern unsigned short pmap_getport(struct sockaddr_in *address, extern unsigned short pmap_getport(struct sockaddr_in *address,
unsigned long program, unsigned long program,
unsigned long version, unsigned long version,
unsigned int protocol); unsigned int protocol);
if ((port = if ((port =
pmap_getport(raddr, program, version, IPPROTO_UDP)) == 0) { pmap_getport(raddr, program, version, IPPROTO_UDP)) == 0) {
goto fooy; goto fooy;
} }
raddr->sin_port = htons(port); raddr->sin_port = htons(port);
} }
cl->cl_ops = &udp_ops; cl->cl_ops = &udp_ops;
cl->cl_private = (char*) cu; cl->cl_private = (char*) cu;
cu->cu_raddr = *raddr; cu->cu_raddr = *raddr;
cu->cu_rlen = sizeof(cu->cu_raddr); cu->cu_rlen = sizeof(cu->cu_raddr);
cu->cu_wait = wait; cu->cu_wait = wait;
cu->cu_total.tv_sec = -1; cu->cu_total.tv_sec = -1;
cu->cu_total.tv_usec = -1; cu->cu_total.tv_usec = -1;
cu->cu_sendsz = sendsz; cu->cu_sendsz = sendsz;
cu->cu_recvsz = recvsz; cu->cu_recvsz = recvsz;
call_msg.rm_xid = ((unsigned long)rt_thread_self()) ^ ((unsigned long)rt_tick_get()) ^ (xid_count++); call_msg.rm_xid = ((unsigned long)rt_thread_self()) ^ ((unsigned long)rt_tick_get()) ^ (xid_count++);
call_msg.rm_direction = CALL; call_msg.rm_direction = CALL;
call_msg.rm_call.cb_rpcvers = RPC_MSG_VERSION; call_msg.rm_call.cb_rpcvers = RPC_MSG_VERSION;
call_msg.rm_call.cb_prog = program; call_msg.rm_call.cb_prog = program;
call_msg.rm_call.cb_vers = version; call_msg.rm_call.cb_vers = version;
xdrmem_create(&(cu->cu_outxdrs), cu->cu_outbuf, sendsz, XDR_ENCODE); xdrmem_create(&(cu->cu_outxdrs), cu->cu_outbuf, sendsz, XDR_ENCODE);
if (!xdr_callhdr(&(cu->cu_outxdrs), &call_msg)) if (!xdr_callhdr(&(cu->cu_outxdrs), &call_msg))
{ {
goto fooy; goto fooy;
} }
cu->cu_xdrpos = XDR_GETPOS(&(cu->cu_outxdrs)); cu->cu_xdrpos = XDR_GETPOS(&(cu->cu_outxdrs));
if (*sockp < 0) if (*sockp < 0)
{ {
*sockp = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP); *sockp = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP);
if (*sockp < 0) if (*sockp < 0)
{ {
rt_kprintf("create socket error\n"); rt_kprintf("create socket error\n");
goto fooy; goto fooy;
} }
cu->cu_closeit = TRUE; cu->cu_closeit = TRUE;
} }
else else
{ {
cu->cu_closeit = FALSE; cu->cu_closeit = FALSE;
} }
cu->cu_sock = *sockp; cu->cu_sock = *sockp;
cl->cl_auth = authnone_create(); cl->cl_auth = authnone_create();
return (cl); return (cl);
fooy: fooy:
if (cu) rt_free(cu); if (cu) rt_free(cu);
if (cl) rt_free(cl); if (cl) rt_free(cl);
return ((CLIENT *) NULL); return ((CLIENT *) NULL);
} }
CLIENT *clntudp_create(struct sockaddr_in *raddr, CLIENT *clntudp_create(struct sockaddr_in *raddr,
unsigned long program, unsigned long program,
unsigned long version, unsigned long version,
struct timeval wait, struct timeval wait,
int *sockp) int *sockp)
{ {
return (clntudp_bufcreate(raddr, program, version, wait, sockp, return (clntudp_bufcreate(raddr, program, version, wait, sockp,
UDPMSGSIZE, UDPMSGSIZE)); UDPMSGSIZE, UDPMSGSIZE));
} }
static enum clnt_stat clntudp_call(CLIENT *cl, unsigned long proc, static enum clnt_stat clntudp_call(CLIENT *cl, unsigned long proc,
xdrproc_t xargs, char* argsp, xdrproc_t xargs, char* argsp,
xdrproc_t xresults, char* resultsp, xdrproc_t xresults, char* resultsp,
struct timeval utimeout) struct timeval utimeout)
{ {
register struct cu_data *cu = (struct cu_data *) cl->cl_private; register struct cu_data *cu = (struct cu_data *) cl->cl_private;
register XDR *xdrs; register XDR *xdrs;
register int outlen; register int outlen;
register int inlen; register int inlen;
socklen_t fromlen; socklen_t fromlen;
struct sockaddr_in from; struct sockaddr_in from;
struct rpc_msg reply_msg; struct rpc_msg reply_msg;
XDR reply_xdrs; XDR reply_xdrs;
bool_t ok; bool_t ok;
int nrefreshes = 2; /* number of times to refresh cred */ int nrefreshes = 2; /* number of times to refresh cred */
call_again: call_again:
xdrs = &(cu->cu_outxdrs); xdrs = &(cu->cu_outxdrs);
xdrs->x_op = XDR_ENCODE; xdrs->x_op = XDR_ENCODE;
XDR_SETPOS(xdrs, cu->cu_xdrpos); XDR_SETPOS(xdrs, cu->cu_xdrpos);
/* /*
* the transaction is the first thing in the out buffer * the transaction is the first thing in the out buffer
*/ */
(*(unsigned long *) (cu->cu_outbuf))++; (*(unsigned long *) (cu->cu_outbuf))++;
if ((!XDR_PUTLONG(xdrs, (long *) &proc)) || if ((!XDR_PUTLONG(xdrs, (long *) &proc)) ||
(!AUTH_MARSHALL(cl->cl_auth, xdrs)) || (!(*xargs) (xdrs, argsp))) (!AUTH_MARSHALL(cl->cl_auth, xdrs)) || (!(*xargs) (xdrs, argsp)))
{ {
cu->cu_error.re_status = RPC_CANTENCODEARGS; cu->cu_error.re_status = RPC_CANTENCODEARGS;
return RPC_CANTENCODEARGS; return RPC_CANTENCODEARGS;
} }
outlen = (int) XDR_GETPOS(xdrs); outlen = (int) XDR_GETPOS(xdrs);
send_again: send_again:
if (sendto(cu->cu_sock, cu->cu_outbuf, outlen, 0, if (sendto(cu->cu_sock, cu->cu_outbuf, outlen, 0,
(struct sockaddr *) &(cu->cu_raddr), cu->cu_rlen) (struct sockaddr *) &(cu->cu_raddr), cu->cu_rlen)
!= outlen) != outlen)
{ {
cu->cu_error.re_errno = errno; cu->cu_error.re_errno = errno;
cu->cu_error.re_status = RPC_CANTSEND; cu->cu_error.re_status = RPC_CANTSEND;
return RPC_CANTSEND;
}
/* return RPC_CANTSEND;
* sub-optimal code appears here because we have }
* some clock time to spare while the packets are in flight.
* (We assume that this is actually only executed once.)
*/
reply_msg.acpted_rply.ar_verf = _null_auth;
reply_msg.acpted_rply.ar_results.where = resultsp;
reply_msg.acpted_rply.ar_results.proc = xresults;
/* do recv */ /*
do * sub-optimal code appears here because we have
{ * some clock time to spare while the packets are in flight.
fromlen = sizeof(struct sockaddr); * (We assume that this is actually only executed once.)
*/
reply_msg.acpted_rply.ar_verf = _null_auth;
reply_msg.acpted_rply.ar_results.where = resultsp;
reply_msg.acpted_rply.ar_results.proc = xresults;
inlen = recvfrom(cu->cu_sock, cu->cu_inbuf, /* do recv */
(int) cu->cu_recvsz, 0, do
(struct sockaddr *) &from, &fromlen); {
}while (inlen < 0 && errno == EINTR); fromlen = sizeof(struct sockaddr);
if (inlen < 4) inlen = recvfrom(cu->cu_sock, cu->cu_inbuf,
{ (int) cu->cu_recvsz, 0,
rt_kprintf("recv error, len %d\n", inlen); (struct sockaddr *) &from, &fromlen);
cu->cu_error.re_errno = errno; }while (inlen < 0 && errno == EINTR);
cu->cu_error.re_status = RPC_CANTRECV;
return RPC_CANTRECV;
}
/* see if reply transaction id matches sent id */ if (inlen < 4)
if (*((uint32_t *) (cu->cu_inbuf)) != *((uint32_t *) (cu->cu_outbuf))) {
goto send_again; rt_kprintf("recv error, len %d\n", inlen);
cu->cu_error.re_errno = errno;
cu->cu_error.re_status = RPC_CANTRECV;
/* we now assume we have the proper reply */ return RPC_CANTRECV;
}
/* /* see if reply transaction id matches sent id */
* now decode and validate the response if (*((uint32_t *) (cu->cu_inbuf)) != *((uint32_t *) (cu->cu_outbuf)))
*/ goto send_again;
xdrmem_create(&reply_xdrs, cu->cu_inbuf, (unsigned int) inlen, XDR_DECODE);
ok = xdr_replymsg(&reply_xdrs, &reply_msg);
/* XDR_DESTROY(&reply_xdrs); save a few cycles on noop destroy */
if (ok)
{
_seterr_reply(&reply_msg, &(cu->cu_error));
if (cu->cu_error.re_status == RPC_SUCCESS)
{
if (!AUTH_VALIDATE(cl->cl_auth,
&reply_msg.acpted_rply.ar_verf))
{
cu->cu_error.re_status = RPC_AUTHERROR;
cu->cu_error.re_why = AUTH_INVALIDRESP;
}
if (reply_msg.acpted_rply.ar_verf.oa_base != NULL)
{
extern bool_t xdr_opaque_auth(XDR *xdrs, struct opaque_auth *ap);
xdrs->x_op = XDR_FREE;
(void) xdr_opaque_auth(xdrs, &(reply_msg.acpted_rply.ar_verf));
}
} /* end successful completion */
else
{
/* maybe our credentials need to be refreshed ... */
if (nrefreshes > 0 && AUTH_REFRESH(cl->cl_auth))
{
nrefreshes--;
goto call_again;
}
} /* end of unsuccessful completion */
} /* end of valid reply message */
else
{
cu->cu_error.re_status = RPC_CANTDECODERES;
}
return (enum clnt_stat)(cu->cu_error.re_status); /* we now assume we have the proper reply */
/*
* now decode and validate the response
*/
xdrmem_create(&reply_xdrs, cu->cu_inbuf, (unsigned int) inlen, XDR_DECODE);
ok = xdr_replymsg(&reply_xdrs, &reply_msg);
/* XDR_DESTROY(&reply_xdrs); save a few cycles on noop destroy */
if (ok)
{
_seterr_reply(&reply_msg, &(cu->cu_error));
if (cu->cu_error.re_status == RPC_SUCCESS)
{
if (!AUTH_VALIDATE(cl->cl_auth,
&reply_msg.acpted_rply.ar_verf))
{
cu->cu_error.re_status = RPC_AUTHERROR;
cu->cu_error.re_why = AUTH_INVALIDRESP;
}
if (reply_msg.acpted_rply.ar_verf.oa_base != NULL)
{
extern bool_t xdr_opaque_auth(XDR *xdrs, struct opaque_auth *ap);
xdrs->x_op = XDR_FREE;
(void) xdr_opaque_auth(xdrs, &(reply_msg.acpted_rply.ar_verf));
}
} /* end successful completion */
else
{
/* maybe our credentials need to be refreshed ... */
if (nrefreshes > 0 && AUTH_REFRESH(cl->cl_auth))
{
nrefreshes--;
goto call_again;
}
} /* end of unsuccessful completion */
} /* end of valid reply message */
else
{
cu->cu_error.re_status = RPC_CANTDECODERES;
}
return (enum clnt_stat)(cu->cu_error.re_status);
} }
static void clntudp_geterr(CLIENT *cl, struct rpc_err *errp) static void clntudp_geterr(CLIENT *cl, struct rpc_err *errp)
{ {
register struct cu_data *cu = (struct cu_data *) cl->cl_private; register struct cu_data *cu = (struct cu_data *) cl->cl_private;
*errp = cu->cu_error; *errp = cu->cu_error;
} }
static bool_t clntudp_freeres(CLIENT *cl, xdrproc_t xdr_res, char* res_ptr) static bool_t clntudp_freeres(CLIENT *cl, xdrproc_t xdr_res, char* res_ptr)
{ {
register struct cu_data *cu = (struct cu_data *) cl->cl_private; register struct cu_data *cu = (struct cu_data *) cl->cl_private;
register XDR *xdrs = &(cu->cu_outxdrs); register XDR *xdrs = &(cu->cu_outxdrs);
xdrs->x_op = XDR_FREE; xdrs->x_op = XDR_FREE;
return ((*xdr_res) (xdrs, res_ptr)); return ((*xdr_res) (xdrs, res_ptr));
} }
static void clntudp_abort() static void clntudp_abort()
@ -355,50 +355,50 @@ static void clntudp_abort()
static bool_t clntudp_control(CLIENT *cl, int request, char *info) static bool_t clntudp_control(CLIENT *cl, int request, char *info)
{ {
register struct cu_data *cu = (struct cu_data *) cl->cl_private; register struct cu_data *cu = (struct cu_data *) cl->cl_private;
switch (request) switch (request)
{ {
case CLSET_TIMEOUT: case CLSET_TIMEOUT:
{ {
int mtimeout; int mtimeout;
cu->cu_total = *(struct timeval *) info; cu->cu_total = *(struct timeval *) info;
mtimeout = ((cu->cu_total.tv_sec * 1000) + ((cu->cu_total.tv_usec + 500)/1000)); mtimeout = ((cu->cu_total.tv_sec * 1000) + ((cu->cu_total.tv_usec + 500)/1000));
/* set socket option, note: lwip only support msecond timeout */ /* set socket option, note: lwip only support msecond timeout */
setsockopt(cu->cu_sock, SOL_SOCKET, SO_RCVTIMEO, setsockopt(cu->cu_sock, SOL_SOCKET, SO_RCVTIMEO,
&mtimeout, sizeof(mtimeout)); &mtimeout, sizeof(mtimeout));
} }
break; break;
case CLGET_TIMEOUT: case CLGET_TIMEOUT:
*(struct timeval *) info = cu->cu_total; *(struct timeval *) info = cu->cu_total;
break; break;
case CLSET_RETRY_TIMEOUT: case CLSET_RETRY_TIMEOUT:
cu->cu_wait = *(struct timeval *) info; cu->cu_wait = *(struct timeval *) info;
break; break;
case CLGET_RETRY_TIMEOUT: case CLGET_RETRY_TIMEOUT:
*(struct timeval *) info = cu->cu_wait; *(struct timeval *) info = cu->cu_wait;
break; break;
case CLGET_SERVER_ADDR: case CLGET_SERVER_ADDR:
*(struct sockaddr_in *) info = cu->cu_raddr; *(struct sockaddr_in *) info = cu->cu_raddr;
break; break;
default: default:
return (FALSE); return (FALSE);
} }
return (TRUE); return (TRUE);
} }
static void clntudp_destroy(CLIENT *cl) static void clntudp_destroy(CLIENT *cl)
{ {
register struct cu_data *cu = (struct cu_data *) cl->cl_private; register struct cu_data *cu = (struct cu_data *) cl->cl_private;
if (cu->cu_closeit) if (cu->cu_closeit)
{ {
lwip_close(cu->cu_sock); lwip_close(cu->cu_sock);
} }
XDR_DESTROY(&(cu->cu_outxdrs)); XDR_DESTROY(&(cu->cu_outxdrs));
rt_free(cu); rt_free(cu);
rt_free(cl); rt_free(cl);
} }

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2006-2018, RT-Thread Development Team * Copyright (c) 2006-2021, RT-Thread Development Team
* *
* SPDX-License-Identifier: Apache-2.0 * SPDX-License-Identifier: Apache-2.0
* *
@ -16,11 +16,11 @@ static struct timeval tottimeout = { 60, 0 };
bool_t xdr_pmap(XDR *xdrs, struct pmap *regs) bool_t xdr_pmap(XDR *xdrs, struct pmap *regs)
{ {
if (xdr_u_long(xdrs, &regs->pm_prog) && if (xdr_u_long(xdrs, &regs->pm_prog) &&
xdr_u_long(xdrs, &regs->pm_vers) && xdr_u_long(xdrs, &regs->pm_vers) &&
xdr_u_long(xdrs, &regs->pm_prot)) xdr_u_long(xdrs, &regs->pm_prot))
return (xdr_u_long(xdrs, &regs->pm_port)); return (xdr_u_long(xdrs, &regs->pm_port));
return (FALSE); return (FALSE);
} }
/* /*
@ -30,33 +30,33 @@ bool_t xdr_pmap(XDR *xdrs, struct pmap *regs)
*/ */
unsigned short pmap_getport(struct sockaddr_in *address, unsigned long program, unsigned long version, unsigned int protocol) unsigned short pmap_getport(struct sockaddr_in *address, unsigned long program, unsigned long version, unsigned int protocol)
{ {
unsigned short port = 0; unsigned short port = 0;
int socket = -1; int socket = -1;
register CLIENT *client = RT_NULL; register CLIENT *client = RT_NULL;
struct pmap parms; struct pmap parms;
address->sin_port = htons((unsigned short)PMAPPORT); address->sin_port = htons((unsigned short)PMAPPORT);
if (protocol == IPPROTO_UDP) if (protocol == IPPROTO_UDP)
client = clntudp_bufcreate(address, PMAPPROG, PMAPVERS, timeout, client = clntudp_bufcreate(address, PMAPPROG, PMAPVERS, timeout,
&socket, RPCSMALLMSGSIZE, &socket, RPCSMALLMSGSIZE,
RPCSMALLMSGSIZE); RPCSMALLMSGSIZE);
if (client != (CLIENT *) NULL) if (client != (CLIENT *) NULL)
{ {
parms.pm_prog = program; parms.pm_prog = program;
parms.pm_vers = version; parms.pm_vers = version;
parms.pm_prot = protocol; parms.pm_prot = protocol;
parms.pm_port = 0; /* not needed or used */ parms.pm_port = 0; /* not needed or used */
if (CLNT_CALL(client, PMAPPROC_GETPORT, (xdrproc_t)xdr_pmap, (char*)&parms, if (CLNT_CALL(client, PMAPPROC_GETPORT, (xdrproc_t)xdr_pmap, (char*)&parms,
(xdrproc_t)xdr_u_short, (char*)&port, tottimeout) != RPC_SUCCESS) (xdrproc_t)xdr_u_short, (char*)&port, tottimeout) != RPC_SUCCESS)
{ {
rt_kprintf("pmap failure\n"); rt_kprintf("pmap failure\n");
} }
CLNT_DESTROY(client); CLNT_DESTROY(client);
} }
(void) lwip_close(socket); (void) lwip_close(socket);
address->sin_port = 0; address->sin_port = 0;
return (port); return (port);
} }

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2006-2018, RT-Thread Development Team * Copyright (c) 2006-2021, RT-Thread Development Team
* *
* SPDX-License-Identifier: Apache-2.0 * SPDX-License-Identifier: Apache-2.0
* *
@ -14,51 +14,51 @@
/* The following procedures are supported by the protocol: /* The following procedures are supported by the protocol:
* *
* PMAPPROC_NULL() returns () * PMAPPROC_NULL() returns ()
* takes nothing, returns nothing * takes nothing, returns nothing
* *
* PMAPPROC_SET(struct pmap) returns (bool_t) * PMAPPROC_SET(struct pmap) returns (bool_t)
* TRUE is success, FALSE is failure. Registers the tuple * TRUE is success, FALSE is failure. Registers the tuple
* [prog, vers, prot, port]. * [prog, vers, prot, port].
* *
* PMAPPROC_UNSET(struct pmap) returns (bool_t) * PMAPPROC_UNSET(struct pmap) returns (bool_t)
* TRUE is success, FALSE is failure. Un-registers pair * TRUE is success, FALSE is failure. Un-registers pair
* [prog, vers]. prot and port are ignored. * [prog, vers]. prot and port are ignored.
* *
* PMAPPROC_GETPORT(struct pmap) returns (long unsigned). * PMAPPROC_GETPORT(struct pmap) returns (long unsigned).
* 0 is failure. Otherwise returns the port number where the pair * 0 is failure. Otherwise returns the port number where the pair
* [prog, vers] is registered. It may lie! * [prog, vers] is registered. It may lie!
* *
* PMAPPROC_DUMP() RETURNS (struct pmaplist *) * PMAPPROC_DUMP() RETURNS (struct pmaplist *)
* *
* PMAPPROC_CALLIT(unsigned, unsigned, unsigned, string<>) * PMAPPROC_CALLIT(unsigned, unsigned, unsigned, string<>)
* RETURNS (port, string<>); * RETURNS (port, string<>);
* usage: encapsulatedresults = PMAPPROC_CALLIT(prog, vers, proc, encapsulatedargs); * usage: encapsulatedresults = PMAPPROC_CALLIT(prog, vers, proc, encapsulatedargs);
* Calls the procedure on the local machine. If it is not registered, * Calls the procedure on the local machine. If it is not registered,
* this procedure is quite; ie it does not return error information!!! * this procedure is quite; ie it does not return error information!!!
* This procedure only is supported on rpc/udp and calls via * This procedure only is supported on rpc/udp and calls via
* rpc/udp. This routine only passes null authentication parameters. * rpc/udp. This routine only passes null authentication parameters.
* This file has no interface to xdr routines for PMAPPROC_CALLIT. * This file has no interface to xdr routines for PMAPPROC_CALLIT.
* *
* The service supports remote procedure calls on udp/ip or tcp/ip socket 111. * The service supports remote procedure calls on udp/ip or tcp/ip socket 111.
*/ */
#define PMAPPORT ((unsigned short)111) #define PMAPPORT ((unsigned short)111)
#define PMAPPROG ((unsigned long)100000) #define PMAPPROG ((unsigned long)100000)
#define PMAPVERS ((unsigned long)2) #define PMAPVERS ((unsigned long)2)
#define PMAPVERS_PROTO ((unsigned long)2) #define PMAPVERS_PROTO ((unsigned long)2)
#define PMAPVERS_ORIG ((unsigned long)1) #define PMAPVERS_ORIG ((unsigned long)1)
#define PMAPPROC_NULL ((unsigned long)0) #define PMAPPROC_NULL ((unsigned long)0)
#define PMAPPROC_SET ((unsigned long)1) #define PMAPPROC_SET ((unsigned long)1)
#define PMAPPROC_UNSET ((unsigned long)2) #define PMAPPROC_UNSET ((unsigned long)2)
#define PMAPPROC_GETPORT ((unsigned long)3) #define PMAPPROC_GETPORT ((unsigned long)3)
#define PMAPPROC_DUMP ((unsigned long)4) #define PMAPPROC_DUMP ((unsigned long)4)
#define PMAPPROC_CALLIT ((unsigned long)5) #define PMAPPROC_CALLIT ((unsigned long)5)
struct pmap { struct pmap {
long unsigned pm_prog; long unsigned pm_prog;
long unsigned pm_vers; long unsigned pm_vers;
long unsigned pm_prot; long unsigned pm_prot;
long unsigned pm_port; long unsigned pm_port;
}; };
extern bool_t xdr_pmap (XDR *__xdrs, struct pmap *__regs); extern bool_t xdr_pmap (XDR *__xdrs, struct pmap *__regs);

View File

@ -1,12 +1,12 @@
/* /*
* Copyright (c) 2006-2018, RT-Thread Development Team * Copyright (c) 2006-2021, RT-Thread Development Team
* *
* SPDX-License-Identifier: Apache-2.0 * SPDX-License-Identifier: Apache-2.0
* *
* Change Logs: * Change Logs:
* Date Author Notes * Date Author Notes
*/ */
/* @(#)rpc.h 2.3 88/08/10 4.0 RPCSRC; from 1.9 88/02/08 SMI */ /* @(#)rpc.h 2.3 88/08/10 4.0 RPCSRC; from 1.9 88/02/08 SMI */
/* /*
* Sun RPC is a product of Sun Microsystems, Inc. and is provided for * Sun RPC is a product of Sun Microsystems, Inc. and is provided for
* unrestricted use provided that this legend is included on all tape * unrestricted use provided that this legend is included on all tape
@ -46,17 +46,17 @@
#ifndef _RPC_RPC_H #ifndef _RPC_RPC_H
#define _RPC_RPC_H 1 #define _RPC_RPC_H 1
#include <rpc/types.h> /* some typedefs */ #include <rpc/types.h> /* some typedefs */
/* external data representation interfaces */ /* external data representation interfaces */
#include <rpc/xdr.h> /* generic (de)serializer */ #include <rpc/xdr.h> /* generic (de)serializer */
#include <rpc/auth.h> #include <rpc/auth.h>
/* Client side (mostly) remote procedure call */ /* Client side (mostly) remote procedure call */
#include <rpc/clnt.h> /* generic rpc stuff */ #include <rpc/clnt.h> /* generic rpc stuff */
/* semi-private protocol headers */ /* semi-private protocol headers */
#include <rpc/rpc_msg.h> /* protocol for rpc messages */ #include <rpc/rpc_msg.h> /* protocol for rpc messages */
#endif #endif

View File

@ -1,12 +1,12 @@
/* /*
* Copyright (c) 2006-2018, RT-Thread Development Team * Copyright (c) 2006-2021, RT-Thread Development Team
* *
* SPDX-License-Identifier: Apache-2.0 * SPDX-License-Identifier: Apache-2.0
* *
* Change Logs: * Change Logs:
* Date Author Notes * Date Author Notes
*/ */
/* @(#)rpc_msg.h 2.1 88/07/29 4.0 RPCSRC */ /* @(#)rpc_msg.h 2.1 88/07/29 4.0 RPCSRC */
/* /*
* Sun RPC is a product of Sun Microsystems, Inc. and is provided for * Sun RPC is a product of Sun Microsystems, Inc. and is provided for
* unrestricted use provided that this legend is included on all tape * unrestricted use provided that this legend is included on all tape
@ -50,8 +50,8 @@
* Copyright (C) 1984, Sun Microsystems, Inc. * Copyright (C) 1984, Sun Microsystems, Inc.
*/ */
#define RPC_MSG_VERSION ((unsigned long) 2) #define RPC_MSG_VERSION ((unsigned long) 2)
#define RPC_SERVICE_PORT ((unsigned short) 2048) #define RPC_SERVICE_PORT ((unsigned short) 2048)
/* /*
* Bottom up definition of an rpc message. * Bottom up definition of an rpc message.
@ -60,27 +60,27 @@
*/ */
enum msg_type { enum msg_type {
CALL=0, CALL=0,
REPLY=1 REPLY=1
}; };
enum reply_stat { enum reply_stat {
MSG_ACCEPTED=0, MSG_ACCEPTED=0,
MSG_DENIED=1 MSG_DENIED=1
}; };
enum accept_stat { enum accept_stat {
SUCCESS=0, SUCCESS=0,
PROG_UNAVAIL=1, PROG_UNAVAIL=1,
PROG_MISMATCH=2, PROG_MISMATCH=2,
PROC_UNAVAIL=3, PROC_UNAVAIL=3,
GARBAGE_ARGS=4, GARBAGE_ARGS=4,
SYSTEM_ERR=5 SYSTEM_ERR=5
}; };
enum reject_stat { enum reject_stat {
RPC_MISMATCH=0, RPC_MISMATCH=0,
AUTH_ERROR=1 AUTH_ERROR=1
}; };
/* /*
@ -93,111 +93,111 @@ enum reject_stat {
* accepted. * accepted.
*/ */
struct accepted_reply { struct accepted_reply {
struct opaque_auth ar_verf; struct opaque_auth ar_verf;
int ar_stat; int ar_stat;
union { union {
struct { struct {
unsigned long low; unsigned long low;
unsigned long high; unsigned long high;
} AR_versions; } AR_versions;
struct { struct {
char* where; char* where;
xdrproc_t proc; xdrproc_t proc;
} AR_results; } AR_results;
/* and many other null cases */ /* and many other null cases */
} ru; } ru;
#define ar_results ru.AR_results #define ar_results ru.AR_results
#define ar_vers ru.AR_versions #define ar_vers ru.AR_versions
}; };
/* /*
* Reply to an rpc request that was rejected by the server. * Reply to an rpc request that was rejected by the server.
*/ */
struct rejected_reply { struct rejected_reply {
int rj_stat; int rj_stat;
union { union {
struct { struct {
unsigned long low; unsigned long low;
unsigned long high; unsigned long high;
} RJ_versions; } RJ_versions;
int RJ_why; /* why authentication did not work */ int RJ_why; /* why authentication did not work */
} ru; } ru;
#define rj_vers ru.RJ_versions #define rj_vers ru.RJ_versions
#define rj_why ru.RJ_why #define rj_why ru.RJ_why
}; };
/* /*
* Body of a reply to an rpc request. * Body of a reply to an rpc request.
*/ */
struct reply_body { struct reply_body {
int rp_stat; int rp_stat;
union { union {
struct accepted_reply RP_ar; struct accepted_reply RP_ar;
struct rejected_reply RP_dr; struct rejected_reply RP_dr;
} ru; } ru;
#define rp_acpt ru.RP_ar #define rp_acpt ru.RP_ar
#define rp_rjct ru.RP_dr #define rp_rjct ru.RP_dr
}; };
/* /*
* Body of an rpc request call. * Body of an rpc request call.
*/ */
struct call_body { struct call_body {
unsigned long cb_rpcvers; /* must be equal to two */ unsigned long cb_rpcvers; /* must be equal to two */
unsigned long cb_prog; unsigned long cb_prog;
unsigned long cb_vers; unsigned long cb_vers;
unsigned long cb_proc; unsigned long cb_proc;
struct opaque_auth cb_cred; struct opaque_auth cb_cred;
struct opaque_auth cb_verf; /* protocol specific - provided by client */ struct opaque_auth cb_verf; /* protocol specific - provided by client */
}; };
/* /*
* The rpc message * The rpc message
*/ */
struct rpc_msg { struct rpc_msg {
unsigned long rm_xid; unsigned long rm_xid;
int rm_direction; int rm_direction;
union { union {
struct call_body RM_cmb; struct call_body RM_cmb;
struct reply_body RM_rmb; struct reply_body RM_rmb;
} ru; } ru;
#define rm_call ru.RM_cmb #define rm_call ru.RM_cmb
#define rm_reply ru.RM_rmb #define rm_reply ru.RM_rmb
}; };
#define acpted_rply ru.RM_rmb.ru.RP_ar #define acpted_rply ru.RM_rmb.ru.RP_ar
#define rjcted_rply ru.RM_rmb.ru.RP_dr #define rjcted_rply ru.RM_rmb.ru.RP_dr
/* /*
* XDR routine to handle a rpc message. * XDR routine to handle a rpc message.
* xdr_callmsg(xdrs, cmsg) * xdr_callmsg(xdrs, cmsg)
* XDR *xdrs; * XDR *xdrs;
* struct rpc_msg *cmsg; * struct rpc_msg *cmsg;
*/ */
extern bool_t xdr_callmsg (XDR *__xdrs, struct rpc_msg *__cmsg); extern bool_t xdr_callmsg (XDR *__xdrs, struct rpc_msg *__cmsg);
/* /*
* XDR routine to pre-serialize the static part of a rpc message. * XDR routine to pre-serialize the static part of a rpc message.
* xdr_callhdr(xdrs, cmsg) * xdr_callhdr(xdrs, cmsg)
* XDR *xdrs; * XDR *xdrs;
* struct rpc_msg *cmsg; * struct rpc_msg *cmsg;
*/ */
extern bool_t xdr_callhdr (XDR *__xdrs, struct rpc_msg *__cmsg); extern bool_t xdr_callhdr (XDR *__xdrs, struct rpc_msg *__cmsg);
/* /*
* XDR routine to handle a rpc reply. * XDR routine to handle a rpc reply.
* xdr_replymsg(xdrs, rmsg) * xdr_replymsg(xdrs, rmsg)
* XDR *xdrs; * XDR *xdrs;
* struct rpc_msg *rmsg; * struct rpc_msg *rmsg;
*/ */
extern bool_t xdr_replymsg (XDR *__xdrs, struct rpc_msg *__rmsg); extern bool_t xdr_replymsg (XDR *__xdrs, struct rpc_msg *__rmsg);
/* /*
* Fills in the error part of a reply message. * Fills in the error part of a reply message.
* _seterr_reply(msg, error) * _seterr_reply(msg, error)
* struct rpc_msg *msg; * struct rpc_msg *msg;
* struct rpc_err *error; * struct rpc_err *error;
*/ */
extern void _seterr_reply (struct rpc_msg *__msg, struct rpc_err *__error); extern void _seterr_reply (struct rpc_msg *__msg, struct rpc_err *__error);
#endif /* rpc/rpc_msg.h */ #endif /* rpc/rpc_msg.h */

View File

@ -1,12 +1,12 @@
/* /*
* Copyright (c) 2006-2018, RT-Thread Development Team * Copyright (c) 2006-2021, RT-Thread Development Team
* *
* SPDX-License-Identifier: Apache-2.0 * SPDX-License-Identifier: Apache-2.0
* *
* Change Logs: * Change Logs:
* Date Author Notes * Date Author Notes
*/ */
/* @(#)rpc_prot.c 2.3 88/08/07 4.0 RPCSRC */ /* @(#)rpc_prot.c 2.3 88/08/07 4.0 RPCSRC */
/* /*
* Sun RPC is a product of Sun Microsystems, Inc. and is provided for * Sun RPC is a product of Sun Microsystems, Inc. and is provided for
* unrestricted use provided that this legend is included on all tape * unrestricted use provided that this legend is included on all tape
@ -14,23 +14,23 @@
* may copy or modify Sun RPC without charge, but are not authorized * may copy or modify Sun RPC without charge, but are not authorized
* to license or distribute it to anyone else except as part of a product or * to license or distribute it to anyone else except as part of a product or
* program developed by the user. * program developed by the user.
* *
* SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE
* WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR * WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR
* PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE. * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE.
* *
* Sun RPC is provided with no support and without any obligation on the * Sun RPC is provided with no support and without any obligation on the
* part of Sun Microsystems, Inc. to assist in its use, correction, * part of Sun Microsystems, Inc. to assist in its use, correction,
* modification or enhancement. * modification or enhancement.
* *
* SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE
* INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC
* OR ANY PART THEREOF. * OR ANY PART THEREOF.
* *
* In no event will Sun Microsystems, Inc. be liable for any lost revenue * In no event will Sun Microsystems, Inc. be liable for any lost revenue
* or profits or other special, indirect and consequential damages, even if * or profits or other special, indirect and consequential damages, even if
* Sun has been advised of the possibility of such damages. * Sun has been advised of the possibility of such damages.
* *
* Sun Microsystems, Inc. * Sun Microsystems, Inc.
* 2550 Garcia Avenue * 2550 Garcia Avenue
* Mountain View, California 94043 * Mountain View, California 94043
@ -63,10 +63,10 @@ static char sccsid[] = "@(#)rpc_prot.c 1.36 87/08/11 Copyr 1984 Sun Micro";
bool_t xdr_opaque_auth(XDR *xdrs, struct opaque_auth *ap) bool_t xdr_opaque_auth(XDR *xdrs, struct opaque_auth *ap)
{ {
if (xdr_enum(xdrs, &(ap->oa_flavor))) if (xdr_enum(xdrs, &(ap->oa_flavor)))
return (xdr_bytes(xdrs, &ap->oa_base, return (xdr_bytes(xdrs, &ap->oa_base,
&ap->oa_length, MAX_AUTH_BYTES)); &ap->oa_length, MAX_AUTH_BYTES));
return (FALSE); return (FALSE);
} }
/* /*
@ -74,7 +74,7 @@ bool_t xdr_opaque_auth(XDR *xdrs, struct opaque_auth *ap)
*/ */
bool_t xdr_des_block(XDR *xdrs, des_block *blkp) bool_t xdr_des_block(XDR *xdrs, des_block *blkp)
{ {
return (xdr_opaque(xdrs, (char*) blkp, sizeof(des_block))); return (xdr_opaque(xdrs, (char*) blkp, sizeof(des_block)));
} }
/* * * * * * * * * * * * * * XDR RPC MESSAGE * * * * * * * * * * * * * * * */ /* * * * * * * * * * * * * * XDR RPC MESSAGE * * * * * * * * * * * * * * * */
@ -85,22 +85,22 @@ bool_t xdr_des_block(XDR *xdrs, des_block *blkp)
static bool_t xdr_accepted_reply(XDR *xdrs, struct accepted_reply *ar) static bool_t xdr_accepted_reply(XDR *xdrs, struct accepted_reply *ar)
{ {
/* personalized union, rather than calling xdr_union */ /* personalized union, rather than calling xdr_union */
if (!xdr_opaque_auth(xdrs, &(ar->ar_verf))) if (!xdr_opaque_auth(xdrs, &(ar->ar_verf)))
return (FALSE); return (FALSE);
if (!xdr_enum(xdrs, (enum_t *) & (ar->ar_stat))) if (!xdr_enum(xdrs, (enum_t *) & (ar->ar_stat)))
return (FALSE); return (FALSE);
switch (ar->ar_stat) { switch (ar->ar_stat) {
case SUCCESS: case SUCCESS:
return ((*(ar->ar_results.proc)) (xdrs, ar->ar_results.where)); return ((*(ar->ar_results.proc)) (xdrs, ar->ar_results.where));
case PROG_MISMATCH: case PROG_MISMATCH:
if (!xdr_u_long(xdrs, &(ar->ar_vers.low))) if (!xdr_u_long(xdrs, &(ar->ar_vers.low)))
return (FALSE); return (FALSE);
return (xdr_u_long(xdrs, &(ar->ar_vers.high))); return (xdr_u_long(xdrs, &(ar->ar_vers.high)));
} }
return (TRUE); /* TRUE => open ended set of problems */ return (TRUE); /* TRUE => open ended set of problems */
} }
/* /*
@ -109,26 +109,26 @@ static bool_t xdr_accepted_reply(XDR *xdrs, struct accepted_reply *ar)
static bool_t xdr_rejected_reply(XDR *xdrs, struct rejected_reply *rr) static bool_t xdr_rejected_reply(XDR *xdrs, struct rejected_reply *rr)
{ {
/* personalized union, rather than calling xdr_union */ /* personalized union, rather than calling xdr_union */
if (!xdr_enum(xdrs, (enum_t *) & (rr->rj_stat))) if (!xdr_enum(xdrs, (enum_t *) & (rr->rj_stat)))
return (FALSE); return (FALSE);
switch (rr->rj_stat) { switch (rr->rj_stat) {
case RPC_MISMATCH: case RPC_MISMATCH:
if (!xdr_u_long(xdrs, &(rr->rj_vers.low))) if (!xdr_u_long(xdrs, &(rr->rj_vers.low)))
return (FALSE); return (FALSE);
return (xdr_u_long(xdrs, &(rr->rj_vers.high))); return (xdr_u_long(xdrs, &(rr->rj_vers.high)));
case AUTH_ERROR: case AUTH_ERROR:
return (xdr_enum(xdrs, (enum_t *) & (rr->rj_why))); return (xdr_enum(xdrs, (enum_t *) & (rr->rj_why)));
} }
return (FALSE); return (FALSE);
} }
static struct xdr_discrim reply_dscrm[3] = { static struct xdr_discrim reply_dscrm[3] = {
{(int) MSG_ACCEPTED, (xdrproc_t)xdr_accepted_reply}, {(int) MSG_ACCEPTED, (xdrproc_t)xdr_accepted_reply},
{(int) MSG_DENIED, (xdrproc_t)xdr_rejected_reply}, {(int) MSG_DENIED, (xdrproc_t)xdr_rejected_reply},
{__dontcare__, NULL_xdrproc_t} {__dontcare__, NULL_xdrproc_t}
}; };
/* /*
@ -136,13 +136,13 @@ static struct xdr_discrim reply_dscrm[3] = {
*/ */
bool_t xdr_replymsg(XDR *xdrs, struct rpc_msg *rmsg) bool_t xdr_replymsg(XDR *xdrs, struct rpc_msg *rmsg)
{ {
if (xdr_u_long(xdrs, &(rmsg->rm_xid)) && if (xdr_u_long(xdrs, &(rmsg->rm_xid)) &&
xdr_enum(xdrs, (enum_t *) & (rmsg->rm_direction)) && xdr_enum(xdrs, (enum_t *) & (rmsg->rm_direction)) &&
(rmsg->rm_direction == REPLY)) (rmsg->rm_direction == REPLY))
return (xdr_union(xdrs, (enum_t *) & (rmsg->rm_reply.rp_stat), return (xdr_union(xdrs, (enum_t *) & (rmsg->rm_reply.rp_stat),
(char*) & (rmsg->rm_reply.ru), reply_dscrm, (char*) & (rmsg->rm_reply.ru), reply_dscrm,
NULL_xdrproc_t)); NULL_xdrproc_t));
return (FALSE); return (FALSE);
} }
@ -154,16 +154,16 @@ bool_t xdr_replymsg(XDR *xdrs, struct rpc_msg *rmsg)
bool_t xdr_callhdr(XDR *xdrs, struct rpc_msg *cmsg) bool_t xdr_callhdr(XDR *xdrs, struct rpc_msg *cmsg)
{ {
cmsg->rm_direction = CALL; cmsg->rm_direction = CALL;
cmsg->rm_call.cb_rpcvers = RPC_MSG_VERSION; cmsg->rm_call.cb_rpcvers = RPC_MSG_VERSION;
if ( if (
(xdrs->x_op == XDR_ENCODE) && (xdrs->x_op == XDR_ENCODE) &&
xdr_u_long(xdrs, &(cmsg->rm_xid)) && xdr_u_long(xdrs, &(cmsg->rm_xid)) &&
xdr_enum(xdrs, (enum_t *) & (cmsg->rm_direction)) && xdr_enum(xdrs, (enum_t *) & (cmsg->rm_direction)) &&
xdr_u_long(xdrs, &(cmsg->rm_call.cb_rpcvers)) && xdr_u_long(xdrs, &(cmsg->rm_call.cb_rpcvers)) &&
xdr_u_long(xdrs, &(cmsg->rm_call.cb_prog))) xdr_u_long(xdrs, &(cmsg->rm_call.cb_prog)))
return (xdr_u_long(xdrs, &(cmsg->rm_call.cb_vers))); return (xdr_u_long(xdrs, &(cmsg->rm_call.cb_vers)));
return (FALSE); return (FALSE);
} }
/* ************************** Client utility routine ************* */ /* ************************** Client utility routine ************* */
@ -171,55 +171,55 @@ bool_t xdr_callhdr(XDR *xdrs, struct rpc_msg *cmsg)
static void accepted(enum accept_stat acpt_stat, struct rpc_err *error) static void accepted(enum accept_stat acpt_stat, struct rpc_err *error)
{ {
switch (acpt_stat) { switch (acpt_stat) {
case PROG_UNAVAIL: case PROG_UNAVAIL:
error->re_status = RPC_PROGUNAVAIL; error->re_status = RPC_PROGUNAVAIL;
return; return;
case PROG_MISMATCH: case PROG_MISMATCH:
error->re_status = RPC_PROGVERSMISMATCH; error->re_status = RPC_PROGVERSMISMATCH;
return; return;
case PROC_UNAVAIL: case PROC_UNAVAIL:
error->re_status = RPC_PROCUNAVAIL; error->re_status = RPC_PROCUNAVAIL;
return; return;
case GARBAGE_ARGS: case GARBAGE_ARGS:
error->re_status = RPC_CANTDECODEARGS; error->re_status = RPC_CANTDECODEARGS;
return; return;
case SYSTEM_ERR: case SYSTEM_ERR:
error->re_status = RPC_SYSTEMERROR; error->re_status = RPC_SYSTEMERROR;
return; return;
case SUCCESS: case SUCCESS:
error->re_status = RPC_SUCCESS; error->re_status = RPC_SUCCESS;
return; return;
} }
/* something's wrong, but we don't know what ... */ /* something's wrong, but we don't know what ... */
error->re_status = RPC_FAILED; error->re_status = RPC_FAILED;
error->re_lb.s1 = (long) MSG_ACCEPTED; error->re_lb.s1 = (long) MSG_ACCEPTED;
error->re_lb.s2 = (long) acpt_stat; error->re_lb.s2 = (long) acpt_stat;
} }
static void rejected(enum reject_stat rjct_stat, struct rpc_err *error) static void rejected(enum reject_stat rjct_stat, struct rpc_err *error)
{ {
switch (rjct_stat) { switch (rjct_stat) {
case RPC_VERSMISMATCH: case RPC_VERSMISMATCH:
error->re_status = RPC_VERSMISMATCH; error->re_status = RPC_VERSMISMATCH;
return; return;
case AUTH_ERROR: case AUTH_ERROR:
error->re_status = RPC_AUTHERROR; error->re_status = RPC_AUTHERROR;
return; return;
} }
/* something's wrong, but we don't know what ... */ /* something's wrong, but we don't know what ... */
error->re_status = RPC_FAILED; error->re_status = RPC_FAILED;
error->re_lb.s1 = (long) MSG_DENIED; error->re_lb.s1 = (long) MSG_DENIED;
error->re_lb.s2 = (long) rjct_stat; error->re_lb.s2 = (long) rjct_stat;
} }
/* /*
@ -228,40 +228,40 @@ static void rejected(enum reject_stat rjct_stat, struct rpc_err *error)
void _seterr_reply(struct rpc_msg *msg, struct rpc_err *error) void _seterr_reply(struct rpc_msg *msg, struct rpc_err *error)
{ {
/* optimized for normal, SUCCESSful case */ /* optimized for normal, SUCCESSful case */
switch (msg->rm_reply.rp_stat) { switch (msg->rm_reply.rp_stat) {
case MSG_ACCEPTED: case MSG_ACCEPTED:
if (msg->acpted_rply.ar_stat == SUCCESS) { if (msg->acpted_rply.ar_stat == SUCCESS) {
error->re_status = RPC_SUCCESS; error->re_status = RPC_SUCCESS;
return; return;
}; };
accepted((enum accept_stat)msg->acpted_rply.ar_stat, error); accepted((enum accept_stat)msg->acpted_rply.ar_stat, error);
break; break;
case MSG_DENIED: case MSG_DENIED:
rejected((enum reject_stat)msg->rjcted_rply.rj_stat, error); rejected((enum reject_stat)msg->rjcted_rply.rj_stat, error);
break; break;
default: default:
error->re_status = RPC_FAILED; error->re_status = RPC_FAILED;
error->re_lb.s1 = (long) (msg->rm_reply.rp_stat); error->re_lb.s1 = (long) (msg->rm_reply.rp_stat);
break; break;
} }
switch (error->re_status) { switch (error->re_status) {
case RPC_VERSMISMATCH: case RPC_VERSMISMATCH:
error->re_vers.low = msg->rjcted_rply.rj_vers.low; error->re_vers.low = msg->rjcted_rply.rj_vers.low;
error->re_vers.high = msg->rjcted_rply.rj_vers.high; error->re_vers.high = msg->rjcted_rply.rj_vers.high;
break; break;
case RPC_AUTHERROR: case RPC_AUTHERROR:
error->re_why = msg->rjcted_rply.rj_why; error->re_why = msg->rjcted_rply.rj_why;
break; break;
case RPC_PROGVERSMISMATCH: case RPC_PROGVERSMISMATCH:
error->re_vers.low = msg->acpted_rply.ar_vers.low; error->re_vers.low = msg->acpted_rply.ar_vers.low;
error->re_vers.high = msg->acpted_rply.ar_vers.high; error->re_vers.high = msg->acpted_rply.ar_vers.high;
break; break;
} }
} }

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2006-2018, RT-Thread Development Team * Copyright (c) 2006-2021, RT-Thread Development Team
* *
* SPDX-License-Identifier: Apache-2.0 * SPDX-License-Identifier: Apache-2.0
* *

View File

@ -1,12 +1,12 @@
/* /*
* Copyright (c) 2006-2018, RT-Thread Development Team * Copyright (c) 2006-2021, RT-Thread Development Team
* *
* SPDX-License-Identifier: Apache-2.0 * SPDX-License-Identifier: Apache-2.0
* *
* Change Logs: * Change Logs:
* Date Author Notes * Date Author Notes
*/ */
/* @(#)xdr.c 2.1 88/07/29 4.0 RPCSRC */ /* @(#)xdr.c 2.1 88/07/29 4.0 RPCSRC */
/* /*
* Sun RPC is a product of Sun Microsystems, Inc. and is provided for * Sun RPC is a product of Sun Microsystems, Inc. and is provided for
* unrestricted use provided that this legend is included on all tape * unrestricted use provided that this legend is included on all tape
@ -14,23 +14,23 @@
* may copy or modify Sun RPC without charge, but are not authorized * may copy or modify Sun RPC without charge, but are not authorized
* to license or distribute it to anyone else except as part of a product or * to license or distribute it to anyone else except as part of a product or
* program developed by the user. * program developed by the user.
* *
* SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE
* WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR * WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR
* PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE. * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE.
* *
* Sun RPC is provided with no support and without any obligation on the * Sun RPC is provided with no support and without any obligation on the
* part of Sun Microsystems, Inc. to assist in its use, correction, * part of Sun Microsystems, Inc. to assist in its use, correction,
* modification or enhancement. * modification or enhancement.
* *
* SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE
* INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC
* OR ANY PART THEREOF. * OR ANY PART THEREOF.
* *
* In no event will Sun Microsystems, Inc. be liable for any lost revenue * In no event will Sun Microsystems, Inc. be liable for any lost revenue
* or profits or other special, indirect and consequential damages, even if * or profits or other special, indirect and consequential damages, even if
* Sun has been advised of the possibility of such damages. * Sun has been advised of the possibility of such damages.
* *
* Sun Microsystems, Inc. * Sun Microsystems, Inc.
* 2550 Garcia Avenue * 2550 Garcia Avenue
* Mountain View, California 94043 * Mountain View, California 94043
@ -58,9 +58,9 @@ static char sccsid[] = "@(#)xdr.c 1.35 87/08/12";
/* /*
* constants specific to the xdr "protocol" * constants specific to the xdr "protocol"
*/ */
#define XDR_FALSE ((long) 0) #define XDR_FALSE ((long) 0)
#define XDR_TRUE ((long) 1) #define XDR_TRUE ((long) 1)
#define LASTUNSIGNED ((unsigned int) 0-1) #define LASTUNSIGNED ((unsigned int) 0-1)
/* /*
* for unit alignment * for unit alignment
@ -73,21 +73,21 @@ static char xdr_zero[BYTES_PER_XDR_UNIT] = { 0, 0, 0, 0 };
*/ */
void xdr_free(xdrproc_t proc, char* objp) void xdr_free(xdrproc_t proc, char* objp)
{ {
XDR x; XDR x;
x.x_op = XDR_FREE; x.x_op = XDR_FREE;
(*proc) (&x, objp); (*proc) (&x, objp);
} }
/* /*
* XDR nothing * XDR nothing
*/ */
bool_t xdr_void( /* xdrs, addr */ ) bool_t xdr_void( /* xdrs, addr */ )
/* XDR *xdrs; */ /* XDR *xdrs; */
/* char* addr; */ /* char* addr; */
{ {
return (TRUE); return (TRUE);
} }
/* /*
@ -95,25 +95,25 @@ bool_t xdr_void( /* xdrs, addr */ )
*/ */
bool_t xdr_int(XDR* xdrs, int* ip) bool_t xdr_int(XDR* xdrs, int* ip)
{ {
if (sizeof(int) == sizeof(long)) { if (sizeof(int) == sizeof(long)) {
return (xdr_long(xdrs, (long *) ip)); return (xdr_long(xdrs, (long *) ip));
} else if (sizeof(int) < sizeof(long)) { } else if (sizeof(int) < sizeof(long)) {
long l; long l;
switch (xdrs->x_op) { switch (xdrs->x_op) {
case XDR_ENCODE: case XDR_ENCODE:
l = (long) *ip; l = (long) *ip;
return XDR_PUTLONG(xdrs, &l); return XDR_PUTLONG(xdrs, &l);
case XDR_DECODE: case XDR_DECODE:
if (!XDR_GETLONG(xdrs, &l)) if (!XDR_GETLONG(xdrs, &l))
return FALSE; return FALSE;
*ip = (int) l; *ip = (int) l;
case XDR_FREE: case XDR_FREE:
return TRUE; return TRUE;
} }
return FALSE; return FALSE;
} else { } else {
return (xdr_short(xdrs, (short *) ip)); return (xdr_short(xdrs, (short *) ip));
} }
} }
/* /*
@ -121,25 +121,25 @@ bool_t xdr_int(XDR* xdrs, int* ip)
*/ */
bool_t xdr_u_int(XDR* xdrs, unsigned int* up) bool_t xdr_u_int(XDR* xdrs, unsigned int* up)
{ {
if (sizeof(unsigned int) == sizeof(unsigned long)) { if (sizeof(unsigned int) == sizeof(unsigned long)) {
return (xdr_u_long(xdrs, (unsigned long *) up)); return (xdr_u_long(xdrs, (unsigned long *) up));
} else if (sizeof(unsigned int) < sizeof(unsigned long)) { } else if (sizeof(unsigned int) < sizeof(unsigned long)) {
unsigned long l; unsigned long l;
switch (xdrs->x_op) { switch (xdrs->x_op) {
case XDR_ENCODE: case XDR_ENCODE:
l = (unsigned long) *up; l = (unsigned long) *up;
return XDR_PUTLONG(xdrs, (long*)&l); return XDR_PUTLONG(xdrs, (long*)&l);
case XDR_DECODE: case XDR_DECODE:
if (!XDR_GETLONG(xdrs, (long*)&l)) if (!XDR_GETLONG(xdrs, (long*)&l))
return FALSE; return FALSE;
*up = (unsigned int) l; *up = (unsigned int) l;
case XDR_FREE: case XDR_FREE:
return TRUE; return TRUE;
} }
return FALSE; return FALSE;
} else { } else {
return (xdr_short(xdrs, (short *) up)); return (xdr_short(xdrs, (short *) up));
} }
} }
/* /*
@ -149,18 +149,18 @@ bool_t xdr_u_int(XDR* xdrs, unsigned int* up)
bool_t xdr_long(XDR* xdrs, long* lp) bool_t xdr_long(XDR* xdrs, long* lp)
{ {
if (xdrs->x_op == XDR_ENCODE if (xdrs->x_op == XDR_ENCODE
&& (sizeof(int32_t) == sizeof(long) && (sizeof(int32_t) == sizeof(long)
|| (int32_t) *lp == *lp)) || (int32_t) *lp == *lp))
return (XDR_PUTLONG(xdrs, lp)); return (XDR_PUTLONG(xdrs, lp));
if (xdrs->x_op == XDR_DECODE) if (xdrs->x_op == XDR_DECODE)
return (XDR_GETLONG(xdrs, lp)); return (XDR_GETLONG(xdrs, lp));
if (xdrs->x_op == XDR_FREE) if (xdrs->x_op == XDR_FREE)
return (TRUE); return (TRUE);
return (FALSE); return (FALSE);
} }
/* /*
@ -171,25 +171,25 @@ bool_t xdr_u_long(XDR* xdrs, unsigned long* ulp)
{ {
if (xdrs->x_op == XDR_DECODE) { if (xdrs->x_op == XDR_DECODE) {
long l; long l;
if (XDR_GETLONG(xdrs, &l) == FALSE) if (XDR_GETLONG(xdrs, &l) == FALSE)
return FALSE; return FALSE;
*ulp = (uint32_t) l; *ulp = (uint32_t) l;
return TRUE; return TRUE;
} }
if (xdrs->x_op == XDR_ENCODE) { if (xdrs->x_op == XDR_ENCODE) {
if (sizeof(uint32_t) != sizeof(unsigned long) if (sizeof(uint32_t) != sizeof(unsigned long)
&& (uint32_t) *ulp != *ulp) && (uint32_t) *ulp != *ulp)
return FALSE; return FALSE;
return (XDR_PUTLONG(xdrs, (long *) ulp)); return (XDR_PUTLONG(xdrs, (long *) ulp));
} }
if (xdrs->x_op == XDR_FREE) if (xdrs->x_op == XDR_FREE)
return (TRUE); return (TRUE);
return (FALSE); return (FALSE);
} }
@ -254,25 +254,25 @@ bool_t xdr_u_longlong_t (XDR * xdrs, unsigned long long* ullp)
*/ */
bool_t xdr_short(XDR* xdrs, short* sp) bool_t xdr_short(XDR* xdrs, short* sp)
{ {
long l; long l;
switch (xdrs->x_op) { switch (xdrs->x_op) {
case XDR_ENCODE: case XDR_ENCODE:
l = (long) *sp; l = (long) *sp;
return (XDR_PUTLONG(xdrs, &l)); return (XDR_PUTLONG(xdrs, &l));
case XDR_DECODE: case XDR_DECODE:
if (!XDR_GETLONG(xdrs, &l)) { if (!XDR_GETLONG(xdrs, &l)) {
return (FALSE); return (FALSE);
} }
*sp = (short) l; *sp = (short) l;
return (TRUE); return (TRUE);
case XDR_FREE: case XDR_FREE:
return (TRUE); return (TRUE);
} }
return (FALSE); return (FALSE);
} }
/* /*
@ -280,25 +280,25 @@ bool_t xdr_short(XDR* xdrs, short* sp)
*/ */
bool_t xdr_u_short(XDR* xdrs, unsigned short* usp) bool_t xdr_u_short(XDR* xdrs, unsigned short* usp)
{ {
unsigned long l; unsigned long l;
switch (xdrs->x_op) { switch (xdrs->x_op) {
case XDR_ENCODE: case XDR_ENCODE:
l = (unsigned long) * usp; l = (unsigned long) * usp;
return (XDR_PUTLONG(xdrs, (long*)&l)); return (XDR_PUTLONG(xdrs, (long*)&l));
case XDR_DECODE: case XDR_DECODE:
if (!XDR_GETLONG(xdrs, (long*)&l)) { if (!XDR_GETLONG(xdrs, (long*)&l)) {
return (FALSE); return (FALSE);
} }
*usp = (unsigned short) l; *usp = (unsigned short) l;
return (TRUE); return (TRUE);
case XDR_FREE: case XDR_FREE:
return (TRUE); return (TRUE);
} }
return (FALSE); return (FALSE);
} }
@ -307,14 +307,14 @@ bool_t xdr_u_short(XDR* xdrs, unsigned short* usp)
*/ */
bool_t xdr_char(XDR* xdrs, char* cp) bool_t xdr_char(XDR* xdrs, char* cp)
{ {
int i; int i;
i = (*cp); i = (*cp);
if (!xdr_int(xdrs, &i)) { if (!xdr_int(xdrs, &i)) {
return (FALSE); return (FALSE);
} }
*cp = i; *cp = i;
return (TRUE); return (TRUE);
} }
/* /*
@ -322,14 +322,14 @@ bool_t xdr_char(XDR* xdrs, char* cp)
*/ */
bool_t xdr_u_char(XDR* xdrs, unsigned char* cp) bool_t xdr_u_char(XDR* xdrs, unsigned char* cp)
{ {
unsigned int u; unsigned int u;
u = (*cp); u = (*cp);
if (!xdr_u_int(xdrs, &u)) { if (!xdr_u_int(xdrs, &u)) {
return (FALSE); return (FALSE);
} }
*cp = u; *cp = u;
return (TRUE); return (TRUE);
} }
/* /*
@ -337,25 +337,25 @@ bool_t xdr_u_char(XDR* xdrs, unsigned char* cp)
*/ */
bool_t xdr_bool(XDR *xdrs, bool_t *bp) bool_t xdr_bool(XDR *xdrs, bool_t *bp)
{ {
long lb; long lb;
switch (xdrs->x_op) { switch (xdrs->x_op) {
case XDR_ENCODE: case XDR_ENCODE:
lb = *bp ? XDR_TRUE : XDR_FALSE; lb = *bp ? XDR_TRUE : XDR_FALSE;
return (XDR_PUTLONG(xdrs, &lb)); return (XDR_PUTLONG(xdrs, &lb));
case XDR_DECODE: case XDR_DECODE:
if (!XDR_GETLONG(xdrs, &lb)) { if (!XDR_GETLONG(xdrs, &lb)) {
return (FALSE); return (FALSE);
} }
*bp = (lb == XDR_FALSE) ? FALSE : TRUE; *bp = (lb == XDR_FALSE) ? FALSE : TRUE;
return (TRUE); return (TRUE);
case XDR_FREE: case XDR_FREE:
return (TRUE); return (TRUE);
} }
return (FALSE); return (FALSE);
} }
/* /*
@ -363,10 +363,10 @@ bool_t xdr_bool(XDR *xdrs, bool_t *bp)
*/ */
bool_t xdr_enum(XDR *xdrs, enum_t *ep) bool_t xdr_enum(XDR *xdrs, enum_t *ep)
{ {
/* /*
* enums are treated as ints * enums are treated as ints
*/ */
return (xdr_long(xdrs, (long *) ep)); return (xdr_long(xdrs, (long *) ep));
} }
/* /*
@ -376,45 +376,45 @@ bool_t xdr_enum(XDR *xdrs, enum_t *ep)
*/ */
bool_t xdr_opaque(XDR *xdrs, char* cp, unsigned int cnt) bool_t xdr_opaque(XDR *xdrs, char* cp, unsigned int cnt)
{ {
register unsigned int rndup; register unsigned int rndup;
static char crud[BYTES_PER_XDR_UNIT]; static char crud[BYTES_PER_XDR_UNIT];
/* /*
* if no data we are done * if no data we are done
*/ */
if (cnt == 0) if (cnt == 0)
return (TRUE); return (TRUE);
/* /*
* round byte count to full xdr units * round byte count to full xdr units
*/ */
rndup = cnt % BYTES_PER_XDR_UNIT; rndup = cnt % BYTES_PER_XDR_UNIT;
if (rndup > 0) if (rndup > 0)
rndup = BYTES_PER_XDR_UNIT - rndup; rndup = BYTES_PER_XDR_UNIT - rndup;
if (xdrs->x_op == XDR_DECODE) { if (xdrs->x_op == XDR_DECODE) {
if (!XDR_GETBYTES(xdrs, cp, cnt)) { if (!XDR_GETBYTES(xdrs, cp, cnt)) {
return (FALSE); return (FALSE);
} }
if (rndup == 0) if (rndup == 0)
return (TRUE); return (TRUE);
return (XDR_GETBYTES(xdrs, crud, rndup)); return (XDR_GETBYTES(xdrs, crud, rndup));
} }
if (xdrs->x_op == XDR_ENCODE) { if (xdrs->x_op == XDR_ENCODE) {
if (!XDR_PUTBYTES(xdrs, cp, cnt)) { if (!XDR_PUTBYTES(xdrs, cp, cnt)) {
return (FALSE); return (FALSE);
} }
if (rndup == 0) if (rndup == 0)
return (TRUE); return (TRUE);
return (XDR_PUTBYTES(xdrs, xdr_zero, rndup)); return (XDR_PUTBYTES(xdrs, xdr_zero, rndup));
} }
if (xdrs->x_op == XDR_FREE) { if (xdrs->x_op == XDR_FREE) {
return (TRUE); return (TRUE);
} }
return (FALSE); return (FALSE);
} }
/* /*
@ -424,49 +424,49 @@ bool_t xdr_opaque(XDR *xdrs, char* cp, unsigned int cnt)
*/ */
bool_t xdr_bytes(XDR *xdrs, char** cpp, unsigned int *sizep, unsigned int maxsize) bool_t xdr_bytes(XDR *xdrs, char** cpp, unsigned int *sizep, unsigned int maxsize)
{ {
register char *sp = *cpp; /* sp is the actual string pointer */ register char *sp = *cpp; /* sp is the actual string pointer */
register unsigned int nodesize; register unsigned int nodesize;
/* /*
* first deal with the length since xdr bytes are counted * first deal with the length since xdr bytes are counted
*/ */
if (!xdr_u_int(xdrs, sizep)) { if (!xdr_u_int(xdrs, sizep)) {
return (FALSE); return (FALSE);
} }
nodesize = *sizep; nodesize = *sizep;
if ((nodesize > maxsize) && (xdrs->x_op != XDR_FREE)) { if ((nodesize > maxsize) && (xdrs->x_op != XDR_FREE)) {
return (FALSE); return (FALSE);
} }
/* /*
* now deal with the actual bytes * now deal with the actual bytes
*/ */
switch (xdrs->x_op) { switch (xdrs->x_op) {
case XDR_DECODE: case XDR_DECODE:
if (nodesize == 0) { if (nodesize == 0) {
return (TRUE); return (TRUE);
} }
if (sp == NULL) { if (sp == NULL) {
*cpp = sp = (char *) rt_malloc(nodesize); *cpp = sp = (char *) rt_malloc(nodesize);
} }
if (sp == NULL) { if (sp == NULL) {
rt_kprintf("xdr_bytes: out of memory\n"); rt_kprintf("xdr_bytes: out of memory\n");
return (FALSE); return (FALSE);
} }
/* fall into ... */ /* fall into ... */
case XDR_ENCODE: case XDR_ENCODE:
return (xdr_opaque(xdrs, sp, nodesize)); return (xdr_opaque(xdrs, sp, nodesize));
case XDR_FREE: case XDR_FREE:
if (sp != NULL) { if (sp != NULL) {
rt_free(sp); rt_free(sp);
*cpp = NULL; *cpp = NULL;
} }
return (TRUE); return (TRUE);
} }
return (FALSE); return (FALSE);
} }
/* /*
@ -474,7 +474,7 @@ bool_t xdr_bytes(XDR *xdrs, char** cpp, unsigned int *sizep, unsigned int maxsiz
*/ */
bool_t xdr_netobj(XDR *xdrs, struct netobj *np) bool_t xdr_netobj(XDR *xdrs, struct netobj *np)
{ {
return (xdr_bytes(xdrs, &np->n_bytes, &np->n_len, MAX_NETOBJ_SZ)); return (xdr_bytes(xdrs, &np->n_bytes, &np->n_len, MAX_NETOBJ_SZ));
} }
/* /*
@ -490,30 +490,30 @@ bool_t xdr_netobj(XDR *xdrs, struct netobj *np)
*/ */
bool_t xdr_union(XDR* xdrs, enum_t* dscmp, char* unp, const struct xdr_discrim* choices, xdrproc_t dfault) bool_t xdr_union(XDR* xdrs, enum_t* dscmp, char* unp, const struct xdr_discrim* choices, xdrproc_t dfault)
{ {
register enum_t dscm; register enum_t dscm;
/* /*
* we deal with the discriminator; it's an enum * we deal with the discriminator; it's an enum
*/ */
if (!xdr_enum(xdrs, dscmp)) { if (!xdr_enum(xdrs, dscmp)) {
return (FALSE); return (FALSE);
} }
dscm = *dscmp; dscm = *dscmp;
/* /*
* search choices for a value that matches the discriminator. * search choices for a value that matches the discriminator.
* if we find one, execute the xdr routine for that value. * if we find one, execute the xdr routine for that value.
*/ */
for (; choices->proc != NULL_xdrproc_t; choices++) { for (; choices->proc != NULL_xdrproc_t; choices++) {
if (choices->value == dscm) if (choices->value == dscm)
return ((*(choices->proc)) (xdrs, unp, LASTUNSIGNED)); return ((*(choices->proc)) (xdrs, unp, LASTUNSIGNED));
} }
/* /*
* no match - execute the default xdr routine if there is one * no match - execute the default xdr routine if there is one
*/ */
return ((dfault == NULL_xdrproc_t) ? FALSE : return ((dfault == NULL_xdrproc_t) ? FALSE :
(*dfault) (xdrs, unp, LASTUNSIGNED)); (*dfault) (xdrs, unp, LASTUNSIGNED));
} }
@ -533,70 +533,70 @@ bool_t xdr_union(XDR* xdrs, enum_t* dscmp, char* unp, const struct xdr_discrim*
*/ */
bool_t xdr_string(XDR *xdrs, char **cpp, unsigned int maxsize) bool_t xdr_string(XDR *xdrs, char **cpp, unsigned int maxsize)
{ {
register char *sp = *cpp; /* sp is the actual string pointer */ register char *sp = *cpp; /* sp is the actual string pointer */
unsigned int size; unsigned int size;
unsigned int nodesize; unsigned int nodesize;
/* /*
* first deal with the length since xdr strings are counted-strings * first deal with the length since xdr strings are counted-strings
*/ */
switch (xdrs->x_op) { switch (xdrs->x_op) {
case XDR_FREE: case XDR_FREE:
if (sp == NULL) { if (sp == NULL) {
return (TRUE); /* already free */ return (TRUE); /* already free */
} }
/* fall through... */ /* fall through... */
case XDR_ENCODE: case XDR_ENCODE:
size = strlen(sp); size = strlen(sp);
break; break;
} }
if (!xdr_u_int(xdrs, &size)) { if (!xdr_u_int(xdrs, &size)) {
return (FALSE); return (FALSE);
} }
if (size > maxsize) { if (size > maxsize) {
return (FALSE); return (FALSE);
} }
nodesize = size + 1; nodesize = size + 1;
/* /*
* now deal with the actual bytes * now deal with the actual bytes
*/ */
switch (xdrs->x_op) { switch (xdrs->x_op) {
case XDR_DECODE: case XDR_DECODE:
if (nodesize == 0) { if (nodesize == 0) {
return (TRUE); return (TRUE);
} }
if (sp == NULL) if (sp == NULL)
*cpp = sp = (char *) rt_malloc(nodesize); *cpp = sp = (char *) rt_malloc(nodesize);
if (sp == NULL) { if (sp == NULL) {
rt_kprintf("xdr_string: out of memory\n"); rt_kprintf("xdr_string: out of memory\n");
return (FALSE); return (FALSE);
} }
sp[size] = 0; sp[size] = 0;
/* fall into ... */ /* fall into ... */
case XDR_ENCODE: case XDR_ENCODE:
return (xdr_opaque(xdrs, sp, size)); return (xdr_opaque(xdrs, sp, size));
case XDR_FREE: case XDR_FREE:
rt_free(sp); rt_free(sp);
*cpp = NULL; *cpp = NULL;
return (TRUE); return (TRUE);
} }
return (FALSE); return (FALSE);
} }
/* /*
* Wrapper for xdr_string that can be called directly from * Wrapper for xdr_string that can be called directly from
* routines like clnt_call * routines like clnt_call
*/ */
bool_t xdr_wrapstring(XDR *xdrs, char **cpp) bool_t xdr_wrapstring(XDR *xdrs, char **cpp)
{ {
if (xdr_string(xdrs, cpp, LASTUNSIGNED)) { if (xdr_string(xdrs, cpp, LASTUNSIGNED)) {
return (TRUE); return (TRUE);
} }
return (FALSE); return (FALSE);
} }
/* /*
@ -608,69 +608,69 @@ bool_t xdr_wrapstring(XDR *xdrs, char **cpp)
*/ */
bool_t xdr_array(XDR *xdrs, char **addrp, unsigned int *sizep, unsigned int maxsize, unsigned int elsize, xdrproc_t elproc) bool_t xdr_array(XDR *xdrs, char **addrp, unsigned int *sizep, unsigned int maxsize, unsigned int elsize, xdrproc_t elproc)
{ {
register unsigned int i; register unsigned int i;
register char* target = *addrp; register char* target = *addrp;
register unsigned int c; /* the actual element count */ register unsigned int c; /* the actual element count */
register bool_t stat = TRUE; register bool_t stat = TRUE;
register unsigned int nodesize; register unsigned int nodesize;
/* like strings, arrays are really counted arrays */ /* like strings, arrays are really counted arrays */
if (!xdr_u_int(xdrs, sizep)) { if (!xdr_u_int(xdrs, sizep)) {
return (FALSE); return (FALSE);
} }
c = *sizep; c = *sizep;
if ((c > maxsize) && (xdrs->x_op != XDR_FREE)) { if ((c > maxsize) && (xdrs->x_op != XDR_FREE)) {
return (FALSE); return (FALSE);
} }
/* duh, look for integer overflow (fefe) */ /* duh, look for integer overflow (fefe) */
{ {
unsigned int i; unsigned int i;
nodesize = 0; nodesize = 0;
for (i=c; i; --i) { for (i=c; i; --i) {
unsigned int tmp=nodesize+elsize; unsigned int tmp=nodesize+elsize;
if (tmp<nodesize) /* overflow */ if (tmp<nodesize) /* overflow */
return FALSE; return FALSE;
nodesize=tmp; nodesize=tmp;
} }
} }
/* /*
* if we are deserializing, we may need to allocate an array. * if we are deserializing, we may need to allocate an array.
* We also save time by checking for a null array if we are freeing. * We also save time by checking for a null array if we are freeing.
*/ */
if (target == NULL) if (target == NULL)
switch (xdrs->x_op) { switch (xdrs->x_op) {
case XDR_DECODE: case XDR_DECODE:
if (c == 0) if (c == 0)
return (TRUE); return (TRUE);
*addrp = target = rt_malloc(nodesize); *addrp = target = rt_malloc(nodesize);
if (target == NULL) { if (target == NULL) {
rt_kprintf("xdr_array: out of memory\n"); rt_kprintf("xdr_array: out of memory\n");
return (FALSE); return (FALSE);
} }
memset(target, 0, nodesize); memset(target, 0, nodesize);
break; break;
case XDR_FREE: case XDR_FREE:
return (TRUE); return (TRUE);
} }
/* /*
* now we xdr each element of array * now we xdr each element of array
*/ */
for (i = 0; (i < c) && stat; i++) { for (i = 0; (i < c) && stat; i++) {
stat = (*elproc) (xdrs, target, LASTUNSIGNED); stat = (*elproc) (xdrs, target, LASTUNSIGNED);
target += elsize; target += elsize;
} }
/* /*
* the array may need freeing * the array may need freeing
*/ */
if (xdrs->x_op == XDR_FREE) { if (xdrs->x_op == XDR_FREE) {
rt_free(*addrp); rt_free(*addrp);
*addrp = NULL; *addrp = NULL;
} }
return (stat); return (stat);
} }
/* /*
@ -685,17 +685,17 @@ bool_t xdr_array(XDR *xdrs, char **addrp, unsigned int *sizep, unsigned int maxs
*/ */
bool_t xdr_vector(XDR *xdrs, char *basep, unsigned int nelem, unsigned int elemsize, xdrproc_t xdr_elem) bool_t xdr_vector(XDR *xdrs, char *basep, unsigned int nelem, unsigned int elemsize, xdrproc_t xdr_elem)
{ {
register unsigned int i; register unsigned int i;
register char *elptr; register char *elptr;
elptr = basep; elptr = basep;
for (i = 0; i < nelem; i++) { for (i = 0; i < nelem; i++) {
if (!(*xdr_elem) (xdrs, elptr, LASTUNSIGNED)) { if (!(*xdr_elem) (xdrs, elptr, LASTUNSIGNED)) {
return (FALSE); return (FALSE);
} }
elptr += elemsize; elptr += elemsize;
} }
return (TRUE); return (TRUE);
} }
@ -710,31 +710,31 @@ bool_t xdr_vector(XDR *xdrs, char *basep, unsigned int nelem, unsigned int elems
*/ */
bool_t xdr_reference(XDR *xdrs, char **pp, unsigned int size, xdrproc_t proc) bool_t xdr_reference(XDR *xdrs, char **pp, unsigned int size, xdrproc_t proc)
{ {
register char* loc = *pp; register char* loc = *pp;
register bool_t stat; register bool_t stat;
if (loc == NULL) if (loc == NULL)
switch (xdrs->x_op) { switch (xdrs->x_op) {
case XDR_FREE: case XDR_FREE:
return (TRUE); return (TRUE);
case XDR_DECODE: case XDR_DECODE:
*pp = loc = (char*) rt_malloc(size); *pp = loc = (char*) rt_malloc(size);
if (loc == NULL) { if (loc == NULL) {
rt_kprintf("xdr_reference: out of memory\n"); rt_kprintf("xdr_reference: out of memory\n");
return (FALSE); return (FALSE);
} }
memset(loc, 0, (int) size); memset(loc, 0, (int) size);
break; break;
} }
stat = (*proc) (xdrs, loc, LASTUNSIGNED); stat = (*proc) (xdrs, loc, LASTUNSIGNED);
if (xdrs->x_op == XDR_FREE) { if (xdrs->x_op == XDR_FREE) {
rt_free(loc); rt_free(loc);
*pp = NULL; *pp = NULL;
} }
return (stat); return (stat);
} }
@ -760,15 +760,15 @@ bool_t xdr_reference(XDR *xdrs, char **pp, unsigned int size, xdrproc_t proc)
bool_t xdr_pointer(XDR *xdrs, char **objpp, unsigned int obj_size, xdrproc_t xdr_obj) bool_t xdr_pointer(XDR *xdrs, char **objpp, unsigned int obj_size, xdrproc_t xdr_obj)
{ {
bool_t more_data; bool_t more_data;
more_data = (*objpp != NULL); more_data = (*objpp != NULL);
if (!xdr_bool(xdrs, &more_data)) { if (!xdr_bool(xdrs, &more_data)) {
return (FALSE); return (FALSE);
} }
if (!more_data) { if (!more_data) {
*objpp = NULL; *objpp = NULL;
return (TRUE); return (TRUE);
} }
return (xdr_reference(xdrs, objpp, obj_size, xdr_obj)); return (xdr_reference(xdrs, objpp, obj_size, xdr_obj));
} }

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2006-2018, RT-Thread Development Team * Copyright (c) 2006-2021, RT-Thread Development Team
* *
* SPDX-License-Identifier: Apache-2.0 * SPDX-License-Identifier: Apache-2.0
* *
@ -93,7 +93,7 @@ enum xdr_op {
/* /*
* This is the number of bytes per unit of external data. * This is the number of bytes per unit of external data.
*/ */
#define BYTES_PER_XDR_UNIT (4) #define BYTES_PER_XDR_UNIT (4)
/* /*
* This only works if the above is a power of 2. But it's defined to be * This only works if the above is a power of 2. But it's defined to be
* 4 by the appropriate RFCs. So it will work. And it's normally quicker * 4 by the appropriate RFCs. So it will work. And it's normally quicker
@ -110,35 +110,35 @@ enum xdr_op {
typedef struct XDR XDR; typedef struct XDR XDR;
struct XDR struct XDR
{ {
enum xdr_op x_op; /* operation; fast additional param */ enum xdr_op x_op; /* operation; fast additional param */
struct xdr_ops struct xdr_ops
{ {
bool_t (*x_getlong) (XDR *__xdrs, long *__lp); bool_t (*x_getlong) (XDR *__xdrs, long *__lp);
/* get a long from underlying stream */ /* get a long from underlying stream */
bool_t (*x_putlong) (XDR *__xdrs, const long *__lp); bool_t (*x_putlong) (XDR *__xdrs, const long *__lp);
/* put a long to " */ /* put a long to " */
bool_t (*x_getbytes) (XDR *__xdrs, char* __addr, unsigned int __len); bool_t (*x_getbytes) (XDR *__xdrs, char* __addr, unsigned int __len);
/* get some bytes from " */ /* get some bytes from " */
bool_t (*x_putbytes) (XDR *__xdrs, const char *__addr, unsigned int __len); bool_t (*x_putbytes) (XDR *__xdrs, const char *__addr, unsigned int __len);
/* put some bytes to " */ /* put some bytes to " */
unsigned int (*x_getpostn) (const XDR *__xdrs); unsigned int (*x_getpostn) (const XDR *__xdrs);
/* returns bytes off from beginning */ /* returns bytes off from beginning */
bool_t (*x_setpostn) (XDR *__xdrs, unsigned int __pos); bool_t (*x_setpostn) (XDR *__xdrs, unsigned int __pos);
/* lets you reposition the stream */ /* lets you reposition the stream */
int32_t *(*x_inline) (XDR *__xdrs, unsigned int __len); int32_t *(*x_inline) (XDR *__xdrs, unsigned int __len);
/* buf quick ptr to buffered data */ /* buf quick ptr to buffered data */
void (*x_destroy) (XDR *__xdrs); void (*x_destroy) (XDR *__xdrs);
/* free privates of this xdr_stream */ /* free privates of this xdr_stream */
bool_t (*x_getint32) (XDR *__xdrs, int32_t *__ip); bool_t (*x_getint32) (XDR *__xdrs, int32_t *__ip);
/* get a int from underlying stream */ /* get a int from underlying stream */
bool_t (*x_putint32) (XDR *__xdrs, const int32_t *__ip); bool_t (*x_putint32) (XDR *__xdrs, const int32_t *__ip);
/* put a int to " */ /* put a int to " */
} }
*x_ops; *x_ops;
char* x_public; /* users' data */ char* x_public; /* users' data */
char* x_private; /* pointer to private data */ char* x_private; /* pointer to private data */
char* x_base; /* private used for position info */ char* x_base; /* private used for position info */
unsigned int x_handy; /* extra private word */ unsigned int x_handy; /* extra private word */
}; };
/* /*
@ -173,51 +173,51 @@ typedef bool_t (*xdrproc_t) (XDR *, void *,...);
#define xdr_putint32(xdrs, int32p) \ #define xdr_putint32(xdrs, int32p) \
(*(xdrs)->x_ops->x_putint32)(xdrs, int32p) (*(xdrs)->x_ops->x_putint32)(xdrs, int32p)
#define XDR_GETLONG(xdrs, longp) \ #define XDR_GETLONG(xdrs, longp) \
(*(xdrs)->x_ops->x_getlong)(xdrs, longp) (*(xdrs)->x_ops->x_getlong)(xdrs, longp)
#define xdr_getlong(xdrs, longp) \ #define xdr_getlong(xdrs, longp) \
(*(xdrs)->x_ops->x_getlong)(xdrs, longp) (*(xdrs)->x_ops->x_getlong)(xdrs, longp)
#define XDR_PUTLONG(xdrs, longp) \ #define XDR_PUTLONG(xdrs, longp) \
(*(xdrs)->x_ops->x_putlong)(xdrs, longp) (*(xdrs)->x_ops->x_putlong)(xdrs, longp)
#define xdr_putlong(xdrs, longp) \ #define xdr_putlong(xdrs, longp) \
(*(xdrs)->x_ops->x_putlong)(xdrs, longp) (*(xdrs)->x_ops->x_putlong)(xdrs, longp)
#define XDR_GETBYTES(xdrs, addr, len) \ #define XDR_GETBYTES(xdrs, addr, len) \
(*(xdrs)->x_ops->x_getbytes)(xdrs, addr, len) (*(xdrs)->x_ops->x_getbytes)(xdrs, addr, len)
#define xdr_getbytes(xdrs, addr, len) \ #define xdr_getbytes(xdrs, addr, len) \
(*(xdrs)->x_ops->x_getbytes)(xdrs, addr, len) (*(xdrs)->x_ops->x_getbytes)(xdrs, addr, len)
#define XDR_PUTBYTES(xdrs, addr, len) \ #define XDR_PUTBYTES(xdrs, addr, len) \
(*(xdrs)->x_ops->x_putbytes)(xdrs, addr, len) (*(xdrs)->x_ops->x_putbytes)(xdrs, addr, len)
#define xdr_putbytes(xdrs, addr, len) \ #define xdr_putbytes(xdrs, addr, len) \
(*(xdrs)->x_ops->x_putbytes)(xdrs, addr, len) (*(xdrs)->x_ops->x_putbytes)(xdrs, addr, len)
#define XDR_GETPOS(xdrs) \ #define XDR_GETPOS(xdrs) \
(*(xdrs)->x_ops->x_getpostn)(xdrs) (*(xdrs)->x_ops->x_getpostn)(xdrs)
#define xdr_getpos(xdrs) \ #define xdr_getpos(xdrs) \
(*(xdrs)->x_ops->x_getpostn)(xdrs) (*(xdrs)->x_ops->x_getpostn)(xdrs)
#define XDR_SETPOS(xdrs, pos) \ #define XDR_SETPOS(xdrs, pos) \
(*(xdrs)->x_ops->x_setpostn)(xdrs, pos) (*(xdrs)->x_ops->x_setpostn)(xdrs, pos)
#define xdr_setpos(xdrs, pos) \ #define xdr_setpos(xdrs, pos) \
(*(xdrs)->x_ops->x_setpostn)(xdrs, pos) (*(xdrs)->x_ops->x_setpostn)(xdrs, pos)
#define XDR_INLINE(xdrs, len) \ #define XDR_INLINE(xdrs, len) \
(*(xdrs)->x_ops->x_inline)(xdrs, len) (*(xdrs)->x_ops->x_inline)(xdrs, len)
#define xdr_inline(xdrs, len) \ #define xdr_inline(xdrs, len) \
(*(xdrs)->x_ops->x_inline)(xdrs, len) (*(xdrs)->x_ops->x_inline)(xdrs, len)
#define XDR_DESTROY(xdrs) \ #define XDR_DESTROY(xdrs) \
do { \ do { \
if ((xdrs)->x_ops->x_destroy) \ if ((xdrs)->x_ops->x_destroy) \
(*(xdrs)->x_ops->x_destroy)(xdrs); \ (*(xdrs)->x_ops->x_destroy)(xdrs); \
} while (0) } while (0)
#define xdr_destroy(xdrs) \ #define xdr_destroy(xdrs) \
do { \ do { \
if ((xdrs)->x_ops->x_destroy) \ if ((xdrs)->x_ops->x_destroy) \
(*(xdrs)->x_ops->x_destroy)(xdrs); \ (*(xdrs)->x_ops->x_destroy)(xdrs); \
} while (0) } while (0)
/* /*
* Support struct for discriminated unions. * Support struct for discriminated unions.
@ -261,10 +261,10 @@ struct xdr_discrim
* and shouldn't be used any longer. Code which use this defines or longs * and shouldn't be used any longer. Code which use this defines or longs
* in the RPC code will not work on 64bit Solaris platforms ! * in the RPC code will not work on 64bit Solaris platforms !
*/ */
#define IXDR_GET_LONG(buf) ((long)IXDR_GET_U_INT32(buf)) #define IXDR_GET_LONG(buf) ((long)IXDR_GET_U_INT32(buf))
#define IXDR_PUT_LONG(buf, v) ((long)IXDR_PUT_INT32(buf, (long)(v))) #define IXDR_PUT_LONG(buf, v) ((long)IXDR_PUT_INT32(buf, (long)(v)))
#define IXDR_GET_U_LONG(buf) ((unsigned long)IXDR_GET_LONG(buf)) #define IXDR_GET_U_LONG(buf) ((unsigned long)IXDR_GET_LONG(buf))
#define IXDR_PUT_U_LONG(buf, v) IXDR_PUT_LONG(buf, (long)(v)) #define IXDR_PUT_U_LONG(buf, v) IXDR_PUT_LONG(buf, (long)(v))
#define IXDR_GET_BOOL(buf) ((bool_t)IXDR_GET_LONG(buf)) #define IXDR_GET_BOOL(buf) ((bool_t)IXDR_GET_LONG(buf))
@ -305,24 +305,24 @@ extern bool_t xdr_uint64_t (XDR *__xdrs, uint64_t *__up);
extern bool_t xdr_bool (XDR *__xdrs, bool_t *__bp); extern bool_t xdr_bool (XDR *__xdrs, bool_t *__bp);
extern bool_t xdr_enum (XDR *__xdrs, enum_t *__ep); extern bool_t xdr_enum (XDR *__xdrs, enum_t *__ep);
extern bool_t xdr_array (XDR * _xdrs, char* *__addrp, unsigned int *__sizep, extern bool_t xdr_array (XDR * _xdrs, char* *__addrp, unsigned int *__sizep,
unsigned int __maxsize, unsigned int __elsize, xdrproc_t __elproc); unsigned int __maxsize, unsigned int __elsize, xdrproc_t __elproc);
extern bool_t xdr_bytes (XDR *xdrs, char **cpp, unsigned int *sizep, extern bool_t xdr_bytes (XDR *xdrs, char **cpp, unsigned int *sizep,
unsigned int maxsize); unsigned int maxsize);
extern bool_t xdr_opaque (XDR *__xdrs, char* __cp, unsigned int __cnt); extern bool_t xdr_opaque (XDR *__xdrs, char* __cp, unsigned int __cnt);
extern bool_t xdr_string (XDR *xdrs, char **cpp, unsigned int maxsize); extern bool_t xdr_string (XDR *xdrs, char **cpp, unsigned int maxsize);
extern bool_t xdr_union (XDR *__xdrs, enum_t *__dscmp, char *__unp, extern bool_t xdr_union (XDR *__xdrs, enum_t *__dscmp, char *__unp,
const struct xdr_discrim *__choices, const struct xdr_discrim *__choices,
xdrproc_t dfault); xdrproc_t dfault);
extern bool_t xdr_char (XDR *__xdrs, char *__cp); extern bool_t xdr_char (XDR *__xdrs, char *__cp);
extern bool_t xdr_u_char (XDR *__xdrs, unsigned char *__cp); extern bool_t xdr_u_char (XDR *__xdrs, unsigned char *__cp);
extern bool_t xdr_vector (XDR *__xdrs, char *__basep, unsigned int __nelem, extern bool_t xdr_vector (XDR *__xdrs, char *__basep, unsigned int __nelem,
unsigned int __elemsize, xdrproc_t __xdr_elem); unsigned int __elemsize, xdrproc_t __xdr_elem);
extern bool_t xdr_float (XDR *__xdrs, float *__fp); extern bool_t xdr_float (XDR *__xdrs, float *__fp);
extern bool_t xdr_double (XDR *__xdrs, double *__dp); extern bool_t xdr_double (XDR *__xdrs, double *__dp);
extern bool_t xdr_reference (XDR *__xdrs, char* *__xpp, unsigned int __size, extern bool_t xdr_reference (XDR *__xdrs, char* *__xpp, unsigned int __size,
xdrproc_t __proc); xdrproc_t __proc);
extern bool_t xdr_pointer (XDR *__xdrs, char **__objpp, extern bool_t xdr_pointer (XDR *__xdrs, char **__objpp,
unsigned int __obj_size, xdrproc_t __xdr_obj); unsigned int __obj_size, xdrproc_t __xdr_obj);
extern bool_t xdr_wrapstring (XDR *__xdrs, char **cpp); extern bool_t xdr_wrapstring (XDR *__xdrs, char **cpp);
extern unsigned long xdr_sizeof (xdrproc_t, void *); extern unsigned long xdr_sizeof (xdrproc_t, void *);
@ -346,13 +346,13 @@ extern bool_t xdr_netobj (XDR *__xdrs, struct netobj *__np);
/* XDR using memory buffers */ /* XDR using memory buffers */
extern void xdrmem_create (XDR *__xdrs, const char* __addr, extern void xdrmem_create (XDR *__xdrs, const char* __addr,
unsigned int __size, enum xdr_op __xop); unsigned int __size, enum xdr_op __xop);
/* XDR pseudo records for tcp */ /* XDR pseudo records for tcp */
extern void xdrrec_create (XDR *__xdrs, unsigned int __sendsize, extern void xdrrec_create (XDR *__xdrs, unsigned int __sendsize,
unsigned int __recvsize, char* __tcp_handle, unsigned int __recvsize, char* __tcp_handle,
int (*__readit) (char *, char *, int), int (*__readit) (char *, char *, int),
int (*__writeit) (char *, char *, int)); int (*__writeit) (char *, char *, int));
/* make end of xdr record */ /* make end of xdr record */
extern bool_t xdrrec_endofrecord (XDR *__xdrs, bool_t __sendnow); extern bool_t xdrrec_endofrecord (XDR *__xdrs, bool_t __sendnow);

View File

@ -1,12 +1,12 @@
/* /*
* Copyright (c) 2006-2018, RT-Thread Development Team * Copyright (c) 2006-2021, RT-Thread Development Team
* *
* SPDX-License-Identifier: Apache-2.0 * SPDX-License-Identifier: Apache-2.0
* *
* Change Logs: * Change Logs:
* Date Author Notes * Date Author Notes
*/ */
/* @(#)xdr_mem.c 2.1 88/07/29 4.0 RPCSRC */ /* @(#)xdr_mem.c 2.1 88/07/29 4.0 RPCSRC */
/* /*
* Sun RPC is a product of Sun Microsystems, Inc. and is provided for * Sun RPC is a product of Sun Microsystems, Inc. and is provided for
* unrestricted use provided that this legend is included on all tape * unrestricted use provided that this legend is included on all tape
@ -14,23 +14,23 @@
* may copy or modify Sun RPC without charge, but are not authorized * may copy or modify Sun RPC without charge, but are not authorized
* to license or distribute it to anyone else except as part of a product or * to license or distribute it to anyone else except as part of a product or
* program developed by the user. * program developed by the user.
* *
* SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE
* WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR * WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR
* PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE. * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE.
* *
* Sun RPC is provided with no support and without any obligation on the * Sun RPC is provided with no support and without any obligation on the
* part of Sun Microsystems, Inc. to assist in its use, correction, * part of Sun Microsystems, Inc. to assist in its use, correction,
* modification or enhancement. * modification or enhancement.
* *
* SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE
* INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC
* OR ANY PART THEREOF. * OR ANY PART THEREOF.
* *
* In no event will Sun Microsystems, Inc. be liable for any lost revenue * In no event will Sun Microsystems, Inc. be liable for any lost revenue
* or profits or other special, indirect and consequential damages, even if * or profits or other special, indirect and consequential damages, even if
* Sun has been advised of the possibility of such damages. * Sun has been advised of the possibility of such damages.
* *
* Sun Microsystems, Inc. * Sun Microsystems, Inc.
* 2550 Garcia Avenue * 2550 Garcia Avenue
* Mountain View, California 94043 * Mountain View, California 94043
@ -65,30 +65,30 @@ static int32_t *xdrmem_inline (XDR *, unsigned int);
static void xdrmem_destroy (XDR *); static void xdrmem_destroy (XDR *);
static struct xdr_ops xdrmem_ops = { static struct xdr_ops xdrmem_ops = {
xdrmem_getlong, xdrmem_getlong,
xdrmem_putlong, xdrmem_putlong,
xdrmem_getbytes, xdrmem_getbytes,
xdrmem_putbytes, xdrmem_putbytes,
xdrmem_getpos, xdrmem_getpos,
xdrmem_setpos, xdrmem_setpos,
xdrmem_inline, xdrmem_inline,
xdrmem_destroy, xdrmem_destroy,
NULL, NULL,
NULL NULL
}; };
/* /*
* The procedure xdrmem_create initializes a stream descriptor for a * The procedure xdrmem_create initializes a stream descriptor for a
* memory buffer. * memory buffer.
*/ */
void void
xdrmem_create (XDR *xdrs, const char* addr, unsigned int size, enum xdr_op op) xdrmem_create (XDR *xdrs, const char* addr, unsigned int size, enum xdr_op op)
{ {
xdrs->x_op = op; xdrs->x_op = op;
xdrs->x_ops = &xdrmem_ops; xdrs->x_ops = &xdrmem_ops;
xdrs->x_private = xdrs->x_base = (char*)addr; xdrs->x_private = xdrs->x_base = (char*)addr;
xdrs->x_handy = size; xdrs->x_handy = size;
} }
static void static void
@ -140,7 +140,7 @@ xdrmem_putbytes (XDR *xdrs, const char *addr, unsigned int len)
static unsigned int xdrmem_getpos (const XDR *xdrs) static unsigned int xdrmem_getpos (const XDR *xdrs)
{ {
return ((unsigned long) xdrs->x_private - (unsigned long) xdrs->x_base); return ((unsigned long) xdrs->x_private - (unsigned long) xdrs->x_base);
} }
static bool_t xdrmem_setpos(XDR *xdrs, unsigned int pos) static bool_t xdrmem_setpos(XDR *xdrs, unsigned int pos)
@ -149,9 +149,9 @@ static bool_t xdrmem_setpos(XDR *xdrs, unsigned int pos)
register char* lastaddr = xdrs->x_private + xdrs->x_handy; register char* lastaddr = xdrs->x_private + xdrs->x_handy;
if ((long) newaddr > (long) lastaddr if ((long) newaddr > (long) lastaddr
|| (UINT_MAX < LONG_MAX || (UINT_MAX < LONG_MAX
&& (long) UINT_MAX < (long) lastaddr - (long) newaddr)) && (long) UINT_MAX < (long) lastaddr - (long) newaddr))
return (FALSE); return (FALSE);
xdrs->x_private = newaddr; xdrs->x_private = newaddr;
xdrs->x_handy = (long) lastaddr - (long) newaddr; xdrs->x_handy = (long) lastaddr - (long) newaddr;
return (TRUE); return (TRUE);
@ -160,13 +160,13 @@ static bool_t xdrmem_setpos(XDR *xdrs, unsigned int pos)
static int32_t * static int32_t *
xdrmem_inline (XDR *xdrs, unsigned int len) xdrmem_inline (XDR *xdrs, unsigned int len)
{ {
int32_t *buf = 0; int32_t *buf = 0;
if (xdrs->x_handy >= len) { if (xdrs->x_handy >= len) {
xdrs->x_handy -= len; xdrs->x_handy -= len;
buf = (int32_t *) xdrs->x_private; buf = (int32_t *) xdrs->x_private;
xdrs->x_private += len; xdrs->x_private += len;
} }
return (buf); return (buf);
} }

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2006-2018, RT-Thread Development Team * Copyright (c) 2006-2021, RT-Thread Development Team
* *
* SPDX-License-Identifier: Apache-2.0 * SPDX-License-Identifier: Apache-2.0
* *

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2006-2018, RT-Thread Development Team * Copyright (c) 2006-2021, RT-Thread Development Team
* *
* SPDX-License-Identifier: Apache-2.0 * SPDX-License-Identifier: Apache-2.0
* *

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2006-2018, RT-Thread Development Team * Copyright (c) 2006-2021, RT-Thread Development Team
* *
* SPDX-License-Identifier: Apache-2.0 * SPDX-License-Identifier: Apache-2.0
* *

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2006-2019, RT-Thread Development Team * Copyright (c) 2006-2021, RT-Thread Development Team
* *
* SPDX-License-Identifier: Apache-2.0 * SPDX-License-Identifier: Apache-2.0
* *

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2006-2018, RT-Thread Development Team * Copyright (c) 2006-2021, RT-Thread Development Team
* *
* SPDX-License-Identifier: Apache-2.0 * SPDX-License-Identifier: Apache-2.0
* *

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2006-2018, RT-Thread Development Team * Copyright (c) 2006-2021, RT-Thread Development Team
* *
* SPDX-License-Identifier: Apache-2.0 * SPDX-License-Identifier: Apache-2.0
* *

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2006-2018, RT-Thread Development Team * Copyright (c) 2006-2021, RT-Thread Development Team
* *
* SPDX-License-Identifier: Apache-2.0 * SPDX-License-Identifier: Apache-2.0
* *

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2006-2018, RT-Thread Development Team * Copyright (c) 2006-2021, RT-Thread Development Team
* *
* SPDX-License-Identifier: Apache-2.0 * SPDX-License-Identifier: Apache-2.0
* *

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2006-2018, RT-Thread Development Team * Copyright (c) 2006-2021, RT-Thread Development Team
* *
* SPDX-License-Identifier: Apache-2.0 * SPDX-License-Identifier: Apache-2.0
* *

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2006-2018, RT-Thread Development Team * Copyright (c) 2006-2021, RT-Thread Development Team
* *
* SPDX-License-Identifier: Apache-2.0 * SPDX-License-Identifier: Apache-2.0
* *

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2006-2018, RT-Thread Development Team * Copyright (c) 2006-2021, RT-Thread Development Team
* *
* SPDX-License-Identifier: Apache-2.0 * SPDX-License-Identifier: Apache-2.0
* *

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2006-2018, RT-Thread Development Team * Copyright (c) 2006-2021, RT-Thread Development Team
* *
* SPDX-License-Identifier: Apache-2.0 * SPDX-License-Identifier: Apache-2.0
* *

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2006-2018, RT-Thread Development Team * Copyright (c) 2006-2021, RT-Thread Development Team
* *
* SPDX-License-Identifier: Apache-2.0 * SPDX-License-Identifier: Apache-2.0
* *

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2006-2018, RT-Thread Development Team * Copyright (c) 2006-2021, RT-Thread Development Team
* *
* SPDX-License-Identifier: Apache-2.0 * SPDX-License-Identifier: Apache-2.0
* *

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2006-2018, RT-Thread Development Team * Copyright (c) 2006-2021, RT-Thread Development Team
* *
* SPDX-License-Identifier: Apache-2.0 * SPDX-License-Identifier: Apache-2.0
* *

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2006-2018, RT-Thread Development Team * Copyright (c) 2006-2021, RT-Thread Development Team
* *
* SPDX-License-Identifier: Apache-2.0 * SPDX-License-Identifier: Apache-2.0
* *

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2006-2018, RT-Thread Development Team * Copyright (c) 2006-2021, RT-Thread Development Team
* *
* SPDX-License-Identifier: Apache-2.0 * SPDX-License-Identifier: Apache-2.0
* *
@ -522,16 +522,16 @@ INIT_ENV_EXPORT(dfs_mount_table);
int dfs_mount_device(rt_device_t dev) int dfs_mount_device(rt_device_t dev)
{ {
int index = 0; int index = 0;
if(dev == RT_NULL) { if(dev == RT_NULL) {
rt_kprintf("the device is NULL to be mounted.\n"); rt_kprintf("the device is NULL to be mounted.\n");
return -RT_ERROR; return -RT_ERROR;
} }
while (1) while (1)
{ {
if (mount_table[index].path == NULL) break; if (mount_table[index].path == NULL) break;
if(strcmp(mount_table[index].device_name, dev->parent.name) == 0) { if(strcmp(mount_table[index].device_name, dev->parent.name) == 0) {
if (dfs_mount(mount_table[index].device_name, if (dfs_mount(mount_table[index].device_name,
mount_table[index].path, mount_table[index].path,
@ -548,10 +548,10 @@ int dfs_mount_device(rt_device_t dev)
return RT_EOK; return RT_EOK;
} }
} }
index ++; index ++;
} }
rt_kprintf("can't find device:%s to be mounted.\n", dev->parent.name); rt_kprintf("can't find device:%s to be mounted.\n", dev->parent.name);
return -RT_ERROR; return -RT_ERROR;
} }

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2006-2018, RT-Thread Development Team * Copyright (c) 2006-2021, RT-Thread Development Team
* *
* SPDX-License-Identifier: Apache-2.0 * SPDX-License-Identifier: Apache-2.0
* *

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2006-2018, RT-Thread Development Team * Copyright (c) 2006-2021, RT-Thread Development Team
* *
* SPDX-License-Identifier: Apache-2.0 * SPDX-License-Identifier: Apache-2.0
* *
@ -140,7 +140,7 @@ static int do_pollfd(struct pollfd *pollfd, rt_pollreq_t *req)
/* dealwith the device return error -1*/ /* dealwith the device return error -1*/
if (mask < 0) if (mask < 0)
{ {
fd_put(f); fd_put(f);
pollfd->revents = 0; pollfd->revents = 0;
return mask; return mask;
@ -232,4 +232,4 @@ int poll(struct pollfd *fds, nfds_t nfds, int timeout)
return num; return num;
} }
#endif #endif

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2006-2018, RT-Thread Development Team * Copyright (c) 2006-2021, RT-Thread Development Team
* *
* SPDX-License-Identifier: Apache-2.0 * SPDX-License-Identifier: Apache-2.0
* *
@ -180,4 +180,4 @@ int select(int nfds, fd_set *readfds, fd_set *writefds, fd_set *exceptfds, struc
return ret; return ret;
} }
#endif #endif

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2006-2018, RT-Thread Development Team * Copyright (c) 2006-2021, RT-Thread Development Team
* *
* SPDX-License-Identifier: Apache-2.0 * SPDX-License-Identifier: Apache-2.0
* *

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2006-2018, RT-Thread Development Team * Copyright (c) 2006-2021, RT-Thread Development Team
* *
* SPDX-License-Identifier: Apache-2.0 * SPDX-License-Identifier: Apache-2.0
* *

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2006-2018, RT-Thread Development Team * Copyright (c) 2006-2021, RT-Thread Development Team
* *
* SPDX-License-Identifier: Apache-2.0 * SPDX-License-Identifier: Apache-2.0
* *

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2006-2018, RT-Thread Development Team * Copyright (c) 2006-2021, RT-Thread Development Team
* *
* SPDX-License-Identifier: Apache-2.0 * SPDX-License-Identifier: Apache-2.0
* *

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2006-2018, RT-Thread Development Team * Copyright (c) 2006-2021, RT-Thread Development Team
* *
* SPDX-License-Identifier: Apache-2.0 * SPDX-License-Identifier: Apache-2.0
* *
@ -14,7 +14,7 @@
static const struct rt_clock_cputime_ops *_cputime_ops = RT_NULL; static const struct rt_clock_cputime_ops *_cputime_ops = RT_NULL;
/** /**
* The clock_cpu_getres() function shall return the resolution of CPU time, the * The clock_cpu_getres() function shall return the resolution of CPU time, the
* number of nanosecond per tick. * number of nanosecond per tick.
* *
* @return the number of nanosecond per tick * @return the number of nanosecond per tick
@ -43,7 +43,7 @@ uint32_t clock_cpu_gettime(void)
} }
/** /**
* The clock_cpu_microsecond() fucntion shall return the microsecond according to * The clock_cpu_microsecond() fucntion shall return the microsecond according to
* cpu_tick parameter. * cpu_tick parameter.
* *
* @param cpu_tick the cpu tick * @param cpu_tick the cpu tick
@ -58,7 +58,7 @@ uint32_t clock_cpu_microsecond(uint32_t cpu_tick)
} }
/** /**
* The clock_cpu_microsecond() fucntion shall return the millisecond according to * The clock_cpu_microsecond() fucntion shall return the millisecond according to
* cpu_tick parameter. * cpu_tick parameter.
* *
* @param cpu_tick the cpu tick * @param cpu_tick the cpu tick
@ -74,7 +74,7 @@ uint32_t clock_cpu_millisecond(uint32_t cpu_tick)
/** /**
* The clock_cpu_seops() function shall set the ops of cpu time. * The clock_cpu_seops() function shall set the ops of cpu time.
* *
* @return always return 0. * @return always return 0.
*/ */
int clock_cpu_setops(const struct rt_clock_cputime_ops *ops) int clock_cpu_setops(const struct rt_clock_cputime_ops *ops)

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2006-2018, RT-Thread Development Team * Copyright (c) 2006-2021, RT-Thread Development Team
* *
* SPDX-License-Identifier: Apache-2.0 * SPDX-License-Identifier: Apache-2.0
* *
@ -19,7 +19,7 @@
static float cortexm_cputime_getres(void) static float cortexm_cputime_getres(void)
{ {
float ret = 1000 * 1000 * 1000; float ret = 1000 * 1000 * 1000;
ret = ret / SystemCoreClock; ret = ret / SystemCoreClock;
return ret; return ret;
} }
@ -29,7 +29,7 @@ static uint32_t cortexm_cputime_gettime(void)
return DWT->CYCCNT; return DWT->CYCCNT;
} }
const static struct rt_clock_cputime_ops _cortexm_ops = const static struct rt_clock_cputime_ops _cortexm_ops =
{ {
cortexm_cputime_getres, cortexm_cputime_getres,
cortexm_cputime_gettime cortexm_cputime_gettime
@ -38,13 +38,13 @@ const static struct rt_clock_cputime_ops _cortexm_ops =
int cortexm_cputime_init(void) int cortexm_cputime_init(void)
{ {
/* check support bit */ /* check support bit */
if ((DWT->CTRL & (1UL << DWT_CTRL_NOCYCCNT_Pos)) == 0) if ((DWT->CTRL & (1UL << DWT_CTRL_NOCYCCNT_Pos)) == 0)
{ {
/* enable trace*/ /* enable trace*/
CoreDebug->DEMCR |= (1UL << CoreDebug_DEMCR_TRCENA_Pos); CoreDebug->DEMCR |= (1UL << CoreDebug_DEMCR_TRCENA_Pos);
/* whether cycle counter not enabled */ /* whether cycle counter not enabled */
if ((DWT->CTRL & (1UL << DWT_CTRL_CYCCNTENA_Pos)) == 0) if ((DWT->CTRL & (1UL << DWT_CTRL_CYCCNTENA_Pos)) == 0)
{ {
/* enable cycle counter */ /* enable cycle counter */
DWT->CTRL |= (1UL << DWT_CTRL_CYCCNTENA_Pos); DWT->CTRL |= (1UL << DWT_CTRL_CYCCNTENA_Pos);

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2006-2019, RT-Thread Development Team * Copyright (c) 2006-2021, RT-Thread Development Team
* *
* SPDX-License-Identifier: Apache-2.0 * SPDX-License-Identifier: Apache-2.0
* *
@ -56,7 +56,7 @@ rt_err_t rt_hwcrypto_bignum_default(struct rt_hwcrypto_device *device)
/** /**
* @brief Init bignum obj * @brief Init bignum obj
* *
* @param n bignum obj * @param n bignum obj
*/ */
void rt_hwcrypto_bignum_init(struct hw_bignum_mpi *n) void rt_hwcrypto_bignum_init(struct hw_bignum_mpi *n)
@ -87,9 +87,9 @@ void rt_hwcrypto_bignum_free(struct hw_bignum_mpi *n)
/** /**
* @brief Get length of bignum as an unsigned binary buffer * @brief Get length of bignum as an unsigned binary buffer
* *
* @param n bignum obj * @param n bignum obj
* *
* @return binary buffer length * @return binary buffer length
*/ */
int rt_hwcrypto_bignum_get_len(const struct hw_bignum_mpi *n) int rt_hwcrypto_bignum_get_len(const struct hw_bignum_mpi *n)
@ -112,11 +112,11 @@ int rt_hwcrypto_bignum_get_len(const struct hw_bignum_mpi *n)
/** /**
* @brief Export n into unsigned binary data, big endian * @brief Export n into unsigned binary data, big endian
* *
* @param n bignum obj * @param n bignum obj
* @param buf Buffer for the binary number * @param buf Buffer for the binary number
* @param len Length of the buffer * @param len Length of the buffer
* *
* @return export bin length * @return export bin length
*/ */
int rt_hwcrypto_bignum_export_bin(struct hw_bignum_mpi *n, rt_uint8_t *buf, int len) int rt_hwcrypto_bignum_export_bin(struct hw_bignum_mpi *n, rt_uint8_t *buf, int len)
@ -139,11 +139,11 @@ int rt_hwcrypto_bignum_export_bin(struct hw_bignum_mpi *n, rt_uint8_t *buf, int
/** /**
* @brief Import n from unsigned binary data, big endian * @brief Import n from unsigned binary data, big endian
* *
* @param n bignum obj * @param n bignum obj
* @param buf Buffer for the binary number * @param buf Buffer for the binary number
* @param len Length of the buffer * @param len Length of the buffer
* *
* @return RT_EOK on success. * @return RT_EOK on success.
*/ */
rt_err_t rt_hwcrypto_bignum_import_bin(struct hw_bignum_mpi *n, rt_uint8_t *buf, int len) rt_err_t rt_hwcrypto_bignum_import_bin(struct hw_bignum_mpi *n, rt_uint8_t *buf, int len)
@ -179,11 +179,11 @@ rt_err_t rt_hwcrypto_bignum_import_bin(struct hw_bignum_mpi *n, rt_uint8_t *buf,
/** /**
* @brief x = a + b * @brief x = a + b
* *
* @param a bignum obj * @param a bignum obj
* @param b bignum obj * @param b bignum obj
* @param c bignum obj * @param c bignum obj
* *
* @return RT_EOK on success. * @return RT_EOK on success.
*/ */
rt_err_t rt_hwcrypto_bignum_add(struct hw_bignum_mpi *x, rt_err_t rt_hwcrypto_bignum_add(struct hw_bignum_mpi *x,
@ -206,11 +206,11 @@ rt_err_t rt_hwcrypto_bignum_add(struct hw_bignum_mpi *x,
/** /**
* @brief x = a - b * @brief x = a - b
* *
* @param a bignum obj * @param a bignum obj
* @param b bignum obj * @param b bignum obj
* @param c bignum obj * @param c bignum obj
* *
* @return RT_EOK on success. * @return RT_EOK on success.
*/ */
rt_err_t rt_hwcrypto_bignum_sub(struct hw_bignum_mpi *x, rt_err_t rt_hwcrypto_bignum_sub(struct hw_bignum_mpi *x,
@ -233,11 +233,11 @@ rt_err_t rt_hwcrypto_bignum_sub(struct hw_bignum_mpi *x,
/** /**
* @brief x = a * b * @brief x = a * b
* *
* @param a bignum obj * @param a bignum obj
* @param b bignum obj * @param b bignum obj
* @param c bignum obj * @param c bignum obj
* *
* @return RT_EOK on success. * @return RT_EOK on success.
*/ */
rt_err_t rt_hwcrypto_bignum_mul(struct hw_bignum_mpi *x, rt_err_t rt_hwcrypto_bignum_mul(struct hw_bignum_mpi *x,
@ -260,11 +260,11 @@ rt_err_t rt_hwcrypto_bignum_mul(struct hw_bignum_mpi *x,
/** /**
* @brief x = a * b (mod c) * @brief x = a * b (mod c)
* *
* @param a bignum obj * @param a bignum obj
* @param b bignum obj * @param b bignum obj
* @param c bignum obj * @param c bignum obj
* *
* @return RT_EOK on success. * @return RT_EOK on success.
*/ */
rt_err_t rt_hwcrypto_bignum_mulmod(struct hw_bignum_mpi *x, rt_err_t rt_hwcrypto_bignum_mulmod(struct hw_bignum_mpi *x,
@ -288,11 +288,11 @@ rt_err_t rt_hwcrypto_bignum_mulmod(struct hw_bignum_mpi *x,
/** /**
* @brief x = a ^ b (mod c) * @brief x = a ^ b (mod c)
* *
* @param a bignum obj * @param a bignum obj
* @param b bignum obj * @param b bignum obj
* @param c bignum obj * @param c bignum obj
* *
* @return RT_EOK on success. * @return RT_EOK on success.
*/ */
rt_err_t rt_hwcrypto_bignum_exptmod(struct hw_bignum_mpi *x, rt_err_t rt_hwcrypto_bignum_exptmod(struct hw_bignum_mpi *x,

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2006-2019, RT-Thread Development Team * Copyright (c) 2006-2021, RT-Thread Development Team
* *
* SPDX-License-Identifier: Apache-2.0 * SPDX-License-Identifier: Apache-2.0
* *
@ -83,42 +83,42 @@ void rt_hwcrypto_bignum_free(struct hw_bignum_mpi *n);
/** /**
* @brief Get length of bignum as an unsigned binary buffer * @brief Get length of bignum as an unsigned binary buffer
* *
* @param n bignum obj * @param n bignum obj
* *
* @return binary buffer Length * @return binary buffer Length
*/ */
int rt_hwcrypto_bignum_get_len(const struct hw_bignum_mpi *n); int rt_hwcrypto_bignum_get_len(const struct hw_bignum_mpi *n);
/** /**
* @brief Export n into unsigned binary data, big endian * @brief Export n into unsigned binary data, big endian
* *
* @param n bignum obj * @param n bignum obj
* @param buf Buffer for the binary number * @param buf Buffer for the binary number
* @param len Length of the buffer * @param len Length of the buffer
* *
* @return export bin length * @return export bin length
*/ */
int rt_hwcrypto_bignum_export_bin(struct hw_bignum_mpi *n, rt_uint8_t *buf, int len); int rt_hwcrypto_bignum_export_bin(struct hw_bignum_mpi *n, rt_uint8_t *buf, int len);
/** /**
* @brief Import n from unsigned binary data, big endian * @brief Import n from unsigned binary data, big endian
* *
* @param n bignum obj * @param n bignum obj
* @param buf Buffer for the binary number * @param buf Buffer for the binary number
* @param len Length of the buffer * @param len Length of the buffer
* *
* @return RT_EOK on success. * @return RT_EOK on success.
*/ */
rt_err_t rt_hwcrypto_bignum_import_bin(struct hw_bignum_mpi *n, rt_uint8_t *buf, int len); rt_err_t rt_hwcrypto_bignum_import_bin(struct hw_bignum_mpi *n, rt_uint8_t *buf, int len);
/** /**
* @brief x = a + b * @brief x = a + b
* *
* @param a bignum obj * @param a bignum obj
* @param b bignum obj * @param b bignum obj
* @param c bignum obj * @param c bignum obj
* *
* @return RT_EOK on success. * @return RT_EOK on success.
*/ */
rt_err_t rt_hwcrypto_bignum_add(struct hw_bignum_mpi *x, rt_err_t rt_hwcrypto_bignum_add(struct hw_bignum_mpi *x,
@ -127,11 +127,11 @@ rt_err_t rt_hwcrypto_bignum_add(struct hw_bignum_mpi *x,
/** /**
* @brief x = a - b * @brief x = a - b
* *
* @param a bignum obj * @param a bignum obj
* @param b bignum obj * @param b bignum obj
* @param c bignum obj * @param c bignum obj
* *
* @return RT_EOK on success. * @return RT_EOK on success.
*/ */
rt_err_t rt_hwcrypto_bignum_sub(struct hw_bignum_mpi *x, rt_err_t rt_hwcrypto_bignum_sub(struct hw_bignum_mpi *x,
@ -140,11 +140,11 @@ rt_err_t rt_hwcrypto_bignum_sub(struct hw_bignum_mpi *x,
/** /**
* @brief x = a * b * @brief x = a * b
* *
* @param a bignum obj * @param a bignum obj
* @param b bignum obj * @param b bignum obj
* @param c bignum obj * @param c bignum obj
* *
* @return RT_EOK on success. * @return RT_EOK on success.
*/ */
rt_err_t rt_hwcrypto_bignum_mul(struct hw_bignum_mpi *x, rt_err_t rt_hwcrypto_bignum_mul(struct hw_bignum_mpi *x,
@ -153,11 +153,11 @@ rt_err_t rt_hwcrypto_bignum_mul(struct hw_bignum_mpi *x,
/** /**
* @brief x = a * b (mod c) * @brief x = a * b (mod c)
* *
* @param a bignum obj * @param a bignum obj
* @param b bignum obj * @param b bignum obj
* @param c bignum obj * @param c bignum obj
* *
* @return RT_EOK on success. * @return RT_EOK on success.
*/ */
rt_err_t rt_hwcrypto_bignum_mulmod(struct hw_bignum_mpi *x, rt_err_t rt_hwcrypto_bignum_mulmod(struct hw_bignum_mpi *x,
@ -167,11 +167,11 @@ rt_err_t rt_hwcrypto_bignum_mulmod(struct hw_bignum_mpi *x,
/** /**
* @brief x = a ^ b (mod c) * @brief x = a ^ b (mod c)
* *
* @param a bignum obj * @param a bignum obj
* @param b bignum obj * @param b bignum obj
* @param c bignum obj * @param c bignum obj
* *
* @return RT_EOK on success. * @return RT_EOK on success.
*/ */
rt_err_t rt_hwcrypto_bignum_exptmod(struct hw_bignum_mpi *x, rt_err_t rt_hwcrypto_bignum_exptmod(struct hw_bignum_mpi *x,

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2006-2019, RT-Thread Development Team * Copyright (c) 2006-2021, RT-Thread Development Team
* *
* SPDX-License-Identifier: Apache-2.0 * SPDX-License-Identifier: Apache-2.0
* *
@ -20,7 +20,7 @@
* *
* @return CRC context * @return CRC context
*/ */
struct rt_hwcrypto_ctx *rt_hwcrypto_crc_create(struct rt_hwcrypto_device *device, struct rt_hwcrypto_ctx *rt_hwcrypto_crc_create(struct rt_hwcrypto_device *device,
hwcrypto_crc_mode mode) hwcrypto_crc_mode mode)
{ {
struct hwcrypto_crc *crc_ctx; struct hwcrypto_crc *crc_ctx;
@ -89,8 +89,8 @@ void rt_hwcrypto_crc_destroy(struct rt_hwcrypto_ctx *ctx)
* *
* @return RT_EOK on success. * @return RT_EOK on success.
*/ */
rt_uint32_t rt_hwcrypto_crc_update(struct rt_hwcrypto_ctx *ctx, rt_uint32_t rt_hwcrypto_crc_update(struct rt_hwcrypto_ctx *ctx,
const rt_uint8_t *input, const rt_uint8_t *input,
rt_size_t length) rt_size_t length)
{ {
struct hwcrypto_crc *crc_ctx = (struct hwcrypto_crc *)ctx; struct hwcrypto_crc *crc_ctx = (struct hwcrypto_crc *)ctx;
@ -107,7 +107,7 @@ rt_uint32_t rt_hwcrypto_crc_update(struct rt_hwcrypto_ctx *ctx,
* @param ctx CRC context * @param ctx CRC context
* @param cfg CRC config * @param cfg CRC config
*/ */
void rt_hwcrypto_crc_cfg(struct rt_hwcrypto_ctx *ctx, void rt_hwcrypto_crc_cfg(struct rt_hwcrypto_ctx *ctx,
struct hwcrypto_crc_cfg *cfg) struct hwcrypto_crc_cfg *cfg)
{ {
if (cfg) if (cfg)

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2006-2019, RT-Thread Development Team * Copyright (c) 2006-2021, RT-Thread Development Team
* *
* SPDX-License-Identifier: Apache-2.0 * SPDX-License-Identifier: Apache-2.0
* *
@ -129,7 +129,7 @@ void rt_hwcrypto_crc_destroy(struct rt_hwcrypto_ctx *ctx);
* *
* @return CRC value * @return CRC value
*/ */
rt_uint32_t rt_hwcrypto_crc_update(struct rt_hwcrypto_ctx *ctx, rt_uint32_t rt_hwcrypto_crc_update(struct rt_hwcrypto_ctx *ctx,
const rt_uint8_t *input, rt_size_t length); const rt_uint8_t *input, rt_size_t length);
/** /**
@ -138,7 +138,7 @@ rt_uint32_t rt_hwcrypto_crc_update(struct rt_hwcrypto_ctx *ctx,
* @param ctx CRC context * @param ctx CRC context
* @param cfg CRC config * @param cfg CRC config
*/ */
void rt_hwcrypto_crc_cfg(struct rt_hwcrypto_ctx *ctx, void rt_hwcrypto_crc_cfg(struct rt_hwcrypto_ctx *ctx,
struct hwcrypto_crc_cfg *cfg); struct hwcrypto_crc_cfg *cfg);
#ifdef __cplusplus #ifdef __cplusplus

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2006-2019, RT-Thread Development Team * Copyright (c) 2006-2021, RT-Thread Development Team
* *
* SPDX-License-Identifier: Apache-2.0 * SPDX-License-Identifier: Apache-2.0
* *

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2006-2019, RT-Thread Development Team * Copyright (c) 2006-2021, RT-Thread Development Team
* *
* SPDX-License-Identifier: Apache-2.0 * SPDX-License-Identifier: Apache-2.0
* *

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2006-2019, RT-Thread Development Team * Copyright (c) 2006-2021, RT-Thread Development Team
* *
* SPDX-License-Identifier: Apache-2.0 * SPDX-License-Identifier: Apache-2.0
* *

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2006-2019, RT-Thread Development Team * Copyright (c) 2006-2021, RT-Thread Development Team
* *
* SPDX-License-Identifier: Apache-2.0 * SPDX-License-Identifier: Apache-2.0
* *

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2006-2019, RT-Thread Development Team * Copyright (c) 2006-2021, RT-Thread Development Team
* *
* SPDX-License-Identifier: Apache-2.0 * SPDX-License-Identifier: Apache-2.0
* *
@ -81,7 +81,7 @@ rt_err_t rt_hwcrypto_rng_default(struct rt_hwcrypto_device *device)
* @brief Getting Random Numbers from RNG Context * @brief Getting Random Numbers from RNG Context
* *
* @param ctx RNG context * @param ctx RNG context
* *
* @return Random number * @return Random number
*/ */
rt_uint32_t rt_hwcrypto_rng_update_ctx(struct rt_hwcrypto_ctx *ctx) rt_uint32_t rt_hwcrypto_rng_update_ctx(struct rt_hwcrypto_ctx *ctx)

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2006-2019, RT-Thread Development Team * Copyright (c) 2006-2021, RT-Thread Development Team
* *
* SPDX-License-Identifier: Apache-2.0 * SPDX-License-Identifier: Apache-2.0
* *
@ -60,7 +60,7 @@ rt_err_t rt_hwcrypto_rng_default(struct rt_hwcrypto_device *device);
* @brief Getting Random Numbers from RNG Context * @brief Getting Random Numbers from RNG Context
* *
* @param ctx RNG context * @param ctx RNG context
* *
* @return Random number * @return Random number
*/ */
rt_uint32_t rt_hwcrypto_rng_update_ctx(struct rt_hwcrypto_ctx *ctx); rt_uint32_t rt_hwcrypto_rng_update_ctx(struct rt_hwcrypto_ctx *ctx);

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2006-2019, RT-Thread Development Team * Copyright (c) 2006-2021, RT-Thread Development Team
* *
* SPDX-License-Identifier: Apache-2.0 * SPDX-License-Identifier: Apache-2.0
* *
@ -215,7 +215,7 @@ void rt_hwcrypto_symmetric_get_ivoff(struct rt_hwcrypto_ctx *ctx, rt_int32_t *iv
* *
* @param des The destination symmetric crypto context * @param des The destination symmetric crypto context
* @param src The symmetric crypto context to be copy * @param src The symmetric crypto context to be copy
* *
* @return RT_EOK on success. * @return RT_EOK on success.
*/ */
rt_err_t rt_hwcrypto_symmetric_cpy(struct rt_hwcrypto_ctx *des, const struct rt_hwcrypto_ctx *src) rt_err_t rt_hwcrypto_symmetric_cpy(struct rt_hwcrypto_ctx *des, const struct rt_hwcrypto_ctx *src)

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2006-2019, RT-Thread Development Team * Copyright (c) 2006-2021, RT-Thread Development Team
* *
* SPDX-License-Identifier: Apache-2.0 * SPDX-License-Identifier: Apache-2.0
* *

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2006-2019, RT-Thread Development Team * Copyright (c) 2006-2021, RT-Thread Development Team
* *
* SPDX-License-Identifier: Apache-2.0 * SPDX-License-Identifier: Apache-2.0
* *

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2006-2019, RT-Thread Development Team * Copyright (c) 2006-2021, RT-Thread Development Team
* *
* SPDX-License-Identifier: Apache-2.0 * SPDX-License-Identifier: Apache-2.0
* *

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2006-2018, RT-Thread Development Team * Copyright (c) 2006-2021, RT-Thread Development Team
* *
* SPDX-License-Identifier: Apache-2.0 * SPDX-License-Identifier: Apache-2.0
* *
@ -325,7 +325,7 @@ void rt_device_hwtimer_isr(rt_hwtimer_t *timer)
} }
#ifdef RT_USING_DEVICE_OPS #ifdef RT_USING_DEVICE_OPS
const static struct rt_device_ops hwtimer_ops = const static struct rt_device_ops hwtimer_ops =
{ {
rt_hwtimer_init, rt_hwtimer_init,
rt_hwtimer_open, rt_hwtimer_open,

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2006-2018, RT-Thread Development Team * Copyright (c) 2006-2021, RT-Thread Development Team
* *
* SPDX-License-Identifier: Apache-2.0 * SPDX-License-Identifier: Apache-2.0
* *

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2006-2018, RT-Thread Development Team * Copyright (c) 2006-2021, RT-Thread Development Team
* *
* SPDX-License-Identifier: Apache-2.0 * SPDX-License-Identifier: Apache-2.0
* *

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2006-2018, RT-Thread Development Team * Copyright (c) 2006-2021, RT-Thread Development Team
* *
* SPDX-License-Identifier: Apache-2.0 * SPDX-License-Identifier: Apache-2.0
* *
@ -97,9 +97,9 @@ static rt_err_t i2c_bus_device_control(rt_device_t dev,
} }
#ifdef RT_USING_DEVICE_OPS #ifdef RT_USING_DEVICE_OPS
const static struct rt_device_ops i2c_ops = const static struct rt_device_ops i2c_ops =
{ {
RT_NULL, RT_NULL,
RT_NULL, RT_NULL,
RT_NULL, RT_NULL,
i2c_bus_device_read, i2c_bus_device_read,

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2006-2018, RT-Thread Development Team * Copyright (c) 2006-2021, RT-Thread Development Team
* *
* SPDX-License-Identifier: Apache-2.0 * SPDX-License-Identifier: Apache-2.0
* *

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2006-2018, RT-Thread Development Team * Copyright (c) 2006-2021, RT-Thread Development Team
* *
* SPDX-License-Identifier: Apache-2.0 * SPDX-License-Identifier: Apache-2.0
* *

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2006-2018, RT-Thread Development Team * Copyright (c) 2006-2021, RT-Thread Development Team
* *
* SPDX-License-Identifier: Apache-2.0 * SPDX-License-Identifier: Apache-2.0
* *

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2006-2018, RT-Thread Development Team * Copyright (c) 2006-2021, RT-Thread Development Team
* *
* SPDX-License-Identifier: Apache-2.0 * SPDX-License-Identifier: Apache-2.0
* *

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2006-2018, RT-Thread Development Team * Copyright (c) 2006-2021, RT-Thread Development Team
* *
* SPDX-License-Identifier: Apache-2.0 * SPDX-License-Identifier: Apache-2.0
* *

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2006-2018, RT-Thread Development Team * Copyright (c) 2006-2021, RT-Thread Development Team
* *
* SPDX-License-Identifier: Apache-2.0 * SPDX-License-Identifier: Apache-2.0
* *

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2006-2018, RT-Thread Development Team * Copyright (c) 2006-2021, RT-Thread Development Team
* *
* SPDX-License-Identifier: Apache-2.0 * SPDX-License-Identifier: Apache-2.0
* *

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2006-2018, RT-Thread Development Team * Copyright (c) 2006-2021, RT-Thread Development Team
* *
* SPDX-License-Identifier: Apache-2.0 * SPDX-License-Identifier: Apache-2.0
* *

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2006-2018, RT-Thread Development Team * Copyright (c) 2006-2021, RT-Thread Development Team
* *
* SPDX-License-Identifier: Apache-2.0 * SPDX-License-Identifier: Apache-2.0
* *

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2006-2018, RT-Thread Development Team * Copyright (c) 2006-2021, RT-Thread Development Team
* *
* SPDX-License-Identifier: Apache-2.0 * SPDX-License-Identifier: Apache-2.0
* *

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2006-2018, RT-Thread Development Team * Copyright (c) 2006-2021, RT-Thread Development Team
* *
* SPDX-License-Identifier: Apache-2.0 * SPDX-License-Identifier: Apache-2.0
* *

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2006-2018, RT-Thread Development Team * Copyright (c) 2006-2021, RT-Thread Development Team
* *
* SPDX-License-Identifier: Apache-2.0 * SPDX-License-Identifier: Apache-2.0
* *
@ -22,163 +22,163 @@ extern "C" {
* EXT_CSD fields * EXT_CSD fields
*/ */
#define EXT_CSD_FLUSH_CACHE 32 /* W */ #define EXT_CSD_FLUSH_CACHE 32 /* W */
#define EXT_CSD_CACHE_CTRL 33 /* R/W */ #define EXT_CSD_CACHE_CTRL 33 /* R/W */
#define EXT_CSD_POWER_OFF_NOTIFICATION 34 /* R/W */ #define EXT_CSD_POWER_OFF_NOTIFICATION 34 /* R/W */
#define EXT_CSD_PACKED_FAILURE_INDEX 35 /* RO */ #define EXT_CSD_PACKED_FAILURE_INDEX 35 /* RO */
#define EXT_CSD_PACKED_CMD_STATUS 36 /* RO */ #define EXT_CSD_PACKED_CMD_STATUS 36 /* RO */
#define EXT_CSD_EXP_EVENTS_STATUS 54 /* RO, 2 bytes */ #define EXT_CSD_EXP_EVENTS_STATUS 54 /* RO, 2 bytes */
#define EXT_CSD_EXP_EVENTS_CTRL 56 /* R/W, 2 bytes */ #define EXT_CSD_EXP_EVENTS_CTRL 56 /* R/W, 2 bytes */
#define EXT_CSD_DATA_SECTOR_SIZE 61 /* R */ #define EXT_CSD_DATA_SECTOR_SIZE 61 /* R */
#define EXT_CSD_GP_SIZE_MULT 143 /* R/W */ #define EXT_CSD_GP_SIZE_MULT 143 /* R/W */
#define EXT_CSD_PARTITION_ATTRIBUTE 156 /* R/W */ #define EXT_CSD_PARTITION_ATTRIBUTE 156 /* R/W */
#define EXT_CSD_PARTITION_SUPPORT 160 /* RO */ #define EXT_CSD_PARTITION_SUPPORT 160 /* RO */
#define EXT_CSD_HPI_MGMT 161 /* R/W */ #define EXT_CSD_HPI_MGMT 161 /* R/W */
#define EXT_CSD_RST_N_FUNCTION 162 /* R/W */ #define EXT_CSD_RST_N_FUNCTION 162 /* R/W */
#define EXT_CSD_BKOPS_EN 163 /* R/W */ #define EXT_CSD_BKOPS_EN 163 /* R/W */
#define EXT_CSD_BKOPS_START 164 /* W */ #define EXT_CSD_BKOPS_START 164 /* W */
#define EXT_CSD_SANITIZE_START 165 /* W */ #define EXT_CSD_SANITIZE_START 165 /* W */
#define EXT_CSD_WR_REL_PARAM 166 /* RO */ #define EXT_CSD_WR_REL_PARAM 166 /* RO */
#define EXT_CSD_RPMB_MULT 168 /* RO */ #define EXT_CSD_RPMB_MULT 168 /* RO */
#define EXT_CSD_BOOT_WP 173 /* R/W */ #define EXT_CSD_BOOT_WP 173 /* R/W */
#define EXT_CSD_ERASE_GROUP_DEF 175 /* R/W */ #define EXT_CSD_ERASE_GROUP_DEF 175 /* R/W */
#define EXT_CSD_PART_CONFIG 179 /* R/W */ #define EXT_CSD_PART_CONFIG 179 /* R/W */
#define EXT_CSD_ERASED_MEM_CONT 181 /* RO */ #define EXT_CSD_ERASED_MEM_CONT 181 /* RO */
#define EXT_CSD_BUS_WIDTH 183 /* R/W */ #define EXT_CSD_BUS_WIDTH 183 /* R/W */
#define EXT_CSD_HS_TIMING 185 /* R/W */ #define EXT_CSD_HS_TIMING 185 /* R/W */
#define EXT_CSD_POWER_CLASS 187 /* R/W */ #define EXT_CSD_POWER_CLASS 187 /* R/W */
#define EXT_CSD_REV 192 /* RO */ #define EXT_CSD_REV 192 /* RO */
#define EXT_CSD_STRUCTURE 194 /* RO */ #define EXT_CSD_STRUCTURE 194 /* RO */
#define EXT_CSD_CARD_TYPE 196 /* RO */ #define EXT_CSD_CARD_TYPE 196 /* RO */
#define EXT_CSD_OUT_OF_INTERRUPT_TIME 198 /* RO */ #define EXT_CSD_OUT_OF_INTERRUPT_TIME 198 /* RO */
#define EXT_CSD_PART_SWITCH_TIME 199 /* RO */ #define EXT_CSD_PART_SWITCH_TIME 199 /* RO */
#define EXT_CSD_PWR_CL_52_195 200 /* RO */ #define EXT_CSD_PWR_CL_52_195 200 /* RO */
#define EXT_CSD_PWR_CL_26_195 201 /* RO */ #define EXT_CSD_PWR_CL_26_195 201 /* RO */
#define EXT_CSD_PWR_CL_52_360 202 /* RO */ #define EXT_CSD_PWR_CL_52_360 202 /* RO */
#define EXT_CSD_PWR_CL_26_360 203 /* RO */ #define EXT_CSD_PWR_CL_26_360 203 /* RO */
#define EXT_CSD_SEC_CNT 212 /* RO, 4 bytes */ #define EXT_CSD_SEC_CNT 212 /* RO, 4 bytes */
#define EXT_CSD_S_A_TIMEOUT 217 /* RO */ #define EXT_CSD_S_A_TIMEOUT 217 /* RO */
#define EXT_CSD_REL_WR_SEC_C 222 /* RO */ #define EXT_CSD_REL_WR_SEC_C 222 /* RO */
#define EXT_CSD_HC_WP_GRP_SIZE 221 /* RO */ #define EXT_CSD_HC_WP_GRP_SIZE 221 /* RO */
#define EXT_CSD_ERASE_TIMEOUT_MULT 223 /* RO */ #define EXT_CSD_ERASE_TIMEOUT_MULT 223 /* RO */
#define EXT_CSD_HC_ERASE_GRP_SIZE 224 /* RO */ #define EXT_CSD_HC_ERASE_GRP_SIZE 224 /* RO */
#define EXT_CSD_BOOT_MULT 226 /* RO */ #define EXT_CSD_BOOT_MULT 226 /* RO */
#define EXT_CSD_SEC_TRIM_MULT 229 /* RO */ #define EXT_CSD_SEC_TRIM_MULT 229 /* RO */
#define EXT_CSD_SEC_ERASE_MULT 230 /* RO */ #define EXT_CSD_SEC_ERASE_MULT 230 /* RO */
#define EXT_CSD_SEC_FEATURE_SUPPORT 231 /* RO */ #define EXT_CSD_SEC_FEATURE_SUPPORT 231 /* RO */
#define EXT_CSD_TRIM_MULT 232 /* RO */ #define EXT_CSD_TRIM_MULT 232 /* RO */
#define EXT_CSD_PWR_CL_200_195 236 /* RO */ #define EXT_CSD_PWR_CL_200_195 236 /* RO */
#define EXT_CSD_PWR_CL_200_360 237 /* RO */ #define EXT_CSD_PWR_CL_200_360 237 /* RO */
#define EXT_CSD_PWR_CL_DDR_52_195 238 /* RO */ #define EXT_CSD_PWR_CL_DDR_52_195 238 /* RO */
#define EXT_CSD_PWR_CL_DDR_52_360 239 /* RO */ #define EXT_CSD_PWR_CL_DDR_52_360 239 /* RO */
#define EXT_CSD_BKOPS_STATUS 246 /* RO */ #define EXT_CSD_BKOPS_STATUS 246 /* RO */
#define EXT_CSD_POWER_OFF_LONG_TIME 247 /* RO */ #define EXT_CSD_POWER_OFF_LONG_TIME 247 /* RO */
#define EXT_CSD_GENERIC_CMD6_TIME 248 /* RO */ #define EXT_CSD_GENERIC_CMD6_TIME 248 /* RO */
#define EXT_CSD_CACHE_SIZE 249 /* RO, 4 bytes */ #define EXT_CSD_CACHE_SIZE 249 /* RO, 4 bytes */
#define EXT_CSD_PWR_CL_DDR_200_360 253 /* RO */ #define EXT_CSD_PWR_CL_DDR_200_360 253 /* RO */
#define EXT_CSD_TAG_UNIT_SIZE 498 /* RO */ #define EXT_CSD_TAG_UNIT_SIZE 498 /* RO */
#define EXT_CSD_DATA_TAG_SUPPORT 499 /* RO */ #define EXT_CSD_DATA_TAG_SUPPORT 499 /* RO */
#define EXT_CSD_MAX_PACKED_WRITES 500 /* RO */ #define EXT_CSD_MAX_PACKED_WRITES 500 /* RO */
#define EXT_CSD_MAX_PACKED_READS 501 /* RO */ #define EXT_CSD_MAX_PACKED_READS 501 /* RO */
#define EXT_CSD_BKOPS_SUPPORT 502 /* RO */ #define EXT_CSD_BKOPS_SUPPORT 502 /* RO */
#define EXT_CSD_HPI_FEATURES 503 /* RO */ #define EXT_CSD_HPI_FEATURES 503 /* RO */
/* /*
* EXT_CSD field definitions * EXT_CSD field definitions
*/ */
#define EXT_CSD_WR_REL_PARAM_EN (1<<2) #define EXT_CSD_WR_REL_PARAM_EN (1<<2)
#define EXT_CSD_BOOT_WP_B_PWR_WP_DIS (0x40) #define EXT_CSD_BOOT_WP_B_PWR_WP_DIS (0x40)
#define EXT_CSD_BOOT_WP_B_PERM_WP_DIS (0x10) #define EXT_CSD_BOOT_WP_B_PERM_WP_DIS (0x10)
#define EXT_CSD_BOOT_WP_B_PERM_WP_EN (0x04) #define EXT_CSD_BOOT_WP_B_PERM_WP_EN (0x04)
#define EXT_CSD_BOOT_WP_B_PWR_WP_EN (0x01) #define EXT_CSD_BOOT_WP_B_PWR_WP_EN (0x01)
#define EXT_CSD_PART_CONFIG_ACC_MASK (0x7) #define EXT_CSD_PART_CONFIG_ACC_MASK (0x7)
#define EXT_CSD_PART_CONFIG_ACC_BOOT0 (0x1) #define EXT_CSD_PART_CONFIG_ACC_BOOT0 (0x1)
#define EXT_CSD_PART_CONFIG_ACC_RPMB (0x3) #define EXT_CSD_PART_CONFIG_ACC_RPMB (0x3)
#define EXT_CSD_PART_CONFIG_ACC_GP0 (0x4) #define EXT_CSD_PART_CONFIG_ACC_GP0 (0x4)
#define EXT_CSD_PART_SUPPORT_PART_EN (0x1) #define EXT_CSD_PART_SUPPORT_PART_EN (0x1)
#define EXT_CSD_CMD_SET_NORMAL (1<<0) #define EXT_CSD_CMD_SET_NORMAL (1<<0)
#define EXT_CSD_CMD_SET_SECURE (1<<1) #define EXT_CSD_CMD_SET_SECURE (1<<1)
#define EXT_CSD_CMD_SET_CPSECURE (1<<2) #define EXT_CSD_CMD_SET_CPSECURE (1<<2)
#define EXT_CSD_CARD_TYPE_HS_26 (1<<0) /* Card can run at 26MHz */ #define EXT_CSD_CARD_TYPE_HS_26 (1<<0) /* Card can run at 26MHz */
#define EXT_CSD_CARD_TYPE_HS_52 (1<<1) /* Card can run at 52MHz */ #define EXT_CSD_CARD_TYPE_HS_52 (1<<1) /* Card can run at 52MHz */
#define EXT_CSD_CARD_TYPE_HS (EXT_CSD_CARD_TYPE_HS_26 | \ #define EXT_CSD_CARD_TYPE_HS (EXT_CSD_CARD_TYPE_HS_26 | \
EXT_CSD_CARD_TYPE_HS_52) EXT_CSD_CARD_TYPE_HS_52)
#define EXT_CSD_CARD_TYPE_DDR_1_8V (1<<2) /* Card can run at 52MHz */ #define EXT_CSD_CARD_TYPE_DDR_1_8V (1<<2) /* Card can run at 52MHz */
/* DDR mode @1.8V or 3V I/O */ /* DDR mode @1.8V or 3V I/O */
#define EXT_CSD_CARD_TYPE_DDR_1_2V (1<<3) /* Card can run at 52MHz */ #define EXT_CSD_CARD_TYPE_DDR_1_2V (1<<3) /* Card can run at 52MHz */
/* DDR mode @1.2V I/O */ /* DDR mode @1.2V I/O */
#define EXT_CSD_CARD_TYPE_DDR_52 (EXT_CSD_CARD_TYPE_DDR_1_8V \ #define EXT_CSD_CARD_TYPE_DDR_52 (EXT_CSD_CARD_TYPE_DDR_1_8V \
| EXT_CSD_CARD_TYPE_DDR_1_2V) | EXT_CSD_CARD_TYPE_DDR_1_2V)
#define EXT_CSD_CARD_TYPE_HS200_1_8V (1<<4) /* Card can run at 200MHz */ #define EXT_CSD_CARD_TYPE_HS200_1_8V (1<<4) /* Card can run at 200MHz */
#define EXT_CSD_CARD_TYPE_HS200_1_2V (1<<5) /* Card can run at 200MHz */ #define EXT_CSD_CARD_TYPE_HS200_1_2V (1<<5) /* Card can run at 200MHz */
/* SDR mode @1.2V I/O */ /* SDR mode @1.2V I/O */
#define EXT_CSD_CARD_TYPE_HS200 (EXT_CSD_CARD_TYPE_HS200_1_8V | \ #define EXT_CSD_CARD_TYPE_HS200 (EXT_CSD_CARD_TYPE_HS200_1_8V | \
EXT_CSD_CARD_TYPE_HS200_1_2V) EXT_CSD_CARD_TYPE_HS200_1_2V)
#define EXT_CSD_CARD_TYPE_HS400_1_8V (1<<6) /* Card can run at 200MHz DDR, 1.8V */ #define EXT_CSD_CARD_TYPE_HS400_1_8V (1<<6) /* Card can run at 200MHz DDR, 1.8V */
#define EXT_CSD_CARD_TYPE_HS400_1_2V (1<<7) /* Card can run at 200MHz DDR, 1.2V */ #define EXT_CSD_CARD_TYPE_HS400_1_2V (1<<7) /* Card can run at 200MHz DDR, 1.2V */
#define EXT_CSD_CARD_TYPE_HS400 (EXT_CSD_CARD_TYPE_HS400_1_8V | \ #define EXT_CSD_CARD_TYPE_HS400 (EXT_CSD_CARD_TYPE_HS400_1_8V | \
EXT_CSD_CARD_TYPE_HS400_1_2V) EXT_CSD_CARD_TYPE_HS400_1_2V)
#define EXT_CSD_BUS_WIDTH_1 0 /* Card is in 1 bit mode */ #define EXT_CSD_BUS_WIDTH_1 0 /* Card is in 1 bit mode */
#define EXT_CSD_BUS_WIDTH_4 1 /* Card is in 4 bit mode */ #define EXT_CSD_BUS_WIDTH_4 1 /* Card is in 4 bit mode */
#define EXT_CSD_BUS_WIDTH_8 2 /* Card is in 8 bit mode */ #define EXT_CSD_BUS_WIDTH_8 2 /* Card is in 8 bit mode */
#define EXT_CSD_DDR_BUS_WIDTH_4 5 /* Card is in 4 bit DDR mode */ #define EXT_CSD_DDR_BUS_WIDTH_4 5 /* Card is in 4 bit DDR mode */
#define EXT_CSD_DDR_BUS_WIDTH_8 6 /* Card is in 8 bit DDR mode */ #define EXT_CSD_DDR_BUS_WIDTH_8 6 /* Card is in 8 bit DDR mode */
#define EXT_CSD_TIMING_BC 0 /* Backwards compatility */ #define EXT_CSD_TIMING_BC 0 /* Backwards compatility */
#define EXT_CSD_TIMING_HS 1 /* High speed */ #define EXT_CSD_TIMING_HS 1 /* High speed */
#define EXT_CSD_TIMING_HS200 2 /* HS200 */ #define EXT_CSD_TIMING_HS200 2 /* HS200 */
#define EXT_CSD_TIMING_HS400 3 /* HS400 */ #define EXT_CSD_TIMING_HS400 3 /* HS400 */
#define EXT_CSD_SEC_ER_EN BIT(0) #define EXT_CSD_SEC_ER_EN BIT(0)
#define EXT_CSD_SEC_BD_BLK_EN BIT(2) #define EXT_CSD_SEC_BD_BLK_EN BIT(2)
#define EXT_CSD_SEC_GB_CL_EN BIT(4) #define EXT_CSD_SEC_GB_CL_EN BIT(4)
#define EXT_CSD_SEC_SANITIZE BIT(6) /* v4.5 only */ #define EXT_CSD_SEC_SANITIZE BIT(6) /* v4.5 only */
#define EXT_CSD_RST_N_EN_MASK 0x3 #define EXT_CSD_RST_N_EN_MASK 0x3
#define EXT_CSD_RST_N_ENABLED 1 /* RST_n is enabled on card */ #define EXT_CSD_RST_N_ENABLED 1 /* RST_n is enabled on card */
#define EXT_CSD_NO_POWER_NOTIFICATION 0 #define EXT_CSD_NO_POWER_NOTIFICATION 0
#define EXT_CSD_POWER_ON 1 #define EXT_CSD_POWER_ON 1
#define EXT_CSD_POWER_OFF_SHORT 2 #define EXT_CSD_POWER_OFF_SHORT 2
#define EXT_CSD_POWER_OFF_LONG 3 #define EXT_CSD_POWER_OFF_LONG 3
#define EXT_CSD_PWR_CL_8BIT_MASK 0xF0 /* 8 bit PWR CLS */ #define EXT_CSD_PWR_CL_8BIT_MASK 0xF0 /* 8 bit PWR CLS */
#define EXT_CSD_PWR_CL_4BIT_MASK 0x0F /* 8 bit PWR CLS */ #define EXT_CSD_PWR_CL_4BIT_MASK 0x0F /* 8 bit PWR CLS */
#define EXT_CSD_PWR_CL_8BIT_SHIFT 4 #define EXT_CSD_PWR_CL_8BIT_SHIFT 4
#define EXT_CSD_PWR_CL_4BIT_SHIFT 0 #define EXT_CSD_PWR_CL_4BIT_SHIFT 0
#define EXT_CSD_PACKED_EVENT_EN BIT(3) #define EXT_CSD_PACKED_EVENT_EN BIT(3)
/* /*
* EXCEPTION_EVENT_STATUS field * EXCEPTION_EVENT_STATUS field
*/ */
#define EXT_CSD_URGENT_BKOPS BIT(0) #define EXT_CSD_URGENT_BKOPS BIT(0)
#define EXT_CSD_DYNCAP_NEEDED BIT(1) #define EXT_CSD_DYNCAP_NEEDED BIT(1)
#define EXT_CSD_SYSPOOL_EXHAUSTED BIT(2) #define EXT_CSD_SYSPOOL_EXHAUSTED BIT(2)
#define EXT_CSD_PACKED_FAILURE BIT(3) #define EXT_CSD_PACKED_FAILURE BIT(3)
#define EXT_CSD_PACKED_GENERIC_ERROR BIT(0) #define EXT_CSD_PACKED_GENERIC_ERROR BIT(0)
#define EXT_CSD_PACKED_INDEXED_ERROR BIT(1) #define EXT_CSD_PACKED_INDEXED_ERROR BIT(1)
/* /*
* BKOPS status level * BKOPS status level
*/ */
#define EXT_CSD_BKOPS_LEVEL_2 0x2 #define EXT_CSD_BKOPS_LEVEL_2 0x2
/* /*
* MMC_SWITCH access modes * MMC_SWITCH access modes
*/ */
#define MMC_SWITCH_MODE_CMD_SET 0x00 /* Change the command set */ #define MMC_SWITCH_MODE_CMD_SET 0x00 /* Change the command set */
#define MMC_SWITCH_MODE_SET_BITS 0x01 /* Set bits which are 1 in value */ #define MMC_SWITCH_MODE_SET_BITS 0x01 /* Set bits which are 1 in value */
#define MMC_SWITCH_MODE_CLEAR_BITS 0x02 /* Clear bits which are 1 in value */ #define MMC_SWITCH_MODE_CLEAR_BITS 0x02 /* Clear bits which are 1 in value */
#define MMC_SWITCH_MODE_WRITE_BYTE 0x03 /* Set target to value */ #define MMC_SWITCH_MODE_WRITE_BYTE 0x03 /* Set target to value */
/* /*
* extern function * extern function
*/ */

View File

@ -1,11 +1,11 @@
/* /*
* Copyright (c) 2006-2018, RT-Thread Development Team * Copyright (c) 2006-2021, RT-Thread Development Team
* *
* SPDX-License-Identifier: Apache-2.0 * SPDX-License-Identifier: Apache-2.0
* *
* Change Logs: * Change Logs:
* Date Author Notes * Date Author Notes
* 2011-07-25 weety first version * 2011-07-25 weety first version
*/ */
#ifndef __MMCSD_CARD_H__ #ifndef __MMCSD_CARD_H__
@ -17,87 +17,87 @@
extern "C" { extern "C" {
#endif #endif
#define SD_SCR_BUS_WIDTH_1 (1 << 0) #define SD_SCR_BUS_WIDTH_1 (1 << 0)
#define SD_SCR_BUS_WIDTH_4 (1 << 2) #define SD_SCR_BUS_WIDTH_4 (1 << 2)
struct rt_mmcsd_cid { struct rt_mmcsd_cid {
rt_uint8_t mid; /* ManufacturerID */ rt_uint8_t mid; /* ManufacturerID */
rt_uint8_t prv; /* Product Revision */ rt_uint8_t prv; /* Product Revision */
rt_uint16_t oid; /* OEM/Application ID */ rt_uint16_t oid; /* OEM/Application ID */
rt_uint32_t psn; /* Product Serial Number */ rt_uint32_t psn; /* Product Serial Number */
rt_uint8_t pnm[5]; /* Product Name */ rt_uint8_t pnm[5]; /* Product Name */
rt_uint8_t reserved1;/* reserved */ rt_uint8_t reserved1;/* reserved */
rt_uint16_t mdt; /* Manufacturing Date */ rt_uint16_t mdt; /* Manufacturing Date */
rt_uint8_t crc; /* CID CRC */ rt_uint8_t crc; /* CID CRC */
rt_uint8_t reserved2;/* not used, always 1 */ rt_uint8_t reserved2;/* not used, always 1 */
}; };
struct rt_mmcsd_csd { struct rt_mmcsd_csd {
rt_uint8_t csd_structure; /* CSD register version */ rt_uint8_t csd_structure; /* CSD register version */
rt_uint8_t taac; rt_uint8_t taac;
rt_uint8_t nsac; rt_uint8_t nsac;
rt_uint8_t tran_speed; /* max data transfer rate */ rt_uint8_t tran_speed; /* max data transfer rate */
rt_uint16_t card_cmd_class; /* card command classes */ rt_uint16_t card_cmd_class; /* card command classes */
rt_uint8_t rd_blk_len; /* max read data block length */ rt_uint8_t rd_blk_len; /* max read data block length */
rt_uint8_t rd_blk_part; rt_uint8_t rd_blk_part;
rt_uint8_t wr_blk_misalign; rt_uint8_t wr_blk_misalign;
rt_uint8_t rd_blk_misalign; rt_uint8_t rd_blk_misalign;
rt_uint8_t dsr_imp; /* DSR implemented */ rt_uint8_t dsr_imp; /* DSR implemented */
rt_uint8_t c_size_mult; /* CSD 1.0 , device size multiplier */ rt_uint8_t c_size_mult; /* CSD 1.0 , device size multiplier */
rt_uint32_t c_size; /* device size */ rt_uint32_t c_size; /* device size */
rt_uint8_t r2w_factor; rt_uint8_t r2w_factor;
rt_uint8_t wr_blk_len; /* max wtire data block length */ rt_uint8_t wr_blk_len; /* max wtire data block length */
rt_uint8_t wr_blk_partial; rt_uint8_t wr_blk_partial;
rt_uint8_t csd_crc; rt_uint8_t csd_crc;
}; };
struct rt_sd_scr { struct rt_sd_scr {
rt_uint8_t sd_version; rt_uint8_t sd_version;
rt_uint8_t sd_bus_widths; rt_uint8_t sd_bus_widths;
}; };
struct rt_sdio_cccr { struct rt_sdio_cccr {
rt_uint8_t sdio_version; rt_uint8_t sdio_version;
rt_uint8_t sd_version; rt_uint8_t sd_version;
rt_uint8_t direct_cmd:1, /* Card Supports Direct Commands during data transfer rt_uint8_t direct_cmd:1, /* Card Supports Direct Commands during data transfer
only SD mode, not used for SPI mode */ only SD mode, not used for SPI mode */
multi_block:1, /* Card Supports Multi-Block */ multi_block:1, /* Card Supports Multi-Block */
read_wait:1, /* Card Supports Read Wait read_wait:1, /* Card Supports Read Wait
only SD mode, not used for SPI mode */ only SD mode, not used for SPI mode */
suspend_resume:1, /* Card supports Suspend/Resume suspend_resume:1, /* Card supports Suspend/Resume
only SD mode, not used for SPI mode */ only SD mode, not used for SPI mode */
s4mi:1, /* generate interrupts during a 4-bit s4mi:1, /* generate interrupts during a 4-bit
multi-block data transfer */ multi-block data transfer */
e4mi:1, /* Enable the multi-block IRQ during e4mi:1, /* Enable the multi-block IRQ during
4-bit transfer for the SDIO card */ 4-bit transfer for the SDIO card */
low_speed:1, /* Card is a Low-Speed card */ low_speed:1, /* Card is a Low-Speed card */
low_speed_4:1; /* 4-bit support for Low-Speed cards */ low_speed_4:1; /* 4-bit support for Low-Speed cards */
rt_uint8_t bus_width:1, /* Support SDIO bus width, 1:4bit, 0:1bit */
cd_disable:1, /* Connect[0]/Disconnect[1] the 10K-90K ohm pull-up
resistor on CD/DAT[3] (pin 1) of the card */
power_ctrl:1, /* Support Master Power Control */
high_speed:1; /* Support High-Speed */
rt_uint8_t bus_width:1, /* Support SDIO bus width, 1:4bit, 0:1bit */
cd_disable:1, /* Connect[0]/Disconnect[1] the 10K-90K ohm pull-up
resistor on CD/DAT[3] (pin 1) of the card */
power_ctrl:1, /* Support Master Power Control */
high_speed:1; /* Support High-Speed */
}; };
struct rt_sdio_cis { struct rt_sdio_cis {
rt_uint16_t manufacturer; rt_uint16_t manufacturer;
rt_uint16_t product; rt_uint16_t product;
rt_uint16_t func0_blk_size; rt_uint16_t func0_blk_size;
rt_uint32_t max_tran_speed; rt_uint32_t max_tran_speed;
}; };
/* /*
* SDIO function CIS tuple (unknown to the core) * SDIO function CIS tuple (unknown to the core)
*/ */
struct rt_sdio_function_tuple { struct rt_sdio_function_tuple {
struct rt_sdio_function_tuple *next; struct rt_sdio_function_tuple *next;
rt_uint8_t code; rt_uint8_t code;
rt_uint8_t size; rt_uint8_t size;
rt_uint8_t *data; rt_uint8_t *data;
}; };
struct rt_sdio_function; struct rt_sdio_function;
@ -107,60 +107,60 @@ typedef void (rt_sdio_irq_handler_t)(struct rt_sdio_function *);
* SDIO function devices * SDIO function devices
*/ */
struct rt_sdio_function { struct rt_sdio_function {
struct rt_mmcsd_card *card; /* the card this device belongs to */ struct rt_mmcsd_card *card; /* the card this device belongs to */
rt_sdio_irq_handler_t *irq_handler; /* IRQ callback */ rt_sdio_irq_handler_t *irq_handler; /* IRQ callback */
rt_uint8_t num; /* function number */ rt_uint8_t num; /* function number */
rt_uint8_t func_code; /* Standard SDIO Function interface code */ rt_uint8_t func_code; /* Standard SDIO Function interface code */
rt_uint16_t manufacturer; /* manufacturer id */ rt_uint16_t manufacturer; /* manufacturer id */
rt_uint16_t product; /* product id */ rt_uint16_t product; /* product id */
rt_uint32_t max_blk_size; /* maximum block size */ rt_uint32_t max_blk_size; /* maximum block size */
rt_uint32_t cur_blk_size; /* current block size */ rt_uint32_t cur_blk_size; /* current block size */
rt_uint32_t enable_timeout_val; /* max enable timeout in msec */ rt_uint32_t enable_timeout_val; /* max enable timeout in msec */
struct rt_sdio_function_tuple *tuples;
struct rt_sdio_function_tuple *tuples;
void *priv; void *priv;
}; };
#define SDIO_MAX_FUNCTIONS 7 #define SDIO_MAX_FUNCTIONS 7
struct rt_mmcsd_card { struct rt_mmcsd_card {
struct rt_mmcsd_host *host; struct rt_mmcsd_host *host;
rt_uint32_t rca; /* card addr */ rt_uint32_t rca; /* card addr */
rt_uint32_t resp_cid[4]; /* card CID register */ rt_uint32_t resp_cid[4]; /* card CID register */
rt_uint32_t resp_csd[4]; /* card CSD register */ rt_uint32_t resp_csd[4]; /* card CSD register */
rt_uint32_t resp_scr[2]; /* card SCR register */ rt_uint32_t resp_scr[2]; /* card SCR register */
rt_uint16_t tacc_clks; /* data access time by ns */ rt_uint16_t tacc_clks; /* data access time by ns */
rt_uint32_t tacc_ns; /* data access time by clk cycles */ rt_uint32_t tacc_ns; /* data access time by clk cycles */
rt_uint32_t max_data_rate; /* max data transfer rate */ rt_uint32_t max_data_rate; /* max data transfer rate */
rt_uint32_t card_capacity; /* card capacity, unit:KB */ rt_uint32_t card_capacity; /* card capacity, unit:KB */
rt_uint32_t card_blksize; /* card block size */ rt_uint32_t card_blksize; /* card block size */
rt_uint32_t erase_size; /* erase size in sectors */ rt_uint32_t erase_size; /* erase size in sectors */
rt_uint16_t card_type; rt_uint16_t card_type;
#define CARD_TYPE_MMC 0 /* MMC card */ #define CARD_TYPE_MMC 0 /* MMC card */
#define CARD_TYPE_SD 1 /* SD card */ #define CARD_TYPE_SD 1 /* SD card */
#define CARD_TYPE_SDIO 2 /* SDIO card */ #define CARD_TYPE_SDIO 2 /* SDIO card */
#define CARD_TYPE_SDIO_COMBO 3 /* SD combo (IO+mem) card */ #define CARD_TYPE_SDIO_COMBO 3 /* SD combo (IO+mem) card */
rt_uint16_t flags; rt_uint16_t flags;
#define CARD_FLAG_HIGHSPEED (1 << 0) /* SDIO bus speed 50MHz */ #define CARD_FLAG_HIGHSPEED (1 << 0) /* SDIO bus speed 50MHz */
#define CARD_FLAG_SDHC (1 << 1) /* SDHC card */ #define CARD_FLAG_SDHC (1 << 1) /* SDHC card */
#define CARD_FLAG_SDXC (1 << 2) /* SDXC card */ #define CARD_FLAG_SDXC (1 << 2) /* SDXC card */
struct rt_sd_scr scr; struct rt_sd_scr scr;
struct rt_mmcsd_csd csd; struct rt_mmcsd_csd csd;
rt_uint32_t hs_max_data_rate; /* max data transfer rate in high speed mode */ rt_uint32_t hs_max_data_rate; /* max data transfer rate in high speed mode */
rt_uint8_t sdio_function_num; /* totol number of SDIO functions */ rt_uint8_t sdio_function_num; /* totol number of SDIO functions */
struct rt_sdio_cccr cccr; /* common card info */ struct rt_sdio_cccr cccr; /* common card info */
struct rt_sdio_cis cis; /* common tuple info */ struct rt_sdio_cis cis; /* common tuple info */
struct rt_sdio_function *sdio_function[SDIO_MAX_FUNCTIONS + 1]; /* SDIO functions (devices) */ struct rt_sdio_function *sdio_function[SDIO_MAX_FUNCTIONS + 1]; /* SDIO functions (devices) */
}; };

View File

@ -1,11 +1,11 @@
/* /*
* Copyright (c) 2006-2018, RT-Thread Development Team * Copyright (c) 2006-2021, RT-Thread Development Team
* *
* SPDX-License-Identifier: Apache-2.0 * SPDX-License-Identifier: Apache-2.0
* *
* Change Logs: * Change Logs:
* Date Author Notes * Date Author Notes
* 2011-07-25 weety first version * 2011-07-25 weety first version
*/ */
#ifndef __CMD_H__ #ifndef __CMD_H__
@ -85,9 +85,9 @@ extern "C" {
#define SD_APP_OP_COND 41 /* bcr [31:0] OCR R3 */ #define SD_APP_OP_COND 41 /* bcr [31:0] OCR R3 */
#define SD_APP_SEND_SCR 51 /* adtc R1 */ #define SD_APP_SEND_SCR 51 /* adtc R1 */
#define SCR_SPEC_VER_0 0 /* Implements system specification 1.0 - 1.01 */ #define SCR_SPEC_VER_0 0 /* Implements system specification 1.0 - 1.01 */
#define SCR_SPEC_VER_1 1 /* Implements system specification 1.10 */ #define SCR_SPEC_VER_1 1 /* Implements system specification 1.10 */
#define SCR_SPEC_VER_2 2 /* Implements system specification 2.00 */ #define SCR_SPEC_VER_2 2 /* Implements system specification 2.00 */
/* SDIO commands type argument response */ /* SDIO commands type argument response */

View File

@ -1,11 +1,11 @@
/* /*
* Copyright (c) 2006-2018, RT-Thread Development Team * Copyright (c) 2006-2021, RT-Thread Development Team
* *
* SPDX-License-Identifier: Apache-2.0 * SPDX-License-Identifier: Apache-2.0
* *
* Change Logs: * Change Logs:
* Date Author Notes * Date Author Notes
* 2011-07-25 weety first version * 2011-07-25 weety first version
*/ */
#ifndef __CORE_H__ #ifndef __CORE_H__
@ -27,139 +27,139 @@ extern "C" {
#endif #endif
struct rt_mmcsd_data { struct rt_mmcsd_data {
rt_uint32_t blksize; rt_uint32_t blksize;
rt_uint32_t blks; rt_uint32_t blks;
rt_uint32_t *buf; rt_uint32_t *buf;
rt_int32_t err; rt_int32_t err;
rt_uint32_t flags; rt_uint32_t flags;
#define DATA_DIR_WRITE (1 << 0) #define DATA_DIR_WRITE (1 << 0)
#define DATA_DIR_READ (1 << 1) #define DATA_DIR_READ (1 << 1)
#define DATA_STREAM (1 << 2) #define DATA_STREAM (1 << 2)
unsigned int bytes_xfered; unsigned int bytes_xfered;
struct rt_mmcsd_cmd *stop; /* stop command */ struct rt_mmcsd_cmd *stop; /* stop command */
struct rt_mmcsd_req *mrq; /* associated request */ struct rt_mmcsd_req *mrq; /* associated request */
rt_uint32_t timeout_ns; rt_uint32_t timeout_ns;
rt_uint32_t timeout_clks; rt_uint32_t timeout_clks;
}; };
struct rt_mmcsd_cmd { struct rt_mmcsd_cmd {
rt_uint32_t cmd_code; rt_uint32_t cmd_code;
rt_uint32_t arg; rt_uint32_t arg;
rt_uint32_t resp[4]; rt_uint32_t resp[4];
rt_uint32_t flags; rt_uint32_t flags;
/*rsponse types /*rsponse types
*bits:0~3 *bits:0~3
*/ */
#define RESP_MASK (0xF) #define RESP_MASK (0xF)
#define RESP_NONE (0) #define RESP_NONE (0)
#define RESP_R1 (1 << 0) #define RESP_R1 (1 << 0)
#define RESP_R1B (2 << 0) #define RESP_R1B (2 << 0)
#define RESP_R2 (3 << 0) #define RESP_R2 (3 << 0)
#define RESP_R3 (4 << 0) #define RESP_R3 (4 << 0)
#define RESP_R4 (5 << 0) #define RESP_R4 (5 << 0)
#define RESP_R6 (6 << 0) #define RESP_R6 (6 << 0)
#define RESP_R7 (7 << 0) #define RESP_R7 (7 << 0)
#define RESP_R5 (8 << 0) /*SDIO command response type*/ #define RESP_R5 (8 << 0) /*SDIO command response type*/
/*command types /*command types
*bits:4~5 *bits:4~5
*/ */
#define CMD_MASK (3 << 4) /* command type */ #define CMD_MASK (3 << 4) /* command type */
#define CMD_AC (0 << 4) #define CMD_AC (0 << 4)
#define CMD_ADTC (1 << 4) #define CMD_ADTC (1 << 4)
#define CMD_BC (2 << 4) #define CMD_BC (2 << 4)
#define CMD_BCR (3 << 4) #define CMD_BCR (3 << 4)
#define resp_type(cmd) ((cmd)->flags & RESP_MASK) #define resp_type(cmd) ((cmd)->flags & RESP_MASK)
/*spi rsponse types /*spi rsponse types
*bits:6~8 *bits:6~8
*/ */
#define RESP_SPI_MASK (0x7 << 6) #define RESP_SPI_MASK (0x7 << 6)
#define RESP_SPI_R1 (1 << 6) #define RESP_SPI_R1 (1 << 6)
#define RESP_SPI_R1B (2 << 6) #define RESP_SPI_R1B (2 << 6)
#define RESP_SPI_R2 (3 << 6) #define RESP_SPI_R2 (3 << 6)
#define RESP_SPI_R3 (4 << 6) #define RESP_SPI_R3 (4 << 6)
#define RESP_SPI_R4 (5 << 6) #define RESP_SPI_R4 (5 << 6)
#define RESP_SPI_R5 (6 << 6) #define RESP_SPI_R5 (6 << 6)
#define RESP_SPI_R7 (7 << 6) #define RESP_SPI_R7 (7 << 6)
#define spi_resp_type(cmd) ((cmd)->flags & RESP_SPI_MASK) #define spi_resp_type(cmd) ((cmd)->flags & RESP_SPI_MASK)
/* /*
* These are the command types. * These are the command types.
*/ */
#define cmd_type(cmd) ((cmd)->flags & CMD_MASK) #define cmd_type(cmd) ((cmd)->flags & CMD_MASK)
rt_int32_t retries; /* max number of retries */
rt_int32_t err;
struct rt_mmcsd_data *data; rt_int32_t retries; /* max number of retries */
struct rt_mmcsd_req *mrq; /* associated request */ rt_int32_t err;
struct rt_mmcsd_data *data;
struct rt_mmcsd_req *mrq; /* associated request */
}; };
struct rt_mmcsd_req { struct rt_mmcsd_req {
struct rt_mmcsd_data *data; struct rt_mmcsd_data *data;
struct rt_mmcsd_cmd *cmd; struct rt_mmcsd_cmd *cmd;
struct rt_mmcsd_cmd *stop; struct rt_mmcsd_cmd *stop;
}; };
/*the following is response bit*/ /*the following is response bit*/
#define R1_OUT_OF_RANGE (1 << 31) /* er, c */ #define R1_OUT_OF_RANGE (1 << 31) /* er, c */
#define R1_ADDRESS_ERROR (1 << 30) /* erx, c */ #define R1_ADDRESS_ERROR (1 << 30) /* erx, c */
#define R1_BLOCK_LEN_ERROR (1 << 29) /* er, c */ #define R1_BLOCK_LEN_ERROR (1 << 29) /* er, c */
#define R1_ERASE_SEQ_ERROR (1 << 28) /* er, c */ #define R1_ERASE_SEQ_ERROR (1 << 28) /* er, c */
#define R1_ERASE_PARAM (1 << 27) /* ex, c */ #define R1_ERASE_PARAM (1 << 27) /* ex, c */
#define R1_WP_VIOLATION (1 << 26) /* erx, c */ #define R1_WP_VIOLATION (1 << 26) /* erx, c */
#define R1_CARD_IS_LOCKED (1 << 25) /* sx, a */ #define R1_CARD_IS_LOCKED (1 << 25) /* sx, a */
#define R1_LOCK_UNLOCK_FAILED (1 << 24) /* erx, c */ #define R1_LOCK_UNLOCK_FAILED (1 << 24) /* erx, c */
#define R1_COM_CRC_ERROR (1 << 23) /* er, b */ #define R1_COM_CRC_ERROR (1 << 23) /* er, b */
#define R1_ILLEGAL_COMMAND (1 << 22) /* er, b */ #define R1_ILLEGAL_COMMAND (1 << 22) /* er, b */
#define R1_CARD_ECC_FAILED (1 << 21) /* ex, c */ #define R1_CARD_ECC_FAILED (1 << 21) /* ex, c */
#define R1_CC_ERROR (1 << 20) /* erx, c */ #define R1_CC_ERROR (1 << 20) /* erx, c */
#define R1_ERROR (1 << 19) /* erx, c */ #define R1_ERROR (1 << 19) /* erx, c */
#define R1_UNDERRUN (1 << 18) /* ex, c */ #define R1_UNDERRUN (1 << 18) /* ex, c */
#define R1_OVERRUN (1 << 17) /* ex, c */ #define R1_OVERRUN (1 << 17) /* ex, c */
#define R1_CID_CSD_OVERWRITE (1 << 16) /* erx, c, CID/CSD overwrite */ #define R1_CID_CSD_OVERWRITE (1 << 16) /* erx, c, CID/CSD overwrite */
#define R1_WP_ERASE_SKIP (1 << 15) /* sx, c */ #define R1_WP_ERASE_SKIP (1 << 15) /* sx, c */
#define R1_CARD_ECC_DISABLED (1 << 14) /* sx, a */ #define R1_CARD_ECC_DISABLED (1 << 14) /* sx, a */
#define R1_ERASE_RESET (1 << 13) /* sr, c */ #define R1_ERASE_RESET (1 << 13) /* sr, c */
#define R1_STATUS(x) (x & 0xFFFFE000) #define R1_STATUS(x) (x & 0xFFFFE000)
#define R1_CURRENT_STATE(x) ((x & 0x00001E00) >> 9) /* sx, b (4 bits) */ #define R1_CURRENT_STATE(x) ((x & 0x00001E00) >> 9) /* sx, b (4 bits) */
#define R1_READY_FOR_DATA (1 << 8) /* sx, a */ #define R1_READY_FOR_DATA (1 << 8) /* sx, a */
#define R1_APP_CMD (1 << 5) /* sr, c */ #define R1_APP_CMD (1 << 5) /* sr, c */
#define R1_SPI_IDLE (1 << 0) #define R1_SPI_IDLE (1 << 0)
#define R1_SPI_ERASE_RESET (1 << 1) #define R1_SPI_ERASE_RESET (1 << 1)
#define R1_SPI_ILLEGAL_COMMAND (1 << 2) #define R1_SPI_ILLEGAL_COMMAND (1 << 2)
#define R1_SPI_COM_CRC (1 << 3) #define R1_SPI_COM_CRC (1 << 3)
#define R1_SPI_ERASE_SEQ (1 << 4) #define R1_SPI_ERASE_SEQ (1 << 4)
#define R1_SPI_ADDRESS (1 << 5) #define R1_SPI_ADDRESS (1 << 5)
#define R1_SPI_PARAMETER (1 << 6) #define R1_SPI_PARAMETER (1 << 6)
/* R1 bit 7 is always zero */ /* R1 bit 7 is always zero */
#define R2_SPI_CARD_LOCKED (1 << 8) #define R2_SPI_CARD_LOCKED (1 << 8)
#define R2_SPI_WP_ERASE_SKIP (1 << 9) /* or lock/unlock fail */ #define R2_SPI_WP_ERASE_SKIP (1 << 9) /* or lock/unlock fail */
#define R2_SPI_LOCK_UNLOCK_FAIL R2_SPI_WP_ERASE_SKIP #define R2_SPI_LOCK_UNLOCK_FAIL R2_SPI_WP_ERASE_SKIP
#define R2_SPI_ERROR (1 << 10) #define R2_SPI_ERROR (1 << 10)
#define R2_SPI_CC_ERROR (1 << 11) #define R2_SPI_CC_ERROR (1 << 11)
#define R2_SPI_CARD_ECC_ERROR (1 << 12) #define R2_SPI_CARD_ECC_ERROR (1 << 12)
#define R2_SPI_WP_VIOLATION (1 << 13) #define R2_SPI_WP_VIOLATION (1 << 13)
#define R2_SPI_ERASE_PARAM (1 << 14) #define R2_SPI_ERASE_PARAM (1 << 14)
#define R2_SPI_OUT_OF_RANGE (1 << 15) /* or CSD overwrite */ #define R2_SPI_OUT_OF_RANGE (1 << 15) /* or CSD overwrite */
#define R2_SPI_CSD_OVERWRITE R2_SPI_OUT_OF_RANGE #define R2_SPI_CSD_OVERWRITE R2_SPI_OUT_OF_RANGE
#define CARD_BUSY 0x80000000 /* Card Power up status bit */ #define CARD_BUSY 0x80000000 /* Card Power up status bit */
/* R5 response bits */ /* R5 response bits */
#define R5_COM_CRC_ERROR (1 << 15) #define R5_COM_CRC_ERROR (1 << 15)
#define R5_ILLEGAL_COMMAND (1 << 14) #define R5_ILLEGAL_COMMAND (1 << 14)
#define R5_ERROR (1 << 11) #define R5_ERROR (1 << 11)
#define R5_FUNCTION_NUMBER (1 << 9) #define R5_FUNCTION_NUMBER (1 << 9)
#define R5_OUT_OF_RANGE (1 << 8) #define R5_OUT_OF_RANGE (1 << 8)
#define R5_STATUS(x) (x & 0xCB00) #define R5_STATUS(x) (x & 0xCB00)
#define R5_IO_CURRENT_STATE(x) ((x & 0x3000) >> 12) #define R5_IO_CURRENT_STATE(x) ((x & 0x3000) >> 12)
@ -173,36 +173,36 @@ struct rt_mmcsd_req {
rt_inline rt_uint32_t __rt_fls(rt_uint32_t val) rt_inline rt_uint32_t __rt_fls(rt_uint32_t val)
{ {
rt_uint32_t bit = 32; rt_uint32_t bit = 32;
if (!val) if (!val)
return 0; return 0;
if (!(val & 0xffff0000u)) if (!(val & 0xffff0000u))
{ {
val <<= 16; val <<= 16;
bit -= 16; bit -= 16;
} }
if (!(val & 0xff000000u)) if (!(val & 0xff000000u))
{ {
val <<= 8; val <<= 8;
bit -= 8; bit -= 8;
} }
if (!(val & 0xf0000000u)) if (!(val & 0xf0000000u))
{ {
val <<= 4; val <<= 4;
bit -= 4; bit -= 4;
} }
if (!(val & 0xc0000000u)) if (!(val & 0xc0000000u))
{ {
val <<= 2; val <<= 2;
bit -= 2; bit -= 2;
} }
if (!(val & 0x80000000u)) if (!(val & 0x80000000u))
{ {
bit -= 1; bit -= 1;
} }
return bit; return bit;
} }
#define MMCSD_HOST_PLUGED 0 #define MMCSD_HOST_PLUGED 0

View File

@ -1,11 +1,11 @@
/* /*
* Copyright (c) 2006-2018, RT-Thread Development Team * Copyright (c) 2006-2021, RT-Thread Development Team
* *
* SPDX-License-Identifier: Apache-2.0 * SPDX-License-Identifier: Apache-2.0
* *
* Change Logs: * Change Logs:
* Date Author Notes * Date Author Notes
* 2011-07-25 weety first version * 2011-07-25 weety first version
*/ */
#ifndef __HOST_H__ #ifndef __HOST_H__
@ -18,33 +18,33 @@ extern "C" {
#endif #endif
struct rt_mmcsd_io_cfg { struct rt_mmcsd_io_cfg {
rt_uint32_t clock; /* clock rate */ rt_uint32_t clock; /* clock rate */
rt_uint16_t vdd; rt_uint16_t vdd;
/* vdd stores the bit number of the selected voltage range from below. */ /* vdd stores the bit number of the selected voltage range from below. */
rt_uint8_t bus_mode; /* command output mode */ rt_uint8_t bus_mode; /* command output mode */
#define MMCSD_BUSMODE_OPENDRAIN 1 #define MMCSD_BUSMODE_OPENDRAIN 1
#define MMCSD_BUSMODE_PUSHPULL 2 #define MMCSD_BUSMODE_PUSHPULL 2
rt_uint8_t chip_select; /* SPI chip select */ rt_uint8_t chip_select; /* SPI chip select */
#define MMCSD_CS_IGNORE 0 #define MMCSD_CS_IGNORE 0
#define MMCSD_CS_HIGH 1 #define MMCSD_CS_HIGH 1
#define MMCSD_CS_LOW 2 #define MMCSD_CS_LOW 2
rt_uint8_t power_mode; /* power supply mode */ rt_uint8_t power_mode; /* power supply mode */
#define MMCSD_POWER_OFF 0 #define MMCSD_POWER_OFF 0
#define MMCSD_POWER_UP 1 #define MMCSD_POWER_UP 1
#define MMCSD_POWER_ON 2 #define MMCSD_POWER_ON 2
rt_uint8_t bus_width; /* data bus width */ rt_uint8_t bus_width; /* data bus width */
#define MMCSD_BUS_WIDTH_1 0 #define MMCSD_BUS_WIDTH_1 0
#define MMCSD_BUS_WIDTH_4 2 #define MMCSD_BUS_WIDTH_4 2
#define MMCSD_BUS_WIDTH_8 3 #define MMCSD_BUS_WIDTH_8 3
}; };
@ -52,71 +52,71 @@ struct rt_mmcsd_host;
struct rt_mmcsd_req; struct rt_mmcsd_req;
struct rt_mmcsd_host_ops { struct rt_mmcsd_host_ops {
void (*request)(struct rt_mmcsd_host *host, struct rt_mmcsd_req *req); void (*request)(struct rt_mmcsd_host *host, struct rt_mmcsd_req *req);
void (*set_iocfg)(struct rt_mmcsd_host *host, struct rt_mmcsd_io_cfg *io_cfg); void (*set_iocfg)(struct rt_mmcsd_host *host, struct rt_mmcsd_io_cfg *io_cfg);
rt_int32_t (*get_card_status)(struct rt_mmcsd_host *host); rt_int32_t (*get_card_status)(struct rt_mmcsd_host *host);
void (*enable_sdio_irq)(struct rt_mmcsd_host *host, rt_int32_t en); void (*enable_sdio_irq)(struct rt_mmcsd_host *host, rt_int32_t en);
}; };
struct rt_mmcsd_host { struct rt_mmcsd_host {
struct rt_mmcsd_card *card; struct rt_mmcsd_card *card;
const struct rt_mmcsd_host_ops *ops; const struct rt_mmcsd_host_ops *ops;
rt_uint32_t freq_min; rt_uint32_t freq_min;
rt_uint32_t freq_max; rt_uint32_t freq_max;
struct rt_mmcsd_io_cfg io_cfg; struct rt_mmcsd_io_cfg io_cfg;
rt_uint32_t valid_ocr; /* current valid OCR */ rt_uint32_t valid_ocr; /* current valid OCR */
#define VDD_165_195 (1 << 7) /* VDD voltage 1.65 - 1.95 */ #define VDD_165_195 (1 << 7) /* VDD voltage 1.65 - 1.95 */
#define VDD_20_21 (1 << 8) /* VDD voltage 2.0 ~ 2.1 */ #define VDD_20_21 (1 << 8) /* VDD voltage 2.0 ~ 2.1 */
#define VDD_21_22 (1 << 9) /* VDD voltage 2.1 ~ 2.2 */ #define VDD_21_22 (1 << 9) /* VDD voltage 2.1 ~ 2.2 */
#define VDD_22_23 (1 << 10) /* VDD voltage 2.2 ~ 2.3 */ #define VDD_22_23 (1 << 10) /* VDD voltage 2.2 ~ 2.3 */
#define VDD_23_24 (1 << 11) /* VDD voltage 2.3 ~ 2.4 */ #define VDD_23_24 (1 << 11) /* VDD voltage 2.3 ~ 2.4 */
#define VDD_24_25 (1 << 12) /* VDD voltage 2.4 ~ 2.5 */ #define VDD_24_25 (1 << 12) /* VDD voltage 2.4 ~ 2.5 */
#define VDD_25_26 (1 << 13) /* VDD voltage 2.5 ~ 2.6 */ #define VDD_25_26 (1 << 13) /* VDD voltage 2.5 ~ 2.6 */
#define VDD_26_27 (1 << 14) /* VDD voltage 2.6 ~ 2.7 */ #define VDD_26_27 (1 << 14) /* VDD voltage 2.6 ~ 2.7 */
#define VDD_27_28 (1 << 15) /* VDD voltage 2.7 ~ 2.8 */ #define VDD_27_28 (1 << 15) /* VDD voltage 2.7 ~ 2.8 */
#define VDD_28_29 (1 << 16) /* VDD voltage 2.8 ~ 2.9 */ #define VDD_28_29 (1 << 16) /* VDD voltage 2.8 ~ 2.9 */
#define VDD_29_30 (1 << 17) /* VDD voltage 2.9 ~ 3.0 */ #define VDD_29_30 (1 << 17) /* VDD voltage 2.9 ~ 3.0 */
#define VDD_30_31 (1 << 18) /* VDD voltage 3.0 ~ 3.1 */ #define VDD_30_31 (1 << 18) /* VDD voltage 3.0 ~ 3.1 */
#define VDD_31_32 (1 << 19) /* VDD voltage 3.1 ~ 3.2 */ #define VDD_31_32 (1 << 19) /* VDD voltage 3.1 ~ 3.2 */
#define VDD_32_33 (1 << 20) /* VDD voltage 3.2 ~ 3.3 */ #define VDD_32_33 (1 << 20) /* VDD voltage 3.2 ~ 3.3 */
#define VDD_33_34 (1 << 21) /* VDD voltage 3.3 ~ 3.4 */ #define VDD_33_34 (1 << 21) /* VDD voltage 3.3 ~ 3.4 */
#define VDD_34_35 (1 << 22) /* VDD voltage 3.4 ~ 3.5 */ #define VDD_34_35 (1 << 22) /* VDD voltage 3.4 ~ 3.5 */
#define VDD_35_36 (1 << 23) /* VDD voltage 3.5 ~ 3.6 */ #define VDD_35_36 (1 << 23) /* VDD voltage 3.5 ~ 3.6 */
rt_uint32_t flags; /* define device capabilities */ rt_uint32_t flags; /* define device capabilities */
#define MMCSD_BUSWIDTH_4 (1 << 0) #define MMCSD_BUSWIDTH_4 (1 << 0)
#define MMCSD_BUSWIDTH_8 (1 << 1) #define MMCSD_BUSWIDTH_8 (1 << 1)
#define MMCSD_MUTBLKWRITE (1 << 2) #define MMCSD_MUTBLKWRITE (1 << 2)
#define MMCSD_HOST_IS_SPI (1 << 3) #define MMCSD_HOST_IS_SPI (1 << 3)
#define controller_is_spi(host) (host->flags & MMCSD_HOST_IS_SPI) #define controller_is_spi(host) (host->flags & MMCSD_HOST_IS_SPI)
#define MMCSD_SUP_SDIO_IRQ (1 << 4) /* support signal pending SDIO IRQs */ #define MMCSD_SUP_SDIO_IRQ (1 << 4) /* support signal pending SDIO IRQs */
#define MMCSD_SUP_HIGHSPEED (1 << 5) /* support high speed */ #define MMCSD_SUP_HIGHSPEED (1 << 5) /* support high speed */
rt_uint32_t max_seg_size; /* maximum size of one dma segment */ rt_uint32_t max_seg_size; /* maximum size of one dma segment */
rt_uint32_t max_dma_segs; /* maximum number of dma segments in one request */ rt_uint32_t max_dma_segs; /* maximum number of dma segments in one request */
rt_uint32_t max_blk_size; /* maximum block size */ rt_uint32_t max_blk_size; /* maximum block size */
rt_uint32_t max_blk_count; /* maximum block count */ rt_uint32_t max_blk_count; /* maximum block count */
rt_uint32_t spi_use_crc; rt_uint32_t spi_use_crc;
struct rt_mutex bus_lock; struct rt_mutex bus_lock;
struct rt_semaphore sem_ack; struct rt_semaphore sem_ack;
rt_uint32_t sdio_irq_num; rt_uint32_t sdio_irq_num;
struct rt_semaphore *sdio_irq_sem; struct rt_semaphore *sdio_irq_sem;
struct rt_thread *sdio_irq_thread; struct rt_thread *sdio_irq_thread;
void *private_data; void *private_data;
}; };
rt_inline void mmcsd_delay_ms(rt_uint32_t ms) rt_inline void mmcsd_delay_ms(rt_uint32_t ms)
{ {
if (ms < 1000 / RT_TICK_PER_SECOND) if (ms < 1000 / RT_TICK_PER_SECOND)
{ {
rt_thread_delay(1); rt_thread_delay(1);
} }
else else
{ {
rt_thread_delay(ms/(1000 / RT_TICK_PER_SECOND)); rt_thread_delay(ms/(1000 / RT_TICK_PER_SECOND));
} }
} }
#ifdef __cplusplus #ifdef __cplusplus

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