Hi everyone,

I'm building a WinCE 6 OS for an Intel D945GCLF motherboard using the
CEPC:x86 BSP as my starting point. Right now I'm having a hard time getting
the ATA interface to recognise anything connected to it. I've got all service
packs up unit June 2008 installed...

I've tried the following with this board:

- New 1G CF card that I purchassed with the board
- Older 256Mb CF card that I've used successfuly in the past
- Older 720Mb 2.5" rotating hard disk

So far the OS boots from all three devices, but none of them are mounted by
the OS once booted. I'm now thinking that there is a problem with the ATAPI
driver in combination with the ICH7 device...

The ATAPI catalog item is selected, and the OS does try and initialise the
first HD (Primary Master) without success. I've disbled the other three
interfaces (Pri/Slave, Sec/Master and Sec/Slave) since they are not present
in my application.

I've tried the following to get this working:

- Set DMA value in ali1543.reg to 0 to disable DMA (this has solved this
issue in the past for me)
- Change the TransferMode value to different settings including PIO default,
PIO default disable IORDY, PIO Flow control up to mode 4 (which is supported
by the CF card)
- Change the DeviceID and VendorID flags to match the ones reported by the
ICH7 for the ATA interface

None of this appears to be working... Does anyone have any insight on this
issue? Has anyone used the D945GCLF / ICH7 with success? Am I going crazy!?!

I've attached pertinent debug output below for your reference:

...

OSAXST1: >>> Loading Module 'atapi.dll' (0x8395A778) at address
0xC0490000-0xC04AC000 in Process 'NK.EXE' (0x81783C80)
ATAPI:PCIConfig!DeviceConfig+(0)
ATAPI:PCIConfig!DeviceConfig+(0)
Warning: No Match template is found for following PCI Devic
-------------------------------------------------------------------------------
Bus/Device/Function = 0/31/3, Unknown Device Type
VendorID = 0x8086, DeviceID = 0x27DA, Command = 0x0001, Status = 0x0280
RevisionID = 0x01, ProgIf = 0x00, SubClass = 0x05, BaseClass = 0x0C
CacheLineSize = 0x00, LatencyTimer = 0x00, HeaderType = 0x00, BIST = 0x00
BaseAddresses:
0x00000000 0x00000000 0x00000000 0x00000000 0x00002001 0x00000000
CIS = 0x00000000, SubVendorID = 0x8086, SubSystemID = 0x464C
ROMBaseAddress = 0x00000000
InterruptLine = 0x0B, InterruptPin = 0x02, MinGrant = 0x00, MaxLatency =
0x0
-------------------------------------------------------------------------------
PCIBUS!PCICfgCheckBARs: WARNING: No matching registry key was found for
placed device 0/31/3.
PCIBUS!PCICfgCheckBARs: Problems can result if the device is being
used while configuring PCIbus.
PCIBUS!PCICfgAllocMemSpace: Failed to place Device resource: Bus 0, Device
2, Function 0
PCIBUS!PCICfgAllocMemSpace: Failed to place Bridge resource: Bus 0, Device
28, Function 0
PCIBUS!PCICfgAllocMemSpace: Failed to place Device resource: Bus 0, Device
2, Function 0
PCIBUS!PCICfgAllocMemSpace: Failed to place Device resource: Bus 0, Device
2, Function 0
PCIBUS!PCICfgAllocMemSpace: Failed to place Device resource: Bus 0, Device
27, Function 0
PCIBUS!PCICfgAllocMemSpace: Failed to place Device resource: Bus 0, Device
29, Function 7
PCIBUS!PCICfgAllocIoSpace: Failed to place Bridge resource: Bus 0, Device
28, Function 0
PCIBUS!PCICfgAllocIoSpace: Failed to place Device resource: Bus 0, Device
29, Function 0
PCIBUS!PCICfgAllocIoSpace: Failed to place Device resource: Bus 0, Device
29, Function 1
PCIBUS!PCICfgAllocIoSpace: Failed to place Device resource: Bus 0, Device
29, Function 2
PCIBUS!PCICfgAllocIoSpace: Failed to place Device resource: Bus 0, Device
29, Function 3
PCIBUS!PCICfgAllocIoSpace: Failed to place Device resource: Bus 0, Device
31, Function 3
PCIBUS!PCICfgAllocIoSpace: Failed to place Device resource: Bus 0, Device 2,
Function 0
ATAPI:PCIConfig!DeviceConfig+(1)
ATAPI:PCIConfig!DeviceConfig+(1)
ATAPI:PCIConfig!DeviceConfig+(1)
ATAPI:PCIConfig!DeviceConfig+(1)
ATAPI:PCIConfig!DeviceConfig+(1)
ATAPI:PCIConfig!DeviceConfig+(1)
ATAPI:PCIConfig!DeviceConfig+(1)
ATAPI:PCIConfig!DeviceConfig+(1)
ATAPI:PCIConfig!DeviceConfig+(1)
ATAPI:PCIConfig!DeviceConfig+(1)
OSAXST1: <<< Unloading Module 'atapi.dll' (0x8395A778) at address
0xC0490000-0xC04AC000 in Process 'NK.EXE' (0x81783C80)
PCIBUS::OpenNonExistInstanceKey(Drivers\BuiltIn\PCI\Instance\PCI-PCI-BRIDGE1) returned open exist.continue search
PCIBUS::OpenNonExistInstanceKey(Drivers\BuiltIn\PCI\Instance\PCI-PCI-BRIDGE1) returned open exist.continue search
PCIBUS::OpenNonExistInstanceKey(Drivers\BuiltIn\PCI\Instance\PCI-PCI-BRIDGE2) returned open exist.continue search
PCIBUS::OpenNonExistInstanceKey(Drivers\BuiltIn\PCI\Instance\UHCI1) returned
open exist.continue search
PCIBUS::OpenNonExistInstanceKey(Drivers\BuiltIn\PCI\Instance\UHCI1) returned
open exist.continue search
PCIBUS::OpenNonExistInstanceKey(Drivers\BuiltIn\PCI\Instance\UHCI2) returned
open exist.continue search
PCIBUS::OpenNonExistInstanceKey(Drivers\BuiltIn\PCI\Instance\UHCI1) returned
open exist.continue search
PCIBUS::OpenNonExistInstanceKey(Drivers\BuiltIn\PCI\Instance\UHCI2) returned
open exist.continue search
PCIBUS::OpenNonExistInstanceKey(Drivers\BuiltIn\PCI\Instance\UHCI3) returned
open exist.continue search
PCIBUS::OpenNonExistInstanceKey(Drivers\BuiltIn\PCI\Instance\PCI-PCI-BRIDGE1) returned open exist.continue search
PCIBUS::OpenNonExistInstanceKey(Drivers\BuiltIn\PCI\Instance\PCI-PCI-BRIDGE2) returned open exist.continue search
PCIBUS::OpenNonExistInstanceKey(Drivers\BuiltIn\PCI\Instance\PCI-PCI-BRIDGE3) returned open exist.continue search
OSAXST1: >>> Loading Module 'atapi.dll' (0x8395A778) at address
0xC0490000-0xC04AC000 in Process 'NK.EXE' (0x81783C80)
ATAPI:PCIConfig!DeviceConfig+(2)
OSAXST1: <<< Unloading Module 'atapi.dll' (0x8395A778) at address
0xC0490000-0xC04AC000 in Process 'NK.EXE' (0x81783C80)
OSAXST1: >>> Loading Module 'atapi.dll' (0x8395A778) at address
0xC0490000-0xC04AC000 in Process 'NK.EXE' (0x81783C80)
ATAPI:PCIConfig!DeviceConfig+(3)
OSAXST1: <<< Unloading Module 'atapi.dll' (0x8395A778) at address
0xC0490000-0xC04AC000 in Process 'NK.EXE' (0x81783C80)
OSAXST1: >>> Loading Module 'atapi.dll' (0x8395A778) at address
0xC0490000-0xC04AC000 in Process 'NK.EXE' (0x81783C80)
ATAPI:PCIConfig!DeviceConfig+(2)
OSAXST1: <<< Unloading Module 'atapi.dll' (0x8395A778) at address
0xC0490000-0xC04AC000 in Process 'NK.EXE' (0x81783C80)
OSAXST1: >>> Loading Module 'atapi.dll' (0x8395A778) at address
0xC0490000-0xC04AC000 in Process 'NK.EXE' (0x81783C80)
ATAPI:PCIConfig!DeviceConfig+(3)
OSAXST1: <<< Unloading Module 'atapi.dll' (0x8395A778) at address
0xC0490000-0xC04AC000 in Process 'NK.EXE' (0x81783C80)
PCIBUS::OpenNonExistInstanceKey(Drivers\BuiltIn\PCI\Instance\ALI14531)
returned open exist.continue search

...

DEVICE!RegReadActivationValues
RegQueryValueEx(Drivers\BuiltIn\PCI\Instance\ALI14532\Device0\BusPrefix)
returned 2
Atapi!CDisk::ResetController> SRST failed
DEVICE!LaunchDevice: Init() failed for device 0xd04ac330
DEVICE!I_ActivateDeviceEx: couldn't activate: prefix DSK, index 1, dll
atapi.dll, context 0xd03acf68CHub(Root tier 0)::HubStatusChangeThread -
device attached on port 1
+CHub(Root tier 0)::AttachDevice - port = 1, fIsLowSpeed = 1
CHub(Root tier 0)::AttachDevice - status =
DEVICE_CONFIG_STATUS_OPENING_ENDPOINT0_PIPE, failures = 0
CHub(Root tier 0)::AttachDevice - status =
DEVICE_CONFIG_STATUS_USING_ADDRESS0, failures = 0
CHub(Root tier 0)::AttachDevice - status =
DEVICE_CONFIG_STATUS_RESET_AND_ENABLE_PORT, failures = 0

DeviceFolder::LoadDevice(Drivers\BuiltIn\PCI\Instance\ALI14532) last 291
TicksDEVICE!RegReadActivationValues
RegQueryValueEx(Drivers\BuiltIn\PCI\Instance\ALI14531\BusPrefix)
returned[NOTIFY] HandleSystemEvent 7 /ADD IDE1:
2

...

RE: ICH7 ATAPI driver issue by Werner

Werner
Thu Jul 31 01:48:11 PDT 2008

I have once adapted the atapi driver that shipped with CE6 to work with ICH4.
I assume it is the same for ICH7.
Before you make any changes, make a copy. Also don't make any changes in the
PUBLIC tree, instead copy the driver code to your BSP/PLATFORM tree and build
it from there.
You need to set "ProgIF" correct in 82371.reg (or its copy). It is used to
identify the PCI chipset during pci enumeration.
You probably need to make some changes in Block\Atapi\pcicfg.cpp function
ConfigRsrc (at least I did). By default the 82371 chipset used portIO to talk
to the hw. More recent chipsets work with memoryIO access. You have to tell
this to the driver when he tries to detect the chip.
Download the ICH7 datasheet fom Intel to find this info.

Success
Werner


RE: ICH7 ATAPI driver issue by spyke555

spyke555
Thu Jul 31 08:39:03 PDT 2008

> Before you make any changes, make a copy. Also don't make any changes in the
> PUBLIC tree, instead copy the driver code to your BSP/PLATFORM tree and build
> it from there.

No worries here, I've cloned my CECP BSP and have modified the platform.reg
there to pull in the modified ali1543.reg etc from this new platform
directory.

> You need to set "ProgIF" correct in 82371.reg (or its copy). It is used to
> identify the PCI chipset during pci enumeration.

Guess this brings up another question. The OS is recognising the IDE
interface as an ALI15431 device and not an I82371. If I'm reading this
correctly, changing this value should correct this.

Looking at the Intel datasheet I see an "Programing Interface" register with
a default value of 0x8A, the I82371.reg currently has "ProfIF" set to 0x80...
So I'll try changing that. Looks like bits 0 and 2 control the Legacy (I/O)
vs Native (Memory) addressing for the driver. With both set to legacy by
default (according to the datasheet) I should be okay for now... May also
need to adjust this in the BIOS.

I'll give this a go and let you know how it works out.

"Werner" wrote:

> I have once adapted the atapi driver that shipped with CE6 to work with ICH4.
> I assume it is the same for ICH7.
> You probably need to make some changes in Block\Atapi\pcicfg.cpp function
> ConfigRsrc (at least I did). By default the 82371 chipset used portIO to talk
> to the hw. More recent chipsets work with memoryIO access. You have to tell
> this to the driver when he tries to detect the chip.
> Download the ICH7 datasheet fom Intel to find this info.
>
> Success
> Werner
>

RE: ICH7 ATAPI driver issue by Werner

Werner
Thu Jul 31 08:57:20 PDT 2008

ProgIF=8A is same as ICH4. Looks OK.
I find it strange though that the chip is recognized as ALI1453, cause the
VendorID and DeviceID should be different. VendorId is 8086 for Intel.

If legacy mode is set to legacy (=portIO) than you are OK. But usually the
BIOS sets it to non legacy (I think that this is what "A" means in "8A"). It
might also not be enough to do this, if I remember well you need to change
some code in the driver to let it detect it properly. At least if it is not
working, pcicfg.cpp is the file you should be debugging.

Werner

RE: ICH7 ATAPI driver issue by spyke555

spyke555
Thu Jul 31 14:08:05 PDT 2008

> I find it strange though that the chip is recognized as ALI1453, cause the
> VendorID and DeviceID should be different. VendorId is 8086 for Intel.

You and me both... Do note that the i82371.reg does not include a DeviceID
field, only the Intel VendorID. I tried adding this and setting it to 27DF as
per the ICH7 information and this did not change anything, still detecting as
ali1543...

So I commented out the ALI1543 entries in platform.reg and then it tries to
initialise it as GenericIDE! So I commented out everything other than the
i82371 and it finally used these settings!!!

I was then getting the following (pertinent) messages at boot time:

...
Atapi!IDE_Init> Activating IDE/ATA device
Drivers\BuiltIn\PCI\Instance\I823711\Device0
DEVICE!RegReadActivationValues RegQueryValueExCHub(Root tier
0)::HubStatusChangeThread - port 2, change = 0x0001, status = 0x0501
(Drivers\BuiltIn\PCI\Instance\I823711\Device0\BusPrefix) returned 2
Atapi!CDisk::ResetController> Device is busy; 3 seconds remaining
Atapi!CDisk::ResetController> Device is busy; 2 seconds remaining
Atapi!CDisk::ResetController> Device is busy; 1 seconds remaining
Atapi!CDisk::ResetController> Timeout
DEVICE!LaunchDevice: Init() failed for device 0xd04adb10
DEVICE!I_ActivateDeviceEx: couldn't activate: prefix DSK, index 1, dll
atapi.dll, context 0xd03acf68
DeviceFolder::LoadDevice(Drivers\BuiltIn\PCI\Instance\I823711) last 3792
TicksDEVICE!RegReadActivationValues
RegQueryValueEx(Drivers\BuiltIn\PCI\Instance\PCI-PCI-BRIDGE4\DllName)
returned[NOTIFY] HandleSystemEvent 7 /ADD IDE1:
...

Changing the ProgIF=8F (Native mode) got me a little further:

...
Atapi!CDisk::ResetController> Device is ready
Atapi!CDisk::ResetController> SRST failed
...

Also tried messing with the BIOS settings and that did not help either...

> It might also not be enough to do this, if I remember well you need to
> change some code in the driver to let it detect it properly. At least if it
> is not working, pcicfg.cpp is the file you should be debugging.

Looks like there's no escaping it, I now need to dig into this one...

I've looked at the code here but to be honnest I'm not exactly sure what I'm
looking for. Plus the fact that the Ethernet port on this MB is not being
detected either is going to put a serious crimp on any kernel level debugging
I'm affraid...

You wouldn't be able to dig up the mods you made in the past would you? I'll
keep plugging away at this, but worried I may be in over my head already! ;-)

Thanks for the help so far though! At least you got me looking in the right
places!!!

"Werner" wrote:

> ProgIF=8A is same as ICH4. Looks OK.
>
> If legacy mode is set to legacy (=portIO) than you are OK. But usually the
> BIOS sets it to non legacy (I think that this is what "A" means in "8A"). It
> might also not be enough to do this, if I remember well you need to change
> some code in the driver to let it detect it properly. At least if it is not
> working, pcicfg.cpp is the file you should be debugging.
>
> Werner

RE: ICH7 ATAPI driver issue by Werner

Werner
Fri Aug 01 02:58:00 PDT 2008

In pcicfg.cpp function ConfigRsrc() I added the following lines (this is for
CE6)
ln261 :
// Disable this PCI device if it was enabled by BIOS (manipulating BAR
register while device is enabled can give unpredicted results)
PCIConfig_Write(Bus, Device, Function, 0x04, 0x00, sizeof(WORD));
DWORD d8 = PCIConfig_Read(Bus, Device, Function, 0x04);
DWORD d9 = PCIConfig_Read(Bus, Device, Function, 0x06);

...

// Check that the register has a valid format; it should have consecutive
high 1's and consecutive low 0's
SizeFound = (BaseAddress != 0) && (BaseAddress != 0xFFFFFFFF) && (((Size +
1) & Size) == 0);

Size +=1;

if (SizeFound) {
// Change start
// Register 10, 14, 18, 1C are now recognized as registers to set IDE I/O
registers when in native PCI mode
// Either set Reg to correct value (1F0, 3F4, 170, 174) or set Reg to 0 when
in legacy mode
BOOL bPlaced = FALSE;
switch (Offset)
{
case 0x10: Reg = 0x01F1; PCIConfig_Write(Bus, Device, Function, 0x10,
0x01F0, sizeof(DWORD)); bPlaced = TRUE; break;
case 0x14: Reg = 0x03F5; PCIConfig_Write(Bus, Device, Function, 0x14,
0x03F4, sizeof(DWORD)); bPlaced = TRUE; break;
case 0x18: Reg = 0x0171; PCIConfig_Write(Bus, Device, Function, 0x18,
0x0170, sizeof(DWORD)); bPlaced = TRUE; break;
case 0x1C: Reg = 0x0375; PCIConfig_Write(Bus, Device, Function, 0x1C,
0x0374, sizeo