Marc Jones | 8ae8c88 | 2007-12-19 01:32:08 +0000 | [diff] [blame] | 1 | /* |
Stefan Reinauer | 7e61e45 | 2008-01-18 10:35:56 +0000 | [diff] [blame] | 2 | * This file is part of the coreboot project. |
Marc Jones | 8ae8c88 | 2007-12-19 01:32:08 +0000 | [diff] [blame] | 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. |
Marc Jones | 8ae8c88 | 2007-12-19 01:32:08 +0000 | [diff] [blame] | 14 | */ |
| 15 | |
| 16 | #ifndef PORTING_H |
| 17 | #define PORTING_H |
| 18 | |
| 19 | |
| 20 | /* For AMD64 or 32-bit GCC */ |
| 21 | typedef int int32; |
| 22 | typedef unsigned int uint32; |
| 23 | typedef short int16; |
| 24 | typedef unsigned short uint16; |
| 25 | typedef char int8; |
| 26 | typedef unsigned char uint8; |
| 27 | |
| 28 | /* Create the Boolean type */ |
| 29 | #define TRUE 1 |
| 30 | #define FALSE 0 |
| 31 | typedef unsigned char BOOL; |
| 32 | |
| 33 | /* Force tight packing of structures */ |
| 34 | #pragma pack(1) |
| 35 | |
| 36 | #define CALLCONV |
| 37 | |
| 38 | |
| 39 | typedef 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 | */ |
| 54 | typedef 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 | |
| 65 | void CALLCONV AmdMSRRead(uint32 Address, uint64 *Value); |
| 66 | void CALLCONV AmdMSRWrite(uint32 Address, uint64 *Value); |
| 67 | void CALLCONV AmdIORead(uint8 IOSize, uint16 Address, uint32 *Value); |
| 68 | void CALLCONV AmdIOWrite(uint8 IOSize, uint16 Address, uint32 *Value); |
| 69 | void CALLCONV AmdMemRead(uint8 MemSize, uint64 *Address, uint32 *Value); |
| 70 | void CALLCONV AmdMemWrite(uint8 MemSize, uint64 *Address, uint32 *Value); |
| 71 | void CALLCONV AmdPCIRead(SBDFO loc, uint32 *Value); |
| 72 | void CALLCONV AmdPCIWrite(SBDFO loc, uint32 *Value); |
| 73 | void CALLCONV AmdCPUIDRead(uint32 Address, uint32 Regs[4]); |
| 74 | void CALLCONV ErrorStop(uint32 Value); |
| 75 | |
Marc Jones | 8ae8c88 | 2007-12-19 01:32:08 +0000 | [diff] [blame] | 76 | #define BYTESIZE 1 |
| 77 | #define WORDSIZE 2 |
| 78 | #define DWORDSIZE 4 |
| 79 | |
| 80 | #endif /* PORTING_H */ |