log: Allow runtime selection of 'debug' log level
[petitboot] / discover / grub2 / grub2.h
index 2de77a280b96ce97f2bbcefaa680ade0fc676221..e79bf41d4b655598a3019394a0c2f5ccbbac0ca3 100644 (file)
@@ -43,6 +43,7 @@ struct grub2_statement {
                STMT_TYPE_MENUENTRY,
                STMT_TYPE_IF,
                STMT_TYPE_BLOCK,
+               STMT_TYPE_CONDITIONAL,
        } type;
        int                     (*exec)(struct grub2_script *,
                                        struct grub2_statement *);
@@ -59,11 +60,16 @@ struct grub2_statement_menuentry {
        struct grub2_statements *statements;
 };
 
-struct grub2_statement_if {
+struct grub2_statement_conditional {
        struct grub2_statement  st;
        struct grub2_statement  *condition;
-       struct grub2_statements *true_case;
-       struct grub2_statements *false_case;
+       struct grub2_statements *statements;
+};
+
+struct grub2_statement_if {
+       struct grub2_statement  st;
+       struct grub2_statements *conditionals;
+       struct grub2_statements *else_case;
 };
 
 struct grub2_statement_block {
@@ -71,6 +77,18 @@ struct grub2_statement_block {
        struct grub2_statements *statements;
 };
 
+struct grub2_statement_function {
+       struct grub2_statement  st;
+       struct grub2_word       *name;
+       struct grub2_statements *body;
+};
+
+struct grub2_statement_for {
+       struct grub2_statement  st;
+       struct grub2_word       *var;
+       struct grub2_argv       *list;
+       struct grub2_statements *body;
+};
 
 struct grub2_script {
        struct grub2_statements         *statements;
@@ -78,6 +96,8 @@ struct grub2_script {
        struct list                     symtab;
        struct discover_context         *ctx;
        struct discover_boot_option     *opt;
+       const char                      *filename;
+       unsigned int                    n_options;
 };
 
 struct grub2_parser {
@@ -85,10 +105,6 @@ struct grub2_parser {
        struct grub2_script     *script;
 };
 
-struct grub2_root {
-       char *uuid;
-};
-
 /* type for builtin functions */
 typedef int (*grub2_function)(struct grub2_script *script, void *data,
                                int argc, char *argv[]);
@@ -101,14 +117,25 @@ struct grub2_statement *create_statement_simple(struct grub2_parser *parser,
 struct grub2_statement *create_statement_menuentry(struct grub2_parser *parser,
                struct grub2_argv *argv, struct grub2_statements *stmts);
 
+struct grub2_statement *create_statement_conditional(
+               struct grub2_parser *parser, struct grub2_statement *condition,
+               struct grub2_statements *statements);
+
 struct grub2_statement *create_statement_if(struct grub2_parser *parser,
-               struct grub2_statement *condition,
-               struct grub2_statements *true_case,
-               struct grub2_statements *false_case);
+               struct grub2_statement *conditional,
+               struct grub2_statements *elifs,
+               struct grub2_statements *else_case);
 
 struct grub2_statement *create_statement_block(struct grub2_parser *parser,
                struct grub2_statements *stmts);
 
+struct grub2_statement *create_statement_function(struct grub2_parser *parser,
+               struct grub2_word *name, struct grub2_statements *body);
+
+struct grub2_statement *create_statement_for(struct grub2_parser *parser,
+               struct grub2_word *var, struct grub2_argv *list,
+               struct grub2_statements *body);
+
 struct grub2_word *create_word_text(struct grub2_parser *parser,
                const char *text);
 
@@ -129,10 +156,16 @@ void script_execute(struct grub2_script *script);
 
 int statement_simple_execute(struct grub2_script *script,
                struct grub2_statement *statement);
+int statement_block_execute(struct grub2_script *script,
+               struct grub2_statement *statement);
 int statement_if_execute(struct grub2_script *script,
                struct grub2_statement *statement);
 int statement_menuentry_execute(struct grub2_script *script,
                struct grub2_statement *statement);
+int statement_function_execute(struct grub2_script *script,
+               struct grub2_statement *statement);
+int statement_for_execute(struct grub2_script *script,
+               struct grub2_statement *statement);
 
 struct grub2_script *create_script(struct grub2_parser *parser,
                struct discover_context *ctx);
@@ -148,15 +181,16 @@ void script_register_function(struct grub2_script *script,
 void register_builtins(struct grub2_script *script);
 
 /* resources */
-struct resource *create_grub2_resource(void *ctx,
+struct resource *create_grub2_resource(struct discover_boot_option *opt,
                struct discover_device *orig_device,
-               struct grub2_root *root, const char *path);
+               const char *root, const char *path);
 
 bool resolve_grub2_resource(struct device_handler *handler,
                struct resource *res);
 
 /* external parser api */
 struct grub2_parser *grub2_parser_create(struct discover_context *ctx);
-void grub2_parser_parse(struct grub2_parser *parser, char *buf, int len);
+void grub2_parser_parse(struct grub2_parser *parser, const char *filename,
+               char *buf, int len);
 #endif /* GRUB2_H */