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, Universitaetstr. 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 22enum cpu_type { 23 CPU_K1OM, 24 CPU_X86_64, 25 CPU_X86_32, 26 CPU_ARM7, 27 CPU_ARM8, 28 CPU_TYPE_NUM // must be last 29}; 30 31#include <string.h> 32#include <barrelfish/static_assert.h> 33 34static inline const char *cpu_type_to_archstr(enum cpu_type cpu_type) 35{ 36 STATIC_ASSERT(CPU_TYPE_NUM == 5, "knowledge of all CPU types here"); 37 switch(cpu_type) { 38 case CPU_K1OM: return "k1om"; 39 case CPU_X86_64: return "x86_64"; 40 case CPU_X86_32: return "x86_32"; 41 case CPU_ARM7: return "armv7"; 42 case CPU_ARM8: return "armv8"; 43 default: return "(unknown)"; 44 } 45} 46 47static inline const enum cpu_type archstr_to_cputype(char* archstr) 48{ 49 STATIC_ASSERT(CPU_TYPE_NUM == 5, "knowledge of all CPU types here"); 50 51 if(strcmp("k1om", archstr) == 0) return CPU_K1OM; 52 if(strcmp("x86_64", archstr) == 0) return CPU_X86_64; 53 if(strcmp("x86_32", archstr) == 0) return CPU_X86_32; 54 if(strcmp("armv7", archstr) == 0) return CPU_ARM7; 55 if(strcmp("armv8", archstr) == 0) return CPU_ARM8; 56 return CPU_TYPE_NUM; 57} 58 59#endif 60 61// XXX: Code that needs these includes should includes should include it directly 62#include <barrelfish_kpi/generic_arch.h> 63 64#endif // BARRELFISH_KPI_CPU_H 65