XenevaOS
Loading...
Searching...
No Matches
Macros | Functions
mman.h File Reference
#include <stdint.h>
#include <_xeneva.h>
Include dependency graph for mman.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define PAGE_SIZE   4096
 
#define MEMMAP_NO_FILEDESC   -1
 
#define PROTECTION_FLAG_READONLY   1<<0
 
#define PROTECTION_FLAG_WRITE   1<<1
 
#define PROTECTION_FLAG_NO_EXEC   1<<2
 
#define PROTECTION_FLAG_NO_CACHE   1<<3
 
#define MEMMAP_FLAG_SHARED   1<<0
 
#define MEMMAP_FLAG_COW   1<<1
 
#define MEMMAP_FLAG_PRIVATE   1<<2
 
#define MEMMAP_FLAG_DISCARD_FILE_READ   1<<3
 

Functions

XE_LIB void * _KeMemMap (void *address, size_t length, int protect, int flags, int filedesc, uint64_t offset)
 _KeMemMap – memory map
 
XE_LIB void _KeMemUnmap (void *address, size_t len)
 _KeMemUnmap – unmaps a memory segment
 
XE_LIB int _KeCreateSharedMem (uint16_t key, size_t sz, uint8_t flags)
 _KeCreateSharedMem – create a shared memory chunk
 
XE_LIB void * _KeObtainSharedMem (uint16_t id, void *shmaddr, int shmflg)
 _KeObtainSharedMem – obtain a shared memory
 
XE_LIB void _KeUnmapSharedMem (uint16_t key)
 _KeUnmapSharedMem – unmap shared memory segment
 
XE_LIB uint64_t _KeGetProcessHeapMem (size_t sz)
 _KeGetProcessHeapMem – request a new memory from process heap
 
XE_LIB void _KeMemMapDirty (void *startAddr, size_t len, int flags, int prot)
 _KeMemMapDirty – dirty update previously allocated memory map
 
XE_LIB int _KeProcessHeapUnmap (void *ptr, size_t sz)
 _KeProcessHeapUnmap – unmaps previosly allocated heap memory
 

Detailed Description

BSD 2-Clause License

Copyright (c) 2022-2023, Manas Kamal Choudhury All rights reserved.

Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:

  1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
  2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

Macro Definition Documentation

◆ MEMMAP_FLAG_COW

#define MEMMAP_FLAG_COW   1<<1

◆ MEMMAP_FLAG_DISCARD_FILE_READ

#define MEMMAP_FLAG_DISCARD_FILE_READ   1<<3

◆ MEMMAP_FLAG_PRIVATE

#define MEMMAP_FLAG_PRIVATE   1<<2

◆ MEMMAP_FLAG_SHARED

#define MEMMAP_FLAG_SHARED   1<<0

◆ MEMMAP_NO_FILEDESC

#define MEMMAP_NO_FILEDESC   -1

◆ PAGE_SIZE

#define PAGE_SIZE   4096

◆ PROTECTION_FLAG_NO_CACHE

#define PROTECTION_FLAG_NO_CACHE   1<<3

◆ PROTECTION_FLAG_NO_EXEC

#define PROTECTION_FLAG_NO_EXEC   1<<2

◆ PROTECTION_FLAG_READONLY

#define PROTECTION_FLAG_READONLY   1<<0

◆ PROTECTION_FLAG_WRITE

#define PROTECTION_FLAG_WRITE   1<<1

Function Documentation

◆ _KeCreateSharedMem()

XE_LIB int _KeCreateSharedMem ( uint16_t  key,
size_t  sz,
uint8_t  flags 
)

_KeCreateSharedMem – create a shared memory chunk

Parameters
key– key to use
sz– memory size
flags– shared memory flags

◆ _KeGetProcessHeapMem()

XE_LIB uint64_t _KeGetProcessHeapMem ( size_t  sz)

_KeGetProcessHeapMem – request a new memory from process heap

Parameters
sz– size in bytes

◆ _KeMemMap()

XE_LIB void * _KeMemMap ( void *  address,
size_t  length,
int  protect,
int  flags,
int  filedesc,
uint64_t  offset 
)

_KeMemMap – memory map

Parameters
address– starting address
length– length of the mappings
protect– protection flags
flags– memory map flags
filedesc– file descriptor to map
offset– offset from where to begin, it should be multiple of PAGE_SIZE

◆ _KeMemMapDirty()

XE_LIB void _KeMemMapDirty ( void *  startAddr,
size_t  len,
int  flags,
int  prot 
)

_KeMemMapDirty – dirty update previously allocated memory map

Parameters
startAddr– starting address
len– length in bytes
flags– memory map flags
prot– protection flags

◆ _KeMemUnmap()

XE_LIB void _KeMemUnmap ( void *  address,
size_t  len 
)

_KeMemUnmap – unmaps a memory segment

Parameters
address– starting address of mapped address range
len– length of the address mapped range

◆ _KeObtainSharedMem()

XE_LIB void * _KeObtainSharedMem ( uint16_t  id,
void *  shmaddr,
int  shmflg 
)

_KeObtainSharedMem – obtain a shared memory

Parameters
id– segment id
shmaddr– user specified address
shmflg– flags to use for protection

◆ _KeProcessHeapUnmap()

XE_LIB int _KeProcessHeapUnmap ( void *  ptr,
size_t  sz 
)

_KeProcessHeapUnmap – unmaps previosly allocated heap memory

Parameters
ptr– Pointer to freeable address
sz– size in bytes to unallocate

◆ _KeUnmapSharedMem()

XE_LIB void _KeUnmapSharedMem ( uint16_t  key)

_KeUnmapSharedMem – unmap shared memory segment

Parameters
key– key to search