mirror of
git://projects.qi-hardware.com/iris.git
synced 2025-01-30 21:11:06 +02:00
better interfaces
This commit is contained in:
parent
a838dd63c6
commit
a2e13cbcda
@ -21,12 +21,6 @@
|
|||||||
|
|
||||||
#include "iris.hh"
|
#include "iris.hh"
|
||||||
|
|
||||||
// This shouldn't really be here. But where should it be?
|
|
||||||
// Requests made by initial threads to tell init about themselves.
|
|
||||||
enum init_requests:
|
|
||||||
INIT_SET_GPIO = 1
|
|
||||||
INIT_SET_LCD
|
|
||||||
|
|
||||||
// List interface.
|
// List interface.
|
||||||
template <typename _T> //
|
template <typename _T> //
|
||||||
struct List : public Kernel::Cap:
|
struct List : public Kernel::Cap:
|
||||||
|
@ -17,6 +17,7 @@
|
|||||||
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
#include "devices.hh"
|
#include "devices.hh"
|
||||||
|
#include "init.hh"
|
||||||
#define ARCH
|
#define ARCH
|
||||||
#include "arch.hh"
|
#include "arch.hh"
|
||||||
|
|
||||||
@ -53,12 +54,6 @@ enum event_type:
|
|||||||
TOUCHPAD_EVENT
|
TOUCHPAD_EVENT
|
||||||
NUM_EVENTS
|
NUM_EVENTS
|
||||||
|
|
||||||
enum cap_type:
|
|
||||||
CAP_KEYBOARD = 32
|
|
||||||
CAP_TOUCHPAD
|
|
||||||
CAP_LOCKLEDS
|
|
||||||
CAP_PWM
|
|
||||||
|
|
||||||
static Kernel::Cap events[NUM_EVENTS]
|
static Kernel::Cap events[NUM_EVENTS]
|
||||||
|
|
||||||
static void event (event_type type, unsigned data):
|
static void event (event_type type, unsigned data):
|
||||||
@ -265,20 +260,7 @@ Kernel::Num start ():
|
|||||||
Lockleds leds
|
Lockleds leds
|
||||||
Pwm pwm
|
Pwm pwm
|
||||||
|
|
||||||
Kernel::Caps c = Kernel::my_memory.create_caps (4)
|
((Init)Kernel::my_parent).register_gpio ()
|
||||||
unsigned init_slot = c.use ()
|
|
||||||
Kernel::set_recv_arg (Kernel::Cap (init_slot, 0))
|
|
||||||
Kernel::my_receiver.create_capability (CAP_KEYBOARD)
|
|
||||||
Kernel::set_recv_arg (Kernel::Cap (init_slot, 1))
|
|
||||||
Kernel::my_receiver.create_capability (CAP_TOUCHPAD)
|
|
||||||
Kernel::set_recv_arg (Kernel::Cap (init_slot, 2))
|
|
||||||
Kernel::my_receiver.create_capability (CAP_LOCKLEDS)
|
|
||||||
Kernel::set_recv_arg (Kernel::Cap (init_slot, 3))
|
|
||||||
Kernel::my_receiver.create_capability (CAP_PWM)
|
|
||||||
|
|
||||||
Kernel::my_parent.ocall (c, INIT_SET_GPIO)
|
|
||||||
free_cap (c)
|
|
||||||
Kernel::free_slot (init_slot)
|
|
||||||
|
|
||||||
if kbd.is_scanning ():
|
if kbd.is_scanning ():
|
||||||
Kernel::my_receiver.set_alarm (ALARM_INTERVAL)
|
Kernel::my_receiver.set_alarm (ALARM_INTERVAL)
|
||||||
@ -304,25 +286,23 @@ Kernel::Num start ():
|
|||||||
// Reregister the interrupt.
|
// Reregister the interrupt.
|
||||||
Kernel::register_interrupt (IRQ_GPIO0)
|
Kernel::register_interrupt (IRQ_GPIO0)
|
||||||
break
|
break
|
||||||
case CAP_KEYBOARD:
|
case Init::GPIO_KEYBOARD:
|
||||||
kdebug ("gpio: keyboard callback registered.\n")
|
|
||||||
set_cb (KEYBOARD_EVENT)
|
set_cb (KEYBOARD_EVENT)
|
||||||
Kernel::recv.reply.invoke ()
|
Kernel::recv.reply.invoke ()
|
||||||
kbd.send_initial ()
|
kbd.send_initial ()
|
||||||
event (KEYBOARD_EVENT, ~0)
|
event (KEYBOARD_EVENT, ~0)
|
||||||
break
|
break
|
||||||
case CAP_TOUCHPAD:
|
case Init::GPIO_TOUCHPAD:
|
||||||
kdebug ("gpio: touchpad callback registered.\n")
|
|
||||||
set_cb (TOUCHPAD_EVENT)
|
set_cb (TOUCHPAD_EVENT)
|
||||||
Kernel::recv.reply.invoke ()
|
Kernel::recv.reply.invoke ()
|
||||||
tp.send_initial ()
|
tp.send_initial ()
|
||||||
event (TOUCHPAD_EVENT, ~0)
|
event (TOUCHPAD_EVENT, ~0)
|
||||||
break
|
break
|
||||||
case CAP_LOCKLEDS:
|
case Init::GPIO_LOCKLEDS:
|
||||||
leds.set (Kernel::recv.data[0].l)
|
leds.set (Kernel::recv.data[0].l)
|
||||||
Kernel::recv.reply.invoke ()
|
Kernel::recv.reply.invoke ()
|
||||||
break
|
break
|
||||||
case CAP_PWM:
|
case Init::GPIO_PWM:
|
||||||
pwm.set_backlight (Kernel::recv.data[0].l)
|
pwm.set_backlight (Kernel::recv.data[0].l)
|
||||||
Kernel::recv.reply.invoke ()
|
Kernel::recv.reply.invoke ()
|
||||||
break
|
break
|
||||||
|
@ -18,6 +18,7 @@
|
|||||||
|
|
||||||
#include "devices.hh"
|
#include "devices.hh"
|
||||||
#include "iris.hh"
|
#include "iris.hh"
|
||||||
|
#include "init.hh"
|
||||||
|
|
||||||
static Keyboard kbd, tp
|
static Keyboard kbd, tp
|
||||||
static Display lcd
|
static Display lcd
|
||||||
@ -30,33 +31,39 @@ enum type:
|
|||||||
|
|
||||||
static void setup ():
|
static void setup ():
|
||||||
unsigned state = 0
|
unsigned state = 0
|
||||||
Kernel::recv.arg = Kernel::alloc_cap ()
|
Kernel::Caps my_caps = Kernel::my_memory.create_caps (4 + 1)
|
||||||
|
unsigned my_slot = my_caps.use ()
|
||||||
|
unsigned slot = Kernel::alloc_slot ()
|
||||||
while true:
|
while true:
|
||||||
Kernel::wait ()
|
Kernel::wait ()
|
||||||
|
Kernel::Cap reply = Kernel::get_reply ()
|
||||||
|
Kernel::Caps caps = Kernel::get_arg ()
|
||||||
switch Kernel::recv.data[0].value ():
|
switch Kernel::recv.data[0].value ():
|
||||||
case INIT_SET_GPIO:
|
case Init::REGISTER_GPIO:
|
||||||
kdebug ("gpio\n")
|
caps.use (slot)
|
||||||
Kernel::Caps caps = Kernel::get_arg ()
|
for unsigned i = 0; i < 4; ++i:
|
||||||
Kernel::Cap reply = Kernel::get_reply ()
|
my_caps.set (i, Kernel::Cap (slot, i).copy ())
|
||||||
unsigned gpio_slot = caps.use ()
|
kbd = Kernel::Cap (my_slot, 0)
|
||||||
kbd = Kernel::Cap (gpio_slot, 0)
|
tp = Kernel::Cap (my_slot, 1)
|
||||||
tp = Kernel::Cap (gpio_slot, 1)
|
lockleds = Kernel::Cap (my_slot, 2)
|
||||||
lockleds = Kernel::Cap (gpio_slot, 2)
|
pwm = Kernel::Cap (my_slot, 3)
|
||||||
pwm = Kernel::Cap (gpio_slot, 3)
|
|
||||||
reply.invoke ()
|
|
||||||
Kernel::free_cap (reply)
|
|
||||||
++state
|
|
||||||
break
|
break
|
||||||
case INIT_SET_LCD:
|
case Init::REGISTER_LCD:
|
||||||
kdebug ("lcd\n")
|
caps.use (slot)
|
||||||
lcd = Kernel::get_arg ()
|
my_caps.set (4, Kernel::Cap (slot, 0).copy ())
|
||||||
Kernel::recv.reply.invoke ()
|
lcd = Kernel::Cap (my_slot, 4)
|
||||||
++state
|
|
||||||
break
|
break
|
||||||
if state == 2:
|
default:
|
||||||
|
kdebug ("unknown setup request for init\n")
|
||||||
|
continue
|
||||||
|
reply.invoke ()
|
||||||
|
Kernel::free_cap (caps)
|
||||||
|
Kernel::free_cap (reply)
|
||||||
|
if ++state == 2:
|
||||||
break
|
break
|
||||||
|
Kernel::free_cap (my_caps)
|
||||||
|
Kernel::free_slot (slot)
|
||||||
Kernel::schedule ()
|
Kernel::schedule ()
|
||||||
kdebug ("init registering keyboard\n")
|
|
||||||
Kernel::Cap kc = Kernel::my_receiver.create_capability (KBD)
|
Kernel::Cap kc = Kernel::my_receiver.create_capability (KBD)
|
||||||
kbd.set_cb (kc)
|
kbd.set_cb (kc)
|
||||||
Kernel::Cap tc = Kernel::my_receiver.create_capability (TP)
|
Kernel::Cap tc = Kernel::my_receiver.create_capability (TP)
|
||||||
@ -68,9 +75,7 @@ char const *decode_kbd = "0123456789abcdefghijklmnopqrstuvwxyz!@#$%^&*() T\n[],.
|
|||||||
Kernel::Num start ():
|
Kernel::Num start ():
|
||||||
// Set up lcd first
|
// Set up lcd first
|
||||||
Kernel::schedule ()
|
Kernel::schedule ()
|
||||||
kdebug ("start init\n")
|
|
||||||
setup ()
|
setup ()
|
||||||
kdebug ("run init\n")
|
|
||||||
while true:
|
while true:
|
||||||
Kernel::wait ()
|
Kernel::wait ()
|
||||||
switch Kernel::recv.protected_data.value ():
|
switch Kernel::recv.protected_data.value ():
|
||||||
|
@ -17,6 +17,7 @@
|
|||||||
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
#include "devices.hh"
|
#include "devices.hh"
|
||||||
|
#include "init.hh"
|
||||||
#define ARCH
|
#define ARCH
|
||||||
#include "arch.hh"
|
#include "arch.hh"
|
||||||
|
|
||||||
@ -26,10 +27,6 @@ extern unsigned char const charset[127-32][6]
|
|||||||
|
|
||||||
#define assert(x) do { while (!(x)) kdebug ("assertion failed " #x); } while (0)
|
#define assert(x) do { while (!(x)) kdebug ("assertion failed " #x); } while (0)
|
||||||
|
|
||||||
enum types:
|
|
||||||
LCD_EOF_CB = 32
|
|
||||||
LCD_LOG
|
|
||||||
|
|
||||||
// For now, support only 16 bpp.
|
// For now, support only 16 bpp.
|
||||||
// Screen is 800x480 tft.
|
// Screen is 800x480 tft.
|
||||||
static unsigned h = 800, v = 480, hs = 80, vs = 20, fps = 60, Bpp = 2
|
static unsigned h = 800, v = 480, hs = 80, vs = 20, fps = 60, Bpp = 2
|
||||||
@ -161,11 +158,10 @@ Kernel::Num start ():
|
|||||||
__asm__ volatile ("lw $a0, %0\ncache 0x15, 0($a0)" :: "m"(dptr) : "memory", "a0")
|
__asm__ volatile ("lw $a0, %0\ncache 0x15, 0($a0)" :: "m"(dptr) : "memory", "a0")
|
||||||
reset ()
|
reset ()
|
||||||
|
|
||||||
Kernel::Cap logcap = Kernel::my_receiver.create_capability (LCD_LOG)
|
Kernel::Cap logcap = Kernel::my_receiver.create_capability (Init::LCD_LOG)
|
||||||
__asm__ volatile ("li $a0, 1\nlw $a1, %0\nbreak" :: "m"(logcap.code): "a0", "a1", "memory")
|
__asm__ volatile ("li $a0, 1\nlw $a1, %0\nbreak" :: "m"(logcap.code): "a0", "a1", "memory")
|
||||||
|
|
||||||
Kernel::Cap set_eof_cb = Kernel::my_receiver.create_capability (LCD_EOF_CB)
|
((Init)Kernel::my_parent).register_lcd ()
|
||||||
Kernel::my_parent.ocall (set_eof_cb, INIT_SET_LCD)
|
|
||||||
|
|
||||||
unsigned slot = Kernel::alloc_slot ()
|
unsigned slot = Kernel::alloc_slot ()
|
||||||
Kernel::Cap eof_cb = Kernel::alloc_cap ()
|
Kernel::Cap eof_cb = Kernel::alloc_cap ()
|
||||||
@ -177,14 +173,14 @@ Kernel::Num start ():
|
|||||||
lcd_clr_eof ()
|
lcd_clr_eof ()
|
||||||
eof_cb.invoke ()
|
eof_cb.invoke ()
|
||||||
break
|
break
|
||||||
case LCD_EOF_CB:
|
case Init::LCD_SET_EOF_CB:
|
||||||
Kernel::free_cap (eof_cb)
|
Kernel::free_cap (eof_cb)
|
||||||
eof_cb = Kernel::recv.arg
|
eof_cb = Kernel::recv.arg
|
||||||
Kernel::recv.arg = Kernel::alloc_cap ()
|
Kernel::recv.arg = Kernel::alloc_cap ()
|
||||||
Kernel::recv.reply.invoke ()
|
Kernel::recv.reply.invoke ()
|
||||||
Kernel::register_interrupt (IRQ_LCD)
|
Kernel::register_interrupt (IRQ_LCD)
|
||||||
break
|
break
|
||||||
case LCD_LOG:
|
case Init::LCD_LOG:
|
||||||
log_char (Kernel::recv.data[0].l)
|
log_char (Kernel::recv.data[0].l)
|
||||||
break
|
break
|
||||||
default:
|
default:
|
||||||
|
77
invoke.ccp
77
invoke.ccp
@ -179,11 +179,12 @@ static void reply_num (unsigned num1, unsigned num2 = 0, unsigned num3 = 0):
|
|||||||
else:
|
else:
|
||||||
dpanic (0, "nothing to reply to")
|
dpanic (0, "nothing to reply to")
|
||||||
|
|
||||||
static void reply_cap (unsigned target, Kernel::Num protected_data, kCapRef *ref):
|
static void reply_cap (unsigned target, Kernel::Num protected_data, kCapRef *ref, unsigned num = 0):
|
||||||
replied_caps.set (0, (kReceiver *)target, protected_data, kCapRef (), ref)
|
replied_caps.set (0, (kReceiver *)target, protected_data, kCapRef (), ref)
|
||||||
kCapability::Context c
|
kCapability::Context c
|
||||||
c.arg = kCapRef (&replied_caps, 0)
|
c.arg = kCapRef (&replied_caps, 0)
|
||||||
c.copy[1] = true
|
c.copy[1] = true
|
||||||
|
c.data[0] = Kernel::Num (num, 0)
|
||||||
if reply_target:
|
if reply_target:
|
||||||
reply_target->send_message (reply_protected, &c)
|
reply_target->send_message (reply_protected, &c)
|
||||||
else:
|
else:
|
||||||
@ -193,7 +194,7 @@ static void reply_cap (unsigned target, Kernel::Num protected_data, kCapRef *ref
|
|||||||
static void receiver_invoke (unsigned cmd, unsigned target, Kernel::Num protected_data, kCapability::Context *c):
|
static void receiver_invoke (unsigned cmd, unsigned target, Kernel::Num protected_data, kCapability::Context *c):
|
||||||
kReceiver *receiver = (kReceiver *)protected_data.l
|
kReceiver *receiver = (kReceiver *)protected_data.l
|
||||||
switch cmd:
|
switch cmd:
|
||||||
case Kernel::Receiver::SET_OWNER:
|
case Kernel::Receiver::SET_OWNER & REQUEST_MASK:
|
||||||
if !c->arg.valid ():
|
if !c->arg.valid ():
|
||||||
reply_num (~0)
|
reply_num (~0)
|
||||||
return
|
return
|
||||||
@ -203,25 +204,25 @@ static void receiver_invoke (unsigned cmd, unsigned target, Kernel::Num protecte
|
|||||||
return
|
return
|
||||||
receiver->own ((kThread *)c->arg->protected_data.l)
|
receiver->own ((kThread *)c->arg->protected_data.l)
|
||||||
break
|
break
|
||||||
case Kernel::Receiver::CREATE_CAPABILITY:
|
case Kernel::Receiver::CREATE_CAPABILITY & REQUEST_MASK:
|
||||||
reply_cap ((unsigned)receiver, c->data[1], &receiver->capabilities)
|
reply_cap ((unsigned)receiver, c->data[1], &receiver->capabilities)
|
||||||
return
|
return
|
||||||
case Kernel::Receiver::CREATE_CALL_CAPABILITY:
|
case Kernel::Receiver::CREATE_CALL_CAPABILITY & REQUEST_MASK:
|
||||||
reply_cap (CAPTYPE_RECEIVER | (c->data[0].h ? Kernel::Receiver::CALL_ASYNC : Kernel::Receiver::CALL), protected_data, &((kObject *)protected_data.l)->refs)
|
reply_cap (CAPTYPE_RECEIVER | (c->data[0].h ? Kernel::Receiver::CALL_ASYNC : Kernel::Receiver::CALL), protected_data, &((kObject *)protected_data.l)->refs)
|
||||||
return
|
return
|
||||||
case Kernel::Receiver::GET_REPLY_PROTECTED_DATA:
|
case Kernel::Receiver::GET_REPLY_PROTECTED_DATA & REQUEST_MASK:
|
||||||
reply_num (receiver->reply_protected_data.l, receiver->reply_protected_data.h, receiver->protected_only ? 1 : 0)
|
reply_num (receiver->reply_protected_data.l, receiver->reply_protected_data.h, receiver->protected_only ? 1 : 0)
|
||||||
return
|
return
|
||||||
case Kernel::Receiver::SET_REPLY_PROTECTED_DATA:
|
case Kernel::Receiver::SET_REPLY_PROTECTED_DATA & REQUEST_MASK:
|
||||||
receiver->reply_protected_data = c->data[1]
|
receiver->reply_protected_data = c->data[1]
|
||||||
break
|
break
|
||||||
case Kernel::Receiver::GET_ALARM:
|
case Kernel::Receiver::GET_ALARM & REQUEST_MASK:
|
||||||
reply_num (receiver->alarm_count)
|
reply_num (receiver->alarm_count)
|
||||||
return
|
return
|
||||||
case Kernel::Receiver::SET_ALARM:
|
case Kernel::Receiver::SET_ALARM & REQUEST_MASK:
|
||||||
case Kernel::Receiver::ADD_ALARM:
|
case Kernel::Receiver::ADD_ALARM & REQUEST_MASK:
|
||||||
unsigned old = receiver->alarm_count
|
unsigned old = receiver->alarm_count
|
||||||
if cmd == Kernel::Receiver::SET_ALARM:
|
if cmd == Kernel::Receiver::SET_ALARM & REQUEST_MASK:
|
||||||
receiver->alarm_count = c->data[1].l
|
receiver->alarm_count = c->data[1].l
|
||||||
else:
|
else:
|
||||||
receiver->alarm_count += c->data[1].l
|
receiver->alarm_count += c->data[1].l
|
||||||
@ -253,7 +254,7 @@ static void receiver_invoke (unsigned cmd, unsigned target, Kernel::Num protecte
|
|||||||
static void memory_invoke (unsigned cmd, unsigned target, Kernel::Num protected_data, kCapability::Context *c):
|
static void memory_invoke (unsigned cmd, unsigned target, Kernel::Num protected_data, kCapability::Context *c):
|
||||||
kMemory *mem = (kMemory *)protected_data.l
|
kMemory *mem = (kMemory *)protected_data.l
|
||||||
switch cmd:
|
switch cmd:
|
||||||
case Kernel::Memory::CREATE:
|
case Kernel::Memory::CREATE & REQUEST_MASK:
|
||||||
switch c->data[0].h:
|
switch c->data[0].h:
|
||||||
case CAPTYPE_RECEIVER:
|
case CAPTYPE_RECEIVER:
|
||||||
kReceiver *ret = mem->alloc_receiver ()
|
kReceiver *ret = mem->alloc_receiver ()
|
||||||
@ -300,7 +301,7 @@ static void memory_invoke (unsigned cmd, unsigned target, Kernel::Num protected_
|
|||||||
reply_num (~0)
|
reply_num (~0)
|
||||||
return
|
return
|
||||||
break
|
break
|
||||||
case Kernel::Memory::DESTROY:
|
case Kernel::Memory::DESTROY & REQUEST_MASK:
|
||||||
if !c->arg.valid () || (unsigned)c->arg->target & ~KERNEL_MASK || !c->arg->target || ((kObject *)c->arg->protected_data.l)->address_space != mem:
|
if !c->arg.valid () || (unsigned)c->arg->target & ~KERNEL_MASK || !c->arg->target || ((kObject *)c->arg->protected_data.l)->address_space != mem:
|
||||||
reply_num (~0)
|
reply_num (~0)
|
||||||
return
|
return
|
||||||
@ -324,10 +325,10 @@ static void memory_invoke (unsigned cmd, unsigned target, Kernel::Num protected_
|
|||||||
panic (0x55228930, "invalid case")
|
panic (0x55228930, "invalid case")
|
||||||
return
|
return
|
||||||
break
|
break
|
||||||
case Kernel::Memory::LIST:
|
case Kernel::Memory::LIST & REQUEST_MASK:
|
||||||
// TODO
|
// TODO
|
||||||
break
|
break
|
||||||
case Kernel::Memory::MAP:
|
case Kernel::Memory::MAP & REQUEST_MASK:
|
||||||
// FIXME: this should work for fake pages as well.
|
// FIXME: this should work for fake pages as well.
|
||||||
if !c->arg.valid () || (unsigned)c->arg->target & ~KERNEL_MASK || ((unsigned)c->arg->target & CAPTYPE_MASK) != CAPTYPE_PAGE:
|
if !c->arg.valid () || (unsigned)c->arg->target & ~KERNEL_MASK || ((unsigned)c->arg->target & CAPTYPE_MASK) != CAPTYPE_PAGE:
|
||||||
dpanic (0x22993341, "Trying to map non-page")
|
dpanic (0x22993341, "Trying to map non-page")
|
||||||
@ -341,7 +342,7 @@ static void memory_invoke (unsigned cmd, unsigned target, Kernel::Num protected_
|
|||||||
bool readonly = c->data[1].l & (unsigned)c->arg->target & Kernel::Page::READONLY
|
bool readonly = c->data[1].l & (unsigned)c->arg->target & Kernel::Page::READONLY
|
||||||
mem->map (page, c->data[1].l & PAGE_MASK, readonly)
|
mem->map (page, c->data[1].l & PAGE_MASK, readonly)
|
||||||
break
|
break
|
||||||
case Kernel::Memory::MAPPING:
|
case Kernel::Memory::MAPPING & REQUEST_MASK:
|
||||||
bool readonly
|
bool readonly
|
||||||
kPage *page = mem->get_mapping (c->data[1].l, &readonly)
|
kPage *page = mem->get_mapping (c->data[1].l, &readonly)
|
||||||
unsigned t = CAPTYPE_PAGE | CAP_MASTER
|
unsigned t = CAPTYPE_PAGE | CAP_MASTER
|
||||||
@ -349,10 +350,10 @@ static void memory_invoke (unsigned cmd, unsigned target, Kernel::Num protected_
|
|||||||
t |= Kernel::Page::READONLY
|
t |= Kernel::Page::READONLY
|
||||||
reply_cap (t, (unsigned)page, &page->refs)
|
reply_cap (t, (unsigned)page, &page->refs)
|
||||||
return
|
return
|
||||||
case Kernel::Memory::GET_LIMIT:
|
case Kernel::Memory::GET_LIMIT & REQUEST_MASK:
|
||||||
reply_num (mem->limit)
|
reply_num (mem->limit)
|
||||||
return
|
return
|
||||||
case Kernel::Memory::SET_LIMIT:
|
case Kernel::Memory::SET_LIMIT & REQUEST_MASK:
|
||||||
mem->limit = c->data[1].l
|
mem->limit = c->data[1].l
|
||||||
break
|
break
|
||||||
default:
|
default:
|
||||||
@ -364,7 +365,7 @@ static void memory_invoke (unsigned cmd, unsigned target, Kernel::Num protected_
|
|||||||
static void thread_invoke (unsigned cmd, unsigned target, Kernel::Num protected_data, kCapability::Context *c):
|
static void thread_invoke (unsigned cmd, unsigned target, Kernel::Num protected_data, kCapability::Context *c):
|
||||||
kThread *thread = (kThread *)protected_data.l
|
kThread *thread = (kThread *)protected_data.l
|
||||||
switch cmd:
|
switch cmd:
|
||||||
case Kernel::Thread::GET_INFO:
|
case Kernel::Thread::GET_INFO & REQUEST_MASK:
|
||||||
switch c->data[0].h:
|
switch c->data[0].h:
|
||||||
case Kernel::Thread::PC:
|
case Kernel::Thread::PC:
|
||||||
reply_num (thread->pc)
|
reply_num (thread->pc)
|
||||||
@ -378,7 +379,7 @@ static void thread_invoke (unsigned cmd, unsigned target, Kernel::Num protected_
|
|||||||
default:
|
default:
|
||||||
reply_num (*kThread_arch_info (thread, c->data[0].h))
|
reply_num (*kThread_arch_info (thread, c->data[0].h))
|
||||||
return
|
return
|
||||||
case Kernel::Thread::SET_INFO:
|
case Kernel::Thread::SET_INFO & REQUEST_MASK:
|
||||||
unsigned *value
|
unsigned *value
|
||||||
switch c->data[1].l:
|
switch c->data[1].l:
|
||||||
case Kernel::Thread::PC:
|
case Kernel::Thread::PC:
|
||||||
@ -411,7 +412,7 @@ static void thread_invoke (unsigned cmd, unsigned target, Kernel::Num protected_
|
|||||||
if value:
|
if value:
|
||||||
*value = (*value & ~c->data[1].h) | (c->data[1].l & c->data[1].h)
|
*value = (*value & ~c->data[1].h) | (c->data[1].l & c->data[1].h)
|
||||||
break
|
break
|
||||||
case Kernel::Thread::USE_SLOT:
|
case Kernel::Thread::USE_SLOT & REQUEST_MASK:
|
||||||
if c->data[1].l >= thread->slots || !c->arg.valid ():
|
if c->data[1].l >= thread->slots || !c->arg.valid ():
|
||||||
dbg_send (5, 3)
|
dbg_send (5, 3)
|
||||||
dpanic (c->data[1].l, "no argument given for USE_SLOT")
|
dpanic (c->data[1].l, "no argument given for USE_SLOT")
|
||||||
@ -433,7 +434,14 @@ static void thread_invoke (unsigned cmd, unsigned target, Kernel::Num protected_
|
|||||||
if new_caps:
|
if new_caps:
|
||||||
// TODO: link it into a list.
|
// TODO: link it into a list.
|
||||||
break
|
break
|
||||||
case Kernel::Thread::SCHEDULE:
|
case Kernel::Thread::GET_CAPS & REQUEST_MASK:
|
||||||
|
unsigned slot = c->data[1].l
|
||||||
|
if slot < thread->slots:
|
||||||
|
reply_cap (CAPTYPE_CAPS | CAP_MASTER, (unsigned)thread->caps[slot], &thread->caps[slot]->refs, thread->slots)
|
||||||
|
else:
|
||||||
|
reply_num (thread->slots)
|
||||||
|
return
|
||||||
|
case Kernel::Thread::SCHEDULE & REQUEST_MASK:
|
||||||
do_schedule = true
|
do_schedule = true
|
||||||
return
|
return
|
||||||
default:
|
default:
|
||||||
@ -442,19 +450,19 @@ static void thread_invoke (unsigned cmd, unsigned target, Kernel::Num protected_
|
|||||||
reply_num (Kernel::ERR_INVALID_OPERATION)
|
reply_num (Kernel::ERR_INVALID_OPERATION)
|
||||||
return
|
return
|
||||||
switch cmd:
|
switch cmd:
|
||||||
case Kernel::Thread::PRIV_REGISTER_INTERRUPT:
|
case Kernel::Thread::PRIV_REGISTER_INTERRUPT & REQUEST_MASK:
|
||||||
arch_register_interrupt (c->data[1].l, c->arg.valid () && (((unsigned)c->arg->target) & ~REQUEST_MASK) == CAPTYPE_RECEIVER ? (kReceiver *)c->arg->protected_data.l : NULL)
|
arch_register_interrupt (c->data[1].l, c->arg.valid () && (((unsigned)c->arg->target) & ~REQUEST_MASK) == CAPTYPE_RECEIVER ? (kReceiver *)c->arg->protected_data.l : NULL)
|
||||||
break
|
break
|
||||||
case Kernel::Thread::PRIV_GET_TOP_MEMORY:
|
case Kernel::Thread::PRIV_GET_TOP_MEMORY & REQUEST_MASK:
|
||||||
reply_cap (CAPTYPE_MEMORY | CAP_MASTER, (unsigned)&top_memory, &top_memory.refs)
|
reply_cap (CAPTYPE_MEMORY | CAP_MASTER, (unsigned)&top_memory, &top_memory.refs)
|
||||||
return
|
return
|
||||||
case Kernel::Thread::PRIV_MAKE_PRIV:
|
case Kernel::Thread::PRIV_MAKE_PRIV & REQUEST_MASK:
|
||||||
if !c->arg.valid () || ((unsigned)c->arg->target) & ~REQUEST_MASK != CAPTYPE_THREAD:
|
if !c->arg.valid () || ((unsigned)c->arg->target) & ~REQUEST_MASK != CAPTYPE_THREAD:
|
||||||
reply_num (~0)
|
reply_num (~0)
|
||||||
return
|
return
|
||||||
((kThread *)c->arg->protected_data.l)->flags |= Kernel::Thread::PRIV
|
((kThread *)c->arg->protected_data.l)->flags |= Kernel::Thread::PRIV
|
||||||
break
|
break
|
||||||
case Kernel::Thread::PRIV_ALLOC_RANGE:
|
case Kernel::Thread::PRIV_ALLOC_RANGE & REQUEST_MASK:
|
||||||
if !c->arg.valid () || ((unsigned)c->arg->target) & ~REQUEST_MASK != CAPTYPE_MEMORY:
|
if !c->arg.valid () || ((unsigned)c->arg->target) & ~REQUEST_MASK != CAPTYPE_MEMORY:
|
||||||
panic (0x54365435, "non-memory argument to alloc_range")
|
panic (0x54365435, "non-memory argument to alloc_range")
|
||||||
reply_num (~0)
|
reply_num (~0)
|
||||||
@ -472,7 +480,7 @@ static void thread_invoke (unsigned cmd, unsigned target, Kernel::Num protected_
|
|||||||
return
|
return
|
||||||
reply_num (data & ~0xc0000000)
|
reply_num (data & ~0xc0000000)
|
||||||
return
|
return
|
||||||
case Kernel::Thread::PRIV_ALLOC_PHYSICAL:
|
case Kernel::Thread::PRIV_ALLOC_PHYSICAL & REQUEST_MASK:
|
||||||
if !c->arg.valid ():
|
if !c->arg.valid ():
|
||||||
panic (0x71342134, "no argument provided for alloc physical")
|
panic (0x71342134, "no argument provided for alloc physical")
|
||||||
reply_num (~0)
|
reply_num (~0)
|
||||||
@ -501,7 +509,7 @@ static void thread_invoke (unsigned cmd, unsigned target, Kernel::Num protected_
|
|||||||
page->flags |= Kernel::Page::PHYSICAL
|
page->flags |= Kernel::Page::PHYSICAL
|
||||||
kPage_arch_update_mapping (page)
|
kPage_arch_update_mapping (page)
|
||||||
break
|
break
|
||||||
case Kernel::Thread::PRIV_PHYSICAL_ADDRESS:
|
case Kernel::Thread::PRIV_PHYSICAL_ADDRESS & REQUEST_MASK:
|
||||||
if !c->arg.valid () || ((unsigned)c->arg->target) & ~REQUEST_MASK != CAPTYPE_PAGE:
|
if !c->arg.valid () || ((unsigned)c->arg->target) & ~REQUEST_MASK != CAPTYPE_PAGE:
|
||||||
dpanic (0x99049380, "invalid page for physical address")
|
dpanic (0x99049380, "invalid page for physical address")
|
||||||
reply_num (~0)
|
reply_num (~0)
|
||||||
@ -509,11 +517,11 @@ static void thread_invoke (unsigned cmd, unsigned target, Kernel::Num protected_
|
|||||||
kPage *page = (kPage *)c->arg->protected_data.l
|
kPage *page = (kPage *)c->arg->protected_data.l
|
||||||
reply_num (page->frame & ~0xc0000000)
|
reply_num (page->frame & ~0xc0000000)
|
||||||
return
|
return
|
||||||
case Kernel::Thread::PRIV_PANIC:
|
case Kernel::Thread::PRIV_PANIC & REQUEST_MASK:
|
||||||
panic (c->data[1].l, "panic requested by thread")
|
panic (c->data[1].l, "panic requested by thread")
|
||||||
reply_num (~0)
|
reply_num (~0)
|
||||||
return
|
return
|
||||||
case Kernel::Thread::DBG_SEND:
|
case Kernel::Thread::DBG_SEND & REQUEST_MASK:
|
||||||
dbg_send (c->data[1].l, c->data[1].h)
|
dbg_send (c->data[1].l, c->data[1].h)
|
||||||
break
|
break
|
||||||
default:
|
default:
|
||||||
@ -551,7 +559,7 @@ static bool page_check_payment (kPage *page):
|
|||||||
static void page_invoke (unsigned cmd, unsigned target, Kernel::Num protected_data, kCapability::Context *c):
|
static void page_invoke (unsigned cmd, unsigned target, Kernel::Num protected_data, kCapability::Context *c):
|
||||||
kPage *page = (kPage *)protected_data.l
|
kPage *page = (kPage *)protected_data.l
|
||||||
switch cmd & ~Kernel::Page::READONLY:
|
switch cmd & ~Kernel::Page::READONLY:
|
||||||
case Kernel::Page::SHARE:
|
case Kernel::Page::SHARE & REQUEST_MASK:
|
||||||
if !c->arg.valid ():
|
if !c->arg.valid ():
|
||||||
// Cannot share without a target page.
|
// Cannot share without a target page.
|
||||||
reply_num (~0)
|
reply_num (~0)
|
||||||
@ -626,7 +634,7 @@ static void page_invoke (unsigned cmd, unsigned target, Kernel::Num protected_da
|
|||||||
t->share_prev->share_next = t
|
t->share_prev->share_next = t
|
||||||
kPage_arch_update_mapping (t)
|
kPage_arch_update_mapping (t)
|
||||||
break
|
break
|
||||||
case Kernel::Page::SET_FLAGS:
|
case Kernel::Page::SET_FLAGS & REQUEST_MASK:
|
||||||
if cmd & Kernel::Page::READONLY:
|
if cmd & Kernel::Page::READONLY:
|
||||||
reply_num (~0)
|
reply_num (~0)
|
||||||
return
|
return
|
||||||
@ -698,14 +706,14 @@ static void print_cap (kCapRef cap, kCapRef self):
|
|||||||
static void caps_invoke (unsigned cmd, unsigned target, Kernel::Num protected_data, kCapability::Context *c):
|
static void caps_invoke (unsigned cmd, unsigned target, Kernel::Num protected_data, kCapability::Context *c):
|
||||||
kCaps *caps = (kCapsP)protected_data.l
|
kCaps *caps = (kCapsP)protected_data.l
|
||||||
switch cmd:
|
switch cmd:
|
||||||
case Kernel::Caps::SET:
|
case Kernel::Caps::SET & REQUEST_MASK:
|
||||||
if c->data[1].l >= caps->size:
|
if c->data[1].l >= caps->size:
|
||||||
dpanic (0, "invalid index for set caps")
|
dpanic (0, "invalid index for set caps")
|
||||||
return
|
return
|
||||||
caps->clone (c->data[1].l, c->arg, c->copy[1])
|
caps->clone (c->data[1].l, c->arg, c->copy[1])
|
||||||
reply_num (0)
|
reply_num (0)
|
||||||
return
|
return
|
||||||
case Kernel::Caps::PRINT:
|
case Kernel::Caps::PRINT & REQUEST_MASK:
|
||||||
if c->data[1].l >= caps->size:
|
if c->data[1].l >= caps->size:
|
||||||
dpanic (0, "invalid caps for print")
|
dpanic (0, "invalid caps for print")
|
||||||
return
|
return
|
||||||
@ -802,7 +810,8 @@ static void kernel_invoke (unsigned target, Kernel::Num protected_data, kCapabil
|
|||||||
cmd = c->data[0].l
|
cmd = c->data[0].l
|
||||||
c->data[0].l = 0
|
c->data[0].l = 0
|
||||||
else:
|
else:
|
||||||
cmd = target & REQUEST_MASK
|
cmd = target
|
||||||
|
cmd &= REQUEST_MASK
|
||||||
switch target & CAPTYPE_MASK:
|
switch target & CAPTYPE_MASK:
|
||||||
case CAPTYPE_RECEIVER:
|
case CAPTYPE_RECEIVER:
|
||||||
receiver_invoke (cmd, target, protected_data, c)
|
receiver_invoke (cmd, target, protected_data, c)
|
||||||
|
18
iris.hhp
18
iris.hhp
@ -252,7 +252,7 @@ namespace Kernel:
|
|||||||
Receiver (Cap c = Cap ()) : Cap (c):
|
Receiver (Cap c = Cap ()) : Cap (c):
|
||||||
enum request:
|
enum request:
|
||||||
// Operations
|
// Operations
|
||||||
SET_OWNER = 1
|
SET_OWNER = CAPTYPE_RECEIVER + 1
|
||||||
CREATE_CAPABILITY
|
CREATE_CAPABILITY
|
||||||
CREATE_CALL_CAPABILITY
|
CREATE_CALL_CAPABILITY
|
||||||
CREATE_ASYNC_CALL_CAPABILITY
|
CREATE_ASYNC_CALL_CAPABILITY
|
||||||
@ -295,9 +295,10 @@ namespace Kernel:
|
|||||||
Thread (Cap c = Cap ()) : Cap (c):
|
Thread (Cap c = Cap ()) : Cap (c):
|
||||||
enum request:
|
enum request:
|
||||||
// Info details are arch-specific.
|
// Info details are arch-specific.
|
||||||
GET_INFO = 1
|
GET_INFO = CAPTYPE_THREAD + 1
|
||||||
SET_INFO
|
SET_INFO
|
||||||
USE_SLOT
|
USE_SLOT
|
||||||
|
GET_CAPS
|
||||||
SCHEDULE
|
SCHEDULE
|
||||||
PRIV_ALLOC_RANGE
|
PRIV_ALLOC_RANGE
|
||||||
PRIV_PHYSICAL_ADDRESS
|
PRIV_PHYSICAL_ADDRESS
|
||||||
@ -342,13 +343,16 @@ namespace Kernel:
|
|||||||
void wait (bool wait):
|
void wait (bool wait):
|
||||||
set_flags (wait ? WAITING : 0, WAITING)
|
set_flags (wait ? WAITING : 0, WAITING)
|
||||||
inline unsigned use (Caps caps, unsigned slot = alloc_slot ())
|
inline unsigned use (Caps caps, unsigned slot = alloc_slot ())
|
||||||
|
inline Caps get_caps (unsigned slot)
|
||||||
|
unsigned get_num_caps ():
|
||||||
|
return call (CAP_MASTER_DIRECT | GET_CAPS, ~0).l
|
||||||
|
|
||||||
struct Caps : public Cap:
|
struct Caps : public Cap:
|
||||||
Caps (unsigned slot, unsigned idx) : Cap (slot, idx):
|
Caps (unsigned slot, unsigned idx) : Cap (slot, idx):
|
||||||
Caps (Cap c = Cap ()) : Cap (c):
|
Caps (Cap c = Cap ()) : Cap (c):
|
||||||
enum request:
|
enum request:
|
||||||
// Not an operation; this capability can be used in Thread::USE_SLOT.
|
// Not an operation; this capability can be used in Thread::USE_SLOT.
|
||||||
USE = 1
|
USE = CAPTYPE_CAPS + 1
|
||||||
SET
|
SET
|
||||||
PRINT
|
PRINT
|
||||||
unsigned use (unsigned slot = alloc_slot ()):
|
unsigned use (unsigned slot = alloc_slot ()):
|
||||||
@ -358,6 +362,10 @@ namespace Kernel:
|
|||||||
void print (unsigned idx):
|
void print (unsigned idx):
|
||||||
invoke (CAP_MASTER_DIRECT | PRINT, idx)
|
invoke (CAP_MASTER_DIRECT | PRINT, idx)
|
||||||
|
|
||||||
|
Caps Thread::get_caps (unsigned slot):
|
||||||
|
call (CAP_MASTER_DIRECT | GET_CAPS, slot)
|
||||||
|
return get_arg ()
|
||||||
|
|
||||||
unsigned Thread::use (Caps caps, unsigned slot):
|
unsigned Thread::use (Caps caps, unsigned slot):
|
||||||
ocall (caps, CAP_MASTER_DIRECT | USE_SLOT, slot)
|
ocall (caps, CAP_MASTER_DIRECT | USE_SLOT, slot)
|
||||||
return slot
|
return slot
|
||||||
@ -366,7 +374,7 @@ namespace Kernel:
|
|||||||
Page (unsigned slot, unsigned idx) : Cap (slot, idx):
|
Page (unsigned slot, unsigned idx) : Cap (slot, idx):
|
||||||
Page (Cap c = Cap ()) : Cap (c):
|
Page (Cap c = Cap ()) : Cap (c):
|
||||||
enum request:
|
enum request:
|
||||||
SHARE = 1
|
SHARE = CAPTYPE_PAGE + 1
|
||||||
GET_FLAGS
|
GET_FLAGS
|
||||||
SET_FLAGS
|
SET_FLAGS
|
||||||
// Not an operation; a capability with this bit cannot write to the page.
|
// Not an operation; a capability with this bit cannot write to the page.
|
||||||
@ -407,7 +415,7 @@ namespace Kernel:
|
|||||||
Memory (unsigned slot, unsigned idx) : Cap (slot, idx):
|
Memory (unsigned slot, unsigned idx) : Cap (slot, idx):
|
||||||
Memory (Cap c = Cap ()) : Cap (c):
|
Memory (Cap c = Cap ()) : Cap (c):
|
||||||
enum request:
|
enum request:
|
||||||
CREATE = 1
|
CREATE = CAPTYPE_MEMORY + 1
|
||||||
DESTROY
|
DESTROY
|
||||||
LIST
|
LIST
|
||||||
MAP
|
MAP
|
||||||
|
@ -34,7 +34,7 @@ uimage:
|
|||||||
mips/entry.o: $(boot_threads)
|
mips/entry.o: $(boot_threads)
|
||||||
mips/init.o: TARGET_FLAGS = -I/usr/include
|
mips/init.o: TARGET_FLAGS = -I/usr/include
|
||||||
$(boot_threads): TARGET_FLAGS = -I.
|
$(boot_threads): TARGET_FLAGS = -I.
|
||||||
$(addprefix boot-programs/,$(addsuffix .cc,$(boot_threads))): boot-programs/devices.hh
|
$(addprefix boot-programs/,$(addsuffix .cc,$(boot_threads))): boot-programs/devices.hh boot-programs/init.hh
|
||||||
lcd: boot-programs/charset.data
|
lcd: boot-programs/charset.data
|
||||||
|
|
||||||
boot-programs/charset.data: boot-programs/charset
|
boot-programs/charset.data: boot-programs/charset
|
||||||
|
@ -221,9 +221,6 @@ kThread *exception ():
|
|||||||
if !dbg_cap.valid ():
|
if !dbg_cap.valid ():
|
||||||
dpanic (0, "no log capability provided")
|
dpanic (0, "no log capability provided")
|
||||||
break
|
break
|
||||||
dbg_log ("debug capability registered. thread = ")
|
|
||||||
dbg_log_num ((unsigned)current)
|
|
||||||
dbg_log_char ('\n')
|
|
||||||
break
|
break
|
||||||
if dbg_cap.valid ():
|
if dbg_cap.valid ():
|
||||||
dbg_log_char (current->arch.a[1])
|
dbg_log_char (current->arch.a[1])
|
||||||
|
Loading…
x
Reference in New Issue
Block a user