mirror of
git://projects.qi-hardware.com/iris.git
synced 2025-04-21 12:27:27 +03:00
start wrapper; proper serial port baudrate
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
// Iris: micro-kernel for a capability-based operating system.
|
||||
// mips/trendtac/boot.S: Kernel entry point, called by the boot loader.
|
||||
// mips/boot.S: Kernel entry point, called by the boot loader.
|
||||
// Copyright 2009 Bas Wijnen <wijnen@debian.org>
|
||||
//
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
|
||||
@@ -15,15 +15,17 @@
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
start_load = 0xa0600000
|
||||
load = 0x80000000
|
||||
#UDC_BOOT = set
|
||||
#UDC_BOOT = comment this out for nand boot
|
||||
|
||||
ARCH_CPPFLAGS = -I. -Imips -Imips/nanonote -Wa,-mips32 -DNANONOTE -DUSE_SERIAL
|
||||
CROSS = mipsel-linux-gnu-
|
||||
OBJDUMP = $(CROSS)objdump
|
||||
junk = mdebug.abi32 reginfo comment pdr
|
||||
OBJCOPYFLAGS = $(addprefix --remove-section=.,$(junk))
|
||||
LDFLAGS = --omagic -Ttext $(load)
|
||||
iris.elf: LDFLAGS = --omagic -Ttext $(load)
|
||||
mips/start.elf: LDFLAGS = --omagic -Ttext $(start_load)
|
||||
|
||||
arch_iris_sources = mips/interrupts.cc mips/arch.cc
|
||||
boot_sources = mips/init.cc mips/nanonote/board.cc
|
||||
@@ -44,13 +46,16 @@ boot_threads = $(standard_boot_programs) $(sd_boot_programs)
|
||||
threadlist = mips/nanonote/threadlist-sd
|
||||
ARCH_CXXFLAGS = -DNUM_THREADS=4
|
||||
all: iris-sd.tar
|
||||
iris-sd.tar: $(addprefix fs/,$(addsuffix .elf,$(programs))) iris.raw fs/init.config
|
||||
mkimage -A mips -T kernel -a $(load) -e a$(shell /bin/sh -c '$(OBJDUMP) -t iris.elf | grep __start$$ | cut -b2-8') -n Iris -d iris.raw fs/uimage | sed -e 's/:/;/g'
|
||||
iris-sd.tar: $(addprefix fs/,$(addsuffix .elf,$(programs))) mips/start.raw.gz fs/init.config
|
||||
mkimage -A mips -T kernel -a $(start_load) -e a$(shell /bin/sh -c '$(OBJDUMP) -t mips/start.elf | grep __start$$ | cut -b2-8') -n Iris -d mips/start.raw.gz fs/uimage | sed -e 's/:/;/g'
|
||||
cd fs && tar cvf ../$@ uimage init.config $(addsuffix .elf,$(programs)) --dereference
|
||||
endif
|
||||
|
||||
test: iris.raw mips/nanonote/server/usb-server mips/nanonote/sdram-setup.raw $(addsuffix .elf,$(addprefix fs/,$(programs))) fs/init.config
|
||||
echo "reboot 0xa$(shell /bin/sh -c '$(OBJDUMP) -t iris.elf | grep __start$$ | cut -b2-8')" | nc localhost 5050
|
||||
mips/start.o:mips/start.S Makefile Makefile.arch iris.raw
|
||||
$(CC) $(CPPFLAGS) -DSTART=0xa$(shell /bin/sh -c '$(OBJDUMP) -t iris.elf | grep __start$$ | cut -b2-8') -c $< -o $@
|
||||
|
||||
test: mips/start.raw mips/start.elf mips/nanonote/server/usb-server mips/nanonote/sdram-setup.raw $(addsuffix .elf,$(addprefix fs/,$(programs))) fs/init.config
|
||||
echo "reboot $(start_load) 0xa$(shell /bin/sh -c '$(OBJDUMP) -t mips/start.elf | grep __start$$ | cut -b2-8') $<" | nc localhost 5050
|
||||
|
||||
mips/nanonote/server/usb-server: mips/nanonote/server/usb-server.ccp mips/nanonote/server/Makefile.am mips/nanonote/server/configure.ac devices.hh
|
||||
$(MAKE) -C mips/nanonote/server
|
||||
@@ -63,6 +68,9 @@ mips/nanonote/server/usb-server: mips/nanonote/server/usb-server.ccp mips/nanono
|
||||
%.raw: %.elf
|
||||
$(OBJCOPY) -S $(OBJCOPYFLAGS) -Obinary $< $@
|
||||
|
||||
%.raw.gz: %.raw
|
||||
gzip < $< > $@
|
||||
|
||||
nanonote-boot: mips/nanonote/nanonote-boot.cc mips/nanonote/sdram-setup.raw
|
||||
g++ `pkg-config --cflags --libs shevek` $< -o $@ -D'STAGE1="$<"' -lusb
|
||||
|
||||
@@ -84,12 +92,15 @@ source/charset.data: source/charset
|
||||
$< > $@
|
||||
|
||||
%.o:%.S Makefile Makefile.arch mips/arch.hh
|
||||
$(CC) $(CPPFLAGS) $(TARGET_FLAGS) -DKERNEL_STACK_SIZE=0x2000 -c $< -o $@
|
||||
$(CC) $(CPPFLAGS) $(TARGET_FLAGS) -DKERNEL_STACK_SIZE=0x1000 -c $< -o $@
|
||||
|
||||
# entry.o must be the first file. threadlist.o must be the first of the init objects (which can be freed after loading).
|
||||
iris.elf: mips/entry.o $(subst .cc,.o,$(iris_sources)) $(threadlist).o mips/boot.o $(subst .cc,.o,$(boot_sources))
|
||||
$(LD) $(LDFLAGS) $^ -o $@
|
||||
|
||||
mips/start.elf: mips/start.o
|
||||
$(LD) $(LDFLAGS) $^ -o $@
|
||||
|
||||
server:
|
||||
while mips/nanonote/server/usb-server ; do : ; done
|
||||
|
||||
@@ -100,7 +111,7 @@ setup:
|
||||
x-terminal-emulator -e make debug &
|
||||
x-terminal-emulator -e make servers &
|
||||
|
||||
ARCH_CLEAN_FILES = $(boot_sources) $(addsuffix .elf,$(boot_threads)) $(arch_headers) devices.hh keys.hh mips/*.o mips/nanonote/*.o source/charset.data iris.elf iris.raw mips/nanonote/sdram-setup.elf mips/nanonote/sdram-setup.raw
|
||||
ARCH_CLEAN_FILES = $(boot_sources) $(addsuffix .elf,$(boot_threads)) $(arch_headers) devices.hh keys.hh mips/*.o mips/nanonote/*.o source/charset.data iris.elf iris.raw mips/nanonote/sdram-setup.elf mips/nanonote/sdram-setup.raw mips/start.elf mips/start.raw
|
||||
|
||||
.PRECIOUS: mips/arch.hh mips/nanonote/jz4740.hh mips/nanonote/board.hh
|
||||
.PHONY: test all monitor server servers setup
|
||||
|
||||
@@ -71,12 +71,13 @@ void board_init ():
|
||||
UART0_FCR = 0
|
||||
UART0_MCR = 0
|
||||
UART0_SIRCR = 0
|
||||
UART0_UMR = 0
|
||||
UART0_UACR = 0
|
||||
UART0_UMR = 1
|
||||
UART0_LCR = UARTLCR_WLEN_8 | UARTLCR_STOP1 | UARTLCR_DLAB
|
||||
unsigned uart_div = 3000000 / 16 / 9600
|
||||
UART0_DLHR = uart_div >> 8
|
||||
UART0_DLLR = uart_div
|
||||
unsigned const baud = 57600
|
||||
unsigned uart_div = 12000000 / baud
|
||||
UART0_DLHR = (uart_div >> 8) & 0xff
|
||||
UART0_DLLR = uart_div & 0xff
|
||||
UART0_LCR = UARTLCR_WLEN_8 | UARTLCR_STOP1
|
||||
UART0_FCR = UARTFCR_UUE | UARTFCR_FE | UARTFCR_RFLS | UARTFCR_TFLS
|
||||
kdebug ("\n\nSerial port initialized\n")
|
||||
|
||||
@@ -2346,10 +2346,10 @@ static void gpio_disable_pull (unsigned p, unsigned pins):
|
||||
//**************************************************************************
|
||||
static void pll_init ():
|
||||
// The cpu clock frequency
|
||||
unsigned const cpu_clock = 336000000
|
||||
//unsigned const cpu_clock = 200000000
|
||||
//unsigned const pixclock = 13500000
|
||||
unsigned const pixclock = 25846153
|
||||
//unsigned const cpu_clock = 336000000
|
||||
//unsigned const pixclock = 25846153
|
||||
unsigned const cpu_clock = 200000000
|
||||
unsigned const pixclock = 13500000
|
||||
// Configure the pll frequency to cpu_clock.
|
||||
CPM_CPPCR = ((cpu_clock * 2 / JZ_EXTAL - 2) << CPM_CPPCR_PLLM_BIT) | (0 << CPM_CPPCR_PLLN_BIT) | (0 << CPM_CPPCR_PLLOD_BIT) | (0x20 << CPM_CPPCR_PLLST_BIT) | CPM_CPPCR_PLLEN
|
||||
// Set up dividers; see documentation for the meaning of all the values.
|
||||
|
||||
@@ -20,7 +20,7 @@ AUTOMAKE_OPTIONS = foreign
|
||||
bin_PROGRAMS = usb-server
|
||||
|
||||
usb_server_SOURCES = usb-server.cc
|
||||
usb_server_CPPFLAGS = $(SHEVEK_CFLAGS) -DSTAGE1_FILE=\"mips/nanonote/sdram-setup.raw\" -DSTAGE2_FILE=\"iris.raw\" -I../../..
|
||||
usb_server_CPPFLAGS = $(SHEVEK_CFLAGS) -DSTAGE1_FILE=\"mips/nanonote/sdram-setup.raw\" -DSTAGE2_FILE=\"mips/start.raw\" -I../../..
|
||||
usb_server_LDFLAGS = $(SHEVEK_LIBS) -lusb
|
||||
|
||||
PYPP = /usr/bin/pypp
|
||||
|
||||
@@ -40,7 +40,7 @@ struct data:
|
||||
static int const run_vendor = 0xfffe
|
||||
static int const run_product = 0x0002
|
||||
static unsigned const timeout = 10000
|
||||
void boot (unsigned entry)
|
||||
void boot (std::string const &filename, unsigned load, unsigned entry)
|
||||
data (std::string const &port):
|
||||
handle = NULL
|
||||
server = shevek::server <client, data *>::create ()
|
||||
@@ -49,7 +49,6 @@ struct data:
|
||||
|
||||
private:
|
||||
static unsigned const STAGE1_LOAD = 0x80002000
|
||||
static unsigned const STAGE2_LOAD = 0x80000000
|
||||
static unsigned const STAGE1_ENTRY = STAGE1_LOAD
|
||||
enum requests:
|
||||
VR_GET_CPU_INFO = 0
|
||||
@@ -212,9 +211,10 @@ struct client : public shevek::server <client, data *>::connection:
|
||||
keep = is_stdio
|
||||
void read (std::string const &line):
|
||||
shevek::istring l (line)
|
||||
unsigned entry
|
||||
if l ("reboot %x%", entry):
|
||||
get_server ()->data ()->boot (entry)
|
||||
unsigned load, entry
|
||||
std::string filename
|
||||
if l ("reboot %x %x %r%", load, entry, filename):
|
||||
get_server ()->data ()->boot (filename, load, entry)
|
||||
else if l ("shutdown%"):
|
||||
std::cerr << "shutting down\n"
|
||||
shevek::end_loop ()
|
||||
@@ -266,8 +266,8 @@ void data::get_device (unsigned vendor, unsigned product, unsigned tries):
|
||||
sleep (1)
|
||||
std::cerr << shevek::ostring ("giving up finding device %04x:%04x\n", vendor, product)
|
||||
|
||||
void data::boot (unsigned entry):
|
||||
std::cerr << "booting " << shevek::ostring ("%x", entry) << "\n"
|
||||
void data::boot (std::string const &filename, unsigned load, unsigned entry):
|
||||
std::cerr << "booting " << shevek::ostring ("%s from %x@%x", Glib::ustring (filename), load, entry) << "\n"
|
||||
if handle:
|
||||
usb_release_interface (handle, 0)
|
||||
usb_close (handle)
|
||||
@@ -294,10 +294,10 @@ void data::boot (unsigned entry):
|
||||
std::ostringstream stage2
|
||||
usb_release_interface (handle, 0)
|
||||
file.close ()
|
||||
file.open (STAGE2_FILE)
|
||||
file.open (filename.c_str ())
|
||||
stage2 << file.rdbuf ()
|
||||
std::cerr << "sending Iris\n"
|
||||
send_file (STAGE2_LOAD, stage2.str ().size (), stage2.str ().data ())
|
||||
std::cerr << shevek::ostring ("sending Iris (size 0x%x)\n", stage2.str ().size ())
|
||||
send_file (load, stage2.str ().size (), stage2.str ().data ())
|
||||
std::cerr << "flushing caches\n"
|
||||
request (VR_FLUSH_CACHES)
|
||||
std::cerr << "running Iris\n"
|
||||
|
||||
46
mips/start.S
Normal file
46
mips/start.S
Normal file
@@ -0,0 +1,46 @@
|
||||
// Iris: micro-kernel for a capability-based operating system.
|
||||
// mips/start.S: kernel starter at high address.
|
||||
// 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/>.
|
||||
|
||||
.globl __start
|
||||
.set noreorder
|
||||
|
||||
__start:
|
||||
bal 1f
|
||||
// For some reason the disassembler considers everything
|
||||
// after __start non-code until the next label. So I add a label.
|
||||
start_hack_for_disassembler:
|
||||
nop
|
||||
.word _gp
|
||||
1: lw $gp, 0($ra)
|
||||
|
||||
li $a0, 0xa0000000
|
||||
la $a1, image
|
||||
la $a2, image_end
|
||||
|
||||
1: lw $a3, 0($a1)
|
||||
sw $a3, 0($a0)
|
||||
addiu $a1, 4
|
||||
bne $a1, $a2, 1b
|
||||
addiu $a0, 4
|
||||
|
||||
li $t9, START
|
||||
jr $t9
|
||||
nop
|
||||
|
||||
image:
|
||||
.incbin "iris.raw"
|
||||
image_end:
|
||||
Reference in New Issue
Block a user