diff options
| author | Aleksa Vučković <aleksav013@gmail.com> | 2022-01-31 10:26:32 +0100 |
|---|---|---|
| committer | Aleksa Vučković <aleksav013@gmail.com> | 2022-01-31 10:26:32 +0100 |
| commit | 147200155c716a4ee76aa1f0402b90012d0a2883 (patch) | |
| tree | 25f0695605718c25e2c6d866ac1e225d75e9f8d3 | |
| parent | a914c37365967afaf3148293a857c36af6f94ecb (diff) | |
80 char per line
| -rwxr-xr-x | scripts/install_headers.sh | 1 | ||||
| -rwxr-xr-x | scripts/setup_compiler.sh | 2 | ||||
| -rw-r--r-- | src/c/gdt.c | 3 | ||||
| -rw-r--r-- | src/c/heap.c | 18 | ||||
| -rw-r--r-- | src/c/idt.c | 3 | ||||
| -rw-r--r-- | src/c/paging.c | 9 | ||||
| -rw-r--r-- | src/c/tty.c | 3 | ||||
| -rw-r--r-- | src/c/vga.c | 3 | ||||
| -rw-r--r-- | src/include/source/gdt.h | 3 | ||||
| -rw-r--r-- | src/include/source/heap.h | 3 | ||||
| -rw-r--r-- | src/include/source/idt.h | 3 |
11 files changed, 34 insertions, 17 deletions
diff --git a/scripts/install_headers.sh b/scripts/install_headers.sh index 213d9d5..8707fa8 100755 --- a/scripts/install_headers.sh +++ b/scripts/install_headers.sh @@ -3,4 +3,5 @@ SYSROOT="/opt/aleksa" SYSROOT_INCLUDE=$SYSROOT/usr/include/ +mkdir -p "$SYSROOT_INCLUDE" rsync src/include/ "$SYSROOT_INCLUDE" -ru --delete diff --git a/scripts/setup_compiler.sh b/scripts/setup_compiler.sh index 46870fd..0fd7bed 100755 --- a/scripts/setup_compiler.sh +++ b/scripts/setup_compiler.sh @@ -6,4 +6,4 @@ i686-aleksa-as "src/crt/crt0.s" -o "${GCC_INCLUDE}crt0.o" i686-aleksa-as "src/crt/crti.s" -o "${GCC_INCLUDE}crti.o" i686-aleksa-as "src/crt/crtn.s" -o "${GCC_INCLUDE}crtn.o" -#touch "${GCC_INCLUDE}libc.a" +touch "${GCC_INCLUDE}libc.a" 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<CMD_LENGTH;x++) for(size_t y=0;y<CMD_LENGTH;y++) pieces[x][y]='\0'; + for(size_t x=0;x<CMD_LENGTH;x++) for(size_t y=0;y<CMD_LENGTH;y++) + pieces[x][y]='\0'; size_t i=0,j=0,r=0; while(buffer[i]==' '&&buffer[i]!='\0') i++; diff --git a/src/c/vga.c b/src/c/vga.c index 5294144..ac1e409 100644 --- a/src/c/vga.c +++ b/src/c/vga.c @@ -95,7 +95,8 @@ void terminal_writefloat(double num) void clear(void) { - for(size_t i=0;i<VGA_HEIGHT;i++) for(size_t j=0;j<VGA_WIDTH;j++) terminal_putchar(' '); + for(size_t i=0;i<VGA_HEIGHT;i++) for(size_t j=0;j<VGA_WIDTH;j++) + terminal_putchar(' '); terminal_column=0; terminal_row=0; } diff --git a/src/include/source/gdt.h b/src/include/source/gdt.h index 7ed587c..f31a982 100644 --- a/src/include/source/gdt.h +++ b/src/include/source/gdt.h @@ -19,7 +19,8 @@ struct gdt_pointer uint32_t offset; } __attribute__((packed)); -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); void init_gdt_table(void); #endif diff --git a/src/include/source/heap.h b/src/include/source/heap.h index 15cba98..4bf12a7 100644 --- a/src/include/source/heap.h +++ b/src/include/source/heap.h @@ -18,7 +18,8 @@ typedef struct _KHEAPBM { extern KHEAPBM kheap; void k_heapBMInit(KHEAPBM *heap); -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); void *k_heapBMAlloc(KHEAPBM *heap, uint32_t size); void k_heapBMFree(KHEAPBM *heap, void *ptr); diff --git a/src/include/source/idt.h b/src/include/source/idt.h index b150d40..cbae940 100644 --- a/src/include/source/idt.h +++ b/src/include/source/idt.h @@ -28,7 +28,8 @@ struct idt_pointer uint32_t offset; } __attribute__((packed)); -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); void add_idt_entry(size_t num,uint32_t offset); void init_pic(void); void init_idt_table(void); |
