DCMD_PROC_PTINFO

Return the pagetable mapping information for a memory segment

#include <sys/procfs.h>

#define DCMD_PROC_PTINFO   __DIOTF(_DCMD_PROC, __PROC_SUBCMD_PROCFS + 34, procfs_mapinfo)

The arguments to devctl() are:

Argument Value
filedes A file descriptor for the process.
dcmd DCMD_PROC_PTINFO
dev_data_ptr An array of at least one procfs_mapinfo structure
n_bytes The size of the array
dev_info_ptr A pointer to an integer where the number of mappings can be stored

This command returns the pagetable mapping information for the specified memory segment. Call this command with an array of at least one procfs_mapinfo structure (defined in <sys/procfs.h>). The virtual address you're interested in must be the vaddr field of the first procfs_mapinfo entry passed in. If the supplied virtual address doesn't match an existing segment, devctl() provides information on the next monotonically increasing segment.

The information is based on the current state of the pagetable mappings, and each mapping returned represents a page table entry. This means that while the mapping entry for the pagetable entry has PROT_READ | PROT_WRITE protection bits, it may not have been read from or written to, in which case the actual page table entry may indicate PROT_NONE or PROT_READ.

The size field indicates the size of the page mapping. The default is 4 KB, but larger mappings are possible on some machines.

Note: The number of mappings returned is the total number of mappings that could be returned, regardless of the size of the buffer passed.

For example:

procfs_mapinfo *my_buffer;
int num_mappings;

my_buffer = (procfs_mapinfo *) malloc( sizeof(procfs_mapinfo) * 10 );
if ( my_buffer == NULL ) {
  /* Not enough memory. */
}

if ((err = devctl( fd, DCMD_PROC_PTINFO, my_buffer,
                   sizeof(procfs_mapinfo) * 10, 
                   &num_mappings)) != EOK)
{
  /* An error occurred. */
}