blob: b7e33303cf396da5f12e0cd7ca7939cd5f6eb76d [file] [log] [blame]
Olivier Deprezcb4c5622019-09-19 17:46:46 +02001/*
2 * Copyright (c) 2019, Arm Limited. All rights reserved.
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
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);
59
60#endif /* DEBUGFS_H */