#include #include #include #include #include #include #include #include struct fb myfb; void video(void) { unsigned int x, y; pl111_init(&myfb, 24); x = 0, y = 0; for (y=0; y<480; y++) for (x=0; x<640; x++) fb_write_pixel(&myfb, x, y, 0x3f, 0x0, 0x6f); console_init(&myfb); } void test_memory() { struct page *p, *q; p = mm_get_free_pages(0); if (p) print("%x, %x\n", p, p->address); else print("Error: failed to allocate memory for p\n"); q = mm_get_free_pages(4); if (q) print("%x, %x\n", q, q->address); else print("Error: failed to allocate memory for q\n"); mm_put_free_pages(p); mm_put_free_pages(q); q = mm_get_free_pages(1); if (q) print("%x, %x\n", q, q->address); else print("Error: failed to allocate memory for q\n"); p = mm_get_free_pages(0); if (p) print("%x, %x\n", p, p->address); else print("Error: failed to allocate memory for p\n"); } int main(void) { char *lower, *upper; struct atag *atags; //setup MMU mmu_reinit(); print_init(&pl011_putc); //initialize the serial console //setup memory mm_init(); if (atags_first_mem_region(&atags)) { print("Error: atags must contain at least one memory region\n"); return -1; } do { lower = (char *)atags->data.mem.start; upper = lower + atags->data.mem.size - 1; declare_memory_region(lower, upper); } while (!atags_next_mem_region(&atags)); test_memory(); video(); return 0; }