Hello,
?
I want to get the base address of PCI memory address space.?Is it possible to do it like this: So when the io manager send IRPMJ_PNP –> IRP_MN_START_DEVICE, i get the the stack->Parameters.startdevice.allocatedResourcesTranslated. And then i see the cmResourceTypeMemory case. And save the u.Memory.Start.
If it is possible like that, but why i couldn’t get cmResourceTypeMemory? I found CmResourceTypePort and other.
?
Regards,
Sofian
Are you saying IRP_MN_START_DEVICE does not give you the memory, or are you
trying to find this some other way?
–
Don Burn (MVP, Windows DKD)
Windows Filesystem and Driver Consulting
Website: http://www.windrvr.com
Blog: http://msmvps.com/blogs/WinDrvr
“sahrizal sofian” wrote in message
news:xxxxx@ntdev…
Hello,
I want to get the base address of PCI memory address space. Is it possible
to do it like this: So when the io manager send IRPMJ_PNP –>
IRP_MN_START_DEVICE, i get the the
stack->Parameters.startdevice.allocatedResourcesTranslated. And then i see
the cmResourceTypeMemory case. And save the u.Memory.Start.
If it is possible like that, but why i couldn’t get cmResourceTypeMemory? I
found CmResourceTypePort and other.
Regards,
Sofian
Information from ESET NOD32 Antivirus, version of virus signature
database 4417 (20090911)
The message was checked by ESET NOD32 Antivirus.
http://www.eset.com
Information from ESET NOD32 Antivirus, version of virus signature database 4417 (20090911)
The message was checked by ESET NOD32 Antivirus.
http://www.eset.com
This is what i want to ask. From my understanding, The base address should be on the cmResourceTypeMemory case right? But, when i debug it, there is no PartialDescriptors with type of cmResourceTypeMemory.
— On Fri, 9/11/09, Don Burn wrote:
From: Don Burn
Subject: Re:[ntdev] Find base address of PCI memory address space
To: “Windows System Software Devs Interest List”
Date: Friday, September 11, 2009, 12:14 PM
Are you saying IRP_MN_START_DEVICE does not give you the memory, or are you
trying to find this some other way?
–
Don Burn (MVP, Windows DKD)
Windows Filesystem and Driver Consulting
Website: http://www.windrvr.com
Blog: http://msmvps.com/blogs/WinDrvr
“sahrizal sofian” wrote in message
news:xxxxx@ntdev…
Hello,
I want to get the base address of PCI memory address space. Is it possible
to do it like this: So when the io manager send IRPMJ_PNP –>
IRP_MN_START_DEVICE, i get the the
stack->Parameters.startdevice.allocatedResourcesTranslated. And then i see
the cmResourceTypeMemory case. And save the u.Memory.Start.
If it is possible like that, but why i couldn’t get cmResourceTypeMemory? I
found CmResourceTypePort and other.
Regards,
Sofian
Information from ESET NOD32 Antivirus, version of virus signature
database 4417 (20090911)
The message was checked by ESET NOD32 Antivirus.
http://www.eset.com
Information from ESET NOD32 Antivirus, version of virus signature database 4417 (20090911)
The message was checked by ESET NOD32 Antivirus.
http://www.eset.com
—
NTDEV is sponsored by OSR
For our schedule of WDF, WDM, debugging and other seminars visit:
http://www.osr.com/seminars
To unsubscribe, visit the List Server section of OSR Online at http://www.osronline.com/page.cfm?name=ListServer
Well the obvious question is does the device have memory? You can have a
PCI device without memory.
–
Don Burn (MVP, Windows DKD)
Windows Filesystem and Driver Consulting
Website: http://www.windrvr.com
Blog: http://msmvps.com/blogs/WinDrvr
“sahrizal sofian” wrote in message
news:xxxxx@ntdev…
> This is what i want to ask. From my understanding, The base address should
> be on the cmResourceTypeMemory case right? But, when i debug it, there is
> no PartialDescriptors with type of cmResourceTypeMemory.
>
> — On Fri, 9/11/09, Don Burn wrote:
>
>
> From: Don Burn
> Subject: Re:[ntdev] Find base address of PCI memory address space
> To: “Windows System Software Devs Interest List”
> Date: Friday, September 11, 2009, 12:14 PM
>
>
> Are you saying IRP_MN_START_DEVICE does not give you the memory, or are
> you
> trying to find this some other way?
>
>
> –
> Don Burn (MVP, Windows DKD)
> Windows Filesystem and Driver Consulting
> Website: http://www.windrvr.com
> Blog: http://msmvps.com/blogs/WinDrvr
>
>
> “sahrizal sofian” wrote in message
> news:xxxxx@ntdev…
> Hello,
>
> I want to get the base address of PCI memory address space. Is it possible
> to do it like this: So when the io manager send IRPMJ_PNP –>
> IRP_MN_START_DEVICE, i get the the
> stack->Parameters.startdevice.allocatedResourcesTranslated. And then i see
> the cmResourceTypeMemory case. And save the u.Memory.Start.
> If it is possible like that, but why i couldn’t get cmResourceTypeMemory?
> I
> found CmResourceTypePort and other.
>
> Regards,
> Sofian
>
>
>
>
>
> Information from ESET NOD32 Antivirus, version of virus
> signature
> database 4417 (20090911)
>
> The message was checked by ESET NOD32 Antivirus.
>
> http://www.eset.com
>
>
>
>
> Information from ESET NOD32 Antivirus, version of virus
> signature database 4417 (20090911)
>
> The message was checked by ESET NOD32 Antivirus.
>
> http://www.eset.com
>
>
>
>
>
> —
> NTDEV is sponsored by OSR
>
> For our schedule of WDF, WDM, debugging and other seminars visit:
> http://www.osr.com/seminars
>
> To unsubscribe, visit the List Server section of OSR Online at
> http://www.osronline.com/page.cfm?name=ListServer
>
>
>
>
>
>
> Information from ESET NOD32 Antivirus, version of virus
> signature database 4417 (20090911)
>
> The message was checked by ESET NOD32 Antivirus.
>
> http://www.eset.com
>
>
Information from ESET NOD32 Antivirus, version of virus signature database 4417 (20090911)
The message was checked by ESET NOD32 Antivirus.
http://www.eset.com
>This is what i want to ask. From my understanding, The base address should be on the >cmResourceTypeMemory case right? But, when i debug it, there is no PartialDescriptors with type of >cmResourceTypeMemory.
You should look a specification of a PCI board which you use. The specification explains what kind of PCI resources the board has - memory or I/O ports or both. Usually a PCI board has at least one PCI memory region, but as Don said it is possible that a PCI board has only PCI I/O ports. Again, if you have any concern which PCI resources your driver expect to get you should look the documentation of the PCI board.
Igor Sharovar
Thank you guys?for the information. I make some mistakes in programming, but now i can get the memory resources. After getting this memory resources, i save?the base address and the length?in device extension. I want to ask, if i?map this by?calling?mmimapiospace and assign this to variable memBar. let’s say i just want to test to write/read to this memBar. Is it possible just by assigning *(memBar+offset) = anyvalues ? I have tried it but it gives me error when build. How can i use this variable?
?
Regards,
Sofian
?
— On Fri, 9/11/09, igor.sharovar@hp.com <igor.sharovar> wrote:
From: igor.sharovar@hp.com <igor.sharovar>
Subject: RE:[ntdev] Find base address of PCI memory address space
To: “Windows System Software Devs Interest List”
Date: Friday, September 11, 2009, 2:02 PM
>This is what i want to ask. From my understanding, The base address should be on the >cmResourceTypeMemory case right? But, when i debug it, there is no PartialDescriptors with type of >cmResourceTypeMemory.
You should look a specification of a PCI board which you use. The specification explains what kind of PCI resources the board has - memory or I/O ports or both. Usually a PCI board has at least one PCI memory region, but as Don said it is possible that a PCI board has only PCI I/O ports. Again, if you have any concern which PCI resources your driver expect to get you should look the documentation of the PCI board.
Igor Sharovar
???
—
NTDEV is sponsored by OSR
For our schedule of WDF, WDM, debugging and other seminars visit:
http://www.osr.com/seminars
To unsubscribe, visit the List Server section of OSR Online at http://www.osronline.com/page.cfm?name=ListServer</igor.sharovar></igor.sharovar>
> Is it possible just by assigning *(memBar+offset) = anyvalues ?
No, you need to use HAL macros such as WRITE_REGISTER_UCHAR to access PCI card registers in memory space. You would need something like:
WRITE_REGISTER_UCHAR((PUCHAR)(memBar+offset), (UCHAR)anyvalues);
If memBar is declared as a PVOID, (PUCHAR)(memBar+offset) does not do what you think it does. Well it does if all you want to do is access the buffer in pointer sized increments
d
Sent from my phone with no t9, all spilling mistakes are not intentional.
-----Original Message-----
From: xxxxx@ced.co.uk
Sent: Tuesday, September 15, 2009 7:03 AM
To: Windows System Software Devs Interest List
Subject: RE:[ntdev] Find base address of PCI memory address space
> Is it possible just by assigning *(memBar+offset) = anyvalues ?
No, you need to use HAL macros such as WRITE_REGISTER_UCHAR to access PCI card registers in memory space. You would need something like:
WRITE_REGISTER_UCHAR((PUCHAR)(memBar+offset), (UCHAR)anyvalues);
—
NTDEV is sponsored by OSR
For our schedule of WDF, WDM, debugging and other seminars visit:
http://www.osr.com/seminars
To unsubscribe, visit the List Server section of OSR Online at http://www.osronline.com/page.cfm?name=ListServer
Thanks, so we should use the HAL library routines to access the resources. But, how if i have my own defined datastructure. How can i write this data to PCI cards register in memory space?
— On Tue, 9/15/09, Doron Holan wrote:
From: Doron Holan
Subject: RE: RE:[ntdev] Find base address of PCI memory address space
To: “Windows System Software Devs Interest List”
Date: Tuesday, September 15, 2009, 10:20 AM
If memBar is declared as a PVOID, (PUCHAR)(memBar+offset) does not do what you think it does. Well it does if all you want to do is access the buffer in pointer sized increments
d
Sent from my phone with no t9, all spilling mistakes are not intentional.
-----Original Message-----
From: xxxxx@ced.co.uk
Sent: Tuesday, September 15, 2009 7:03 AM
To: Windows System Software Devs Interest List
Subject: RE:[ntdev] Find base address of PCI memory address space
> Is it possible just by assigning *(memBar+offset) = anyvalues ?
No, you need to use HAL macros such as WRITE_REGISTER_UCHAR to access PCI card registers in memory space. You would need something like:
WRITE_REGISTER_UCHAR((PUCHAR)(memBar+offset), (UCHAR)anyvalues);
—
NTDEV is sponsored by OSR
For our schedule of WDF, WDM, debugging and other seminars visit:
http://www.osr.com/seminars
To unsubscribe, visit the List Server section of OSR Online at http://www.osronline.com/page.cfm?name=ListServer
—
NTDEV is sponsored by OSR
For our schedule of WDF, WDM, debugging and other seminars visit:
http://www.osr.com/seminars
To unsubscribe, visit the List Server section of OSR Online at http://www.osronline.com/page.cfm?name=ListServer
sahrizal sofian wrote:
Thanks, so we should use the HAL library routines to access the
resources. But, how if i have my own defined datastructure. How can i
write this data to PCI cards register in memory space?
What do you mean by “defined data structure”? If you have a struct in
memory that you want to copy to the device, you can use this:
WRITE_REGISTER_BUFFER_ULONG( (PUCHAR)memBar + offset, &structure,
sizeof(structure)/4 );
–
Tim Roberts, xxxxx@probo.com
Providenza & Boekelheide, Inc.
If you want to update a field in a data structure mapped onto a chunk of
device memory you use the appropriate HAL routines to do that, based on the
field size. If you want to copy an entire data object to device memory, you
do this using the buffer variants of the HAL routines.
You can just dereference pointers, and that will work on most platforms most
of the time, but there are issues and there is no guarantee that doing so
results in the data being visible to the device.
Mark Roddy
On Tue, Sep 15, 2009 at 10:56 AM, sahrizal sofian
wrote:
> Thanks, so we should use the HAL library routines to access the resources.
> But, how if i have my own defined datastructure. How can i write this data
> to PCI cards register in memory space?
>
>
> — On Tue, 9/15/09, Doron Holan wrote:
>
>
> From: Doron Holan
> Subject: RE: RE:[ntdev] Find base address of PCI memory address space
> To: “Windows System Software Devs Interest List”
> Date: Tuesday, September 15, 2009, 10:20 AM
>
>
> If memBar is declared as a PVOID, (PUCHAR)(memBar+offset) does not do what
> you think it does. Well it does if all you want to do is access the buffer
> in pointer sized increments
>
> d
>
> Sent from my phone with no t9, all spilling mistakes are not intentional.
>
> -----Original Message-----
> From: xxxxx@ced.co.ukhttp:<
> xxxxx@ced.co.uk http:
> >
> Sent: Tuesday, September 15, 2009 7:03 AM
> To: Windows System Software Devs Interest List
> >
> Subject: RE:[ntdev] Find base address of PCI memory address space
>
>
> > Is it possible just by assigning *(memBar+offset) = anyvalues ?
>
> No, you need to use HAL macros such as WRITE_REGISTER_UCHAR to access PCI
> card registers in memory space. You would need something like:
>
> WRITE_REGISTER_UCHAR((PUCHAR)(memBar+offset), (UCHAR)anyvalues);
>
>
>
> —
> NTDEV is sponsored by OSR
>
> For our schedule of WDF, WDM, debugging and other seminars visit:
> http://www.osr.com/seminars
>
> To unsubscribe, visit the List Server section of OSR Online at
> http://www.osronline.com/page.cfm?name=ListServer
>
>
> —
> NTDEV is sponsored by OSR
>
> For our schedule of WDF, WDM, debugging and other seminars visit:
> http://www.osr.com/seminars
>
> To unsubscribe, visit the List Server section of OSR Online at
> http://www.osronline.com/page.cfm?name=ListServer
>
>
> — NTDEV is sponsored by OSR For our schedule of WDF, WDM, debugging and
> other seminars visit: http://www.osr.com/seminars To unsubscribe, visit
> the List Server section of OSR Online at
> http://www.osronline.com/page.cfm?name=ListServer</http:></http:>
>Thanks, so we should use the HAL library routines to access the resources.
Correct, they take care of memory barriers and are properly written with proper use of “volatile” (if not in handicrafted assembler).
–
Maxim S. Shatskih
Windows DDK MVP
xxxxx@storagecraft.com
http://www.storagecraft.com
>But, how if i have my own defined datastructure. How can i write this data to PCI cards register in >memory space?
It is very easy.
When your driver gets IRPMJ_PNP –> IRP_MN_START_DEVICE it should get a virtual address by using function MmMapIoSpace(). One of parameter in this function is PCI physical address which you get from ResourceListRaw. The virtual address you could use in HAL functions. An example of these functions Tim already showed. You could also look the sample WinDDK\XXX\src\general\PLX9x5x and particular the function PLxPrepareHardware(file Init.c) which shows getting a virtual PCI address from a physical.
Igor Sharovar
Yes,? i am sorry, you are right. I haven’t so familiar with many routines in kernel programming. Anyway thank you guys giving?a good direction.
?
Regards,
Sofian
— On Tue, 9/15/09, Tim Roberts wrote:
From: Tim Roberts
Subject: Re: [ntdev] Find base address of PCI memory address space
To: “Windows System Software Devs Interest List”
Date: Tuesday, September 15, 2009, 1:48 PM
sahrizal sofian wrote:
> Thanks, so we should use the HAL library routines to access the
> resources. But, how if i have my own defined datastructure. How can i
> write this data to PCI cards register in memory space?
>
What do you mean by “defined data structure”?? If you have a struct in
memory that you want to copy to the device, you can use this:
? ? WRITE_REGISTER_BUFFER_ULONG( (PUCHAR)memBar + offset, &structure,
sizeof(structure)/4 );
–
Tim Roberts, xxxxx@probo.com
Providenza & Boekelheide, Inc.
—
NTDEV is sponsored by OSR
For our schedule of WDF, WDM, debugging and other seminars visit:
http://www.osr.com/seminars
To unsubscribe, visit the List Server section of OSR Online at http://www.osronline.com/page.cfm?name=ListServer
> If memBar is declared as a PVOID, (PUCHAR)(memBar+offset) does not do what you think it does.
Actually, if memBar is declared as a PVOID I am not sure the above line will compile, in the first place - you just don’t do pointer arithmetic on void pointers, do you. Similarly, you cannot use PVOID as an array without first casting it to the right type, and you cannot use it with * operator either without raising compile error . If memBar is declared as a pointer of some type (say, PULONG), the above line will compile fine, but the result will be. indeed, very different from what the OP expects -I believe he expects the result that (PUCHAR)(memBar)+offset produces regardless of pointer type…
Anton Bassov
pointer arithmetic on PVOID certainly works. it increments the pointer value by the size of a pointer, but, yes, you are correct you cannot dereference it to get “VOID” … but OTOH, that is not what i was point out if you look at how the parens are set up.
d
From: xxxxx@lists.osr.com [xxxxx@lists.osr.com] on behalf of xxxxx@hotmail.com [xxxxx@hotmail.com]
Sent: Tuesday, September 15, 2009 10:30 PM
To: Windows System Software Devs Interest List
Subject: RE:[ntdev] Find base address of PCI memory address space
If memBar is declared as a PVOID, (PUCHAR)(memBar+offset) does not do what you think it does.
Actually, if memBar is declared as a PVOID I am not sure the above line will compile, in the first place - you just don’t do pointer arithmetic on void pointers, do you. Similarly, you cannot use PVOID as an array without first casting it to the right type, and you cannot use it with * operator either without raising compile error . If memBar is declared as a pointer of some type (say, PULONG), the above line will compile fine, but the result will be. indeed, very different from what the OP expects -I believe he expects the result that (PUCHAR)(memBar)+offset produces regardless of pointer type…
Anton Bassov
NTDEV is sponsored by OSR
For our schedule of WDF, WDM, debugging and other seminars visit:
http://www.osr.com/seminars
To unsubscribe, visit the List Server section of OSR Online at http://www.osronline.com/page.cfm?name=ListServer
> pointer arithmetic on PVOID certainly works. it increments the pointer value by the size of a pointer,
Actually, I tested it, and it, indeed, compiles without any problem. To be honest, I have never accessed a void pointer directly in my entire life, and don’t plan to do it any time soon - the very first thing I do whenever I encounter a void pointer is casting it to the target type…
but, yes, you are correct you cannot dereference it to get “VOID”
Well, once you can do pointer arithmetic on void pointers it would be quite logical to allow dereferencing it to get a pointer, i.e. to treat void* simply as an array of pointers of any type. However, trying something like that results in compile errors, although pointer arithmetic indeed works - in order to make it work you need a void**, rather than simply void*…
that is not what i was point out if you look at how the parens are set up.
Sure…
Anton Bassov
> When your driver gets IRPMJ_PNP –> IRP_MN_START_DEVICE it should get a virtual address by
using function MmMapIoSpace(). One of parameter in this function is PCI physical address which you
Do not forget to use Translated resources, and not Raw.
–
Maxim S. Shatskih
Windows DDK MVP
xxxxx@storagecraft.com
http://www.storagecraft.com
>pointer arithmetic on PVOID certainly works.
In C, not in C++.
–
Maxim S. Shatskih
Windows DDK MVP
xxxxx@storagecraft.com
http://www.storagecraft.com
I think Anton is correct here: the type 'void' does not have a size. C/C++
pointers must point to a type with a 'size' for pointer arithmetic to
compile.
Surely Doron must be trying to say that one can perform arithmetic on any
pointer. Since the WDF team created some very nice macros for doing so, it
may simply be that looking inside them to see that all pointers are first
cast to PUCHAR to make the 'stride' 1 byte is a lost detail.
So
PVOID member;
((PUCHAR)member + offset)
Would compile just fine and work too.
Where as
(PUCHAR)(member + offset)
Is going to cause the compiler to think one daft.
Cheers,
Dave Cattley
-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of Doron Holan
Sent: Wednesday, September 16, 2009 1:41 AM
To: Windows System Software Devs Interest List
Subject: RE: RE:[ntdev] Find base address of PCI memory address space
pointer arithmetic on PVOID certainly works. it increments the pointer value
by the size of a pointer, but, yes, you are correct you cannot dereference
it to get "VOID" ... but OTOH, that is not what i was point out if you look
at how the parens are set up.
d
From: xxxxx@lists.osr.com [xxxxx@lists.osr.com]
on behalf of xxxxx@hotmail.com [xxxxx@hotmail.com]
Sent: Tuesday, September 15, 2009 10:30 PM
To: Windows System Software Devs Interest List
Subject: RE:[ntdev] Find base address of PCI memory address space
If memBar is declared as a PVOID, (PUCHAR)(memBar+offset) does not do what
you think it does.
Actually, if memBar is declared as a PVOID I am not sure the above line
will compile, in the first place - you just don't do pointer arithmetic on
void pointers, do you. Similarly, you cannot use PVOID as an array without
first casting it to the right type, and you cannot use it with * operator
either without raising compile error . If memBar is declared as a pointer
of some type (say, PULONG), the above line will compile fine, but the result
will be. indeed, very different from what the OP expects -I believe he
expects the result that (PUCHAR)(memBar)+offset produces regardless of
pointer type....
Anton Bassov
NTDEV is sponsored by OSR
For our schedule of WDF, WDM, debugging and other seminars visit:
To unsubscribe, visit the List Server section of OSR Online at
ListServer/Forum
NTDEV is sponsored by OSR
For our schedule of WDF, WDM, debugging and other seminars visit:
To unsubscribe, visit the List Server section of OSR Online at