xref: /rk3399_ARM-atf/include/lib/debugfs.h (revision 992f091b5de3b0837c95a338a4e739f6ca2f254f)
10ca3913dSOlivier Deprez /*
20ca3913dSOlivier Deprez  * Copyright (c) 2019, Arm Limited. All rights reserved.
30ca3913dSOlivier Deprez  *
40ca3913dSOlivier Deprez  * SPDX-License-Identifier: BSD-3-Clause
50ca3913dSOlivier Deprez  */
60ca3913dSOlivier Deprez 
70ca3913dSOlivier Deprez #ifndef DEBUGFS_H
80ca3913dSOlivier Deprez #define DEBUGFS_H
90ca3913dSOlivier Deprez 
100ca3913dSOlivier Deprez #define NAMELEN   13 /* Maximum length of a file name */
110ca3913dSOlivier Deprez #define PATHLEN   41 /* Maximum length of a path */
120ca3913dSOlivier Deprez #define STATLEN   41 /* Size of static part of dir format */
130ca3913dSOlivier Deprez #define ROOTLEN   (2 + 4) /* Size needed to encode root string */
140ca3913dSOlivier Deprez #define FILNAMLEN (2 + NAMELEN) /* Size needed to encode filename */
150ca3913dSOlivier Deprez #define DIRLEN    (STATLEN + FILNAMLEN + 3*ROOTLEN) /* Size of dir entry */
160ca3913dSOlivier Deprez 
170ca3913dSOlivier Deprez #define KSEEK_SET 0
180ca3913dSOlivier Deprez #define KSEEK_CUR 1
190ca3913dSOlivier Deprez #define KSEEK_END 2
200ca3913dSOlivier Deprez 
210ca3913dSOlivier Deprez #define NELEM(tab) (sizeof(tab) / sizeof((tab)[0]))
220ca3913dSOlivier Deprez 
230ca3913dSOlivier Deprez typedef unsigned short qid_t; /* FIXME: short type not recommended? */
240ca3913dSOlivier Deprez 
250ca3913dSOlivier Deprez /*******************************************************************************
260ca3913dSOlivier Deprez  * This structure contains the necessary information to represent a 9p
270ca3913dSOlivier Deprez  * directory.
280ca3913dSOlivier Deprez  ******************************************************************************/
290ca3913dSOlivier Deprez typedef struct {
300ca3913dSOlivier Deprez 	char		name[NAMELEN];
310ca3913dSOlivier Deprez 	long		length;
320ca3913dSOlivier Deprez 	unsigned char	mode;
330ca3913dSOlivier Deprez 	unsigned char	index;
340ca3913dSOlivier Deprez 	unsigned char	dev;
350ca3913dSOlivier Deprez 	qid_t		qid;
360ca3913dSOlivier Deprez } dir_t;
370ca3913dSOlivier Deprez 
380ca3913dSOlivier Deprez /* Permission definitions used as flags */
390ca3913dSOlivier Deprez #define O_READ		(1 << 0)
400ca3913dSOlivier Deprez #define O_WRITE		(1 << 1)
410ca3913dSOlivier Deprez #define O_RDWR		(1 << 2)
420ca3913dSOlivier Deprez #define O_BIND		(1 << 3)
430ca3913dSOlivier Deprez #define O_DIR		(1 << 4)
440ca3913dSOlivier Deprez #define O_STAT		(1 << 5)
450ca3913dSOlivier Deprez 
460ca3913dSOlivier Deprez /* 9p interface */
470ca3913dSOlivier Deprez int mount(const char *srv, const char *mnt, const char *spec);
480ca3913dSOlivier Deprez int create(const char *name, int flags);
490ca3913dSOlivier Deprez int open(const char *name, int flags);
500ca3913dSOlivier Deprez int close(int fd);
510ca3913dSOlivier Deprez int read(int fd, void *buf, int n);
520ca3913dSOlivier Deprez int write(int fd, void *buf, int n);
530ca3913dSOlivier Deprez int seek(int fd, long off, int whence);
540ca3913dSOlivier Deprez int bind(const char *path, const char *where);
550ca3913dSOlivier Deprez int stat(const char *path, dir_t *dir);
560ca3913dSOlivier Deprez 
570ca3913dSOlivier Deprez /* DebugFS initialization */
580ca3913dSOlivier Deprez void debugfs_init(void);
59*992f091bSAmbroise Vincent int debugfs_smc_setup(void);
60*992f091bSAmbroise Vincent 
61*992f091bSAmbroise Vincent /* Debugfs version returned through SMC interface */
62*992f091bSAmbroise Vincent #define DEBUGFS_VERSION		(0x000000001U)
63*992f091bSAmbroise Vincent 
64*992f091bSAmbroise Vincent /* Function ID for accessing the debugfs interface */
65*992f091bSAmbroise Vincent #define DEBUGFS_FID_VALUE	(0x30U)
66*992f091bSAmbroise Vincent 
67*992f091bSAmbroise Vincent #define is_debugfs_fid(_fid)	\
68*992f091bSAmbroise Vincent 	(((_fid) & FUNCID_NUM_MASK) == DEBUGFS_FID_VALUE)
69*992f091bSAmbroise Vincent 
70*992f091bSAmbroise Vincent /* Error code for debugfs SMC interface failures */
71*992f091bSAmbroise Vincent #define DEBUGFS_E_INVALID_PARAMS	(-2)
72*992f091bSAmbroise Vincent #define DEBUGFS_E_DENIED		(-3)
73*992f091bSAmbroise Vincent 
74*992f091bSAmbroise Vincent uintptr_t debugfs_smc_handler(unsigned int smc_fid,
75*992f091bSAmbroise Vincent 			      u_register_t cmd,
76*992f091bSAmbroise Vincent 			      u_register_t arg2,
77*992f091bSAmbroise Vincent 			      u_register_t arg3,
78*992f091bSAmbroise Vincent 			      u_register_t arg4,
79*992f091bSAmbroise Vincent 			      void *cookie,
80*992f091bSAmbroise Vincent 			      void *handle,
81*992f091bSAmbroise Vincent 			      uintptr_t flags);
820ca3913dSOlivier Deprez 
830ca3913dSOlivier Deprez #endif /* DEBUGFS_H */
84