2009-09-27 11:23:33 +03:00
|
|
|
#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
|
|
|
|
2012-01-14 19:17:23 +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.
|
2009-09-27 11:23:33 +03:00
|
|
|
asm volatile (".set noreorder\n"
|
2012-01-14 19:17:23 +02:00
|
|
|
".globl __start\n"
|
|
|
|
".text\n"
|
2009-09-27 11:23:33 +03:00
|
|
|
"__start:\n"
|
2011-01-15 03:10:46 +02:00
|
|
|
"\tnop\n"
|
2009-09-27 11:23:33 +03:00
|
|
|
"__hack_label:\n"
|
2012-01-14 19:17:23 +02:00
|
|
|
"\tmove $k0, $ra\n"
|
2009-09-27 11:23:33 +03:00
|
|
|
"\tbal 1f\n"
|
|
|
|
"\tnop\n"
|
|
|
|
"\t.word _gp\n"
|
|
|
|
"1:\n"
|
|
|
|
"\tlw $gp, 0($ra)\n"
|
2011-01-15 03:10:46 +02:00
|
|
|
"\tla $sp, stack + 0x100\n"
|
2009-09-27 11:23:33 +03:00
|
|
|
"\tla $t9, start_cpp\n"
|
2012-01-14 19:17:23 +02:00
|
|
|
"\tmove $ra, $k0\n"
|
2009-09-27 11:23:33 +03:00
|
|
|
"\tjr $t9\n"
|
|
|
|
"\tnop\n"
|
|
|
|
".set reorder")
|
|
|
|
|
2012-01-14 19:17:23 +02:00
|
|
|
#include "jz4740.hh"
|
|
|
|
|
|
|
|
void kdebug (unsigned ch):
|
|
|
|
while !(UART0_LSR & UARTLSR_TDRQ):
|
|
|
|
UART0_TDR = ch
|
|
|
|
while !(UART0_LSR & UARTLSR_TEMT):
|
|
|
|
|
2009-09-27 11:23:33 +03:00
|
|
|
extern "C":
|
|
|
|
void start_cpp ()
|
2011-01-15 03:10:46 +02:00
|
|
|
char stack[0x100]
|
2009-09-27 11:23:33 +03:00
|
|
|
|
|
|
|
void start_cpp ():
|
2012-01-14 19:17:23 +02:00
|
|
|
setup_uart ()
|
|
|
|
kdebug ('.')
|
|
|
|
setup_sdram ()
|
|
|
|
kdebug ('!')
|
2009-09-27 11:23:33 +03:00
|
|
|
// everything is ok now: return to boot loader to load stage 2.
|