Windows System Software -- Consulting, Training, Development -- Unique Expertise, Guaranteed Results

Home NTDEV

Before Posting...

Please check out the Community Guidelines in the Announcements and Administration Category.

More Info on Driver Writing and Debugging


The free OSR Learning Library has more than 50 articles on a wide variety of topics about writing and debugging device drivers and Minifilters. From introductory level to advanced. All the articles have been recently reviewed and updated, and are written using the clear and definitive style you've come to expect from OSR over the years.


Check out The OSR Learning Library at: https://www.osr.com/osr-learning-library/


memory mapping in ISA device driver (non PnP)

MohanMohan Member Posts: 7

Hi,

I am new to windows driver development.
In my project we are using PCA-6029 (i7 with H110 chipset) SBC. It supports windows 10 IOT enterprise LTSC, we have to develop a ISA device driver to access custom ISA board (slave). ISA board is a memory module, we need to access the memory (0xcc000 - 0xcc799) from SBC (PCA 6029) through ISA bus.

I have developed basic driver by referring Microsoft site. I can able to create driver object and device object. Now I have faced issue in memory mapping section (EvtDevicePrepareHardware ()).

In driver source:

DriverEntry()
{
WdfDriverCreate(); -> driver obj created successfully.
}

isaEvtDeviceAdd()
{
WDF_PNPPOWER_EVENT_CALLBACKS_INIT(&pnppowercallback);
pnppowercallback.evtdevicepreparehardware = isaEvtdevicepreparehardware; ->set callback functions
WdfDeviceInitSetPnpPowerEventCallbacks (DeviceInit, &pnppowercallback) ->register the pnp callbacks.
WdfDeviceCreate(); -> device obj created successfully.
}

NTSTATUS isaEvtdevicepreparehardware (WDFDEVICE Device,
WDFCMRESLIST Resources,
WDFCMRESLIST ResourcesTranslated)
{
KdPrint(("WdfCmResourceListGetCount=%d\n", WdfCmResourceListGetCount(ResourcesTranslated)));

 for (i = 0; i < WdfCmResourceListGetCount(ResourcesTranslated); i++) 
 {

 desc = WdfCmResourceListGetDescriptor(ResourcesTranslated, i);

 switch (desc->Type) 
 {

 case CmResourceTypeMemory:
 desc->u.Port.Start.LowPart,
 desc->u.Port.Length));
 DevExt->RegsBase = MmMapIoSpace(desc->u.Memory.Start, desc->u.Memory.Length, MmNonCached);
 break;

 case CmResourceTypePort:
 desc->u.Port.Start.LowPart,
 desc->u.Port.Length));
 break;

default:
KdPrint(("default!!\n"));
break;
}
}

}

Here, isaEvtdevicepreparehardware is getting triggered, but WdfCmResourceListGetCount = 0, that means PNP manager couldn't find any resources.

My doubts:

  1. since our custom ISA board is non PNP device, then how to specify hardware resources to PNPmanager ?

  2. How our driver can identify the ISA board ?, Which hardware ID need to use in our INF file. (custom board doesn't have vendor ID and device ID). ?

  3. In SBC (pca 6029) ISA bus is connected through LPC interface ( processor - LPC - - ISA). In Device manager I can see the "System devices > Intel(R) 100 Series/C230 Series Chipset Family LPC Controller (H110) - A143” device, it has msisadrv.sys driver. Shall we consider this as ISA bus driver ?
    whether our driver (function driver) need to talk with bus driver for resource allocation ?

  4. How to conform our ISA board has connected and bus driver has started?

I have bit confused, Please help me to solve this issue.

Thanks in Advance,
Mohan.

.

Comments

  • Don_BurnDon_Burn Member - All Emails Posts: 1,764

    Look at the LogConfig directive of an INF file https://docs.microsoft.com/en-us/windows-hardware/drivers/install/inf-logconfig-directive This is how you make a non-PNP device's hardware known so it can be dealt with a driver written for PnP.

  • MohanMohan Member Posts: 7

    Thanks for your quick reply !!!

    Need one more clarification:

    1. How our KMDF driver can identify the ISA board ? we need to use any specific hardware ID ? since custom board doesn't have vendor ID and device ID.
    2. ISA is connected through LPC interface, whether we need to use LPC hardware ID
      (PCI\VEN_8086&DEV_A082&SUBSYS_14621043&REV_20) ?

    with Thanks
    mohan

  • Tim_RobertsTim_Roberts Member - All Emails Posts: 14,411

    If this is for an enclosed embedded system, and not for general release, then you might consider throwing out all of the PnP concerns and just do hardcoded mapping of your memory space. Are you sure the device exists at physical 0xCC000? Does the BIOS know about your device?

    Tim Roberts, [email protected]
    Providenza & Boekelheide, Inc.

  • MohanMohan Member Posts: 7

    Thanks for asking!!!

    Yeah this is an enclosed embedded system. (SBC card and ISA card are connected through backplane).

    1. **Are you sure the device exists at physical 0xCC000? **
      -> the custom ISA board is memory module of 2KB (0xcc000 -0xcc799), this memory range we used in slave side. But i don't know where it mapped in SBC side. How can can I find the physical memory of ISA interface?.

    2.Does the BIOS know about your device?
    ->This also I am not sure, while installing OS in BIOS section didn't have ISA peripheral initialization. How can I confirm BIOS knows about ISA device? (since internally it is connected through LPC interface).

    with Thanks,
    Mohan.

  • Tim_RobertsTim_Roberts Member - All Emails Posts: 14,411

    this memory range we used in slave side. But i don't know where it mapped in SBC side.

    In ISA, the board claims its own address. The addresses aren't assigned by anyone else. In many cases, there was a set of DIP switches to select between several options. If you've used CC000 before, then that's probably it forever and ever. ;)

    My previous suggestion still stands. I suggest you write a non-PnP driver that unconditionally maps that address and see if you can access the card. That's going to be the least energy solution.

    Tim Roberts, [email protected]
    Providenza & Boekelheide, Inc.

  • Peter_Viscarola_(OSR)Peter_Viscarola_(OSR) Administrator Posts: 9,046

    you might consider throwing out all of the PnP concerns and just do hardcoded mapping of your memory space

    As rare as it may be, I strenuously object to Mr. Roberts’ suggestion. Just put the memory resource in the LogConfig, and save future maintainers the grief of figuring out your logic. It’ll take you longer to write the comment to explain to future maintainers that yes, you REALLY do want to access these hard-coded memory addresses and, yes, you KNOW that’s not the right way to write a typical Windows drivers but, yes, this works in this case.

    Why go through that? Put the resource where Gxd himself intended it to be, use the EvtDevicePrepareHardware callback that you’ve already written and be done with it.

    Peter

    Peter Viscarola
    OSR
    @OSRDrivers

  • MohanMohan Member Posts: 7

    Thanks for your suggestions!!!

    Now I have updated [logconfig section] section in INF file. I have specified the memory range, But still I am not getting any resource assignation.

    Like before, isaEvtdevicepreparehardware is getting triggered, but WdfCmResourceListGetCount = 0.

    In INF file,

    [sampleHW_driver_Device.LogConfigOverride]|
    [sampleHW_driver_Device.NT.LogConfigOverride]|
    [sampleHW_driver_Device.ntx86.LogConfigOverride]|
    [sampleHW_driver_Device.ntarm64.LogConfigOverride]|
    [sampleHW_driver_Device.NTamd64.LogConfigOverride]
    LogConfig=sampleHW_driver_Device.override0

    [sampleHW_driver_Device.override0]
    MemConfig=0xcc000-0xcc799

    1. Anything I have missed ?

    MS site they mentioned:
    Note If you are building a universal or mobile driver package, this directive is not valid. See Using a Universal INF File.

    1. Whether I have made mistake in building as universal driver, If then how to build for non universal?

    2. Need to update anything in registry side?

    with Thanks,
    Mohan.

  • Mark_RoddyMark_Roddy Member - All Emails Posts: 4,576

    Drop the 'Ox' from the memconfig spec, as in CC000-CC799.

  • MohanMohan Member Posts: 7

    Thanks for your suggestions!!!
    I updated as @Mark_Roddy suggested, But still I am not getting any resource assignation.
    Like before, isaEvtdevicepreparehardware is getting triggered, but WdfCmResourceListGetCount = 0.

    below I have added in INF file.
    .INF file:

    [sampleHW_driver_Device.LogConfigOverride]|
    [sampleHW_driver_Device.NT.LogConfigOverride]|
    [sampleHW_driver_Device.ntx86.LogConfigOverride]|
    [sampleHW_driver_Device.ntarm64.LogConfigOverride]|
    [sampleHW_driver_Device.NTamd64.LogConfigOverride]
    LogConfig=sampleHW_driver_Device.override0

    [sampleHW_driver_Device.override0]
    MemConfig=CC000-CC799

    Doubts:
    1. Our ISA slave (custom board) doesn't have hardware id, then how the driver knows the assignation of resource (memory mapping (CC000-CC799) to that particular device (ISA slave)?
    2. still now the memory range is free (device manager->resources), how we can tell the driver to map that memory to this non pnp device?

    with Thanks,
    Mohan.

  • Peter_Viscarola_(OSR)Peter_Viscarola_(OSR) Administrator Posts: 9,046
    edited July 19

    Having JUST been through this in another thread, you might try using the FactDef in addition to (or instead of) LogConfig.

    Peter

    Peter Viscarola
    OSR
    @OSRDrivers

Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. Sign in or register to get started.

Upcoming OSR Seminars
OSR has suspended in-person seminars due to the Covid-19 outbreak. But, don't miss your training! Attend via the internet instead!
Kernel Debugging 30 January 2023 Live, Online
Developing Minifilters 20 March 2023 Live, Online
Writing WDF Drivers TBD 2023 Live, Online
Internals & Software Drivers 17 April 2023 Live, Online