1. My .bss section doesn't work and I have no idea why, here's my makefile and linker script..
Code: Select all
link command is ld -T link.ld -o jouleos.bin asm.o .objs/kernel/main.o..(more objects)
linker script:
ENTRY(asm.o)
phys = 0x00100000;
SECTIONS
{
.text phys : AT(phys) {
_code = .;
*(.text)
. = ALIGN(4096);
}
.data : AT(phys + (_data - _code))
{
_data = .;
*(.data)
. = ALIGN(4096);
}
.bss : AT(phys + (_bss - _code))
{
_bss = .;
*(.bss)
. = ALIGN(4096);
}
end = .;
}
2. Even when I force it to not use .bss for variables my memory manager still doesn't completely work!
theirs really not an easy way to put it..
Code: Select all
inline unsigned char SetDataBit(void *data,unsigned int bit,unsigned int set){ //set should be 1 to set the bit to 1, or 0 to set the bit to 0
unsigned int *ptr=data; //we do int for 32bit optimization
ptr=ptr+(bit/32);
if(set==0){
*ptr=*ptr&(0xFFFFFFFF^(1<<(bit%32)));
}else{
*ptr=*ptr|(1<<(bit%32));
}
return *ptr;
}
inline unsigned char GetDataBit(void *data,unsigned int bit){
unsigned int *ptr=data;
ptr=ptr+(bit/32);
return *ptr&(1<<(bit%32));
}
void SetDataBits(void *data,unsigned int base,unsigned int limit,unsigned int set){
for(base=base;base<=limit;base++){
SetDataBit(data,base,set);
}
}
//set should be 1 if your searching for 0 bits and want to set them to 1 or 0 if your looking for 1 bits and want to set them to 0
// the 0 bit should be SET, as if it tries to set this bit and returns it, then it will make the caller think that their was no space
//otherwise though this returns 0 for no space, or the base bit set
unsigned int SetFreeBits(void *data,unsigned int base,unsigned int limit,unsigned int number,unsigned int set){ //set determines which way you want to set it..
unsigned int tmp;
unsigned int i;
unsigned char base_for;
unsigned char is_free=0;
tmp=number;
for(i=base;i<=limit;i++){
if(GetDataBit(data,i)==(set^1)){
if(is_free==0){base_for=i;}
is_free=1;
}else{
base_for=0;
is_free=0;
}
if(is_free==1){tmp--;}else{tmp=number;}
if(tmp==0){
SetDataBits(data,base_for,base_for+number,set);
return base_for;
}
}
return 0;
}
//this override functions let you alloc or free a range of addresses..
unsigned int override_AllocCore(AddressSpace *space, unsigned int base,unsigned int number){
if((base+number)>space->limit){return 0;}
SetDataBits(space->address,base,number,1);
return base;
}
unsigned int FreeCore(AddressSpace *space,unsigned int base,unsigned int number){
if((base+number)>space->limit){return 0;}
SetDataBits(space->address,base,number,0);
return base;
}
unsigned int AllocCore(AddressSpace *space, unsigned int number){
return SetFreeBits(space->address,0,space->limit,number,1); //yea simple..
}
void SetupAddressSpace(AddressSpace *space,void *address,unsigned int limit,unsigned char uses_paging,void *owner){
space->address=address;
memset(space->address,0,(limit/32)+1);
//putc_tmp('2');
space->limit=limit;
space->page_addressing=uses_paging;
space->owner=owner;
AllocCore(space,1); //allocate first bit..
}
unsigned int virtual_address[32768]={0};
unsigned int physical_address[32768]={0};
AddressSpace physical_memory;
AddressSpace virtual_memory;
void InitMemMan(){
//putc_tmp("h");
//I 0xFFFF FFFF isn't right!?
SetupAddressSpace(&physical_memory,physical_address,0xFFFFF,1,0); //eventually change the limit to the size of physical memory..
SetupAddressSpace(&virtual_memory,virtual_address,0xFFFFF,1,0);
override_AllocCore(&physical_memory,0,0x20000/4096); //allocate first 2 megs
//This below is only for testing
if(AllcCore(&virtual_address,20)==0){__asm("hlt");}else{putc_tmp('h');}
}