Skip to content
Permalink
Browse files

Add support to clang compilation

- Add support to clang compilation
- Fix memory allocator
  • Loading branch information...
rene committed May 28, 2018
1 parent 0bce3ed commit d07624cfc550e6e16a058bc2c16ededf608d56be
Showing with 14 additions and 19 deletions.
  1. +2 −2 kernel/arch/x86/build/Makefile
  2. +5 −6 kernel/fs/bhash.c
  3. +0 −7 kernel/kernel/fork.c
  4. +1 −0 kernel/kernel/kernel.c
  5. +6 −4 kernel/kernel/mm/kmalloc.c
@@ -11,10 +11,10 @@ CWD := arch/x86/build


# Architecture compiler and link flags
ARCH_CF := -m32
ARCH_CF := -m32 -march=i486
ARCH_LF := -melf_i386
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

@@ -298,15 +298,14 @@ static buff_header_t *getblk(int major, int device, uint64_t blocknum)

driver = block_dev_drivers[major];

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

while(1) {

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

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

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

cli();

@@ -89,13 +89,6 @@ void _exec_init(char *init_data, size_t size)
newth->kstack = (char*)((void*)new_stack + PROCESS_STACK_SIZE);

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.fs = USER_DS_RPL;
newth->arch_tss.regs.gs = USER_DS_RPL;
@@ -138,6 +138,7 @@ void kernel_main_thread(void *arg)
}

/* Mount root file system */
memset(&rootdev, 0, sizeof(rootdev));
rstr = cmdline_get_value("root");
strcpy(rdev_str, rstr);
rdev_len = strlen(rstr);
@@ -57,7 +57,7 @@ void *_vmalloc_(mem_map *memm, uint32_t size, uint16_t flags)
uint32_t apages, index;
uint32_t size_region;
uint32_t newpage;
uint32_t *mem_block;
uchar8_t *mem_block;
uint32_t *table;
mregion *mem_area;
zone_t mzone;
@@ -140,6 +140,7 @@ void *_vmalloc_(mem_map *memm, uint32_t size, uint16_t flags)
i++;
} else {
index++;
i = 0;
table = pgdir->tables[index];
}
}
@@ -154,16 +155,16 @@ void *_vmalloc_(mem_map *memm, uint32_t size, uint16_t flags)
mem_area->initial_addr = pstart;
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) ) {
for(i=0; i<((size - sizeof(mregion)) / sizeof(void*)); i++) {
for(i=0; i<((size - sizeof(mregion)) / sizeof(char)); i++) {
mem_block[i] = 0;
}
}

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

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

0 comments on commit d07624c

Please sign in to comment.
You can’t perform that action at this time.