2012-09-17 23:33:50 -04:00
|
|
|
#include <mm.h>
|
2012-09-07 23:56:32 -04:00
|
|
|
#include <print.h>
|
|
|
|
#include <devices/pl011.h>
|
|
|
|
|
2012-09-10 22:44:54 -04:00
|
|
|
#include <devices/pl111.h>
|
2012-09-07 23:56:32 -04:00
|
|
|
#include <framebuffer.h>
|
2012-09-09 01:58:38 -04:00
|
|
|
#include <console.h>
|
2012-09-07 23:56:32 -04:00
|
|
|
|
2012-09-17 23:33:50 -04:00
|
|
|
extern const unsigned int kernel_end;
|
|
|
|
|
2012-09-07 23:56:32 -04:00
|
|
|
struct fb myfb;
|
|
|
|
|
2012-09-09 01:58:38 -04:00
|
|
|
void video(void) {
|
2012-09-17 23:33:50 -04:00
|
|
|
unsigned int x, y;
|
2012-09-10 22:44:54 -04:00
|
|
|
pl111_init(&myfb, 24);
|
2012-09-17 23:33:50 -04:00
|
|
|
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);
|
|
|
|
|
2012-09-09 01:58:38 -04:00
|
|
|
console_init(&myfb);
|
2012-09-07 23:56:32 -04:00
|
|
|
}
|
2012-09-17 23:33:50 -04:00
|
|
|
|
|
|
|
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");
|
|
|
|
|
|
|
|
}
|
2012-09-07 23:56:32 -04:00
|
|
|
|
2012-09-09 01:58:38 -04:00
|
|
|
int main(void) {
|
2012-09-17 23:33:50 -04:00
|
|
|
char *lower;
|
2012-09-07 23:56:32 -04:00
|
|
|
print_init(&pl011_putc); //initialize the serial console
|
|
|
|
|
2012-09-17 23:33:50 -04:00
|
|
|
//setup memory
|
|
|
|
mm_init();
|
|
|
|
mm_add_free_region((void*)0x60000000, (void*)0x7FFFFFFF);
|
|
|
|
lower = (char*) &kernel_end;
|
|
|
|
if ((unsigned int)lower % MM_PAGE_SIZE != 0)
|
|
|
|
lower += (MM_PAGE_SIZE - ((unsigned int)lower % MM_PAGE_SIZE));
|
|
|
|
mm_add_free_region((void*)lower, (void*)0x9FFFFFFF); //subtract the memory used by the kernel
|
|
|
|
|
|
|
|
test_memory();
|
|
|
|
|
2012-09-07 23:56:32 -04:00
|
|
|
video();
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|