Commit a first cut at ports of boot2 and loader to 64-bit MIPS, with a
particular interest in (and support for) SRI International and the
University of Cambridge's BERI FPGA soft-core processor. This includes
micro device drivers for the Altera JTAG UART console, memory-mapped
flash, and the Altera SD Card IP core in both boot2 and loader. boot2
can be written to the on-board Intel StrataFlash on the DE4 board, and
loader can be placed in StrataFlash or the SD Card.
Plenty of XXX comments, but works quite well locally in practice and I
am using it daily. Although I had originally ported the ARM version
of boot2, the current version is x86-derived as that proved more
feature-complete. As we don't currently use partitions on our flash
disks, support for that has been commented out relative to x86, but
would be easy to add back. FDT support has not yet been hooked up,
although some skeleton parts have been put in place for that.
This may well be a useful starting point for ports to other 32-bit and
64-bit MIPS-ISA systems.
This merge is synchronised to CheriBSD github commit
e41d74fd719525d4dd7a7ee499114679165eeaf6, but with some additions of
$FreeBSD.
MFC after: 3 weeks
Sponsored by: DARPA, AFRAL
2014-02-18 23:18:32 +00:00
|
|
|
/*-
|
|
|
|
* Copyright (c) 2013-2014 Robert N. M. Watson
|
|
|
|
* All rights reserved.
|
|
|
|
*
|
|
|
|
* This software was developed by SRI International and the University of
|
|
|
|
* Cambridge Computer Laboratory under DARPA/AFRL contract (FA8750-10-C-0237)
|
|
|
|
* ("CTSRD"), as part of the DARPA CRASH research programme.
|
|
|
|
*
|
|
|
|
* Redistribution and use in source and binary forms, with or without
|
|
|
|
* modification, are permitted provided that the following conditions
|
|
|
|
* are met:
|
|
|
|
* 1. Redistributions of source code must retain the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer.
|
|
|
|
* 2. Redistributions in binary form must reproduce the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer in the
|
|
|
|
* documentation and/or other materials provided with the distribution.
|
|
|
|
*
|
|
|
|
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
|
|
|
|
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
|
|
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
|
|
|
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
|
|
|
|
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
|
|
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
|
|
|
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
|
|
|
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
|
|
|
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
|
|
|
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
|
|
|
* SUCH DAMAGE.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <sys/cdefs.h>
|
|
|
|
__FBSDID("$FreeBSD$");
|
|
|
|
|
|
|
|
#include <sys/param.h>
|
|
|
|
#include <sys/linker.h>
|
|
|
|
#include <sys/reboot.h>
|
|
|
|
|
|
|
|
#include <machine/bootinfo.h>
|
|
|
|
#include <machine/elf.h>
|
|
|
|
|
|
|
|
#include <stand.h>
|
|
|
|
#include <bootstrap.h>
|
|
|
|
#include <loader.h>
|
|
|
|
#include <mips.h>
|
|
|
|
|
2014-05-30 16:47:54 +00:00
|
|
|
#ifdef LOADER_USB_SUPPORT
|
|
|
|
#include <storage/umass_common.h>
|
|
|
|
#endif
|
|
|
|
|
Commit a first cut at ports of boot2 and loader to 64-bit MIPS, with a
particular interest in (and support for) SRI International and the
University of Cambridge's BERI FPGA soft-core processor. This includes
micro device drivers for the Altera JTAG UART console, memory-mapped
flash, and the Altera SD Card IP core in both boot2 and loader. boot2
can be written to the on-board Intel StrataFlash on the DE4 board, and
loader can be placed in StrataFlash or the SD Card.
Plenty of XXX comments, but works quite well locally in practice and I
am using it daily. Although I had originally ported the ARM version
of boot2, the current version is x86-derived as that proved more
feature-complete. As we don't currently use partitions on our flash
disks, support for that has been commented out relative to x86, but
would be easy to add back. FDT support has not yet been hooked up,
although some skeleton parts have been put in place for that.
This may well be a useful starting point for ports to other 32-bit and
64-bit MIPS-ISA systems.
This merge is synchronised to CheriBSD github commit
e41d74fd719525d4dd7a7ee499114679165eeaf6, but with some additions of
$FreeBSD.
MFC after: 3 weeks
Sponsored by: DARPA, AFRAL
2014-02-18 23:18:32 +00:00
|
|
|
static int __elfN(exec)(struct preloaded_file *);
|
|
|
|
static void extract_currdev(struct bootinfo *);
|
|
|
|
|
|
|
|
struct devsw *devsw[] = {
|
|
|
|
&beri_cfi_disk,
|
|
|
|
&beri_sdcard_disk,
|
2014-05-30 16:47:54 +00:00
|
|
|
#ifdef LOADER_USB_SUPPORT
|
|
|
|
&umass_disk,
|
|
|
|
#endif
|
Commit a first cut at ports of boot2 and loader to 64-bit MIPS, with a
particular interest in (and support for) SRI International and the
University of Cambridge's BERI FPGA soft-core processor. This includes
micro device drivers for the Altera JTAG UART console, memory-mapped
flash, and the Altera SD Card IP core in both boot2 and loader. boot2
can be written to the on-board Intel StrataFlash on the DE4 board, and
loader can be placed in StrataFlash or the SD Card.
Plenty of XXX comments, but works quite well locally in practice and I
am using it daily. Although I had originally ported the ARM version
of boot2, the current version is x86-derived as that proved more
feature-complete. As we don't currently use partitions on our flash
disks, support for that has been commented out relative to x86, but
would be easy to add back. FDT support has not yet been hooked up,
although some skeleton parts have been put in place for that.
This may well be a useful starting point for ports to other 32-bit and
64-bit MIPS-ISA systems.
This merge is synchronised to CheriBSD github commit
e41d74fd719525d4dd7a7ee499114679165eeaf6, but with some additions of
$FreeBSD.
MFC after: 3 weeks
Sponsored by: DARPA, AFRAL
2014-02-18 23:18:32 +00:00
|
|
|
NULL
|
|
|
|
};
|
|
|
|
|
|
|
|
struct arch_switch archsw;
|
|
|
|
|
|
|
|
struct file_format *file_formats[] = {
|
|
|
|
&beri_elf,
|
|
|
|
NULL
|
|
|
|
};
|
|
|
|
|
|
|
|
struct fs_ops *file_system[] = {
|
|
|
|
#ifdef LOADER_UFS_SUPPORT
|
|
|
|
&ufs_fsops,
|
|
|
|
#endif
|
|
|
|
NULL
|
|
|
|
};
|
|
|
|
|
|
|
|
struct console *consoles[] = {
|
|
|
|
&altera_jtag_uart_console,
|
|
|
|
NULL
|
|
|
|
};
|
|
|
|
|
|
|
|
extern void __bss_start, __bss_end;
|
|
|
|
extern void __heap_start, __heap_end;
|
|
|
|
|
|
|
|
static int
|
|
|
|
__elfN(exec)(struct preloaded_file *fp)
|
|
|
|
{
|
|
|
|
|
|
|
|
return (EFTYPE);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Capture arguments from boot2 for later reuse when launching the kernel.
|
|
|
|
* Note that we choose not to maintain a pointer to boo2_bootinfop after
|
|
|
|
* initial argument processing: this is because we might load the kernel over
|
|
|
|
* the spot where boot2 was running, so we can't pass that pointer on to the
|
|
|
|
* kernel. To be on the safe side, never reference it outside of the body of
|
|
|
|
* main(), instead preserving a copy.
|
|
|
|
*/
|
|
|
|
int boot2_argc;
|
|
|
|
char **boot2_argv;
|
|
|
|
char **boot2_envv;
|
|
|
|
|
|
|
|
struct bootinfo boot2_bootinfo;
|
|
|
|
|
|
|
|
int
|
|
|
|
main(int argc, char *argv[], char *envv[], struct bootinfo *bootinfop)
|
|
|
|
{
|
|
|
|
struct devsw **dp;
|
|
|
|
|
|
|
|
/* NB: Must be sure to bzero() before using any globals. */
|
|
|
|
bzero(&__bss_start, (uintptr_t)&__bss_end - (uintptr_t)&__bss_start);
|
|
|
|
|
|
|
|
boot2_argc = argc;
|
|
|
|
boot2_argv = argv;
|
|
|
|
boot2_envv = envv;
|
|
|
|
boot2_bootinfo = *bootinfop; /* Copy rather than by reference. */
|
|
|
|
|
|
|
|
setheap((void *)&__heap_start, (void *)&__heap_end);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Pick up console settings from boot2; probe console.
|
|
|
|
*/
|
|
|
|
if (bootinfop->bi_boot2opts & RB_MULTIPLE) {
|
|
|
|
if (bootinfop->bi_boot2opts & RB_SERIAL)
|
|
|
|
setenv("console", "comconsole vidconsole", 1);
|
|
|
|
else
|
|
|
|
setenv("console", "vidconsole comconsole", 1);
|
|
|
|
} else if (bootinfop->bi_boot2opts & RB_SERIAL)
|
|
|
|
setenv("console", "comconsole", 1);
|
|
|
|
else if (bootinfop->bi_boot2opts & RB_MUTE)
|
|
|
|
setenv("console", "nullconsole", 1);
|
|
|
|
cons_probe();
|
|
|
|
setenv("LINES", "24", 1);
|
|
|
|
|
|
|
|
printf("%s(%d, %p, %p, %p (%p))\n", __func__, argc, argv, envv,
|
|
|
|
bootinfop, (void *)bootinfop->bi_memsize);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Initialise devices.
|
|
|
|
*/
|
|
|
|
for (dp = devsw; *dp != NULL; dp++) {
|
|
|
|
if ((*dp)->dv_init != NULL)
|
|
|
|
(*dp)->dv_init();
|
|
|
|
}
|
|
|
|
extract_currdev(bootinfop);
|
|
|
|
|
2016-12-18 13:57:23 +00:00
|
|
|
printf("\n%s", bootprog_info);
|
Commit a first cut at ports of boot2 and loader to 64-bit MIPS, with a
particular interest in (and support for) SRI International and the
University of Cambridge's BERI FPGA soft-core processor. This includes
micro device drivers for the Altera JTAG UART console, memory-mapped
flash, and the Altera SD Card IP core in both boot2 and loader. boot2
can be written to the on-board Intel StrataFlash on the DE4 board, and
loader can be placed in StrataFlash or the SD Card.
Plenty of XXX comments, but works quite well locally in practice and I
am using it daily. Although I had originally ported the ARM version
of boot2, the current version is x86-derived as that proved more
feature-complete. As we don't currently use partitions on our flash
disks, support for that has been commented out relative to x86, but
would be easy to add back. FDT support has not yet been hooked up,
although some skeleton parts have been put in place for that.
This may well be a useful starting point for ports to other 32-bit and
64-bit MIPS-ISA systems.
This merge is synchronised to CheriBSD github commit
e41d74fd719525d4dd7a7ee499114679165eeaf6, but with some additions of
$FreeBSD.
MFC after: 3 weeks
Sponsored by: DARPA, AFRAL
2014-02-18 23:18:32 +00:00
|
|
|
#if 0
|
|
|
|
printf("bootpath=\"%s\"\n", bootpath);
|
|
|
|
#endif
|
|
|
|
|
2014-07-27 16:12:51 +00:00
|
|
|
interact(NULL);
|
Commit a first cut at ports of boot2 and loader to 64-bit MIPS, with a
particular interest in (and support for) SRI International and the
University of Cambridge's BERI FPGA soft-core processor. This includes
micro device drivers for the Altera JTAG UART console, memory-mapped
flash, and the Altera SD Card IP core in both boot2 and loader. boot2
can be written to the on-board Intel StrataFlash on the DE4 board, and
loader can be placed in StrataFlash or the SD Card.
Plenty of XXX comments, but works quite well locally in practice and I
am using it daily. Although I had originally ported the ARM version
of boot2, the current version is x86-derived as that proved more
feature-complete. As we don't currently use partitions on our flash
disks, support for that has been commented out relative to x86, but
would be easy to add back. FDT support has not yet been hooked up,
although some skeleton parts have been put in place for that.
This may well be a useful starting point for ports to other 32-bit and
64-bit MIPS-ISA systems.
This merge is synchronised to CheriBSD github commit
e41d74fd719525d4dd7a7ee499114679165eeaf6, but with some additions of
$FreeBSD.
MFC after: 3 weeks
Sponsored by: DARPA, AFRAL
2014-02-18 23:18:32 +00:00
|
|
|
return (0);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
extract_currdev(struct bootinfo *bootinfop)
|
|
|
|
{
|
|
|
|
const char *bootdev;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Pick up boot device information from boot2.
|
|
|
|
*
|
|
|
|
* XXXRW: Someday: device units.
|
|
|
|
*/
|
|
|
|
switch(bootinfop->bi_boot_dev_type) {
|
|
|
|
case BOOTINFO_DEV_TYPE_DRAM:
|
|
|
|
bootdev = "dram0";
|
|
|
|
break;
|
|
|
|
|
|
|
|
case BOOTINFO_DEV_TYPE_CFI:
|
|
|
|
bootdev = "cfi0";
|
|
|
|
break;
|
|
|
|
|
|
|
|
case BOOTINFO_DEV_TYPE_SDCARD:
|
|
|
|
bootdev = "sdcard0";
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
bootdev = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (bootdev != NULL) {
|
|
|
|
env_setenv("currdev", EV_VOLATILE, bootdev, NULL, env_nounset);
|
|
|
|
env_setenv("loaddev", EV_VOLATILE, bootdev, env_noset,
|
|
|
|
env_nounset);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
abort(void)
|
|
|
|
{
|
|
|
|
|
|
|
|
printf("error: loader abort\n");
|
|
|
|
while (1);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
exit(int code)
|
|
|
|
{
|
|
|
|
|
|
|
|
printf("error: loader exit\n");
|
|
|
|
while (1);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
longjmperror(void)
|
|
|
|
{
|
|
|
|
|
|
|
|
printf("error: loader longjmp error\n");
|
|
|
|
while (1);
|
|
|
|
}
|
|
|
|
|
|
|
|
time_t
|
|
|
|
time(time_t *tloc)
|
|
|
|
{
|
|
|
|
|
|
|
|
/* We can't provide time since UTC, so just provide time since boot. */
|
|
|
|
return (cp0_count_get() / 100000000);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
2014-05-30 13:53:37 +00:00
|
|
|
* Delay - in usecs
|
|
|
|
*
|
|
|
|
* NOTE: We are assuming that the CPU is running at 100MHz.
|
Commit a first cut at ports of boot2 and loader to 64-bit MIPS, with a
particular interest in (and support for) SRI International and the
University of Cambridge's BERI FPGA soft-core processor. This includes
micro device drivers for the Altera JTAG UART console, memory-mapped
flash, and the Altera SD Card IP core in both boot2 and loader. boot2
can be written to the on-board Intel StrataFlash on the DE4 board, and
loader can be placed in StrataFlash or the SD Card.
Plenty of XXX comments, but works quite well locally in practice and I
am using it daily. Although I had originally ported the ARM version
of boot2, the current version is x86-derived as that proved more
feature-complete. As we don't currently use partitions on our flash
disks, support for that has been commented out relative to x86, but
would be easy to add back. FDT support has not yet been hooked up,
although some skeleton parts have been put in place for that.
This may well be a useful starting point for ports to other 32-bit and
64-bit MIPS-ISA systems.
This merge is synchronised to CheriBSD github commit
e41d74fd719525d4dd7a7ee499114679165eeaf6, but with some additions of
$FreeBSD.
MFC after: 3 weeks
Sponsored by: DARPA, AFRAL
2014-02-18 23:18:32 +00:00
|
|
|
*/
|
|
|
|
void
|
|
|
|
delay(int usecs)
|
|
|
|
{
|
2014-05-30 13:53:37 +00:00
|
|
|
uint32_t delta;
|
|
|
|
uint32_t curr;
|
|
|
|
uint32_t last;
|
|
|
|
|
|
|
|
last = cp0_count_get();
|
|
|
|
while (usecs > 0) {
|
|
|
|
curr = cp0_count_get();
|
|
|
|
delta = curr - last;
|
|
|
|
while (usecs > 0 && delta >= 100) {
|
|
|
|
usecs--;
|
|
|
|
last += 100;
|
|
|
|
delta -= 100;
|
|
|
|
}
|
|
|
|
}
|
Commit a first cut at ports of boot2 and loader to 64-bit MIPS, with a
particular interest in (and support for) SRI International and the
University of Cambridge's BERI FPGA soft-core processor. This includes
micro device drivers for the Altera JTAG UART console, memory-mapped
flash, and the Altera SD Card IP core in both boot2 and loader. boot2
can be written to the on-board Intel StrataFlash on the DE4 board, and
loader can be placed in StrataFlash or the SD Card.
Plenty of XXX comments, but works quite well locally in practice and I
am using it daily. Although I had originally ported the ARM version
of boot2, the current version is x86-derived as that proved more
feature-complete. As we don't currently use partitions on our flash
disks, support for that has been commented out relative to x86, but
would be easy to add back. FDT support has not yet been hooked up,
although some skeleton parts have been put in place for that.
This may well be a useful starting point for ports to other 32-bit and
64-bit MIPS-ISA systems.
This merge is synchronised to CheriBSD github commit
e41d74fd719525d4dd7a7ee499114679165eeaf6, but with some additions of
$FreeBSD.
MFC after: 3 weeks
Sponsored by: DARPA, AFRAL
2014-02-18 23:18:32 +00:00
|
|
|
}
|