Skip to content

Commit db85c88

Browse files
committed
Implements mm_free_physical.
Signed-off-by: Nathan Ringo <me@remexre.com>
1 parent 4112058 commit db85c88

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

src/kernel/mm/physical_alloc.c

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -208,3 +208,15 @@ bool mm_alloc_physical(paddr *out) {
208208
*out = paddr_offset(head, link.length << 12);
209209
return true;
210210
}
211+
212+
void mm_free_physical(paddr frame) {
213+
// TODO: There should be a lock around essentially this whole function.
214+
assert(bits_of_paddr(frame));
215+
216+
struct physical_free_list link = {
217+
.next = free_list_head,
218+
.length = 1,
219+
};
220+
copy_to_physical(frame, &link, sizeof(struct physical_free_list));
221+
free_list_head = frame;
222+
}

0 commit comments

Comments
 (0)