mirror of
https://github.com/opnsense/src.git
synced 2026-06-08 16:22:46 -04:00
To avoid problems, invalidate the data cache and disable the MMU once
we're done uncompressing the kernel.
This commit is contained in:
parent
44d6e87b07
commit
b64b87c8bd
2 changed files with 38 additions and 4 deletions
|
|
@ -31,6 +31,7 @@ __FBSDID("$FreeBSD$");
|
|||
#include <sys/inflate.h>
|
||||
#include <machine/elf.h>
|
||||
#include <machine/pte.h>
|
||||
#include <machine/cpufunc.h>
|
||||
|
||||
#include <stdlib.h>
|
||||
|
||||
|
|
@ -44,6 +45,24 @@ void __start(void);
|
|||
|
||||
#define GZ_HEAD 0xa
|
||||
|
||||
#ifdef CPU_ARM7TDMI
|
||||
#define cpu_idcache_wbinv_all arm7tdmi_cache_flushID
|
||||
#elif defined(CPU_ARM8)
|
||||
#define cpu_idcache_wbinv_all arm8_cache_purgeID
|
||||
#elif defined(CPU_ARM9)
|
||||
#define cpu_idcache_wbinv_all arm9_dcache_wbinv_all
|
||||
#elif defined(CPU_ARM10)
|
||||
#define cpu_idcache_wbinv_all arm10_idcache_wbinv_all
|
||||
#elif defined(CPU_SA110) || defined(CPU_SA1110) || defined(CPU_SA1100) || \
|
||||
defined(CPU_IXP12X0)
|
||||
#define cpu_idcache_wbinv_all sa1_cache_purgeID
|
||||
#elif defined(CPU_XSCALE_80200) || defined(CPU_XSCALE_80321) || \
|
||||
defined(CPU_XSCALE_PXA2X0) || defined(CPU_XSCALE_IXP425)
|
||||
#define cpu_idcache_wbinv_all xscale_cache_purgeID
|
||||
#endif
|
||||
int arm_pdcache_line_size = 32;
|
||||
int block_userspace_access = 0;
|
||||
|
||||
static __inline void *
|
||||
memcpy(void *dst, const void *src, int len)
|
||||
{
|
||||
|
|
@ -160,7 +179,7 @@ putstr(char *dummy)
|
|||
static int
|
||||
input(void *dummy)
|
||||
{
|
||||
if ((size_t)(i_input - orig_input) >= KERNSIZE) {
|
||||
if ((size_t)(i_input - orig_input) >= KERNCOMPSIZE) {
|
||||
return (GZ_EOF);
|
||||
}
|
||||
return *i_input++;
|
||||
|
|
@ -383,7 +402,7 @@ void
|
|||
__start(void)
|
||||
{
|
||||
void *curaddr;
|
||||
void *dst;
|
||||
void *dst, *altdst;
|
||||
char *kernel = (char *)&kernel_start;
|
||||
|
||||
__asm __volatile("mov %0, pc" :
|
||||
|
|
@ -393,11 +412,22 @@ __start(void)
|
|||
if (*kernel == 0x1f && kernel[1] == 0x8b) {
|
||||
int pt_addr = (((int)&_end + KERNSIZE + 0x100) &
|
||||
~(L1_TABLE_SIZE - 1)) + L1_TABLE_SIZE;
|
||||
|
||||
setup_pagetables(pt_addr, (vm_paddr_t)curaddr,
|
||||
(vm_paddr_t)curaddr + 0x10000000);
|
||||
/* Gzipped kernel */
|
||||
dst = inflate_kernel(kernel, &_end);
|
||||
kernel = (char *)&_end;
|
||||
altdst = 4 + load_kernel((unsigned int)kernel,
|
||||
(unsigned int)curaddr,
|
||||
(unsigned int)&func_end , 0);
|
||||
if (altdst > dst)
|
||||
dst = altdst;
|
||||
cpu_idcache_wbinv_all();
|
||||
__asm __volatile("mrc p15, 0, %0, c1, c0, 0\n"
|
||||
"bic %0, %0, #1\n" /* MMU_ENABLE */
|
||||
"mcr p15, 0, %0, c1, c0, 0\n"
|
||||
: "=r" (pt_addr));
|
||||
} else
|
||||
#endif
|
||||
dst = 4 + load_kernel((unsigned int)&kernel_start,
|
||||
|
|
|
|||
|
|
@ -59,6 +59,10 @@ SYSTEM_LD_TAIL +=;sed s/" + SIZEOF_HEADERS"// ldscript.$M\
|
|||
${KERNEL_KO}.bin; \
|
||||
rm ${FULLKERNEL}.noheader
|
||||
|
||||
FILES_CPU_FUNC = $S/$M/$M/cpufunc_asm_arm7tdmi.S \
|
||||
$S/$M/$M/cpufunc_asm_arm8.S $S/$M/$M/cpufunc_asm_arm9.S \
|
||||
$S/$M/$M/cpufunc_asm_sa1.S $S/$M/$M/cpufunc_asm_arm10.S \
|
||||
$S/$M/$M/cpufunc_asm_xscale.S
|
||||
trampoline: ${KERNEL_KO}.tramp
|
||||
${KERNEL_KO}.tramp: ${KERNEL_KO}
|
||||
echo "#define KERNNAME \"${KERNEL_KO}.tmp\"" >opt_kernname.h
|
||||
|
|
@ -85,10 +89,10 @@ ${KERNEL_KO}.tramp: ${KERNEL_KO}
|
|||
${CC} -O2 -DKZIP -I. -c $S/kern/inflate.c -o inflate-tramp.o
|
||||
${CC} -O -nostdlib -I. -Xlinker -T -Xlinker ldscript.$M.tramp \
|
||||
-DKZIP $S/$M/$M/elf_trampoline.c inflate-tramp.o $S/$M/$M/inckern.S \
|
||||
-o ${KERNEL_KO}.gz.tramp
|
||||
${FILES_CPU_FUNC} -o ${KERNEL_KO}.gz.tramp
|
||||
${CC} -O -nostdlib -I. -Xlinker -T -Xlinker ldscript.$M.tramp.noheader \
|
||||
-DKZIP $S/$M/$M/elf_trampoline.c inflate-tramp.o $S/$M/$M/inckern.S \
|
||||
-o ${KERNEL_KO}.tramp.noheader
|
||||
${FILES_CPU_FUNC} -o ${KERNEL_KO}.tramp.noheader
|
||||
${OBJCOPY} -S -O binary ${KERNEL_KO}.tramp.noheader \
|
||||
${KERNEL_KO}.gz.tramp.bin
|
||||
rm ${KERNEL_KO}.tmp.gz ${KERNEL_KO}.tramp.noheader opt_kernname.h \
|
||||
|
|
|
|||
Loading…
Reference in a new issue