1/* 2 * Copyright 2020, Data61, CSIRO (ABN 41 687 119 230) 3 * 4 * SPDX-License-Identifier: GPL-2.0-only 5 */ 6 7#include <devices_gen.h> 8#include <drivers/common.h> 9#include <drivers/smp.h> 10#include <elfloader_common.h> 11#include <printf.h> 12 13#include <strops.h> 14 15static struct elfloader_device *smp_ops = NULL; 16 17struct smp_cpu_data secondary_data; 18 19void smp_register_handler(struct elfloader_device *dev) 20{ 21 if (dev->drv->type != DRIVER_SMP) { 22 return; 23 } 24 25 smp_ops = dev; 26} 27 28int __attribute__((weak)) plat_cpu_on(struct elfloader_cpu *cpu, void *entry, void *stack) 29{ 30 if (!smp_ops) { 31 return -1; 32 } 33 34 if (cpu->enable_method == NULL || dev_get_smp(smp_ops)->enable_method == NULL) { 35 /* if cpu has a NULL enable_method, expect a driver with a NULL enable_method too */ 36 if (cpu->enable_method != NULL || dev_get_smp(smp_ops)-> enable_method != NULL) { 37 return -1; 38 } 39 } else if (strcmp(cpu->enable_method, dev_get_smp(smp_ops)->enable_method)) { 40 return -1; 41 } 42 43 return dev_get_smp(smp_ops)->cpu_on(smp_ops, cpu, entry, stack); 44} 45