Skip to content

Commit

Permalink
Add support to clang compilation
Browse files Browse the repository at this point in the history
- Add support to clang compilation
- Fix memory allocator
  • Loading branch information
rene committed May 28, 2018
1 parent 0bce3ed commit d07624c
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 19 deletions.
4 changes: 2 additions & 2 deletions kernel/arch/x86/build/Makefile
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@ CWD := arch/x86/build




# Architecture compiler and link flags # Architecture compiler and link flags
ARCH_CF := -m32 ARCH_CF := -m32 -march=i486
ARCH_LF := -melf_i386 ARCH_LF := -melf_i386
INCDIRS := -I$(PWD)/include -I$(PWD)/arch/include INCDIRS := -I$(PWD)/include -I$(PWD)/arch/include
CFLAGS := $(INCDIRS) -fno-builtin -Wall -nostdlib -nostartfiles -nodefaultlibs $(ARCH_CF) CFLAGS := $(INCDIRS) -fno-builtin -Wall -nostdlib -nodefaultlibs $(ARCH_CF)


MAKEGEN := $(CWD)/MakefileX86.gen MAKEGEN := $(CWD)/MakefileX86.gen


Expand Down
11 changes: 5 additions & 6 deletions kernel/fs/bhash.c
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -298,15 +298,14 @@ static buff_header_t *getblk(int major, int device, uint64_t blocknum)


driver = block_dev_drivers[major]; driver = block_dev_drivers[major];


if (driver == NULL) { if (driver == NULL) {
return NULL; return NULL;
} }


while(1) { while(1) {


if ( (buff = search_blk(driver->buffer_queue, device, blocknum)) != NULL ) { if ( (buff = search_blk(driver->buffer_queue, device, blocknum)) != NULL ) {
/* Block is in hash queue */ /* Block is in hash queue */

if (buff->status == BUFF_ST_BUSY) { if (buff->status == BUFF_ST_BUSY) {
sleep_on(WAIT_THIS_BLOCK_BUFFER_GET_FREE); sleep_on(WAIT_THIS_BLOCK_BUFFER_GET_FREE);
continue; continue;
Expand Down Expand Up @@ -364,8 +363,8 @@ void brelse(int major, int device, buff_header_t *buff)


/* Checking driver pointer after wakeup function. */ /* Checking driver pointer after wakeup function. */
if (driver == NULL) { if (driver == NULL) {
return; return;
} }


cli(); cli();


Expand Down
7 changes: 0 additions & 7 deletions kernel/kernel/fork.c
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -89,13 +89,6 @@ void _exec_init(char *init_data, size_t size)
newth->kstack = (char*)((void*)new_stack + PROCESS_STACK_SIZE); newth->kstack = (char*)((void*)new_stack + PROCESS_STACK_SIZE);


newth->arch_tss.regs.eip = (uint32_t)0xC0000C; /* Start point */ newth->arch_tss.regs.eip = (uint32_t)0xC0000C; /* Start point */
/* newth->arch_tss.regs.ds = KERNEL_DS;
newth->arch_tss.regs.fs = KERNEL_DS;
newth->arch_tss.regs.gs = KERNEL_DS;
newth->arch_tss.regs.ss = KERNEL_DS;
newth->arch_tss.regs.es = KERNEL_DS;
newth->arch_tss.regs.cs = KERNEL_CS;
*/
newth->arch_tss.regs.ds = USER_DS_RPL; newth->arch_tss.regs.ds = USER_DS_RPL;
newth->arch_tss.regs.fs = USER_DS_RPL; newth->arch_tss.regs.fs = USER_DS_RPL;
newth->arch_tss.regs.gs = USER_DS_RPL; newth->arch_tss.regs.gs = USER_DS_RPL;
Expand Down
1 change: 1 addition & 0 deletions kernel/kernel/kernel.c
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -138,6 +138,7 @@ void kernel_main_thread(void *arg)
} }


/* Mount root file system */ /* Mount root file system */
memset(&rootdev, 0, sizeof(rootdev));
rstr = cmdline_get_value("root"); rstr = cmdline_get_value("root");
strcpy(rdev_str, rstr); strcpy(rdev_str, rstr);
rdev_len = strlen(rstr); rdev_len = strlen(rstr);
Expand Down
10 changes: 6 additions & 4 deletions kernel/kernel/mm/kmalloc.c
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ void *_vmalloc_(mem_map *memm, uint32_t size, uint16_t flags)
uint32_t apages, index; uint32_t apages, index;
uint32_t size_region; uint32_t size_region;
uint32_t newpage; uint32_t newpage;
uint32_t *mem_block; uchar8_t *mem_block;
uint32_t *table; uint32_t *table;
mregion *mem_area; mregion *mem_area;
zone_t mzone; zone_t mzone;
Expand Down Expand Up @@ -140,6 +140,7 @@ void *_vmalloc_(mem_map *memm, uint32_t size, uint16_t flags)
i++; i++;
} else { } else {
index++; index++;
i = 0;
table = pgdir->tables[index]; table = pgdir->tables[index];
} }
} }
Expand All @@ -154,16 +155,16 @@ void *_vmalloc_(mem_map *memm, uint32_t size, uint16_t flags)
mem_area->initial_addr = pstart; mem_area->initial_addr = pstart;
mem_area->size = npages; mem_area->size = npages;


mem_block = (void*)((void*)mem_block + sizeof(mregion)); mem_block = (uchar8_t*)((uchar8_t*)mem_block + sizeof(mregion));


if( (flags & GFP_ZEROP) ) { if( (flags & GFP_ZEROP) ) {
for(i=0; i<((size - sizeof(mregion)) / sizeof(void*)); i++) { for(i=0; i<((size - sizeof(mregion)) / sizeof(char)); i++) {
mem_block[i] = 0; mem_block[i] = 0;
} }
} }


/* We have done =:) */ /* We have done =:) */
return(mem_block); return((void*)mem_block);


error: error:
/* Free pages allocated */ /* Free pages allocated */
Expand All @@ -178,6 +179,7 @@ void *_vmalloc_(mem_map *memm, uint32_t size, uint16_t flags)
} else { } else {
index--; index--;
table = pgdir->tables[index]; table = pgdir->tables[index];
i = TABLE_SIZE - 1;
} }
} }
return(0); return(0);
Expand Down

0 comments on commit d07624c

Please sign in to comment.