#define VERSTR "v0.0"
/* CONDEV: which device to use for the kernel console (DEV_VID or DEV_SER) */
-#define CONDEV DEV_VID
+#define CONDEV DEV_SER
#endif /* CONFIG_H_ */
pptr = pool;
while(pptr) {
if(fullsz <= pptr->len) {
- newfree = pptr + fullsz;
+ newfree = (struct memrange __far*)((char __far*)pptr + fullsz);
newfree->magic = pptr->magic;
newfree->len = pptr->len - fullsz;
newfree->next = pptr->next;
void dbg_print_kmalloc_pool(void)
{
struct memrange __far *m;
+ struct memrange __far *end;
m = pool;
while(m) {
- printf("[%x:%x/%x] ", FP_SEG(m), FP_OFFS(m), m->len);
+ end = (struct memrange __far*)((char __far*)m + m->len);
+ printf("[%04x:%04x - ", FP_SEG(m), FP_OFFS(m));
+ printf("%04x:%04x] (%x)\n", FP_SEG(end), FP_OFFS(end), m->len);
m = m->next;
}
- putchar('\n');
}
void dbg_print_kmalloc_stats(void)
typedef char *va_list;
-#define va_start(ap, last) ((ap) = (va_list)&(last))
-#define va_arg(ap, type) ((ap) += sizeof(type), *(type*)(ap))
+#define va_start(ap, last) ((ap) = (char*)&(last) + sizeof(last))
+#define va_arg(ap, type) ((ap) += sizeof(type), *(type*)((ap) - sizeof(type)))
#define va_end(ap)
#define va_copy(dest, src) ((dest) = (src))
static void wrchar(struct outbuf *outbuf, int c);
static int wrstr(struct outbuf *outbuf, struct format *fmt, const char *s);
static int wrint(struct outbuf *outbuf, struct format *fmt, long val);
-static int wruint(struct outbuf *outbuf, struct format *fmt, unsigned long val);
+int wruint(struct outbuf *outbuf, struct format *fmt, unsigned long val);
int printf(const char *fmt, ...)
{
reset_format(&fmt);
break;
+ case 'l':
+ fmt.flags |= FMT_LONG;
+ break;
+
case '0':
if(fmt.fchar != '0') {
fmt.fchar = '0';
return wrstr(outbuf, fmt, ptr);
}
-static int wruint(struct outbuf *outbuf, struct format *fmt, unsigned long val)
+int wruint(struct outbuf *outbuf, struct format *fmt, unsigned long val)
{
- static const char hexconv[] = "0123456789abcdef";
char buf[16], *ptr = buf + 15;
buf[15] = 0;
printf("eightysix kernel %s\n", VERSTR);
- printf("kmalloc free pool\n");
- dbg_print_kmalloc_pool();
- printf("kmalloc stats\n");
+ printf("initial kmalloc stats\n");
dbg_print_kmalloc_stats();
+ printf("initial free pool\n");
+ dbg_print_kmalloc_pool();
void __far *ptr[32];
for(i=0; i<32; i++) {
ptr[i] = kmalloc(256);
+ printf("ALLOC(256) - %x:%x\n", FP_SEG(ptr[i]), FP_OFFS(ptr[i]));
}
- for(i=0; i<20; i++) {
+ printf("\nallocated 32 256b blocks ... ");
+ dbg_print_kmalloc_stats();
+ dbg_print_kmalloc_pool();
+
+ for(i=0; i<40; i++) {
int idx = rand() & 0x1f;
if(ptr[idx]) {
+ printf("FREE(%x:%x)\n", FP_SEG(ptr[idx]), FP_OFFS(ptr[idx]));
kfree(ptr[idx]);
ptr[idx] = 0;
+ dbg_print_kmalloc_pool();
}
}
- printf("kmalloc free pool\n");
- dbg_print_kmalloc_pool();
- printf("kmalloc stats\n");
+ printf("\nafter freeing some... kmalloc free pool\n");
dbg_print_kmalloc_stats();
+ dbg_print_kmalloc_pool();
init_intr();
}