mirror of
git://projects.qi-hardware.com/iris.git
synced 2025-04-21 12:27:27 +03:00
move dbg_* to panic.ccp
This commit is contained in:
@@ -24,7 +24,7 @@ OBJDUMP = $(CROSS)objdump
|
||||
junk = mdebug.abi32 reginfo comment pdr
|
||||
OBJCOPYFLAGS = $(addprefix --remove-section=.,$(junk))
|
||||
|
||||
arch_kernel_sources = mips/interrupts.cc mips/test.cc mips/arch.cc
|
||||
arch_kernel_sources = mips/interrupts.cc mips/arch.cc
|
||||
boot_sources = mips/init.cc
|
||||
arch_headers = mips/arch.hh mips/jz4730.hh
|
||||
boot_threads = init gpio lcd
|
||||
|
||||
@@ -216,7 +216,7 @@ save_regs:
|
||||
la $sp, kernel_stack + KERNEL_STACK_SIZE
|
||||
|
||||
#ifndef NDEBUG
|
||||
// Allow interrupts to set EPC and friends.
|
||||
// Allow kernel bugs to set EPC and friends.
|
||||
mfc0 $k0, $CP0_STATUS
|
||||
li $k1, 0x1000ff00
|
||||
and $k0, $k0, $k1
|
||||
|
||||
@@ -203,10 +203,9 @@ static void init_threads ():
|
||||
thread->arch.t0 = mkcap (mem, (unsigned)init_receiver, (void *)i)
|
||||
previous->schedule_next = thread
|
||||
thread->schedule_prev = previous
|
||||
previous = thread
|
||||
|
||||
mem->pfree ((unsigned)pages)
|
||||
thread->schedule_next = NULL
|
||||
previous = thread
|
||||
mem->pfree ((unsigned)pages)
|
||||
|
||||
// Initialize the kernel, finish by falling into the idle task.
|
||||
void init (unsigned mem):
|
||||
|
||||
@@ -29,8 +29,12 @@ static void handle_exit (Thread *old_current):
|
||||
schedule ()
|
||||
if !current:
|
||||
current = &idle
|
||||
if (current->flags & (THREAD_FLAG_RUNNING | THREAD_FLAG_WAITING)) != THREAD_FLAG_RUNNING:
|
||||
dbg_send ((unsigned)current >> PAGE_BITS, 3)
|
||||
panic (0x99338844, "non-scheduled thread running")
|
||||
if old_current == current:
|
||||
return
|
||||
dbg_send ((unsigned)current >> PAGE_BITS, 3)
|
||||
arch_flush_cache ()
|
||||
if current != &idle:
|
||||
if (Memory *)asids[current->address_space->arch.asid] != current->address_space:
|
||||
@@ -101,6 +105,7 @@ Thread *interrupt ():
|
||||
c.copy[j] = false
|
||||
dbg_code = (unsigned)arch_interrupt_receiver[i]->owner
|
||||
arch_interrupt_receiver[i]->send_message (i, &c)
|
||||
arch_interrupt_receiver[i] = NULL
|
||||
if ipr & (1 << IRQ_OST0):
|
||||
ost_clear_uf (0)
|
||||
intc_ack_irq (IRQ_OST0)
|
||||
@@ -126,8 +131,10 @@ static void arch_invoke ():
|
||||
target = caller->address_space->find_capability (caller->arch.v0, &wait)
|
||||
do_schedule = false
|
||||
if wait:
|
||||
unschedule ()
|
||||
caller->wait ()
|
||||
if !target:
|
||||
dbg_send (0, 0)
|
||||
// There must be no action here.
|
||||
else:
|
||||
Capability::Context c
|
||||
@@ -140,9 +147,14 @@ static void arch_invoke ():
|
||||
c.data[2] = caller->arch.t2
|
||||
c.data[3] = caller->arch.t3
|
||||
target->invoke (&c)
|
||||
// If the caller received a reply from the kernel, it is no longer set as current. Don't let it lose its timeslice.
|
||||
if caller != current && (caller->flags & (THREAD_FLAG_RUNNING | THREAD_FLAG_WAITING)) == THREAD_FLAG_RUNNING && !do_schedule:
|
||||
current = caller
|
||||
if do_schedule:
|
||||
// If the call was to schedule without wait, it isn't done yet.
|
||||
if !wait:
|
||||
schedule ()
|
||||
else:
|
||||
// If the caller received an immediate reply from the kernel, it is no longer set as current. Don't let it lose its timeslice.
|
||||
if caller != current && (caller->flags & (THREAD_FLAG_RUNNING | THREAD_FLAG_WAITING)) == THREAD_FLAG_RUNNING:
|
||||
current = caller
|
||||
|
||||
/// A general exception has occurred.
|
||||
Thread *exception ():
|
||||
@@ -202,8 +214,18 @@ Thread *exception ():
|
||||
case 9:
|
||||
// Breakpoint.
|
||||
//panic (0x91223344, "Breakpoint.")
|
||||
dbg_send (current->arch.a0, current->arch.a1)
|
||||
current->pc += 4
|
||||
if current->arch.a0:
|
||||
if dbg_cap:
|
||||
panic (0x34259380, "Break instruction while log capability was already set")
|
||||
bool dummy
|
||||
dbg_cap = current->address_space->find_capability (current->arch.a1, &dummy)
|
||||
if !dbg_cap:
|
||||
panic (0x06111129, "no log capability provided")
|
||||
break
|
||||
if dbg_cap:
|
||||
dbg_log_char (current->arch.a1)
|
||||
break
|
||||
break
|
||||
case 10:
|
||||
// Reserved instruction.
|
||||
|
||||
116
mips/test.ccp
116
mips/test.ccp
@@ -1,116 +0,0 @@
|
||||
#pypp 0
|
||||
// Iris: micro-kernel for a capability-based operating system.
|
||||
// mips/test.ccp: Telling the user things with LEDs.
|
||||
// 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 "../kernel.hh"
|
||||
|
||||
#define REG32(addr) *((volatile unsigned int *)(addr))
|
||||
|
||||
#define GPIO_BASE 0xB0010000
|
||||
|
||||
#define __gpio_port_data(p) ( REG_GPIO_GPDR(p) )
|
||||
|
||||
#define GPIO_GPSLR(n) (GPIO_BASE + (0x10 + (n)*0x30))
|
||||
#define GPIO_GPSUR(n) (GPIO_BASE + (0x14 + (n)*0x30))
|
||||
#define GPIO_GPFLR(n) (GPIO_BASE + (0x18 + (n)*0x30))
|
||||
#define GPIO_GPFUR(n) (GPIO_BASE + (0x1c + (n)*0x30))
|
||||
|
||||
#define GPIO_GPDR(n) (GPIO_BASE + (0x00 + (n)*0x30))
|
||||
|
||||
#define REG_GPIO_GPSLR(n) REG32(GPIO_GPSLR((n)))
|
||||
#define REG_GPIO_GPSUR(n) REG32(GPIO_GPSUR((n)))
|
||||
#define REG_GPIO_GPFLR(n) REG32(GPIO_GPFLR((n)))
|
||||
#define REG_GPIO_GPFUR(n) REG32(GPIO_GPFUR((n)))
|
||||
|
||||
#define REG_GPIO_GPDR(n) REG32(GPIO_GPDR((n)))
|
||||
|
||||
static void __gpio_port_as_gpiofn (unsigned p, unsigned o, unsigned fn):
|
||||
unsigned int tmp
|
||||
if o < 16:
|
||||
tmp = REG_GPIO_GPSLR(p)
|
||||
tmp &= ~(3 << ((o) << 1))
|
||||
REG_GPIO_GPSLR(p) = tmp
|
||||
tmp = REG_GPIO_GPFLR(p)
|
||||
tmp &= ~(3 << ((o) << 1))
|
||||
tmp |= fn << ((o) << 1)
|
||||
REG_GPIO_GPFLR(p) = tmp
|
||||
else:
|
||||
tmp = REG_GPIO_GPSUR(p)
|
||||
tmp &= ~(3 << (((o) - 16) << 1))
|
||||
REG_GPIO_GPSUR(p) = tmp
|
||||
tmp = REG_GPIO_GPFUR(p)
|
||||
tmp &= ~(3 << (((o) - 16) << 1))
|
||||
tmp |= fn << (((o) - 16) << 1)
|
||||
REG_GPIO_GPFUR(p) = tmp
|
||||
|
||||
static void __gpio_port_as_output (unsigned p, unsigned o):
|
||||
__gpio_port_as_gpiofn (p, o, 1)
|
||||
static void __gpio_port_as_input (unsigned p, unsigned o):
|
||||
__gpio_port_as_gpiofn (p, o, 0)
|
||||
static void __gpio_as_output (unsigned n):
|
||||
__gpio_port_as_output(n / 32, n % 32)
|
||||
static void __gpio_as_input (unsigned n):
|
||||
__gpio_port_as_input(n / 32, n % 32)
|
||||
static void __gpio_set_pin (unsigned n):
|
||||
__gpio_port_data (n / 32) |= (1 << (n % 32))
|
||||
static void __gpio_clear_pin (unsigned n):
|
||||
__gpio_port_data (n / 32) &= ~(1 << (n % 32))
|
||||
|
||||
#define CAPSLOCKLED_IO 27
|
||||
#define NUMLOCKLED_IO 86
|
||||
#define NETWORK_IO 9
|
||||
#define LIGHT 105
|
||||
|
||||
void dbg_led (bool one, bool two, bool three):
|
||||
__gpio_as_output (CAPSLOCKLED_IO)
|
||||
__gpio_as_output (NUMLOCKLED_IO)
|
||||
__gpio_as_output (NETWORK_IO)
|
||||
if one:
|
||||
__gpio_clear_pin (NUMLOCKLED_IO)
|
||||
else:
|
||||
__gpio_set_pin (NUMLOCKLED_IO)
|
||||
if two:
|
||||
__gpio_clear_pin (CAPSLOCKLED_IO)
|
||||
else:
|
||||
__gpio_set_pin (CAPSLOCKLED_IO)
|
||||
if three:
|
||||
__gpio_clear_pin (NETWORK_IO)
|
||||
else:
|
||||
__gpio_set_pin (NETWORK_IO)
|
||||
|
||||
void dbg_sleep (unsigned ms):
|
||||
for unsigned i = 0; i < 2673 * ms; ++i:
|
||||
__gpio_as_output (CAPSLOCKLED_IO)
|
||||
|
||||
void dbg_send (unsigned code, unsigned bits):
|
||||
if bits > 32:
|
||||
bits = 32
|
||||
for int i = bits - 1; i >= 0; --i:
|
||||
bool on = code & (1 << i)
|
||||
dbg_led (false, false, false)
|
||||
dbg_sleep (200)
|
||||
if on:
|
||||
dbg_led (true, false, false)
|
||||
else:
|
||||
dbg_led (false, true, false)
|
||||
dbg_sleep (400)
|
||||
dbg_led (false, false, false)
|
||||
dbg_sleep (200)
|
||||
dbg_led (true, true, false)
|
||||
dbg_sleep (50)
|
||||
dbg_led (false, false, false)
|
||||
dbg_sleep (50)
|
||||
Reference in New Issue
Block a user