On Sun, Aug 2, 2009 at 6:37 AM, Jason Wang<[email protected]> wrote: > updated the new, which changed the display value > static void setup(void) > { > int size = (unsigned int)(&_eheap - &_heap) - HDRSIZE; > *((hdrtype_t *) hstart) = FREE_BLOCK(size); > // printf("%s memory size:0x%x,begin:0x%x end:0x%x, > hstart:0x%x\n",__func__,size,(unsigned int)&_heap,(unsigned > int)&_eheap,(unsigned int )*((hdrtype_t *) hstart)); > > > } > > static void *alloc(int len) > { > hdrtype_t header; > void *ptr = hstart; > printf("%s %d length:0x%x,ptr=0x%x \n",__func__,__LINE__,len,(unsigned > int )ptr); > printf("%s %d memory begin:0x%x end:0x%x, > hstart:0x%x\n",__func__,__LINE__,(unsigned int)&_heap,(unsigned > int)&_eheap,(unsigned int ) hstart); > /* Align the size. */ > len = (len + 3) & ~3; > > if (!len || len > 0xffffff) > return (void *)NULL; > // while(1); > > /* Make sure the region is setup correctly. */ > if (!HAS_MAGIC(*((hdrtype_t *) ptr))){ > setup(); > } > if (!HAS_MAGIC(*((hdrtype_t *) ptr))){ > printf("set up error,*ptr=0x%x\n",(unsigned int)*((hdrtype_t *) ptr)); > } > > /* Find some free space. */ > do { > header = *((hdrtype_t *) ptr); > int size = SIZE(header); > > if (!HAS_MAGIC(header) || size == 0) { > printf("memory allocator panic!!! the size=0x%x. > header=0x%x\n",size,(unsigned int)header); > halt(); > } > > if (header & FLAG_FREE) { > if (len <= size) { > void *nptr = ptr + (HDRSIZE + len); > int nsize = size - (HDRSIZE + len); > > /* If there is still room in this block, > * then mark it as such otherwise account > * the whole space for that block. > */ > > if (nsize > 0) { > /* Mark the block as used. */ > *((hdrtype_t *) ptr) = USED_BLOCK(len); > > /* Create a new free block. */ > *((hdrtype_t *) nptr) = > FREE_BLOCK(nsize); > } else { > /* Mark the block as used. */ > *((hdrtype_t *) ptr) = USED_BLOCK(size); > } > > return (void *)(ptr + HDRSIZE); > } > } > > ptr += HDRSIZE + size; > > } while (ptr < hend); > > /* Nothing available. */ > return (void *)NULL; > } > result log: > Running option rom at ce00:0003 > hello, initialize_usb > 00:13.0 4387:1002.0 OHCI controller > Not supported. > 00:13.1 4388:1002.1 OHCI controller > Not supported. > 00:13.2 4389:1002.2 OHCI controller > Not supported. > 00:13.3 438a:1002.3 OHCI controller > Not supported. > 00:13.4 438b:1002.4 OHCI controller > Not supported. > 00:13.5 4386:1002.5 EHCI controller > Not supported. > 00:05.0 3038:1106.0 UHCI controller > alloc 82 length:0x238,ptr=0x3077e0 > alloc 83 memory begin:0x77e0 end:0x577e0, hstart:0x300000 > set up error,*ptr=0xa2c0e2cc > memory allocator panic!!! the size=0xc0e2cc. header=0xa2c0e2cc
You're trying to allocate 1.25 Mbytes of memory? Why is that? ron -- coreboot mailing list: [email protected] http://www.coreboot.org/mailman/listinfo/coreboot

