ReactOS 0.4.16-dev-2633-g8dc9e50
amd.c File Reference
#include "pciidex.h"
Include dependency graph for amd.c:

Go to the source code of this file.

Macros

#define PCI_DEV_AMD_756   0x7409
 
#define PCI_DEV_AMD_766   0x7411
 
#define PCI_DEV_AMD_768   0x7441
 
#define PCI_DEV_AMD_8111   0x7469
 
#define PCI_DEV_AMD_CS5536   0x2092
 
#define PCI_DEV_AMD_CS5536_2   0x209A
 
#define PCI_DEV_NFORCE_IDE   0x01BC
 
#define PCI_DEV_NFORCE2_IDE   0x0065
 
#define PCI_DEV_NFORCE2_IDE_2   0x0085
 
#define PCI_DEV_NFORCE3_IDE   0x00D5
 
#define PCI_DEV_NFORCE3_IDE_2   0x00E5
 
#define PCI_DEV_CK804_IDE   0x0053
 
#define PCI_DEV_MCP04_IDE   0x0035
 
#define PCI_DEV_MCP51_IDE   0x0265
 
#define PCI_DEV_MCP55_IDE   0x036E
 
#define PCI_DEV_MCP61_IDE   0x03EC
 
#define PCI_DEV_MCP65_IDE   0x0448
 
#define PCI_DEV_MCP67_IDE   0x0560
 
#define PCI_DEV_MCP73_IDE   0x056C
 
#define PCI_DEV_MCP77_IDE   0x0759
 
#define PCI_DEV_NFORCE2_SATA   0x008E
 
#define PCI_DEV_NFORCE3_SATA   0x00E3
 
#define PCI_DEV_NFORCE3_SATA_2   0x00EE
 
#define PCI_DEV_CK804_SATA   0x0054
 
#define PCI_DEV_CK804_SATA_2   0x0055
 
#define PCI_DEV_MCP04_SATA   0x0036
 
#define PCI_DEV_MCP04_SATA_2   0x003E
 
#define PCI_DEV_MCP51_SATA   0x0266
 
#define PCI_DEV_MCP51_SATA_2   0x0267
 
#define PCI_DEV_MCP55_SATA   0x037E
 
#define PCI_DEV_MCP55_SATA_2   0x037F
 
#define PCI_DEV_MCP61_SATA   0x03E7
 
#define PCI_DEV_MCP61_SATA_2   0x03F6
 
#define PCI_DEV_MCP61_SATA_3   0x03F7
 
#define PCI_DEV_MCP89_SATA   0x0D85
 
#define PCI_SUBSYSTEM_AMD_SERENADE   0x36C0
 
#define AMD_CONFIG_BASE   0x40
 
#define NV_CONFIG_BASE   0x50
 
#define AMD_PCI_CLOCK   30000
 
#define AMD_REG_CONFIG_PREFETCH(IoBase)   ((IoBase) + 0x01)
 
#define AMD_REG_CONFIG_CR(IoBase)   ((IoBase) + 0x02)
 
#define AMD_REG_TIMING_CTRL(IoBase)   ((IoBase) + 0x08)
 
#define AMD_REG_ADDRESS_SETUP(IoBase)   ((IoBase) + 0x0C)
 
#define AMD_REG_UDMA(IoBase, Channel)   ((IoBase) + 0x10 + (2 - ((Channel) * 2)))
 
#define AMD_CONFIG_PREFETCH(Channel)   (0xC0 >> ((Channel) * 2))
 
#define AMD_CONFIG_CR(Channel)   (0x03 << ((Channel) * 2))
 
#define AMD_UDMA_TIME(x)   (x)
 
#define AMD_UDMA_EN   0xC0
 
#define AMD_UDMA_CTRL(Drive, Value)   ((Value) << ((1 - (Drive)) * 8))
 
#define HW_FLAGS_UDMA4   0x0001
 
#define HW_FLAGS_UDMA5   0x0002
 
#define HW_FLAGS_CHECK_SYSBOARD   0x0004
 
#define HW_FLAGS_NO_PREFETCH   0x0008
 
#define HW_FLAGS_SATA   0x0010
 

Functions

static ULONG AmdGetPciConfigIoBase (_In_ PATA_CONTROLLER Controller)
 
static VOID AmdEnablePostedWriteBuffer (_In_ PATA_CONTROLLER Controller, _In_ PCHANNEL_DATA_PATA ChanData, _In_ ULONG Channel, _In_reads_(MAX_IDE_DEVICE) PCHANNEL_DEVICE_CONFIG *DeviceList, _In_ ULONG IoBase)
 
static VOID AmdSetTransferMode (_In_ PATA_CONTROLLER Controller, _In_ ULONG Channel, _In_reads_(MAX_IDE_DEVICE) PCHANNEL_DEVICE_CONFIG *DeviceList)
 
static VOID AmdControllerStart (_In_ PATA_CONTROLLER Controller)
 
static BOOLEAN NvHasUdmaCable (_In_ USHORT UdmaTimReg, _In_ ULONG Drive)
 
NTSTATUS AmdGetControllerProperties (_Inout_ PATA_CONTROLLER Controller)
 

Variables

struct {
   USHORT   VendorID
 
   USHORT   DeviceID
 
   USHORT   Flags
 
AmdControllerList []
 
static const UCHAR AmdUdmaSettings []
 
static const ULONG AmdTimingControlShift [MAX_IDE_CHANNEL][MAX_IDE_DEVICE]
 
static const ULONG AmdAddressSetupShift [MAX_IDE_CHANNEL][MAX_IDE_DEVICE]
 
static const ULONG AmdPortTimShift [MAX_IDE_CHANNEL]
 
static PCIIDEX_PAGED_DATA const ATA_PCI_ENABLE_BITS AmdEnableBits [MAX_IDE_CHANNEL]
 
static PCIIDEX_PAGED_DATA const ATA_PCI_ENABLE_BITS NvEnableBits [MAX_IDE_CHANNEL]
 

Macro Definition Documentation

◆ AMD_CONFIG_BASE

#define AMD_CONFIG_BASE   0x40

Definition at line 54 of file amd.c.

◆ AMD_CONFIG_CR

#define AMD_CONFIG_CR (   Channel)    (0x03 << ((Channel) * 2))

Definition at line 66 of file amd.c.

◆ AMD_CONFIG_PREFETCH

#define AMD_CONFIG_PREFETCH (   Channel)    (0xC0 >> ((Channel) * 2))

Definition at line 65 of file amd.c.

◆ AMD_PCI_CLOCK

#define AMD_PCI_CLOCK   30000

Definition at line 57 of file amd.c.

◆ AMD_REG_ADDRESS_SETUP

#define AMD_REG_ADDRESS_SETUP (   IoBase)    ((IoBase) + 0x0C)

Definition at line 62 of file amd.c.

◆ AMD_REG_CONFIG_CR

#define AMD_REG_CONFIG_CR (   IoBase)    ((IoBase) + 0x02)

Definition at line 60 of file amd.c.

◆ AMD_REG_CONFIG_PREFETCH

#define AMD_REG_CONFIG_PREFETCH (   IoBase)    ((IoBase) + 0x01)

Definition at line 59 of file amd.c.

◆ AMD_REG_TIMING_CTRL

#define AMD_REG_TIMING_CTRL (   IoBase)    ((IoBase) + 0x08)

Definition at line 61 of file amd.c.

◆ AMD_REG_UDMA

#define AMD_REG_UDMA (   IoBase,
  Channel 
)    ((IoBase) + 0x10 + (2 - ((Channel) * 2)))

Definition at line 63 of file amd.c.

◆ AMD_UDMA_CTRL

#define AMD_UDMA_CTRL (   Drive,
  Value 
)    ((Value) << ((1 - (Drive)) * 8))

Definition at line 71 of file amd.c.

◆ AMD_UDMA_EN

#define AMD_UDMA_EN   0xC0

Definition at line 69 of file amd.c.

◆ AMD_UDMA_TIME

#define AMD_UDMA_TIME (   x)    (x)

Definition at line 68 of file amd.c.

◆ HW_FLAGS_CHECK_SYSBOARD

#define HW_FLAGS_CHECK_SYSBOARD   0x0004

Definition at line 81 of file amd.c.

◆ HW_FLAGS_NO_PREFETCH

#define HW_FLAGS_NO_PREFETCH   0x0008

Definition at line 82 of file amd.c.

◆ HW_FLAGS_SATA

#define HW_FLAGS_SATA   0x0010

Definition at line 83 of file amd.c.

◆ HW_FLAGS_UDMA4

#define HW_FLAGS_UDMA4   0x0001

Definition at line 79 of file amd.c.

◆ HW_FLAGS_UDMA5

#define HW_FLAGS_UDMA5   0x0002

Definition at line 80 of file amd.c.

◆ NV_CONFIG_BASE

#define NV_CONFIG_BASE   0x50

Definition at line 55 of file amd.c.

◆ PCI_DEV_AMD_756

#define PCI_DEV_AMD_756   0x7409

Definition at line 14 of file amd.c.

◆ PCI_DEV_AMD_766

#define PCI_DEV_AMD_766   0x7411

Definition at line 15 of file amd.c.

◆ PCI_DEV_AMD_768

#define PCI_DEV_AMD_768   0x7441

Definition at line 16 of file amd.c.

◆ PCI_DEV_AMD_8111

#define PCI_DEV_AMD_8111   0x7469

Definition at line 17 of file amd.c.

◆ PCI_DEV_AMD_CS5536

#define PCI_DEV_AMD_CS5536   0x2092

Definition at line 18 of file amd.c.

◆ PCI_DEV_AMD_CS5536_2

#define PCI_DEV_AMD_CS5536_2   0x209A

Definition at line 19 of file amd.c.

◆ PCI_DEV_CK804_IDE

#define PCI_DEV_CK804_IDE   0x0053

Definition at line 26 of file amd.c.

◆ PCI_DEV_CK804_SATA

#define PCI_DEV_CK804_SATA   0x0054

Definition at line 39 of file amd.c.

◆ PCI_DEV_CK804_SATA_2

#define PCI_DEV_CK804_SATA_2   0x0055

Definition at line 40 of file amd.c.

◆ PCI_DEV_MCP04_IDE

#define PCI_DEV_MCP04_IDE   0x0035

Definition at line 27 of file amd.c.

◆ PCI_DEV_MCP04_SATA

#define PCI_DEV_MCP04_SATA   0x0036

Definition at line 41 of file amd.c.

◆ PCI_DEV_MCP04_SATA_2

#define PCI_DEV_MCP04_SATA_2   0x003E

Definition at line 42 of file amd.c.

◆ PCI_DEV_MCP51_IDE

#define PCI_DEV_MCP51_IDE   0x0265

Definition at line 28 of file amd.c.

◆ PCI_DEV_MCP51_SATA

#define PCI_DEV_MCP51_SATA   0x0266

Definition at line 43 of file amd.c.

◆ PCI_DEV_MCP51_SATA_2

#define PCI_DEV_MCP51_SATA_2   0x0267

Definition at line 44 of file amd.c.

◆ PCI_DEV_MCP55_IDE

#define PCI_DEV_MCP55_IDE   0x036E

Definition at line 29 of file amd.c.

◆ PCI_DEV_MCP55_SATA

#define PCI_DEV_MCP55_SATA   0x037E

Definition at line 45 of file amd.c.

◆ PCI_DEV_MCP55_SATA_2

#define PCI_DEV_MCP55_SATA_2   0x037F

Definition at line 46 of file amd.c.

◆ PCI_DEV_MCP61_IDE

#define PCI_DEV_MCP61_IDE   0x03EC

Definition at line 30 of file amd.c.

◆ PCI_DEV_MCP61_SATA

#define PCI_DEV_MCP61_SATA   0x03E7

Definition at line 47 of file amd.c.

◆ PCI_DEV_MCP61_SATA_2

#define PCI_DEV_MCP61_SATA_2   0x03F6

Definition at line 48 of file amd.c.

◆ PCI_DEV_MCP61_SATA_3

#define PCI_DEV_MCP61_SATA_3   0x03F7

Definition at line 49 of file amd.c.

◆ PCI_DEV_MCP65_IDE

#define PCI_DEV_MCP65_IDE   0x0448

Definition at line 31 of file amd.c.

◆ PCI_DEV_MCP67_IDE

#define PCI_DEV_MCP67_IDE   0x0560

Definition at line 32 of file amd.c.

◆ PCI_DEV_MCP73_IDE

#define PCI_DEV_MCP73_IDE   0x056C

Definition at line 33 of file amd.c.

◆ PCI_DEV_MCP77_IDE

#define PCI_DEV_MCP77_IDE   0x0759

Definition at line 34 of file amd.c.

◆ PCI_DEV_MCP89_SATA

#define PCI_DEV_MCP89_SATA   0x0D85

Definition at line 50 of file amd.c.

◆ PCI_DEV_NFORCE2_IDE

#define PCI_DEV_NFORCE2_IDE   0x0065

Definition at line 22 of file amd.c.

◆ PCI_DEV_NFORCE2_IDE_2

#define PCI_DEV_NFORCE2_IDE_2   0x0085

Definition at line 23 of file amd.c.

◆ PCI_DEV_NFORCE2_SATA

#define PCI_DEV_NFORCE2_SATA   0x008E

Definition at line 36 of file amd.c.

◆ PCI_DEV_NFORCE3_IDE

#define PCI_DEV_NFORCE3_IDE   0x00D5

Definition at line 24 of file amd.c.

◆ PCI_DEV_NFORCE3_IDE_2

#define PCI_DEV_NFORCE3_IDE_2   0x00E5

Definition at line 25 of file amd.c.

◆ PCI_DEV_NFORCE3_SATA

#define PCI_DEV_NFORCE3_SATA   0x00E3

Definition at line 37 of file amd.c.

◆ PCI_DEV_NFORCE3_SATA_2

#define PCI_DEV_NFORCE3_SATA_2   0x00EE

Definition at line 38 of file amd.c.

◆ PCI_DEV_NFORCE_IDE

#define PCI_DEV_NFORCE_IDE   0x01BC

Definition at line 21 of file amd.c.

◆ PCI_SUBSYSTEM_AMD_SERENADE

#define PCI_SUBSYSTEM_AMD_SERENADE   0x36C0

Definition at line 52 of file amd.c.

Function Documentation

◆ AmdControllerStart()

static VOID AmdControllerStart ( _In_ PATA_CONTROLLER  Controller)
static

Definition at line 297 of file amd.c.

299{
300 UCHAR ConfigReg;
301
302 ASSERT(Controller->Pci.VendorID == PCI_VEN_AMD);
303
304 /* Initialize controller before issuing the identify command */
305 ConfigReg = PciRead8(Controller, AMD_REG_CONFIG_PREFETCH(AMD_CONFIG_BASE));
306 ConfigReg &= ~(AMD_CONFIG_PREFETCH(0) | AMD_CONFIG_PREFETCH(1));
307 PciWrite8(Controller, AMD_REG_CONFIG_PREFETCH(AMD_CONFIG_BASE), ConfigReg);
308}
#define AMD_CONFIG_BASE
Definition: amd.c:54
#define AMD_REG_CONFIG_PREFETCH(IoBase)
Definition: amd.c:59
#define AMD_CONFIG_PREFETCH(Channel)
Definition: amd.c:65
#define ASSERT(a)
Definition: mode.c:44
#define PCI_VEN_AMD
Definition: pata.h:11
FORCEINLINE UCHAR PciRead8(_In_ PATA_CONTROLLER Controller, _In_ ULONG ConfigDataOffset)
Definition: pciidex.h:847
FORCEINLINE VOID PciWrite8(_In_ PATA_CONTROLLER Controller, _In_ ULONG ConfigDataOffset, _In_ UCHAR Value)
Definition: pciidex.h:883
unsigned char UCHAR
Definition: typedefs.h:53

Referenced by AmdGetControllerProperties().

◆ AmdEnablePostedWriteBuffer()

static VOID AmdEnablePostedWriteBuffer ( _In_ PATA_CONTROLLER  Controller,
_In_ PCHANNEL_DATA_PATA  ChanData,
_In_ ULONG  Channel,
_In_reads_(MAX_IDE_DEVICE) PCHANNEL_DEVICE_CONFIG DeviceList,
_In_ ULONG  IoBase 
)
static

Definition at line 181 of file amd.c.

187{
188 UCHAR ConfigReg;
189 ULONG i;
190
191 ConfigReg = PciRead8(Controller, AMD_REG_CONFIG_PREFETCH(IoBase));
192 if (ChanData->HwFlags & HW_FLAGS_NO_PREFETCH)
193 {
194 /* Errata: IDE Read / Write Prefetch Hangs PCI Bus */
195 ConfigReg &= ~(AMD_CONFIG_PREFETCH(0) | AMD_CONFIG_PREFETCH(1));
196 }
197 else
198 {
199 ConfigReg |= AMD_CONFIG_PREFETCH(Channel);
200
201 for (i = 0; i < MAX_IDE_DEVICE; ++i)
202 {
204
205 if (Device && !Device->IsFixedDisk)
206 {
207 ConfigReg &= ~AMD_CONFIG_PREFETCH(Channel);
208 break;
209 }
210 }
211 }
212 PciWrite8(Controller, AMD_REG_CONFIG_PREFETCH(IoBase), ConfigReg);
213}
#define HW_FLAGS_NO_PREFETCH
Definition: amd.c:82
PDEVICE_LIST DeviceList
Definition: utils.c:27
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
#define MAX_IDE_DEVICE
Definition: ide.h:32
_In_ ULONG Channel
Definition: pciidex.h:74
uint32_t ULONG
Definition: typedefs.h:59
_Must_inspect_result_ _In_ WDFDEVICE Device
Definition: wdfchildlist.h:474

Referenced by AmdSetTransferMode().

◆ AmdGetControllerProperties()

NTSTATUS AmdGetControllerProperties ( _Inout_ PATA_CONTROLLER  Controller)

Definition at line 329 of file amd.c.

331{
333 ULONG i, HwFlags, SupportedMode;
334
335 PAGED_CODE();
336 ASSERT(Controller->Pci.VendorID == PCI_VEN_AMD || Controller->Pci.VendorID == PCI_VEN_NVIDIA);
337
338 for (i = 0; i < RTL_NUMBER_OF(AmdControllerList); ++i)
339 {
340 HwFlags = AmdControllerList[i].Flags;
341
342 if ((Controller->Pci.VendorID == AmdControllerList[i].VendorID) &&
343 (Controller->Pci.DeviceID == AmdControllerList[i].DeviceID))
344 {
345 break;
346 }
347 }
349 return STATUS_NO_MATCH;
350
351 Status = PciIdeCreateChannelData(Controller, 0);
352 if (!NT_SUCCESS(Status))
353 return Status;
354
355 if (HwFlags & HW_FLAGS_SATA)
356 {
357 SupportedMode = SATA_ALL;
358 }
359 else
360 {
361 SupportedMode = PIO_ALL | MWDMA_ALL | UDMA_ALL;
362
363 if (HwFlags & HW_FLAGS_CHECK_SYSBOARD)
364 {
365 if (Controller->Pci.SubSystemID == PCI_SUBSYSTEM_AMD_SERENADE)
366 SupportedMode &= ~UDMA_MODE6;
367 }
368 else
369 {
370 if (HwFlags & HW_FLAGS_UDMA5)
371 SupportedMode &= ~UDMA_MODE6;
372 else if (HwFlags & HW_FLAGS_UDMA4)
373 SupportedMode &= ~UDMA_MODES(5, 6);
374 }
375
376 if (Controller->Pci.VendorID == PCI_VEN_AMD)
377 {
378 Controller->ChannelEnableBits = AmdEnableBits;
379 Controller->Start = AmdControllerStart;
380 }
381 else
382 {
383 Controller->ChannelEnableBits = NvEnableBits;
384 }
385 }
386
387 for (i = 0; i < Controller->MaxChannels; ++i)
388 {
389 PCHANNEL_DATA_PATA ChanData = Controller->Channels[i];
390
391 ChanData->HwFlags = HwFlags;
392 ChanData->TransferModeSupported = SupportedMode;
393
394 if (HwFlags & HW_FLAGS_SATA)
395 {
396 ChanData->ChanInfo |= CHANNEL_FLAG_NO_SLAVE;
397 ChanData->SetTransferMode = SataSetTransferMode;
398 }
399 else
400 {
401 ChanData->SetTransferMode = AmdSetTransferMode;
402
403 /* Check for 80-conductor cable */
404 if (Controller->Pci.VendorID == PCI_VEN_AMD)
405 {
406 UCHAR ConfigReg = PciRead8(Controller, AMD_REG_CONFIG_CR(AMD_CONFIG_BASE));
407
408 if (!(ConfigReg & AMD_REG_CONFIG_CR(i)))
409 {
410 INFO("CH %lu: BIOS detected 40-conductor cable\n", i);
411 ChanData->TransferModeSupported &= ~UDMA_80C_ALL;
412 }
413 }
414 else
415 {
416 USHORT UdmaTimReg = PciRead16(Controller, AMD_REG_UDMA(NV_CONFIG_BASE, i));
417
418 if (!NvHasUdmaCable(UdmaTimReg, 0) && !NvHasUdmaCable(UdmaTimReg, 1))
419 {
420 INFO("CH %lu: BIOS hasn't selected mode faster than UDMA 2, "
421 "assume 40-conductor cable\n",
422 ChanData->Channel);
423 ChanData->TransferModeSupported &= ~UDMA_80C_ALL;
424 }
425 }
426 }
427 }
428
429 return STATUS_SUCCESS;
430}
#define PAGED_CODE()
#define RTL_NUMBER_OF(x)
Definition: RtlRegistry.c:12
#define HW_FLAGS_UDMA5
Definition: amd.c:80
#define NV_CONFIG_BASE
Definition: amd.c:55
#define HW_FLAGS_SATA
Definition: amd.c:83
static PCIIDEX_PAGED_DATA const ATA_PCI_ENABLE_BITS NvEnableBits[MAX_IDE_CHANNEL]
Definition: amd.c:160
#define HW_FLAGS_UDMA4
Definition: amd.c:79
#define PCI_SUBSYSTEM_AMD_SERENADE
Definition: amd.c:52
static PCIIDEX_PAGED_DATA const ATA_PCI_ENABLE_BITS AmdEnableBits[MAX_IDE_CHANNEL]
Definition: amd.c:153
#define AMD_REG_UDMA(IoBase, Channel)
Definition: amd.c:63
#define AMD_REG_CONFIG_CR(IoBase)
Definition: amd.c:60
static PCIIDEX_PAGED_DATA const struct @1172 AmdControllerList[]
static VOID AmdControllerStart(_In_ PATA_CONTROLLER Controller)
Definition: amd.c:297
static BOOLEAN NvHasUdmaCable(_In_ USHORT UdmaTimReg, _In_ ULONG Drive)
Definition: amd.c:313
static VOID AmdSetTransferMode(_In_ PATA_CONTROLLER Controller, _In_ ULONG Channel, _In_reads_(MAX_IDE_DEVICE) PCHANNEL_DEVICE_CONFIG *DeviceList)
Definition: amd.c:217
#define HW_FLAGS_CHECK_SYSBOARD
Definition: amd.c:81
#define UDMA_ALL
Definition: ata_user.h:31
#define MWDMA_ALL
Definition: ata_user.h:27
#define PIO_ALL
Definition: ata_user.h:19
LONG NTSTATUS
Definition: precomp.h:26
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:33
#define INFO
Definition: debug.h:89
Status
Definition: gdiplustypes.h:25
#define STATUS_NO_MATCH
Definition: ntstatus.h:873
#define SATA_ALL
Definition: pata.h:37
#define PCI_VEN_NVIDIA
Definition: pata.h:12
NTSTATUS PciIdeCreateChannelData(_In_ PATA_CONTROLLER Controller, _In_ ULONG HwExtensionSize)
#define CHANNEL_FLAG_NO_SLAVE
Definition: pciidex.h:270
FORCEINLINE USHORT PciRead16(_In_ PATA_CONTROLLER Controller, _In_ ULONG ConfigDataOffset)
Definition: pciidex.h:859
CHANNEL_SET_MODE_EX SataSetTransferMode
Definition: pciidex.h:633
unsigned short USHORT
Definition: pedump.c:61
#define STATUS_SUCCESS
Definition: shellext.h:65

Referenced by PciIdeGetControllerProperties().

◆ AmdGetPciConfigIoBase()

static ULONG AmdGetPciConfigIoBase ( _In_ PATA_CONTROLLER  Controller)
static

Definition at line 170 of file amd.c.

172{
173 if (Controller->Pci.VendorID == PCI_VEN_AMD)
174 return AMD_CONFIG_BASE;
175
176 return NV_CONFIG_BASE;
177}

Referenced by AmdSetTransferMode().

◆ AmdSetTransferMode()

static VOID AmdSetTransferMode ( _In_ PATA_CONTROLLER  Controller,
_In_ ULONG  Channel,
_In_reads_(MAX_IDE_DEVICE) PCHANNEL_DEVICE_CONFIG DeviceList 
)
static

Definition at line 217 of file amd.c.

221{
222 PCHANNEL_DATA_PATA ChanData = Controller->Channels[Channel];
223 const ULONG IoBase = AmdGetPciConfigIoBase(Controller);
224 ATA_TIMING DeviceTimings[MAX_IDE_DEVICE];
225 ULONG i, DriveTimReg, PortTimReg, UdmaTimReg;
226
228
229 DriveTimReg = PciRead32(Controller, AMD_REG_TIMING_CTRL(IoBase));
230 PortTimReg = PciRead32(Controller, AMD_REG_ADDRESS_SETUP(IoBase));
231 UdmaTimReg = PciRead32(Controller, AMD_REG_UDMA(IoBase, 1));
232
233 INFO("CH %lu: Config (before)\n"
234 "DRV %08lX\n"
235 "PORT %08lX\n"
236 "UDMA %08lX\n"
237 "CFG %08lX\n",
238 Channel, DriveTimReg, PortTimReg, UdmaTimReg, PciRead32(Controller, IoBase));
239
240 for (i = 0; i < MAX_IDE_DEVICE; ++i)
241 {
243 PATA_TIMING Timing = &DeviceTimings[i];
244 ULONG Value;
245
246 /* UDMA timings */
247 if (Device && (Device->DmaMode >= UDMA_MODE(0)))
248 {
249 Value = AmdUdmaSettings[Device->DmaMode - UDMA_MODE(0)];
250 }
251 else
252 {
253 /* Set "Slow UDMA mode 0" by default */
254 if (Controller->Pci.VendorID == PCI_VEN_AMD)
255 Value = AMD_UDMA_TIME(3);
256 else
257 Value = 0;
258 }
259 UdmaTimReg &= ~(0xFF << AmdTimingControlShift[Channel][i]);
260 UdmaTimReg |= Value << AmdTimingControlShift[Channel][i];
261
262 if (!Device)
263 continue;
264
265 /* PIO and DMA timings */
266 ViaClampTimings(Timing);
267
268 Value = Timing->AddressSetup;
269 PortTimReg &= ~(0x03 << AmdAddressSetupShift[Channel][i]);
270 PortTimReg |= Value << AmdAddressSetupShift[Channel][i];
271
272 Value = (Timing->CmdActive << 4) | Timing->CmdRecovery;
273 PortTimReg &= ~(0xFF << AmdPortTimShift[Channel]);
274 PortTimReg |= Value << AmdPortTimShift[Channel];
275
276 Value = (Timing->DataActive << 4) | Timing->DataRecovery;
277 DriveTimReg &= ~(0xFF << AmdTimingControlShift[Channel][i]);
278 DriveTimReg |= Value << AmdTimingControlShift[Channel][i];
279 }
280
281 AmdEnablePostedWriteBuffer(Controller, ChanData, Channel, DeviceList, IoBase);
282
283 PciWrite32(Controller, AMD_REG_TIMING_CTRL(IoBase), DriveTimReg);
284 PciWrite32(Controller, AMD_REG_ADDRESS_SETUP(IoBase), PortTimReg);
285 PciWrite32(Controller, AMD_REG_UDMA(IoBase, 1), UdmaTimReg);
286
287 INFO("CH %lu: Config (after)\n"
288 "DRV %08lX\n"
289 "PORT %08lX\n"
290 "UDMA %08lX\n"
291 "CFG %08lX\n",
292 Channel, DriveTimReg, PortTimReg, UdmaTimReg, PciRead32(Controller, IoBase));
293}
static const ULONG AmdTimingControlShift[MAX_IDE_CHANNEL][MAX_IDE_DEVICE]
Definition: amd.c:134
#define AMD_PCI_CLOCK
Definition: amd.c:57
#define AMD_UDMA_TIME(x)
Definition: amd.c:68
static const ULONG AmdPortTimShift[MAX_IDE_CHANNEL]
Definition: amd.c:146
#define AMD_REG_TIMING_CTRL(IoBase)
Definition: amd.c:61
static VOID AmdEnablePostedWriteBuffer(_In_ PATA_CONTROLLER Controller, _In_ PCHANNEL_DATA_PATA ChanData, _In_ ULONG Channel, _In_reads_(MAX_IDE_DEVICE) PCHANNEL_DEVICE_CONFIG *DeviceList, _In_ ULONG IoBase)
Definition: amd.c:181
static const ULONG AmdAddressSetupShift[MAX_IDE_CHANNEL][MAX_IDE_DEVICE]
Definition: amd.c:140
static const UCHAR AmdUdmaSettings[]
Definition: amd.c:123
#define AMD_REG_ADDRESS_SETUP(IoBase)
Definition: amd.c:62
static ULONG AmdGetPciConfigIoBase(_In_ PATA_CONTROLLER Controller)
Definition: amd.c:170
#define UDMA_MODE(n)
Definition: ata_user.h:39
#define SHARED_CMD_TIMINGS
Definition: pata.h:230
VOID AtaSelectTimings(_In_reads_(MAX_IDE_DEVICE) PCHANNEL_DEVICE_CONFIG *DeviceList, _Out_writes_all_(MAX_IDE_DEVICE) PATA_TIMING Timings, _In_range_(>, 0) ULONG ClockPeriodPs, _In_ ULONG Flags)
Definition: pata_generic.c:116
FORCEINLINE VOID PciWrite32(_In_ PATA_CONTROLLER Controller, _In_ ULONG ConfigDataOffset, _In_ ULONG Value)
Definition: pciidex.h:903
FORCEINLINE ULONG PciRead32(_In_ PATA_CONTROLLER Controller, _In_ ULONG ConfigDataOffset)
Definition: pciidex.h:871
ATATIM CmdRecovery
Definition: pata.h:224
ATATIM CmdActive
Definition: pata.h:223
ATATIM DataRecovery
Definition: pata.h:227
ATATIM AddressSetup
Definition: pata.h:221
ATATIM DataActive
Definition: pata.h:226
VOID ViaClampTimings(_Inout_ PATA_TIMING Timing)
Definition: via.c:165
_Must_inspect_result_ _In_ WDFKEY _In_ PCUNICODE_STRING _Out_opt_ PUSHORT _Inout_opt_ PUNICODE_STRING Value
Definition: wdfregistry.h:413

Referenced by AmdGetControllerProperties().

◆ NvHasUdmaCable()

static BOOLEAN NvHasUdmaCable ( _In_ USHORT  UdmaTimReg,
_In_ ULONG  Drive 
)
static

Definition at line 313 of file amd.c.

316{
317 PAGED_CODE();
318
319 /* UDMA was disabled by BIOS */
320 if ((AMD_UDMA_CTRL(Drive, UdmaTimReg) & AMD_UDMA_EN) != AMD_UDMA_EN)
321 return FALSE;
322
323 /* Check clock settings, see if UDMA3 or higher mode is active */
324 return !!((AMD_UDMA_CTRL(Drive, UdmaTimReg) & 0x7) & AMD_UDMA_TIME(4));
325}
#define AMD_UDMA_CTRL(Drive, Value)
Definition: amd.c:71
#define AMD_UDMA_EN
Definition: amd.c:69
PWCHAR Drive
Definition: chkdsk.c:73
#define FALSE
Definition: types.h:117

Referenced by AmdGetControllerProperties().

Variable Documentation

◆ AmdAddressSetupShift

const ULONG AmdAddressSetupShift[MAX_IDE_CHANNEL][MAX_IDE_DEVICE]
static
Initial value:
=
{
{ 6, 4 },
{ 2, 0 },
}

Definition at line 140 of file amd.c.

Referenced by AmdSetTransferMode().

◆ 

PCIIDEX_PAGED_DATA const struct { ... } AmdControllerList[]

◆ AmdEnableBits

Initial value:
=
{
{ AMD_CONFIG_BASE, 0x02, 0x02 },
{ AMD_CONFIG_BASE, 0x01, 0x01 },
}

Definition at line 153 of file amd.c.

Referenced by AmdGetControllerProperties().

◆ AmdPortTimShift

const ULONG AmdPortTimShift[MAX_IDE_CHANNEL]
static
Initial value:
=
{
24,
16
}

Definition at line 146 of file amd.c.

Referenced by AmdSetTransferMode().

◆ AmdTimingControlShift

const ULONG AmdTimingControlShift[MAX_IDE_CHANNEL][MAX_IDE_DEVICE]
static
Initial value:
=
{
{ 24, 16 },
{ 8, 0 },
}

Definition at line 134 of file amd.c.

Referenced by AmdSetTransferMode().

◆ AmdUdmaSettings

const UCHAR AmdUdmaSettings[]
static

◆ DeviceID

Definition at line 77 of file amd.c.

◆ Flags

Definition at line 78 of file amd.c.

◆ NvEnableBits

Initial value:
=
{
{ NV_CONFIG_BASE, 0x02, 0x02 },
{ NV_CONFIG_BASE, 0x01, 0x01 },
}

Definition at line 160 of file amd.c.

Referenced by AmdGetControllerProperties().

◆ VendorID

USHORT VendorID

Definition at line 76 of file amd.c.