Exemplo n.º 1
0
static void
pager (void)
{
    L4_ThreadId_t tid;
    L4_MsgTag_t tag;
    L4_Msg_t msg;

    L4_Send(master_tid);
    for (;;) {
        tag = L4_Wait(&tid);

        for (;;) {
            L4_Word_t faddr, fip;
            L4_MsgStore(tag, &msg);

            if (L4_UntypedWords (tag) != 2 ||
                !L4_IpcSucceeded (tag)) {
                printf ("Malformed pagefault IPC from %p (tag=%p)\n",
                        (void *) tid.raw, (void *) tag.raw);
                L4_KDB_Enter ("malformed pf");
                break;
            }

            faddr = L4_MsgWord(&msg, 0);
            fip   = L4_MsgWord (&msg, 1);
            L4_MsgClear(&msg);
            {
                L4_MapItem_t map;
                L4_SpaceId_t space;
                L4_Word_t seg, offset, cache, rwx, size;
                int r;

                seg = get_seg(KBENCH_SPACE, faddr, &offset, &cache, &rwx);
                assert(seg != ~0UL);

                size = L4_GetMinPageBits();
                faddr &= ~((1ul << size)-1);
                offset &= ~((1ul << size)-1);

                space.raw = __L4_TCR_SenderSpace();

                L4_MapItem_Map(&map, seg, offset, faddr, size,
                               cache, rwx);
                r = L4_ProcessMapItem(space, map);
                assert(r == 1);
            }
            L4_MsgLoad(&msg);
//            tag = L4_ReplyWait (tid, &tid);
            tag = L4_MsgTag();
            L4_Set_SendBlock(&tag);
            L4_Set_ReceiveBlock(&tag);
            tag = L4_Ipc(tid, L4_anythread, tag, &tid);
        }
    }
}
Exemplo n.º 2
0
static void
utimer(void)
{
	L4_KDB_SetThreadName(sos_my_tid(), "utimer");
	L4_Accept(L4_UntypedWordsAcceptor);

	List *entryq;
	entryq = list_empty();

	for (;;) {
		L4_Yield();

		// Walk the timer list
		L4_Word_t now = L4_KDB_GetTick();
		list_delete(entryq, processExpired, &now);

		// Wait for a new packet either blocking or non-blocking
		L4_MsgTag_t tag = L4_Niltag;
		if (list_null(entryq))
			L4_Set_ReceiveBlock(&tag);
		else
			L4_Clear_ReceiveBlock(&tag);

		L4_ThreadId_t wait_tid = L4_nilthread;
		tag = L4_Ipc(L4_nilthread, L4_anythread, tag, &wait_tid);

		if (!L4_IpcFailed(tag)) {
			// Received a time out request queue it
			L4_Msg_t msg; L4_MsgStore(tag, &msg);	// Get the message
			utimer_entry_t *entry = (utimer_entry_t *) L4_MsgWord(&msg, 0);
			entry->fTid  = wait_tid;
			list_shift(entryq, entry);
		}
		else if (3 == L4_ErrorCode()) // Receive error # 1
			continue;	// no-partner - non-blocking
		else
			assert(!"Unhandled IPC error");
	}
}