1
0
mirror of git://projects.qi-hardware.com/iris.git synced 2025-04-21 12:27:27 +03:00

use automake

This commit is contained in:
Bas Wijnen
2012-09-26 19:03:36 +02:00
parent 538b9b9361
commit d9a12225eb
38 changed files with 815 additions and 336 deletions

View File

@@ -1,73 +1,50 @@
#pypp 0
#include <iris.hh>
#include <ui.hh>
#include <devices.hh>
enum Ins:
TOTAL_TIME
START
NUM_INS
enum Outs:
CURRENT_TIME
ALARM
NUM_OUTS
typedef UI <NUM_INS, NUM_OUTS> ui_t
static ui_t ui
static ui_t::in <unsigned> total_time
static ui_t::in_event do_start
static ui_t::out <unsigned> current_time
static ui_t::out_event do_alarm
static bool ticking
static void event (unsigned code):
switch code:
case TOTAL_TIME:
break
case START:
current_time = total_time
if !ticking:
if !current_time:
do_alarm ()
else:
ticking = true
Iris::my_receiver.set_alarm (HZ)
break
default:
Iris::panic (0, "invalid event for alarm clock")
enum captypes:
CONTROL = 1
KBD
INTERRUPT
Iris::Num start ():
ticking = false;
Iris::Cap ui_cap = Iris::my_receiver.create_capability (0)
ui.init (ui_cap.copy ());
Iris::free_cap (ui_cap)
total_time.init ()
do_start.init ()
current_time.init ()
do_alarm.init ()
ui.add_in (&total_time, TOTAL_TIME);
ui.add_in (&do_start, START);
ui.add_out (&current_time, CURRENT_TIME);
ui.add_out (&do_alarm, ALARM);
unsigned *screen = (unsigned *)0x40000000
Iris::RTC rtc = Iris::my_parent.get_capability <Iris::RTC> ()
Iris::Display display = Iris::my_parent.get_capability <Iris::Display> ()
display.map_fb ((unsigned)screen)
Iris::Font font = Iris::my_parent.get_capability <Iris::Font> ()
font.set_display (display)
Iris::Keyboard keyboard = Iris::my_parent.get_capability <Iris::Keyboard> ()
Iris::Cap cap = Iris::my_receiver.create_capability (KBD)
keyboard.set_cb (cap.copy ())
Iris::free_cap (cap)
Iris::Buzzer buzzer = Iris::my_parent.get_capability <Iris::Buzzer> ()
Iris::Event self = Iris::my_receiver.create_capability (CONTROL)
Iris::my_parent.provide_capability <Iris::Event> (self)
cap = Iris::my_receiver.create_capability (INTERRUPT)
Iris::my_parent.init_done ()
while true:
Iris::wait ()
switch Iris::recv.protected_data.l:
case ~0:
// alarm.
if current_time:
current_time = current_time - 1
if !current_time:
do_alarm ()
ticking = false
else:
// TODO: use rtc for scheduling an event.
Iris::my_receiver.set_alarm (HZ)
continue
case 0:
// ui event.
if !ui.event (&event):
// Exit request.
return 0
case INTERRUPT:
// Interrupt
if Iris::recv.data[0].l == ~0:
// Not a real interrupt, just an abort notification.
continue
font.printf ("alarm: interrupt\n")
break
case CONTROL:
// Store callback
font.printf ("alarm: control event\n")
break
case KBD:
// Key press
unsigned time = rtc.get_time ()
unsigned alarm = rtc.get_alarm ()
unsigned enabled = Iris::recv.data[1].l
font.printf ("%d %d %d", time, alarm, enabled)
rtc.set_alarm (time + 10, cap)
Iris::poweroff ()
break
default:
Iris::panic (Iris::recv.protected_data.l, "invalid request for alarm")

View File

@@ -320,10 +320,15 @@ Iris::Num start ():
Iris::Memory top_memory = Iris::get_top_memory ()
Iris::Directory root = receive_devices ()
root.lock_ro ()
kdebug_line ()
Iris::Block run_block = find (root, ELFRUN_NAME)
kdebug_line ()
Iris::Cap parent_cap = Iris::my_receiver.create_capability (0)
kdebug_line ()
run (run_block, top_memory, parent_cap)
kdebug_line ()
Iris::wait ()
kdebug_line ()
if Iris::recv.data[0].l != Iris::Parent::PROVIDE_CAPABILITY || Iris::recv.data[1].l != Iris::Elfrun::ID:
Iris::panic (0, "elfrun doesn't provide correct capability")
Iris::Cap reply = Iris::get_reply ()

179
source/font.ccp Normal file
View File

@@ -0,0 +1,179 @@
#pypp 0
// Iris: micro-kernel for a capability-based operating system.
// source/font.ccp: Font manager.
// Copyright 2012 Bas Wijnen <wijnen@debian.org>
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
#include "devices.hh"
#define screenw 320
#define screenh 240
struct Glyph:
unsigned width, height, baseline
unsigned data[1]
static Iris::Display display
static Iris::Caps caps, display_caps
static unsigned slot, num_glyphs
static unsigned long pages, base
static Glyph **glyphs
static char *fb
static unsigned x, y
static unsigned read_int (unsigned addr):
return *reinterpret_cast <unsigned *> (addr)
static void load_font (Iris::Block font):
unsigned long long size = font.get_size ().value ()
pages = (size + PAGE_SIZE - 1) >> PAGE_BITS
caps = Iris::my_memory.create_caps (pages)
slot = caps.use ()
for unsigned i = 0; i < size; i += PAGE_SIZE:
Iris::Page page = Iris::Cap (slot, i >> PAGE_BITS)
Iris::set_recv_arg (page)
font.get_block (i)
Iris::my_memory.map (page, base + i)
num_glyphs = read_int (base)
glyphs = reinterpret_cast <Glyph **> (base + sizeof (int))
for unsigned i = 0; i < num_glyphs; ++i:
glyphs[i] = reinterpret_cast <Glyph *> (base + sizeof (int) + read_int (base + sizeof (int) + i * sizeof (int)))
static void free_font ():
for unsigned i = 0; i < pages; ++i:
Iris::my_memory.destroy (Iris::Cap (slot, i))
Iris::my_memory.destroy (caps)
Iris::free_slot (slot)
static unsigned draw_char (char c, unsigned &w, unsigned &h):
if c >= num_glyphs:
c = num_glyphs - 1
Glyph *g = glyphs[c]
w = g->width
h = g->height
for unsigned ty = 0; ty < h; ++ty:
unsigned py = ty + y - g->baseline
if py < 0 || py >= screenh:
continue
for unsigned tx = 0; tx < g->width; ++tx:
unsigned px = tx + x
if px < 0 || px >= screenw:
continue
unsigned p = g->data[ty * g->width + tx]
unsigned red = unsigned (p) & 0xff
unsigned green = unsigned (p >> 8) & 0xff
unsigned blue = unsigned (p >> 16) & 0xff
unsigned alpha = (unsigned (p >> 24) & 0xff) + 1
if alpha == 0x100:
fb[(py * 320 + px) * 4 + 2] = red
fb[(py * 320 + px) * 4 + 1] = green
fb[(py * 320 + px) * 4 + 0] = blue
else:
unsigned unalpha = 256 - alpha
fb[(py * 320 + px) * 4 + 2] = (fb[(py * 320 + px) * 4 + 2] * unalpha + red * alpha) >> 8
fb[(py * 320 + px) * 4 + 1] = (fb[(py * 320 + px) * 4 + 1] * unalpha + green * alpha) >> 8
fb[(py * 320 + px) * 4 + 0] = (fb[(py * 320 + px) * 4 + 0] * unalpha + blue * alpha) >> 8
return g->baseline
static void get_size (char c, unsigned &w, unsigned &h, unsigned &b):
if c >= num_glyphs:
c = num_glyphs - 1
Glyph *g = glyphs[c]
w = g->width
h = g->height
b = g->baseline
Iris::Num start ():
x = 0
y = 8
// Random address which is large enough to store a huge file.
base = 0x40000000
fb = reinterpret_cast <char *> (0x20000000)
Iris::Font self = Iris::my_receiver.create_capability (0)
Iris::my_parent.provide_capability <Iris::Font> (self.copy ())
Iris::free_cap (self)
//display = Iris::my_parent.get_capability <Iris::Display> ()
Iris::Block font = Iris::my_parent.get_capability <Iris::Block> ()
load_font (font)
Iris::free_cap (font)
Iris::my_parent.init_done ()
//display_caps = display.map_fb (reinterpret_cast <unsigned> (fb))
bool have_display = false
while true:
Iris::wait ()
switch Iris::recv.data[0].l:
case Iris::Font::SET_DISPLAY:
Iris::Cap reply = Iris::get_reply ()
if have_display:
Iris::free_cap (display)
have_display = true
display = Iris::get_arg ()
display_caps = display.map_fb (reinterpret_cast <unsigned> (fb))
reply.invoke ()
Iris::free_cap (reply)
break
case Iris::Font::LOAD_FONT:
free_font ()
font = Iris::get_arg ()
load_font (font)
Iris::free_cap (font)
Iris::recv.reply.invoke ()
break
case Iris::Font::SETUP:
// TODO: interface needs to be defined.
Iris::recv.reply.invoke ()
break
case Iris::Font::AT:
if Iris::recv.data[0].h & 1:
x += Iris::recv.data[1].l
if x > screenw:
x = 0
y += 16
if y + 16 > screenh + 8:
y = 8
else:
x = Iris::recv.data[1].l
if Iris::recv.data[0].h & 2:
y += Iris::recv.data[1].h
if y + 16 > screenh + 8:
y = 8
else:
y = Iris::recv.data[1].h
Iris::recv.reply.invoke ()
break
case Iris::Font::WRITE:
Iris::Cap reply = Iris::get_reply ()
unsigned w, h
unsigned b = draw_char (Iris::recv.data[1].l, w, h)
x += w
if x + w > screenw:
x = 0
y += h
if y + h > screenh + b:
y = b
reply.invoke ()
Iris::free_cap (reply)
break
case Iris::Font::GET_POS:
Iris::recv.reply.invoke (x, y)
break
case Iris::Font::GET_SIZE:
unsigned w, h, b
get_size (Iris::recv.data[1].l, w, h, b)
Iris::recv.reply.invoke (Iris::Num (b, h), w)
break
default:
Iris::panic (0, "invalid operation type for lcd")
break

View File

@@ -295,11 +295,13 @@ static Type types[] = {
{ "Keyboard", 8, Iris::Keyboard::ID },
{ "Buzzer", 6, Iris::Buzzer::ID },
{ "Display", 7, Iris::Display::ID },
{ "Font", 4, Iris::Font::ID },
{ "Setting", 7, Iris::Setting::ID },
{ "Directory", 9, Iris::Directory::ID },
{ "WDirectory", 10, Iris::WDirectory::ID },
{ "Stream", 6, Iris::Stream::ID },
{ "UI", 2, Iris::UI::ID },
{ "RTC", 3, Iris::RTC::ID },
{ NULL, 0, 0 }
}
@@ -514,9 +516,9 @@ Iris::Num start ():
switch Iris::recv.protected_data.l:
case SYSREQ:
if Iris::recv.data[0].l & Iris::Keyboard::RELEASE:
Iris::poweroff ()
Iris::reboot ()
continue
kdebug ("sysreq event: powering device off at release\n")
kdebug ("sysreq event: rebooting device at release\n")
continue
case FILE:
File *file = (File *)Iris::recv.protected_data.h
@@ -563,6 +565,7 @@ Iris::Num start ():
if (*d)->type == type && (*d)->index == index:
break
if !d:
Iris::debug ("requested %x by %s\n", type, caller->name)
Iris::panic (type, "unregistered device requested")
Iris::recv.reply.invoke (0, 0, (*d)->dev->cap)
//kdebug ("given device ")

View File

@@ -244,7 +244,7 @@ static void log_msg ():
log_char ('\n')
enum captype:
LOG = 32
LOG = 1
BACKLIGHT
LCD
@@ -359,7 +359,7 @@ Iris::Num start ():
Iris::wait ()
//log_msg ()
switch Iris::recv.protected_data.l:
case IRQ_LCD:
case 0:
have_eof = false
eof_cb.invoke ()
Iris::free_cap (eof_cb)

View File

@@ -21,7 +21,7 @@
#include "arch.hh"
#include "keys.hh"
//#define QI
#define QI
#define SCAN_INTERVAL HZ / 50
class DevKbd:
@@ -128,10 +128,10 @@ unsigned const DevKbd::encode[NUM_ROWS][NUM_COLS] = {
{ Key::Q, Key::W, Key::E, Key::R, Key::T, Key::Y, Key::U, Key::I },
{ Key::A, Key::S, Key::D, Key::F, Key::G, Key::H, Key::J, Key::K },
{ Key::ESCAPE, Key::Z, Key::X, Key::C, Key::V, Key::B, Key::N, Key::M },
{ Key::TAB, Key::CAPS, Key::BACKSLASH, Key::QUOTE, Key::COMMA, Key::PERIOD, Key::SLASH, Key::UP },
{ Key::O, Key::L, Key::EQUAL, Key::ARROW, Key::SPACE, Key::QI, Key::CTRL, Key::LEFT },
{ Key::TAB, Key::CAPS_LOCK, Key::BACKSLASH, Key::QUOTE, Key::COMMA, Key::PERIOD, Key::SLASH, Key::UP },
{ Key::O, Key::L, Key::EQUALS, Key::SPECIAL + 0, Key::SPACE, Key::RIGHT_LOGO, Key::RIGHT_CONTROL, Key::LEFT },
{ Key::F8, Key::P, Key::BACKSPACE, Key::ENTER, Key::VOLUME_UP, Key::VOLUME_DOWN, Key::DOWN, Key::RIGHT },
{ Key::SHIFT, Key::ALT, Key::FN, ~0, ~0, ~0, ~0, ~0 }
{ Key::LEFT_SHIFT, Key::LEFT_ALT, Key::FN, ~0, ~0, ~0, ~0, ~0 }
#else
{ Key::ESCAPE, Key::TAB, Key::F1, Key::F2, Key::F3, Key::F4, Key::SPECIAL + 0, ~0 },
{ Key::N1, Key::N2, Key::N3, Key::N4, Key::N5, Key::N6, Key::N7, Key::N8 },
@@ -149,10 +149,10 @@ unsigned const DevKbd::keys[NUM_KEYS] = {
Key::Q, Key::W, Key::E, Key::R, Key::T, Key::Y, Key::U, Key::I,
Key::A, Key::S, Key::D, Key::F, Key::G, Key::H, Key::J, Key::K,
Key::ESCAPE, Key::Z, Key::X, Key::C, Key::V, Key::B, Key::N, Key::M,
Key::TAB, Key::CAPS, Key::BACKSLASH, Key::QUOTE, Key::COMMA, Key::PERIOD, Key::SLASH, Key::UP,
Key::O, Key::L, Key::EQUAL, Key::ARROW, Key::SPACE, Key::QI, Key::CTRL, Key::LEFT,
Key::TAB, Key::CAPS_LOCK, Key::BACKSLASH, Key::QUOTE, Key::COMMA, Key::PERIOD, Key::SLASH, Key::UP,
Key::O, Key::L, Key::EQUALS, Key::SPECIAL + 0, Key::SPACE, Key::RIGHT_LOGO, Key::RIGHT_CONTROL, Key::LEFT,
Key::F8, Key::P, Key::BACKSPACE, Key::ENTER, Key::VOLUME_UP, Key::VOLUME_DOWN, Key::DOWN, Key::RIGHT,
Key::SHIFT, Key::ALT, Key::FN
Key::LEFT_SHIFT, Key::LEFT_ALT, Key::FN
#else
Key::ESCAPE, Key::TAB, Key::F1, Key::F2, Key::F3, Key::F4, Key::SPECIAL + 0,
Key::N1, Key::N2, Key::N3, Key::N4, Key::N5, Key::N6, Key::N7, Key::N8,
@@ -195,7 +195,7 @@ class Event:
scan ()
enum codes:
KBD_DEV = 32
KBD_DEV = 1
PWR
SDMMC
@@ -228,7 +228,7 @@ Iris::Num start ():
Iris::my_receiver.set_alarm (SCAN_INTERVAL)
continue
switch Iris::recv.protected_data.l:
case IRQ_GPIO3:
case 0:
// Interrupt.
pwr.scan ()
kbd.scan ()

View File

@@ -20,6 +20,8 @@
#define ARCH
#include "arch.hh"
static Iris::Font font
static void ready ():
while !rtc_write_ready ():
Iris::schedule ()
@@ -42,17 +44,104 @@ Iris::Num start ():
cpm_start_rtc ()
ready ()
rtc_enabled ()
if rtc_get_scratch_pattern () != 0xbeefface:
ready ()
rtc_set_nc1Hz_val (RTC_CLOCK)
ready ()
rtc_set_adjc_val (0)
ready ()
rtc_set_second (0)
ready ()
rtc_set_nc1Hz_val (RTC_CLOCK)
rtc_disable_1Hz_irq ()
ready ()
rtc_disable_alarm ()
ready ()
rtc_enable_1Hz_irq ()
rtc_clear_alarm_flag ()
ready ()
rtc_enable_alarm_irq ()
ready ()
rtc_set_hwfcr_val (0)
ready ()
rtc_set_hrcr_val (0)
ready ()
rtc_enable_alarm_wakeup ()
ready ()
rtc_set_scratch_pattern (0xbeefface)
Iris::RTC self = Iris::my_receiver.create_capability (1)
Iris::my_parent.provide_capability <Iris::RTC> (self.copy ())
Iris::free_cap (self)
Iris::my_parent.init_done ()
bool have_interrupt = false
Iris::Cap interrupt
while true:
ready ()
rtc_clear_1Hz_flag ()
ready ()
Iris::register_interrupt (IRQ_RTC)
Iris::wait ()
kdebug ("tick\n")
if Iris::recv.protected_data.l == 0:
// Interrupt.
ready ()
rtc_disable_alarm ()
if have_interrupt:
interrupt.invoke (0)
Iris::free_cap (interrupt)
have_interrupt = false
continue
switch Iris::recv.data[0].l:
case Iris::RTC::SETUP:
ready ()
rtc_set_nc1Hz_val (Iris::recv.data[1].l)
ready ()
rtc_set_adjc_val (Iris::recv.data[1].h)
Iris::recv.reply.invoke ()
break
case Iris::RTC::GET_TIME:
ready ()
Iris::recv.reply.invoke (rtc_get_second ())
Iris::recv.reply.invoke (0)
break
case Iris::RTC::SET_TIME:
ready ()
rtc_set_second (Iris::recv.data[1].l)
Iris::recv.reply.invoke ()
break
case Iris::RTC::GET_ALARM:
ready ()
Iris::recv.reply.invoke (rtc_get_alarm_second (), rtc_alarm_is_enabled ())
Iris::recv.reply.invoke (0)
break
case Iris::RTC::UNSET_ALARM:
Iris::Cap reply = Iris::get_reply ()
if have_interrupt:
have_interrupt = false
interrupt.invoke (~0)
Iris::free_cap (interrupt)
Iris::unregister_interrupt (IRQ_RTC)
ready ()
rtc_disable_alarm ()
reply.invoke ()
Iris::free_cap (reply)
case Iris::RTC::SET_ALARM:
Iris::Cap reply = Iris::get_reply ()
Iris::Cap arg = Iris::get_arg ()
unsigned alarm = Iris::recv.data[1].l
ready ()
rtc_clear_alarm_flag ()
if have_interrupt:
Iris::debug ("not registering irq\n")
interrupt.invoke (~0)
Iris::free_cap (interrupt)
else:
Iris::debug ("registering irq\n")
Iris::register_interrupt (IRQ_RTC)
interrupt = arg
have_interrupt = true
ready ()
rtc_set_alarm_second (alarm)
ready ()
rtc_clear_alarm_flag ()
ready ()
rtc_enable_alarm ()
reply.invoke ()
Iris::free_cap (reply)
break
default:
Iris::panic (Iris::recv.data[0].l, "invalid rtc request")
return 0

View File

@@ -95,7 +95,7 @@ bool Mmc::send (unsigned cmd, unsigned arg, Response_type response_type, unsigne
MSC_IMASK = ~MSC_IMASK_END_CMD_RES
Iris::register_interrupt (IRQ_MSC)
msc_start_op ()
Iris::wait_for_interrupt (IRQ_MSC)
Iris::wait_for_interrupt ()
MSC_IMASK = ~0
//kdebug ("cmd: ")
//kdebug_num (cmd)
@@ -426,7 +426,7 @@ void Mmc::set_block (unsigned block):
for unsigned a = 0; a < 1 << csd.write_bl_len; a += 4:
while MSC_STAT & MSC_STAT_DATA_FIFO_FULL:
Iris::register_interrupt (IRQ_MSC)
Iris::wait_for_interrupt (IRQ_MSC)
Iris::wait_for_interrupt ()
MSC_TXFIFO = current_block[a >> 2]
MSC_IMASK = ~0
MSC_IREG = MSC_IREG_DATA_TRAN_DONE
@@ -442,7 +442,7 @@ void Mmc::set_block (unsigned block):
for unsigned aa = 0; aa < 1 << 9; aa += 4:
while MSC_STAT & MSC_STAT_DATA_FIFO_EMPTY:
Iris::register_interrupt (IRQ_MSC)
Iris::wait_for_interrupt (IRQ_MSC)
Iris::wait_for_interrupt ()
current_block[(a + aa) >> 2] = MSC_RXFIFO
MSC_IMASK = ~0
MSC_IREG = MSC_IREG_DATA_TRAN_DONE
@@ -485,13 +485,13 @@ void Mmc::wait_write ():
MSC_IMASK = ~MSC_IMASK_PRG_DONE
while !MSC_STAT & MSC_STAT_PRG_DONE:
Iris::register_interrupt (IRQ_MSC)
Iris::wait_for_interrupt (IRQ_MSC)
Iris::wait_for_interrupt ()
MSC_IREG = MSC_IREG_PRG_DONE
static Mmc mmc
enum types:
DETECT
DETECT = 1
REQUEST
Iris::Num start ():
@@ -525,15 +525,15 @@ Iris::Num start ():
while true:
Iris::wait ()
switch Iris::recv.protected_data.l:
case 0:
mmc.interrupt ()
break
case DETECT:
if Iris::recv.data[0].l:
mmc.detect ()
else:
mmc.release ()
break
case IRQ_MSC:
mmc.interrupt ()
break
case REQUEST:
//kdebug ("sd+mmc request ")
//kdebug_num (Iris::recv.data[0].l)

View File

@@ -247,7 +247,7 @@ class Pwm:
// TODO: make it really work as a pwm instead of a switch; check if pwm1 is connected to anything.
enum codes:
KEYBOARD = 32
KEYBOARD = 1
TOUCHPAD
LOCKLEDS
PWM
@@ -289,7 +289,7 @@ Iris::Num start ():
if kbd.is_scanning ():
Iris::my_receiver.set_alarm (ALARM_INTERVAL)
break
case IRQ_GPIO0:
case 0:
// Always scan keyboard and touchpad on any interrupt.
kbd.scan ()
tp.check_events ()

View File

@@ -390,6 +390,7 @@ bool Udc::handle_setup (Setup *s, unsigned cmd):
void Udc::irq_usb (unsigned cmd):
// Reset.
//Iris::debug ("usb reset\n")
state = IDLE
void Udc::irq_in (unsigned cmd):
@@ -507,11 +508,7 @@ void Udc::irq_out (unsigned cmd):
Iris::panic (0)
unsigned size = UDC_OUTCOUNT
unsigned csr = UDC_OUTCSR
//kdebug ("handling bulk interrupt for ")
//kdebug_num (csr)
//kdebug (" with ")
//kdebug_num (size)
//kdebug (" bytes.\n")
//Iris::debug ("handling bulk interrupt for %x with %d bytes.\n", csr, size)
csr &= ~UDC_OUTCSR_OUTPKTRDY
for unsigned i = 0; i < size; i += 4:
*p++ = UDC_FIFO (1)
@@ -534,13 +531,7 @@ void Udc::interrupt (unsigned cmd):
unsigned out = UDC_INTROUT
if !(usb & 4) && !(in & 1) && !(out & 2):
break
//kdebug ("interrupt: ")
//kdebug_num (usb, 1)
//kdebug ("/")
//kdebug_num (in, 1)
//kdebug ("/")
//kdebug_num (out, 1)
//kdebug ("\n")
//Iris::debug ("interrupt: %d/%d/%d\n", usb, in, out)
if usb & 4:
irq_usb (cmd)
if in & 1:
@@ -554,7 +545,7 @@ void Udc::log (unsigned c):
log_buffer[log_buffer_size++] = c
enum pdata:
LOG = 32
LOG = 1
DIRECTORY
FILE
NAME
@@ -565,20 +556,23 @@ Iris::Num start ():
map_cpm ()
Udc udc
Iris::Cap logcap = Iris::my_receiver.create_capability (LOG)
__asm__ volatile ("li $a0, 1\nlw $a1, %0\nbreak" :: "m"(logcap.code): "a0", "a1", "memory")
udc.init ()
Iris::register_interrupt (IRQ_UDC)
//Iris::Cap logcap = Iris::my_receiver.create_capability (LOG)
//__asm__ volatile ("li $a0, 1\nlw $a1, %0\nbreak" :: "m"(logcap.code): "a0", "a1", "memory")
Iris::Directory dir = Iris::my_receiver.create_capability (DIRECTORY)
Iris::my_parent.provide_capability <Iris::Directory> (dir.copy ())
Iris::free_cap (dir)
udc.init ()
Iris::register_interrupt (IRQ_UDC)
// Don't call init_done, because this can be used as bootthread and without a parent this call will not be answered.
//Iris::my_parent.init_done ()
unsigned state = 0
while true:
Iris::wait ()
Iris::Cap reply = Iris::get_reply ()
Iris::Cap arg = Iris::get_arg ()
//Iris::debug ("udc event, protected: %x\n", Iris::recv.protected_data.l)
switch Iris::recv.protected_data.l:
case IRQ_UDC:
case 0:
udc.interrupt (state)
Iris::register_interrupt (IRQ_UDC)
break
@@ -586,7 +580,7 @@ Iris::Num start ():
udc.log (Iris::recv.data[0].l)
break
case DIRECTORY:
//kdebug ("dir request\n")
//Iris::debug ("dir request %d\n", Iris::recv.data[0].l)
switch Iris::recv.data[0].l:
case Iris::Directory::GET_NAME:
Iris::Cap name = Iris::my_receiver.create_capability (Iris::Num (NAME, Iris::recv.data[1].l))
@@ -600,8 +594,7 @@ Iris::Num start ():
case Iris::Directory::UNLOCK_RO:
state = Iris::recv.data[0].l
if Iris::recv.data[1].h != 0:
kdebug ("index out of supported range\n")
Iris::panic (0)
Iris::panic (0, "index out of supported range")
udc.send (Iris::recv.data[0].l, Iris::recv.data[1].l, reply, arg)
continue
case Iris::Directory::GET_FILE_RO:
@@ -623,7 +616,7 @@ Iris::Num start ():
continue
break
case FILE:
//kdebug ("file request\n")
//Iris::debug ("file request %d\n", Iris::recv.data[0].l)
switch Iris::recv.data[0].l:
case Iris::Block::GET_BLOCK:
if Iris::recv.data[0].h != PAGE_SIZE << 16:
@@ -639,7 +632,7 @@ Iris::Num start ():
continue
break
case NAME:
//kdebug ("name request\n")
//Iris::debug ("name request %d\n", Iris::recv.data[0].l)
switch Iris::recv.data[0].l:
case Iris::String::GET_SIZE:
reply.invoke (16)