Subject: Re: question about mmap
To: Eduardo Horvath <eeh@NetBSD.org>
From: Park Chan-youn <phygeeks@gmail.com>
List: tech-kern
Date: 03/11/2005 09:43:50
Eduardo Horvath wrote:
> On Wed, Mar 09, 2005 at 05:12:30PM +0900, Chan-youn Park wrote:
>
>>Hi. I'm developing a device driver on PowerPC/Sandpoint platform.
>>
>>What I want to do is to implement an mmap interface in the device
>>driver. The device driver is for a DSP, and the DSP had its own
>>internal RAM which can be seen through PCI bus.
>>
>>I've succeeded in seeing the memory space in the kernel, but when I
>>tried to see it using the mmap I've implemented, it does not work.
>
>
> How is it not working? What do you see in that memory?
For example, what I want to see is this
----
0x80800200: 00 02 00 00 04 02 00 00 08 02 00 00 0c 02 00 00
0x80800210: 10 02 00 00 14 02 00 00 18 02 00 00 1c 02 00 00
0x80800220: 20 02 00 00 24 02 00 00 28 02 00 00 2c 02 00 00
0x80800230: 30 02 00 00 34 02 00 00 38 02 00 00 3c 02 00 00
0x80800240: 40 02 00 00 44 02 00 00 48 02 00 00 4c 02 00 00
0x80800250: 50 02 00 00 54 02 00 00 58 02 00 00 5c 02 00 00
0x80800260: 60 02 00 00 64 02 00 00 68 02 00 00 6c 02 00 00
0x80800270: 70 02 00 00 74 02 00 00 78 02 00 00 7c 02 00 00
0x80800280: 80 02 00 00 84 02 00 00 88 02 00 00 8c 02 00 00
0x80800290: 90 02 00 00 94 02 00 00 98 02 00 00 9c 02 00 00
0x808002a0: a0 02 00 00 a4 02 00 00 a8 02 00 00 ac 02 00 00
0x808002b0: b0 02 00 00 b4 02 00 00 b8 02 00 00 bc 02 00 00
0x808002c0: c0 02 00 00 c4 02 00 00 c8 02 00 00 cc 02 00 00
0x808002d0: d0 02 00 00 d4 02 00 00 d8 02 00 00 dc 02 00 00
0x808002e0: e0 02 00 00 e4 02 00 00 e8 02 00 00 ec 02 00 00
0x808002f0: f0 02 00 00 f4 02 00 00 f8 02 00 00 fc 02 00 00
----
The above is printed in kernel. But, when printed using the address
given through the mmap, the following is shown.
----
0x00000200: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
0x00000210: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
0x00000220: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
0x00000230: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
0x00000240: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
0x00000250: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
0x00000260: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
0x00000270: ff ff ff ff ff ff ff ff bf ff ff ff ff ff ff ff
0x00000280: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
0x00000290: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
0x000002a0: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
0x000002b0: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
0x000002c0: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
0x000002d0: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
0x000002e0: ff ff ff ff ff ff ff ff ff ff ff ff f7 ff ff ff
0x000002f0: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
----
The address shown in the leftmost column is the offset from the DSP
internal memory, which becomes a physical address if you add to it
'0x80800000'.
> Could it be that the cache is enabled and you are not seeing changes?
> Or could it be an endianness issue since the PowerPC is big-endian
> and the PCI bus is little endian?
>
> Eduardo
Cache might be the problem. I've tried using 'volatile' type, but it
does not work. I also want to know where does the values shown come from.
One interesting thing is, when seen through mmap, the 'meaningless' data
repeats after a page - that is, in this architecture, 4096 bytes. Is
that could be some hint?
Btw, as you can see from the above, it is not a simple endianess
problem. I used bus_space interface, and they treat the endianess
correctly, AFAIK.