Thanks, merged to staging at 4402cbebfec6..f30d87bf34f2 (from, to]

You can see the entire diff with 'git diff' or at
https://github.com/brho/akaros/compare/4402cbebfec6...f30d87bf34f2

--------

And I have a fancy command line now:

Boot Command Line: '/kernel Giraffes Inside'

Barret


On 2015-11-02 at 19:19 "'Davide Libenzi' via Akaros"
<[email protected]> wrote:
> This CL adds support for multiboot command line, and also adds an API
> to retrieve boot options.
> Tested with qemu -append option.
> 
> https://github.com/brho/akaros/compare/master...dlibenzi:boot_cmdline
> 
> 
> The following changes since commit
> 2a9b3cdc47dbde55f9d125fde3e11832ca4c0b91:
> 
>   Avoid double declarations, integer overflow, and use branch hints
> (2015-10-30 16:02:29 -0400)
> 
> are available in the git repository at:
> 
>   [email protected]:dlibenzi/akaros boot_cmdline
> 
> for you to fetch changes up to
> 51b5249fe747f5ecd0a2d4c21da3d33d2c3a7217:
> 
>   Added support for multiboot protocol command line extraction
> (2015-11-02 19:14:32 -0800)
> 
> ----------------------------------------------------------------
> Davide Libenzi (1):
>       Added support for multiboot protocol command line extraction
> 
>  kern/include/init.h   | 11 +++++++++++
>  kern/include/string.h |  2 +-
>  kern/src/init.c       | 55
> +++++++++++++++++++++++++++++++++++++++++++++++++++
>  kern/src/strstr.c     |  4 ++--
>  4 files changed, 69 insertions(+), 3 deletions(-)
>  create mode 100644 kern/include/init.h
> 
> diff --git a/kern/include/init.h b/kern/include/init.h
> new file mode 100644
> index 0000000..ee364b5
> --- /dev/null
> +++ b/kern/include/init.h
> @@ -0,0 +1,11 @@
> +/* Copyright (c) 2015 Google Inc
> + * Davide Libenzi <[email protected]>
> + * See LICENSE for details.
> + */
> +
> +#pragma once
> +
> +const char *get_boot_option(const char *base, const char *option,
> char *param,
> + size_t max_param);
> +void _panic(const char *file, int line, const char *fmt, ...);
> +void _warn(const char *file, int line, const char *fmt, ...);
> diff --git a/kern/include/string.h b/kern/include/string.h
> index efcc890..ab5ac5f 100644
> --- a/kern/include/string.h
> +++ b/kern/include/string.h
> @@ -5,7 +5,7 @@
> 
>  int strlen(const char *s);
>  int strnlen(const char *s, size_t size);
> -char *strstr(char *s1, char *s2);
> +const char *strstr(const char *s1, const char *s2);
> 
>  /* zra : These aren't being used, and they are dangerous, so I'm
> rm'ing them
>  STRING strcpy(STRING dst, const STRING src);
> diff --git a/kern/src/init.c b/kern/src/init.c
> index ba88555..4d1c986 100644
> --- a/kern/src/init.c
> +++ b/kern/src/init.c
> @@ -46,11 +46,62 @@
>  #include <acpi.h>
>  #include <coreboot_tables.h>
> 
> +#define MAX_BOOT_CMDLINE_SIZE 4096
> +
>  int booting = 1;
>  struct sysinfo_t sysinfo;
> +static char boot_cmdline[MAX_BOOT_CMDLINE_SIZE];
> +
>  static void run_linker_funcs(void);
>  static int run_init_script(void);
> 
> +const char *get_boot_option(const char *base, const char *option,
> char *param,
> + size_t max_param)
> +{
> + const char *opt;
> +
> + if (!base)
> + base = boot_cmdline;
> + else
> + base++;
> + opt = strstr(base, option);
> + if (opt) {
> + const char *arg = opt;
> +
> + for (; *arg && (strchr("= \t", *arg) == NULL); arg++);
> + if (*arg == '=') {
> + size_t psize;
> + const char *eoa;
> +
> + arg++;
> + if (*arg == '\'') {
> + arg++;
> + for (eoa = arg; *eoa && (*eoa != '\''); eoa++);
> + } else {
> + for (eoa = arg; *eoa && (strchr(" \t", *eoa) == NULL); eoa++);
> + }
> + psize = eoa - arg;
> + psize = MIN(psize, max_param - 1);
> + memcpy(param, arg, psize);
> + param[psize] = 0;
> + } else if (max_param) {
> + *param = 0;
> + }
> + }
> +
> + return opt;
> +}
> +
> +static void extract_multiboot_cmdline(struct multiboot_info *mbi)
> +{
> + if (mbi && (mbi->flags & MULTIBOOT_INFO_CMDLINE) && mbi->cmdline) {
> + const char *cmdln = (const char *) KADDR(mbi->cmdline);
> +
> + strncpy(boot_cmdline, cmdln, sizeof(boot_cmdline));
> + boot_cmdline[sizeof(boot_cmdline) - 1] = 0;
> + }
> +}
> +
>  void kernel_init(multiboot_info_t *mboot_info)
>  {
>   extern char edata[], end[];
> @@ -62,9 +113,13 @@ void kernel_init(multiboot_info_t *mboot_info)
>   * memory, we may clobber it. */
>   multiboot_kaddr = (struct multiboot_info*)((physaddr_t)mboot_info
>                                                 + KERNBASE);
> + extract_multiboot_cmdline(multiboot_kaddr);
> +
>   cons_init();
>   print_cpuinfo();
> 
> + printk("Boot Command Line: '%s'\n", boot_cmdline);
> +
>   exception_table_init();
>   cache_init(); // Determine systems's cache properties
>   pmem_init(multiboot_kaddr);
> diff --git a/kern/src/strstr.c b/kern/src/strstr.c
> index 10fbf3a..4904469 100644
> --- a/kern/src/strstr.c
> +++ b/kern/src/strstr.c
> @@ -32,9 +32,9 @@
>   * Return pointer to first occurrence of s2 in s1,
>   * 0 if none
>   */
> -char *strstr(char *s1, char *s2)
> +const char *strstr(const char *s1, const char *s2)
>  {
> - char *p;
> + const char *p;
>   int f, n;
> 
>   f = s2[0];
> 

-- 
You received this message because you are subscribed to the Google Groups 
"Akaros" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to