[dev][power][psci] refactor out of the qemu-virt-arm module
This commit is contained in:
committed by
Travis Geiselbrecht
parent
baca46e133
commit
f4b2fa9a6b
@@ -12,6 +12,7 @@
|
||||
#include <lk/trace.h>
|
||||
#include <dev/bus/pci.h>
|
||||
#include <dev/interrupt/arm_gic.h>
|
||||
#include <dev/power/psci.h>
|
||||
#include <dev/timer/arm_generic.h>
|
||||
#include <dev/uart.h>
|
||||
#include <dev/virtio.h>
|
||||
@@ -65,8 +66,6 @@ static pmm_arena_t arena = {
|
||||
.flags = PMM_ARENA_FLAG_KMAP,
|
||||
};
|
||||
|
||||
extern int psci_call(ulong arg0, ulong arg1, ulong arg2, ulong arg3);
|
||||
|
||||
// callbacks to the fdt_walk routine
|
||||
static void memcallback(uint64_t base, uint64_t len, void *cookie) {
|
||||
bool *found_mem = (bool *)cookie;
|
||||
@@ -157,13 +156,9 @@ void platform_early_init(void) {
|
||||
LTRACEF("booting %d cpus\n", cpu_count);
|
||||
|
||||
/* boot the secondary cpus using the Power State Coordintion Interface */
|
||||
ulong psci_call_num = 0x84000000 + 3; /* SMC32 CPU_ON */
|
||||
#if ARCH_ARM64
|
||||
psci_call_num += 0x40000000; /* SMC64 */
|
||||
#endif
|
||||
for (int cpuid = 1; cpuid < cpu_count; cpuid++) {
|
||||
/* note: assumes cpuids are numbered like MPIDR 0:0:0:N */
|
||||
int ret = psci_call(psci_call_num, cpuid, MEMBASE + KERNEL_LOAD_OFFSET, cpuid);
|
||||
int ret = psci_cpu_on(cpuid, MEMBASE + KERNEL_LOAD_OFFSET);
|
||||
if (ret != 0) {
|
||||
printf("ERROR: psci CPU_ON returns %d\n", ret);
|
||||
}
|
||||
@@ -287,7 +282,7 @@ status_t platform_allocate_interrupts(size_t count, uint align_log2, bool msi, u
|
||||
}
|
||||
|
||||
status_t platform_compute_msi_values(unsigned int vector, unsigned int cpu, bool edge,
|
||||
uint64_t *msi_address_out, uint16_t *msi_data_out) {
|
||||
uint64_t *msi_address_out, uint16_t *msi_data_out) {
|
||||
|
||||
// only handle edge triggered at the moment
|
||||
DEBUG_ASSERT(edge);
|
||||
@@ -301,3 +296,18 @@ status_t platform_compute_msi_values(unsigned int vector, unsigned int cpu, bool
|
||||
|
||||
return NO_ERROR;
|
||||
}
|
||||
|
||||
void platform_halt(platform_halt_action suggested_action, platform_halt_reason reason) {
|
||||
switch (suggested_action) {
|
||||
case HALT_ACTION_SHUTDOWN:
|
||||
case HALT_ACTION_HALT:
|
||||
psci_system_off();
|
||||
break;
|
||||
case HALT_ACTION_REBOOT:
|
||||
psci_system_reset();
|
||||
break;
|
||||
}
|
||||
dprintf(ALWAYS, "HALT: spinning forever... (reason = %d)\n", reason);
|
||||
arch_disable_ints();
|
||||
for (;;);
|
||||
}
|
||||
|
||||
@@ -18,7 +18,6 @@ LK_HEAP_IMPLEMENTATION ?= dlmalloc
|
||||
MODULE_SRCS += \
|
||||
$(LOCAL_DIR)/debug.c \
|
||||
$(LOCAL_DIR)/platform.c \
|
||||
$(LOCAL_DIR)/secondary_boot.S \
|
||||
$(LOCAL_DIR)/uart.c
|
||||
|
||||
MEMBASE := 0x40000000
|
||||
@@ -26,15 +25,16 @@ MEMSIZE ?= 0x08000000 # 512MB
|
||||
KERNEL_LOAD_OFFSET := 0x100000 # 1MB
|
||||
|
||||
MODULE_DEPS += \
|
||||
lib/cbuf \
|
||||
lib/fdtwalk \
|
||||
dev/bus/pci \
|
||||
dev/bus/pci/drivers \
|
||||
dev/interrupt/arm_gic \
|
||||
dev/power/psci \
|
||||
dev/timer/arm_generic \
|
||||
dev/virtio/block \
|
||||
dev/virtio/gpu \
|
||||
dev/virtio/net \
|
||||
lib/cbuf \
|
||||
lib/fdtwalk \
|
||||
|
||||
GLOBAL_DEFINES += \
|
||||
MEMBASE=$(MEMBASE) \
|
||||
|
||||
@@ -1,31 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2014 Travis Geiselbrecht
|
||||
*
|
||||
* Use of this source code is governed by a MIT-style
|
||||
* license that can be found in the LICENSE file or at
|
||||
* https://opensource.org/licenses/MIT
|
||||
*/
|
||||
|
||||
#include <lk/asm.h>
|
||||
|
||||
.section .text
|
||||
|
||||
/* used to call into PSCI firmware (Power State Coordination Firmware) */
|
||||
FUNCTION(psci_call)
|
||||
#if ARCH_ARM
|
||||
hvc #0
|
||||
bx lr
|
||||
#else
|
||||
/* If booted at EL2 (bit 3 set of boot EL), we need to use SMC instead of HVC. */
|
||||
adrp x9, arm64_boot_el
|
||||
ldr x9, [x9, #:lo12:arm64_boot_el]
|
||||
tbnz x9, #3, .Lsmc
|
||||
hvc #0
|
||||
ret
|
||||
.Lsmc:
|
||||
smc #0
|
||||
ret
|
||||
#endif
|
||||
|
||||
.ltorg
|
||||
|
||||
Reference in New Issue
Block a user