Asked By Peter_Šupina
05-Feb-10 10:19 AM

Hello all.
We need to access (read/write) memory on devices (cards) attached to
PC/104 bus.
Operating system: Microsoft Windows Embedded CE 6.0
Target processor: Advantech PCM-3375 (x86 architecture)
http://www.advantech.com/products/PCM-3375/mod_1-2JKGWQ.aspx
We were using operating system QNX 4.25 before, now we plan to migrate
our code to WinCE6.
Under QNX, we were accessing the memory using block of code similar to
this one:
{
int addr =3D 0xd9080; // physical address on card
unsigned long size =3D 0x1000; // size of block to access
unsigned char *mem =3D NULL;
int fd;
void *map;
/* Address has to be in specific range */
if (addr < 0xffff) addr +=3D 0xd0000;
addr &=3D 0xffff0;
/* Open physical memory */
fd =3D shm_open( "Physical", O_RDWR, 0777 );
if (fd =3D=3D -1) {
fprintf(stderr, "shm_open failed: %s\n", strerror(errno));
exit(1);
}
/* Map memory (4kB aligned) */
map =3D mmap( 0, size + (addr & 0xfff), PROT_WRITE | PROT_READ,
MAP_SHARED, fd, addr & ~0xfff );
if (addr =3D=3D (void *) -1) {
fprintf(stderr, "mmap failed: %s\n", strerror(errno));
exit(1);
}
mem =3D (unsigned char*)((char*)map + (addr & 0xfff));
/* Working with memory */
mem[0] =3D 0xa0; // Writing to memory
printf("mem[0] =3D %X\n", mem[0]); // Reading from memory
/* Unmap memory */
munmap(map, size + (addr & 0xfff);
shm_unlink("Physical");
}
Reference to functions used:
http://www.users.pjwstk.edu.pl/~jms/qnx/help/watcom/clibref/qnx/shm_open.ht=
ml
http://www.users.pjwstk.edu.pl/~jms/qnx/help/watcom/clibref/qnx/mmap.html
http://www.users.pjwstk.edu.pl/~jms/qnx/help/watcom/clibref/qnx/munmap.html
http://www.users.pjwstk.edu.pl/~jms/qnx/help/watcom/clibref/qnx/shm_unlink.=
html
We need to write code to do the same operations under Windows Embedded
CE 6.0.
Do I need to write Kernel-mode driver to access the physical memory?
Do I need to adjust BSP?
Which functions should I use?
Thank you.
Best regards,
Peter =C5=A0upina