XenevaOS
Loading...
Searching...
No Matches
Functions
shm.c File Reference
#include <Mm/shm.h>
#include <Mm/kmalloc.h>
#include <Mm/pmmngr.h>
#include <Mm/vmmngr.h>
#include <list.h>
#include <Hal/AA64/aa64lowlevel.h>
#include <aucon.h>
#include <_null.h>
#include <string.h>
#include <stdint.h>
Include dependency graph for shm.c:

Functions

void AuInitialiseSHMMan ()
 AuInitialiseSHMMan – initialise shm manager.
 
uint16_t AuSHMGetID ()
 AuSHMGetID – allocate a new shared memory id.
 
AuSHMAuGetSHMSeg (uint16_t key)
 AuGetSHMSeg – searches and return a shm segment by its key.
 
AuSHMAuGetSHMByID (uint16_t id)
 AuGetSHMSeg – searches and return a shm segment by its key.
 
int AuCreateSHM (AuProcess *proc, uint16_t key, size_t sz, uint8_t flags)
 AuCreateSHM – create a new shared memory segment or returns previously allocated one.
 
void AuSHMDelete (AuSHM *shm)
 AuSHMDelete – removes a SHM Segment from system shm list.
 
size_t AuSHMProcBreak (AuProcess *proc, size_t num_frames)
 AuSHMProcBreak – gets some available shm memory and increase the break count.
 
void AuSHMProcSwap (dataentry *current, dataentry *index)
 AuSHMProcSwap – Swaps data between list entry.
 
void AuSHMProcOrderList (AuProcess *proc)
 
void envmdebug ()
 
void * AuSHMObtainMem (AuProcess *proc, uint16_t id, void *shmaddr, int shmflg)
 AuSHMObtainMem – obtains a virtual memory from given shm segment.
 
void AuSHMUnmap (uint16_t key, AuProcess *proc)
 AuSHMUnmap – unmaps a shared memory segment.
 
void AuSHMUnmapAll (AuProcess *proc)
 AuSHMUnmapAll – unmaps all mappings for this process.
 

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.

Function Documentation

◆ AuCreateSHM()

int AuCreateSHM ( AuProcess proc,
uint16_t  key,
size_t  sz,
uint8_t  flags 
)

AuCreateSHM – create a new shared memory segment or returns previously allocated one.

Parameters
proc– Creator process
key– unique key to use
sz– size in multiple of PAGE_SIZE
flags– security flags
Returns
id of newly created SHM, -1 on failure

◆ AuGetSHMByID()

AuSHM * AuGetSHMByID ( uint16_t  id)

AuGetSHMSeg – searches and return a shm segment by its key.

Parameters
key– key to search
Returns
Pointer to shm on success, NULL on failure

◆ AuGetSHMSeg()

AuSHM * AuGetSHMSeg ( uint16_t  key)

AuGetSHMSeg – searches and return a shm segment by its key.

Parameters
key– key to search

◆ AuInitialiseSHMMan()

void AuInitialiseSHMMan ( )

AuInitialiseSHMMan – initialise shm manager.

◆ AuSHMDelete()

void AuSHMDelete ( AuSHM shm)

AuSHMDelete – removes a SHM Segment from system shm list.

Parameters
shm– segment to delete

◆ AuSHMGetID()

uint16_t AuSHMGetID ( )

AuSHMGetID – allocate a new shared memory id.

◆ AuSHMObtainMem()

void * AuSHMObtainMem ( AuProcess proc,
uint16_t  id,
void *  shmaddr,
int  shmflg 
)

AuSHMObtainMem – obtains a virtual memory from given shm segment.

Parameters
proc– Calling process
id– shm segment id
shmaddr– starting shared memory address to map @parma shmflg – flags
Returns
starting address of this shm on success, NULL on failure

◆ AuSHMProcBreak()

size_t AuSHMProcBreak ( AuProcess proc,
size_t  num_frames 
)

AuSHMProcBreak – gets some available shm memory and increase the break count.

Parameters
proc– Process to look
num_frames– number of frames to increase
Returns
start address of last break

◆ AuSHMProcOrderList()

void AuSHMProcOrderList ( AuProcess proc)

◆ AuSHMProcSwap()

void AuSHMProcSwap ( dataentry current,
dataentry index 
)

AuSHMProcSwap – Swaps data between list entry.

◆ AuSHMUnmap()

void AuSHMUnmap ( uint16_t  key,
AuProcess proc 
)

AuSHMUnmap – unmaps a shared memory segment.

Parameters
key– key to search
proc– process to look

◆ AuSHMUnmapAll()

void AuSHMUnmapAll ( AuProcess proc)

AuSHMUnmapAll – unmaps all mappings for this process.

Parameters
proc– Pointer to process that needs unmapping

◆ envmdebug()

void envmdebug ( )
extern