Olivier Deprez | cb4c562 | 2019-09-19 17:46:46 +0200 | [diff] [blame] | 1 | /* |
Govindraj Raja | 79cd7a0 | 2024-03-07 15:24:19 -0600 | [diff] [blame] | 2 | * Copyright (c) 2019-2024, Arm Limited. All rights reserved. |
Olivier Deprez | cb4c562 | 2019-09-19 17:46:46 +0200 | [diff] [blame] | 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); |
Ambroise Vincent | 9660dc1 | 2019-07-12 13:47:03 +0100 | [diff] [blame] | 59 | int debugfs_smc_setup(void); |
| 60 | |
| 61 | /* Debugfs version returned through SMC interface */ |
| 62 | #define DEBUGFS_VERSION (0x000000001U) |
| 63 | |
Govindraj Raja | 79cd7a0 | 2024-03-07 15:24:19 -0600 | [diff] [blame] | 64 | /* Function ID for accessing the debugfs interface from |
| 65 | * Vendor-Specific EL3 Range. |
| 66 | */ |
| 67 | #define DEBUGFS_FID_VALUE (0x10U) |
Ambroise Vincent | 9660dc1 | 2019-07-12 13:47:03 +0100 | [diff] [blame] | 68 | |
Govindraj Raja | 5619356 | 2024-05-08 20:36:04 -0500 | [diff] [blame] | 69 | #define is_debugfs_fid(_fid) \ |
| 70 | (GET_SMC_NUM(_fid) == DEBUGFS_FID_VALUE) |
Ambroise Vincent | 9660dc1 | 2019-07-12 13:47:03 +0100 | [diff] [blame] | 71 | |
Govindraj Raja | 79cd7a0 | 2024-03-07 15:24:19 -0600 | [diff] [blame] | 72 | |
| 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 Raja | 5619356 | 2024-05-08 20:36:04 -0500 | [diff] [blame] | 79 | (GET_SMC_NUM(_fid) == DEBUGFS_FID_VALUE_DEPRECATED) |
Govindraj Raja | 79cd7a0 | 2024-03-07 15:24:19 -0600 | [diff] [blame] | 80 | |
| 81 | |
Ambroise Vincent | 9660dc1 | 2019-07-12 13:47:03 +0100 | [diff] [blame] | 82 | /* Error code for debugfs SMC interface failures */ |
| 83 | #define DEBUGFS_E_INVALID_PARAMS (-2) |
| 84 | #define DEBUGFS_E_DENIED (-3) |
| 85 | |
| 86 | uintptr_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 Deprez | cb4c562 | 2019-09-19 17:46:46 +0200 | [diff] [blame] | 94 | |
| 95 | #endif /* DEBUGFS_H */ |