- Main Page
- Data Structures
- Files
- Directories

- Search for |

- File List
- Globals

# kmalloc.c File Reference

`#include <lib/kmalloc.h>`
`#include <lib/kprintf.h>`
`#include <ubixos/kpanic.h>`
`#include <ubixos/sched.h>`
`#include <ubixos/spinlock.h>`
`#include <vmm/vmm.h>`
`#include <string.h>`
`#include <assert.h>`

Include dependency graph for kmalloc.c:

Go to the source code of this file.

## Functions
static void * | getEmptyDesc ()
static int | insertFreeDesc (struct memDescriptor *freeDesc)
void | kfree (void *baseAddr)
void * | kmalloc (uInt32 len)
static void | mergeMemBlocks ()
## Variables
static spinLock_t | emptyDescSpinLock = SPIN_LOCK_INITIALIZER
static struct memDescriptor * | emptyKernDesc = 0x0
static struct memDescriptor * | freeKernDesc = 0x0
static spinLock_t | mallocSpinLock = SPIN_LOCK_INITIALIZER
static struct memDescriptor * | usedKernDesc = 0x0

## Function Documentation

static void* getEmptyDesc | ( |  | ) | `[static]`

Definition at line 67 of file kmalloc.c.

References emptyDescSpinLock, emptyKernDesc, kpanic(), memset(), memDescriptor::next, memDescriptor::prev, spinLock(), spinUnlock(), vmm_getFreeMallocPage(), and x1.

Referenced by kmalloc().

Here is the call graph for this function:

static int insertFreeDesc | ( | struct memDescriptor * | freeDesc | ) | `[static]`

Definition at line 124 of file kmalloc.c.

References assert, freeKernDesc, kpanic(), memDescriptor::limit, memDescriptor::next, and memDescriptor::prev.

Referenced by kfree(), and kmalloc().

Here is the call graph for this function:

void kfree | ( | void * | baseAddr | ) |

Definition at line 351 of file kmalloc.c.

References assert, memDescriptor::baseAddr, insertFreeDesc(), kprintf(), memDescriptor::limit, mallocSpinLock, memset(), memDescriptor::next, memDescriptor::prev, spinLock(), spinUnlock(), and usedKernDesc.

Referenced by close(), device_remove(), elf_loadfile(), execFile(), fclose(), fopen(), kmod_load(), ldEnable(), mpi_destroyMbox(), mpi_fetchMessage(), ne2kFreeBuffer(), operator delete(), operator delete[](), sys_exec(), sys_write(), sysExec(), systemTask(), ubixfs_cacheDelete(), ubixFSmkDir(), ubthread_cond_destroy(), ubthread_mutex_destroy(), vfs_mount(), and writeUbixFS().

Here is the call graph for this function:

void* kmalloc | ( | uInt32 | len | ) |

Definition at line 247 of file kmalloc.c.

References assert, memDescriptor::baseAddr, freeKernDesc, getEmptyDesc(), insertFreeDesc(), kprintf(), memDescriptor::limit, MALLOC_ALIGN, mallocSpinLock, memDescriptor::next, memDescriptor::prev, spinLock(), spinUnlock(), and usedKernDesc.

Referenced by addDirEntry(), biosCall(), devfs_initialize(), devfs_makeNode(), device_add(), elf_loadfile(), execFile(), falloc(), fdc_init(), fopen(), initHardDisk(), initLNC(), kmain(), kmod_add(), kmod_load(), ldEnable(), lncAttach(), mpi_createMbox(), mpi_postMessage(), mpi_spam(), ne2k_init(), ne2kAllocBuffer(), openFileUbixFS(), operator new(), operator new[](), sched_init(), schedNewTask(), sys_exec(), sys_write(), sysctl_add(), sysctl_init(), sysExec(), tty_init(), ubixfs_cacheNew(), ubixfs_initialize(), ubixFSLoadDir(), ubixFSmkDir(), ubixFSUnlink(), ubthread_cond_init(), ubthread_create(), ubthread_mutex_init(), ufs_openFile(), vfs_mount(), vfsRegisterFS(), vitals_init(), and writeUbixFS().

Here is the call graph for this function:

static void mergeMemBlocks | ( |  | ) | `[static]`

Definition at line 185 of file kmalloc.c.

References memDescriptor::baseAddr, emptyKernDesc, freeKernDesc, memDescriptor::limit, memDescriptor::next, and memDescriptor::prev.

## Variable Documentation

spinLock_t emptyDescSpinLock = SPIN_LOCK_INITIALIZER`[static]`

Definition at line 55 of file kmalloc.c.

Referenced by getEmptyDesc().

struct memDescriptor* emptyKernDesc = 0x0`[static]`

Definition at line 49 of file kmalloc.c.

Referenced by getEmptyDesc(), and mergeMemBlocks().

struct memDescriptor* freeKernDesc = 0x0`[static]`

Definition at line 48 of file kmalloc.c.

Referenced by insertFreeDesc(), kmalloc(), and mergeMemBlocks().

spinLock_t mallocSpinLock = SPIN_LOCK_INITIALIZER`[static]`

Definition at line 54 of file kmalloc.c.

Referenced by kfree(), and kmalloc().

struct memDescriptor* usedKernDesc = 0x0`[static]`

Definition at line 47 of file kmalloc.c.

Referenced by kfree(), and kmalloc().