Nine times out of ten it will triple fault. The bit that is my kernel is attempting to set when it triple faults seems entirely random.
However, the range seems fairly consistent. 0x1FFFFA0-0x1FFFFFF
Another weird issue that probably has a very easy fix is happening (that i think mite be related to this issue). For example, the bit storage will be at 0x106000.
Here's the particular function that's causing the error. (I think)
Code: Select all
int SetBits(Bitset* b, int bit_start, int bit_end) {
kprintf("bit_start=%x, bit_end=%x\n", bit_start, bit_end);
wait(1);
register int i;
if(bit_start == 0) {
b->bits_before_bit_change = bit_end;
b->bits_type = on;
} else if(bit_start == b->bits_before_bit_change && b->bits_type==on) {
b->bits_before_bit_change = bit_end;
b->bits_type = on;
}
/*if((bit_start%32)==0 && (bit_end%32)==0) {
int iend = bit_end/32;
for(i = bit_start/32; i<iend; i++) {
if((i%0x5000)==0) {
kprintf("loop!%x\n", i*32);
}
if(i >= b->length) {
kprintf("YOU FAILED!!\n");
return 1;
}
b->bit_storage[i] = 0xFFFFFFFF;
}
return 0;
}*/
for(i = bit_start; i<bit_end; i++) {
if((i%32)==0 && bit_end-i>=32) { /*
if(i/32 >= b->length) {
return 1;
} else {
// Mark it. duh.
b->bit_storage[i/32] = 0xFFFFFFFF;
i+=31;
}*/
} else if(SetBit(b, i) == 1) {
return 1;
}
if((UInt32) i>=0x1ffffa0) {
PutHex(i);
PrintChar('\r');
}
}
return 0;
}
also, paging code (which is calling the SetBits() function)
Code: Select all
Bitset* bits;
...
#define ONE_TO_ONE_MAP_MB 32
...
void Paging_Init(int kb_of_mem) {
...
for(i=0; i<(ONE_TO_ONE_MAP_MB/4); i++) {
kprintf("start=");
if(SetBits(bits, (i*MEGABYTE*4), ((i+1)*MEGABYTE*4))==1) {
kprintf("Error");
}
kprintf("middle=");
PageTable* pt = IdMapPageTable(i);
pd->d[i] = AssemblePDE((Pointer) pt->t, 0x7);
kprintf("%x %x, %x\n", i, (i*MEGABYTE*4), ((i+1)*MEGABYTE*4));
}
...
}