1
0
mirror of git://projects.qi-hardware.com/iris.git synced 2024-11-17 00:37:31 +02:00

Make it work with new gcc version; use linker script to force entry code in page 0.

This commit is contained in:
Bas Wijnen 2015-07-01 01:48:10 -04:00
parent fa021a80f0
commit 2d803d5650
16 changed files with 263 additions and 204 deletions

5
.gitignore vendored
View File

@ -6,17 +6,18 @@ uimage
*.hh *.hh
*.gz *.gz
*.raw *.raw
source/charset.data userspace/data/charset.data
mips/nanonote/sdram-setup.raw mips/nanonote/sdram-setup.raw
nanonote-boot nanonote-boot
.deps/ .deps/
.dirstamp .dirstamp
mips/.dirstamp mips/.dirstamp
source/.dirstamp userspace/.dirstamp
Makefile Makefile
Makefile.in Makefile.in
aclocal.m4 aclocal.m4
autom4te.cache/ autom4te.cache/
compile
config.log config.log
config.status config.status
configure configure

View File

@ -20,12 +20,11 @@ AUTOMAKE_OPTIONS = subdir-objects foreign
# Define some variables. # Define some variables.
OBJDUMP = $(host_alias)-objdump OBJDUMP = $(host_alias)-objdump
OBJCOPY = $(host_alias)-objcopy OBJCOPY = $(host_alias)-objcopy
SERIAL = /dev/ttyUSB0 SERIAL ?= /dev/ttyUSB0
junk = mdebug.abi32 reginfo comment pdr note.gnu.build-id junk = mdebug.abi32 gnu.attributes ctors eh_frame eh_frame_hdr MIPS.abiflags reginfo comment pdr note.gnu.build-id
objcopyflags = -S $(addprefix --remove-section=.,$(junk)) objcopyflags = -S $(addprefix --remove-section=.,$(junk))
start_load = 0x80003000 start_load = 0x80100000
load = 0x80000000
noinst_DATA = iris.raw mips/start.raw mips/start-hack.S mips/board/sdram-setup.raw noinst_DATA = iris.raw mips/start.raw mips/start-hack.S mips/board/sdram-setup.raw
noinst_PROGRAMS = iris.elf mips/start.elf mips/board/sdram-setup.elf noinst_PROGRAMS = iris.elf mips/start.elf mips/board/sdram-setup.elf
@ -46,15 +45,16 @@ endif
endif endif
# Threadlist must be the last file on the line below. # Threadlist must be the last file on the line below.
iris_sources = kernel/panic.cc kernel/data.cc kernel/alloc.cc kernel/memory.cc kernel/invoke.cc kernel/schedule.cc mips/interrupts.cc mips/arch.cc source/boot/threadlist.S iris_sources = kernel/panic.cc kernel/data.cc kernel/alloc.cc kernel/memory.cc kernel/invoke.cc kernel/schedule.cc mips/interrupts.cc mips/arch.cc userspace/boot/threadlist.S
boot_sources = mips/init.cc mips/board/board.cc boot_sources = mips/init.cc mips/board/board.cc
headers = include/kernel.hh include/iris.hh include/devices.hh include/ui.hh include/keys.hh mips/arch.hh mips/board/jz4740.hh mips/board/board.hh mips/nand.hh headers = include/kernel.hh include/iris.hh include/devices.hh include/keys.hh mips/arch.hh mips/board/jz4740.hh mips/board/board.hh mips/nand.hh
iris_elf_CPPFLAGS = -O5 -fno-inline -Iinclude -Imips -Imips/board -Wa,-mips32 -DNANONOTE -DUSE_SERIAL iris_elf_DEPENDENCIES = mips/board/iris.ld
iris_elf_CXXFLAGS = -Wno-unused-parameter -fno-strict-aliasing -fno-builtin -ggdb3 iris_elf_CPPFLAGS = -fno-inline -Iinclude -Imips -Imips/board -mips32 -DNANONOTE -DUSE_SERIAL
iris_elf_LDFLAGS = -Wl,--omagic -Wl,-Ttext -Wl,$(load) -nostdlib iris_elf_CXXFLAGS = -O5 -Wno-unused-parameter -fno-strict-aliasing -fno-builtin -ggdb3 -fno-exceptions -fno-common
iris_elf_LDFLAGS = -Wl,--omagic -nostdlib -T mips/board/iris.ld
iris_elf_SOURCES = mips/entry.S ${iris_sources} mips/boot.S ${boot_sources} ${headers} iris_elf_SOURCES = mips/entry.S ${iris_sources} mips/boot.S ${boot_sources} ${headers}
mips_start_elf_CPPFLAGS = -O5 -fno-inline -Wa,-mips32 -DSTART="0x$(shell /bin/sh -c '$(OBJDUMP) -t iris.elf | grep __start$$ | cut -b1-8')" mips_start_elf_CPPFLAGS = -fno-inline -mips32 -DSTART="0x$(shell /bin/sh -c '$(OBJDUMP) -t iris.elf | grep __start$$ | cut -b1-8')" -DADDR0="0x$(shell /bin/sh -c '$(OBJDUMP) -t iris.elf | grep addr000$$ | cut -b1-8')"
mips_start_elf_LDFLAGS = -Wl,--omagic -Wl,-Ttext -Wl,$(start_load) -nostdlib mips_start_elf_LDFLAGS = -Wl,--omagic -Wl,-Ttext -Wl,$(start_load) -nostdlib
mips_start_elf_SOURCES = mips/start-hack.S iris.raw mips_start_elf_SOURCES = mips/start-hack.S iris.raw
@ -62,34 +62,34 @@ mips/start-hack.S: mips/start.S iris.raw
cp $< $@ cp $< $@
mips_board_sdram_setup_elf_DEPENDENCIES = mips/board/sdram-setup.ld mips_board_sdram_setup_elf_DEPENDENCIES = mips/board/sdram-setup.ld
mips_board_sdram_setup_elf_CPPFLAGS = -O5 -fno-inline -Iinclude -Imips -Imips/board -Wa,-mips32 mips_board_sdram_setup_elf_CPPFLAGS = -fno-inline -Iinclude -Imips -Imips/board -mips32
mips_board_sdram_setup_elf_CXXFLAGS = -Wno-unused-parameter -fno-strict-aliasing -fno-builtin -ggdb3 mips_board_sdram_setup_elf_CXXFLAGS = -O5 -Wno-unused-parameter -fno-strict-aliasing -fno-builtin -ggdb3 -fno-exceptions -fno-common
mips_board_sdram_setup_elf_LDFLAGS = -Wl,--omagic -Wl,-T -Wl,mips/board/sdram-setup.ld -nostdlib mips_board_sdram_setup_elf_LDFLAGS = -Wl,--omagic -Wl,-T -Wl,mips/board/sdram-setup.ld -nostdlib
mips_board_sdram_setup_elf_SOURCES = mips/board/sdram-setup.cc mips_board_sdram_setup_elf_SOURCES = mips/board/sdram-setup.cc
program_targets = \ program_targets = \
source/bootinit.elf \ userspace/bootinit.elf \
source/init.elf \ userspace/init.elf \
source/boot.elf \ userspace/boot.elf \
source/gpio.elf \ userspace/gpio.elf \
source/lcd.elf \ userspace/lcd.elf \
source/nand.elf \ userspace/nand.elf \
source/rtc.elf \ userspace/rtc.elf \
source/sdmmc.elf \ userspace/sdmmc.elf \
source/udc.elf \ userspace/udc.elf \
source/elfrun.elf \ userspace/elfrun.elf \
source/fat.elf \ userspace/fat.elf \
source/font.elf \ userspace/font.elf \
source/gui.elf \ userspace/gui.elf \
source/partition.elf \ userspace/partition.elf \
source/usbmassstorage.elf \ userspace/usbmassstorage.elf \
source/alarm.elf \ userspace/alarm.elf \
source/ball.elf \ userspace/ball.elf \
source/booter.elf \ userspace/booter.elf \
source/bsquare.elf \ userspace/bsquare.elf \
source/buzzer.elf \ userspace/buzzer.elf \
source/metronome.elf \ userspace/metronome.elf \
source/test.elf userspace/test.elf
fs_targets = \ fs_targets = \
fs/alarm.elf \ fs/alarm.elf \
@ -117,13 +117,13 @@ fs_targets = \
noinst_PROGRAMS += $(program_targets) noinst_PROGRAMS += $(program_targets)
noinst_DATA += $(fs_targets) noinst_DATA += $(fs_targets)
AM_CPPFLAGS = -O5 -fno-inline -Iinclude -Imips -Imips/board -Wa,-mips32 -DNANONOTE AM_CPPFLAGS = -fno-inline -Iinclude -Imips -Imips/board -mips32 -DNANONOTE
AM_CXXFLAGS = -Wno-unused-parameter -fno-strict-aliasing -fno-builtin -ggdb3 AM_CXXFLAGS = -O5 -Wno-unused-parameter -fno-strict-aliasing -fno-builtin -ggdb3
AM_LDFLAGS = -nostdlib AM_LDFLAGS = -nostdlib
BUILT_SOURCES = $(headers) source/data/charset.data server BUILT_SOURCES = $(headers) userspace/data/charset.data server
source/boot/threadlist.S: source/boot/mkthreadlist Makefile $(addprefix fs/,$(addsuffix .elf,bootinit $(notdir $(boot_threads)))) userspace/boot/threadlist.S: userspace/boot/mkthreadlist Makefile $(addprefix fs/,$(addsuffix .elf,bootinit $(notdir $(boot_threads))))
$< bootinit $(boot_threads) > $@ $< bootinit $(boot_threads) > $@
PYPP = /usr/bin/pypp PYPP = /usr/bin/pypp
@ -132,43 +132,43 @@ PYPP = /usr/bin/pypp
%.hh: %.hhp %.hh: %.hhp
$(PYPP) --name $< < $< > $@ $(PYPP) --name $< < $< > $@
source/data/charset.data: source/data/charset userspace/data/charset.data: userspace/data/charset
$< > $@ $< > $@
fs/font.dat: source/data/courier-10+8+32.png source/data/makefont fs/font.dat: userspace/data/courier-10+8+32.png userspace/data/makefont
source/data/makefont $< > $@ userspace/data/makefont $< > $@
fs/init.config: source/data/init.config fs/init.config: userspace/data/init.config
ln -s ../$< $@ ln -s ../$< $@
fs/%.elf: source/%.elf fs/%.elf: userspace/%.elf
mkdir -p fs mkdir -p fs
$(OBJCOPY) -S $< $@ $(OBJCOPY) -S $< $@
source_bootinit_elf_SOURCES = source/boot/crt0.cc source/boot/bootinit.cc ${headers} userspace_bootinit_elf_SOURCES = userspace/boot/crt0.cc userspace/boot/bootinit.cc ${headers}
source_init_elf_SOURCES = source/boot/crt0.cc source/boot/init.cc ${headers} userspace_init_elf_SOURCES = userspace/boot/crt0.cc userspace/boot/init.cc ${headers}
source_boot_elf_SOURCES = source/boot/crt0.cc source/hardware/boot.cc ${headers} userspace_boot_elf_SOURCES = userspace/boot/crt0.cc userspace/hardware/boot.cc ${headers}
source_buzzer_elf_SOURCES = source/boot/crt0.cc source/hardware/buzzer.cc ${headers} userspace_buzzer_elf_SOURCES = userspace/boot/crt0.cc userspace/hardware/buzzer.cc ${headers}
source_gpio_elf_SOURCES = source/boot/crt0.cc source/hardware/gpio.cc ${headers} userspace_gpio_elf_SOURCES = userspace/boot/crt0.cc userspace/hardware/gpio.cc ${headers}
source_lcd_elf_SOURCES = source/boot/crt0.cc source/hardware/lcd.cc ${headers} userspace_lcd_elf_SOURCES = userspace/boot/crt0.cc userspace/hardware/lcd.cc ${headers}
source_nand_elf_SOURCES = source/boot/crt0.cc source/hardware/nand.cc ${headers} userspace_nand_elf_SOURCES = userspace/boot/crt0.cc userspace/hardware/nand.cc ${headers}
source_rtc_elf_SOURCES = source/boot/crt0.cc source/hardware/rtc.cc ${headers} userspace_rtc_elf_SOURCES = userspace/boot/crt0.cc userspace/hardware/rtc.cc ${headers}
source_sdmmc_elf_SOURCES = source/boot/crt0.cc source/hardware/sdmmc.cc ${headers} userspace_sdmmc_elf_SOURCES = userspace/boot/crt0.cc userspace/hardware/sdmmc.cc ${headers}
source_udc_elf_SOURCES = source/boot/crt0.cc source/hardware/udc.cc ${headers} userspace_udc_elf_SOURCES = userspace/boot/crt0.cc userspace/hardware/udc.cc ${headers}
#source_buffer_elf_SOURCES = source/boot/crt0.cc source/glue/buffer.cc ${headers} #userspace_buffer_elf_SOURCES = userspace/boot/crt0.cc userspace/glue/buffer.cc ${headers}
source_elfrun_elf_SOURCES = source/boot/crt0.cc source/glue/elfrun.cc ${headers} userspace_elfrun_elf_SOURCES = userspace/boot/crt0.cc userspace/glue/elfrun.cc ${headers}
source_fat_elf_SOURCES = source/boot/crt0.cc source/glue/fat.cc ${headers} userspace_fat_elf_SOURCES = userspace/boot/crt0.cc userspace/glue/fat.cc ${headers}
source_font_elf_SOURCES = source/boot/crt0.cc source/glue/font.cc ${headers} userspace_font_elf_SOURCES = userspace/boot/crt0.cc userspace/glue/font.cc ${headers}
source_gui_elf_SOURCES = source/boot/crt0.cc source/glue/gui.cc ${headers} userspace_gui_elf_SOURCES = userspace/boot/crt0.cc userspace/glue/gui.cc ${headers}
source_partition_elf_SOURCES = source/boot/crt0.cc source/glue/partition.cc ${headers} userspace_partition_elf_SOURCES = userspace/boot/crt0.cc userspace/glue/partition.cc ${headers}
source_usbmassstorage_elf_SOURCES = source/boot/crt0.cc source/glue/usbmassstorage.cc ${headers} userspace_usbmassstorage_elf_SOURCES = userspace/boot/crt0.cc userspace/glue/usbmassstorage.cc ${headers}
source_metronome_elf_SOURCES = source/boot/crt0.cc source/application/metronome.cc ${headers} userspace_metronome_elf_SOURCES = userspace/boot/crt0.cc userspace/application/metronome.cc ${headers}
source_test_elf_SOURCES = source/boot/crt0.cc source/application/test.cc ${headers} userspace_test_elf_SOURCES = userspace/boot/crt0.cc userspace/application/test.cc ${headers}
source_alarm_elf_SOURCES = source/boot/crt0.cc source/application/alarm.cc ${headers} userspace_alarm_elf_SOURCES = userspace/boot/crt0.cc userspace/application/alarm.cc ${headers}
source_ball_elf_SOURCES = source/boot/crt0.cc source/application/ball.cc ${headers} userspace_ball_elf_SOURCES = userspace/boot/crt0.cc userspace/application/ball.cc ${headers}
source_booter_elf_SOURCES = source/boot/crt0.cc source/application/booter.cc ${headers} userspace_booter_elf_SOURCES = userspace/boot/crt0.cc userspace/application/booter.cc ${headers}
source_bsquare_elf_SOURCES = source/boot/crt0.cc source/application/bsquare.cc ${headers} userspace_bsquare_elf_SOURCES = userspace/boot/crt0.cc userspace/application/bsquare.cc ${headers}
server: server:
test -e native/Makefile || native/autogen.sh test -e native/Makefile || native/autogen.sh
@ -189,28 +189,28 @@ iris.tar.gz: mips/start.raw.gz mips/start.elf $(fs_targets) fs/init.config fs/fo
gzip < $< > $@ gzip < $< > $@
sources = \ sources = \
source/alarm.cc \ userspace/boot/bootinit.cc \
source/ball.cc \ userspace/boot/init.cc \
source/boot.cc \ userspace/hardware/boot.cc \
source/booter.cc \ userspace/hardware/buzzer.cc \
source/bootinit.cc \ userspace/hardware/gpio.cc \
source/bsquare.cc \ userspace/hardware/lcd.cc \
source/buzzer.cc \ userspace/hardware/nand.cc \
source/elfrun.cc \ userspace/hardware/rtc.cc \
source/fat.cc \ userspace/hardware/sdmmc.cc \
source/font.cc \ userspace/hardware/udc.cc \
source/gpio.cc \ userspace/glue/elfrun.cc \
source/gui.cc \ userspace/glue/fat.cc \
source/init.cc \ userspace/glue/font.cc \
source/lcd.cc \ userspace/glue/gui.cc \
source/metronome.cc \ userspace/glue/partition.cc \
source/nand.cc \ userspace/glue/usbmassstorage.cc \
source/partition.cc \ userspace/application/alarm.cc \
source/rtc.cc \ userspace/application/ball.cc \
source/sdmmc.cc \ userspace/application/booter.cc \
source/test.cc \ userspace/application/bsquare.cc \
source/udc.cc \ userspace/application/metronome.cc \
source/usbmassstorage.cc userspace/application/test.cc
debug: debug:
stty -F $(SERIAL) 57600 raw stty -F $(SERIAL) 57600 raw
@ -218,4 +218,4 @@ debug:
autoclean: maintainer-clean autoclean: maintainer-clean
$(MAKE) -C native autoclean $(MAKE) -C native autoclean
rm -rf aclocal.m4 configure depcomp fs install-sh iris.raw iris-sd.tar Makefile.in missing $(iris_sources) $(boot_sources) $(sources) $(headers) mips/start-hack.S mips/start.raw mips/start.raw.gz source/data/charset.data iris.tar.gz rm -rf aclocal.m4 configure depcomp fs install-sh iris.raw iris-sd.tar Makefile.in missing $(iris_sources) $(boot_sources) $(sources) $(headers) mips/start-hack.S mips/start.raw mips/start.raw.gz userspace/data/charset.data iris.tar.gz mips/board/sdram-setup.cc mips/board/sdram-setup.raw mips/board/sdram-setup.elf userspace/boot/crt0.cc

View File

@ -1,5 +1,5 @@
AC_INIT([iris], [0.2], [wijnen@debian.org]) AC_INIT([iris], [0.2], [wijnen@debian.org])
AM_INIT_AUTOMAKE(AC_PACKAGE_NAME, AC_PACKAGE_VERSION) AM_INIT_AUTOMAKE()
AC_PROG_CXX AC_PROG_CXX
AM_PROG_AS AM_PROG_AS

View File

@ -90,39 +90,41 @@ namespace Iris:
NUM_EXCEPTION_CODES NUM_EXCEPTION_CODES
#ifndef NDEBUG #ifndef NDEBUG
static const char *exception_name[NUM_EXCEPTION_CODES] = { static inline const char *exception_name(int code):
"no error", const char *names[] = {
"write denied", "no error",
"unmapped read", "write denied",
"unmapped write", "unmapped read",
"invalid address read", "unmapped write",
"invalid address write", "invalid address read",
"reserved instruction", "invalid address write",
"coprocessor unusable", "reserved instruction",
"overflow", "coprocessor unusable",
"trap", "overflow",
"watchpoint", "trap",
"breakpoint", "watchpoint",
"no page directory", "breakpoint",
"no page table", "no page directory",
"out of memory", "no page table",
"invalid operation" "out of memory",
} "invalid operation"
}
return names[code]
#endif #endif
struct Num: struct Num:
unsigned l, h unsigned l, h
Num (unsigned long long n = 0) : l (n), h (n >> 32): inline Num (unsigned long long n = 0) : l (n), h (n >> 32):
Num (unsigned ll, unsigned hh) : l (ll), h (hh): inline Num (unsigned ll, unsigned hh) : l (ll), h (hh):
unsigned long long value () const: inline unsigned long long value () const:
return ((unsigned long long)h << 32) | l return ((unsigned long long)h << 32) | l
unsigned &low (): inline unsigned &low ():
return l return l
unsigned &high (): inline unsigned &high ():
return h return h
unsigned const &low () const: inline unsigned const &low () const:
return l return l
unsigned const &high () const: inline unsigned const &high () const:
return h return h
struct Cap struct Cap

View File

@ -61,7 +61,7 @@ void kThread::raise (unsigned code, unsigned data):
kdebug_num ((unsigned)old_current) kdebug_num ((unsigned)old_current)
kdebug ('/') kdebug ('/')
if code < Iris::NUM_EXCEPTION_CODES: if code < Iris::NUM_EXCEPTION_CODES:
kdebug (Iris::exception_name[code]) kdebug (Iris::exception_name(code))
else: else:
kdebug ("invalid code:") kdebug ("invalid code:")
kdebug_num (code) kdebug_num (code)

View File

@ -55,7 +55,7 @@ start_hack_for_disassembler:
la $sp, kernel_stack + KERNEL_STACK_SIZE la $sp, kernel_stack + KERNEL_STACK_SIZE
// Clear .bss // Clear .bss
la $a0, _edata la $a0, _bss
la $a1, _end la $a1, _end
1: sw $zero, 0($a0) 1: sw $zero, 0($a0)
bne $a1, $a0, 1b bne $a1, $a0, 1b

View File

@ -17,6 +17,7 @@
#define KERNEL_STACK_SIZE 0x1000 #define KERNEL_STACK_SIZE 0x1000
// The kernel stack. // The kernel stack.
.bss
.lcomm kernel_stack, KERNEL_STACK_SIZE .lcomm kernel_stack, KERNEL_STACK_SIZE
.globl run_idle .globl run_idle
@ -24,24 +25,30 @@
.set noat .set noat
.set noreorder .set noreorder
.text
#define ARCH #define ARCH
#define ASM #define ASM
#define __KERNEL__ #define __KERNEL__
#include "arch.hh" #include "arch.hh"
.org 0x000
addr_000: addr_000:
#if 1 #if 1
// TLB refill // TLB refill
lui $k0, 0x8000 lui $k0, 0x8000
lw $k1, 0x174($k0) // directory lw $k1, 0x174($k0) // directory
mfc0 $k0, $CP0_ENTRY_HI mfc0 $k0, $CP0_ENTRY_HI
// Entry high is address: 12 bit offset in page; 1 bit even/odd; 9 bit which page pair; 10 bit which table.
srl $k0, $k0, 19 srl $k0, $k0, 19
andi $k0, $k0, 0xffc andi $k0, $k0, 0xffc // Bits 30:21 remain: which page table to get from directory.
addu $k0, $k0, $k1 addu $k0, $k0, $k1
lw $k0, 0($k0) lw $k0, 0($k0) // k0 is the page table.
beq $zero, $k0, zero_refill beq $zero, $k0, zero_refill
mfc0 $k1, $CP0_ENTRY_HI mfc0 $k1, $CP0_ENTRY_HI
srl $k1, $k1, 10 srl $k1, $k1, 10
// Bits 20:13 remain: which page pair to get from page table.
// (Only the lower half is used for this; the upper half contains pointers to the kPages.)
andi $k1, $k1, 0x7f8 andi $k1, $k1, 0x7f8
addu $k0, $k0, $k1 addu $k0, $k0, $k1
lw $k1, 0($k0) lw $k1, 0($k0)
@ -66,7 +73,8 @@ zero_refill:
jr $t9 jr $t9
nop nop
#endif #endif
.fill 0x100 - (. - addr_000)
.org 0x100
addr_100: addr_100:
// Cache error // Cache error
move $k1, $ra move $k1, $ra
@ -75,8 +83,8 @@ addr_100:
la $t9, cache_error la $t9, cache_error
jr $t9 jr $t9
nop nop
.fill 0x180 - (. - addr_000) - 3 * 4
.org 0x180 - 3 * 4
directory: // 0x174 directory: // 0x174
.word 0 .word 0
current: // 0x178 current: // 0x178
@ -92,9 +100,8 @@ addr_180:
la $t9, exception la $t9, exception
jr $t9 jr $t9
nop nop
// This is annoying; it must fill it up so addr_200 is right. For some
// reason .fill 0x200 - (. - addr_000) - 2 * 4 doesn't work here. .org 0x200 - 2 * 4
.fill 0x60
.word 0x00000012 // 1f8 EntryLo data for idle page. .word 0x00000012 // 1f8 EntryLo data for idle page.
.word 0x80000000 // 1fc A pointer to the current page. .word 0x80000000 // 1fc A pointer to the current page.
addr_200: addr_200:
@ -105,8 +112,8 @@ addr_200:
la $t9, interrupt la $t9, interrupt
jr $t9 jr $t9
nop nop
.fill 0x280 - (. - addr_000)
.org 0x280
start_idle: // 280 start_idle: // 280
// Wait for the next interrupt, then the first thread will be scheduled. // Wait for the next interrupt, then the first thread will be scheduled.
// It is impractical to try to call schedule, because for that the // It is impractical to try to call schedule, because for that the
@ -221,3 +228,6 @@ save_regs:
la $ra, kernel_exit la $ra, kernel_exit
jr $t9 jr $t9
nop nop
.set at
.set reorder

View File

@ -310,7 +310,16 @@ void init (unsigned mem):
// Say we're handling an exception. Since we're going to enter the idle task, allow access to cp0. // Say we're handling an exception. Since we're going to enter the idle task, allow access to cp0.
// All interrupts enter the CPU through the interrupt controller at IP2, so enable that. // All interrupts enter the CPU through the interrupt controller at IP2, so enable that.
cp0_set (CP0_STATUS, 0x1000ff13) cp0_set (CP0_STATUS, 0x10000413)
for int a = 0; a < 0x300; a += 0x80:
kdebug("addr ")
kdebug_num(a)
kdebug(":")
for int b = 0; b < 0x10; b += 4:
kdebug(" ")
kdebug_num(*(unsigned *)(0x80000000 | (a + b)))
kdebug('\n')
kdebug ("entering idle task\n") kdebug ("entering idle task\n")
// Done; return to user space (the idle task). // Done; return to user space (the idle task).

View File

@ -50,13 +50,13 @@ static kThread *handle_exit ():
current->address_space->arch.asid = asids[0] current->address_space->arch.asid = asids[0]
asids[0] = asids[asids[0]] asids[0] = asids[asids[0]]
else: else:
static unsigned random = 1 static unsigned random
current->address_space->arch.asid = random
// Overwrite used asid, so flush those values from tlb.
flush_tlb (random)
++random ++random
if random >= 64: if random >= 64:
random = 1 random = 1
current->address_space->arch.asid = random
// Overwrite used asid, so flush those values from tlb.
flush_tlb (random)
asids[current->address_space->arch.asid] = (unsigned)current->address_space asids[current->address_space->arch.asid] = (unsigned)current->address_space
cp0_set (CP0_ENTRY_HI, current->address_space->arch.asid) cp0_set (CP0_ENTRY_HI, current->address_space->arch.asid)
directory = current->address_space->arch.directory directory = current->address_space->arch.directory

23
mips/nanonote/iris.ld Normal file
View File

@ -0,0 +1,23 @@
OUTPUT_ARCH(mips)
ENTRY(__start)
MEMORY
{
ram : ORIGIN = 0x80000000 , LENGTH = 32M
}
SECTIONS
{
.text : { "mips/iris_elf-entry.o" (.text*) } > ram
.text : { *(.text*) } > ram
.rodata : { *(.rodata*) *(.note*) } > ram
.sdata : { *(.sdata*) } > ram
.data : { *(.data*) *(.scommon*) *(.reginfo*) } > ram
_gp = ABSOLUTE(.);
.got : { *(.got*) } > ram
_bss = ABSOLUTE(.);
.sbss : { *(.sbss*) } > ram
.bss : { *(.bss*) } > ram
_end = ABSOLUTE(.);
}

View File

@ -49,7 +49,7 @@ base:
addiu $v1, $v1, 32 addiu $v1, $v1, 32
// Set a1 to start address of image. // Set a1 to start address of image.
addiu $a1, $ra, image - base addiu $a1, $ra, image - base + ADDR0 - 0x80000000
// Set a2 to end address of image. // Set a2 to end address of image.
lw $a2, 0($ra) lw $a2, 0($ra)

View File

@ -1,54 +1,73 @@
#pypp 0 #pypp 0
// vim: set filetype=cpp : //
#include <iris.hh> #include <iris.hh>
#include <devices.hh> #include <ui.hh>
enum captypes: enum Ins:
CONTROL = 1 TOTAL_TIME
KBD START
INTERRUPT 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")
Iris::Num start (): Iris::Num start ():
unsigned *screen = (unsigned *)0x40000000 ticking = false;
Iris::RTC rtc = Iris::my_parent.get_capability <Iris::RTC> () Iris::Cap ui_cap = Iris::my_receiver.create_capability (0)
Iris::Display display = Iris::my_parent.get_capability <Iris::Display> () ui.init (ui_cap.copy ());
display.map_fb ((unsigned)screen) Iris::free_cap (ui_cap)
Iris::Font font = Iris::my_parent.get_capability <Iris::Font> () total_time.init ()
font.set_display (display) do_start.init ()
Iris::Keyboard keyboard = Iris::my_parent.get_capability <Iris::Keyboard> () current_time.init ()
Iris::Cap cap = Iris::my_receiver.create_capability (KBD) do_alarm.init ()
keyboard.set_cb (cap.copy ()) ui.add_in (&total_time, TOTAL_TIME);
Iris::free_cap (cap) ui.add_in (&do_start, START);
Iris::Buzzer buzzer = Iris::my_parent.get_capability <Iris::Buzzer> () ui.add_out (&current_time, CURRENT_TIME);
Iris::Event self = Iris::my_receiver.create_capability (CONTROL) ui.add_out (&do_alarm, ALARM);
Iris::my_parent.provide_capability <Iris::Event> (self)
cap = Iris::my_receiver.create_capability (INTERRUPT)
Iris::my_parent.init_done () Iris::my_parent.init_done ()
while true: while true:
Iris::wait () Iris::wait ()
switch Iris::recv.protected_data.l: switch Iris::recv.protected_data.l:
case INTERRUPT: case ~0:
// RTC alarm interrupt. // alarm.
if Iris::recv.data[0].l == ~0: if current_time:
// Not a real interrupt, just an abort notification. current_time = current_time - 1
continue if !current_time:
font.printf ("alarm: RTC alarm interrupt\n") do_alarm ()
break ticking = false
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: else:
// Key press. // TODO: use rtc for scheduling an event.
unsigned time = rtc.get_time () Iris::my_receiver.set_alarm (HZ)
rtc.set_alarm (time + 5, cap) continue
unsigned alarm = rtc.get_alarm () case 0:
unsigned enabled = Iris::recv.data[1].l // ui event.
font.printf ("Debug: %d %d %d\n", time, alarm, enabled) if !ui.event (&event):
break // Exit request.
default: return 0
Iris::panic (Iris::recv.protected_data.l, "invalid request for alarm")

View File

@ -19,9 +19,6 @@
#include "iris.hh" #include "iris.hh"
#include "devices.hh" #include "devices.hh"
// For some unknown reason, gcc needs this to be defined.
unsigned __gxx_personality_v0
struct list: struct list:
list *prev, *next list *prev, *next

View File

@ -34,15 +34,15 @@
driver driver_buzzer = "buzzer.elf" driver driver_buzzer = "buzzer.elf"
receive driver_buzzer / Buzzer = buzzer receive driver_buzzer / Buzzer = buzzer
#program alarm = "alarm.elf" program alarm = "alarm.elf"
#receive alarm / UI = ui receive alarm / UI = ui
#program gui = "gui.elf" program gui = "gui.elf"
#give gui / UI = ui give gui / UI = ui
#give gui / Display = display give gui / Display = display
#give gui / Setting = display_bright give gui / Setting = display_bright
#give gui / Buzzer = buzzer give gui / Buzzer = buzzer
#give gui / Keyboard = keyboard give gui / Keyboard = keyboard
#driver sdmmc = "sd+mmc.elf" #driver sdmmc = "sd+mmc.elf"
#receive sdmmc / WBlock = sdmmc #receive sdmmc / WBlock = sdmmc
@ -62,19 +62,19 @@
#program test = "test.elf" #program test = "test.elf"
#give test / Directory = root #give test / Directory = root
file fontfile = "font.dat" #file fontfile = "font.dat"
program font = "font.elf" #program font = "font.elf"
receive font / Font = font #receive font / Font = font
give font / Block = fontfile #give font / Block = fontfile
#give font / Display = display #give font / Display = display
driver driver_rtc = "rtc.elf" #driver driver_rtc = "rtc.elf"
receive driver_rtc / RTC = rtc #receive driver_rtc / RTC = rtc
driver alarm = "alarm.elf" #driver alarm = "alarm.elf"
give alarm / Keyboard = keyboard #give alarm / Keyboard = keyboard
give alarm / Display = display #give alarm / Display = display
give alarm / Buzzer = buzzer #give alarm / Buzzer = buzzer
give alarm / Font = font #give alarm / Font = font
give alarm / RTC = rtc #give alarm / RTC = rtc
receive alarm / Event = alarm #receive alarm / Event = alarm

View File

@ -104,12 +104,10 @@ Iris::Num start ():
Iris::Font self = Iris::my_receiver.create_capability (0) Iris::Font self = Iris::my_receiver.create_capability (0)
Iris::my_parent.provide_capability <Iris::Font> (self.copy ()) Iris::my_parent.provide_capability <Iris::Font> (self.copy ())
Iris::free_cap (self) Iris::free_cap (self)
//display = Iris::my_parent.get_capability <Iris::Display> ()
Iris::Block font = Iris::my_parent.get_capability <Iris::Block> () Iris::Block font = Iris::my_parent.get_capability <Iris::Block> ()
load_font (font) load_font (font)
Iris::free_cap (font) Iris::free_cap (font)
Iris::my_parent.init_done () Iris::my_parent.init_done ()
//display_caps = display.map_fb (reinterpret_cast <unsigned> (fb))
bool have_display = false bool have_display = false
while true: while true:
Iris::wait () Iris::wait ()

View File

@ -20,7 +20,7 @@
#define ARCH #define ARCH
#include "arch.hh" #include "arch.hh"
__asm__ volatile (".section .rodata\n.globl charset\ncharset:\n.incbin \"source/data/charset.data\"\n.section .text") __asm__ volatile (".section .rodata\n.globl charset\ncharset:\n.incbin \"userspace/data/charset.data\"\n.section .text")
extern unsigned char const charset[127-32][8][6] extern unsigned char const charset[127-32][8][6]
#define assert(x) do { if (!(x)) { kdebug ("assertion failed " #x); while (true) {} } } while (0) #define assert(x) do { if (!(x)) { kdebug ("assertion failed " #x); while (true) {} } } while (0)