1/**
2 * \file
3 * \brief Registering for handler functions to manage cores
4 */
5/*
6 * Copyright (c) 2013, ETH Zurich.
7 * All rights reserved.
8 *
9 * This file is distributed under the terms in the attached LICENSE file.
10 * If you do not find this file, copies can be found by writing to:
11 * ETH Zurich D-INFK, Haldeneggsteig 4, CH-8092 Zurich. Attn: Systems Group.
12 */
13
14#include <stdlib.h>
15#include <string.h>
16#include <errno.h>
17#include <assert.h>
18#include <coreboot.h>
19#include <barrelfish_kpi/types.h>
20#include <barrelfish_kpi/cpu.h>
21
22static coreboot_start_fn_t spawn_core_handlers[CPU_TYPE_NUM];
23
24/**
25 * Register spawn core handler function for specific cpu type.
26 *
27 * \param type CPU type
28 * \param handler Handler functions
29 */
30void coreboot_set_spawn_handler(enum cpu_type type, coreboot_start_fn_t handler)
31{
32    if (type < CPU_TYPE_NUM) {
33        spawn_core_handlers[type] = handler;
34    }
35}
36
37/**
38 * \param  cpu_type Get handler for specific cpu type
39 * \return Core boot handler function or NULL in case none was registered
40 * for that type
41 */
42coreboot_start_fn_t coreboot_get_spawn_handler(enum cpu_type type) {
43    assert(type < CPU_TYPE_NUM);
44
45    if (type >= CPU_TYPE_NUM) {
46        return NULL;
47    }
48    return spawn_core_handlers[type];
49}
50