forked from kexecboot/kexecboot
/
cfgparser.h
88 lines (73 loc) · 2.83 KB
/
cfgparser.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
/*
* kexecboot - A kexec based bootloader
*
* Copyright (c) 2009-2011 Yuri Bushmelev <jay4mail@gmail.com>
* Copyright (c) 2009 Omegamoon <omegamoon@gmail.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, or (at your option)
* any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
*/
#ifndef _HAVE_CONFIGPARSER_H
#define _HAVE_CONFIGPARSER_H
#include "config.h"
#include "util.h"
#define MOUNTPOINT "/mnt"
#define ROOTFS "/root"
#define MMCBLK_BOOTCONF "/dev/mmcblk0p5"
#define MMCBLK_BOOTCONF_FSTYPE "vfat"
#define BOOTCONF_PATH MOUNTPOINT "/multiboot"
#define BOOTCFG_PATH MOUNTPOINT "/boot/boot.cfg"
/* define BOOT TYPE */
#define BOOT_TYPE_LINUX 0x1
#define BOOT_TYPE_KEXEC 0x2
#define BOOT_TYPE_IMAGE 0x4
enum ui_type_t { GUI, TEXTUI };
typedef struct {
char *label; /* Partition label (name) */
char *device; /* Device name */
char *kernelpath; /* Found kernel (/boot/zImage) */
char *cmdline; /* Kernel cmdline (logo.nologo debug) */
char *initrd; /* Initial ramdisk file */
char *iconpath; /* Custom partition icon path */
char *directory; /* Boot directory */
char *image; /* Partition image */
char *imagepath; /* Partition image file */
void *icondata; /* Icon data */
int is_default; /* Use section as default? */
int boottype; /* Boot type */
int priority; /* Priority of item in menu */
} kx_cfg_section;
/* Config file data structure */
struct cfgdata_t {
int timeout; /* Seconds before default item autobooting (0 - disabled) */
enum ui_type_t ui; /* UI (graphics/text) */
int debug; /* Use debugging */
unsigned int size; /* Size of sections array allocated */
unsigned int count; /* Sections count */
kx_cfg_section **list; /* List of sections */
kx_cfg_section *current; /* Latest allocated section */
/* cmdline parameters */
int angle; /* FB angle */
char *fbcon; /* fbcon tag */
char *mtdparts; /* MTD partitioning */
char *ttydev; /* Console tty device name */
};
/* Clean config file structure */
void init_cfgdata(struct cfgdata_t *cfgdata);
/* Free config file sections */
void destroy_cfgdata(struct cfgdata_t *cfgdata);
/* Set kernelpath only (may be used when no config file found) */
int cfgdata_add_kernel(struct cfgdata_t *cfgdata, char *kernelpath);
/* Parse config file into specified structure */
/* NOTE: It will not clean cfgdata before parsing, do it yourself */
int parse_cfgfile(char *cfgpath, struct cfgdata_t *cfgdata);
int parse_cmdline(struct cfgdata_t *cfgdata);
#endif /* _HAVE_CONFIGPARSER_H */