[wdtl] Re: [wdtl-patches] questions
Status: Beta
Brought to you by:
andreyvolkov
From: Andrey V. <and...@us...> - 2002-12-01 21:40:59
|
Hello, Rick. First look at DDK examples ( in src/general dir, especially toaster example), you could certainly, look in another src subdirs, but, thanks M$ driver programmers, I feel a doubt it will be helpful (ex. floppy driver are placed in ONE floppy.c file wich size is ~200K :((, try understand what it will be do and where ;) AND PLEASE, SEND REPLY TO wdt...@li... Rick wrote: RP> Okay ... driver needs to interact with an 8250, 16450 or 16550 UART but RP> in unusual way. RP> 1. I need to allocate an IRQ (3 or 4). RP> 2. I need to install ISR for above IRQ. RP> 3. the IRQ might be shared with other devices RP> (COM1 & COM3 on IRQ4, COM2 & COM4 on IRQ3). RP> 4. need to allocate memory for a FIFO to record incoming data. See later in this mail RP> 5. device I/O handlers to read data from FIFO and return data to the RP> application. RP> 7. may also want to support send/receive characters over TxD/RxD (but no RP> hardware flow control since those signals are being used for something RP> else). On Driver Level call new/delete or malloc/free or ExAllocatePool/ExFreePool (last pair will be called by new and malloc stuff). On user land app. call WriteFile/ReadFile or DeviceIoControl to access of your queue. RP> 6. ioctl handlers for optional stuff. If you will use wdtlwiz then it will be generated automatically on fifth step and placed in ioctl_def.h. RP> Also, I have an example for a WDM style RS485 driver written in C that is RP> very close to what I want. RP> 1. how to allocate an IRQ/IRP ? From WDTLs point of view: in your class declared like this class YourDevClass: public CWdmFunctionDevice<YourDevClass> or class YourDevClass: public CNtDevice<YourDevClass> { ..... }; declare STATIC function like this: class YourDevClass: public CWdmFuncDevice<YourDevClass> { ..... protected: KINTERRUPT InterruptObject; static BOOLEAN YourInterruptFn( IN PKINTERRUPT pInterrupt, IN YourDevClass *pThis ); }; Then, when you will call IoConnectInterrupt in your StartDevice routine or in Initialize Routine ( if you will write not PnP driver, in this case you also must call IoReportResourceForDetection before) point this functions as ServiceRoutine parameter and 'this' as ServiceContext parameter. Vector parameter will be 3 or 4 (depend wich UART you will use). Also interrupt resource must be flagged with CmResourceShareShared. RP> 2. how to release IRQ/IRP ? When Windows call ISR it will masking 80.. interrupt controller (forget real number, whell wish io port number is 0x21) before and enable again after your ISR return TRUE. RP> 3. how to share IRQ/IRP with other driver? First your driver MUST start BEFORE standard serial driver and claim your resources (io ports and interrups), else your ISR never will be called. Second you may simply return FALSE in your ISR and this interrupt will be chained to a next driver who have attached ISR to this interrupt (standard serial driver in your case) or to default handler which does nothing (ergo you will block interrupt forever). RP> Permit me some time to review what I have so that I can come back with RP> more specific questions. Will wait... -- Regards, Andrey Volkov |