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