-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathsemi_loader.h
101 lines (81 loc) · 2.85 KB
/
semi_loader.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
89
90
91
92
93
94
95
96
97
98
99
100
101
/*
* Copyright (c) 2012 Linaro Limited
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
* 3. Neither the name of Linaro Limited nor the names of its
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*/
#ifndef SEMI_LOADER_H
#define SEMI_LOADER_H
#define ATAG_NONE 0x00000000
#define ATAG_CORE 0x54410001
#define ATAG_MEM 0x54410002
#define ATAG_INITRD2 0x54420005
#define ATAG_CMDLINE 0x54410009
struct atag_header {
unsigned size;
unsigned tag;
};
struct atag_core {
unsigned flags;
unsigned pagesize;
unsigned rootdev;
};
struct atag_mem {
unsigned size;
unsigned start;
};
struct atag_initrd2 {
unsigned start;
unsigned size;
};
static const char uboot_image_header_magic[] = {
0x27, 0x05, 0x19, 0x56
};
#define UBOOT_IMAGE_HEADER_SIZE 0x40
#define ZIMAGE_MAGIC_OFFSET 36
#define ZIMAGE_MAGIC 0x016f2818UL
#define PHYS_OFFSET 0x80000000
#define PHYS_SIZE 0x80000000 /* can limit on kernel cmdline if necessary */
#define ATAGS_OFFSET 0x100
#define TEXT_OFFSET 0x8000
#define INITRD_OFFSET 0xD00000 /* qemu uses the same random offset */
#define FDT_SIZE_MAX 0x10000 /* maximum size allowed for device tree blob */
#define SEMI_CMDLINE_MAX 0x1000 /* maximum semihosting command line length */
/*
* Align number <n> or pointer <p> up to the next boundary of size <size>.
* <size> must be a power of two.
*/
#define ALIGN_INT(n, size) (((n) + ((size) - 1)) & ~((size) - 1))
#define ALIGN(p, size) ((void *)ALIGN_INT((unsigned)(p), size))
struct loader_info {
unsigned kernel_size; /* nonzero indicates preloaded kernel size */
unsigned initrd_start; /* start of preloaded initrd, if any */
unsigned initrd_size;
unsigned cmdline_start; /* start of cmdline buffer */
unsigned cmdline_size;
/* The remaining fields are set by the loader: */
/* There could be a built-in FDT, but currently that it not supported */
unsigned fdt_start; /* start of device tree blob, if any */
unsigned fdt_size;
unsigned atags_start;
unsigned kernel_entry; /* kernel entry point */
};
void load_kernel(struct loader_info *info);
void __boot_kernel(unsigned entry_point,
unsigned r0, unsigned r1, unsigned r2, unsigned r3);
static void boot_kernel(struct loader_info *info,
unsigned r0, unsigned r1, unsigned r2, unsigned r3) {
__boot_kernel(info->kernel_entry, r0, r1, r2, r3);
}
#endif /* ! SEMI_LOADER_H */