110 for (
uint64_t i = 0; i < pageAmount; i++)
129 if (virtAddr ==
NULL)
232 LOG_ERR(
"failed to create /dev/shmem directory");
240 LOG_ERR(
"failed to create /dev/shmem/new file");
277MODULE_INFO(
"Shared Memory",
"Kai Norberg",
"Implements shared memory for inter-process communication", OS_VERSION,
278 "MIT",
"BOOT_ALWAYS");
#define assert(expression)
static uintptr_t address
Mapped virtual address of the HPET registers.
dentry_t * devfs_file_new(dentry_t *parent, const char *name, const vnode_ops_t *vnodeOps, const file_ops_t *fileOps, void *data)
Create a new file inside a mounted devfs instance.
dentry_t * devfs_dir_new(dentry_t *parent, const char *name, const vnode_ops_t *vnodeOps, void *data)
Create a new directory inside a mounted devfs instance.
static dentry_t * shmemDir
static void shmem_deinit(void)
static void shmem_object_free(shmem_object_t *shmem)
static void * shmem_mmap(file_t *file, void *address, size_t length, size_t *offset, pml_flags_t flags)
static shmem_object_t * shmem_object_new(void)
static void shmem_close(file_t *file)
static uint64_t shmem_open(file_t *file)
static dentry_t * newFile
static void * shmem_object_allocate_pages(shmem_object_t *shmem, uint64_t pageAmount, space_t *space, void *address, pml_flags_t flags)
static void shmem_vmm_callback(void *data)
static file_ops_t fileOps
static uint64_t shmem_init(void)
#define LOG_ERR(format,...)
size_t pfn_t
Page Frame Number type.
void pmm_free(pfn_t pfn)
Free a single page of physical memory.
pfn_t pmm_alloc(void)
Allocate a single page of physical memory.
void * vmm_map_pages(space_t *space, void *virtAddr, pfn_t *pfns, size_t amount, pml_flags_t flags, space_callback_func_t func, void *data)
Maps an array of physical pages to virtual memory in a given address space.
#define MODULE_INFO(_name, _author, _description, _version, _licence, _deviceTypes)
Macro to define module information.
static process_t * process_current_unsafe(void)
Retrieves the process of the currently running thread without disabling interrupts.
static void lock_init(lock_t *lock)
Initializes a lock.
#define LOCK_SCOPE(lock)
Acquires a lock for the reminder of the current scope.
#define REF(ptr)
Increment reference count.
static void ref_init(ref_t *ref, void *callback)
Initialize a reference counter.
#define UNREF(ptr)
Decrement reference count.
#define EINVAL
Invalid argument.
#define errno
Error number variable.
#define BYTES_TO_PAGES(amount)
Convert a size in bytes to pages.
#define NULL
Pointer error value.
#define ERR
Integer error value.
#define PAGE_SIZE
The size of a memory page in bytes.
static const path_flag_t flags[]
uint64_t _module_procedure(const module_event_t *event)
_PUBLIC void * malloc(size_t size)
_PUBLIC void free(void *ptr)
Directory entry structure.
File operations structure.
uint64_t(* open)(file_t *file)
A simple ticket lock implementation.
A entry in a page table without a specified address or callback ID.
Reference counting structure.
Represents a shared memory object.
Virtual address space structure.