• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2019, Arm Limited. All rights reserved.
3  *
4  * SPDX-License-Identifier: BSD-3-Clause
5  */
6 
7 #ifndef DEBUGFS_H
8 #define DEBUGFS_H
9 
10 #define NAMELEN   13 /* Maximum length of a file name */
11 #define PATHLEN   41 /* Maximum length of a path */
12 #define STATLEN   41 /* Size of static part of dir format */
13 #define ROOTLEN   (2 + 4) /* Size needed to encode root string */
14 #define FILNAMLEN (2 + NAMELEN) /* Size needed to encode filename */
15 #define DIRLEN    (STATLEN + FILNAMLEN + 3*ROOTLEN) /* Size of dir entry */
16 
17 #define KSEEK_SET 0
18 #define KSEEK_CUR 1
19 #define KSEEK_END 2
20 
21 #define NELEM(tab) (sizeof(tab) / sizeof((tab)[0]))
22 
23 typedef unsigned short qid_t; /* FIXME: short type not recommended? */
24 
25 /*******************************************************************************
26  * This structure contains the necessary information to represent a 9p
27  * directory.
28  ******************************************************************************/
29 typedef struct {
30 	char		name[NAMELEN];
31 	long		length;
32 	unsigned char	mode;
33 	unsigned char	index;
34 	unsigned char	dev;
35 	qid_t		qid;
36 } dir_t;
37 
38 /* Permission definitions used as flags */
39 #define O_READ		(1 << 0)
40 #define O_WRITE		(1 << 1)
41 #define O_RDWR		(1 << 2)
42 #define O_BIND		(1 << 3)
43 #define O_DIR		(1 << 4)
44 #define O_STAT		(1 << 5)
45 
46 /* 9p interface */
47 int mount(const char *srv, const char *mnt, const char *spec);
48 int create(const char *name, int flags);
49 int open(const char *name, int flags);
50 int close(int fd);
51 int read(int fd, void *buf, int n);
52 int write(int fd, void *buf, int n);
53 int seek(int fd, long off, int whence);
54 int bind(const char *path, const char *where);
55 int stat(const char *path, dir_t *dir);
56 
57 /* DebugFS initialization */
58 void debugfs_init(void);
59 int debugfs_smc_setup(void);
60 
61 /* Debugfs version returned through SMC interface */
62 #define DEBUGFS_VERSION		(0x000000001U)
63 
64 /* Function ID for accessing the debugfs interface */
65 #define DEBUGFS_FID_VALUE	(0x30U)
66 
67 #define is_debugfs_fid(_fid)	\
68 	(((_fid) & FUNCID_NUM_MASK) == DEBUGFS_FID_VALUE)
69 
70 /* Error code for debugfs SMC interface failures */
71 #define DEBUGFS_E_INVALID_PARAMS	(-2)
72 #define DEBUGFS_E_DENIED		(-3)
73 
74 uintptr_t debugfs_smc_handler(unsigned int smc_fid,
75 			      u_register_t cmd,
76 			      u_register_t arg2,
77 			      u_register_t arg3,
78 			      u_register_t arg4,
79 			      void *cookie,
80 			      void *handle,
81 			      uintptr_t flags);
82 
83 #endif /* DEBUGFS_H */
84