blob: 1fdccb6ae7699d394439e1ed7cf4817ad54cd427 [file] [log] [blame]
Olivier Deprezcb4c5622019-09-19 17:46:46 +02001/*
Govindraj Raja79cd7a02024-03-07 15:24:19 -06002 * Copyright (c) 2019-2024, Arm Limited. All rights reserved.
Olivier Deprezcb4c5622019-09-19 17:46:46 +02003 *
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
23typedef 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 ******************************************************************************/
29typedef 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 */
47int mount(const char *srv, const char *mnt, const char *spec);
48int create(const char *name, int flags);
49int open(const char *name, int flags);
50int close(int fd);
51int read(int fd, void *buf, int n);
52int write(int fd, void *buf, int n);
53int seek(int fd, long off, int whence);
54int bind(const char *path, const char *where);
55int stat(const char *path, dir_t *dir);
56
57/* DebugFS initialization */
58void debugfs_init(void);
Ambroise Vincent9660dc12019-07-12 13:47:03 +010059int debugfs_smc_setup(void);
60
61/* Debugfs version returned through SMC interface */
62#define DEBUGFS_VERSION (0x000000001U)
63
Govindraj Raja79cd7a02024-03-07 15:24:19 -060064/* Function ID for accessing the debugfs interface from
65 * Vendor-Specific EL3 Range.
66 */
67#define DEBUGFS_FID_VALUE (0x10U)
Ambroise Vincent9660dc12019-07-12 13:47:03 +010068
Govindraj Raja56193562024-05-08 20:36:04 -050069#define is_debugfs_fid(_fid) \
70 (GET_SMC_NUM(_fid) == DEBUGFS_FID_VALUE)
Ambroise Vincent9660dc12019-07-12 13:47:03 +010071
Govindraj Raja79cd7a02024-03-07 15:24:19 -060072
73/* Function ID for accessing the debugfs interface from arm sip.
74 * This is now deprecated FID and will be removed after 2.12 release.
75 */
76#define DEBUGFS_FID_VALUE_DEPRECATED (0x30U)
77
78#define is_debugfs_fid_deprecated(_fid) \
Govindraj Raja56193562024-05-08 20:36:04 -050079 (GET_SMC_NUM(_fid) == DEBUGFS_FID_VALUE_DEPRECATED)
Govindraj Raja79cd7a02024-03-07 15:24:19 -060080
81
Ambroise Vincent9660dc12019-07-12 13:47:03 +010082/* Error code for debugfs SMC interface failures */
83#define DEBUGFS_E_INVALID_PARAMS (-2)
84#define DEBUGFS_E_DENIED (-3)
85
86uintptr_t debugfs_smc_handler(unsigned int smc_fid,
87 u_register_t cmd,
88 u_register_t arg2,
89 u_register_t arg3,
90 u_register_t arg4,
91 void *cookie,
92 void *handle,
93 uintptr_t flags);
Olivier Deprezcb4c5622019-09-19 17:46:46 +020094
95#endif /* DEBUGFS_H */