10ca3913dSOlivier Deprez /* 2273b8983SGovindraj Raja * Copyright (c) 2019-2024, 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); 59992f091bSAmbroise Vincent int debugfs_smc_setup(void); 60992f091bSAmbroise Vincent 61992f091bSAmbroise Vincent /* Debugfs version returned through SMC interface */ 62992f091bSAmbroise Vincent #define DEBUGFS_VERSION (0x000000001U) 63992f091bSAmbroise Vincent 64273b8983SGovindraj Raja /* Function ID for accessing the debugfs interface from 65273b8983SGovindraj Raja * Vendor-Specific EL3 Range. 66273b8983SGovindraj Raja */ 67273b8983SGovindraj Raja #define DEBUGFS_FID_VALUE (0x10U) 68992f091bSAmbroise Vincent 69992f091bSAmbroise Vincent #define is_debugfs_fid(_fid) \ 70*62865b4eSGovindraj Raja (GET_SMC_NUM(_fid) == DEBUGFS_FID_VALUE) 71992f091bSAmbroise Vincent 72273b8983SGovindraj Raja 73273b8983SGovindraj Raja /* Function ID for accessing the debugfs interface from arm sip. 74273b8983SGovindraj Raja * This is now deprecated FID and will be removed after 2.12 release. 75273b8983SGovindraj Raja */ 76273b8983SGovindraj Raja #define DEBUGFS_FID_VALUE_DEPRECATED (0x30U) 77273b8983SGovindraj Raja 78273b8983SGovindraj Raja #define is_debugfs_fid_deprecated(_fid) \ 79*62865b4eSGovindraj Raja (GET_SMC_NUM(_fid) == DEBUGFS_FID_VALUE_DEPRECATED) 80273b8983SGovindraj Raja 81273b8983SGovindraj Raja 82992f091bSAmbroise Vincent /* Error code for debugfs SMC interface failures */ 83992f091bSAmbroise Vincent #define DEBUGFS_E_INVALID_PARAMS (-2) 84992f091bSAmbroise Vincent #define DEBUGFS_E_DENIED (-3) 85992f091bSAmbroise Vincent 86992f091bSAmbroise Vincent uintptr_t debugfs_smc_handler(unsigned int smc_fid, 87992f091bSAmbroise Vincent u_register_t cmd, 88992f091bSAmbroise Vincent u_register_t arg2, 89992f091bSAmbroise Vincent u_register_t arg3, 90992f091bSAmbroise Vincent u_register_t arg4, 91992f091bSAmbroise Vincent void *cookie, 92992f091bSAmbroise Vincent void *handle, 93992f091bSAmbroise Vincent uintptr_t flags); 940ca3913dSOlivier Deprez 950ca3913dSOlivier Deprez #endif /* DEBUGFS_H */ 96