blob: a0f88786cf97a43d06bccc99c0c2fd3c537fbfaf [file] [log] [blame]
Marc Jones8ae8c882007-12-19 01:32:08 +00001/*
Stefan Reinauer7e61e452008-01-18 10:35:56 +00002 * This file is part of the coreboot project.
Marc Jones8ae8c882007-12-19 01:32:08 +00003 *
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.
Marc Jones8ae8c882007-12-19 01:32:08 +000014 */
15
16#ifndef PORTING_H
17#define PORTING_H
18
19
20/* For AMD64 or 32-bit GCC */
21typedef int int32;
22typedef unsigned int uint32;
23typedef short int16;
24typedef unsigned short uint16;
25typedef char int8;
26typedef unsigned char uint8;
27
28/* Create the Boolean type */
29#define TRUE 1
30#define FALSE 0
31typedef unsigned char BOOL;
32
33/* Force tight packing of structures */
34#pragma pack(1)
35
36#define CALLCONV
37
38
39typedef struct _uint64
40{
41 uint32 lo;
42 uint32 hi;
43}uint64;
44
45
46/*
47 * SBDFO - Segment Bus Device Function Offset
48 * 31:28 Segment (4-bits)
49 * 27:20 Bus (8-bits)
50 * 19:15 Device (5-bits)
51 * 14:12 Function(3-bits)
52 * 11:00 Offset (12-bits)
53 */
54typedef uint32 SBDFO;
55
56#define MAKE_SBDFO(seg,bus,dev,fun,off) ((((uint32)(seg))<<28) | (((uint32)(bus))<<20) | \
57 (((uint32)(dev))<<15) | (((uint32)(fun))<<12) | ((uint32)(off)))
58#define SBDFO_SEG(x) (((uint32)(x)>>28) & 0x0F)
59#define SBDFO_BUS(x) (((uint32)(x)>>20) & 0xFF)
60#define SBDFO_DEV(x) (((uint32)(x)>>15) & 0x1F)
61#define SBDFO_FUN(x) (((uint32)(x)>>12) & 0x07)
62#define SBDFO_OFF(x) (((uint32)(x)) & 0xFFF)
63#define ILLEGAL_SBDFO 0xFFFFFFFF
64
65void CALLCONV AmdMSRRead(uint32 Address, uint64 *Value);
66void CALLCONV AmdMSRWrite(uint32 Address, uint64 *Value);
67void CALLCONV AmdIORead(uint8 IOSize, uint16 Address, uint32 *Value);
68void CALLCONV AmdIOWrite(uint8 IOSize, uint16 Address, uint32 *Value);
69void CALLCONV AmdMemRead(uint8 MemSize, uint64 *Address, uint32 *Value);
70void CALLCONV AmdMemWrite(uint8 MemSize, uint64 *Address, uint32 *Value);
71void CALLCONV AmdPCIRead(SBDFO loc, uint32 *Value);
72void CALLCONV AmdPCIWrite(SBDFO loc, uint32 *Value);
73void CALLCONV AmdCPUIDRead(uint32 Address, uint32 Regs[4]);
74void CALLCONV ErrorStop(uint32 Value);
75
Marc Jones8ae8c882007-12-19 01:32:08 +000076#define BYTESIZE 1
77#define WORDSIZE 2
78#define DWORDSIZE 4
79
80#endif /* PORTING_H */