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

new directory organization

This commit is contained in:
Bas Wijnen
2013-05-14 18:30:50 -04:00
parent b06e011a07
commit fa021a80f0
62 changed files with 133 additions and 2572 deletions

View File

@@ -0,0 +1,54 @@
#pypp 0
// vim: set filetype=cpp : //
#include <iris.hh>
#include <devices.hh>
enum captypes:
CONTROL = 1
KBD
INTERRUPT
Iris::Num start ():
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 INTERRUPT:
// RTC alarm interrupt.
if Iris::recv.data[0].l == ~0:
// Not a real interrupt, just an abort notification.
continue
font.printf ("alarm: RTC alarm interrupt\n")
break
case CONTROL:
// Store callback
font.printf ("alarm: control event\n")
break
case KBD:
if Iris::recv.data[0].l & Iris::Keyboard::RELEASE:
// Key release.
Iris::poweroff ()
else:
// Key press.
unsigned time = rtc.get_time ()
rtc.set_alarm (time + 5, cap)
unsigned alarm = rtc.get_alarm ()
unsigned enabled = Iris::recv.data[1].l
font.printf ("Debug: %d %d %d\n", time, alarm, enabled)
break
default:
Iris::panic (Iris::recv.protected_data.l, "invalid request for alarm")

View File

@@ -0,0 +1,62 @@
#pypp 0
// Iris: micro-kernel for a capability-based operating system.
// source/ball.ccp: Bouncing ball demo.
// Copyright 2009 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 <iris.hh>
#include <devices.hh>
static unsigned *framebuffer
static int const r = 10
void ball (int x, int y, unsigned colour):
for int ty = y - r; ty < y + r; ++ty:
if ty < 0 || ty >= 240:
continue
for int tx = x - r; tx < x + r; ++tx:
if tx < 0 || tx >= 320:
continue
if (x - tx) * (x - tx) + (y - ty) * (y - ty) > r * r:
continue
framebuffer[ty * 320 + tx] = (colour)
Iris::Num start ():
Iris::my_parent.init_done ()
int colour = 0x3f30ff
framebuffer = (unsigned *)0x15000
Iris::Display display = Iris::my_parent.get_capability <Iris::Display> ()
Iris::Caps fb = display.map_fb ((unsigned)framebuffer)
int x = r, y = r, dx = 3, dy = 0
Iris::Cap eof = Iris::my_receiver.create_capability (0)
while true:
display.set_eof_cb (eof)
Iris::wait ()
ball (x, y, 0)
x += dx
y += dy
if y + r >= 240:
dy = -dy
y = 240 - r
if x - r < 0:
x = r
dx = -dx
if x + r >= 320:
x = 320 - r
dx = -dx
if y == 240 - r && dy == 0:
dy = -21
++dy
ball (x, y, colour)

View File

@@ -0,0 +1,28 @@
#pypp 0
// Iris: micro-kernel for a capability-based operating system.
// source/booter.ccp: Boot into another kernel.
// Copyright 2010 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 <iris.hh>
#include <devices.hh>
Iris::Num start ():
Iris::String data = Iris::my_parent.get_capability <Iris::String> ()
Iris::Boot boot = Iris::my_parent.get_capability <Iris::Boot> ()
//boot.boot (data, 0x81fff000, 0x81fff000)
boot.boot (data, 0xa1fff000, 0xa1fff000)
Iris::panic (0, "boot returns")
return 0

View File

@@ -0,0 +1,60 @@
#pypp 0
// Iris: micro-kernel for a capability-based operating system.
// source/bsquare.ccp: Floating square demo.
// Copyright 2009 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 <iris.hh>
#include <devices.hh>
static unsigned *framebuffer
static int const r = 10
static int colour
void square (int x, int y, bool print):
for int ty = y - r; ty < y + r; ++ty:
if ty < 0 || ty >= 240:
continue
for int tx = x - r; tx < x + r; ++tx:
if tx < 0 || tx >= 320:
continue
framebuffer[ty * 320 + tx] = (print ? colour : 0)
Iris::Num start ():
Iris::my_parent.init_done ()
colour = 0xffff00
framebuffer = (unsigned *)0x15000
Iris::Display display = Iris::my_parent.get_capability <Iris::Display> (0x10001)
int x = r, y = r, dx = 3, dy = 3
Iris::Cap eof = Iris::my_receiver.create_capability (0)
while true:
display.set_eof_cb (eof)
Iris::wait ()
square (x, y, false)
x += dx
y += dy
if y + r >= 240:
dy = -dy
y = 240 - r
if x - r < 0:
x = r
dx = -dx
if x + r >= 320:
x = 320 - r
dx = -dx
if y - r < 0:
y = r
dy = -dy
square (x, y, true)

View File

@@ -0,0 +1,71 @@
#pypp 0
// Iris: micro-kernel for a capability-based operating system.
// boot-programs/metronome.ccp: Userspace program.
// Copyright 2009 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"
#include "keys.hh"
Iris::Num start ():
Iris::my_parent.init_done ()
Iris::Buzzer buzzer = Iris::my_parent.get_capability <Iris::Buzzer> ()
Iris::Keyboard kbd = Iris::my_parent.get_capability <Iris::Keyboard> ()
Iris::Cap key = Iris::my_receiver.create_capability (0)
kbd.set_cb (key)
// Frequency of the pulse train in millihertz.
unsigned mHz = 1000
// Frequency of single pulses in hertz.
unsigned freq = 1000
bool running (false)
while true:
Iris::wait ()
switch Iris::recv.protected_data.l:
case ~0:
if running:
buzzer.beep (freq, 10, ~0)
Iris::my_receiver.set_alarm (HZ * 1000 / mHz)
break
case 0:
if Iris::recv.data[0].l & Iris::Keyboard::RELEASE:
break
switch Iris::recv.data[0].l:
case Key::VOLUME_UP:
freq = freq * 11 / 10
break
case Key::VOLUME_DOWN:
freq = freq * 9 / 10
break
case Key::LEFT:
mHz = mHz * 99 / 100
break
case Key::RIGHT:
mHz = mHz * 101 / 100
break
case Key::UP:
mHz = mHz * 11 / 10
break
case Key::DOWN:
mHz = mHz * 9 / 10
break
case Key::P:
running = !running
if running:
Iris::my_receiver.set_alarm (0)
break
break
default:
kdebug ("metronome: huh?\n")
break

View File

@@ -0,0 +1,58 @@
#pypp 0
// Iris: micro-kernel for a capability-based operating system.
// source/test.ccp: Testing program.
// Copyright 2009 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 <iris.hh>
#include <devices.hh>
bool match (char const *a, char const *b, unsigned l1, unsigned l2):
if l1 != l2:
return false
for unsigned i = 0; i < l1; ++i:
if a[i] != b[i]:
return false
return true
static bool print_name (Iris::String name, unsigned indent):
unsigned l = name.get_size ().l
for unsigned i = 0; i < indent; ++i:
kdebug_char (' ')
char part[16]
for unsigned i = 0; i < l; i += 16:
name.get_chars (i, part)
for unsigned k = 0; k < 16 && i * 16 + k < l; ++k:
kdebug_char (part[k])
kdebug_char ('\n')
return match (part, ".", l, 1) || match (part, "..", l, 2)
static void print_dir (Iris::Directory dir, unsigned indent):
dir.lock_ro ()
Iris::Num files = dir.get_size ()
for Iris::Num i = 0; i.value () < files.value (); i = i.value () + 1:
Iris::String f = dir.get_name (i)
bool ignore = print_name (f, indent)
if !ignore && dir.get_file_info (i, 0).l & 1:
Iris::Directory d = dir.get_file_ro (i)
print_dir (d, indent + 4)
Iris::free_cap (d)
Iris::free_cap (f)
dir.unlock_ro ()
Iris::Num start ():
Iris::Directory dir = Iris::my_parent.get_capability <Iris::Directory> ()
print_dir (dir, 0)
return 0