Memory Map problem with ISA Bus

I have a PC/104 card that maps 512 bytes into low memory on the ISA bus. In the computers bios the ISA bus is set to the range of 0xd0000-0xdffff. I have tried a number of locations within this range. I am calling the following functions in my code to gain access to the board however when I do a read on the board everything appears as FFh.

ThreadCtl(_NTO_TCTL_IO,0);
if(mmap_device_memory( NULL, 0x200, PROT_READ|PROT_WRITE, NULL, 0xd8000)==MAP_FAILED){
printf(“memory map error\n”);
}

I’m not getting an error on the mmap but I can’t read from the board. What am I doing wrong?

How are you trying to read the board?

mmap_device_memory() returns a pointer to the virtual address you need to use. Something like this:

char *ptr;

ptr = mmap_device_memory(...);
for( i = 0; i < 512; i++ )
  {
      printf( "%X ", ptr[i] );
       if( !(i %  16))
          printf("\n" );
   }

Rick…

Does the board need some kind of initialisation. I hope the board isn`t Plug & Play ;-)

I dont know if you cut and paste the code or its really the code you used, but as Rick pointed out, mmap returns a virtual pointer to the address and you need to go through that pointer to access the memory area you mmap to.

I wasn’t using the virtual address to access the board. So that is probably my problem. In the code that Rick posted what is the diference between using ptr[i] as opposed to *(ptr+i). does ptr[i] increment an array of pointers, if so is that what the mmap_device_memory is really returning?

Nothing as long as your data types are correct. (ptr needs to be of type char * - or unsigned char *).

Rick…

*(ptr+i) and ptr[i] do the same operation. However ptr[i] is better and easier on the eye ;-) *(ptr+i) is often miss understood by newbies because if ptr is a pointer to an int and i = 1, you access ptr + 1 byte offset but rather ptr + 4 bytes.

I don’t understand wha you mean by “increment an array of pointers”. There is no array of pointers in Rick’s code. As a matter of fact there is no array , just one pointer pointing to char.