1/**
2 * \file
3 * \brief Platform information declarations
4:qa
5 */
6
7/*
8 * Copyright (c) 2016, ETH Zurich.
9 * All rights reserved.
10 *
11 * This file is distributed under the terms in the attached LICENSE file.
12 * If you do not find this file, copies can be found by writing to:
13 * ETH Zurich D-INFK, Universitaetstr 6, CH-8092 Zurich. Attn: Systems Group.
14 */
15
16#ifndef BARRELFISH_KPI_PLATFORM_H
17#define BARRELFISH_KPI_PLATFORM_H
18
19#include <barrelfish/static_assert.h>
20
21enum pi_arch {
22    PI_ARCH_X86,
23    PI_ARCH_ARMV7A,
24    PI_ARCH_ARMV8A,
25};
26
27enum pi_platform {
28    // placeholder platform
29    PI_PLATFORM_UNKNOWN,
30    // x86 platforms
31    PI_PLATFORM_PC,
32    // armv7 platforms
33    PI_PLATFORM_OMAP44XX,
34    PI_PLATFORM_VEXPRESS,
35    PI_PLATFORM_ZYNQ7,
36    // armv8 platforms
37    PI_PLATFORM_APM88XXXX,
38    PI_PLATFORM_FVP,
39    PI_PLATFORM_QEMU,
40    PI_PLATFORM_CN88XX,
41    PI_PLATFORM_RPI3,
42    PI_PLATFORM_IMX8X
43};
44
45/* Must be at least as large as all architectures' structs. */
46#define PI_ARCH_INFO_SIZE 255
47
48struct arch_info_armv7 {
49    /* The number of cores in the system, as reported by the GIC.  The cores
50     * in the primary cluster will be numbered sequentially, those in other
51     * clusters (big.little) probably aren't. */
52    uint32_t ncores;
53
54    /* The various identification registers. */
55    uint32_t midr, ctr, id_pfr0, id_pfr1;
56    uint32_t id_dfr0, id_afr0;
57};
58STATIC_ASSERT_SIZEOF(struct arch_info_armv7, 28);
59
60STATIC_ASSERT(PI_ARCH_INFO_SIZE >= sizeof(struct arch_info_armv7), \
61              "Overflowed PI_ARCH_INFO_SIZE");
62
63struct arch_info_armv8 {
64    /* The number of cores in the system, as reported by the GIC.  The cores
65     * in the primary cluster will be numbered sequentially, those in other
66     * clusters (big.little) probably aren't. */
67    uint32_t ncores;
68
69    /* The various identification registers. */
70    uint32_t midr, ctr, id_pfr0, id_pfr1;
71    uint32_t id_dfr0, id_afr0;
72};
73STATIC_ASSERT_SIZEOF(struct arch_info_armv8, 28);
74
75STATIC_ASSERT(PI_ARCH_INFO_SIZE >= sizeof(struct arch_info_armv8), \
76              "Overflowed PI_ARCH_INFO_SIZE");
77
78/// Struct that can be used to request/parse platform information
79struct platform_info {
80    enum pi_arch           arch;       // the architecture
81    enum pi_platform       platform;   // the platfrom
82
83    /* Some platforms e.g. ARMv7 need the CPU driver to probe the hardware for
84     * them, e.g. for the number of CPUs. */
85    union {
86        struct arch_info_armv7 armv7;
87        struct arch_info_armv8 armv8;
88    } arch_info;
89};
90
91#endif
92