summaryrefslogtreecommitdiff
path: root/Core/EM/Ahci/AhciInt13Smm.h
blob: efe0fad1664dd5d177c0da89f911be68b5326c08 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
//**********************************************************************
//**********************************************************************
//**                                                                  **
//**        (C)Copyright 1985-2014, American Megatrends, Inc.         **
//**                                                                  **
//**                       All Rights Reserved.                       **
//**                                                                  **
//**         5555 Oakbrook Pkwy, Suite 200, Norcross, GA 30093        **
//**                                                                  **
//**                       Phone: (770)-246-8600                      **
//**                                                                  **
//**********************************************************************
//**********************************************************************
//**********************************************************************
// $Header: /Alaska/SOURCE/Modules/AHCI/INT13/AhciInt13Smm.h 1     11/25/14 12:09a Kapilporwal $Revision:
//
// $Date: 11/25/14 12:09a $Log: /Alaska/SOURCE/Modules/AHCI/INT13/AhciInt13Smm.h $
// 
// 
//
//****************************************************************************

//<AMI_FHDR_START>
//****************************************************************************
//
// Name:    AhciInt13Smm.h
//
// Description: 
//    This file contains the definitions of function prototype, constant and 
//    data structure for AhciInt13Smm module.
//****************************************************************************
//<AMI_FHDR_END>

#ifndef __AINT13_SMM_HEADER__
#define __AINT13_SMM_HEADER__

#define AHCI_INT13_SMM_DATA_GUID \
    { 0xF4F63525, 0x281E, 0x4040, 0xA3, 0x13, 0xC1, 0xD6, 0x76, 0x63, 0x84, 0xBE }

// PciExpressBaseAddress uses PCIEX_BASE_ADDRESS
#define PCI_CFG_ADDR(bus,dev,func,reg) \
    ((VOID*)(UINTN) (PciExpressBaseAddress + ((bus) << 20) + ((dev) << 15) + ((func) << 12) + reg))

#define     AHCI_CONTROLLER         0x06
#define     MASS_STORAGE            0x01
#define     PCI_ABAR                0x24
#define     HDD_BLOCK_SIZE          512

#define     READ_SECTORS            0x20
#define     READ_SECTORS_EXT        0x24
#define     READ_MULTIPLE           0xC4
#define     READ_MULTIPLE_EXT       0x29
#define     WRITE_SECTORS           0x30
#define     WRITE_SECTORS_EXT       0x34
#define     WRITE_MULTIPLE          0xC5
#define     WRITE_MULTIPLE_EXT      0x39
#define     READ_DMA                0xC8
#define     READ_DMA_EXT            0x25
#define     WRITE_DMA               0xCA
#define     WRITE_DMA_EXT           0x35

// Int13 parameter definition
// function(AH) definition
#define     READ_SECTOR             0x02
#define     WRITE_SECTOR            0x03
#define     EXT_READ                0x42
#define     EXT_WRITE               0x43

#ifndef OFFSET_OF
#define OFFSET_OF(TYPE, Field) ((UINTN) &(((TYPE *)0)->Field))
#endif

EFI_STATUS AhciInt13DxeEntry(
    IN EFI_HANDLE           ImageHandle,
    IN EFI_SYSTEM_TABLE     *SystemTable
);

EFI_STATUS AhciInt13SmmEntry (
    IN EFI_HANDLE           ImageHandle,
    IN EFI_SYSTEM_TABLE     *SystemTable 
);

// Prevent compiler from padding the structures
#pragma pack(1)

typedef struct {
    DLINK     dLink;
    UINT8     DriveNum;       // Int13's Drive Number(dl)
    UINT8     PMPortNum;      // PMPort number on HBA
    UINT8     PortNum;        // Port number on HBA
    UINT8     BusNo;          // Bus# of Controller  
    UINT8     DevNo;          // Device# of Controller  
    UINT8     FuncNo;         // Function# of Controller  
    UINT8     DeviceType;     // 0 ATA, 1 ATAPI
    UINT8     Lun;            // ATAPI LUN
    UINT16    BlockSize;      // ATAPI Block Size
    UINT16    wMAXCYL;        // maximum no. of cylinders..INT13 interface. (logical)
    UINT8     bMAXHN;         // maximum no. of heads..INT13 interface. (logical)
    UINT8     bMAXSN;         // no. of sectors per track..INT13 interface. (logical)
    UINT16    wLBACYL;        // #of cylinders drive is configured for. (physical)
    UINT8     bLBAHD;         // #of heads drive is configured for. (physical)
    UINT8     bLBASPT;        // #of sectors per track drive is configured for. (physical)
    UINT8     WCommand;       // write command
    UINT8     RCommand;       // read command
} SMM_AINT13_DRIVE_INFO;

typedef struct {
    UINT8                  DriveCount;
    SMM_AINT13_DRIVE_INFO  DriveInfo[32];       // Sync array length with SATA_PORT_COUNT of Aint13.h
} AHCI_INT13_SMM_DATA;

typedef struct {
    UINT8       PackageSize;    // size of package(10h or 18h)
    UINT8       Reserved;       // reserved
    UINT16      XferSector;     // transfer sectors
    UINT32      Buffer;         // 32 bit address transfer buffer
    UINT64      StartLba;       // Start LBA sectors;
    UINT64      Buffer64;       // 64 bit address transfer buffer(option);
} DISK_ADDRESS_PACKAGE;

// DO NOT MODIFY BELOW STRUCTURE
// NOTE: If modified, AINT13.ASM (of AI13.bin) also needs to be modified
typedef struct {
    UINT32          StackEDI;
    UINT32          StackESI;
    UINT32          StackEBP;
    UINT32          StackESP;
    UINT32          StackEBX;
    UINT32          StackEDX;
    UINT32          StackECX;
    UINT32          StackEAX;
    UINT16          StackDS;
    UINT16          StackES;  
    UINT16          StackGS;
    UINT16          StackFS;
    EFI_FLAGS_REG   StackFlags;
} INT13_TO_SMI_EXREGS;

#pragma pack()

#endif 

//**********************************************************************
//**********************************************************************
//**                                                                  **
//**        (C)Copyright 1985-2014, American Megatrends, Inc.         **
//**                                                                  **
//**                       All Rights Reserved.                       **
//**                                                                  **
//**         5555 Oakbrook Pkwy, Suite 200, Norcross, GA 30093        **
//**                                                                  **
//**                       Phone: (770)-246-8600                      **
//**                                                                  **
//**********************************************************************
//**********************************************************************