VirtualMemory Linux

Implements VirtualMemory, mapping of virtual memory pages.

Summary
VirtualMemory LinuxImplements VirtualMemory, mapping of virtual memory pages.
CopyrightThis program is free software.
Files
C-kern/api/memory/vm.hHeader file of VirtualMemory.
C-kern/platform/Linux/vm.cLinux specific implementation VirtualMemory Linux.
Macros
PROC_SELF_MAPSThe Linux system file containing the currently mapped memory regions and their access permissions of this process.
Functions
Functions
sys_pagesize_vmUses sysconf(_SC_PAGESIZE) which conforms to POSIX.1-2001.
vm_region_t
helper
lifetime
query
iterate
vmpage_t
helper
SET_PROTConverts accessmode_e into POSIX representation.
lifetime
change

Copyright

This program is free software.  You can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more details.

Author

© 2011 Jörg Seebohn

Files

C-kern/api/memory/vm.h

Header file of VirtualMemory.

C-kern/platform/Linux/vm.c

Linux specific implementation VirtualMemory Linux.

Macros

PROC_SELF_MAPS

#define PROC_SELF_MAPS "/proc/self/maps"

The Linux system file containing the currently mapped memory regions and their access permissions of this process.

Format

address          perms offset   dev   inode   pathname
08048000-08056000 r-xp 00000000 03:0c 64593   /usr/sbin/gpm
08056000-08058000 rw-p 0000d000 03:0c 64593   /usr/sbin/gpm
08058000-0805b000 rwxp 00000000 00:00 0

See

man 5 proc

for a more detailed description

Functions

Summary
Functions
sys_pagesize_vmUses sysconf(_SC_PAGESIZE) which conforms to POSIX.1-2001.

Functions

sys_pagesize_vm

uint32_t sys_pagesize_vm()

Uses sysconf(_SC_PAGESIZE) which conforms to POSIX.1-2001.

vm_region_t

helper

lifetime

query

iterate

vmpage_t

Summary
helper
SET_PROTConverts accessmode_e into POSIX representation.
lifetime
change

helper

SET_PROT

#define SET_PROT(
   prot,
   access_mode
) static_assert(0 == accessmode_NONE, "") ; static_assert(0 == PROT_NONE, "") ; if ( accessmode_READ == PROT_READ && accessmode_WRITE == PROT_WRITE && accessmode_EXEC == PROT_EXEC) { prot = access_mode & (accessmode_RDWR|accessmode_EXEC); } else { if (accessmode_READ & access_mode) { prot = PROT_READ ; } else { prot = PROT_NONE ; } if (accessmode_WRITE & access_mode) { prot |= PROT_WRITE ; } if (accessmode_EXEC & access_mode) { prot |= PROT_EXEC ; } }

Converts accessmode_e into POSIX representation.  The parameter prot is set to the POSIX representation of the value access_mode which is of type accessmode_e.

lifetime

change

Manages mapping of virtual memory pages.
Implements VirtualMemory, mapping of virtual memory pages.
#define PROC_SELF_MAPS "/proc/self/maps"
The Linux system file containing the currently mapped memory regions and their access permissions of this process.
uint32_t sys_pagesize_vm()
Uses sysconf(_SC_PAGESIZE) which conforms to POSIX.1-2001.
#define SET_PROT(
   prot,
   access_mode
) static_assert(0 == accessmode_NONE, "") ; static_assert(0 == PROT_NONE, "") ; if ( accessmode_READ == PROT_READ && accessmode_WRITE == PROT_WRITE && accessmode_EXEC == PROT_EXEC) { prot = access_mode & (accessmode_RDWR|accessmode_EXEC); } else { if (accessmode_READ & access_mode) { prot = PROT_READ ; } else { prot = PROT_NONE ; } if (accessmode_WRITE & access_mode) { prot |= PROT_WRITE ; } if (accessmode_EXEC & access_mode) { prot |= PROT_EXEC ; } }
Converts accessmode_e into POSIX representation.
Determines how you can access a data block (on disk or in memory).
Close