xref: /illumos-gate/usr/src/grub/grub-0.97/stage2/cpu.h (revision a5602e1b)
1 /*
2  *  GRUB  --  GRand Unified Bootloader
3  *  Copyright (C) 2006  Free Software Foundation, Inc.
4  *
5  *  This program is free software; you can redistribute it and/or modify
6  *  it under the terms of the GNU General Public License as published by
7  *  the Free Software Foundation; either version 2 of the License, or
8  *  (at your option) any later version.
9  *
10  *  This program is distributed in the hope that it will be useful,
11  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
12  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13  *  GNU General Public License for more details.
14  *
15  *  You should have received a copy of the GNU General Public License
16  *  along with this program; if not, write to the Free Software
17  *  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
18  */
19 /*
20  * Copyright 2006 Sun Microsystems, Inc.  All rights reserved.
21  * Use is subject to license terms.
22  */
23 
24 #ifndef	_AMD64_CPU
25 #define	_AMD64_CPU
26 
27 #ifdef	__cplusplus
28 extern "C" {
29 #endif
30 
31 #include <shared.h>
32 
33 typedef unsigned int    uint_t;
34 typedef unsigned long ulong_t;
35 
36 #define BITX(u, h, l)   (((u) >> (l)) & ((1lu << ((h) - (l) + 1lu)) - 1lu))
37 
38 #include <controlregs.h>
39 
40 extern ulong_t amd64_get_cr2(void);
41 extern ulong_t amd64_get_cr0(void);
42 extern ulong_t amd64_get_cr3(void);
43 extern ulong_t amd64_get_cr4(void);
44 
45 extern ulong_t amd64_get_eflags(void);
46 
47 struct amd64_cpuid_regs {
48 	uint32_t r_eax;
49 	uint32_t r_ebx;
50 	uint32_t r_ecx;
51 	uint32_t r_edx;
52 };
53 
54 #define	AMD64_Auth	0x68747541
55 #define	AMD64_enti	0x69746e65
56 #define	AMD64_cAMD	0x444d4163
57 
58 extern uint32_t amd64_cpuid_supported(void);
59 extern void amd64_cpuid_insn(uint32_t, struct amd64_cpuid_regs *);
60 extern void amd64_rdmsr(uint32_t, uint64_t *);
61 extern void amd64_wrmsr(uint32_t, const uint64_t *);
62 extern int get_target_operating_mode(void);
63 
64 #ifdef	__cplusplus
65 }
66 #endif
67 
68 #endif	/* _AMD64_CPU */
69