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

Make it compile again; fixed poweroff problem

This commit is contained in:
Bas Wijnen 2013-05-12 09:46:11 -04:00
parent 223ed86672
commit b06e011a07
16 changed files with 245 additions and 195 deletions

28
.gitignore vendored
View File

@ -9,18 +9,24 @@ uimage
source/charset.data source/charset.data
mips/nanonote/sdram-setup.raw mips/nanonote/sdram-setup.raw
nanonote-boot nanonote-boot
mips/nanonote/server/.deps/ .deps/
mips/nanonote/server/Makefile .dirstamp
mips/nanonote/server/Makefile.in mips/.dirstamp
mips/nanonote/server/aclocal.m4 source/.dirstamp
mips/nanonote/server/autom4te.cache/ Makefile
mips/nanonote/server/config.log Makefile.in
mips/nanonote/server/config.status aclocal.m4
mips/nanonote/server/configure autom4te.cache/
mips/nanonote/server/depcomp config.log
mips/nanonote/server/install-sh config.status
mips/nanonote/server/missing configure
depcomp
install-sh
missing
mips/nanonote/server/usb-server mips/nanonote/server/usb-server
mips/start-hack.S
threadlist.S
native/usb-server
fs/ fs/
iris-sd.tar iris-sd.tar
unbrick unbrick

View File

@ -24,7 +24,7 @@ SERIAL = /dev/ttyUSB0
junk = mdebug.abi32 reginfo comment pdr note.gnu.build-id junk = mdebug.abi32 reginfo comment pdr note.gnu.build-id
objcopyflags = -S $(addprefix --remove-section=.,$(junk)) objcopyflags = -S $(addprefix --remove-section=.,$(junk))
start_load = 0x80400000 start_load = 0x80003000
load = 0x80000000 load = 0x80000000
noinst_DATA = iris.raw mips/start.raw mips/start-hack.S mips/nanonote/sdram-setup.raw noinst_DATA = iris.raw mips/start.raw mips/start-hack.S mips/nanonote/sdram-setup.raw
@ -38,9 +38,10 @@ if UDC
boot_threads = udc boot_threads = udc
else else
if UNBRICK if UNBRICK
boot_threads = nand sdmmc usbmassstorage boot_threads = sdmmc usbmassstorage
else else
boot_threads = sdmmc partition fat boot_threads = sdmmc partition fat
noinst_DATA += iris.tar.gz
endif endif
endif endif
@ -67,6 +68,30 @@ mips_nanonote_sdram_setup_elf_LDFLAGS = -Wl,--omagic -Wl,-T -Wl,mips/nanonote/sd
mips_nanonote_sdram_setup_elf_SOURCES = mips/nanonote/sdram-setup.cc mips_nanonote_sdram_setup_elf_SOURCES = mips/nanonote/sdram-setup.cc
program_targets = \ program_targets = \
source/alarm.elf \
source/ball.elf \
source/boot.elf \
source/booter.elf \
source/bootinit.elf \
source/bsquare.elf \
source/buzzer.elf \
source/elfrun.elf \
source/fat.elf \
source/font.elf \
source/gpio.elf \
source/gui.elf \
source/init.elf \
source/lcd.elf \
source/metronome.elf \
source/nand.elf \
source/partition.elf \
source/rtc.elf \
source/sdmmc.elf \
source/test.elf \
source/udc.elf \
source/usbmassstorage.elf
fs_targets = \
fs/alarm.elf \ fs/alarm.elf \
fs/ball.elf \ fs/ball.elf \
fs/boot.elf \ fs/boot.elf \
@ -91,6 +116,7 @@ program_targets = \
fs/usbmassstorage.elf fs/usbmassstorage.elf
noinst_PROGRAMS += $(program_targets) noinst_PROGRAMS += $(program_targets)
noinst_DATA += $(fs_targets)
AM_CPPFLAGS = -O5 -fno-inline -I. -I./mips -I./mips/nanonote -Wa,-mips32 -DNANONOTE AM_CPPFLAGS = -O5 -fno-inline -I. -I./mips -I./mips/nanonote -Wa,-mips32 -DNANONOTE
AM_CXXFLAGS = -Wno-unused-parameter -fno-strict-aliasing -fno-builtin -ggdb3 AM_CXXFLAGS = -Wno-unused-parameter -fno-strict-aliasing -fno-builtin -ggdb3
AM_LDFLAGS = -nostdlib AM_LDFLAGS = -nostdlib
@ -113,28 +139,31 @@ fs/font.dat: courier-10+8+32.png makefont
fs/%: % fs/%: %
ln -s ../$< $@ ln -s ../$< $@
fs_alarm_elf_SOURCES = source/crt0.cc source/alarm.cc ${headers} fs/%.elf: source/%.elf
fs_ball_elf_SOURCES = source/crt0.cc source/ball.cc ${headers} $(OBJCOPY) -S $< $@
fs_boot_elf_SOURCES = source/crt0.cc source/boot.cc ${headers}
fs_booter_elf_SOURCES = source/crt0.cc source/booter.cc ${headers} source_alarm_elf_SOURCES = source/crt0.cc source/alarm.cc ${headers}
fs_bootinit_elf_SOURCES = source/crt0.cc source/bootinit.cc ${headers} source_ball_elf_SOURCES = source/crt0.cc source/ball.cc ${headers}
fs_bsquare_elf_SOURCES = source/crt0.cc source/bsquare.cc ${headers} source_boot_elf_SOURCES = source/crt0.cc source/boot.cc ${headers}
fs_buzzer_elf_SOURCES = source/crt0.cc source/buzzer.cc ${headers} source_booter_elf_SOURCES = source/crt0.cc source/booter.cc ${headers}
fs_elfrun_elf_SOURCES = source/crt0.cc source/elfrun.cc ${headers} source_bootinit_elf_SOURCES = source/crt0.cc source/bootinit.cc ${headers}
fs_fat_elf_SOURCES = source/crt0.cc source/fat.cc ${headers} source_bsquare_elf_SOURCES = source/crt0.cc source/bsquare.cc ${headers}
fs_font_elf_SOURCES = source/crt0.cc source/font.cc ${headers} source_buzzer_elf_SOURCES = source/crt0.cc source/buzzer.cc ${headers}
fs_gpio_elf_SOURCES = source/crt0.cc source/gpio.cc ${headers} source_elfrun_elf_SOURCES = source/crt0.cc source/elfrun.cc ${headers}
fs_gui_elf_SOURCES = source/crt0.cc source/gui.cc ${headers} source_fat_elf_SOURCES = source/crt0.cc source/fat.cc ${headers}
fs_init_elf_SOURCES = source/crt0.cc source/init.cc ${headers} source_font_elf_SOURCES = source/crt0.cc source/font.cc ${headers}
fs_lcd_elf_SOURCES = source/crt0.cc source/lcd.cc ${headers} source_gpio_elf_SOURCES = source/crt0.cc source/gpio.cc ${headers}
fs_metronome_elf_SOURCES = source/crt0.cc source/metronome.cc ${headers} source_gui_elf_SOURCES = source/crt0.cc source/gui.cc ${headers}
fs_nand_elf_SOURCES = source/crt0.cc source/nand.cc ${headers} source_init_elf_SOURCES = source/crt0.cc source/init.cc ${headers}
fs_partition_elf_SOURCES = source/crt0.cc source/partition.cc ${headers} source_lcd_elf_SOURCES = source/crt0.cc source/lcd.cc ${headers}
fs_rtc_elf_SOURCES = source/crt0.cc source/rtc.cc ${headers} source_metronome_elf_SOURCES = source/crt0.cc source/metronome.cc ${headers}
fs_sdmmc_elf_SOURCES = source/crt0.cc source/sdmmc.cc ${headers} source_nand_elf_SOURCES = source/crt0.cc source/nand.cc ${headers}
fs_test_elf_SOURCES = source/crt0.cc source/test.cc ${headers} source_partition_elf_SOURCES = source/crt0.cc source/partition.cc ${headers}
fs_udc_elf_SOURCES = source/crt0.cc source/udc.cc ${headers} source_rtc_elf_SOURCES = source/crt0.cc source/rtc.cc ${headers}
fs_usbmassstorage_elf_SOURCES = source/crt0.cc source/usbmassstorage.cc ${headers} source_sdmmc_elf_SOURCES = source/crt0.cc source/sdmmc.cc ${headers}
source_test_elf_SOURCES = source/crt0.cc source/test.cc ${headers}
source_udc_elf_SOURCES = source/crt0.cc source/udc.cc ${headers}
source_usbmassstorage_elf_SOURCES = source/crt0.cc source/usbmassstorage.cc ${headers}
server: server:
test -e native/Makefile || native/autogen.sh test -e native/Makefile || native/autogen.sh
@ -146,6 +175,14 @@ test: mips/start.raw mips/start.elf server mips/nanonote/sdram-setup.raw fs/init
native/usb-server native/usb-server
echo 'reboot $(start_load) 0x$(shell /bin/sh -c '$(OBJDUMP) -t mips/start.elf | grep __start$$ | cut -b1-8') mips/start.raw' | nc localhost 5050 echo 'reboot $(start_load) 0x$(shell /bin/sh -c '$(OBJDUMP) -t mips/start.elf | grep __start$$ | cut -b1-8') mips/start.raw' | nc localhost 5050
# SD boot stuff
iris.tar.gz: mips/start.raw.gz mips/start.elf $(fs_targets) fs/init.config fs/font.dat
test -d fs/boot || mkdir fs/boot
mkimage -A mips -T kernel -a $(start_load) -e $(shell /bin/sh -c '$(OBJDUMP) -t mips/start.elf | grep __start$$ | cut -b1-8') -n Iris -d mips/start.raw.gz fs/boot/uImage | sed -e 's/:/;/g'
cd fs && tar czvf ../$@ --dereference *
%.gz: %
gzip < $< > $@
sources = \ sources = \
source/alarm.cc \ source/alarm.cc \
source/ball.cc \ source/ball.cc \
@ -170,6 +207,10 @@ sources = \
source/udc.cc \ source/udc.cc \
source/usbmassstorage.cc source/usbmassstorage.cc
debug:
stty -F $(SERIAL) 57600 raw
cat $(SERIAL)
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 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

View File

@ -528,7 +528,7 @@ void kPage::check_payment ():
// No kPage is paying for this frame anymore. // No kPage is paying for this frame anymore.
raw_pfree (frame) raw_pfree (frame)
kPage *next kPage *next
for p = share_prev, next = (p ? p->share_prev : NULL); p; p = next, next = p->share_prev: for p = share_prev, next = (p ? p->share_prev : NULL); p; p = next, next = p ? p->share_prev : NULL:
p->frame = NULL p->frame = NULL
p->share_prev = NULL p->share_prev = NULL
p->share_next = NULL p->share_next = NULL

View File

@ -23,7 +23,6 @@ void kThread_arch_init (kThread *thread):
thread->arch.at = 0 thread->arch.at = 0
for unsigned i = 0; i < 2; ++i: for unsigned i = 0; i < 2; ++i:
thread->arch.v[i] = 0 thread->arch.v[i] = 0
thread->arch.k[i] = 0
for unsigned i = 0; i < 4; ++i: for unsigned i = 0; i < 4; ++i:
thread->arch.a[i] = 0 thread->arch.a[i] = 0
for unsigned i = 0; i < 10; ++i: for unsigned i = 0; i < 10; ++i:
@ -99,16 +98,12 @@ unsigned *kThread_arch_info (kThread *thread, unsigned num):
case 25: case 25:
return &thread->arch.t[9] return &thread->arch.t[9]
case 26: case 26:
return &thread->arch.k[0]
case 27:
return &thread->arch.k[1]
case 28:
return &thread->arch.gp return &thread->arch.gp
case 29: case 27:
return &thread->sp return &thread->sp
case 30: case 28:
return &thread->arch.fp return &thread->arch.fp
case 31: case 29:
return &thread->arch.ra return &thread->arch.ra
default: default:
return NULL return NULL

View File

@ -83,7 +83,6 @@
#define SAVE_RA (SAVE_FP + 4) #define SAVE_RA (SAVE_FP + 4)
#define SAVE_HI (SAVE_RA + 4) #define SAVE_HI (SAVE_RA + 4)
#define SAVE_LO (SAVE_HI + 4) #define SAVE_LO (SAVE_HI + 4)
#define SAVE_K (SAVE_LO + 4)
#ifndef ASM #ifndef ASM
@ -91,7 +90,7 @@ void flush_tlb (unsigned asid)
void arch_flush_cache () void arch_flush_cache ()
struct kThread_arch: struct kThread_arch:
unsigned at, v[2], a[4], t[10], s[8], gp, fp, ra, hi, lo, k[2] unsigned at, v[2], a[4], t[10], s[8], gp, fp, ra, hi, lo
// The following is used for page mapping. // The following is used for page mapping.
// Each Memory has a directory with 0x400 page tables. // Each Memory has a directory with 0x400 page tables.

View File

@ -32,81 +32,80 @@
addr_000: addr_000:
#if 0 #if 0
// TLB refill // TLB refill
bne $zero, $k1, slow_refill lui $k0, 0x8000
nop lw $k1, 0x174($k0) // directory
bne $zero, $k0, slow_refill
lw $k1, -0xd94($zero)
mfc0 $k0, $CP0_ENTRY_HI mfc0 $k0, $CP0_ENTRY_HI
srl $k0, $k0, 19 srl $k0, $k0, 19
and $k0, $k0, 0x3fc and $k0, $k0, 0xffc
addu $k0, $k0, $k1 addu $k0, $k0, $k1
beq $zero, $k0, zero_refill beq $zero, $k0, zero_refill
lw $k0, 0($k0) lw $k0, 0($k0)
mfc0 $k1, $CP0_ENTRY_HI mfc0 $k1, $CP0_ENTRY_HI
srl $k1, $k1, 10 srl $k1, $k1, 10
and $k1, $k1, 0x1f8 and $k1, $k1, 0xff8
add $k0, $k0, $k1 add $k0, $k0, $k1
lw $k1, 0($k0) lw $k1, 0($k0)
mtc0 $k1, $CP0_ENTRY_LO0 mtc0 $k1, $CP0_ENTRY_LO0
lw $k1, 4($k0) lw $k1, 4($k0)
mtc0 $k1, $CP0_ENTRY_LO1 mtc0 $k1, $CP0_ENTRY_LO1
1: tlbwr 1: tlbwr
move $zero, $k0 move $k0, $zero
move $zero, $k1 move $k1, $zero
eret eret
zero_refill: zero_refill:
mtc0 $zero, $CP_ENTRY_LO0 mtc0 $zero, $CP0_ENTRY_LO0
b 1b b 1b
mtc0 $zero, $CP_ENTRY_LO1 mtc0 $zero, $CP0_ENTRY_LO1
#else
slow_refill: // Slow refill: use C code (which calls kdebug etc)
move $k1, $zero move $k1, $ra
#endif
sw $ra, -0xd88($zero)
bal save_regs bal save_regs
nop nop
la $t9, tlb_refill la $t9, tlb_refill
jr $t9 jr $t9
nop nop
#endif
.fill 0x100 - (. - addr_000) .fill 0x100 - (. - addr_000)
addr_100: addr_100:
// Cache error // Cache error
sw $ra, -0xd88($zero) move $k1, $ra
bal save_regs bal save_regs
nop nop
la $t9, cache_error la $t9, cache_error
jr $t9 jr $t9
nop nop
.fill 0x180 - (. - addr_000) .fill 0x180 - (. - addr_000) - 3 * 4
directory: // 0x174
.word 0
current: // 0x178
.word idle
// 0x17c
.word _gp
addr_180: addr_180:
// General exception // General exception
sw $ra, -0xd88($zero) move $k1, $ra
bal save_regs bal save_regs
nop nop
la $t9, exception la $t9, exception
jr $t9 jr $t9
nop nop
.fill 0x200 - (. - addr_000) - 8 // This is annoying; it must fill it up so addr_200 is right. For some
.word 0x0000001e // 1f8 EntryLo data for idle page. // reason .fill 0x200 - (. - addr_000) - 2 * 4 doesn't work here.
.fill 0x60
.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:
// Interrupt // Interrupt
sw $ra, -0xd88($zero) move $k1, $ra
bal save_regs bal save_regs
nop nop
la $t9, interrupt la $t9, interrupt
jr $t9 jr $t9
nop nop
.fill 0x280 - (. - addr_000) - 20 .fill 0x280 - (. - addr_000)
directory:
.word 0 // -d94 == directory
// space for save_regs
.word 0 // -d90 == k0
.word idle // -d8c == current
.word 0 // -d88 == ra
.word _gp // -d84 == gp
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.
@ -118,111 +117,106 @@ start_idle: // 280
// TODO: save only fragile registers now, the rest on task switch. // TODO: save only fragile registers now, the rest on task switch.
kernel_exit: kernel_exit:
move $k0, $v0
lui $k1, 0x8000
sw $v0, 0x178($k1) // current
lw $k1, SAVE_PC($k0)
mtc0 $k1, $CP0_EPC
lw $k1, SAVE_LO($k0)
mtlo $k1
lw $k1, SAVE_HI($k0)
mthi $k1
lw $v0, SAVE_V + 0 * 4($k0)
lw $v1, SAVE_V + 1 * 4($k0)
lw $a0, SAVE_A + 0 * 4($k0)
lw $a1, SAVE_A + 1 * 4($k0)
lw $a2, SAVE_A + 2 * 4($k0)
lw $a3, SAVE_A + 3 * 4($k0)
lw $t0, SAVE_T + 0 * 4($k0)
lw $t1, SAVE_T + 1 * 4($k0)
lw $t2, SAVE_T + 2 * 4($k0)
lw $t3, SAVE_T + 3 * 4($k0)
lw $t4, SAVE_T + 4 * 4($k0)
lw $t5, SAVE_T + 5 * 4($k0)
lw $t6, SAVE_T + 6 * 4($k0)
lw $t7, SAVE_T + 7 * 4($k0)
lw $t8, SAVE_T + 8 * 4($k0)
lw $t9, SAVE_T + 9 * 4($k0)
lw $s0, SAVE_S + 0 * 4($k0)
lw $s1, SAVE_S + 1 * 4($k0)
lw $s2, SAVE_S + 2 * 4($k0)
lw $s3, SAVE_S + 3 * 4($k0)
lw $s4, SAVE_S + 4 * 4($k0)
lw $s5, SAVE_S + 5 * 4($k0)
lw $s6, SAVE_S + 6 * 4($k0)
lw $s7, SAVE_S + 7 * 4($k0)
lw $fp, SAVE_FP($k0)
lw $at, SAVE_AT($k0)
lw $sp, SAVE_SP($k0)
lw $gp, SAVE_GP($k0)
lw $ra, SAVE_RA($k0)
#ifndef NDEBUG #ifndef NDEBUG
// Exceptions were enabled in the kernel; set them to usermode setting again. // Exceptions were enabled in the kernel; set them to usermode setting again.
mfc0 $k0, $CP0_STATUS mfc0 $k1, $CP0_STATUS
ori $k0, $k0, 0xff13 ori $k1, $k1, 0xff13
mtc0 $k0, $CP0_STATUS mtc0 $k1, $CP0_STATUS
#endif #endif
sw $v0, -0xd8c($zero) move $k0, $zero
lw $k0, SAVE_PC($v0) move $k1, $zero
mtc0 $k0, $CP0_EPC
lw $k0, SAVE_LO($v0)
lw $k1, SAVE_HI($v0)
mtlo $k0
mthi $k1
lw $v1, SAVE_V + 1 * 4($v0)
lw $a0, SAVE_A + 0 * 4($v0)
lw $a1, SAVE_A + 1 * 4($v0)
lw $a2, SAVE_A + 2 * 4($v0)
lw $a3, SAVE_A + 3 * 4($v0)
lw $t0, SAVE_T + 0 * 4($v0)
lw $t1, SAVE_T + 1 * 4($v0)
lw $t2, SAVE_T + 2 * 4($v0)
lw $t3, SAVE_T + 3 * 4($v0)
lw $t4, SAVE_T + 4 * 4($v0)
lw $t5, SAVE_T + 5 * 4($v0)
lw $t6, SAVE_T + 6 * 4($v0)
lw $t7, SAVE_T + 7 * 4($v0)
lw $t8, SAVE_T + 8 * 4($v0)
lw $t9, SAVE_T + 9 * 4($v0)
lw $s0, SAVE_S + 0 * 4($v0)
lw $s1, SAVE_S + 1 * 4($v0)
lw $s2, SAVE_S + 2 * 4($v0)
lw $s3, SAVE_S + 3 * 4($v0)
lw $s4, SAVE_S + 4 * 4($v0)
lw $s5, SAVE_S + 5 * 4($v0)
lw $s6, SAVE_S + 6 * 4($v0)
lw $s7, SAVE_S + 7 * 4($v0)
lw $fp, SAVE_FP($v0)
lw $ra, SAVE_RA($v0)
lw $at, SAVE_AT($v0)
lw $k0, SAVE_K + 0 * 4($v0)
lw $k1, SAVE_V + 0 * 4($v0)
sw $k1, -0xd90($zero)
lw $k1, SAVE_K + 1 * 4($v0)
lw $sp, SAVE_SP($v0)
lw $gp, SAVE_GP($v0)
lw $v0, -0xd90($zero)
eret eret
save_regs: save_regs:
sw $k0, -0xd90($zero) lui $k0, 0x8000
lw $k0, -0xd8c($zero) lw $k0, 0x178($k0) // current
sw $at, SAVE_AT($k0) sw $k1, SAVE_RA($k0)
sw $gp, SAVE_GP($k0) sw $gp, SAVE_GP($k0)
sw $sp, SAVE_SP($k0) sw $sp, SAVE_SP($k0)
sw $at, SAVE_AT($k0)
sw $fp, SAVE_FP($k0) sw $fp, SAVE_FP($k0)
sw $k1, SAVE_K + 4($k0)
lw $k1, -0xd90($zero)
sw $k1, SAVE_K + 0($k0)
lw $k1, -0xd88($zero)
sw $k1, SAVE_RA($k0)
sw $v0, SAVE_V + 0 * 4($k0)
sw $v1, SAVE_V + 1 * 4($k0)
sw $a0, SAVE_A + 0 * 4($k0)
sw $a1, SAVE_A + 1 * 4($k0)
sw $a2, SAVE_A + 2 * 4($k0)
sw $a3, SAVE_A + 3 * 4($k0)
sw $t0, SAVE_T + 0 * 4($k0)
sw $t1, SAVE_T + 1 * 4($k0)
sw $t2, SAVE_T + 2 * 4($k0)
sw $t3, SAVE_T + 3 * 4($k0)
sw $t4, SAVE_T + 4 * 4($k0)
sw $t5, SAVE_T + 5 * 4($k0)
sw $t6, SAVE_T + 6 * 4($k0)
sw $t7, SAVE_T + 7 * 4($k0)
sw $t8, SAVE_T + 8 * 4($k0)
sw $t9, SAVE_T + 9 * 4($k0)
sw $s0, SAVE_S + 0 * 4($k0)
sw $s1, SAVE_S + 1 * 4($k0)
sw $s2, SAVE_S + 2 * 4($k0)
sw $s3, SAVE_S + 3 * 4($k0)
sw $s4, SAVE_S + 4 * 4($k0)
sw $s5, SAVE_S + 5 * 4($k0)
sw $s6, SAVE_S + 6 * 4($k0)
sw $s7, SAVE_S + 7 * 4($k0) sw $s7, SAVE_S + 7 * 4($k0)
mfhi $v0 sw $s6, SAVE_S + 6 * 4($k0)
mflo $v1 sw $s5, SAVE_S + 5 * 4($k0)
sw $v0, SAVE_HI($k0) sw $s4, SAVE_S + 4 * 4($k0)
sw $v1, SAVE_LO($k0) sw $s3, SAVE_S + 3 * 4($k0)
sw $s2, SAVE_S + 2 * 4($k0)
sw $s1, SAVE_S + 1 * 4($k0)
sw $s0, SAVE_S + 0 * 4($k0)
sw $t9, SAVE_T + 9 * 4($k0)
sw $t8, SAVE_T + 8 * 4($k0)
sw $t7, SAVE_T + 7 * 4($k0)
sw $t6, SAVE_T + 6 * 4($k0)
sw $t5, SAVE_T + 5 * 4($k0)
sw $t4, SAVE_T + 4 * 4($k0)
sw $t3, SAVE_T + 3 * 4($k0)
sw $t2, SAVE_T + 2 * 4($k0)
sw $t1, SAVE_T + 1 * 4($k0)
sw $t0, SAVE_T + 0 * 4($k0)
sw $a3, SAVE_A + 3 * 4($k0)
sw $a2, SAVE_A + 2 * 4($k0)
sw $a1, SAVE_A + 1 * 4($k0)
sw $a0, SAVE_A + 0 * 4($k0)
sw $v1, SAVE_V + 1 * 4($k0)
sw $v0, SAVE_V + 0 * 4($k0)
mfhi $k1
sw $k1, SAVE_HI($k0)
mflo $k1
sw $k1, SAVE_LO($k0)
mfc0 $k1, $CP0_EPC mfc0 $k1, $CP0_EPC
sw $k1, SAVE_PC($k0) sw $k1, SAVE_PC($k0)
lw $gp, -0xd84($zero)
la $sp, kernel_stack + KERNEL_STACK_SIZE
#ifndef NDEBUG #ifndef NDEBUG
// Allow kernel bugs to set EPC and friends. // Allow kernel bugs to set EPC and friends.
mfc0 $k0, $CP0_STATUS mfc0 $k0, $CP0_STATUS
li $k1, 0x10000000 lui $k1, 0x1000
and $k0, $k0, $k1 and $k0, $k0, $k1
mtc0 $k0, $CP0_STATUS mtc0 $k0, $CP0_STATUS
#endif #endif
lui $k0, 0x8000
lw $gp, 0x17c($k0)
la $sp, kernel_stack + KERNEL_STACK_SIZE
move $t9, $ra move $t9, $ra
la $ra, kernel_exit la $ra, kernel_exit
jr $t9 jr $t9

View File

@ -1,4 +1,5 @@
#pypp 0 #pypp 0
// vim: set filetype=cpp : //
// Iris: micro-kernel for a capability-based operating system. // Iris: micro-kernel for a capability-based operating system.
// mips/init.ccp: mips-specific boot code. // mips/init.ccp: mips-specific boot code.
// Copyright 2009 Bas Wijnen <wijnen@debian.org> // Copyright 2009 Bas Wijnen <wijnen@debian.org>
@ -73,40 +74,33 @@ static void init_cp0 ():
// Use non-vectored interrupts. // Use non-vectored interrupts.
cp0_set0 (CP0_INT_CTL) cp0_set0 (CP0_INT_CTL)
// clear the tlb, hardwire page 0 to 0xffffffff
// and soft-wire it to (0x294 << 20) + (0x290 << 10)
// (for the idle task).
cp0_set (CP0_WIRED, 1)
cp0_set0 (CP0_PAGE_MASK)
cp0_set0 (CP0_ENTRY_LO0)
cp0_set0 (CP0_ENTRY_LO1)
// Get number of tlb entries (is 31). // Get number of tlb entries (is 31).
unsigned num unsigned num
cp0_get (CP0_CONFIG1, num) cp0_get (CP0_CONFIG1, num)
num >>= 25 num >>= 25
num &= 0x3f num &= 0x3f
// Clear the tlb. // Clear the tlb.
for unsigned i = 1; i <= num; ++i: cp0_set (CP0_WIRED, 0)
cp0_set0 (CP0_PAGE_MASK)
cp0_set0 (CP0_ENTRY_LO0)
cp0_set0 (CP0_ENTRY_LO1)
for unsigned i = 0; i <= num; ++i:
// with asid 0, no page faults will be triggered, so it's safe to map memory anywhere. // with asid 0, no page faults will be triggered, so it's safe to map memory anywhere.
cp0_set (CP0_ENTRY_HI, 0x2000 * i) // And it's set to invalid anyway.
cp0_set (CP0_ENTRY_HI, 0x2000 * (i + 1))
cp0_set (CP0_INDEX, i) cp0_set (CP0_INDEX, i)
// write the data. // write the data.
__asm__ volatile ("tlbwi") __asm__ volatile ("tlbwi")
// Fill the upper page in kseg3.
cp0_set (CP0_ENTRY_HI, 0xffffe000)
cp0_set (CP0_ENTRY_LO0, 0x1d)
cp0_set (CP0_ENTRY_LO1, 0x1f)
cp0_set0 (CP0_INDEX)
__asm__ volatile ("tlbwi")
// Fill the idle task's page in useg. Set it to non-cachable. // Fill the idle task's page in useg. Set it to non-cachable.
// its directory entry is at 1fc, so it's number 7f (0fe00000). // its directory entry is at 1fc, so it's number 7f (0fe00000).
// its table entry is at 1f8, so it's number 7e (0007e000). // its table entry is at 1f8, so it's number 7e (0007e000).
// its address is 280 (00000280), used below for EPC. // its address is 280 (00000280), used below for EPC.
unsigned const idle_entry_hi = 0x0fe7e000 unsigned const idle_entry_hi = 0x0fe7e000
cp0_set (CP0_ENTRY_HI, idle_entry_hi) cp0_set (CP0_ENTRY_HI, idle_entry_hi)
cp0_set (CP0_ENTRY_LO0, 0x16) cp0_set (CP0_ENTRY_LO0, 0x00000012)
cp0_set (CP0_ENTRY_LO1, 0x14) // The following value doesn't make much sense, but it is what is
// filled in at run-time. So for robustness it's used here as well.
cp0_set (CP0_ENTRY_LO1, 0x80000000)
__asm__ volatile ("tlbwr") __asm__ volatile ("tlbwr")
// Allow eret to be used to jump to the idle task. // Allow eret to be used to jump to the idle task.
cp0_set (CP0_EPC, (idle_entry_hi & PAGE_MASK) | 0x280) cp0_set (CP0_EPC, (idle_entry_hi & PAGE_MASK) | 0x280)
@ -318,5 +312,6 @@ void init (unsigned mem):
// 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, 0x1000ff13)
kdebug ("entering idle task\n")
// Done; return to user space (the idle task). // Done; return to user space (the idle task).
__asm__ volatile ("eret") __asm__ volatile ("eret")

View File

@ -1,4 +1,5 @@
#pypp 0 #pypp 0
// vim: set filetype=cpp : //
// Iris: micro-kernel for a capability-based operating system. // Iris: micro-kernel for a capability-based operating system.
// mips/interrupts.ccp: Functions called by mips/entry.S. // mips/interrupts.ccp: Functions called by mips/entry.S.
// Copyright 2009 Bas Wijnen <wijnen@debian.org> // Copyright 2009 Bas Wijnen <wijnen@debian.org>
@ -72,6 +73,7 @@ static kThread *handle_exit ():
/// Otherwise, the ultra-fast code in entry.S is used. /// Otherwise, the ultra-fast code in entry.S is used.
kThread *tlb_refill (): kThread *tlb_refill ():
++dbg_code.h ++dbg_code.h
kdebug_num ((unsigned)directory)
old_current = current old_current = current
if !directory: if !directory:
unsigned addr unsigned addr
@ -80,6 +82,9 @@ kThread *tlb_refill ():
return handle_exit () return handle_exit ()
unsigned EntryHi unsigned EntryHi
cp0_get (CP0_ENTRY_HI, EntryHi) cp0_get (CP0_ENTRY_HI, EntryHi)
kdebug (" tlb ")
kdebug_num (EntryHi)
kdebug ("\n")
Table *t = directory[EntryHi >> 21] Table *t = directory[EntryHi >> 21]
if !t: if !t:
unsigned addr unsigned addr

View File

@ -1,4 +1,5 @@
#pypp 0 #pypp 0
// vim: set filetype=cpp ://
// Iris: micro-kernel for a capability-based operating system. // Iris: micro-kernel for a capability-based operating system.
// mips/nanonote/board.ccp: nanonote-specific definitions. // mips/nanonote/board.ccp: nanonote-specific definitions.
// Copyright 2009 Bas Wijnen <wijnen@debian.org> // Copyright 2009 Bas Wijnen <wijnen@debian.org>
@ -22,7 +23,7 @@
void board_init (): void board_init ():
pll_init () pll_init ()
cpm_stop_all () cpm_start_all ()
// Timer interrupts and buzzer. // Timer interrupts and buzzer.
cpm_start_tcu () cpm_start_tcu ()
// sdram memory. // sdram memory.
@ -38,7 +39,7 @@ void board_init ():
// buzzer. // buzzer.
gpio_as_pwm4 () gpio_as_pwm4 ()
// Set up memory. // Set up memory.
//setup_sdram () setup_sdram ()
// Use some gpio pins for lcd. // Use some gpio pins for lcd.
gpio_as_gpio (2, (1 << 21) | (1 << 22) | (1 << 23)) gpio_as_gpio (2, (1 << 21) | (1 << 22) | (1 << 23))
gpio_as_output (2, (1 << 21) | (1 << 22) | (1 << 23)) gpio_as_output (2, (1 << 21) | (1 << 22) | (1 << 23))
@ -52,6 +53,7 @@ void board_init ():
// Set up keyboard: this breaks uart receive. // Set up keyboard: this breaks uart receive.
gpio_as_gpio (3, 0x05fc0000) gpio_as_gpio (3, 0x05fc0000)
// Set up timed interrupts. // Set up timed interrupts.
tcu_start_timer_clock (0)
tcu_stop_counter (0) tcu_stop_counter (0)
tcu_select_extalclk (0) tcu_select_extalclk (0)
tcu_select_clk_div4 (0) tcu_select_clk_div4 (0)
@ -104,6 +106,8 @@ void arch_poweroff ():
while !rtc_write_ready (): while !rtc_write_ready ():
rtc_enabled () rtc_enabled ()
while !rtc_write_ready (): while !rtc_write_ready ():
rtc_set_hrcr_val (0x7f)
while !rtc_write_ready ():
kdebug ("Power down.\n") kdebug ("Power down.\n")
sync_serial () sync_serial ()
rtc_power_down () rtc_power_down ()

View File

@ -16,7 +16,7 @@
// along with this program. If not, see <http://www.gnu.org/licenses/>. // along with this program. If not, see <http://www.gnu.org/licenses/>.
// This program is a wrapper around the kernel. // This program is a wrapper around the kernel.
// It is linked for loading at 0x80600000; however, it it position-independant and may be loaded anywhere. // It is position-independant and may be loaded anywhere.
// It does not use gp. This means that li and la must not be used. // It does not use gp. This means that li and la must not be used.
.globl __start .globl __start
.set noreorder .set noreorder

View File

@ -136,11 +136,9 @@ static void panic_message (unsigned n, const char *line, char const *name, char
kdebug_num (old_current->arch.hi) kdebug_num (old_current->arch.hi)
kdebug (" lo=") kdebug (" lo=")
kdebug_num (old_current->arch.lo) kdebug_num (old_current->arch.lo)
kdebug ("\nk=")
kdebug_num (old_current->arch.k[0])
kdebug (" ")
kdebug_num (old_current->arch.k[1])
kdebug ('\n') kdebug ('\n')
kdebug ("Directory: ")
kdebug_num ((unsigned)directory)
kdebug ("; ") kdebug ("; ")
kdebug (name) kdebug (name)
kdebug (':') kdebug (':')

View File

@ -1,4 +1,5 @@
#pypp 0 #pypp 0
// vim: set filetype=cpp : //
// Iris: micro-kernel for a capability-based operating system. // Iris: micro-kernel for a capability-based operating system.
// schedule.ccp: Thread scheduling. // schedule.ccp: Thread scheduling.
// Copyright 2009 Bas Wijnen <wijnen@debian.org> // Copyright 2009 Bas Wijnen <wijnen@debian.org>

View File

@ -23,6 +23,7 @@ Iris::Num start ():
Iris::my_parent.provide_capability <Iris::Event> (self) Iris::my_parent.provide_capability <Iris::Event> (self)
cap = Iris::my_receiver.create_capability (INTERRUPT) cap = Iris::my_receiver.create_capability (INTERRUPT)
Iris::my_parent.init_done () Iris::my_parent.init_done ()
font.printf ("Press a key to attempt reboot.\n")
while true: while true:
Iris::wait () Iris::wait ()
switch Iris::recv.protected_data.l: switch Iris::recv.protected_data.l:
@ -38,13 +39,16 @@ Iris::Num start ():
font.printf ("alarm: control event\n") font.printf ("alarm: control event\n")
break break
case KBD: case KBD:
// Key press if Iris::recv.data[0].l & Iris::Keyboard::RELEASE:
unsigned time = rtc.get_time () // Key release.
unsigned alarm = rtc.get_alarm () Iris::poweroff ()
unsigned enabled = Iris::recv.data[1].l else:
font.printf ("%d %d %d", time, alarm, enabled) // Key press.
rtc.set_alarm (time + 10, cap) unsigned time = rtc.get_time ()
Iris::poweroff () 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 break
default: default:
Iris::panic (Iris::recv.protected_data.l, "invalid request for alarm") Iris::panic (Iris::recv.protected_data.l, "invalid request for alarm")

View File

@ -51,8 +51,8 @@ Iris::Num start ():
rtc_set_adjc_val (0) rtc_set_adjc_val (0)
ready () ready ()
rtc_set_second (0) rtc_set_second (0)
ready () ready ()
rtc_disable_1Hz_irq () rtc_set_alarm_second (0)
ready () ready ()
rtc_disable_alarm () rtc_disable_alarm ()
ready () ready ()
@ -60,6 +60,8 @@ Iris::Num start ():
ready () ready ()
rtc_enable_alarm_irq () rtc_enable_alarm_irq ()
ready () ready ()
rtc_disable_1Hz_irq ()
ready ()
rtc_set_hwfcr_val (0) rtc_set_hwfcr_val (0)
ready () ready ()
rtc_set_hrcr_val (0) rtc_set_hrcr_val (0)

View File

@ -459,8 +459,10 @@ void Mmc::read_page (Iris::Page page, Iris::Num address, unsigned size, unsigned
offset &= ~PAGE_MASK & ~3 offset &= ~PAGE_MASK & ~3
if size + offset > PAGE_SIZE: if size + offset > PAGE_SIZE:
size = PAGE_SIZE - offset size = PAGE_SIZE - offset
page.set_flags (Iris::Page::PAYING | Iris::Page::FRAME)
page.share (buffer_page) page.share (buffer_page)
buffer_page.set_flags (Iris::Page::PAYING | Iris::Page::FRAME) buffer_page.set_flags (Iris::Page::PAYING | Iris::Page::FRAME)
page.set_flags (0, Iris::Page::PAYING)
for unsigned i = 0; i < size; i += 4: for unsigned i = 0; i < size; i += 4:
((unsigned *)buffer)[(offset + i) >> 2] = current_block[(start_pos + i) >> 2] ((unsigned *)buffer)[(offset + i) >> 2] = current_block[(start_pos + i) >> 2]
@ -475,8 +477,10 @@ void Mmc::write_page (Iris::Page page, Iris::Num address, unsigned size, unsigne
offset &= ~PAGE_MASK & ~3 offset &= ~PAGE_MASK & ~3
if size + offset > PAGE_SIZE: if size + offset > PAGE_SIZE:
size = PAGE_SIZE - offset size = PAGE_SIZE - offset
page.set_flags (Iris::Page::PAYING | Iris::Page::FRAME)
page.share (buffer_page) page.share (buffer_page)
buffer_page.set_flags (Iris::Page::PAYING | Iris::Page::FRAME) buffer_page.set_flags (Iris::Page::PAYING | Iris::Page::FRAME)
page.set_flags (0, Iris::Page::PAYING)
for unsigned i = 0; i < size; i += 4: for unsigned i = 0; i < size; i += 4:
current_block[(start_pos + i) >> 2] = ((unsigned *)buffer)[(offset + i) >> 2] current_block[(start_pos + i) >> 2] = ((unsigned *)buffer)[(offset + i) >> 2]
dirty = true dirty = true

View File

@ -1,4 +1,5 @@
#pypp 0 #pypp 0
// vim: set filetype=cpp : //
// Iris: micro-kernel for a capability-based operating system. // Iris: micro-kernel for a capability-based operating system.
// boot-programs/udc.ccp: USB device controller driver. // boot-programs/udc.ccp: USB device controller driver.
// Copyright 2009 Bas Wijnen <wijnen@debian.org> // Copyright 2009 Bas Wijnen <wijnen@debian.org>
@ -551,13 +552,14 @@ enum pdata:
NAME NAME
Iris::Num start (): Iris::Num start ():
Iris::debug ("udc started")
map_udc () map_udc ()
map_gpio () map_gpio ()
map_cpm () map_cpm ()
Udc udc Udc udc
//Iris::Cap logcap = Iris::my_receiver.create_capability (LOG) //Iris::Cap logcap = Iris::my_receiver.create_capability (LOG)
//__asm__ volatile ("li $a0, 1\nlw $a1, %0\nbreak" :: "m"(logcap.code): "a0", "a1", "memory") //__asm__ volatile ("li $a0, 1\nlw $a1, %0\nbreak" :: "m"(logcap.code): "a0", "a1")
Iris::Directory dir = Iris::my_receiver.create_capability (DIRECTORY) Iris::Directory dir = Iris::my_receiver.create_capability (DIRECTORY)
Iris::my_parent.provide_capability <Iris::Directory> (dir.copy ()) Iris::my_parent.provide_capability <Iris::Directory> (dir.copy ())
Iris::free_cap (dir) Iris::free_cap (dir)