summaryrefslogtreecommitdiffstats
path: root/src/sys/init/init_main.C
blob: 4be986ba77e10f78dacf3b6cfe530e92746c810f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
#include <kernel/console.H>  // TODO : Remove this.

#include <sys/task.h>
#include <sys/mutex.h>
#include <sys/msg.h>
#include <sys/mmio.h>

mutex_t global_mutex;

void init_child(void* unused)
{
    mutex_lock(global_mutex);
    printk("Crun: %d on %d\n", task_gettid(), task_getcpuid());
    mutex_unlock(global_mutex);
    for (volatile int i = 0 ; i < 100000; i++);
    task_end();
}

void vfs_main(void*);

void init_main(void* unused)
{
    printk("Starting init!\n");
    
    printk("Bringing up VFS..."); 
    task_create(&vfs_main, NULL);
    task_yield(); // TODO... add a barrier to ensure VFS is fully up.
   
    uint64_t* mmio_addr = (uint64_t*) mmio_map((void*)0x800000000, 1);
    printk("MMIO Access %llx\n", *mmio_addr);

    global_mutex = mutex_create();

    msg_q_t msgq = msg_q_create();
    msg_q_register(msgq, "/msg/init");

    msg_t* msg = msg_allocate();
    msg->type = 1; msg->data[0] = 0xDEADBEEF12345678;
    msg_send(msgq, msg);
    msg = msg_wait(msgq);

    printk("Got Message: %llx\n", msg->data[0]);

    while(1)
    {
	mutex_lock(global_mutex);
	int t = task_create(&init_child, NULL);
	printk("Create child %d\n", t);
	for (volatile int i = 0 ; i < 1000000; i++);
	mutex_unlock(global_mutex);
    }
}
OpenPOWER on IntegriCloud