arch/arm64: Support FEAT_CCIDX
[coreboot2.git] / util / msrtool / darwin.c
blob051ef3bb133b92378490c828320789edee1e1f68
1 /* SPDX-License-Identifier: GPL-2.0-only */
3 #include <sys/types.h>
4 #include <sys/stat.h>
5 #include <fcntl.h>
6 #include <unistd.h>
7 #include <string.h>
8 #include <errno.h>
10 #include "msrtool.h"
12 /* This Darwin support requires DirectHW, which is available at
13 * https://www.coreboot.org/DirectHW
16 int darwin_probe(const struct sysdef *system)
18 #ifdef __DARWIN__
19 return iopl(3) == 0;
20 #else
21 return 0;
22 #endif
25 int darwin_open(uint8_t cpu, enum SysModes mode)
27 #ifdef __DARWIN__
28 if (cpu > 0) {
29 fprintf(stderr, "%s: only core 0 is supported on Mac OS X right now.\n", __func__);
30 return 0;
32 return 1;
33 #else
34 return 0;
35 #endif
38 int darwin_close(uint8_t cpu)
40 return 1;
43 int darwin_rdmsr(uint8_t cpu, uint32_t addr, struct msr *val)
45 #ifdef __DARWIN__
46 msr_t msr;
48 msr = rdmsr(addr);
50 val->hi = msr.lo;
51 val->lo = msr.hi;
52 return 1;
53 #else
54 return 0;
55 #endif