none
MmMapIoSpace() - calling more than once on the same Physical Address RRS feed

  • Question

  • Hi everyone

    I would like to access the contents of a hardware register from my C#.NET app (using Windows Embedded Compact 7 on TI AM3354)

    I know I need to use MmMapIoSpace() in a driver to get the Virtual Address, which can then be used to get the actual contents of a register.

    If the hardware registers have already been mapped using MmMapIoSpace() by its device driver can MmMapIoSpace() be called again by my driver? Are there any issues with doing?

    For instance, The current SPI driver maps the SPI registers at driver init using MmMapIoSpace(). I'm interested in a certain SPI register contents. Can my new driver come along and map this SPI register so I can get its Virtual Address?

    Is there an easier way to do what I'm trying to do?

    Terry

    Thursday, June 26, 2014 10:29 AM

Answers

  • You can use MMapIoSpace() multiple times on the same physical memory ... No issue as per the implementation

    But very important you should handle the race condition such that two threads try to access the same

    physical memory and the change made by one should not effect the other ...

    --- Misbah


    Senior Design Engineer T.E.S Electroni Solutions (Bangalore-India) www.tes-dst.com email-misbah.khan@tes-dst.com

    • Proposed as answer by Misbah Khan Thursday, June 26, 2014 1:22 PM
    • Marked as answer by Terry PG Thursday, June 26, 2014 2:36 PM
    Thursday, June 26, 2014 12:39 PM

All replies

  • Why do you want to access them in an application?

    There is a possibility of race condition as there won't be critical section (Same registers modified in driver and app).

    If you want to modify them performing your own IOCTL to SPI driver is one option if there is access to driver code/BSP.

    Regards,

    GSR

    Thursday, June 26, 2014 10:41 AM
  • GSR

    Thanks for the reply.

    The main reason is to check that the registers have been correctly set by the driver for the correct operation (not necessarily to set the register from the app)

    By having a general driver to do this saves having to modify other drivers not just the SPI.

    (Coming from an Embedded C background on microcontrollers its something I'm used to)

    Terry 

    Thursday, June 26, 2014 10:59 AM
  • In the past on OMAP3530 initial versions of the BSP (CE 6.0) contains this kind of utility. So when you enable KITL and target shell, inside target shell you can execute these customized commands which will give values of the registers.

    May be you can implement a kernel driver and make a customized IOCTL to this driver from your APP.

    The PA of the required register needs to be sent in IOCTL buffers. The IOCTL has to convert PA to VA and then read the register and print the values.

    But, still I am suspecting a race condition if you try to modify the register in your implemented driver.

    Its a very nice utility as you suggested I also would like to see if by default Microsoft supports at least during development stages. Not on final devices.

    Regards,

    GSR

    Thursday, June 26, 2014 11:29 AM
  • You can use MMapIoSpace() multiple times on the same physical memory ... No issue as per the implementation

    But very important you should handle the race condition such that two threads try to access the same

    physical memory and the change made by one should not effect the other ...

    --- Misbah


    Senior Design Engineer T.E.S Electroni Solutions (Bangalore-India) www.tes-dst.com email-misbah.khan@tes-dst.com

    • Proposed as answer by Misbah Khan Thursday, June 26, 2014 1:22 PM
    • Marked as answer by Terry PG Thursday, June 26, 2014 2:36 PM
    Thursday, June 26, 2014 12:39 PM
  • Thanks Misbah

    Its unlikely I'll be writing to registers as its more to check on register settings made by the driver.

    Though the part comes with Ethernet our final product won't have Ethernet fitted.
    What we intend to do is use the MAC Address as a means of a unique serial number to identify the board (saves adding our own serial number) By being able to read the MAC address registers (as well as SPI, I2C etc as required for debug purposes) via a general purpose driver would be useful.

    Terry 

    Thursday, June 26, 2014 1:04 PM