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