uboot/arch/x86/cpu/qemu/cpu.c
<<
>>
Prefs
   1/*
   2 * Copyright (C) 2015, Miao Yan <yanmiaobest@gmail.com>
   3 *
   4 * SPDX-License-Identifier:     GPL-2.0+
   5 */
   6
   7#include <common.h>
   8#include <cpu.h>
   9#include <dm.h>
  10#include <errno.h>
  11#include <qfw.h>
  12#include <asm/cpu.h>
  13
  14DECLARE_GLOBAL_DATA_PTR;
  15
  16int cpu_qemu_get_desc(struct udevice *dev, char *buf, int size)
  17{
  18        if (size < CPU_MAX_NAME_LEN)
  19                return -ENOSPC;
  20
  21        cpu_get_name(buf);
  22
  23        return 0;
  24}
  25
  26static int cpu_qemu_get_count(struct udevice *dev)
  27{
  28        return qemu_fwcfg_online_cpus();
  29}
  30
  31static const struct cpu_ops cpu_qemu_ops = {
  32        .get_desc       = cpu_qemu_get_desc,
  33        .get_count      = cpu_qemu_get_count,
  34};
  35
  36static const struct udevice_id cpu_qemu_ids[] = {
  37        { .compatible = "cpu-qemu" },
  38        { }
  39};
  40
  41U_BOOT_DRIVER(cpu_qemu_drv) = {
  42        .name           = "cpu_qemu",
  43        .id             = UCLASS_CPU,
  44        .of_match       = cpu_qemu_ids,
  45        .ops            = &cpu_qemu_ops,
  46};
  47