Why I can't print?

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
Post Reply
kiss.manfonly

Why I can't print?

Post 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?
User avatar
Pype.Clicker
Member
Member
Posts: 5964
Joined: Wed Oct 18, 2006 2:31 am
Location: In a galaxy, far, far away
Contact:

Re:Why I can't print?

Post 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 ?)
Post Reply