Please bear with me - another rename checkin. This qualifies as trivial, no
[coreboot.git] / src / northbridge / amd / amdht / porting.h
1 /*
2  * This file is part of the coreboot project.
3  *
4  * Copyright (C) 2007 Advanced Micro Devices, Inc.
5  *
6  * This program is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation; version 2 of the License.
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., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301 USA
18  */
19
20 #ifndef PORTING_H
21 #define PORTING_H
22
23
24 /* For AMD64 or 32-bit GCC */
25 typedef int int32;
26 typedef unsigned int uint32;
27 typedef short int16;
28 typedef unsigned short uint16;
29 typedef char int8;
30 typedef unsigned char  uint8;
31
32 /* Create the Boolean type */
33 #define TRUE  1
34 #define FALSE 0
35 typedef unsigned char BOOL;
36
37 /* Force tight packing of structures */
38 #pragma pack(1)
39
40 #define CALLCONV
41
42
43 typedef struct _uint64
44 {
45         uint32 lo;
46         uint32 hi;
47 }uint64;
48
49
50 /*
51  *   SBDFO - Segment Bus Device Function Offset
52  *   31:28   Segment (4-bits)
53  *   27:20   Bus     (8-bits)
54  *   19:15   Device  (5-bits)
55  *   14:12   Function(3-bits)
56  *   11:00   Offset  (12-bits)
57  */
58 typedef uint32 SBDFO;
59
60 #define MAKE_SBDFO(seg,bus,dev,fun,off) ((((uint32)(seg))<<28) | (((uint32)(bus))<<20) | \
61                     (((uint32)(dev))<<15) | (((uint32)(fun))<<12) | ((uint32)(off)))
62 #define SBDFO_SEG(x) (((uint32)(x)>>28) & 0x0F)
63 #define SBDFO_BUS(x) (((uint32)(x)>>20) & 0xFF)
64 #define SBDFO_DEV(x) (((uint32)(x)>>15) & 0x1F)
65 #define SBDFO_FUN(x) (((uint32)(x)>>12) & 0x07)
66 #define SBDFO_OFF(x) (((uint32)(x)) & 0xFFF)
67 #define ILLEGAL_SBDFO 0xFFFFFFFF
68
69 void CALLCONV AmdMSRRead(uint32 Address, uint64 *Value);
70 void CALLCONV AmdMSRWrite(uint32 Address, uint64 *Value);
71 void CALLCONV AmdIORead(uint8 IOSize, uint16 Address, uint32 *Value);
72 void CALLCONV AmdIOWrite(uint8 IOSize, uint16 Address, uint32 *Value);
73 void CALLCONV AmdMemRead(uint8 MemSize, uint64 *Address, uint32 *Value);
74 void CALLCONV AmdMemWrite(uint8 MemSize, uint64 *Address, uint32 *Value);
75 void CALLCONV AmdPCIRead(SBDFO loc, uint32 *Value);
76 void CALLCONV AmdPCIWrite(SBDFO loc, uint32 *Value);
77 void CALLCONV AmdCPUIDRead(uint32 Address, uint32 Regs[4]);
78 void CALLCONV ErrorStop(uint32 Value);
79
80 #ifndef NULL
81 #define NULL ((void *) 0)
82 #endif
83
84 #define BYTESIZE 1
85 #define WORDSIZE 2
86 #define DWORDSIZE 4
87
88 #endif /* PORTING_H */