blob: 7bc34bbcc0db1c77ae04c7f81394d4c8df628940 (
plain)
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
|
/**
* @file initrd.h
* Initrd image support
* An archive file (made with ar) can be linked into the final executable to
* allow files to be loaded in memory on boot. See mkinitrd.sh or the Makefile
* for more info.
*
* Copyright (C) 2018 Clyne Sullivan
*
* 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 3 of the License, 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.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
#ifndef INITRD_H_
#define INITRD_H_
#include <stdint.h>
/**
* Structure for the archive's header.
*/
typedef struct
{
char signature[8]; /**< The archive's signature */
} __attribute__ ((packed)) initrd_header;
/**
* Structure for a file entry in the archive.
*/
typedef struct
{
char name[16]; /**< The name of the file */
uint8_t unused[32]; /**< Unused information */
char size[10]; /**< The file's size in bytes (as string) */
char sig[2]; /**< A signature to start file data */
} __attribute__ ((packed)) initrd_file;
/**
* Confirms the initrd image is loaded and valid.
* @return non-zero if valid image found
*/
uint8_t initrd_validate(void);
/**
* Gets contents of the given file.
* @param name the file's name
* @return pointer to file data, null if not found
*/
char *initrd_getfile(const char *name);
/**
* Gets the size of the given file.
* @param name the file's name
* @return the file's size, in bytes
*/
uint32_t initrd_getfilesize(const char *name);
#endif // INITRD_H_
|