mirror of
git://projects.qi-hardware.com/iris.git
synced 2024-11-16 19:55:20 +02:00
Make it work with new gcc version; use linker script to force entry code in page 0.
This commit is contained in:
parent
fa021a80f0
commit
2d803d5650
5
.gitignore
vendored
5
.gitignore
vendored
@ -6,17 +6,18 @@ uimage
|
||||
*.hh
|
||||
*.gz
|
||||
*.raw
|
||||
source/charset.data
|
||||
userspace/data/charset.data
|
||||
mips/nanonote/sdram-setup.raw
|
||||
nanonote-boot
|
||||
.deps/
|
||||
.dirstamp
|
||||
mips/.dirstamp
|
||||
source/.dirstamp
|
||||
userspace/.dirstamp
|
||||
Makefile
|
||||
Makefile.in
|
||||
aclocal.m4
|
||||
autom4te.cache/
|
||||
compile
|
||||
config.log
|
||||
config.status
|
||||
configure
|
||||
|
178
Makefile.am
178
Makefile.am
@ -20,12 +20,11 @@ AUTOMAKE_OPTIONS = subdir-objects foreign
|
||||
# Define some variables.
|
||||
OBJDUMP = $(host_alias)-objdump
|
||||
OBJCOPY = $(host_alias)-objcopy
|
||||
SERIAL = /dev/ttyUSB0
|
||||
junk = mdebug.abi32 reginfo comment pdr note.gnu.build-id
|
||||
SERIAL ?= /dev/ttyUSB0
|
||||
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))
|
||||
|
||||
start_load = 0x80003000
|
||||
load = 0x80000000
|
||||
start_load = 0x80100000
|
||||
|
||||
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
|
||||
@ -46,15 +45,16 @@ endif
|
||||
endif
|
||||
|
||||
# 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
|
||||
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
|
||||
iris_elf_CPPFLAGS = -O5 -fno-inline -Iinclude -Imips -Imips/board -Wa,-mips32 -DNANONOTE -DUSE_SERIAL
|
||||
iris_elf_CXXFLAGS = -Wno-unused-parameter -fno-strict-aliasing -fno-builtin -ggdb3
|
||||
iris_elf_LDFLAGS = -Wl,--omagic -Wl,-Ttext -Wl,$(load) -nostdlib
|
||||
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_DEPENDENCIES = mips/board/iris.ld
|
||||
iris_elf_CPPFLAGS = -fno-inline -Iinclude -Imips -Imips/board -mips32 -DNANONOTE -DUSE_SERIAL
|
||||
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}
|
||||
|
||||
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_SOURCES = mips/start-hack.S iris.raw
|
||||
|
||||
@ -62,34 +62,34 @@ mips/start-hack.S: mips/start.S iris.raw
|
||||
cp $< $@
|
||||
|
||||
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_CXXFLAGS = -Wno-unused-parameter -fno-strict-aliasing -fno-builtin -ggdb3
|
||||
mips_board_sdram_setup_elf_CPPFLAGS = -fno-inline -Iinclude -Imips -Imips/board -mips32
|
||||
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_SOURCES = mips/board/sdram-setup.cc
|
||||
|
||||
program_targets = \
|
||||
source/bootinit.elf \
|
||||
source/init.elf \
|
||||
source/boot.elf \
|
||||
source/gpio.elf \
|
||||
source/lcd.elf \
|
||||
source/nand.elf \
|
||||
source/rtc.elf \
|
||||
source/sdmmc.elf \
|
||||
source/udc.elf \
|
||||
source/elfrun.elf \
|
||||
source/fat.elf \
|
||||
source/font.elf \
|
||||
source/gui.elf \
|
||||
source/partition.elf \
|
||||
source/usbmassstorage.elf \
|
||||
source/alarm.elf \
|
||||
source/ball.elf \
|
||||
source/booter.elf \
|
||||
source/bsquare.elf \
|
||||
source/buzzer.elf \
|
||||
source/metronome.elf \
|
||||
source/test.elf
|
||||
userspace/bootinit.elf \
|
||||
userspace/init.elf \
|
||||
userspace/boot.elf \
|
||||
userspace/gpio.elf \
|
||||
userspace/lcd.elf \
|
||||
userspace/nand.elf \
|
||||
userspace/rtc.elf \
|
||||
userspace/sdmmc.elf \
|
||||
userspace/udc.elf \
|
||||
userspace/elfrun.elf \
|
||||
userspace/fat.elf \
|
||||
userspace/font.elf \
|
||||
userspace/gui.elf \
|
||||
userspace/partition.elf \
|
||||
userspace/usbmassstorage.elf \
|
||||
userspace/alarm.elf \
|
||||
userspace/ball.elf \
|
||||
userspace/booter.elf \
|
||||
userspace/bsquare.elf \
|
||||
userspace/buzzer.elf \
|
||||
userspace/metronome.elf \
|
||||
userspace/test.elf
|
||||
|
||||
fs_targets = \
|
||||
fs/alarm.elf \
|
||||
@ -117,13 +117,13 @@ fs_targets = \
|
||||
|
||||
noinst_PROGRAMS += $(program_targets)
|
||||
noinst_DATA += $(fs_targets)
|
||||
AM_CPPFLAGS = -O5 -fno-inline -Iinclude -Imips -Imips/board -Wa,-mips32 -DNANONOTE
|
||||
AM_CXXFLAGS = -Wno-unused-parameter -fno-strict-aliasing -fno-builtin -ggdb3
|
||||
AM_CPPFLAGS = -fno-inline -Iinclude -Imips -Imips/board -mips32 -DNANONOTE
|
||||
AM_CXXFLAGS = -O5 -Wno-unused-parameter -fno-strict-aliasing -fno-builtin -ggdb3
|
||||
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) > $@
|
||||
|
||||
PYPP = /usr/bin/pypp
|
||||
@ -132,43 +132,43 @@ PYPP = /usr/bin/pypp
|
||||
%.hh: %.hhp
|
||||
$(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
|
||||
source/data/makefont $< > $@
|
||||
fs/init.config: source/data/init.config
|
||||
fs/font.dat: userspace/data/courier-10+8+32.png userspace/data/makefont
|
||||
userspace/data/makefont $< > $@
|
||||
fs/init.config: userspace/data/init.config
|
||||
ln -s ../$< $@
|
||||
|
||||
fs/%.elf: source/%.elf
|
||||
fs/%.elf: userspace/%.elf
|
||||
mkdir -p fs
|
||||
$(OBJCOPY) -S $< $@
|
||||
|
||||
source_bootinit_elf_SOURCES = source/boot/crt0.cc source/boot/bootinit.cc ${headers}
|
||||
source_init_elf_SOURCES = source/boot/crt0.cc source/boot/init.cc ${headers}
|
||||
userspace_bootinit_elf_SOURCES = userspace/boot/crt0.cc userspace/boot/bootinit.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}
|
||||
source_buzzer_elf_SOURCES = source/boot/crt0.cc source/hardware/buzzer.cc ${headers}
|
||||
source_gpio_elf_SOURCES = source/boot/crt0.cc source/hardware/gpio.cc ${headers}
|
||||
source_lcd_elf_SOURCES = source/boot/crt0.cc source/hardware/lcd.cc ${headers}
|
||||
source_nand_elf_SOURCES = source/boot/crt0.cc source/hardware/nand.cc ${headers}
|
||||
source_rtc_elf_SOURCES = source/boot/crt0.cc source/hardware/rtc.cc ${headers}
|
||||
source_sdmmc_elf_SOURCES = source/boot/crt0.cc source/hardware/sdmmc.cc ${headers}
|
||||
source_udc_elf_SOURCES = source/boot/crt0.cc source/hardware/udc.cc ${headers}
|
||||
userspace_boot_elf_SOURCES = userspace/boot/crt0.cc userspace/hardware/boot.cc ${headers}
|
||||
userspace_buzzer_elf_SOURCES = userspace/boot/crt0.cc userspace/hardware/buzzer.cc ${headers}
|
||||
userspace_gpio_elf_SOURCES = userspace/boot/crt0.cc userspace/hardware/gpio.cc ${headers}
|
||||
userspace_lcd_elf_SOURCES = userspace/boot/crt0.cc userspace/hardware/lcd.cc ${headers}
|
||||
userspace_nand_elf_SOURCES = userspace/boot/crt0.cc userspace/hardware/nand.cc ${headers}
|
||||
userspace_rtc_elf_SOURCES = userspace/boot/crt0.cc userspace/hardware/rtc.cc ${headers}
|
||||
userspace_sdmmc_elf_SOURCES = userspace/boot/crt0.cc userspace/hardware/sdmmc.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}
|
||||
source_elfrun_elf_SOURCES = source/boot/crt0.cc source/glue/elfrun.cc ${headers}
|
||||
source_fat_elf_SOURCES = source/boot/crt0.cc source/glue/fat.cc ${headers}
|
||||
source_font_elf_SOURCES = source/boot/crt0.cc source/glue/font.cc ${headers}
|
||||
source_gui_elf_SOURCES = source/boot/crt0.cc source/glue/gui.cc ${headers}
|
||||
source_partition_elf_SOURCES = source/boot/crt0.cc source/glue/partition.cc ${headers}
|
||||
source_usbmassstorage_elf_SOURCES = source/boot/crt0.cc source/glue/usbmassstorage.cc ${headers}
|
||||
#userspace_buffer_elf_SOURCES = userspace/boot/crt0.cc userspace/glue/buffer.cc ${headers}
|
||||
userspace_elfrun_elf_SOURCES = userspace/boot/crt0.cc userspace/glue/elfrun.cc ${headers}
|
||||
userspace_fat_elf_SOURCES = userspace/boot/crt0.cc userspace/glue/fat.cc ${headers}
|
||||
userspace_font_elf_SOURCES = userspace/boot/crt0.cc userspace/glue/font.cc ${headers}
|
||||
userspace_gui_elf_SOURCES = userspace/boot/crt0.cc userspace/glue/gui.cc ${headers}
|
||||
userspace_partition_elf_SOURCES = userspace/boot/crt0.cc userspace/glue/partition.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}
|
||||
source_test_elf_SOURCES = source/boot/crt0.cc source/application/test.cc ${headers}
|
||||
source_alarm_elf_SOURCES = source/boot/crt0.cc source/application/alarm.cc ${headers}
|
||||
source_ball_elf_SOURCES = source/boot/crt0.cc source/application/ball.cc ${headers}
|
||||
source_booter_elf_SOURCES = source/boot/crt0.cc source/application/booter.cc ${headers}
|
||||
source_bsquare_elf_SOURCES = source/boot/crt0.cc source/application/bsquare.cc ${headers}
|
||||
userspace_metronome_elf_SOURCES = userspace/boot/crt0.cc userspace/application/metronome.cc ${headers}
|
||||
userspace_test_elf_SOURCES = userspace/boot/crt0.cc userspace/application/test.cc ${headers}
|
||||
userspace_alarm_elf_SOURCES = userspace/boot/crt0.cc userspace/application/alarm.cc ${headers}
|
||||
userspace_ball_elf_SOURCES = userspace/boot/crt0.cc userspace/application/ball.cc ${headers}
|
||||
userspace_booter_elf_SOURCES = userspace/boot/crt0.cc userspace/application/booter.cc ${headers}
|
||||
userspace_bsquare_elf_SOURCES = userspace/boot/crt0.cc userspace/application/bsquare.cc ${headers}
|
||||
|
||||
server:
|
||||
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 < $< > $@
|
||||
|
||||
sources = \
|
||||
source/alarm.cc \
|
||||
source/ball.cc \
|
||||
source/boot.cc \
|
||||
source/booter.cc \
|
||||
source/bootinit.cc \
|
||||
source/bsquare.cc \
|
||||
source/buzzer.cc \
|
||||
source/elfrun.cc \
|
||||
source/fat.cc \
|
||||
source/font.cc \
|
||||
source/gpio.cc \
|
||||
source/gui.cc \
|
||||
source/init.cc \
|
||||
source/lcd.cc \
|
||||
source/metronome.cc \
|
||||
source/nand.cc \
|
||||
source/partition.cc \
|
||||
source/rtc.cc \
|
||||
source/sdmmc.cc \
|
||||
source/test.cc \
|
||||
source/udc.cc \
|
||||
source/usbmassstorage.cc
|
||||
userspace/boot/bootinit.cc \
|
||||
userspace/boot/init.cc \
|
||||
userspace/hardware/boot.cc \
|
||||
userspace/hardware/buzzer.cc \
|
||||
userspace/hardware/gpio.cc \
|
||||
userspace/hardware/lcd.cc \
|
||||
userspace/hardware/nand.cc \
|
||||
userspace/hardware/rtc.cc \
|
||||
userspace/hardware/sdmmc.cc \
|
||||
userspace/hardware/udc.cc \
|
||||
userspace/glue/elfrun.cc \
|
||||
userspace/glue/fat.cc \
|
||||
userspace/glue/font.cc \
|
||||
userspace/glue/gui.cc \
|
||||
userspace/glue/partition.cc \
|
||||
userspace/glue/usbmassstorage.cc \
|
||||
userspace/application/alarm.cc \
|
||||
userspace/application/ball.cc \
|
||||
userspace/application/booter.cc \
|
||||
userspace/application/bsquare.cc \
|
||||
userspace/application/metronome.cc \
|
||||
userspace/application/test.cc
|
||||
|
||||
debug:
|
||||
stty -F $(SERIAL) 57600 raw
|
||||
@ -218,4 +218,4 @@ debug:
|
||||
|
||||
autoclean: maintainer-clean
|
||||
$(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
|
||||
|
@ -1,5 +1,5 @@
|
||||
AC_INIT([iris], [0.2], [wijnen@debian.org])
|
||||
AM_INIT_AUTOMAKE(AC_PACKAGE_NAME, AC_PACKAGE_VERSION)
|
||||
AM_INIT_AUTOMAKE()
|
||||
AC_PROG_CXX
|
||||
AM_PROG_AS
|
||||
|
||||
|
@ -90,39 +90,41 @@ namespace Iris:
|
||||
NUM_EXCEPTION_CODES
|
||||
|
||||
#ifndef NDEBUG
|
||||
static const char *exception_name[NUM_EXCEPTION_CODES] = {
|
||||
"no error",
|
||||
"write denied",
|
||||
"unmapped read",
|
||||
"unmapped write",
|
||||
"invalid address read",
|
||||
"invalid address write",
|
||||
"reserved instruction",
|
||||
"coprocessor unusable",
|
||||
"overflow",
|
||||
"trap",
|
||||
"watchpoint",
|
||||
"breakpoint",
|
||||
"no page directory",
|
||||
"no page table",
|
||||
"out of memory",
|
||||
"invalid operation"
|
||||
}
|
||||
static inline const char *exception_name(int code):
|
||||
const char *names[] = {
|
||||
"no error",
|
||||
"write denied",
|
||||
"unmapped read",
|
||||
"unmapped write",
|
||||
"invalid address read",
|
||||
"invalid address write",
|
||||
"reserved instruction",
|
||||
"coprocessor unusable",
|
||||
"overflow",
|
||||
"trap",
|
||||
"watchpoint",
|
||||
"breakpoint",
|
||||
"no page directory",
|
||||
"no page table",
|
||||
"out of memory",
|
||||
"invalid operation"
|
||||
}
|
||||
return names[code]
|
||||
#endif
|
||||
|
||||
struct Num:
|
||||
unsigned l, h
|
||||
Num (unsigned long long n = 0) : l (n), h (n >> 32):
|
||||
Num (unsigned ll, unsigned hh) : l (ll), h (hh):
|
||||
unsigned long long value () const:
|
||||
inline Num (unsigned long long n = 0) : l (n), h (n >> 32):
|
||||
inline Num (unsigned ll, unsigned hh) : l (ll), h (hh):
|
||||
inline unsigned long long value () const:
|
||||
return ((unsigned long long)h << 32) | l
|
||||
unsigned &low ():
|
||||
inline unsigned &low ():
|
||||
return l
|
||||
unsigned &high ():
|
||||
inline unsigned &high ():
|
||||
return h
|
||||
unsigned const &low () const:
|
||||
inline unsigned const &low () const:
|
||||
return l
|
||||
unsigned const &high () const:
|
||||
inline unsigned const &high () const:
|
||||
return h
|
||||
|
||||
struct Cap
|
||||
|
@ -61,7 +61,7 @@ void kThread::raise (unsigned code, unsigned data):
|
||||
kdebug_num ((unsigned)old_current)
|
||||
kdebug ('/')
|
||||
if code < Iris::NUM_EXCEPTION_CODES:
|
||||
kdebug (Iris::exception_name[code])
|
||||
kdebug (Iris::exception_name(code))
|
||||
else:
|
||||
kdebug ("invalid code:")
|
||||
kdebug_num (code)
|
||||
|
@ -55,7 +55,7 @@ start_hack_for_disassembler:
|
||||
la $sp, kernel_stack + KERNEL_STACK_SIZE
|
||||
|
||||
// Clear .bss
|
||||
la $a0, _edata
|
||||
la $a0, _bss
|
||||
la $a1, _end
|
||||
1: sw $zero, 0($a0)
|
||||
bne $a1, $a0, 1b
|
||||
|
26
mips/entry.S
26
mips/entry.S
@ -17,6 +17,7 @@
|
||||
|
||||
#define KERNEL_STACK_SIZE 0x1000
|
||||
// The kernel stack.
|
||||
.bss
|
||||
.lcomm kernel_stack, KERNEL_STACK_SIZE
|
||||
|
||||
.globl run_idle
|
||||
@ -24,24 +25,30 @@
|
||||
.set noat
|
||||
.set noreorder
|
||||
|
||||
.text
|
||||
|
||||
#define ARCH
|
||||
#define ASM
|
||||
#define __KERNEL__
|
||||
#include "arch.hh"
|
||||
|
||||
.org 0x000
|
||||
addr_000:
|
||||
#if 1
|
||||
// TLB refill
|
||||
lui $k0, 0x8000
|
||||
lw $k1, 0x174($k0) // directory
|
||||
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
|
||||
andi $k0, $k0, 0xffc
|
||||
andi $k0, $k0, 0xffc // Bits 30:21 remain: which page table to get from directory.
|
||||
addu $k0, $k0, $k1
|
||||
lw $k0, 0($k0)
|
||||
lw $k0, 0($k0) // k0 is the page table.
|
||||
beq $zero, $k0, zero_refill
|
||||
mfc0 $k1, $CP0_ENTRY_HI
|
||||
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
|
||||
addu $k0, $k0, $k1
|
||||
lw $k1, 0($k0)
|
||||
@ -66,7 +73,8 @@ zero_refill:
|
||||
jr $t9
|
||||
nop
|
||||
#endif
|
||||
.fill 0x100 - (. - addr_000)
|
||||
|
||||
.org 0x100
|
||||
addr_100:
|
||||
// Cache error
|
||||
move $k1, $ra
|
||||
@ -75,8 +83,8 @@ addr_100:
|
||||
la $t9, cache_error
|
||||
jr $t9
|
||||
nop
|
||||
.fill 0x180 - (. - addr_000) - 3 * 4
|
||||
|
||||
.org 0x180 - 3 * 4
|
||||
directory: // 0x174
|
||||
.word 0
|
||||
current: // 0x178
|
||||
@ -92,9 +100,8 @@ addr_180:
|
||||
la $t9, exception
|
||||
jr $t9
|
||||
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.
|
||||
.fill 0x60
|
||||
|
||||
.org 0x200 - 2 * 4
|
||||
.word 0x00000012 // 1f8 EntryLo data for idle page.
|
||||
.word 0x80000000 // 1fc A pointer to the current page.
|
||||
addr_200:
|
||||
@ -105,8 +112,8 @@ addr_200:
|
||||
la $t9, interrupt
|
||||
jr $t9
|
||||
nop
|
||||
.fill 0x280 - (. - addr_000)
|
||||
|
||||
.org 0x280
|
||||
start_idle: // 280
|
||||
// Wait for the next interrupt, then the first thread will be scheduled.
|
||||
// It is impractical to try to call schedule, because for that the
|
||||
@ -221,3 +228,6 @@ save_regs:
|
||||
la $ra, kernel_exit
|
||||
jr $t9
|
||||
nop
|
||||
|
||||
.set at
|
||||
.set reorder
|
||||
|
@ -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.
|
||||
// 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")
|
||||
// Done; return to user space (the idle task).
|
||||
|
@ -50,13 +50,13 @@ static kThread *handle_exit ():
|
||||
current->address_space->arch.asid = asids[0]
|
||||
asids[0] = asids[asids[0]]
|
||||
else:
|
||||
static unsigned random = 1
|
||||
current->address_space->arch.asid = random
|
||||
// Overwrite used asid, so flush those values from tlb.
|
||||
flush_tlb (random)
|
||||
static unsigned random
|
||||
++random
|
||||
if random >= 64:
|
||||
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
|
||||
cp0_set (CP0_ENTRY_HI, current->address_space->arch.asid)
|
||||
directory = current->address_space->arch.directory
|
||||
|
23
mips/nanonote/iris.ld
Normal file
23
mips/nanonote/iris.ld
Normal 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(.);
|
||||
}
|
@ -49,7 +49,7 @@ base:
|
||||
addiu $v1, $v1, 32
|
||||
|
||||
// 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.
|
||||
lw $a2, 0($ra)
|
||||
|
@ -1,54 +1,73 @@
|
||||
#pypp 0
|
||||
// vim: set filetype=cpp : //
|
||||
#include <iris.hh>
|
||||
#include <devices.hh>
|
||||
#include <ui.hh>
|
||||
|
||||
enum captypes:
|
||||
CONTROL = 1
|
||||
KBD
|
||||
INTERRUPT
|
||||
enum Ins:
|
||||
TOTAL_TIME
|
||||
START
|
||||
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 ():
|
||||
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)
|
||||
ticking = false;
|
||||
Iris::Cap ui_cap = Iris::my_receiver.create_capability (0)
|
||||
ui.init (ui_cap.copy ());
|
||||
Iris::free_cap (ui_cap)
|
||||
total_time.init ()
|
||||
do_start.init ()
|
||||
current_time.init ()
|
||||
do_alarm.init ()
|
||||
ui.add_in (&total_time, TOTAL_TIME);
|
||||
ui.add_in (&do_start, START);
|
||||
ui.add_out (¤t_time, CURRENT_TIME);
|
||||
ui.add_out (&do_alarm, ALARM);
|
||||
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 ()
|
||||
case ~0:
|
||||
// alarm.
|
||||
if current_time:
|
||||
current_time = current_time - 1
|
||||
if !current_time:
|
||||
do_alarm ()
|
||||
ticking = false
|
||||
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")
|
||||
// TODO: use rtc for scheduling an event.
|
||||
Iris::my_receiver.set_alarm (HZ)
|
||||
continue
|
||||
case 0:
|
||||
// ui event.
|
||||
if !ui.event (&event):
|
||||
// Exit request.
|
||||
return 0
|
||||
|
@ -19,9 +19,6 @@
|
||||
#include "iris.hh"
|
||||
#include "devices.hh"
|
||||
|
||||
// For some unknown reason, gcc needs this to be defined.
|
||||
unsigned __gxx_personality_v0
|
||||
|
||||
struct list:
|
||||
list *prev, *next
|
||||
|
||||
|
@ -34,15 +34,15 @@
|
||||
driver driver_buzzer = "buzzer.elf"
|
||||
receive driver_buzzer / Buzzer = buzzer
|
||||
|
||||
#program alarm = "alarm.elf"
|
||||
#receive alarm / UI = ui
|
||||
program alarm = "alarm.elf"
|
||||
receive alarm / UI = ui
|
||||
|
||||
#program gui = "gui.elf"
|
||||
#give gui / UI = ui
|
||||
#give gui / Display = display
|
||||
#give gui / Setting = display_bright
|
||||
#give gui / Buzzer = buzzer
|
||||
#give gui / Keyboard = keyboard
|
||||
program gui = "gui.elf"
|
||||
give gui / UI = ui
|
||||
give gui / Display = display
|
||||
give gui / Setting = display_bright
|
||||
give gui / Buzzer = buzzer
|
||||
give gui / Keyboard = keyboard
|
||||
|
||||
#driver sdmmc = "sd+mmc.elf"
|
||||
#receive sdmmc / WBlock = sdmmc
|
||||
@ -62,19 +62,19 @@
|
||||
#program test = "test.elf"
|
||||
#give test / Directory = root
|
||||
|
||||
file fontfile = "font.dat"
|
||||
program font = "font.elf"
|
||||
receive font / Font = font
|
||||
give font / Block = fontfile
|
||||
#file fontfile = "font.dat"
|
||||
#program font = "font.elf"
|
||||
#receive font / Font = font
|
||||
#give font / Block = fontfile
|
||||
#give font / Display = display
|
||||
|
||||
driver driver_rtc = "rtc.elf"
|
||||
receive driver_rtc / RTC = rtc
|
||||
#driver driver_rtc = "rtc.elf"
|
||||
#receive driver_rtc / RTC = rtc
|
||||
|
||||
driver alarm = "alarm.elf"
|
||||
give alarm / Keyboard = keyboard
|
||||
give alarm / Display = display
|
||||
give alarm / Buzzer = buzzer
|
||||
give alarm / Font = font
|
||||
give alarm / RTC = rtc
|
||||
receive alarm / Event = alarm
|
||||
#driver alarm = "alarm.elf"
|
||||
#give alarm / Keyboard = keyboard
|
||||
#give alarm / Display = display
|
||||
#give alarm / Buzzer = buzzer
|
||||
#give alarm / Font = font
|
||||
#give alarm / RTC = rtc
|
||||
#receive alarm / Event = alarm
|
||||
|
@ -104,12 +104,10 @@ Iris::Num start ():
|
||||
Iris::Font self = Iris::my_receiver.create_capability (0)
|
||||
Iris::my_parent.provide_capability <Iris::Font> (self.copy ())
|
||||
Iris::free_cap (self)
|
||||
//display = Iris::my_parent.get_capability <Iris::Display> ()
|
||||
Iris::Block font = Iris::my_parent.get_capability <Iris::Block> ()
|
||||
load_font (font)
|
||||
Iris::free_cap (font)
|
||||
Iris::my_parent.init_done ()
|
||||
//display_caps = display.map_fb (reinterpret_cast <unsigned> (fb))
|
||||
bool have_display = false
|
||||
while true:
|
||||
Iris::wait ()
|
||||
|
@ -20,7 +20,7 @@
|
||||
#define ARCH
|
||||
#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]
|
||||
|
||||
#define assert(x) do { if (!(x)) { kdebug ("assertion failed " #x); while (true) {} } } while (0)
|
||||
|
Loading…
Reference in New Issue
Block a user