aboutsummaryrefslogtreecommitdiff
path: root/kernel/l0/frame.c
diff options
context:
space:
mode:
authorAlex Auvolat <alex.auvolat@ens.fr>2014-12-04 10:43:58 +0100
committerAlex Auvolat <alex.auvolat@ens.fr>2014-12-04 10:43:58 +0100
commit292e4141078d18993b1395820631503ac852eb3d (patch)
tree3b3e5cb75d9bf3abb2639deedc247eba2cdeabe6 /kernel/l0/frame.c
parentd78a3d8be9c194554580cb3c73c1c5ebd0d82a9b (diff)
downloadkogata-292e4141078d18993b1395820631503ac852eb3d.tar.gz
kogata-292e4141078d18993b1395820631503ac852eb3d.zip
Make paging work ! \o/
Diffstat (limited to 'kernel/l0/frame.c')
-rw-r--r--kernel/l0/frame.c10
1 files changed, 5 insertions, 5 deletions
diff --git a/kernel/l0/frame.c b/kernel/l0/frame.c
index 1f16eaf..c646a48 100644
--- a/kernel/l0/frame.c
+++ b/kernel/l0/frame.c
@@ -4,8 +4,8 @@
// TODO: buddy allocator
// this is a simple bitmap allocator
-#define INDEX_FROM_BIT(a) (a/(8*4))
-#define OFFSET_FROM_BIT(a) (a%(8*4))
+#define INDEX_FROM_BIT(a) ((a)/(8*4))
+#define OFFSET_FROM_BIT(a) ((a)%(8*4))
static uint32_t *frame_bitset;
static uint32_t nframes, nused_frames;
@@ -54,9 +54,9 @@ uint32_t frame_alloc(size_t n) {
}
void frame_free(uint32_t base, size_t n) {
- for (size_t x = 0; x < n; x++) {
- uint32_t idx = INDEX_FROM_BIT(base + n);
- uint32_t ofs = OFFSET_FROM_BIT(base + n);
+ for (size_t i = 0; i < n; i++) {
+ uint32_t idx = INDEX_FROM_BIT(base + i);
+ uint32_t ofs = OFFSET_FROM_BIT(base + i);
if (frame_bitset[idx] & (0x1 << ofs)) {
frame_bitset[idx] &= ~(0x1 << ofs);
nused_frames--;