-BUILD_NUM = 223
+BUILD_NUM = 224
#define KERNEL_BASE 0xC0000000
#define BITS 32
+#define INVLPTR ((void*)-1)
+
// Allow nested spinlocks?
#define STACKED_LOCKS 2 // 0: No, 1: Per-CPU, 2: Per-Thread
#define LOCK_DISABLE_INTS 1
// === CONSTANTS ===
#define MAX_CALLBACKS_PER_IRQ 4
+#define TRACE_IRQS 0
// === TYPES ===
typedef void (*tIRQ_Callback)(int);
for( i = 0; i < MAX_CALLBACKS_PER_IRQ; i++ )
{
- //Log(" IRQ_Handler: Call %p", gIRQ_Handlers[Regs->int_num][i]);
- if( gIRQ_Handlers[Regs->int_num][i] )
+ if( gIRQ_Handlers[Regs->int_num][i] ) {
gIRQ_Handlers[Regs->int_num][i](Regs->int_num);
+ #if TRACE_IRQS
+ if( Regs->int_num != 8 )
+ Log("IRQ %i: Call %p", Regs->int_num, gIRQ_Handlers[Regs->int_num][i]);
+ #endif
+ }
}
//Log(" IRQ_Handler: Resetting");
#endif
#if LOCK_DISABLE_INTS
- // Save interrupt state and clear interrupts
- __ASM__ ("pushf;\n\tpop %%eax\n\tcli" : "=a"(IF));
+ // Save interrupt state
+ __ASM__ ("pushf;\n\tpop %0" : "=r"(IF));
IF &= 0x200; // AND out all but the interrupt flag
#endif
#else
__ASM__("xchgl %%eax, (%%edi)":"=a"(v):"a"(1),"D"(&Lock->Lock));
#endif
+
+ #if LOCK_DISABLE_INTS
+ if( v ) __ASM__("sti"); // Re-enable interrupts
+ #endif
}
#if LOCK_DISABLE_INTS
+ __ASM__("cli");
Lock->IF = IF;
#endif
}
#define STACKED_LOCKS 0
#define LOCK_DISABLE_INTS 1
+#define INVLPTR ((void*)0x0FFFFFFFFFFFFFFFULL)
+
//#define INT_MAX 0x7FFFFFFF
//#define UINT_MAX 0xFFFFFFFF
tHeapHead *best = NULL;
Uint bestSize = 0; // Speed hack
size_t Bytes;
+
+ if( __Bytes == 0 ) {
+ //return NULL; // TODO: Return a known un-mapped range.
+ return INVLPTR;
+ }
// Get required size
#if POW2_SIZES
Log_Log("Heap", "free: Returns to %p", __builtin_return_address(0));
#endif
+ // INVLPTR is returned from Heap_Allocate when the allocation
+ // size is zero.
+ if( Ptr == INVLPTR ) return;
+
// Alignment Check
if( (Uint)Ptr & (sizeof(Uint)-1) ) {
Log_Warning("Heap", "free - Passed a non-aligned address (%p)", Ptr);
// Print the block info?
#if 1
- Log_Debug("Heap", "%p - 0x%x Owned by %s:%i",
- head, head->Size, head->File, head->Line);
+ Log_Debug("Heap", "%p - 0x%x (%i) Owned by %s:%i",
+ head, head->Size, head->ValidSize, head->File, head->Line);
#endif
}