Memory Hole & mmap

::disregard previous message ...::

Hello,
I've got a beagleboard C4 running Linux Angstrom version 2.6.29-
omap1. My goal is to set up the video encoder on the omap to run in
test mode, therefore allowing me to read/write to the video DACs. To
do this I need to change the values of several of the Video Encoder
Registers. When I am in UBoot, I can manually do this by ... 'mw
48050CC8 00C70000' (for each register/value combo I need to change.)

The issue comes in when I try to automate this process by running a
script from the kernel... I am using mmap/munmap to perform the
mapping between physical address space and the kernel (see snip
below):

int MAP_SIZE = 4096;
int OMAP_base = 0x48000000; //gives map_base=0x40145000
                                              //All of the video
encoder registers start out in address space 48xxxxxx, this is
                                              //why OMAP_base was
chosen

void WritePhysical(unsigned long Address, unsigned long
Data)
{
  ReadPhysical(Address);
  int fd;
  int offset = Address-OMAP_base;
  if (offset < 0) {
    return;}
  unsigned long *map_base, *virt_addr;
  fd = open("/dev/mem", O_RDWR |
O_SYNC);
  map_base = mmap(0, MAP_SIZE, PROT_READ | PROT_WRITE, MAP_SHARED, fd,
OMAP_base);
  virt_addr = map_base +(0xFFF &
Address);
  *((unsigned long *) virt_addr) =
Data;

close(fd);
}

unsigned long ReadPhysical(unsigned long Address)
{
  int fd;
  unsigned long *map_base, *virt_addr;
  unsigned long read_result;
  fd = open("/dev/mem", O_RDWR |
O_SYNC);
  map_base = mmap(0, MAP_SIZE, PROT_READ | PROT_WRITE, MAP_SHARED, fd,
OMAP_base);

  virt_addr = map_base + (0xFFF &
Address);
  *((unsigned long *) virt_addr) = Data;
  read_result = *((unsigned long *)
virt_addr);
  printf("read result: %X \n",
read_result);

close(fd);
  return read_result;
}

void SVideo
(void)
{
  WritePhysical(VENC_F_CONTROL, 0x00000100);
  ...
  ...
  ...
  ...
}

This compiles with gcc with no problem and runs to completion ...
however none of the address values actually get changed and the omap
is not placed in test mode. If I start tweeking MAP_SIZE or
OMAP_base, I get:
"external abort on non-linefetch (0x1818) at 0xXXXXXXXX"

Since I can change the address registers in UBoot, I am assuming the
memory mapping is 1-to-1, i.e. when i use mw 48050CC8 00C70000 I can
confirm C70000 has been written with: md 48050CC8. However, when i am
running the script from the kernel and none of the address registers
change value (I am checking with ReadPhysical), then is mmap not
seeing this 1-to-1 addressing? Should OMAP_base be the virtual
address the video encoder registers are seen from the kernel? If so,
how can I figure out this virtual address? Any insight would be
appreciated...

For reference:

my boot args: console=ttyS2,115200n8 console=tty0 root=/dev/mmcblk0p2
rootwait mem=112M nohz=off omapfb.debug=y omapdss.debug=y
omapfb.mode=tv.ntsc omapdss.def_disp=tv omapfb.test=y omapfb.vram=0:3M,
1:3M,2:3M

my memory map:
RESETCTRL: 88000000-88000080
DDR2: 88000080-88C00000
DSPLINKMEM0: 88C00000-88C05000
DSPLINKMEM1: 88C05000-88C30000
POOLMEM: 88C30000-88D00000