Xyris
0.5
Main Page
Namespaces
Namespace List
Namespace Members
All
_
a
b
c
d
e
f
g
h
i
k
m
n
p
r
s
t
u
v
w
y
Functions
_
c
d
e
f
g
h
i
k
m
n
p
r
s
t
v
w
Variables
Typedefs
Enumerations
Enumerator
a
b
c
e
g
i
k
m
n
r
s
t
u
v
w
y
Data Structures
Data Structures
Data Structure Index
Data Fields
All
_
a
b
c
d
e
f
g
h
i
l
m
n
o
p
r
s
t
u
v
w
~
Functions
a
b
c
d
e
f
g
h
i
l
m
n
o
p
r
s
t
u
v
w
~
Variables
_
a
b
c
d
e
f
g
h
i
l
m
n
o
p
r
s
t
u
v
w
Typedefs
Enumerations
Enumerator
Files
File List
Globals
All
_
a
b
c
d
e
f
g
i
k
l
m
n
o
p
r
s
t
v
w
Functions
_
c
f
g
i
k
l
m
n
o
p
r
s
t
w
Variables
_
a
b
c
d
e
f
i
m
n
p
r
s
t
w
Typedefs
Enumerations
Enumerator
a
b
g
i
l
o
p
t
Macros
_
a
b
c
e
f
k
l
m
n
p
r
s
t
v
•
All
Data Structures
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Macros
heap.hpp
Go to the documentation of this file.
1
/**
2
* @file heap.hpp
3
* @author Keeton Feavel (keetonfeavel@cedarville.edu)
4
* @brief Liballoc heap implementation
5
* @version 0.3
6
* @date 2019-11-22
7
*
8
* @copyright Copyright the Xyris Contributors (c) 2019
9
* Code shamelessly taken from the OSDev Wiki. The article
10
* can be found at the link below.
11
*
12
* https://wiki.osdev.org/User:Mrvn/LinkedListBucketHeapImplementation
13
*/
14
#pragma once
15
16
#include <stddef.h>
17
18
extern
"C"
{
19
20
/**
21
* @brief This function is supposed to lock the memory data structures. It
22
* could be as simple as disabling interrupts or acquiring a spinlock.
23
* It's up to you to decide.
24
*
25
* @return 0 if the lock was acquired successfully. Anything else is
26
* failure.
27
*/
28
int
liballoc_lock
();
29
30
/**
31
* @brief This function unlocks what was previously locked by the liballoc_lock
32
* function. If it disabled interrupts, it enables interrupts. If it
33
* had acquiried a spinlock, it releases the spinlock. etc.
34
*
35
* @return 0 if the lock was successfully released.
36
*/
37
int
liballoc_unlock
();
38
39
/**
40
* @brief This is the hook into the local system which allocates pages. It
41
* accepts an integer parameter which is the number of pages
42
* required. The page size was set up in the liballoc_init function.
43
*
44
* @return NULL if the pages were not allocated.
45
* @return A pointer to the allocated memory.
46
*/
47
void
*
liballoc_alloc
(
unsigned
int
);
48
49
/**
50
* @brief This frees previously allocated memory. The void* parameter passed
51
* to the function is the exact same value returned from a previous
52
* liballoc_alloc call.
53
*
54
* The integer value is the number of pages to free.
55
*
56
* @return 0 if the memory was successfully freed.
57
*/
58
int
liballoc_free
(
void
*,
unsigned
int
);
59
60
extern
void
*
malloc
(
size_t
);
61
extern
void
*
realloc
(
void
*,
size_t
);
62
extern
void
*
calloc
(
size_t
,
size_t
);
63
extern
void
free
(
void
*);
64
65
}
liballoc_unlock
int liballoc_unlock()
This function unlocks what was previously locked by the liballoc_lock function. If it disabled interr...
Definition:
heap.cpp:26
liballoc_free
int liballoc_free(void *, unsigned int)
This frees previously allocated memory. The void* parameter passed to the function is the exact same ...
Definition:
heap.cpp:36
free
void free(void *)
realloc
void * realloc(void *, size_t)
liballoc_alloc
void * liballoc_alloc(unsigned int)
This is the hook into the local system which allocates pages. It accepts an integer parameter which i...
Definition:
heap.cpp:31
malloc
void * malloc(size_t)
liballoc_lock
int liballoc_lock()
This function is supposed to lock the memory data structures. It could be as simple as disabling inte...
Definition:
heap.cpp:21
calloc
void * calloc(size_t, size_t)
Kernel
Memory
heap.hpp
Generated by
1.8.17