HelenOS sources
This source file includes following definitions.
- arm64_pre_main
- arm64_post_mm_init
- arm64_post_smp_init
- calibrate_delay_loop
- asm_delay_loop
- arch_get_initial_sp
- userspace
- before_task_runs_arch
- before_thread_runs_arch
- after_thread_ran_arch
- arch_reboot
- arch_construct_function
- irq_initialize_arch
- early_putuchar
#include <abi/errno.h>
#include <arch.h>
#include <arch/arch.h>
#include <arch/asm.h>
#include <arch/exception.h>
#include <arch/machine_func.h>
#include <console/console.h>
#include <interrupt.h>
#include <proc/scheduler.h>
#include <syscall/syscall.h>
#include <sysinfo/sysinfo.h>
#include <userspace.h>
static void arm64_post_mm_init(void);
static void arm64_post_smp_init(void);
arch_ops_t arm64_ops = {
.post_mm_init = arm64_post_mm_init,
.post_smp_init = arm64_post_smp_init,
};
arch_ops_t *arch_ops = &arm64_ops;
void arm64_pre_main(void *entry __attribute__((unused)), bootinfo_t *bootinfo)
{
init.cnt = min3(bootinfo->taskmap.cnt, TASKMAP_MAX_RECORDS,
CONFIG_INIT_TASKS);
size_t i;
for (i = 0; i < init.cnt; i++) {
init.tasks[i].paddr =
(uintptr_t) bootinfo->taskmap.tasks[i].addr;
init.tasks[i].size = bootinfo->taskmap.tasks[i].size;
str_cpy(init.tasks[i].name, CONFIG_TASK_NAME_BUFLEN,
bootinfo->taskmap.tasks[i].name);
}
memmap.cnt = min(bootinfo->memmap.cnt, MEMMAP_MAX_RECORDS);
for (i = 0; i < memmap.cnt; i++) {
memmap.zones[i].type = bootinfo->memmap.zones[i].type;
memmap.zones[i].start = bootinfo->memmap.zones[i].start;
memmap.zones[i].size = bootinfo->memmap.zones[i].size;
}
machine_ops_init();
}
void arm64_post_mm_init(void)
{
if (config.cpu_active != 1)
return;
machine_init();
exception_init();
interrupt_init();
zone_merge_all();
machine_output_init();
}
void arm64_post_smp_init(void)
{
const char *platform = machine_get_platform_name();
sysinfo_set_item_data("platform", NULL, (void *) platform,
str_size(platform));
machine_input_init();
}
void calibrate_delay_loop(void)
{
CPU->delay_loop_const = 1;
}
void asm_delay_loop(uint32_t usec)
{
uint64_t stop = CNTVCT_EL0_read() + usec * CNTFRQ_EL0_read() / 1000000;
while (CNTVCT_EL0_read() < stop)
;
}
uintptr_t arch_get_initial_sp(uintptr_t stack_base, uintptr_t stack_size)
{
return stack_base + stack_size;
}
void userspace(uintptr_t pc, uintptr_t sp)
{
SPSR_EL1_write((SPSR_EL1_read() & ~SPSR_MODE_MASK) |
SPSR_MODE_ARM64_EL0T);
ELR_EL1_write(pc);
SP_EL0_write(sp);
TPIDR_EL0_write(0);
asm volatile (
"mov sp, %[kstack]\n"
"mov x0, #0\n"
"mov x1, #0\n"
"mov x2, #0\n"
"mov x3, #0\n"
"mov x4, #0\n"
"mov x5, #0\n"
"mov x6, #0\n"
"mov x7, #0\n"
"mov x8, #0\n"
"mov x9, #0\n"
"mov x10, #0\n"
"mov x11, #0\n"
"mov x12, #0\n"
"mov x13, #0\n"
"mov x14, #0\n"
"mov x15, #0\n"
"mov x16, #0\n"
"mov x17, #0\n"
"mov x18, #0\n"
"mov x19, #0\n"
"mov x20, #0\n"
"mov x21, #0\n"
"mov x22, #0\n"
"mov x23, #0\n"
"mov x24, #0\n"
"mov x25, #0\n"
"mov x26, #0\n"
"mov x27, #0\n"
"mov x28, #0\n"
"mov x29, #0\n"
"mov x30, #0\n"
"eret\n"
:: [kstack] "r" (((uint64_t) (THREAD->kstack)) +
MEM_STACK_SIZE - SP_DELTA)
);
unreachable();
}
void before_task_runs_arch(void)
{
}
void before_thread_runs_arch(void)
{
}
void after_thread_ran_arch(void)
{
}
void arch_reboot(void)
{
while (true)
;
}
void *arch_construct_function(fncptr_t *fptr, void *addr, void *caller)
{
return addr;
}
void irq_initialize_arch(irq_t *irq __attribute__((unused)))
{
}
void early_putuchar(char32_t c)
{
#ifdef CONFIG_DEBUG_EARLY_PRINT
if (c == '\n')
machine_early_uart_output('\r');
machine_early_uart_output(c);
#endif
}
HelenOS homepage, sources at GitHub