Orange Pi5 kernel

Deprecated Linux kernel 5.10.110 for OrangePi 5/5B/5+ boards

3 Commits   0 Branches   0 Tags
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   1) // SPDX-License-Identifier: GPL-2.0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   2) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   3)  * arch/alpha/boot/bootpz.c
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   4)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   5)  * Copyright (C) 1997 Jay Estabrook
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   6)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   7)  * This file is used for creating a compressed BOOTP file for the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   8)  * Linux/AXP kernel
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   9)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  10)  * based significantly on the arch/alpha/boot/main.c of Linus Torvalds
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  11)  * and the decompression code from MILO.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  12)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  13) #include <linux/kernel.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  14) #include <linux/slab.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  15) #include <linux/string.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  16) #include <generated/utsrelease.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  17) #include <linux/mm.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  18) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  19) #include <asm/console.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  20) #include <asm/hwrpb.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  21) #include <asm/io.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  22) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  23) #include <stdarg.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  24) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  25) #include "kzsize.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  26) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  27) /* FIXME FIXME FIXME */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  28) #define MALLOC_AREA_SIZE 0x200000 /* 2MB for now */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  29) /* FIXME FIXME FIXME */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  30) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  31) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  32) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  33)   WARNING NOTE
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  34) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  35)   It is very possible that turning on additional messages may cause
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  36)   kernel image corruption due to stack usage to do the printing.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  37) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  38) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  39) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  40) #undef DEBUG_CHECK_RANGE
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  41) #undef DEBUG_ADDRESSES
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  42) #undef DEBUG_LAST_STEPS
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  43) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  44) extern unsigned long switch_to_osf_pal(unsigned long nr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  45) 	struct pcb_struct * pcb_va, struct pcb_struct * pcb_pa,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  46) 	unsigned long *vptb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  47) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  48) extern int decompress_kernel(void* destination, void *source,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  49) 			     size_t ksize, size_t kzsize);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  50) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  51) extern void move_stack(unsigned long new_stack);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  52) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  53) struct hwrpb_struct *hwrpb = INIT_HWRPB;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  54) static struct pcb_struct pcb_va[1];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  55) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  56) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  57)  * Find a physical address of a virtual object..
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  58)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  59)  * This is easy using the virtual page table address.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  60)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  61) #define VPTB	((unsigned long *) 0x200000000)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  62) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  63) static inline unsigned long
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  64) find_pa(unsigned long address)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  65) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  66) 	unsigned long result;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  67) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  68) 	result = VPTB[address >> 13];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  69) 	result >>= 32;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  70) 	result <<= 13;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  71) 	result |= address & 0x1fff;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  72) 	return result;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  73) }	
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  74) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  75) int
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  76) check_range(unsigned long vstart, unsigned long vend,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  77) 	    unsigned long kstart, unsigned long kend)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  78) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  79) 	unsigned long vaddr, kaddr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  80) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  81) #ifdef DEBUG_CHECK_RANGE
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  82) 	srm_printk("check_range: V[0x%lx:0x%lx] K[0x%lx:0x%lx]\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  83) 		   vstart, vend, kstart, kend);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  84) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  85) 	/* do some range checking for detecting an overlap... */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  86) 	for (vaddr = vstart; vaddr <= vend; vaddr += PAGE_SIZE)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  87) 	{
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  88) 		kaddr = (find_pa(vaddr) | PAGE_OFFSET);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  89) 		if (kaddr >= kstart && kaddr <= kend)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  90) 		{
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  91) #ifdef DEBUG_CHECK_RANGE
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  92) 			srm_printk("OVERLAP: vaddr 0x%lx kaddr 0x%lx"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  93) 				   " [0x%lx:0x%lx]\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  94) 				   vaddr, kaddr, kstart, kend);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  95) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  96) 			return 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  97) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  98) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  99) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 100) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 101) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 102) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 103)  * This function moves into OSF/1 pal-code, and has a temporary
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 104)  * PCB for that. The kernel proper should replace this PCB with
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 105)  * the real one as soon as possible.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 106)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 107)  * The page table muckery in here depends on the fact that the boot
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 108)  * code has the L1 page table identity-map itself in the second PTE
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 109)  * in the L1 page table. Thus the L1-page is virtually addressable
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 110)  * itself (through three levels) at virtual address 0x200802000.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 111)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 112) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 113) #define L1	((unsigned long *) 0x200802000)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 114) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 115) void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 116) pal_init(void)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 117) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 118) 	unsigned long i, rev;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 119) 	struct percpu_struct * percpu;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 120) 	struct pcb_struct * pcb_pa;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 121) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 122) 	/* Create the dummy PCB.  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 123) 	pcb_va->ksp = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 124) 	pcb_va->usp = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 125) 	pcb_va->ptbr = L1[1] >> 32;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 126) 	pcb_va->asn = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 127) 	pcb_va->pcc = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 128) 	pcb_va->unique = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 129) 	pcb_va->flags = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 130) 	pcb_va->res1 = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 131) 	pcb_va->res2 = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 132) 	pcb_pa = (struct pcb_struct *)find_pa((unsigned long)pcb_va);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 133) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 134) 	/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 135) 	 * a0 = 2 (OSF)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 136) 	 * a1 = return address, but we give the asm the vaddr of the PCB
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 137) 	 * a2 = physical addr of PCB
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 138) 	 * a3 = new virtual page table pointer
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 139) 	 * a4 = KSP (but the asm sets it)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 140) 	 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 141) 	srm_printk("Switching to OSF PAL-code... ");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 142) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 143) 	i = switch_to_osf_pal(2, pcb_va, pcb_pa, VPTB);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 144) 	if (i) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 145) 		srm_printk("failed, code %ld\n", i);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 146) 		__halt();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 147) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 148) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 149) 	percpu = (struct percpu_struct *)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 150) 		(INIT_HWRPB->processor_offset + (unsigned long) INIT_HWRPB);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 151) 	rev = percpu->pal_revision = percpu->palcode_avail[2];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 152) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 153) 	srm_printk("OK (rev %lx)\n", rev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 154) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 155) 	tbia(); /* do it directly in case we are SMP */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 156) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 157) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 158) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 159)  * Start the kernel.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 160)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 161) static inline void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 162) runkernel(void)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 163) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 164) 	__asm__ __volatile__(
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 165) 		"bis %0,%0,$27\n\t"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 166) 		"jmp ($27)"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 167) 		: /* no outputs: it doesn't even return */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 168) 		: "r" (START_ADDR));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 169) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 170) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 171) /* Must record the SP (it is virtual) on entry, so we can make sure
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 172)    not to overwrite it during movement or decompression. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 173) unsigned long SP_on_entry;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 174) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 175) /* Calculate the kernel image address based on the end of the BOOTP
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 176)    bootstrapper (ie this program).
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 177) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 178) extern char _end;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 179) #define KERNEL_ORIGIN \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 180) 	((((unsigned long)&_end) + 511) & ~511)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 181) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 182) /* Round address to next higher page boundary. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 183) #define NEXT_PAGE(a)	(((a) | (PAGE_SIZE - 1)) + 1)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 184) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 185) #ifdef INITRD_IMAGE_SIZE
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 186) # define REAL_INITRD_SIZE INITRD_IMAGE_SIZE
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 187) #else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 188) # define REAL_INITRD_SIZE 0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 189) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 190) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 191) /* Defines from include/asm-alpha/system.h
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 192) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 193) 	BOOT_ADDR	Virtual address at which the consoles loads
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 194) 			the BOOTP image.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 195) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 196) 	KERNEL_START    KSEG address at which the kernel is built to run,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 197) 			which includes some initial data pages before the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 198) 			code.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 199) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 200) 	START_ADDR	KSEG address of the entry point of kernel code.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 201) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 202) 	ZERO_PGE	KSEG address of page full of zeroes, but 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 203) 			upon entry to kerne cvan be expected
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 204) 			to hold the parameter list and possible
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 205) 			INTRD information.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 206) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 207)    These are used in the local defines below.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 208) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 209)   
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 210) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 211) /* Virtual addresses for the BOOTP image. Note that this includes the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 212)    bootstrapper code as well as the compressed kernel image, and
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 213)    possibly the INITRD image.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 214) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 215)    Oh, and do NOT forget the STACK, which appears to be placed virtually
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 216)    beyond the end of the loaded image.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 217) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 218) #define V_BOOT_IMAGE_START	BOOT_ADDR
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 219) #define V_BOOT_IMAGE_END	SP_on_entry
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 220) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 221) /* Virtual addresses for just the bootstrapper part of the BOOTP image. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 222) #define V_BOOTSTRAPPER_START	BOOT_ADDR
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 223) #define V_BOOTSTRAPPER_END	KERNEL_ORIGIN
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 224) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 225) /* Virtual addresses for just the data part of the BOOTP
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 226)    image. This may also include the INITRD image, but always
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 227)    includes the STACK.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 228) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 229) #define V_DATA_START		KERNEL_ORIGIN
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 230) #define V_INITRD_START		(KERNEL_ORIGIN + KERNEL_Z_SIZE)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 231) #define V_INTRD_END		(V_INITRD_START + REAL_INITRD_SIZE)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 232) #define V_DATA_END	 	V_BOOT_IMAGE_END
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 233) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 234) /* KSEG addresses for the uncompressed kernel.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 235) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 236)    Note that the end address includes workspace for the decompression.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 237)    Note also that the DATA_START address is ZERO_PGE, to which we write
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 238)    just before jumping to the kernel image at START_ADDR.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 239)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 240) #define K_KERNEL_DATA_START	ZERO_PGE
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 241) #define K_KERNEL_IMAGE_START	START_ADDR
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 242) #define K_KERNEL_IMAGE_END	(START_ADDR + KERNEL_SIZE)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 243) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 244) /* Define to where we may have to decompress the kernel image, before
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 245)    we move it to the final position, in case of overlap. This will be
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 246)    above the final position of the kernel.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 247) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 248)    Regardless of overlap, we move the INITRD image to the end of this
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 249)    copy area, because there needs to be a buffer area after the kernel
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 250)    for "bootmem" anyway.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 251) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 252) #define K_COPY_IMAGE_START	NEXT_PAGE(K_KERNEL_IMAGE_END)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 253) /* Reserve one page below INITRD for the new stack. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 254) #define K_INITRD_START \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 255)     NEXT_PAGE(K_COPY_IMAGE_START + KERNEL_SIZE + PAGE_SIZE)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 256) #define K_COPY_IMAGE_END \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 257)     (K_INITRD_START + REAL_INITRD_SIZE + MALLOC_AREA_SIZE)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 258) #define K_COPY_IMAGE_SIZE \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 259)     NEXT_PAGE(K_COPY_IMAGE_END - K_COPY_IMAGE_START)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 260) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 261) void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 262) start_kernel(void)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 263) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 264) 	int must_move = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 265) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 266) 	/* Initialize these for the decompression-in-place situation,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 267) 	   which is the smallest amount of work and most likely to
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 268) 	   occur when using the normal START_ADDR of the kernel
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 269) 	   (currently set to 16MB, to clear all console code.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 270) 	*/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 271) 	unsigned long uncompressed_image_start = K_KERNEL_IMAGE_START;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 272) 	unsigned long uncompressed_image_end = K_KERNEL_IMAGE_END;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 273) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 274) 	unsigned long initrd_image_start = K_INITRD_START;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 275) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 276) 	/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 277) 	 * Note that this crufty stuff with static and envval
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 278) 	 * and envbuf is because:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 279) 	 *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 280) 	 * 1. Frequently, the stack is short, and we don't want to overrun;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 281) 	 * 2. Frequently the stack is where we are going to copy the kernel to;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 282) 	 * 3. A certain SRM console required the GET_ENV output to stack.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 283) 	 *    ??? A comment in the aboot sources indicates that the GET_ENV
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 284) 	 *    destination must be quadword aligned.  Might this explain the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 285) 	 *    behaviour, rather than requiring output to the stack, which
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 286) 	 *    seems rather far-fetched.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 287) 	 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 288) 	static long nbytes;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 289) 	static char envval[256] __attribute__((aligned(8)));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 290) 	register unsigned long asm_sp asm("30");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 291) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 292) 	SP_on_entry = asm_sp;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 293) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 294) 	srm_printk("Linux/Alpha BOOTPZ Loader for Linux " UTS_RELEASE "\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 295) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 296) 	/* Validity check the HWRPB. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 297) 	if (INIT_HWRPB->pagesize != 8192) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 298) 		srm_printk("Expected 8kB pages, got %ldkB\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 299) 		           INIT_HWRPB->pagesize >> 10);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 300) 		return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 301) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 302) 	if (INIT_HWRPB->vptb != (unsigned long) VPTB) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 303) 		srm_printk("Expected vptb at %p, got %p\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 304) 			   VPTB, (void *)INIT_HWRPB->vptb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 305) 		return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 306) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 307) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 308) 	/* PALcode (re)initialization. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 309) 	pal_init();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 310) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 311) 	/* Get the parameter list from the console environment variable. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 312) 	nbytes = callback_getenv(ENV_BOOTED_OSFLAGS, envval, sizeof(envval));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 313) 	if (nbytes < 0 || nbytes >= sizeof(envval)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 314) 		nbytes = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 315) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 316) 	envval[nbytes] = '\0';
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 317) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 318) #ifdef DEBUG_ADDRESSES
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 319) 	srm_printk("START_ADDR 0x%lx\n", START_ADDR);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 320) 	srm_printk("KERNEL_ORIGIN 0x%lx\n", KERNEL_ORIGIN);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 321) 	srm_printk("KERNEL_SIZE 0x%x\n", KERNEL_SIZE);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 322) 	srm_printk("KERNEL_Z_SIZE 0x%x\n", KERNEL_Z_SIZE);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 323) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 324) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 325) 	/* Since all the SRM consoles load the BOOTP image at virtual
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 326) 	 * 0x20000000, we have to ensure that the physical memory
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 327) 	 * pages occupied by that image do NOT overlap the physical
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 328) 	 * address range where the kernel wants to be run.  This
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 329) 	 * causes real problems when attempting to cdecompress the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 330) 	 * former into the latter... :-(
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 331) 	 *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 332) 	 * So, we may have to decompress/move the kernel/INITRD image
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 333) 	 * virtual-to-physical someplace else first before moving
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 334) 	 * kernel /INITRD to their final resting places... ;-}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 335) 	 *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 336) 	 * Sigh...
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 337) 	 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 338) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 339) 	/* First, check to see if the range of addresses occupied by
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 340) 	   the bootstrapper part of the BOOTP image include any of the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 341) 	   physical pages into which the kernel will be placed for
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 342) 	   execution.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 343) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 344) 	   We only need check on the final kernel image range, since we
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 345) 	   will put the INITRD someplace that we can be sure is not
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 346) 	   in conflict.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 347) 	 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 348) 	if (check_range(V_BOOTSTRAPPER_START, V_BOOTSTRAPPER_END,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 349) 			K_KERNEL_DATA_START, K_KERNEL_IMAGE_END))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 350) 	{
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 351) 		srm_printk("FATAL ERROR: overlap of bootstrapper code\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 352) 		__halt();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 353) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 354) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 355) 	/* Next, check to see if the range of addresses occupied by
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 356) 	   the compressed kernel/INITRD/stack portion of the BOOTP
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 357) 	   image include any of the physical pages into which the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 358) 	   decompressed kernel or the INITRD will be placed for
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 359) 	   execution.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 360) 	 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 361) 	if (check_range(V_DATA_START, V_DATA_END,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 362) 			K_KERNEL_IMAGE_START, K_COPY_IMAGE_END))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 363) 	{
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 364) #ifdef DEBUG_ADDRESSES
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 365) 		srm_printk("OVERLAP: cannot decompress in place\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 366) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 367) 		uncompressed_image_start = K_COPY_IMAGE_START;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 368) 		uncompressed_image_end = K_COPY_IMAGE_END;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 369) 		must_move = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 370) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 371) 		/* Finally, check to see if the range of addresses
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 372) 		   occupied by the compressed kernel/INITRD part of
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 373) 		   the BOOTP image include any of the physical pages
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 374) 		   into which that part is to be copied for
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 375) 		   decompression.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 376) 		*/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 377) 		while (check_range(V_DATA_START, V_DATA_END,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 378) 				   uncompressed_image_start,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 379) 				   uncompressed_image_end))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 380) 		{
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 381) #if 0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 382) 			uncompressed_image_start += K_COPY_IMAGE_SIZE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 383) 			uncompressed_image_end += K_COPY_IMAGE_SIZE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 384) 			initrd_image_start += K_COPY_IMAGE_SIZE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 385) #else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 386) 			/* Keep as close as possible to end of BOOTP image. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 387) 			uncompressed_image_start += PAGE_SIZE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 388) 			uncompressed_image_end += PAGE_SIZE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 389) 			initrd_image_start += PAGE_SIZE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 390) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 391) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 392) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 393) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 394) 	srm_printk("Starting to load the kernel with args '%s'\n", envval);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 395) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 396) #ifdef DEBUG_ADDRESSES
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 397) 	srm_printk("Decompressing the kernel...\n"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 398) 		   "...from 0x%lx to 0x%lx size 0x%x\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 399) 		   V_DATA_START,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 400) 		   uncompressed_image_start,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 401) 		   KERNEL_SIZE);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 402) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 403)         decompress_kernel((void *)uncompressed_image_start,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 404) 			  (void *)V_DATA_START,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 405) 			  KERNEL_SIZE, KERNEL_Z_SIZE);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 406) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 407) 	/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 408) 	 * Now, move things to their final positions, if/as required.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 409) 	 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 410) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 411) #ifdef INITRD_IMAGE_SIZE
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 412) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 413) 	/* First, we always move the INITRD image, if present. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 414) #ifdef DEBUG_ADDRESSES
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 415) 	srm_printk("Moving the INITRD image...\n"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 416) 		   " from 0x%lx to 0x%lx size 0x%x\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 417) 		   V_INITRD_START,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 418) 		   initrd_image_start,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 419) 		   INITRD_IMAGE_SIZE);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 420) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 421) 	memcpy((void *)initrd_image_start, (void *)V_INITRD_START,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 422) 	       INITRD_IMAGE_SIZE);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 423) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 424) #endif /* INITRD_IMAGE_SIZE */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 425) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 426) 	/* Next, we may have to move the uncompressed kernel to the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 427) 	   final destination.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 428) 	 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 429) 	if (must_move) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 430) #ifdef DEBUG_ADDRESSES
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 431) 		srm_printk("Moving the uncompressed kernel...\n"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 432) 			   "...from 0x%lx to 0x%lx size 0x%x\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 433) 			   uncompressed_image_start,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 434) 			   K_KERNEL_IMAGE_START,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 435) 			   (unsigned)KERNEL_SIZE);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 436) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 437) 		/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 438) 		 * Move the stack to a safe place to ensure it won't be
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 439) 		 * overwritten by kernel image.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 440) 		 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 441) 		move_stack(initrd_image_start - PAGE_SIZE);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 442) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 443) 		memcpy((void *)K_KERNEL_IMAGE_START,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 444) 		       (void *)uncompressed_image_start, KERNEL_SIZE);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 445) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 446) 	
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 447) 	/* Clear the zero page, then move the argument list in. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 448) #ifdef DEBUG_LAST_STEPS
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 449) 	srm_printk("Preparing ZERO_PGE...\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 450) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 451) 	memset((char*)ZERO_PGE, 0, PAGE_SIZE);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 452) 	strcpy((char*)ZERO_PGE, envval);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 453) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 454) #ifdef INITRD_IMAGE_SIZE
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 455) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 456) #ifdef DEBUG_LAST_STEPS
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 457) 	srm_printk("Preparing INITRD info...\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 458) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 459) 	/* Finally, set the INITRD paramenters for the kernel. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 460) 	((long *)(ZERO_PGE+256))[0] = initrd_image_start;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 461) 	((long *)(ZERO_PGE+256))[1] = INITRD_IMAGE_SIZE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 462) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 463) #endif /* INITRD_IMAGE_SIZE */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 464) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 465) #ifdef DEBUG_LAST_STEPS
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 466) 	srm_printk("Doing 'runkernel()'...\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 467) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 468) 	runkernel();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 469) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 470) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 471)  /* dummy function, should never be called. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 472) void *__kmalloc(size_t size, gfp_t flags)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 473) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 474) 	return (void *)NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 475) }