[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

heap initialization was Re: struct pointer initialization (fwd)



Please be careful to reply to the list.

--joel
Joel Sherrill, Ph.D.             Director of Research & Development
joel at OARcorp.com                 On-Line Applications Research
Ask me about RTEMS: a free RTOS  Huntsville AL 35805
   Support Available             (256) 722-9985


---------- Forwarded message ----------
Subject: Re: heap initialization was Re: struct pointer initialization 

> 
> This is the response I posted to the same post on crossgcc.
> 
> --joel
> Joel Sherrill, Ph.D.             Director of Research & Development
> joel at OARcorp.com                 On-Line Applications Research
> Ask me about RTEMS: a free RTOS  Huntsville AL 35805
>    Support Available             (256) 722-9985
> 
> 
> ---------- Forwarded message ----------
> Date: Fri, 9 Jul 1999 08:46:55 -0500 (CDT)
> From: joel at OARcorp.com
> To: crossgcc at cygnus.com
> Subject: Re: struct pointer initialization
> 
> 
> 
> On 9 Jul 1999 biguo at 263.net wrote:
> 
> > hello,everyone!I find some problem in following statements :
> >   the_block= (struct  Heap_Block *)0xdd800;
> >   the_block->back_flag = 1;
> >   the_block->front_flag = 0x22800;
> >   the_block->next=(struct  Heap_Block *)0;
> >   the_block->previous=(struct  Heap_Block *)0;
> 
> > In first statement,struct pointer the_block is pointed to address
> > 0xdd800.But the four elements of struct the_block can't be
> > initialized.Their contents all are 0xffffffff.The above initial
> > statements has no effect on the content of four element.It result in
> > failure in work space initialization.How to solve it?Thanks in advance
> > for any help.
> 
> In case I am not the only one to recognize this code, it is from RTEMS. :)
> 
> More than likely, this indicates that:
> 
> 1.  there is not really memory at 0xdd800  
> 
> 2.  the memory controller is not properly initialized.
> 
> 3.  If I recall correctly, you are on an i386ex, so you have to worry
>     about the descriptor tables being setup correctly.  These writes
>     could just be going off in the ether.
> 
> This is definitely during system initialization so any subtle HW
> initialization or memory layout (linker script, etc) problem could cause
> this.
> 
> hello world is a surprisingly difficult program to get running on an
> embedded target. :)  Cables, development tools, linker scripts, device
> drivers, hardware initialization, etc must all be right for you to print
> that magic phrase.  After that, life is usually much easier.
> 
> --joel
> Joel Sherrill, Ph.D.             Director of Research & Development
> joel at OARcorp.com                 On-Line Applications Research
> Ask me about RTEMS: a free RTOS  Huntsville AL 35805
>    Support Available             (256) 722-9985
> 
>   
> 
 > 

---Dan LUO
Let's redeclare the question: 
in Heap_Initialize(heap.c)
.....
the_block             = (Heap_Block *) starting_address;
  the_block->back_flag  = HEAP_DUMMY_FLAG;
  the_block->front_flag = the_size;
/*ADD*/printk("the_block->front_flag= %\n",the_block->front_flag);
  the_block->next       = _Heap_Tail( the_heap );
  the_block->previous   = _Heap_Head( the_heap );

  the_heap->start          = the_block;
  the_heap->first          = the_block;
  the_heap->permanent_null = NULL;
  the_heap->last           = the_block;
  the_block->front_flag = the_size;
/*ADD*/printk("the_block->front_flag= %\n",the_block->front_flag);

  the_block             = _Heap_Next_block( the_block );
.....
the printk shows front_flag be setted correctly.
but _Heap_Next_block changes the value of front_flag to 0xffffffff.
now the_block(not first one) is below starting_address.
(if starting_address=0xdd800,the ret value is 0xdd7fe).
in heap.inl:
RTEMS_INLINE_ROUTINE Heap_Block *_Heap_Next_block (
  Heap_Block *the_block
)
{
  return (Heap_Block *) _Addresses_Add_offset(
                          (void *)the_block,
                          the_block->front_flag & ~ HEAP_BLOCK_USED
                        );
}

Does (void *)the_block do some thing wrong,so the_block->front_flag be changed or location problem?
  



_____________________________________________
????????--???????????????????? http://www.263.net
???????? ???????? ???????? ???????? ??????????
???????? ???????? ???????? ???????? ????????
???????? ???????? ???????? ???????? ????????