1
0
mirror of git://projects.qi-hardware.com/iris.git synced 2024-11-17 09:50:37 +02:00
iris/mips/nanonote/stage1.ccp

67 lines
2.0 KiB
Plaintext
Raw Normal View History

#pypp 0
// Iris: micro-kernel for a capability-based operating system.
// mips/nanonote/sdram-setup.ccp: bootstrapping over usb.
// Copyright 2009 Bas Wijnen <wijnen@debian.org>
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
// This runs like the kernel. In particular, it doesn't want userspace declarations.
2009-10-31 10:32:23 +02:00
#define __KERNEL__
2009-12-11 10:43:42 +02:00
#define dbg_log_char(x) do {} while (0)
2011-01-15 03:10:46 +02:00
#define dbg_log(x) do {} while (0)
2009-12-11 10:43:42 +02:00
#define dbg_log_num(...) do {} while (0)
2011-01-15 03:10:46 +02:00
// Set up gp and sp, jump to start_cpp().
// This must be the first code in the file,
// so also before include jz4740.hh,
// because that defines some static functions which may not be inlined.
asm volatile (".set noreorder\n"
".globl __start\n"
".text\n"
"__start:\n"
2012-09-26 20:03:36 +03:00
"\tmove $t0, $ra\n" // 0
"\tnop\n" // 4
"\tbal 1f\n" // 8
"\tnop\n" // 12
"\t.word _gp\n" // 16
"\t.word 0\n" // 20: This is overwritten in software usbboot mode.
"1:\n"
"\tlw $gp, 0($ra)\n"
2012-09-26 20:03:36 +03:00
"\tlb $a0, 4($ra)\n"
"\tla $sp, stack + 0x40\n"
"\tla $t9, start_cpp\n"
2012-09-26 20:03:36 +03:00
"\tmove $ra, $t0\n"
"\tjr $t9\n"
"\tnop\n"
".set reorder")
#include "jz4740.hh"
void kdebug (unsigned ch):
while !(UART0_LSR & UARTLSR_TDRQ):
UART0_TDR = ch
while !(UART0_LSR & UARTLSR_TEMT):
extern "C":
2012-09-26 20:03:36 +03:00
void start_cpp (int skip_memsetup)
char stack[0x40]
2012-09-26 20:03:36 +03:00
void start_cpp (int skip_memsetup):
setup_uart ()
kdebug ('.')
2012-09-26 20:03:36 +03:00
if !skip_memsetup:
setup_sdram ()
kdebug ('!')
// everything is ok now: return to boot loader to load stage 2.