caddr_t _sbrk(int incr) { prev_heap_end = heap_end; if ((heap_end + incr) > (unsigned char *)_get_stack_pointer()) return (caddr_t)-1; heap_end += incr; return (caddr_t)prev_heap_end; }
void main() { //enable_mmu(); //arm_invalidate_data_caches(); //uart_init(); // gpio setup also affects emmc TODO: document uart_puts("-- EVANGELION/IMX233 kernel_main entered.\r\n"); setbuf(stdout, NULL); //libfs_init(); //init_rpi_qpu(); //uart_puts("-- QPU enabled.\r\n"); FB = (COLOR_TYPE*)0x40000000; FB_MEM = FB; //init_blitter(FB); sprintf(buf, "-- framebuffer at %p.\r\n",FB); uart_puts(buf); sprintf(buf, "-- heap starts at %p.\r\n", heap_end); uart_puts(buf); sprintf(buf, "-- stack pointer at %p.\r\n", _get_stack_pointer()); uart_puts(buf); memset(FB, 0x88, SCREEN_W*SCREEN_H*SCREEN_BPP); //eth_rx_buffer=malloc(64*1024); uart_repl(); }
/* Increase program data space. As malloc and related functions depend on this, it is useful to have a working implementation. The following suffices for a standalone system; it exploits the symbol _end automatically defined by the GNU linker. */ caddr_t _sbrk( int incr ) { extern char _end; static char* heap_end; char* prev_heap_end; if( heap_end == 0 ) heap_end = &_end; prev_heap_end = heap_end; if( ( heap_end + incr) > _get_stack_pointer() ) { while(1) { /* TRAP HERE! */ } } heap_end += incr; return (caddr_t)prev_heap_end; }