From 147200155c716a4ee76aa1f0402b90012d0a2883 Mon Sep 17 00:00:00 2001 From: Aleksa Vučković Date: Mon, 31 Jan 2022 10:26:32 +0100 Subject: 80 char per line --- src/c/gdt.c | 3 ++- src/c/heap.c | 18 ++++++++++++------ src/c/idt.c | 3 ++- src/c/paging.c | 9 ++++++--- src/c/tty.c | 3 ++- src/c/vga.c | 3 ++- src/include/source/gdt.h | 3 ++- src/include/source/heap.h | 3 ++- src/include/source/idt.h | 3 ++- 9 files changed, 32 insertions(+), 16 deletions(-) (limited to 'src') diff --git a/src/c/gdt.c b/src/c/gdt.c index 8791cbe..76ae9dd 100644 --- a/src/c/gdt.c +++ b/src/c/gdt.c @@ -6,7 +6,8 @@ extern void load_gdt(struct gdt_pointer *gdtp); struct gdt_entry gdt[5]; struct gdt_pointer gdtp; -void init_gdt_entry(size_t num, uint16_t limit, uint32_t base, uint8_t access, uint8_t limit_flags) +void init_gdt_entry(size_t num, uint16_t limit, uint32_t base, uint8_t access, + uint8_t limit_flags) { gdt[num].limit=limit; gdt[num].base1=(base & 0xffff); diff --git a/src/c/heap.c b/src/c/heap.c index aaa35dc..3120ed8 100644 --- a/src/c/heap.c +++ b/src/c/heap.c @@ -6,7 +6,8 @@ void k_heapBMInit(KHEAPBM *heap) heap->fblock = 0; } -int k_heapBMAddBlock(KHEAPBM *heap, uintptr_t addr, uint32_t size, uint32_t bsize) +int k_heapBMAddBlock(KHEAPBM *heap, uintptr_t addr, uint32_t size, uint32_t + bsize) { KHEAPBLOCKBM *b; uint32_t bcnt; @@ -64,7 +65,8 @@ void *k_heapBMAlloc(KHEAPBM *heap, uint32_t size) { bcnt = b->size / b->bsize; - bneed = (size / b->bsize) * b->bsize < size ? size / b->bsize + 1 : size / b->bsize; + bneed = (size / b->bsize) * b->bsize < size ? size / b->bsize + 1 : + size / b->bsize; bm = (uint8_t*)&b[1]; for (x = (b->lfb + 1 >= bcnt ? 0 : b->lfb + 1); x != b->lfb; ++x) @@ -75,7 +77,8 @@ void *k_heapBMAlloc(KHEAPBM *heap, uint32_t size) if (bm[x] == 0) { /* count free blocks */ - for (y = 0; bm[x + y] == 0 && y < bneed && (x + y) < bcnt; ++y); + for (y = 0; bm[x + y] == 0 && y < bneed && (x + y) < bcnt; + ++y); /* we have enough, now allocate them */ if (y == bneed) @@ -95,7 +98,8 @@ void *k_heapBMAlloc(KHEAPBM *heap, uint32_t size) return (void*)(x * b->bsize + (uintptr_t)&b[1]); } - /* x will be incremented by one ONCE more in our FOR loop */ + /* x will be incremented by one ONCE more in our FOR loop + * */ x += (y - 1); continue; } @@ -116,9 +120,11 @@ void k_heapBMFree(KHEAPBM *heap, void *ptr) for (b = heap->fblock; b; b = b->next) { - if ((uintptr_t)ptr > (uintptr_t)b && (uintptr_t)ptr < (uintptr_t)b + sizeof(KHEAPBLOCKBM) + b->size) { + if ((uintptr_t)ptr > (uintptr_t)b && (uintptr_t)ptr < (uintptr_t)b + + sizeof(KHEAPBLOCKBM) + b->size) { /* found block */ - ptroff = (uintptr_t)ptr - (uintptr_t)&b[1]; /* get offset to get block */ + ptroff = (uintptr_t)ptr - (uintptr_t)&b[1]; /* get offset to get + block */ /* block offset in BM */ bi = ptroff / b->bsize; /* .. */ diff --git a/src/c/idt.c b/src/c/idt.c index 5a84791..f73d574 100644 --- a/src/c/idt.c +++ b/src/c/idt.c @@ -8,7 +8,8 @@ extern void load_idt(struct idt_pointer *idtp); struct idt_entry idt[256]; struct idt_pointer idtp; -void init_idt_entry(size_t num, uint32_t offset, uint16_t selector, uint8_t type_attr) +void init_idt_entry(size_t num, uint32_t offset, uint16_t selector, uint8_t + type_attr) { idt[num].offset1=(uint16_t)(offset & 0xffff); idt[num].selector=selector; diff --git a/src/c/paging.c b/src/c/paging.c index f7b6e6a..9c4875a 100644 --- a/src/c/paging.c +++ b/src/c/paging.c @@ -23,15 +23,18 @@ uint32_t page_table[1024][1024] __attribute__((aligned(4096))); void set_pt(size_t num,uint32_t address) { - // holds the physical address where we want to start mapping these pages to. - // in this case, we want to map these pages to the very beginning of memory. + // holds the physical address where we want to start mapping these pages + // to. + // in this case, we want to map these pages to the very beginning of + // memory. //we will fill all 1024 entries in the table, mapping 4 megabytes for(size_t i=0;i<1024;i++) { // As the address is page aligned, it will always leave 12 bits zeroed. // Those bits are used by the attributes ;) - page_table[num][i] = (address + i * 0x1000) | 3; // attributes: supervisor level, read/write, present. + page_table[num][i] = (address + i * 0x1000) | 3; // attributes: + supervisor level, read/write, present. } page_directory[num] = ((uint32_t)page_table[num]) | 3; diff --git a/src/c/tty.c b/src/c/tty.c index a05773f..23eb204 100644 --- a/src/c/tty.c +++ b/src/c/tty.c @@ -9,7 +9,8 @@ extern uint32_t time; size_t pieces(char pieces[][CMD_LENGTH],char *buffer) { - for(size_t x=0;x