Driver Development Kit (DDK)

cancel
Showing results for 
Search instead for 
Did you mean: 

MITE init in Windows driver -- stumped.

Hi, I am writing a Windows WDM driver for the 6503. I have written a function to initalize the MITE, but it does not ssem to work (nothing happens when I write to (remapped with MmMapIoSpace()) BAR1 registers).

Please take a look at this code:

NTSTATUS initMite(IN PCM_RESOURCE_LIST raw,
IN PCM_RESOURCE_LIST translated)
{
ULONG physicalAddressBAR1 = 0;
PULONG translatedAddressMITE;
PCM_PARTIAL_RESOURCE_LIST list;
PCM_PARTIAL_RESOURCE_DESCRIPTOR resource;
BOOLEAN bar0;
int i, numResources;
size_t len;

/* First: Get BAR1 physical address */
bar0 = TRUE;
list = &raw->List[0].PartialResourceList;
resource = list->PartialDescriptors;
numResources = list->Count;

for (i = 0; i < numResources; i++, resource++) {
if (resource->Type == CmResourceTypeMemory) {
if (bar0 == TRUE) {
bar0 = FALSE;
} else {
[b]physicalAddressBAR1 = resource->u.Memory.Start.LowPart;[/b]
break;
}
}
}

logEventWithDumpData(MSG_PHYS_BAR1, NULL, &physicalAddressBAR1, 1, NULL, 0);

/* Second: Get MITE translated address */
bar0 = TRUE;
list = &translated->List[0].PartialResourceList;
resource = list->PartialDescriptors;
numResources = list->Count;

for (i = 0; i < numResources; i++, resource++) {
if (resource->Type == CmResourceTypeMemory) {
if (bar0 == TRUE) {
bar0 = FALSE;
len = resource->u.Memory.Length;
[b]translatedAddressMITE = (PULONG)MmMapIoSpace(resource->u.Memory.Start,
resource->u.Memory.Length,
MmNonCached);[/b]
if (translatedAddressMITE == NULL) {
logEvent(MSG_MAPPED_NULL, NULL, NULL, 0);
} else {
ULONG data[2] = {(ULONG)translatedAddressMITE, physicalAddressBAR1};
logEventWithDumpData(MSG_INIT_MITE, NULL, data, 2, NULL, 0);
[b]WRITE_REGISTER_ULONG(translatedAddressMITE + 0xc0,
(physicalAddressBAR1 & 0xffffff00L) | 0x80);[/b]
}
break;
}
}
}

if (translatedAddressMITE != NULL)
MmUnmapIoSpace(translatedAddressMITE, len);

if (translatedAddressMITE == NULL)
return STATUS_UNSUCCESSFUL;
else
return STATUS_SUCCESS;
}


What could be going wrong?
0 Kudos
Message 1 of 3
(8,869 Views)
Forget about it. It was a stupid pointer arithmetic mistake ((long *)x + y != (char *)x + y) on my behalf 😕
0 Kudos
Message 2 of 3
(8,868 Views)

Although this is an old post, can I get similar help?

 

I used this code to to remap the PCI 6503 addresses, and I also am not getting any result.

 

I assume the error you experienced is:

   WRITE_REGISTER_ULONG(translatedAddressMITE + 0xc0,(physicalAddressBAR1 & 0xffffff00L) | 0x80);

And it was fixed with this, so the offset is in bytes, not longs :

  WRITE_REGISTER_UCHAR(((unsigned char *)translatedAddressMITE) + 0xc0,(physicalAddressBAR1 & 0xffffff00L) | 0x80);

 

 

Then I capture the translated addresses for BAR1 with:

translatedBAR1 = (unsigned char *) MmMapIoSpace(resource->u.Memory.Start,
                resource->u.Memory.Length,MmNonCached);

 

And try to set PORTA  with WRITE_REGISTER_UCHAR(translatedBAR1 , 0xff  or  0x00 );

 

But I still don't get any output.  Can you offer any other advice?

 

-Scotty

0 Kudos
Message 3 of 3
(6,595 Views)