+ /* allocate stack space at the top of a memory range, order of preference:
+ * fast, slow, chip
+ */
+ for(i=0; i<NUM_POOLS; i++) {
+ mr = pool[i];
+ if(mr && mr->size >= STACK_SIZE) {
+ stack_top = (uint32_t)mr->start + mr->size;
+ stack_base = stack_top - STACK_SIZE;
+ mr->size -= STACK_SIZE;
+ break;
+ }
+ }
+
+ if(!stack_base) {
+ panic("Failed to allocate stack, no suitable memory ranges found!\n");
+ }
+
+ printf("Allocated %dk stack space: %06lx - %06lx\n", STACK_SIZE >> 10, stack_base, stack_top);
+ move_init_stack(stack_top);
+