summaryrefslogtreecommitdiffstats
path: root/discover/grub2/grub2.h
Commit message (Collapse)AuthorAgeFilesLines
* discover/grub2: Allow unset and invalid defaultsJeremy Kerr2014-12-111-0/+1
| | | | | | | | | | | | | | If the default environment variable is unset or invalid (i.e., references a non-existent boot option), then GRUB2 will fallback to the first boot option present. This is preventing petitboot from autobooting where no default is explicitly set, or is stale. This change adds this fallback behaviour to petitboot. Because we don't know if the first option will be a default at parse time (as no other options matched the default env var), we need to keep options in a list, and register them with the discover server once the parse is complete. Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
* discover/grub2: improve handling of word & delimiter tokensJeremy Kerr2014-12-011-0/+1
| | | | | | | | | | | | | | | | | | | | | | | Currently, the delimiter token handling is a little fragile: we try to ignore non-inter-word delimiters in the lexer with a selective set of regexes on the possible delimiter characters. This means we don't need to handle potential delimiters in every grammar rule, but there are other situations (not regex-able) where we may see delimters, and this will cause a parse error. Instead of relying on the regex behaviour, we have an 'inter_word' flag, which is set when we see the first word token, and cleared when we see an end-of-line token. We only emit TOKEN_DELIM when this flag is set. This means that we only get the delim tokens when they're required - when we're looking for word separators (becuase WORD DELIM WORD is distinct from WORD WORD - eg "linux /vmlinux" and "x$var"). We add a few new tests for the "menuentry" and "if" syntax, with different delimiter configurations. Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
* discover/grub2: Add support for for-loopsJeremy Kerr2014-01-301-0/+13
| | | | | | | | | GRUB2 syntax allows for for-loops; this change adds supoprt in the parser grammar and script execution code to implement them. In the execution code, we simply update the for-loop variable and re-execute the body statements. Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
* discover/grub2: Populate $prefix from config file locationJeremy Kerr2013-11-271-1/+3
| | | | | | | Rather than always using the default prefix, we should determine it from the location of the grub2 config file. Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
* discover/grub2: Allow URL resourcesJeremy Kerr2013-10-141-1/+1
| | | | | | Allow URL-format specifiers for GRUB2 resources. Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
* discover/grub2: Reimplement default optionsJeremy Kerr2013-09-251-0/+1
| | | | Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
* discover/grub2: Implement statement_block_executeJeremy Kerr2013-09-241-0/+2
| | | | Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
* discover/grub2: Implement 'elif'Jeremy Kerr2013-09-241-1/+2
| | | | | | | Rather than just having one conditional in an if statement, we use a list of conditionals instead. This allows us to implement elif. Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
* discover/grub2: Create 'conditional' statementsJeremy Kerr2013-09-241-6/+15
| | | | | | | | Rather than holding the condition and conditional-statements in struct grub2_statment_if, create a new conditional type that contains these. We can then use this to implement elif statements. Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
* discover/grub2: Add function supportJeremy Kerr2013-09-241-0/+10
| | | | Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
* discover/grub2: Implement 'linux' & 'initrd' commandsJeremy Kerr2013-09-241-5/+1
| | | | Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
* discover/grub2: Function infrastructure improvementsJeremy Kerr2013-09-241-12/+6
| | | | | | | | For user-defined functions, we'll need a data pointer to the function's execution callback. Add this as a void *, and change references from 'command' to 'function'. Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
* discover/grub2: Add option state in menuentry processingJeremy Kerr2013-09-241-0/+1
| | | | | | | This will allow menuentry-specific commands to populate boot option data. Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
* discover/grub2: Add a reference to the context from grub2_scriptJeremy Kerr2013-09-241-6/+8
| | | | | | We'll need the context to add boot options. Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
* discover/grub2: Hook up flex/bison parser to discover serverJeremy Kerr2013-09-241-0/+18
| | | | Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
* discover/grub2: Implement multiple-arv variable splittingJeremy Kerr2013-09-241-5/+3
| | | | | | | If we expand a variable containing word-delimiter chars, we need to create new argv items. Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
* discover/grub2: Add initial command executionJeremy Kerr2013-09-241-0/+26
| | | | | | .. with a simple 'set' command to update the environment Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
* discover/grub2: Add menuentry executionJeremy Kerr2013-09-241-0/+2
| | | | Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
* discover/grub2: Fix word appendJeremy Kerr2013-09-241-0/+1
| | | | | | | | The parser was setting word->next on the top-level word, resulting in word chains of a maximum length of 2. Instead, use a last pointer to always append to the last word. Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
* discover/grub2: Handle var tokens in lexerJeremy Kerr2013-09-241-7/+16
| | | | | | | Rather than post-processing to expand variables, use the lexer to identify variable tokens as a type of grub2_word. Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
* discover/grub2: Add initial execution codeJeremy Kerr2013-09-241-1/+9
| | | | Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
* discover/grub2: Add var expansion codeJeremy Kerr2013-09-241-0/+3
| | | | | | Still todo: splitting. Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
* discover/grub2: Add initial script infrastructureJeremy Kerr2013-09-241-1/+9
| | | | | | | Now that we can parse scripts, we want some infrastructure for execution. Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
* discover/grub2: Use subclass-style structs for ASTJeremy Kerr2013-09-241-20/+18
| | | | | | | Use embedded 'struct grub2_statement' data to create a subclass-style syntax tree of statements. Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
* discover/grub2: Implement statement blocksJeremy Kerr2013-09-241-0/+9
| | | | Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
* discover/grub2: Add structures & API for parserJeremy Kerr2013-09-241-1/+76
| | | | Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
* discover/grub2: Initial grub2 lexerJeremy Kerr2013-09-241-0/+10
Add a simple flex lexer to tokenise our grub2 config files. Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
OpenPOWER on IntegriCloud