Root/
| 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 (true) |
| 62 | kdebug ('.') |
| 63 | if !skip_memsetup: |
| 64 | setup_sdram () |
| 65 | kdebug ('!') |
| 66 | // everything is ok now: return to boot loader to load stage 2. |
| 67 |
Branches:
master
