Annotation of Gnu-Mach/kern/boot_script.h, revision 1.1.1.3

1.1       root        1: /* Definitions for boot script parser for Mach.  */
                      2: 
                      3: #ifndef _boot_script_h
                      4: #define _boot_script_h
                      5: 
                      6: /* Written by Shantanu Goel ([email protected]).  */
                      7: 
                      8: /* Error codes returned by boot_script_parse_line()
                      9:    and boot_script_exec_cmd().  */
                     10: #define BOOT_SCRIPT_NOMEM              1
                     11: #define BOOT_SCRIPT_SYNTAX_ERROR       2
                     12: #define BOOT_SCRIPT_INVALID_ASG                3
                     13: #define BOOT_SCRIPT_MACH_ERROR         4
                     14: #define BOOT_SCRIPT_UNDEF_SYM          5
                     15: #define BOOT_SCRIPT_EXEC_ERROR         6
                     16: #define BOOT_SCRIPT_INVALID_SYM                7
                     17: #define BOOT_SCRIPT_BAD_TYPE           8
                     18: 
                     19: /* Legal values for argument `type' to function
                     20:    boot_script_set_variable and boot_script_define_function.  */
                     21: #define VAL_NONE       0       /* none -- function runs at exec time */
                     22: #define VAL_STR                1       /* string */
                     23: #define VAL_PORT       2       /* port */
                     24: #define VAL_TASK       3       /* task port */
                     25: 
                     26: /* This structure describes a command.  */
                     27: struct cmd
                     28: {
                     29:   /* Cookie passed in to boot_script_parse_line.  */
                     30:   void *hook;
                     31: 
                     32:   /* Path of executable.  */
                     33:   char *path;
                     34: 
                     35:   /* Task port.  */
                     36:   task_t task;
                     37: 
                     38:   /* Argument list.  */
                     39:   struct arg **args;
                     40: 
                     41:   /* Amount allocated for `args'.  */
                     42:   int args_alloc;
                     43: 
                     44:   /* Next available slot in `args'.  */
                     45:   int args_index;
                     46: 
                     47:   /* List of functions that want to be run on command execution.  */
                     48:   struct sym **exec_funcs;
                     49: 
                     50:   /* Amount allocated for `exec_funcs'.  */
                     51:   int exec_funcs_alloc;
                     52: 
                     53:   /* Next available slot in `exec_funcs'.  */
                     54:   int exec_funcs_index;
                     55: };
                     56: 
                     57: 
                     58: /* The user must define these functions, we work like malloc and free.  */
                     59: void *boot_script_malloc (unsigned int);
                     60: void boot_script_free (void *, unsigned int);
                     61: 
                     62: /* The user must define this function.  Load the image of the
                     63:    executable specified by PATH in TASK.  Create a thread
                     64:    in TASK and point it at the executable's entry point.  Initialize
                     65:    TASK's stack with argument vector ARGV of length ARGC whose
                     66:    strings are STRINGS.  STRINGS has length STRINGLEN.
                     67:    Return 0 for success, non-zero otherwise.  */
                     68: int boot_script_exec_cmd (void *hook,
                     69:                          task_t task, char *path, int argc,
                     70:                          char **argv, char *strings, int stringlen);
                     71: 
                     72: /* The user must define this functions to perform the corresponding
                     73:    Mach task manipulations.  */
                     74: int boot_script_task_create (struct cmd *); /* task_create + task_suspend */
                     75: int boot_script_task_resume (struct cmd *);
                     76: int boot_script_prompt_task_resume (struct cmd *);
                     77: int boot_script_insert_right (struct cmd *, mach_port_t, mach_port_t *namep);
                     78: int boot_script_insert_task_port (struct cmd *, task_t, mach_port_t *namep);
                     79: 
                     80: /* The user must define this function to clean up the `task_t'
                     81:    returned by boot_script_task_create.  */
                     82: void boot_script_free_task (task_t task, int aborting);
                     83: 
                     84: 
                     85: /* Parse the command line LINE.  This causes the command line to be
                     86:    converted into an internal format.  Returns 0 for success, non-zero
                     87:    otherwise.
                     88: 
                     89:    NOTE: The parser writes into the line so it must not be a string constant.
                     90:    It is also the responsibility of the caller not to deallocate the line
                     91:    across calls to the parser.  */
                     92: int boot_script_parse_line (void *hook, char *cmdline);
                     93: 
                     94: /* Execute the command lines prevously parsed.
                     95:    Returns 0 for success, non-zero otherwise.  */
                     96: int boot_script_exec (void);
                     97: 
                     98: /* Create an entry in the symbol table for variable NAME,
                     99:    whose type is TYPE and value is VAL.  Returns 0 on success,
                    100:    non-zero otherwise.  */
1.1.1.2   root      101: int boot_script_set_variable (const char *name, int type, long val);
1.1       root      102: 
                    103: /* Define the function NAME, which will return type RET_TYPE.  */
                    104: int boot_script_define_function (const char *name, int ret_type,
                    105:                                 int (*func) (const struct cmd *cmd, int *val));
                    106: 
                    107: /* Returns a string describing the error ERR.  */
                    108: char *boot_script_error_string (int err);
                    109: 
                    110: 
                    111: #endif /* _boot_script_h */

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.