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