Re: segmentation fault when porting to linux



On Feb 26, 4:58 am, email7373...@xxxxxxxxxxxxxxx wrote:
I want to move to linux from DOS / Win98, and the piece of hardware
communicates this way (see snippet below).

This snippet works just fine in DOS / Win98, but in linux it fails
with a segmentation fault. Any idea how to make it work?

#include <stdio.h>

typedef unsigned long DWORD;
typedef unsigned char BYTE;
typedef unsigned short WORD;

volatile WORD *memory_word_pointer;

DWORD pmem_address = 0xD4000;

void *return_address (DWORD address)
{
return (BYTE *) address;

}

int main()
{
memory_word_pointer = (WORD *)return_address (pmem_address);

*memory_word_pointer = 0x1000;
return 1;

}

Probably the best solution is to create a proper driver, but you might
be okay just using '/dev/mem'. Type 'man 4 mem'.

DS
.



Relevant Pages