Example #1
0
int memory_get_total() {
	return memory_get_used() + memory_get_free();
}
Example #2
0
int main (void)
{
    L4_Word_t total;

    printf("\n\nHasenpfeffer operating system\n");
    printf("Copyright (C) 2005,2006. Senko Rasic <*****@*****.**>\n\n");


    printf("Initializing root task...\n");
    L4_KernelInterfacePage_t *kip = (L4_KernelInterfacePage_t *) L4_GetKernelInterface();
    void *bi = (void *) L4_BootInfo(kip);
    
    // we need to preload these I/O pages
    // ATA
    L4_Sigma0_GetPage(L4_nilthread, L4_Fpage(0x0000, 4096));

    // KIP
    L4_Sigma0_GetPage(L4_nilthread, L4_Fpage(L4_BootInfo(kip), 4096));
    L4_BootRec_t *br = NULL;

    if (L4_BootInfo_Valid((void *) bi)) {
        int n = L4_BootInfo_Entries(bi);
        br = L4_BootInfo_FirstEntry(bi);
        while (--n) {
            /* touch roottask data from here, because sigma0 only gives pages to initial *thread* */
            if (L4_BootRec_Type(br) == L4_BootInfo_SimpleExec) {
                L4_Word_t mi;
                for (mi = 0; mi < L4_Module_Size(br); mi += 4096) {
                    L4_Sigma0_GetPage(L4_nilthread, L4_Fpage(L4_Module_Start(br) + mi, 4096));
                }
            }
            br = L4_BootRec_Next(br);
        }
    } else {
        printf("panic: invalid bootinfo data\n");
        return 0;
    }

    memory_init();
    total = memory_get_free();

    printf("Creating root memory manager...\n");
    mman_tid = create_local_thread("root memory manager", kip, 1, memman, 4096);
    thread_init(mman_tid);

    printf("Initializing root task manager...\n");
    HpfCapability full, newthread, newtask;
    task_manager_init(&full, &newtask, &newthread);

    dir_paths[0] = "/process/TaskManager";
    dir_caps[0] = full;
    n_paths = 1;

    printf("Loading initial programs...\n");
    int n = L4_BootInfo_Entries(bi);
    br = L4_BootInfo_FirstEntry(bi);
    int first_program = 1;
    while (--n) {
        if (L4_BootRec_Type(br) == L4_BootInfo_Module) {
            L4_ThreadId_t tid = launch(br);
            if (first_program) {
                first_program = 0;

                // this is the root directory server
                if (hermes_capability(tid, &(dir_caps[1]))) {
                    // dir_paths[1] = "/process/DirectoryService";
                    dir_paths[1] = ""; // <- catch-all
                    n_paths = 2;
                }
            }
        }
        br = L4_BootRec_Next(br);
    }

    printf("Init done, running...\n\n");
    task_manager_main();

    return 0;
}