Skip to content

Commit

Permalink
elfloader: Add generic-timer driver
Browse files Browse the repository at this point in the history
This driver just sets CNTVOFF_El2 to 0 if possible.
This can only be done if the elfloader is in hyp-mode, otherwise nothing
happens.

Signed-off-by: Kent McLeod <kent@kry10.com>
  • Loading branch information
kent-mcleod committed Feb 15, 2024
1 parent db74273 commit 93a6e92
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 0 deletions.
1 change: 1 addition & 0 deletions elfloader-tool/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,7 @@ file(
src/drivers/*.c
src/drivers/smp/*.c
src/drivers/uart/*.c
src/drivers/timer/*.c
src/utils/*.c
src/arch-${KernelArch}/*.c
src/arch-${KernelArch}/*.S
Expand Down
1 change: 1 addition & 0 deletions elfloader-tool/include/drivers/common.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ enum driver_type {
DRIVER_INVALID = 0,
DRIVER_SMP,
DRIVER_UART,
DRIVER_TIMER,
DRIVER_MAX
};

Expand Down
3 changes: 3 additions & 0 deletions elfloader-tool/src/arch-arm/smp_boot.c
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,9 @@ void non_boot_main(void)
/* Initialise any platform-specific per-core state */
non_boot_init();

/* Do any driver specific non_boot core init */
initialise_devices_non_boot();

#ifndef CONFIG_ARM_HYPERVISOR_SUPPORT
if (is_hyp_mode()) {
extern void leave_hyp(void);
Expand Down
34 changes: 34 additions & 0 deletions elfloader-tool/src/drivers/timer/generic_timer.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
/*
* Copyright 2020, Data61, CSIRO (ABN 41 687 119 230)
*
* SPDX-License-Identifier: GPL-2.0-only
*/

#include <devices_gen.h>
#include <drivers/common.h>
#include <mode/arm_generic_timer.h>

#include <elfloader_common.h>


static int generic_timer_init(UNUSED struct elfloader_device *dev, UNUSED void *match_data)
{
reset_cntvoff();
return 0;
}

static const struct dtb_match_table generic_timer_matches[] = {
{ .compatible = "arm,armv7-timer" },
{ .compatible = "arm,armv8-timer" },
{ .compatible = NULL /* sentinel */ },
};

static const struct elfloader_driver generic_timer = {
.match_table = generic_timer_matches,
.type = DRIVER_TIMER,
.init = &generic_timer_init,
.init_non_boot = &generic_timer_init,
.ops = NULL,
};

ELFLOADER_DRIVER(generic_timer);

0 comments on commit 93a6e92

Please sign in to comment.