Reputation: 1
I am migrating a code from Linux to ghs Integrity Real Time OS. The code requires opening physical/main memory and then map the physical to virtual memory using mmap.
In Linux, main memory is accessed by,
fd = open("/dev/mem", O_RDONLY);
void * virt_addr = mmap(NULL, 0x20000, PROT_READ | PROT_WRITE, MAP_SHARED, physical_addr);
int32_t register_access = ((UINT8 *)virt_addr + 0x2000);
Note: physical_addr is a physical address of base address register(BAR) in PCI.
Can you please let me know how this can be accomplished in Integrity?
I have implemented this in vxWorks code is:
/* lukup table idx 0 */
ret = idt_ntb_peer_mw_get_addr(&ndev->ntb, 0, &ndev->outMemAddr, &ndev->sizeMapReg);
ret = devMemCreate("/sw2NTB1Cfg", 0, (PHYS_ADDR)ndev->outMemAddr, ndev->sizeMapReg, MMU_ATTR_SUP_RW | MMU_ATTR_USR_RW |
MMU_ATTR_VALID | MMU_ATTR_CACHE_OFF);
/*Opening device memory */
fd = devMemOpen("/sw2NTB1Cfg", O_RDWR, S_IRWXU);
/*mapping physical to virtual using mmap*/
ndev->sw2Ntb1regAddr = mmap(0, 0x200000, PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0);
/*Accessing SW2 NTB device id(offset = 0x2000) using this addr*/
memcpy(&data, (UINT8 *)ndev->sw2Ntb1regAddr + reg, 4); //reg is offset
How will I implement this in Green Hills System's Integrity RTOS.
Upvotes: 0
Views: 186