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

Sept/Oct 2019 Issue of The NT Insider available


Download PDF here: http://insider.osr.com/2019/ntinsider_2019_01.pdf

It’s a particularly BIG issue, too: 40 pages of technical goodness, ranging from WDF to Minifilters. Check it out.
Before Posting...
Please check out the Community Guidelines in the Announcements and Administration Category.

Message signaled interrupt with IoConnectInterruptEx

2»

Comments

  • tatuotatuo Member Posts: 48

    Dear Mr. viscarola

    Thank you very much.
    I am sorry replying to you so late due to the weekend days.
    Thank you for giving us such a platform to discuss our problem. Thank you for giving me such a chance.
    I feel honored to suggest a particular day to give our respect to Mr. Roberts.
    I think he is worthy.
    Because I am new to this forum, please tell me how to take the procedure.
    How about today?

    Yours sincerely.

    Tatuo

  • tatuotatuo Member Posts: 48

    Dear Anton

    Thank you for your advice.
    I think I had better open another thread to discuss problems that occur when data are sent to network.
    ...

    Thanks again.

  • tatuotatuo Member Posts: 48

    Dear Mr. Pavel_A

    Thank you very much for your advice.
    You are right.
    But I must send data which are produced from a program running on windows.
    ...
    Thanks again.

  • tatuotatuo Member Posts: 48

    Dear Mr. Roberts

    >

    Do you have the ability to modify the BIOS in your machine? If you have the source code, then you might be able to modify the DSDT in the BIOS to add >a device for the HPET that you can provide an INF for. Such a driver would be assigned the appropriate interrupt by the system. No hackery.

    >
    asl.exe can be used to retrieve the DSDT.
    ASL file can even been generated using ACPIGenFx.
    The modified DSDT can be stored in registry to test.

    https://docs.microsoft.com/ja-jp/windows-hardware/drivers/bringup/microsoft-asl-compiler

    But I failed with the test.
    First, I set the system to test mode.
    bcdedit /set TESTSIGNING ON
    I retrieved the current DSDT with below command.
    asl.exe /tab=DSDT
    It gave me a dsdt.asl.
    When I compiled it, so many errors were made that were beyond my ability to fix.

    Then I decided to test with the sample asl file GpioSampleKMDF.asl under simdevice.
    It succeeded to be loaded to registry.

    But it did not appeare in the device manager of windows.

    Last, I generated an asl file myself with below code.
    static void Main(string[] args)
    {

            x86Platform Platform = Platforms.Createx86Platform(
                OEMID: "MSFT",
                OEMTableID: "EDK2",
                CreatorID: "MSFT",
                Revision: 1, FileName: "DSDT"
                );
    
            GenericDevice Gen3 = Platform.AddGenericDevice("Tim1", "APIC23", "PNP0003", 1);
            Gen3.AddInterrupt(InterruptType.Edge, InterruptActiveLevel.ActiveHigh, SharingLevel.Exclusive, 23);
    
            Platform.WriteAsl();
        }
    

    It can be loaded but it did not appear in the device manager of windows too.
    Who can give me some hints?
    Help me!

    Thanks in advance.

  • Tim_RobertsTim_Roberts Member - All Emails Posts: 13,068
    via Email
    tatuo wrote:
    > When I compiled it, so many errors were made that were beyond my ability to fix.

    Yes, this happens.  The Intel and Microsoft ASL compilers use different
    rules, and that allows invalid things to slip in.  Most of the errors
    are probably the same; you'll need to do some web searching to find
    them.  There are lots of people hacking their DSDTs in the Linux world,
    and those posts may provide some tops for you.


    > Then I decided to test with the sample asl file GpioSampleKMDF.asl under simdevice.
    > It succeeded to be loaded to registry.

    This is a bit dangerous.  When you put a DSDT in the registry you are
    REPLACING the DSDT provided by the BIOS.  If you don't have all of the
    entries in the original DSDT, that is an excellent way to turn your
    computer into a brick.  You may need to use "last known good" or "safe
    mode" to get rid of it.

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

  • Peter_Viscarola_(OSR)Peter_Viscarola_(OSR) Administrator Posts: 7,413

    Better to add you unique devices to the SSDT using this method. Any existing SSDT will be shorter, for sure, than the DSDT. See https://docs.microsoft.com/en-us/windows-hardware/drivers/bringup/generate-acpi-tables-by-using-acpigenfx

    Peter

    Peter Viscarola
    OSR
    @OSRDrivers

  • tatuotatuo Member Posts: 48

    Dear Mr. Viscarola

    Thank you very much.
    I am using the way you told me today.
    But the device cannot appear in the device manager if just this produced file is used without the contend retrieved from windows with iasl or asl command. If the produced file is attached to the file retrieved from system, it workes fine except for strange view of some device.
    Anyway, I can communicate to the new device now.
    I can verify the resoure information sent to EVT_WDF_DEVICE_PREPARE_HARDWARE.
    u.Interrupt.Vector is 0xa0
    u.Interrupt.Level is 0x0a
    u.Interrupt.Affinity is 0x0f

    But when I install the driver, computer crushes.
    The source code is as following.

    NTSTATUS InterruptPrepareHardware(
    In WDFDEVICE Device,
    In WDFCMRESLIST ResourcesRaw,
    In WDFCMRESLIST ResourcesTranslated
    )
    {
    PCM_PARTIAL_RESOURCE_DESCRIPTOR descriptor;
    PDEVICE_CONTEXT deviceContext;
    .................
    PAGED_CODE();
    deviceContext = WdfObjectGet_DEVICE_CONTEXT(Device);
    ..........................

          status = IoConnectInterrupt(
                &deviceContext->InterruptObject,
                InterruptServiceRoutine,
                deviceContext,
                NULL,
                descriptor->u.Interrupt.Vector,
                (KIRQL)descriptor->u.Interrupt.Level,
                (KIRQL)descriptor->u.Interrupt.Level,
                LevelSensitive,
                FALSE,
                descriptor->u.Interrupt.Affinity,
                FALSE
            );
         return STATUS_SUCCESS;
    
    ...................
    

    }
    InterruptServiceRoutine does nothing now.
    I am searching for the cause...........

    Best regard.

    Tatuo

  • tatuotatuo Member Posts: 48

    Hi

    When I use below code to connect interrupt in EVT_WDF_DEVICE_PREPARE_HARDWARE, error code 0xc000000d is returned, meaning "An invalid parameter was passed to a service or function".

            RtlZeroMemory(&InterruptParams, sizeof(IO_CONNECT_INTERRUPT_PARAMETERS));
            InterruptParams.Version = CONNECT_LINE_BASED;
            InterruptParams.LineBased.PhysicalDeviceObject = WdfDeviceWdmGetDeviceObject(Device);
            InterruptParams.LineBased.InterruptObject = &deviceContext->InterruptObject;
            InterruptParams.LineBased.ServiceRoutine = InterruptServiceRoutine;
            InterruptParams.LineBased.ServiceContext = deviceContext;
            InterruptParams.LineBased.SpinLock = NULL;
            InterruptParams.LineBased.SynchronizeIrql = 0;
            InterruptParams.LineBased.FloatingSave = FALSE;
    
            status = IoConnectInterruptEx(&InterruptParams);
    

    What is the problem?

    Tatuo

  • tatuotatuo Member Posts: 48

    Hi

    When I use below code to connect interrupt to my ISR in EVT_WDF_DEVICE_PREPARE_HARDWARE, no error occurs.
    But I do not know if interrupt can be triggered yet, because I have not connected it to HPET.....

       WDF_INTERRUPT_CONFIG_INIT(&InterruptConfiguration,
                InterruptServiceRoutine,
                DrvInterruptDpc);
    
            InterruptConfiguration.EvtInterruptEnable = TimerInterruptEnable;
            InterruptConfiguration.EvtInterruptDisable = TimerInterruptDisable;
            InterruptConfiguration.InterruptTranslated = descriptor;
            InterruptConfiguration.InterruptRaw = WdfCmResourceListGetDescriptor(ResourcesRaw, i);
    
            InterruptConfiguration.AutomaticSerialization = TRUE;
    
            status = WdfInterruptCreate(Device,
                &InterruptConfiguration,
                WDF_NO_OBJECT_ATTRIBUTES,
                &deviceContext->WdfInterrupt);
    

    Thanks.

    Tatuo

  • Tim_RobertsTim_Roberts Member - All Emails Posts: 13,068

    Well, that's the next step.

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

  • tatuotatuo Member Posts: 48

    Hello, dear friends

    From that, I got both HPET and ioAPIC worked well individually.
    But I failed in getting them talked to each other. The ISR could not be called.

    First, the HPET side:
    I use timer0 and set it to work in Periodic Mode.
    The General Configuration Register is set as 0x01. ( Allow to run and interrupt, diable legacyreplacement route).
    I can read the value of Configuration and Capabilities Register. It is 0x00f000000000ad3c,
    which means
    Interrupt Type: edge triggered
    Interrupt Enable: Yes
    Timer Type: periodic interrupt
    Periodic Interrupt Capable: YES
    Timer Size: 64bit
    32-bit Mode: YES
    Interrupt Route: 22pin
    FSB Interrupt Enable: NO
    FSB Interrupt Delivery: available.

    I can see the Comparator Value Register steps up by the value last written.
    ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
    Then, the ioAPIC side:
    Because I used 22nd pin in my asl file,

       Device (TMR1)
        {
            Name (_HID, "HPET0016")
            Name (_CID, "ACPI\SofTimer")
            Name (_UID, 0x1)
            Method (_STA)
            {
                Return(0xf)
            }
            Method (_CRS, 0x0, NotSerialized) {
                Name (RBUF, ResourceTemplate () {
                    Interrupt(ResourceConsumer, Edge, ActiveHigh, Exclusive) { 0x16 }
                })
                Return(RBUF)
            }
        }
    

    I noticed that the 22nd I/O Redirection Table entry register is changed to 0xf000000000009a0 by OS.
    which means
    Interrupt Vector: a0
    Delivery Mode:001(Lowest priority)
    Destination Mode: Logical Mode
    Delivery Status: IDLE
    Interrupt Input Pin Polarity: High active
    Trigger Mode: Edge sensitive
    Interrupt Mask: Not masked
    These parameters can also be confirmed in EVT_WDF_DEVICE_PREPARE_HARDWARE by PCM_PARTIAL_RESOURCE_DESCRIPTOR.

    I also noticed that the Delivery Status bit of I/O Redirection Table entry register stayed IDLE.
    And the ISR is not called.

    I can see IRQ22 has been allocated to my device from device manager.

    Is the 22nd pin of HPET not connected(mapped) to the IRQ22 of ioAPIC? or is there something I have not set?

    I have searched for the cause for three days and found no way out.
    Help me!

  • Tim_RobertsTim_Roberts Member - All Emails Posts: 13,068
    via Email
    On May 27, 2019, at 5:34 PM, tatuo wrote:
    >
    > From that, I got both HPET and ioAPIC worked well individually.
    > But I failed in getting them talked to each other. The ISR could not be called.

    Are you absolutely sure that HPET timer 1 is not already in use by the operating system?


    > Interrupt Route: 22pin
    > FSB Interrupt Enable: NO
    > FSB Interrupt Delivery: available.

    What does "22pin" mean? Does that mean pin 22 of the HPET chip? Do you actually know what IRQ that's tied to? And don't you need the interrupt to be enable?

    > Because I used 22nd pin in my asl file,
    >
    > Device (TMR1) { Name (_HID, "HPET0016") Name (_CID, "ACPI\SofTimer") Name (_UID, 0x1) Method (_STA) { Return(0xf) } Method (_CRS, 0x0, NotSerialized) { Name (RBUF, ResourceTemplate () { Interrupt(ResourceConsumer, Edge, ActiveHigh, Exclusive) { 0x16 } }) Return(RBUF) } }

    OK, but how did you pick IRQ 0x16?


    > Is the 22nd pin of HPET not connected(mapped) to the IRQ22 of ioAPIC? or is there something I have not set?

    Well, right, you have to know this. You can't assume that a pin number has anything to do with IRQ number. Do you have schematics for the board?

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

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

  • tatuotatuo Member Posts: 48

    Dear Mr. Roberts

    Thank you for your help.
    >

    Are you absolutely sure that HPET timer 1 is not already in use by the operating system?

    >
    Yes, I have confirmed it before I use it.

    >

    What does "22pin" mean?

    >
    That means connecting to IRQ22.

    >

    Do you actually know what IRQ that's tied to?

    >
    It is written in the specification of HPET.

    >

    And don't you need the interrupt to be enable?

    >
    I enable it in the Configuration and Capabilities Register. (The third bit is it.)

    >

    OK, but how did you pick IRQ 0x16?

    >
    I found it is available to use but is not used yet. It can be confirmed by the Configuration and Capabilities Register.

    >

    You can't assume that a pin number has anything to do with IRQ number. Do you have schematics for the board?

    >
    I have not the schematics. But I read the specification of HEPT and ioAPIC. And I read the registers of HEPT and ioAPIC.

    yours sincerely.

    Tatuo

Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Upcoming OSR Seminars
Writing WDF Drivers 21 Oct 2019 OSR Seminar Space & ONLINE
Internals & Software Drivers 18 Nov 2019 Dulles, VA
Kernel Debugging 30 Mar 2020 OSR Seminar Space
Developing Minifilters 27 Apr 2020 OSR Seminar Space & ONLINE