|
|
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 function. Load the contents of FILE ! 73: into a fresh anonymous memory object and return the memory object port. */ ! 74: mach_port_t boot_script_read_file (const char *file); ! 75: ! 76: /* The user must define this functions to perform the corresponding ! 77: Mach task manipulations. */ ! 78: int boot_script_task_create (struct cmd *); /* task_create + task_suspend */ ! 79: int boot_script_task_resume (struct cmd *); ! 80: int boot_script_prompt_task_resume (struct cmd *); ! 81: int boot_script_insert_right (struct cmd *, mach_port_t, mach_port_t *namep); ! 82: int boot_script_insert_task_port (struct cmd *, task_t, mach_port_t *namep); ! 83: ! 84: /* The user must define this function to clean up the `task_t' ! 85: returned by boot_script_task_create. */ ! 86: void boot_script_free_task (task_t task, int aborting); ! 87: ! 88: ! 89: /* Parse the command line LINE. This causes the command line to be ! 90: converted into an internal format. Returns 0 for success, non-zero ! 91: otherwise. ! 92: ! 93: NOTE: The parser writes into the line so it must not be a string constant. ! 94: It is also the responsibility of the caller not to deallocate the line ! 95: across calls to the parser. */ ! 96: int boot_script_parse_line (void *hook, char *cmdline); ! 97: ! 98: /* Execute the command lines prevously parsed. ! 99: Returns 0 for success, non-zero otherwise. */ ! 100: int boot_script_exec (void); ! 101: ! 102: /* Create an entry in the symbol table for variable NAME, ! 103: whose type is TYPE and value is VAL. Returns 0 on success, ! 104: non-zero otherwise. */ ! 105: int boot_script_set_variable (const char *name, int type, integer_t val); ! 106: ! 107: /* Define the function NAME, which will return type RET_TYPE. */ ! 108: int boot_script_define_function (const char *name, int ret_type, ! 109: int (*func) (const struct cmd *cmd, ! 110: integer_t *val)); ! 111: ! 112: /* Returns a string describing the error ERR. */ ! 113: char *boot_script_error_string (int err); ! 114: ! 115: ! 116: #endif /* _boot_script_h */
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.