1
0
mirror of git://projects.qi-hardware.com/iris.git synced 2024-07-01 00:44:31 +03:00

fix invoke; working good keyboard

This commit is contained in:
Bas Wijnen 2009-06-13 23:15:37 +02:00
parent 42f0f365b3
commit ef229121ed
3 changed files with 19 additions and 11 deletions

View File

@ -58,6 +58,7 @@ int main ():
keys[i] = 0xff
// Pin numbers for the cols, relative to the start of the port (so minus 0x60).
event (false, 0, 0)
int const cols[NUM_COLS] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 29 }
while true:
// read keyboard

View File

@ -24,7 +24,7 @@ Capability *Memory::find_capability (unsigned code, bool *copy):
*copy = code & 2 ? true : false
if code & 1:
// Cappage capability
unsigned num = (code & ~PAGE_MASK) >> 1
unsigned num = (code & ~PAGE_MASK) >> 2
if num >= CAPPAGE_SIZE:
return NULL
Capability *page = (Capability *)(code & PAGE_MASK)
@ -33,6 +33,7 @@ Capability *Memory::find_capability (unsigned code, bool *copy):
return &page[num]
else:
// Normal capability
code &= ~3
for Capability *c = capabilities; c; c = c->next:
if c == (Capability *)code:
return c
@ -221,6 +222,7 @@ static void memory_invoke (unsigned target, unsigned protected_data, Capability:
reply_num (0)
break
case CAPTYPE_PAGE:
dbg_send (1, 3)
Page *ret = mem->alloc_page ()
if ret:
reply_cap (CAPTYPE_PAGE | (rights & CAP_PAGE_ALL_RIGHTS), (unsigned)ret)
@ -266,6 +268,7 @@ static void memory_invoke (unsigned target, unsigned protected_data, Capability:
// TODO
break
case CAP_MEMORY_MAP:
dbg_send (3, 3)
// FIXME: this should work for fake pages as well.
if !c->cap[0] || (unsigned)c->cap[0]->target & ~KERNEL_MASK || ((unsigned)c->cap[0]->target & CAPTYPE_MASK) != CAPTYPE_PAGE:
break
@ -340,11 +343,10 @@ static void thread_invoke (unsigned target, unsigned protected_data, Capability:
schedule ()
break
case CAP_THREAD_DEBUG:
for unsigned i = 0; i < 2; ++i:
dbg_led (true, true, true)
dbg_sleep (100)
dbg_led (false, false, false)
dbg_sleep (100)
dbg_led (true, true, true)
dbg_sleep (100)
dbg_led (false, false, false)
dbg_sleep (100)
//dbg_send (c->data[1], 5)
break
case CAP_THREAD_REGISTER_INTERRUPT:
@ -362,6 +364,7 @@ static void thread_invoke (unsigned target, unsigned protected_data, Capability:
reply_cap (CAPTYPE_THREAD | (c->data[1] & CAP_THREAD_ALL_PRIV_RIGHTS), c->cap[0]->protected_data)
break
case CAP_THREAD_ALLOC_PHYSICAL:
dbg_send (2, 3)
// Threads with access to this call are trusted, so no sanity checking is done.
Page *page = (Page *)c->cap[0]->protected_data
page->forget ()
@ -648,7 +651,7 @@ static bool kernel_invoke (unsigned target, unsigned protected_data, Capability:
// cap[0] is the reply capability
// other parameters' meanings depend on the operation.
if (target & (CAPTYPE_MASK | (1 << CAP_RECEIVER_CALL))) == (CAPTYPE_RECEIVER | (1 << CAP_RECEIVER_CALL)):
// This is a call capability.
// This is a call capability. cap[0] is the capability to call.
reply_receiver = (Receiver *)protected_data
reply_receiver->protected_only = !(target & (1 << CAP_RECEIVER_CALL_ASYNC))
Capability *c0 = c->cap[0]
@ -662,8 +665,9 @@ static bool kernel_invoke (unsigned target, unsigned protected_data, Capability:
return true
else:
// Kernel call: don't create actual capablities.
reply = NULL
return kernel_invoke ((unsigned)c0->target, c0->protected_data, c, c0)
c->cap[0] = NULL
kernel_invoke ((unsigned)c0->target, c0->protected_data, c, c0)
return true
if (target & (CAPTYPE_MASK | (1 << CAP_RECEIVER_REPLY))) == (CAPTYPE_RECEIVER | (1 << CAP_RECEIVER_REPLY)):
// This is a reply capability.
Receiver *r = (Receiver *)protected_data
@ -676,8 +680,10 @@ static bool kernel_invoke (unsigned target, unsigned protected_data, Capability:
self->sibling_next->invalidate ()
self->invalidate ()
return true
if !((1 << c->data[0]) & target & ~REQUEST_MASK):
if !((1 << c->data[0]) & target & REQUEST_MASK):
// You are not allowed to perform this operation.
dbg_send (1, 2)
dbg_send (c->data[0])
return true
reply = c->cap[0]
if c->data[0] == CAP_DEGRADE:

View File

@ -326,10 +326,11 @@ void arch_invoke ():
Capability *target
bool wait
Thread *caller = current
target = caller->address_space->find_capability (current->arch.v0, &wait)
target = caller->address_space->find_capability (caller->arch.v0, &wait)
if !target:
// TODO: there must be no action here. This is just because the rest doesn't work yet.
dbg_send (3, 2)
//dbg_send (caller->arch.v0)
schedule ()
// Calling an invalid capability always fails.
caller->arch.v0 = 0