1
0
mirror of git://projects.qi-hardware.com/iris.git synced 2024-11-05 12:52:28 +02:00

more working

This commit is contained in:
Bas Wijnen 2010-01-18 06:45:52 +01:00
parent f1c608288f
commit 8e6efaeb36
13 changed files with 131 additions and 29 deletions

View File

@ -377,6 +377,8 @@ void kCapability::invalidate ():
return
if sibling_prev.valid ():
sibling_prev->sibling_next = sibling_next
else if parent.valid ():
parent->children = sibling_next
else if (unsigned)target & ~KERNEL_MASK:
target->capabilities = sibling_next
else:
@ -497,19 +499,19 @@ static void check_receiver (kReceiver *r, kCapRef cap, unsigned line):
dpanic (line, "consistency bug in capabilities")
else:
if cap->protected_data.l != (unsigned)r:
dbg_log ("Buggy: ")
dbg_log ("Buggy: receiver=")
dbg_log_num ((unsigned)r)
dbg_log (" ")
dbg_log ("; caps=")
dbg_log_num ((unsigned)cap.caps)
dbg_log (" ")
dbg_log ("; caps mem=")
dbg_log_num ((unsigned)cap.caps->address_space)
dbg_log (" ")
dbg_log ("; cap=")
dbg_log_num ((unsigned)cap.deref ())
dbg_log (" ")
dbg_log ("; cap target=")
dbg_log_num ((unsigned)cap->target)
dbg_log ("/")
dbg_log ("; protected=")
dbg_log_num (cap->protected_data.l)
dbg_log ("\n")
dbg_log ("!= receiver\n")
dpanic (line, "consistency bug in kernel capabilities")
for kCapRef c = cap->children; c.valid (); c = c->sibling_next:
check_receiver (r, c, line)

View File

@ -53,6 +53,9 @@ void *operator new[] (unsigned size):
//kdebug ("\n")
return ret
void *operator new (unsigned size):
return new char[size]
struct file:
unsigned size
// Only the first 16 characters of the name are used, because that's much easier.
@ -328,9 +331,80 @@ static void kdebug_name (char const *t, file *f):
kdebug_char (f->name[j])
kdebug ("...")
struct Dev:
static Dev *devs
Dev *next
unsigned code, idx
Device dev
static Dev *find (unsigned c, unsigned i):
for Dev *d = devs; d; d = d->next:
if d->code == c && d->idx == i:
return d
return NULL
static void add (unsigned c, unsigned i, Kernel::Cap cap):
while find (c, i):
++i
Dev *d = new Dev ()
d->next = devs
d->code = c
d->idx = i
d->dev = cap
devs = d
static void kdebug_list ():
for Dev *d = devs; d; d = d->next:
kdebug (">")
kdebug_num (d->code)
kdebug (":")
kdebug_num (d->idx)
Dev *Dev::devs
void handle_init ():
while true:
Kernel::wait ()
switch Kernel::recv.data[0].l:
case Parent::PROVIDE_DEVICE:
Dev::add (Kernel::recv.data[1].l, Kernel::recv.data[0].h, Kernel::get_arg ())
kdebug ("added dev ")
kdebug_num (Kernel::recv.data[1].l)
kdebug (":")
kdebug_num (Kernel::recv.data[0].h)
kdebug ("\n")
Kernel::recv.reply.invoke ()
break
case Parent::GET_DEVICE:
Dev *d = Dev::find (Kernel::recv.data[1].l, Kernel::recv.data[0].h)
if d:
kdebug ("given dev ")
kdebug_num (Kernel::recv.data[1].l)
kdebug (":")
kdebug_num (Kernel::recv.data[0].h)
kdebug ("\n")
Kernel::Cap cap = d->dev.create_user (Kernel::my_memory)
d->dev.use (cap)
Kernel::recv.reply.invoke (0, 0, cap.copy ())
Kernel::free_cap (cap)
else:
kdebug ("device not found: ")
kdebug_num (Kernel::recv.data[1].l)
kdebug (":")
kdebug_num (Kernel::recv.data[0].h)
Dev::kdebug_list ()
kdebug ("\n")
Kernel::recv.reply.invoke (~0, ~0)
Kernel::panic (0)
break
case Parent::INIT_DONE:
kdebug ("init done\n")
return
default:
kdebug ("unknown init request\n")
Kernel::panic (0)
Kernel::Num start ():
// Wait for the debugging device to be active, in case there is one.
Kernel::schedule ()
//Dev::devs = NULL
init_alloc ()
top_memory = Kernel::get_top_memory ()
Directory root = receive_devices ()
@ -344,10 +418,11 @@ Kernel::Num start ():
kdebug_name ("loading ", &files[index[i]])
run (&files[index[i]], files[index[i]].name[0] == '#')
kdebug ("running\n")
Kernel::schedule ()
handle_init ()
root.unlock_ro ()
Kernel::free_slot (slot)
Kernel::my_memory.destroy (caps)
while true:
Kernel::wait ()
kdebug ("request!\n")
handle_init ()
//Kernel::wait ()
//kdebug ("request!\n")

View File

@ -141,6 +141,7 @@ struct Parent : public Kernel::Cap:
PROVIDE_DEVICE
GET_MEMORY
PROVIDE_MEMORY
INIT_DONE
EXIT
ID
// Get a device handle.
@ -158,6 +159,9 @@ struct Parent : public Kernel::Cap:
Kernel::Cap provide_memory (unsigned limit):
icall (CAP_MASTER_DIRECT | PROVIDE_MEMORY, limit)
return Kernel::get_arg ()
// Signal the parent that the initialisation phase is over.
void init_done ():
invoke (CAP_MASTER_DIRECT | INIT_DONE)
// Exit the program. The parent does not reply, but kills the process.
void exit (Kernel::Num code):
call (CAP_MASTER_DIRECT | EXIT, code)

View File

@ -602,6 +602,9 @@ static void page_invoke (unsigned cmd, unsigned target, Kernel::Num protected_da
if c->data[0].h & Kernel::Page::READONLY || cmd & Kernel::Page::READONLY:
t->flags |= Kernel::Page::READONLY
if !(page->flags & Kernel::Page::FRAME):
dbg_log ("share problem: ")
dbg_log_num (page->flags)
dbg_log ("\n")
dpanic (0, "sharing nothing results in lost page")
kPage_arch_update_mapping (t)
break
@ -718,6 +721,8 @@ static void page_invoke (unsigned cmd, unsigned target, Kernel::Num protected_da
dpanic (0, "invalid page operation")
reply_num (Kernel::ERR_INVALID_OPERATION)
return
if page->flags > 0x7f:
dpanic (page->flags, "weird output from page operation")
reply_num (0)
static void print_cap (kCapRef cap, kCapRef self):

View File

@ -138,6 +138,19 @@ static void tlb_reset (kMemory *mem, unsigned address, unsigned value):
else:
cp0_set (CP0_ENTRY_LO0, value)
__asm__ volatile ("tlbwi")
#if 0
dbg_log ("tlb reset ")
unsigned hi, lo0, lo1
cp0_get (CP0_ENTRY_LO0, lo0)
cp0_get (CP0_ENTRY_LO1, lo1)
cp0_get (CP0_ENTRY_HI, hi)
dbg_log_num (lo0)
dbg_log (":")
dbg_log_num (lo1)
dbg_log (" for ")
dbg_log_num (hi)
dbg_log ("\n")
#endif
static unsigned make_entry_lo (kPage *page):
//dbg_log_line ()

View File

@ -84,13 +84,15 @@ kThread *tlb_refill ():
cp0_set (CP0_ENTRY_LO0, t->entrylo[idx])
cp0_set (CP0_ENTRY_LO1, t->entrylo[idx + 1])
__asm__ volatile ("tlbwr")
//dbg_log ("tlb refill ")
//dbg_log_num (t->entrylo[idx])
//dbg_log (":")
//dbg_log_num (t->entrylo[idx + 1])
//dbg_log (" for ")
//dbg_log_num (EntryHi)
//dbg_log ("\n")
#if 0
dbg_log ("tlb refill ")
dbg_log_num (t->entrylo[idx])
dbg_log (":")
dbg_log_num (t->entrylo[idx + 1])
dbg_log (" for ")
dbg_log_num (EntryHi)
dbg_log ("\n")
#endif
handle_exit ()
return current

View File

@ -29,14 +29,14 @@ arch_iris_sources = mips/interrupts.cc mips/arch.cc
boot_sources = mips/init.cc mips/nanonote/board.cc
arch_headers = mips/arch.hh mips/nanonote/jz4740.hh mips/nanonote/board.hh
boot_threads = init udc
programs = \#nanonote-gpio \#buzzer \#lcd
programs = \#nanonote-gpio \#buzzer \#lcd metronome
all: test
test: iris.raw mips/nanonote/server/usb-server mips/nanonote/sdram-setup.raw $(addsuffix .elf,$(addprefix fs/,$(programs)))
echo "reboot 0xa$(shell /bin/sh -c '$(OBJDUMP) -t iris.elf | grep __start$$ | cut -b2-8')" | nc localhost 5050
mips/nanonote/server/usb-server: mips/nanonote/server/usb-server.ccp mips/nanonote/server/Makefile.am mips/nanonote/server/configure.ac
mips/nanonote/server/usb-server: mips/nanonote/server/usb-server.ccp mips/nanonote/server/Makefile.am mips/nanonote/server/configure.ac devices.hh
$(MAKE) -C mips/nanonote/server
echo "shutdown" | nc localhost 5050
sleep 1
@ -60,7 +60,7 @@ $(addsuffix .elf,$(boot_threads)): TARGET_FLAGS = -I.
$(addsuffix .elf,$(boot_threads)): LDFLAGS = -EL
$(addprefix fs/,$(addsuffix .elf,$(programs))): LDFLAGS = -EL
$(addprefix boot-programs/,$(addsuffix .cc,$(boot_threads))): devices.hh keys.hh
source/lcd.o: source/charset.data
source/\#lcd.o: source/charset.data
source/charset.data: source/charset
$< > $@

View File

@ -51,22 +51,20 @@ static void print_addr (char const *t, unsigned addr):
unsigned de = addr >> 21
unsigned te = (addr >> 12) & ((1 << 9) - 1)
if de < 0x400 && old_current && old_current->address_space->arch.directory && old_current->address_space->arch.directory[de]:
dbg_log ("; page = ")
dbg_log_num ((unsigned)old_current->address_space->arch.directory[de]->page[te])
dbg_log ("; EntryLo = ")
dbg_log_num (old_current->address_space->arch.directory[de]->entrylo[te])
dbg_log ("\n")
else:
dbg_log ("; no directory or page table\n")
dbg_log ("; no directory or page table")
if old_current:
cp0_set (CP0_ENTRY_HI, (addr & (PAGE_MASK << 1)) | old_current->address_space->arch.asid)
__asm__ volatile ("tlbp")
unsigned idx, hi
cp0_get (CP0_INDEX, idx)
dbg_log ("tlb index: ")
dbg_log ("; tlb index: ")
if idx & (1 << 31):
dbg_log ("none")
dbg_log ("none\n")
else:
__asm__ volatile ("tlbr")
dbg_log_num (idx, 2)
dbg_log ("; EntryLo = ")
unsigned lo
@ -80,7 +78,7 @@ static void print_addr (char const *t, unsigned addr):
for int i = -4; i < 4; ++i:
dbg_log (" ")
dbg_log_num (((unsigned *)addr)[i])
dbg_log ("\n")
dbg_log ("\n")
static void panic_message (unsigned n, const char *line, char const *name, char const *message):
unsigned vaddr, epc

View File

@ -53,7 +53,6 @@ enum codes:
BUZZER = 32
Kernel::Num start ():
kdebug ("buzzer started.\n")
map_tcu ()
DevBuzzer buzzer
@ -63,6 +62,7 @@ Kernel::Num start ():
Kernel::free_cap (dev)
unsigned user (~0)
unsigned next_user (0)
Kernel::my_parent.init_done ()
while true:
Kernel::wait ()
switch Kernel::recv.protected_data.h:

View File

@ -278,6 +278,7 @@ Kernel::Num start ():
GPIO_GPIER (GPIO_KBD_ROW_PORT) = (1 << GPIO_TP_LEFT) | (1 << GPIO_TP_RIGHT) | GPIO_KBD_ROW_MASK
Kernel::register_interrupt (IRQ_GPIO0)
Kernel::my_parent.init_done ()
while true:
Kernel::schedule ()
Kernel::wait ()

View File

@ -312,8 +312,8 @@ Kernel::Num start ():
bool is_on = true
unsigned backlight_user = 0
Kernel::Num current_backlight = 0
Kernel::my_parent.init_done ()
while true:
//log_str ("Wachten...\n")
Kernel::wait ()
//log_msg ()
switch Kernel::recv.protected_data.h:

View File

@ -211,6 +211,7 @@ Kernel::Num start ():
unsigned user (~0)
unsigned next_user (0)
Kernel::register_interrupt (IRQ_GPIO3)
Kernel::my_parent.init_done ()
while true:
Kernel::wait ()
switch Kernel::recv.protected_data.h:

View File

@ -29,6 +29,7 @@ Kernel::Num start ():
// Frequency of single pulses in hertz.
unsigned freq = 1000
bool running (false)
Kernel::my_parent.init_done ()
while true:
Kernel::wait ()
switch Kernel::recv.protected_data.l: