lx_emul: move arm_64 specifics, add x86 specifics

Split in between x86 and arm code. Move arm-specifics away from
generic include pathes.

Ref genodelabs/genode#4411
This commit is contained in:
Stefan Kalkowski 2022-02-08 16:12:11 +01:00 committed by Norman Feske
parent d7963be212
commit 7809b9e8ad
13 changed files with 101 additions and 9 deletions

View File

@ -24,6 +24,8 @@ void lx_emul_register_initcall(int (*initcall)(void), const char * name);
void lx_emul_start_kernel(void * dtb);
void lx_emul_setup_arch(void * dtb);
int lx_emul_init_task_function(void * dtb);
extern void * lx_emul_init_task_struct;

View File

@ -23,7 +23,25 @@ int pmd_swp_soft_dirty(pmd_t pmd);
void __init pgtable_cache_init(void);
#ifndef pgprot_decrypted
#define pgprot_decrypted(prot) (prot)
#endif
#ifndef mm_pud_folded
#define mm_pud_folded(mm) __is_defined(__PAGETABLE_PUD_FOLDED)
#endif
#ifndef mm_pmd_folded
#define mm_pmd_folded(mm) __is_defined(__PAGETABLE_PMD_FOLDED)
#endif
#ifndef pud_offset
static inline pud_t *pud_offset(p4d_t *p4d, unsigned long address)
{
return 0;
}
#define pud_offset pud_offset
#endif
pte_t pte_swp_clear_uffd_wp(pte_t pte);
pte_t pte_swp_clear_soft_dirty(pte_t pte);

View File

@ -15,7 +15,6 @@
#define _LX_KIT__ENV_H_
#include <base/env.h>
#include <platform_session/connection.h>
#include <timer_session/connection.h>
#include <lx_kit/console.h>
#include <lx_kit/device.h>

View File

@ -15,6 +15,7 @@
#define _LX_KIT__MEMORY_H_
#include <base/allocator_avl.h>
#include <base/attached_dataspace.h>
#include <base/cache.h>
#include <base/env.h>
#include <base/heap.h>

View File

@ -24,10 +24,12 @@ void * dma_alloc_attrs(struct device * dev,
{
void * addr;
#ifdef CONFIG_ARM
if (dev && dev->dma_mem) {
printk("We do not support device DMA memory yet!\n");
lx_emul_trace_and_stop(__func__);
}
#endif
addr = lx_emul_mem_alloc_aligned_uncached(size, PAGE_SIZE);
*dma_handle = lx_emul_mem_dma_addr(addr);

View File

@ -58,7 +58,9 @@ pid_t kernel_thread(int (* fn)(void *),void * arg,unsigned long flags)
.signal = {{0}}
}};
#ifndef CONFIG_X86
task->thread_info.preempt_count = 0;
#endif
lx_emul_task_create(task, "kthread", task->pid, fn, arg);
return task->pid;

View File

@ -0,0 +1,38 @@
/*
* \brief Linux Kernel initialization
* \author Stefan Kalkowski
* \date 2021-03-16
*/
/*
* Copyright (C) 2021 Genode Labs GmbH
*
* This file is distributed under the terms of the GNU General Public License
* version 2.
*/
#include <lx_emul/init.h>
#include <lx_emul/time.h>
#include <linux/clockchips.h>
#include <linux/delay.h>
#include <linux/of.h>
#include <linux/of_clk.h>
#include <linux/of_fdt.h>
void time_init(void)
{
/* arch/arm64/kernel/time.c */
lx_emul_time_init(); /* replaces timer_probe() */
tick_setup_hrtimer_broadcast();
lpj_fine = 1000000 / HZ;
}
void lx_emul_setup_arch(void *dtb)
{
/* calls from setup_arch of arch/arm64/kernel/setup.c */
early_init_dt_scan(dtb);
unflatten_device_tree();
}

View File

@ -0,0 +1,33 @@
/*
* \brief Linux Kernel initialization
* \author Stefan Kalkowski
* \date 2022-01-08
*/
/*
* Copyright (C) 2021 Genode Labs GmbH
*
* This file is distributed under the terms of the GNU General Public License
* version 2.
*/
#include <lx_emul/init.h>
#include <lx_emul/time.h>
#include <linux/delay.h>
#include <linux/sched/clock.h>
unsigned long long sched_clock(void)
{
return lx_emul_time_counter() * 1000;
}
void time_init(void)
{
lx_emul_time_init(); /* replaces timer_probe() */
lpj_fine = 1000000 / HZ;
}
void lx_emul_setup_arch(void *dtb) { }

View File

@ -36,6 +36,9 @@ extern int buses_init(void);
extern int classes_init(void);
extern int platform_bus_init(void);
/* definition from kernel/main.c implemented architecture specific */
extern void time_init(void);
enum system_states system_state;
static __initdata DECLARE_COMPLETION(kthreadd_done);
@ -92,9 +95,7 @@ int lx_emul_init_task_function(void * dtb)
* Here we do the minimum normally done start_kernel() of init/main.c
*/
/* calls from setup_arch of arch/arm64/kernel/setup.c */
early_init_dt_scan(dtb);
unflatten_device_tree();
lx_emul_setup_arch(dtb);
jump_label_init();
kmem_cache_init();
@ -110,11 +111,7 @@ int lx_emul_init_task_function(void * dtb)
softirq_init();
timekeeping_init();
/* arch/arm64/kernel/time.c */
lx_emul_time_init(); /* replaces timer_probe() */
tick_setup_hrtimer_broadcast();
lpj_fine = 1000000 / HZ;
/* arch/arm64/kernel/time.c end */
time_init();
sched_clock_init();