xref: /illumos-gate/usr/src/common/ficl/emu/loader_emu.h (revision 45ede40b2394db7967e59f19288fae9b62efd4aa)
1 /*
2  * This file and its contents are supplied under the terms of the
3  * Common Development and Distribution License ("CDDL"), version 1.0.
4  * You may only use this file in accordance with the terms of version
5  * 1.0 of the CDDL.
6  *
7  * A full copy of the text of the CDDL should have accompanied this
8  * source.  A copy of the CDDL is also available via the Internet at
9  * http://www.illumos.org/license/CDDL.
10  */
11 
12 /*
13  * Copyright 2015 Toomas Soome <tsoome@me.com>
14  */
15 
16 #ifndef _LOADER_EMU_H
17 #define	_LOADER_EMU_H
18 
19 #include <sys/linker_set.h>
20 
21 /*
22  * BootFORTH emulator interface.
23  */
24 
25 #ifdef __cplusplus
26 extern "C" {
27 #endif
28 
29 /* Commands and return values; nonzero return sets command_errmsg != NULL */
30 typedef int (bootblk_cmd_t)(int argc, char *argv[]);
31 extern char *command_errmsg;
32 extern char command_errbuf[];	/* XXX blah, length */
33 #define	CMD_OK		0
34 #define	CMD_ERROR	1
35 
36 /*
37  * Support for commands
38  */
39 struct bootblk_command
40 {
41 	const char	*c_name;
42 	const char	*c_desc;
43 	bootblk_cmd_t	*c_fn;
44 };
45 
46 #define	COMMAND_SET(tag, key, desc, func)				\
47     static bootblk_cmd_t func;						\
48     static struct bootblk_command _cmd_ ## tag = { key, desc, func };	\
49     DATA_SET(Xcommand_set, _cmd_ ## tag)
50 
51 SET_DECLARE(Xcommand_set, struct bootblk_command);
52 
53 #ifdef __cplusplus
54 }
55 #endif
56 
57 #endif /* _LOADER_EMU_H */
58