Makefile.am |
26 | 26 | |
27 | 27 | start_load = 0x80100000 |
28 | 28 | |
29 | | noinst_DATA = iris.raw mips/start.raw mips/start-hack.S mips/board/sdram-setup.raw |
30 | | noinst_PROGRAMS = iris.elf mips/start.elf mips/board/sdram-setup.elf |
| 29 | noinst_DATA = iris.raw mips/start.raw mips/start-hack.S mips/board/stage1.raw |
| 30 | noinst_PROGRAMS = iris.elf mips/start.elf mips/board/stage1.elf |
31 | 31 | |
32 | 32 | %.raw: %.elf |
33 | 33 | $(OBJCOPY) $(objcopyflags) -Obinary $< $@ |
... | ... | |
61 | 61 | mips/start-hack.S: mips/start.S iris.raw |
62 | 62 | cp $< $@ |
63 | 63 | |
64 | | mips_board_sdram_setup_elf_DEPENDENCIES = mips/board/sdram-setup.ld |
65 | | mips_board_sdram_setup_elf_CPPFLAGS = -fno-inline -Iinclude -Imips -Imips/board -mips32 |
66 | | mips_board_sdram_setup_elf_CXXFLAGS = -O5 -Wno-unused-parameter -fno-strict-aliasing -fno-builtin -ggdb3 -fno-exceptions -fno-common |
67 | | mips_board_sdram_setup_elf_LDFLAGS = -Wl,--omagic -Wl,-T -Wl,mips/board/sdram-setup.ld -nostdlib |
68 | | mips_board_sdram_setup_elf_SOURCES = mips/board/sdram-setup.cc |
| 64 | mips_board_stage1_elf_DEPENDENCIES = mips/board/stage1.ld |
| 65 | mips_board_stage1_elf_CPPFLAGS = -fno-inline -Iinclude -Imips -Imips/board -mips32 |
| 66 | mips_board_stage1_elf_CXXFLAGS = -O5 -Wno-unused-parameter -fno-strict-aliasing -fno-builtin -ggdb3 -fno-exceptions -fno-common |
| 67 | mips_board_stage1_elf_LDFLAGS = -Wl,--omagic -Wl,-T -Wl,mips/board/stage1.ld -nostdlib |
| 68 | mips_board_stage1_elf_SOURCES = mips/board/stage1.cc |
69 | 69 | |
70 | 70 | program_targets = \ |
71 | 71 | userspace/bootinit.elf \ |
... | ... | |
175 | 175 | $(MAKE) -C native |
176 | 176 | |
177 | 177 | # This target is meaningless for SD boot mode. |
178 | | test: mips/start.raw mips/start.elf server mips/board/sdram-setup.raw fs/init.config fs/font.dat |
| 178 | test: mips/start.raw mips/start.elf server mips/board/stage1.raw fs/init.config fs/font.dat |
179 | 179 | echo shutdown | nc localhost 5050 || true |
180 | 180 | native/usb-server |
181 | 181 | 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 |
... | ... | |
217 | 217 | cat $(SERIAL) |
218 | 218 | |
219 | 219 | autoclean: maintainer-clean |
220 | | $(MAKE) -C native autoclean |
221 | | 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 |
| 220 | test ! -f native/Makefile || $(MAKE) -C native autoclean |
| 221 | rm -rf aclocal.m4 configure compile 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/stage1.cc mips/board/stage1.elf mips/board/stage1.raw mips/board/stage1.elf userspace/boot/crt0.cc |
include/iris.hhp |
611 | 611 | Iris::Num start () |
612 | 612 | |
613 | 613 | #ifndef __KERNEL__ |
| 614 | #ifndef __NATIVE__ |
614 | 615 | #if 1 |
615 | 616 | // Use a define instead of an inline function, because this is better visible in disassembly, even when not optimizing. |
616 | 617 | #define kdebug_char(_c) do { unsigned _d = (_c); __asm__ volatile ("move $a0, $zero\nlw $a1, %0\nbreak" :: "m"(_d) : "a0", "a1", "memory"); } while (0) |
... | ... | |
684 | 685 | else: |
685 | 686 | kdebug_char (*f) |
686 | 687 | ++f |
687 | | |
688 | | #endif |
| 688 | #else |
| 689 | namespace Iris: |
| 690 | inline void panic(unsigned code, char const *message = NULL): |
| 691 | inline void debug_num (unsigned num, unsigned base): |
| 692 | inline void debug (const char *f, ...): |
| 693 | #endif // !defined(__NATIVE__) |
| 694 | #endif // !defined(__KERNEL__) |
689 | 695 | #endif |
mips/nanonote/sdram-setup.ccp |
1 | | #pypp 0 |
2 | | // Iris: micro-kernel for a capability-based operating system. |
3 | | // mips/nanonote/sdram-setup.ccp: bootstrapping over usb. |
4 | | // Copyright 2009 Bas Wijnen <wijnen@debian.org> |
5 | | // |
6 | | // This program is free software: you can redistribute it and/or modify |
7 | | // it under the terms of the GNU General Public License as published by |
8 | | // the Free Software Foundation, either version 3 of the License, or |
9 | | // (at your option) any later version. |
10 | | // |
11 | | // This program is distributed in the hope that it will be useful, |
12 | | // but WITHOUT ANY WARRANTY; without even the implied warranty of |
13 | | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
14 | | // GNU General Public License for more details. |
15 | | // |
16 | | // You should have received a copy of the GNU General Public License |
17 | | // along with this program. If not, see <http://www.gnu.org/licenses/>. |
18 | | |
19 | | // This runs like the kernel. In particular, it doesn't want userspace declarations. |
20 | | #define __KERNEL__ |
21 | | #define dbg_log_char(x) do {} while (0) |
22 | | #define dbg_log(x) do {} while (0) |
23 | | #define dbg_log_num(...) do {} while (0) |
24 | | |
25 | | // Set up gp and sp, jump to start_cpp(). |
26 | | // This must be the first code in the file, |
27 | | // so also before include jz4740.hh, |
28 | | // because that defines some static functions which may not be inlined. |
29 | | asm volatile (".set noreorder\n" |
30 | | ".globl __start\n" |
31 | | ".text\n" |
32 | | "__start:\n" |
33 | | "\tmove $t0, $ra\n" // 0 |
34 | | "\tnop\n" // 4 |
35 | | "\tbal 1f\n" // 8 |
36 | | "\tnop\n" // 12 |
37 | | "\t.word _gp\n" // 16 |
38 | | "\t.word 0\n" // 20: This is overwritten in software usbboot mode. |
39 | | "1:\n" |
40 | | "\tlw $gp, 0($ra)\n" |
41 | | "\tlb $a0, 4($ra)\n" |
42 | | "\tla $sp, stack + 0x40\n" |
43 | | "\tla $t9, start_cpp\n" |
44 | | "\tmove $ra, $t0\n" |
45 | | "\tjr $t9\n" |
46 | | "\tnop\n" |
47 | | ".set reorder") |
48 | | |
49 | | #include "jz4740.hh" |
50 | | |
51 | | void kdebug (unsigned ch): |
52 | | while !(UART0_LSR & UARTLSR_TDRQ): |
53 | | UART0_TDR = ch |
54 | | while !(UART0_LSR & UARTLSR_TEMT): |
55 | | |
56 | | extern "C": |
57 | | void start_cpp (int skip_memsetup) |
58 | | char stack[0x40] |
59 | | |
60 | | void start_cpp (int skip_memsetup): |
61 | | setup_uart () |
62 | | kdebug ('.') |
63 | | if !skip_memsetup: |
64 | | setup_sdram () |
65 | | kdebug ('!') |
66 | | // everything is ok now: return to boot loader to load stage 2. |
mips/nanonote/sdram-setup.ld |
1 | | OUTPUT_ARCH(mips) |
2 | | ENTRY(__start) |
3 | | MEMORY |
4 | | { |
5 | | ram : ORIGIN = 0x80003000 , LENGTH = 0x800 |
6 | | } |
7 | | |
8 | | SECTIONS |
9 | | { |
10 | | . = ALIGN(4); |
11 | | .text : { *(.text*) } > ram |
12 | | |
13 | | . = ALIGN(4); |
14 | | .rodata : { *(.rodata*) *(.note*) } > ram |
15 | | |
16 | | . = ALIGN(4); |
17 | | .sdata : { *(.sdata*) } > ram |
18 | | |
19 | | . = ALIGN(4); |
20 | | .data : { *(.data*) *(.scommon*) *(.reginfo*) } > ram |
21 | | |
22 | | _gp = ABSOLUTE(.); /* Base of small data */ |
23 | | |
24 | | .got : { *(.got*) } > ram |
25 | | |
26 | | . = ALIGN(4); |
27 | | .sbss : { *(.sbss*) } > ram |
28 | | .bss : { *(.bss*) } > ram |
29 | | . = ALIGN (4); |
30 | | } |
mips/nanonote/stage1.ccp |
| 1 | #pypp 0 |
| 2 | // Iris: micro-kernel for a capability-based operating system. |
| 3 | // mips/nanonote/sdram-setup.ccp: bootstrapping over usb. |
| 4 | // Copyright 2009 Bas Wijnen <wijnen@debian.org> |
| 5 | // |
| 6 | // This program is free software: you can redistribute it and/or modify |
| 7 | // it under the terms of the GNU General Public License as published by |
| 8 | // the Free Software Foundation, either version 3 of the License, or |
| 9 | // (at your option) any later version. |
| 10 | // |
| 11 | // This program is distributed in the hope that it will be useful, |
| 12 | // but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 13 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 14 | // GNU General Public License for more details. |
| 15 | // |
| 16 | // You should have received a copy of the GNU General Public License |
| 17 | // along with this program. If not, see <http://www.gnu.org/licenses/>. |
| 18 | |
| 19 | // This runs like the kernel. In particular, it doesn't want userspace declarations. |
| 20 | #define __KERNEL__ |
| 21 | #define dbg_log_char(x) do {} while (0) |
| 22 | #define dbg_log(x) do {} while (0) |
| 23 | #define dbg_log_num(...) do {} while (0) |
| 24 | |
| 25 | // Set up gp and sp, jump to start_cpp(). |
| 26 | // This must be the first code in the file, |
| 27 | // so also before include jz4740.hh, |
| 28 | // because that defines some static functions which may not be inlined. |
| 29 | asm volatile (".set noreorder\n" |
| 30 | ".globl __start\n" |
| 31 | ".text\n" |
| 32 | "__start:\n" |
| 33 | "\tmove $t0, $ra\n" // 0 |
| 34 | "\tnop\n" // 4 |
| 35 | "\tbal 1f\n" // 8 |
| 36 | "\tnop\n" // 12 |
| 37 | "\t.word _gp\n" // 16 |
| 38 | "\t.word 0\n" // 20: This is overwritten in software usbboot mode. |
| 39 | "1:\n" |
| 40 | "\tlw $gp, 0($ra)\n" |
| 41 | "\tlb $a0, 4($ra)\n" |
| 42 | "\tla $sp, stack + 0x40\n" |
| 43 | "\tla $t9, start_cpp\n" |
| 44 | "\tmove $ra, $t0\n" |
| 45 | "\tjr $t9\n" |
| 46 | "\tnop\n" |
| 47 | ".set reorder") |
| 48 | |
| 49 | #include "jz4740.hh" |
| 50 | |
| 51 | void kdebug (unsigned ch): |
| 52 | while !(UART0_LSR & UARTLSR_TDRQ): |
| 53 | UART0_TDR = ch |
| 54 | while !(UART0_LSR & UARTLSR_TEMT): |
| 55 | |
| 56 | extern "C": |
| 57 | void start_cpp (int skip_memsetup) |
| 58 | char stack[0x40] |
| 59 | |
| 60 | void start_cpp (int skip_memsetup): |
| 61 | setup_uart () |
| 62 | kdebug ('.') |
| 63 | if !skip_memsetup: |
| 64 | setup_sdram () |
| 65 | kdebug ('!') |
| 66 | // everything is ok now: return to boot loader to load stage 2. |
mips/nanonote/stage1.ld |
| 1 | OUTPUT_ARCH(mips) |
| 2 | ENTRY(__start) |
| 3 | MEMORY |
| 4 | { |
| 5 | ram : ORIGIN = 0x80003000 , LENGTH = 0x800 |
| 6 | } |
| 7 | |
| 8 | SECTIONS |
| 9 | { |
| 10 | /* Start with the part containing the interrupt and exception code. */ |
| 11 | .text : { mips/board/mips_board_stage1_elf-stage1.o(.text*) } > ram |
| 12 | .text : { *(.text*) } > ram |
| 13 | |
| 14 | .rodata : { *(.rodata*) *(.note*) } > ram |
| 15 | .sdata : { *(.sdata*) } > ram |
| 16 | .data : { *(.data*) *(.scommon*) *(.reginfo*) } > ram |
| 17 | |
| 18 | _gp = ABSOLUTE(.); |
| 19 | |
| 20 | .got : { *(.got*) } > ram |
| 21 | .sbss : { *(.sbss*) } > ram |
| 22 | .bss : { *(.bss*) } > ram |
| 23 | } |