mirror of
git://projects.qi-hardware.com/iris.git
synced 2025-04-21 12:27:27 +03:00
console
This commit is contained in:
@@ -17,7 +17,7 @@
|
||||
|
||||
load = 0x80000000
|
||||
|
||||
ARCH_CXXFLAGS = -DNUM_THREADS=1
|
||||
ARCH_CXXFLAGS = -DNUM_THREADS=3
|
||||
ARCH_CPPFLAGS = -Imips -Wa,-mips32
|
||||
CROSS = mipsel-linux-gnu-
|
||||
OBJDUMP = $(CROSS)objdump
|
||||
@@ -26,9 +26,8 @@ OBJCOPYFLAGS = $(addprefix --remove-section=.,$(junk))
|
||||
|
||||
arch_kernel_sources = mips/interrupts.cc mips/test.cc mips/arch.cc
|
||||
boot_sources = mips/init.cc
|
||||
BUILT_SOURCES = $(kernel_sources) $(boot_sources)
|
||||
arch_headers = mips/arch.hh mips/jz4730.hh
|
||||
boot_threads = gpio lcd
|
||||
boot_threads = init gpio lcd
|
||||
|
||||
uimage:
|
||||
|
||||
@@ -36,6 +35,10 @@ mips/entry.o: $(boot_threads)
|
||||
mips/init.o: TARGET_FLAGS = -I/usr/include
|
||||
$(boot_threads): TARGET_FLAGS = -I.
|
||||
$(boot_threads): boot-programs/devices.hh
|
||||
lcd: boot-programs/charset.data
|
||||
|
||||
boot-programs/charset.data: boot-programs/charset
|
||||
$< > $@
|
||||
|
||||
# Transform ':' into ';' so vim doesn't think there are errors.
|
||||
uimage: kernel.raw.gz Makefile mips/Makefile.arch
|
||||
@@ -54,4 +57,4 @@ kernel: mips/entry.o $(subst .cc,.o,$(kernel_sources)) mips/boot.o $(subst .cc,.
|
||||
%.gz: %
|
||||
gzip < $< > $@
|
||||
|
||||
ARCH_CLEAN_FILES = uimage kernel kernel.raw kernel.raw.gz $(boot_threads) mips/*.o
|
||||
ARCH_CLEAN_FILES = uimage kernel kernel.raw kernel.raw.gz $(boot_threads) mips/*.o boot-programs/charset.data
|
||||
|
||||
@@ -54,11 +54,7 @@ void Thread_arch_receive (Thread *thread, unsigned protected_data, Capability::C
|
||||
thread->arch.t1 = c->data[1]
|
||||
thread->arch.t2 = c->data[2]
|
||||
thread->arch.t3 = c->data[3]
|
||||
thread->arch.v1 = protected_data
|
||||
thread->arch.v0 = 1
|
||||
|
||||
void Thread_arch_receive_fail (Thread *thread):
|
||||
thread->arch.v0 = 0
|
||||
thread->arch.v0 = protected_data
|
||||
|
||||
unsigned *Thread_arch_info (Thread *thread, unsigned num):
|
||||
switch num:
|
||||
|
||||
10
mips/boot.S
10
mips/boot.S
@@ -38,7 +38,14 @@ start_hack_for_disassembler:
|
||||
|
||||
la $sp, kernel_stack + KERNEL_STACK_SIZE
|
||||
|
||||
// TODO: flush cache and optionally refill it.
|
||||
// Flush cache.
|
||||
lui $v1, 0x8000
|
||||
ori $v0, $v1, 0x8000
|
||||
1:
|
||||
cache 0, 0($v1)
|
||||
cache 1, 0($v1)
|
||||
bne $v1, $v0, 1b
|
||||
addiu $v1, $v1, 32
|
||||
|
||||
// Set kseg0 cachable.
|
||||
li $k0, 0x3
|
||||
@@ -67,3 +74,4 @@ thread_start:
|
||||
.word thread0
|
||||
.word thread1
|
||||
.word thread2
|
||||
.word thread3
|
||||
|
||||
@@ -231,10 +231,14 @@ save_regs:
|
||||
.globl thread0
|
||||
.globl thread1
|
||||
.globl thread2
|
||||
.globl thread3
|
||||
.balign 0x1000
|
||||
thread0:
|
||||
.incbin "lcd"
|
||||
.incbin "init"
|
||||
.balign 0x1000
|
||||
thread1:
|
||||
.incbin "gpio"
|
||||
.incbin "lcd"
|
||||
.balign 0x1000
|
||||
thread2:
|
||||
.incbin "gpio"
|
||||
thread3:
|
||||
|
||||
@@ -141,6 +141,8 @@ static void init_threads ():
|
||||
//bool executable = shdr->sh_flags & SHF_EXEC_INSTR
|
||||
if shdr->sh_type != SHT_NOBITS:
|
||||
unsigned file_offset = shdr->sh_offset >> PAGE_BITS
|
||||
if ((file_offset + shdr->sh_size) >> PAGE_BITS) >= (PAGE_SIZE >> 2):
|
||||
panic (0x87446809, "initial thread too large")
|
||||
for unsigned p = (shdr->sh_addr & PAGE_MASK); p < shdr->sh_addr + shdr->sh_size; p += PAGE_SIZE:
|
||||
unsigned section_offset = (p - (shdr->sh_addr & PAGE_MASK)) >> PAGE_BITS
|
||||
unsigned idx = file_offset + section_offset
|
||||
@@ -238,11 +240,9 @@ void init (unsigned mem):
|
||||
// Set up initial threads.
|
||||
init_threads ()
|
||||
|
||||
// Disable all gpio pins initially.
|
||||
// Disable all gpio interrupts and alternate functions initially.
|
||||
for unsigned i = 0; i < 4; ++i:
|
||||
GPIO_GPIER (i) = 0
|
||||
GPIO_GPDIR (i) = 0
|
||||
GPIO_GPPUR (i) = 0
|
||||
GPIO_GPALR (i) = 0
|
||||
GPIO_GPAUR (i) = 0
|
||||
// Set up the rest of the hardware (copied from Linux).
|
||||
|
||||
@@ -19,6 +19,11 @@
|
||||
#define ARCH
|
||||
#include "../kernel.hh"
|
||||
|
||||
typedef unsigned cacheline[8]
|
||||
void arch_flush_cache ():
|
||||
for cacheline *line = (cacheline *)0x80000000; line < (cacheline *)0x80008000; ++line:
|
||||
__asm__ volatile ("lw $k0, %0; cache 0, 0($k0); cache 1, 0($k0)" :: "m"(line))
|
||||
|
||||
static void handle_exit (Thread *old_current):
|
||||
if !current || (current == &idle):
|
||||
schedule ()
|
||||
@@ -26,6 +31,7 @@ static void handle_exit (Thread *old_current):
|
||||
current = &idle
|
||||
if old_current == current:
|
||||
return
|
||||
arch_flush_cache ()
|
||||
if current != &idle:
|
||||
if (Memory *)asids[current->address_space->arch.asid] != current->address_space:
|
||||
if asids[0]:
|
||||
@@ -146,40 +152,48 @@ Thread *exception ():
|
||||
switch (cause >> 2) & 0x1f:
|
||||
case 0:
|
||||
// Interrupt. This shouldn't happen, since CAUSE[IV] == 1.
|
||||
panic (0x11223344, "Interrupt on exception vector.")
|
||||
panic (0x01223344, "Interrupt on exception vector.")
|
||||
case 1:
|
||||
// TLB modification.
|
||||
panic (0x21223344, "TLB modification.")
|
||||
panic (0x11223344, "TLB modification.")
|
||||
case 2:
|
||||
// TLB load or instruction fetch.
|
||||
unsigned a
|
||||
cp0_get (CP0_EPC, a)
|
||||
dbg_send (a)
|
||||
panic (0x31223344, "TLB load or instruction fetch.")
|
||||
panic (0x21223344, "TLB load or instruction fetch.")
|
||||
case 3:
|
||||
// TLB store.
|
||||
unsigned a
|
||||
cp0_get (CP0_EPC, a)
|
||||
dbg_send (a)
|
||||
panic (0x41223344, "TLB store.")
|
||||
cp0_get (CP0_BAD_V_ADDR, a)
|
||||
dbg_send (a)
|
||||
panic (0x31223344, "TLB store.")
|
||||
case 4:
|
||||
// Address error load or instruction fetch.
|
||||
unsigned a
|
||||
cp0_get (CP0_EPC, a)
|
||||
dbg_send (a)
|
||||
panic (0x51223344, "Address error load or instruction fetch.")
|
||||
cp0_get (CP0_BAD_V_ADDR, a)
|
||||
dbg_send (a)
|
||||
panic (0x41223344, "Address error load or instruction fetch.")
|
||||
case 5:
|
||||
// Address error store.
|
||||
dbg_send (current->arch.v1, 4)
|
||||
unsigned a
|
||||
cp0_get (CP0_EPC, a)
|
||||
dbg_send (*(unsigned *)(a & ~3), 32)
|
||||
dbg_send (a, 32)
|
||||
cp0_get (CP0_BAD_V_ADDR, a)
|
||||
dbg_send (a, 32)
|
||||
panic (0x61223344, "Address error store.")
|
||||
panic (0x51223344, "Address error store.")
|
||||
case 6:
|
||||
// Bus error instruction fetch.
|
||||
panic (0x71223344, "Bus error instruction fetch.")
|
||||
panic (0x61223344, "Bus error instruction fetch.")
|
||||
case 7:
|
||||
// Bus error load or store.
|
||||
panic (0x81223344, "Bus error load or store.")
|
||||
panic (0x71223344, "Bus error load or store.")
|
||||
case 8:
|
||||
// Syscall.
|
||||
current->pc += 4
|
||||
@@ -202,13 +216,13 @@ Thread *exception ():
|
||||
panic (0xc1223344, "Arithmetic overflow.")
|
||||
case 13:
|
||||
// Trap.
|
||||
panic (0xe1223344, "Trap.")
|
||||
panic (0xd1223344, "Trap.")
|
||||
case 15:
|
||||
// Floating point exception.
|
||||
panic (0xf1223344, "Floating point exception.")
|
||||
panic (0xe1223344, "Floating point exception.")
|
||||
case 23:
|
||||
// Reference to WatchHi/WatchLo address.
|
||||
panic (0xf2223344, "Reference to WatchHi/WatchLo address.")
|
||||
panic (0xf1223344, "Reference to WatchHi/WatchLo address.")
|
||||
case 24:
|
||||
// Machine check.
|
||||
panic (0xf3223344, "Machine check.")
|
||||
|
||||
Reference in New Issue
Block a user