debugfs.h 2.7 KB

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