Re: ScsiPortGetDeviceBase returns paged or nonpaged memory?
From: Mark Roddy (markr_at_hollistech.com)
Date: 12/29/04
- Next message: robert_at_prones.pl: "Re: IoRegisterDeviceInterface Fail"
- Previous message: Don Burn: "Re: need some serious help here!!!"
- In reply to: Charles: "Re: ScsiPortGetDeviceBase returns paged or nonpaged memory?"
- Next in thread: Maxim S. Shatskih: "Re: ScsiPortGetDeviceBase returns paged or nonpaged memory?"
- Messages sorted by: [ date ] [ thread ]
Date: Wed, 29 Dec 2004 09:03:30 -0500
Charles wrote:
> From your answer, I know that I could reteat these addresses as nonpaged.
>
> Then, for the other drivers, these addresses still could be seen as
> nonpaged memory
>
> all the time?
>
>
>
> In my scsi miniport driver, I got two pointers, MemBaseAddr and IoBaseAddr,
>
> from the ScsiPortGetDeviceBase routine.
>
> MemBaseAddr points to 0xbad6e000,
>
> IoBaseAddr points to 0xdc00.
>
>
>
> At my experiment, I pass these two pointers to another device driver, say
> Ndis driver.
>
> In Ndis driver, I could access the HBA's memory space through MemBaseAddr.
>
> Value = MemBaseAddr [SOME_OFFSET]; <== OK
>
> MemBaseAddr [SOME_OFFSET] = SOME_COMMAND; <== OK
>
>
>
> But I got IRQL_NOT_LESS_OR_EQUAL error, when I tried to access IoBaseAddr.
>
> Val = IoBaseAddr [SOME_OFFSET]; <== error
>
> IoBaseAddr [SOME_OFFSET] = SOME_COMMAND; <== error
>
> The error code indicates that driver accessed paged memory at DISPATCH_LEVEL
> or above.
>
> Is that caused by IoBaseAddr being mapped to User Space (0~2G)?
> The MemBaseAddr is mapped to Kernel Space (2G~4G) then I could access that
> and
> think that as nonpaged in other drivers?
>
Having some other driver rather than the controlling hardware driver
access device memory is generally not a good idea. But that is beside
the point.
NT supports two flavors of device memory: "memory space" and "io space".
The addresses returned to you by ScsiPortGetDeviceBase are NOT standard
virtual memory addresses, they are logical addresses used specifically
for accessing device memory.
NT provides dedicated functions for performing device memory access. As
I tried (and it appears miserably failed) to point out earlier, you must
use the appropriate access methods for the logical device address type
in order to access device memory. For "memory space", in a scsi miniport
driver, you use ScsiPort[Read/Write]RegisterU* functions, for "io space"
you use ScsiPort[Read/Write]PortU* functions. For NDIS there are
equivalents.
You cannot use the IO address space addresses as in your example because
they are NOT virtual addresses in the NT VM address space. On an x86
platform they happen to be x86 IO port addresses, used in IN or OUT
instructions. That they appear to be user mode VA addresses is simply
your misinterpretation of reality.
I tried to carefully avoid stating that the values returned by
ScsiPortGetDeviceBase were normal nonpaged VA values for precisely this
reason. They are not. Consider them to be opaque tokens interpreted by
the HAL in order to route read/write requests to the correct IO bus
target using the correct IO bus protocol. The fact that memory space
logical device addresses happen to also be nonpaged VA in the OS system
address space is an interesting artifact of the OS implementation and
nothing more.
By the way, your direct memory write: MemBaseAddr [SOME_OFFSET] =
SOME_COMMAND; only appears to work correctly. If you actually depend on
that value being present on the hardware device when your write
operation completes, you will be disappointed.
>
> "Mark Roddy" <markr@hollistech.com> ???
> news:ewoSAvO7EHA.3756@TK2MSFTNGP14.phx.gbl ???...
>
>>Charles wrote:
>>
>>>Hi,
>>>
>>>The ScsiPortGetDeviceBase routine returns a mapped, logical base address
>>>that
>>>can be used to communicate with an HBA.
>>>
>>>Is the returned address nonpaged or not?
>>>
>>>Thanks.
>>>
>>>Charles
>>>
>>>
>>
>>The returned address is a Logical Address intended to be used with
>>ScsiPort[Read/Write][Register/Port][U*]. To answer your question, these
>>addresses definately do not 'page out' so they are not pageable so you
>>can think of them as non-paged.
>>
>>The logical addresses are used to access 'registers' on your HBA.
>>Registers can be 8-16-32 bits wide or they can be arrays of 8/16/32 bit
>>elements of arbitrary length.
>>
>>What you really do not want to do is to simply use pointer dereference
>>to access the device using the address returned by
>>ScsiPortGetDeviceBase. In other words if you do the following:
>>
>>PUCHAR baseAddress = ScsiPortGetDeviceBase(devExt, ....);
>>
>>You do not want to do this:
>>baseAddress[SOME_OFFSET] = SOME_COMMAND;
>>
>>Instead you should do:
>>ScsiPortWriteRegisterUchar(baseAddress + SOME_OFFSET, SOME_COMMAND);
>>
>>--
>>
>>=====================
>>Mark Roddy DDK MVP
>>Windows 2003/XP/2000 Consulting
>>Hollis Technology Solutions 603-321-1032
>>www.hollistech.com
>
>
>
-- ===================== Mark Roddy DDK MVP Windows 2003/XP/2000 Consulting Hollis Technology Solutions 603-321-1032 www.hollistech.com
- Next message: robert_at_prones.pl: "Re: IoRegisterDeviceInterface Fail"
- Previous message: Don Burn: "Re: need some serious help here!!!"
- In reply to: Charles: "Re: ScsiPortGetDeviceBase returns paged or nonpaged memory?"
- Next in thread: Maxim S. Shatskih: "Re: ScsiPortGetDeviceBase returns paged or nonpaged memory?"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|