1/** 2 * \file 3 * \brief Architecture specific CPU bits. 4 */ 5 6/* 7 * Copyright (c) 2007-2010, 2012, ETH Zurich. 8 * Copyright (c) 2015, Hewlett Packard Enterprise Development LP. 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, CAB F.78, Universitaetstrasse 6, CH-8092 Zurich, 14 * Attn: Systems Group. 15 */ 16 17#ifndef BARRELFISH_KPI_CPU_H 18#define BARRELFISH_KPI_CPU_H 19 20#ifndef __ASSEMBLER__ 21 22#include <sys/cdefs.h> 23 24__BEGIN_DECLS 25 26enum cpu_type { 27 CPU_K1OM, 28 CPU_X86_64, 29 CPU_X86_32, 30 CPU_ARM7, 31 CPU_ARM8, 32 CPU_TYPE_NUM // must be last 33}; 34 35#include <string.h> 36#include <barrelfish/static_assert.h> 37 38static inline const char *cpu_type_to_archstr(enum cpu_type cpu_type) 39{ 40 STATIC_ASSERT(CPU_TYPE_NUM == 5, "knowledge of all CPU types here"); 41 switch(cpu_type) { 42 case CPU_K1OM: return "k1om"; 43 case CPU_X86_64: return "x86_64"; 44 case CPU_X86_32: return "x86_32"; 45 case CPU_ARM7: return "armv7"; 46 case CPU_ARM8: return "armv8"; 47 default: return "(unknown)"; 48 } 49} 50 51static inline const enum cpu_type archstr_to_cputype(char* archstr) 52{ 53 STATIC_ASSERT(CPU_TYPE_NUM == 5, "knowledge of all CPU types here"); 54 55 if(strcmp("k1om", archstr) == 0) return CPU_K1OM; 56 if(strcmp("x86_64", archstr) == 0) return CPU_X86_64; 57 if(strcmp("x86_32", archstr) == 0) return CPU_X86_32; 58 if(strcmp("armv7", archstr) == 0) return CPU_ARM7; 59 if(strcmp("armv8", archstr) == 0) return CPU_ARM8; 60 return CPU_TYPE_NUM; 61} 62 63__END_DECLS 64 65#endif 66 67// XXX: Code that needs these includes should includes should include it directly 68#include <barrelfish_kpi/generic_arch.h> 69 70#endif // BARRELFISH_KPI_CPU_H 71