Page 1 of 1

Why I can't print?

Posted: Sun Sep 10, 2006 6:39 am
by kiss.manfonly
I use following code to print my memory:

Code: Select all

void prt_mem_info() 
{
   unsigned long size = e820_size;
   printk("There is total %i memory areas\n", size);
   printk("BaseAddr\tLength\tType\n");
   unsigned long i, j, * ptr;
   
   for (i = 0; i < size; i++) {
      ptr = (unsigned long *)(e820_graph + i);

      printk("0x%x%x\t0x%x%x\t%u\n", 
         ptr[1], ptr[0],
         ptr[3], ptr[2],
         e820_graph[i].type);
      //printk("This is index %i\n", i);
   }
}
And I found a strange thing:
This code works fine in other places(it can scroll the screen) .

When I test in bochs and qemu, they work fine;
When I test in the real hardware, it only print 3 memory areas(total 9 areas)
When I add the last printk(commented), it can printk 6 memory areas....
Why?

Re:Why I can't print?

Posted: Mon Sep 11, 2006 2:46 am
by Pype.Clicker
pretty suspicious behaviour, indeed.
btw, keep in mind that, unlike real machines, BOCHS and QEMU do clear all memory you use. That means if you have an unitialized pointer somewhere, it will behave quite strangely on a real machine.

Oh, and maybe you want to make sure your printk code doesn't trash any other variable (e.g. do you have a sort of 'putc' function? do you prepare the string to be written somewhere? or maybe you write to video memory directly ?)