Paparazzi UAS  v5.15_devel-109-gee85905
Paparazzi is a free software Unmanned Aircraft System.
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
virt2phys.c File Reference

Mapping of virtual to physical memory. More...

#include <stdio.h>
#include <sys/stat.h>
#include <fcntl.h>
#include "virt2phys.h"
+ Include dependency graph for virt2phys.c:

Go to the source code of this file.

Macros

#define _LARGEFILE64_SOURCE
 
#define BIT(i)   ((unsigned long long) 1 << i)
 
#define FILENAME_SIZE   30
 
#define PAGE_SHIFT   12
 
#define PAGE_SIZE   (1<<PAGE_SHIFT)
 
#define PAGE_MASK   (((unsigned long long)1<< PAGE_SHIFT) -1)
 
#define PAGE_PRESENT   BIT(63)
 
#define PAGE_SWAPPED   BIT(62)
 
#define PAGE_PFN_MASK   (((unsigned long long)1<< 55) -1)
 

Functions

static int open_pagemap (pid_t pid)
 
static int virt2phys (int fd, unsigned long vaddr, unsigned long *paddr)
 
int check_contiguity (unsigned long vaddr, pid_t pid, struct physmem *pmem, size_t size)
 

Detailed Description

Mapping of virtual to physical memory.

Source : See the linux kernel documentation at -> https://www.kernel.org/doc/Documentation/vm/pagemap.txt

The file /proc/pid/pagemap contains 8 bytes for each virtual PFN describing the page status. First we check the bits indicating if page is present and not swapped. Then we can get the physical PFN.

Contiguity check consist to verify of contiguous virtual memory correspond to present, not swapped and contiguous physical pages.

Definition in file virt2phys.c.

Macro Definition Documentation

#define _LARGEFILE64_SOURCE

Definition at line 37 of file virt2phys.c.

#define BIT (   i)    ((unsigned long long) 1 << i)

Definition at line 44 of file virt2phys.c.

#define FILENAME_SIZE   30

Definition at line 45 of file virt2phys.c.

Referenced by open_pagemap().

#define PAGE_MASK   (((unsigned long long)1<< PAGE_SHIFT) -1)

Definition at line 48 of file virt2phys.c.

Referenced by check_contiguity(), and virt2phys().

#define PAGE_PFN_MASK   (((unsigned long long)1<< 55) -1)

Definition at line 52 of file virt2phys.c.

Referenced by virt2phys().

#define PAGE_PRESENT   BIT(63)

Definition at line 50 of file virt2phys.c.

Referenced by virt2phys().

#define PAGE_SHIFT   12

Definition at line 46 of file virt2phys.c.

Referenced by virt2phys().

#define PAGE_SIZE   (1<<PAGE_SHIFT)

Definition at line 47 of file virt2phys.c.

Referenced by check_contiguity().

#define PAGE_SWAPPED   BIT(62)

Definition at line 51 of file virt2phys.c.

Referenced by virt2phys().

Function Documentation

int check_contiguity ( unsigned long  vaddr,
pid_t  pid,
struct physmem pmem,
size_t  size 
)

Definition at line 111 of file virt2phys.c.

References fd, open_pagemap(), physmem::paddr, PAGE_MASK, PAGE_SIZE, physmem::size, and virt2phys().

Referenced by v4l2_init().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static int open_pagemap ( pid_t  pid)
static

Definition at line 59 of file virt2phys.c.

References FILENAME_SIZE.

Referenced by check_contiguity().

+ Here is the caller graph for this function:

static int virt2phys ( int  fd,
unsigned long  vaddr,
unsigned long *  paddr 
)
static

Definition at line 78 of file virt2phys.c.

References PAGE_MASK, PAGE_PFN_MASK, PAGE_PRESENT, PAGE_SHIFT, and PAGE_SWAPPED.

Referenced by check_contiguity().

+ Here is the caller graph for this function: