diff options
author | Olivier Deprez <olivier.deprez@arm.com> | 2019-09-19 17:46:46 +0200 |
---|---|---|
committer | Olivier Deprez <olivier.deprez@arm.com> | 2019-12-17 11:03:23 +0100 |
commit | 0ca3913dd898ec0822d4984f8fd6eb86131f1088 (patch) | |
tree | 90fbd0ccf8380581056c888fcdccfcc6e1bb3926 /include | |
parent | fcccd358e4cd6199c797ad127c77c47ec1ad5983 (diff) | |
download | platform_external_arm-trusted-firmware-0ca3913dd898ec0822d4984f8fd6eb86131f1088.tar.gz platform_external_arm-trusted-firmware-0ca3913dd898ec0822d4984f8fd6eb86131f1088.tar.bz2 platform_external_arm-trusted-firmware-0ca3913dd898ec0822d4984f8fd6eb86131f1088.zip |
debugfs: add 9p device interface
The 9p interface provides abstraction layers allowing the software
that uses devices to be independent from the hardware.
This patch provides a file system abstraction to link drivers to their
devices and propose a common interface to expose driver operations to
higher layers. This file system can be used to access and configure a
device by doing read/write operations.
Signed-off-by: Ambroise Vincent <ambroise.vincent@arm.com>
Signed-off-by: Olivier Deprez <olivier.deprez@arm.com>
Change-Id: Ia9662393baf489855dc0c8f389fe4a0afbc9c255
Diffstat (limited to 'include')
-rw-r--r-- | include/lib/debugfs.h | 60 |
1 files changed, 60 insertions, 0 deletions
diff --git a/include/lib/debugfs.h b/include/lib/debugfs.h new file mode 100644 index 000000000..b7e33303c --- /dev/null +++ b/include/lib/debugfs.h @@ -0,0 +1,60 @@ +/* + * Copyright (c) 2019, Arm Limited. All rights reserved. + * + * SPDX-License-Identifier: BSD-3-Clause + */ + +#ifndef DEBUGFS_H +#define DEBUGFS_H + +#define NAMELEN 13 /* Maximum length of a file name */ +#define PATHLEN 41 /* Maximum length of a path */ +#define STATLEN 41 /* Size of static part of dir format */ +#define ROOTLEN (2 + 4) /* Size needed to encode root string */ +#define FILNAMLEN (2 + NAMELEN) /* Size needed to encode filename */ +#define DIRLEN (STATLEN + FILNAMLEN + 3*ROOTLEN) /* Size of dir entry */ + +#define KSEEK_SET 0 +#define KSEEK_CUR 1 +#define KSEEK_END 2 + +#define NELEM(tab) (sizeof(tab) / sizeof((tab)[0])) + +typedef unsigned short qid_t; /* FIXME: short type not recommended? */ + +/******************************************************************************* + * This structure contains the necessary information to represent a 9p + * directory. + ******************************************************************************/ +typedef struct { + char name[NAMELEN]; + long length; + unsigned char mode; + unsigned char index; + unsigned char dev; + qid_t qid; +} dir_t; + +/* Permission definitions used as flags */ +#define O_READ (1 << 0) +#define O_WRITE (1 << 1) +#define O_RDWR (1 << 2) +#define O_BIND (1 << 3) +#define O_DIR (1 << 4) +#define O_STAT (1 << 5) + +/* 9p interface */ +int mount(const char *srv, const char *mnt, const char *spec); +int create(const char *name, int flags); +int open(const char *name, int flags); +int close(int fd); +int read(int fd, void *buf, int n); +int write(int fd, void *buf, int n); +int seek(int fd, long off, int whence); +int bind(const char *path, const char *where); +int stat(const char *path, dir_t *dir); + +/* DebugFS initialization */ +void debugfs_init(void); + +#endif /* DEBUGFS_H */ |