1// kernel_emu.h
2
3#include <stdarg.h>
4
5#include <OS.h>
6
7#include "FSCapabilities.h"
8
9
10struct selectsync;
11struct file_io_vec;
12
13namespace UserlandFS {
14namespace KernelEmu {
15
16int new_path(const char *path, char **copy);
17void free_path(char *p);
18
19status_t notify_listener(int32 operation, uint32 details, dev_t device,
20	ino_t oldDirectory, ino_t directory, ino_t node,
21	const char* oldName, const char* name);
22status_t notify_select_event(selectsync *sync, uint8 event,
23	bool unspecifiedEvent);
24status_t notify_query(port_id port, int32 token, int32 operation,
25	dev_t device, ino_t directory, const char* name, ino_t node);
26
27status_t get_vnode(dev_t nsid, ino_t vnid, void** node);
28status_t put_vnode(dev_t nsid, ino_t vnid);
29status_t acquire_vnode(dev_t nsid, ino_t vnodeID);
30status_t new_vnode(dev_t nsid, ino_t vnid, void* data,
31	const FSVNodeCapabilities& capabilities);
32status_t publish_vnode(dev_t nsid, ino_t vnid, void* data, int type,
33	uint32 flags, const FSVNodeCapabilities& capabilities);
34status_t publish_vnode(dev_t nsid, ino_t vnid, void* data,
35	const FSVNodeCapabilities& capabilities);
36status_t remove_vnode(dev_t nsid, ino_t vnid);
37status_t unremove_vnode(dev_t nsid, ino_t vnid);
38status_t get_vnode_removed(dev_t nsid, ino_t vnid, bool* removed);
39
40status_t file_cache_create(dev_t mountID, ino_t vnodeID, off_t size);
41status_t file_cache_delete(dev_t mountID, ino_t vnodeID);
42status_t file_cache_set_enabled(dev_t mountID, ino_t vnodeID, bool enabled);
43status_t file_cache_set_size(dev_t mountID, ino_t vnodeID, off_t size);
44status_t file_cache_sync(dev_t mountID, ino_t vnodeID);
45
46status_t file_cache_read(dev_t mountID, ino_t vnodeID, void *cookie,
47	off_t offset, void *bufferBase, size_t *_size);
48status_t file_cache_write(dev_t mountID, ino_t vnodeID, void *cookie,
49	off_t offset, const void *buffer, size_t *_size);
50
51status_t do_iterative_fd_io(dev_t volumeID, int fd, int32 requestID,
52	void* cookie, const file_io_vec* vecs, uint32 vecCount);
53status_t read_from_io_request(dev_t volumeID, int32 requestID, void* buffer,
54	size_t size);
55status_t write_to_io_request(dev_t volumeID, int32 requestID, const void* buffer,
56	size_t size);
57status_t notify_io_request(dev_t volumeID, int32 requestID, status_t status);
58
59status_t add_node_listener(dev_t device, ino_t node, uint32 flags,
60	void* listener);
61status_t remove_node_listener(dev_t device, ino_t node, void* listener);
62
63void kernel_debugger(const char *message);
64void vpanic(const char *format, va_list args);
65void panic(const char *format, ...) __attribute__ ((format (__printf__, 1, 2)));
66
67void vdprintf(const char *format, va_list args);
68void dprintf(const char *format, ...)
69	__attribute__ ((format (__printf__, 1, 2)));
70
71void dump_block(const char *buffer, int size, const char *prefix);
72
73int add_debugger_command(char *name, int (*func)(int argc, char **argv),
74	char *help);
75int remove_debugger_command(char *name, int (*func)(int argc, char **argv));
76uint32 parse_expression(const char *string);
77
78thread_id spawn_kernel_thread(thread_entry function, const char *threadName,
79	long priority, void *arg);
80
81
82}	// namespace KernelEmu
83}	// namespace UserlandFS
84
85