| 1 |
/* SPDX-License-Identifier: GPL-2.0 */ |
| 2 |
#ifndef BOOT_BOOT_H |
| 3 |
#define BOOT_BOOT_H |
| 4 |
|
| 5 |
#include <linux/types.h> |
| 6 |
|
| 7 |
#define IPL_START 0x200 |
| 8 |
|
| 9 |
#ifndef __ASSEMBLER__ |
| 10 |
|
| 11 |
#include <linux/printk.h> |
| 12 |
#include <asm/physmem_info.h> |
| 13 |
#include <asm/stacktrace.h> |
| 14 |
|
| 15 |
struct vmlinux_info { |
| 16 |
unsigned long entry; |
| 17 |
unsigned long image_size; /* does not include .bss */ |
| 18 |
unsigned long bss_size; /* uncompressed image .bss size */ |
| 19 |
unsigned long bootdata_off; |
| 20 |
unsigned long bootdata_size; |
| 21 |
unsigned long bootdata_preserved_off; |
| 22 |
unsigned long bootdata_preserved_size; |
| 23 |
unsigned long got_start; |
| 24 |
unsigned long got_end; |
| 25 |
unsigned long amode31_size; |
| 26 |
unsigned long init_mm_off; |
| 27 |
unsigned long swapper_pg_dir_off; |
| 28 |
unsigned long invalid_pg_dir_off; |
| 29 |
unsigned long alt_instructions; |
| 30 |
unsigned long alt_instructions_end; |
| 31 |
#ifdef CONFIG_STACKPROTECTOR |
| 32 |
unsigned long stack_prot_start; |
| 33 |
unsigned long stack_prot_end; |
| 34 |
#endif |
| 35 |
#ifdef CONFIG_KASAN |
| 36 |
unsigned long kasan_early_shadow_page_off; |
| 37 |
unsigned long kasan_early_shadow_pte_off; |
| 38 |
unsigned long kasan_early_shadow_pmd_off; |
| 39 |
unsigned long kasan_early_shadow_pud_off; |
| 40 |
unsigned long kasan_early_shadow_p4d_off; |
| 41 |
#endif |
| 42 |
}; |
| 43 |
|
| 44 |
void startup_kernel(void); |
| 45 |
unsigned long detect_max_physmem_end(void); |
| 46 |
void detect_physmem_online_ranges(unsigned long max_physmem_end); |
| 47 |
void physmem_set_usable_limit(unsigned long limit); |
| 48 |
void physmem_reserve(enum reserved_range_type type, unsigned long addr, unsigned long size); |
| 49 |
void physmem_free(enum reserved_range_type type); |
| 50 |
/* for continuous/multiple allocations per type */ |
| 51 |
unsigned long physmem_alloc_or_die(enum reserved_range_type type, unsigned long size, |
| 52 |
unsigned long align); |
| 53 |
unsigned long physmem_alloc(enum reserved_range_type type, unsigned long size, |
| 54 |
unsigned long align, bool die_on_oom); |
| 55 |
/* for single allocations, 1 per type */ |
| 56 |
unsigned long physmem_alloc_range(enum reserved_range_type type, unsigned long size, |
| 57 |
unsigned long align, unsigned long min, unsigned long max, |
| 58 |
bool die_on_oom); |
| 59 |
unsigned long get_physmem_alloc_pos(void); |
| 60 |
void dump_physmem_reserved(void); |
| 61 |
bool ipl_report_certs_intersects(unsigned long addr, unsigned long size, |
| 62 |
unsigned long *intersection_start); |
| 63 |
bool is_ipl_block_dump(void); |
| 64 |
void store_ipl_parmblock(void); |
| 65 |
int read_ipl_report(void); |
| 66 |
void save_ipl_cert_comp_list(void); |
| 67 |
void setup_boot_command_line(void); |
| 68 |
void parse_boot_command_line(void); |
| 69 |
void verify_facilities(void); |
| 70 |
void print_missing_facilities(void); |
| 71 |
void sclp_early_setup_buffer(void); |
| 72 |
void alt_debug_setup(char *str); |
| 73 |
void do_pgm_check(struct pt_regs *regs); |
| 74 |
unsigned long randomize_within_range(unsigned long size, unsigned long align, |
| 75 |
unsigned long min, unsigned long max); |
| 76 |
void setup_vmem(unsigned long kernel_start, unsigned long kernel_end, unsigned long asce_limit); |
| 77 |
int __printf(1, 2) boot_printk(const char *fmt, ...); |
| 78 |
void print_stacktrace(unsigned long sp); |
| 79 |
void error(char *m); |
| 80 |
int get_random(unsigned long limit, unsigned long *value); |
| 81 |
void boot_rb_dump(void); |
| 82 |
void __noreturn jump_to_kernel(psw_t *psw); |
| 83 |
|
| 84 |
#ifndef boot_fmt |
| 85 |
#define boot_fmt(fmt) fmt |
| 86 |
#endif |
| 87 |
|
| 88 |
#define boot_emerg(fmt, ...) boot_printk(KERN_EMERG boot_fmt(fmt), ##__VA_ARGS__) |
| 89 |
#define boot_alert(fmt, ...) boot_printk(KERN_ALERT boot_fmt(fmt), ##__VA_ARGS__) |
| 90 |
#define boot_crit(fmt, ...) boot_printk(KERN_CRIT boot_fmt(fmt), ##__VA_ARGS__) |
| 91 |
#define boot_err(fmt, ...) boot_printk(KERN_ERR boot_fmt(fmt), ##__VA_ARGS__) |
| 92 |
#define boot_warn(fmt, ...) boot_printk(KERN_WARNING boot_fmt(fmt), ##__VA_ARGS__) |
| 93 |
#define boot_notice(fmt, ...) boot_printk(KERN_NOTICE boot_fmt(fmt), ##__VA_ARGS__) |
| 94 |
#define boot_info(fmt, ...) boot_printk(KERN_INFO boot_fmt(fmt), ##__VA_ARGS__) |
| 95 |
#define boot_debug(fmt, ...) boot_printk(KERN_DEBUG boot_fmt(fmt), ##__VA_ARGS__) |
| 96 |
|
| 97 |
#define boot_panic(...) do { \ |
| 98 |
boot_emerg(__VA_ARGS__); \ |
| 99 |
print_stacktrace(current_frame_address()); \ |
| 100 |
boot_emerg(" -- System halted\n"); \ |
| 101 |
disabled_wait(); \ |
| 102 |
} while (0) |
| 103 |
|
| 104 |
extern struct machine_info machine; |
| 105 |
extern int boot_console_loglevel; |
| 106 |
extern bool boot_ignore_loglevel; |
| 107 |
|
| 108 |
/* Symbols defined by linker scripts */ |
| 109 |
extern const char kernel_version[]; |
| 110 |
extern unsigned long memory_limit; |
| 111 |
extern unsigned long vmalloc_size; |
| 112 |
extern int vmalloc_size_set; |
| 113 |
extern char __boot_data_start[], __boot_data_end[]; |
| 114 |
extern char __boot_data_preserved_start[], __boot_data_preserved_end[]; |
| 115 |
extern char __vmlinux_relocs_64_start[], __vmlinux_relocs_64_end[]; |
| 116 |
extern char _decompressor_syms_start[], _decompressor_syms_end[]; |
| 117 |
extern char _stack_start[], _stack_end[]; |
| 118 |
extern char _end[], _decompressor_end[]; |
| 119 |
extern unsigned char _compressed_start[]; |
| 120 |
extern unsigned char _compressed_end[]; |
| 121 |
extern struct vmlinux_info _vmlinux_info; |
| 122 |
|
| 123 |
#define vmlinux _vmlinux_info |
| 124 |
|
| 125 |
#define __lowcore_pa(x) ((unsigned long)(x) % sizeof(struct lowcore)) |
| 126 |
#define __abs_lowcore_pa(x) (((unsigned long)(x) - __abs_lowcore) % sizeof(struct lowcore)) |
| 127 |
#define __kernel_va(x) ((void *)((unsigned long)(x) - __kaslr_offset_phys + __kaslr_offset)) |
| 128 |
#define __kernel_pa(x) ((unsigned long)(x) - __kaslr_offset + __kaslr_offset_phys) |
| 129 |
#define __identity_va(x) ((void *)((unsigned long)(x) + __identity_base)) |
| 130 |
#define __identity_pa(x) ((unsigned long)(x) - __identity_base) |
| 131 |
|
| 132 |
static inline bool intersects(unsigned long addr0, unsigned long size0, |
| 133 |
unsigned long addr1, unsigned long size1) |
| 134 |
{ |
| 135 |
return addr0 + size0 > addr1 && addr1 + size1 > addr0; |
| 136 |
} |
| 137 |
#endif /* __ASSEMBLER__ */ |
| 138 |
#endif /* BOOT_BOOT_H */ |