summaryrefslogtreecommitdiff
path: root/arch/arm/machine/boot.h
blob: e7c3c8f2ca1f521aa3b5ab21a54d5a4aa426192b (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
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
102
103
104
105
106
107
/*
 * Copyright (c) 2017 Richard Braun.
 *
 * 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 <http://www.gnu.org/licenses/>.
 */

#ifndef _ARM_BOOT_H
#define _ARM_BOOT_H

#include <kern/macros.h>
#include <machine/page.h>
#include <machine/pmap.h>
#include <machine/pmem.h>

/*
 * Size of the stack used when booting a processor.
 */
#define BOOT_STACK_SIZE PAGE_SIZE

#define BOOT_LOAD_SECTION .boot.load
#define BOOT_TEXT_SECTION .boot.text
#define BOOT_DATA_SECTION .boot.data

#define BOOT_KERNEL_OFFSET  (PMAP_START_KERNEL_ADDRESS - PMEM_RAM_START)

#define BOOT_RTOL(addr) ((addr) - PMEM_RAM_START)
#define BOOT_VTOL(addr) ((addr) - PMAP_START_KERNEL_ADDRESS)

#define BOOT_VTOP(addr) ((addr) - BOOT_KERNEL_OFFSET)
#define BOOT_PTOV(addr) ((addr) + BOOT_KERNEL_OFFSET)

#define BOOT_MEM_BLOCK_BITS     10
#define BOOT_MEM_NR_FREE_LISTS  5

#ifndef __ASSEMBLER__

#include <stdnoreturn.h>

#include <kern/init.h>

/*
 * Macros for boot code and data, respectively.
 *
 * Note that all boot data end up in the same section, which means they
 * can't have conflicting qualifiers. As a result, boot data may not be
 * declared const.
 */
#define __boot     __section(QUOTE(BOOT_TEXT_SECTION))
#define __bootdata __section(QUOTE(BOOT_DATA_SECTION)) __attribute__((used))

/*
 * Boundaries of the .boot section.
 */
extern char _boot;
extern char _boot_end;

noreturn void boot_panic(const char *s);

/*
 * Log kernel version and other architecture-specific information.
 */
void boot_log_info(void);

/*
 * This init operation provides :
 *  - all console devices are bootstrapped
 */
INIT_OP_DECLARE(boot_bootstrap_console);

/*
 * This init operation provides :
 *  - all console devices are fully initialized
 */
INIT_OP_DECLARE(boot_setup_console);

/*
 * This init operation provides :
 *  - physical memory has been loaded to the VM system
 */
INIT_OP_DECLARE(boot_load_vm_page_zones);

/*
 * This init operation provides :
 *  - all interrupt controllers have been registered
 */
INIT_OP_DECLARE(boot_setup_intr);

/*
 * This init operation provides :
 *  - all shutdown operations have been registered
 */
INIT_OP_DECLARE(boot_setup_shutdown);

#endif /* __ASSEMBLER__ */

#endif /* _ARM_BOOT_H */