Site hosted by Build your free website today!

Hands-on Projects for the Linux Graphics Subsystem

New book from Christos Karayiannis

Available in Amazon Kindle format at:

PCI Experimens (part III)

The memory region required for the video driver appears as we saw in section 4.2.4 by entering the following command:

sudo cat /proc/791/maps

where 791 was the process id of the X Server (X or Xorg), at the time the command was issued. The process id is returned by the 'ps' or 'pgrep' Unix commands. The next image illustrates part of the output of the previous command:

The line that is of interest here from this output is the following:

b378a000-b575a000 rw-s e8000000 00:00 7279 /sys/devices/pci0000:00/0000:00:02.0/resource0

This describes the mapping of the virtual address space b378a000-b575a000 to the device memory of the PCI device at the 'geographic' address 00:02.0, which as we previously saw in section 4.2.4 is the "VGA compatible controller: Intel Corporation 82852/855GM Integrated Graphics Device (rev 02)".

To understand what the values of the previous command output represent we read from the proc man page the format of this output:

              address           perms offset  dev   inode   pathname
              . . .
              where "address" is the address space in the process that it occupies,
              "perms" is a set of permissions:

                   r = read
                   w = write
                   x = execute
                   s = shared
                   p = private (copy on write)

              "offset" is the offset into the file/whatever, "dev" is the device
              (major:minor), and "inode" is the inode on that device.  0 indicates
              that no inode is associated with the memory region, as the case would
              be with BSS (uninitialized data).

              Under Linux 2.0 there is no field giving pathname.

Notice that the first part, the address is the only one that varies each time the system boot up, for instance at another time the proc output was the following:

b36eb000-b56bb000 rw-s e8000000 00:00 7279 /sys/devices/pci0000:00/0000:00:02.0/resource0

The virtual address space, that maps the device memory, can be placed in a different memory location each time the X Server starts up, however the total size of this address space remains the same. This virtual memory region is placed the first time at b378a000-b575a000 and the same time at b36eb000-b56bb000, which means that its size is about 32MB. This is certainly less than the 128 MB we would expect for a system with 128 MB video memory, however the mystery to this gets solved, if we have a look at the BIOS configuration, during the BIOS setup, which for the system we run the experiment, reveals a restricted size for video memory down to 32 MB.

0xb36eb000 = 3010375680 decimal
0xb56bb000 = 3043733504 decimal
3043733504 - 3010375680 + 1 = 33357825
33357825 / (1024 *1024) ≈ 32 MB

At both cases we see that the device memory is placed at the processor memory location 0xe8000000. We verify this and also the size of this memory region, 128 MB, with lspci. From the Linux command line we enter lspci, with the vvv argument in order to find 'maximum verbose' info about the PCI address 00:02.0:

sudo lspci -vvv -s 00:02.0

The command output is displayed in the following image:

As we see this memory space appears as 'Region 0', starting at e8000000, with a size of 128 MB.