Commit b9f137f4 authored by Evan Lojewski's avatar Evan Lojewski

bios: Pull in latest bios code from upstream litex.

parent 12c5e24a
......@@ -71,7 +71,7 @@ SET(SOURCE
ppc64le_add_executable(${PROJECT_NAME} ${SOURCE})
ppc64le_generate_init(${PROJECT_NAME})
ppc64le_linker_script(${PROJECT_NAME} "${CMAKE_CURRENT_SOURCE_DIR}/linker.ld")
target_link_libraries(${PROJECT_NAME} PRIVATE liblitedram libbase-nofloat libliteeth liblitespi liblitesdcard libfatfs)
target_link_libraries(${PROJECT_NAME} PRIVATE liblitedram libbase-nofloat libliteeth liblitespi liblitesdcard liblitesata libfatfs)
target_include_directories(${PROJECT_NAME} PUBLIC include)
target_compile_definitions(${PROJECT_NAME} PRIVATE "-DTERM_NO_HIST")
......
This diff is collapsed.
#ifndef __BOOT_H
#define __BOOT_H
void set_local_ip(const char * ip_address);
void set_remote_ip(const char * ip_address);
void set_mac_addr(const char * mac_address);
void __attribute__((noreturn)) boot(unsigned long r1, unsigned long r2, unsigned long r3, void *addr);
int serialboot(void);
void netboot(void);
void flashboot(void);
void romboot(void);
void sdcardboot(void);
void sataboot(void);
#endif /* __BOOT_H */
......@@ -30,7 +30,7 @@ static void help_handler(int nb_params, char **params)
{
if ((*cmd)->group == i)
{
printf("%-16s - %s\n", (*cmd)->name, (*cmd)->help ? (*cmd)->help : "-");
printf("%-24s - %s\n", (*cmd)->name, (*cmd)->help ? (*cmd)->help : "-");
not_empty = 1;
}
}
......@@ -41,7 +41,7 @@ static void help_handler(int nb_params, char **params)
}
}
define_command(help, help_handler, "Print this help", MISC_CMDS);
define_command(help, help_handler, "Print this help", SYSTEM_CMDS);
/**
* Command "ident"
......@@ -49,7 +49,7 @@ define_command(help, help_handler, "Print this help", MISC_CMDS);
* Identifier of the system
*
*/
static void ident_helper(int nb_params, char **params)
static void ident_handler(int nb_params, char **params)
{
char buffer[IDENT_SIZE];
......@@ -57,22 +57,7 @@ static void ident_helper(int nb_params, char **params)
printf("Ident: %s", *buffer ? buffer : "-");
}
define_command(ident, ident_helper, "Identifier of the system", SYSTEM_CMDS);
/**
* Command "reboot"
*
* Reboot the system
*
*/
#ifdef CSR_CTRL_RESET_ADDR
static void reboot(int nb_params, char **params)
{
ctrl_reset_write(1);
}
define_command(reboot, reboot, "Reboot the system", SYSTEM_CMDS);
#endif
define_command(ident, ident_handler, "Identifier of the system", SYSTEM_CMDS);
/**
* Command "uptime"
......@@ -81,7 +66,7 @@ define_command(reboot, reboot, "Reboot the system", SYSTEM_CMDS);
*
*/
#ifdef CSR_TIMER0_UPTIME_CYCLES_ADDR
static void uptime(int nb_params, char **params)
static void uptime_handler(int nb_params, char **params)
{
unsigned long uptime;
......@@ -90,7 +75,7 @@ static void uptime(int nb_params, char **params)
printf("Uptime: %ld sys_clk cycles / %ld seconds", uptime, uptime / CONFIG_CLOCK_FREQUENCY);
}
define_command(uptime, uptime, "Uptime of the system since power-up", SYSTEM_CMDS);
define_command(uptime, uptime_handler, "Uptime of the system since power-up", SYSTEM_CMDS);
#endif
/**
......@@ -99,11 +84,11 @@ define_command(uptime, uptime, "Uptime of the system since power-up", SYSTEM_CMD
* Compute CRC32 over an address range
*
*/
static void crc(int nb_params, char **params)
static void crc_handler(int nb_params, char **params)
{
char *c;
unsigned long addr;
unsigned long length;
uintptr_t addr;
size_t length;
if (nb_params < 2)
{
......@@ -128,7 +113,7 @@ static void crc(int nb_params, char **params)
printf("CRC32: %08x", crc32((unsigned char *)addr, length));
}
define_command(crc, crc, "Compute CRC32 of a part of the address space", MISC_CMDS);
define_command(crc, crc_handler, "Compute CRC32 of a part of the address space", SYSTEM_CMDS);
/**
* Command "flush_cpu_dcache"
......@@ -137,7 +122,7 @@ define_command(crc, crc, "Compute CRC32 of a part of the address space", MISC_CM
*
*/
define_command(flush_cpu_dcache, flush_cpu_dcache, "Flush CPU data cache", CACHE_CMDS);
define_command(flush_cpu_dcache, flush_cpu_dcache, "Flush CPU data cache", SYSTEM_CMDS);
/**
* Command "flush_l2_cache"
......@@ -146,5 +131,80 @@ define_command(flush_cpu_dcache, flush_cpu_dcache, "Flush CPU data cache", CACHE
*
*/
#ifdef CONFIG_L2_SIZE
define_command(flush_l2_cache, flush_l2_cache, "Flush L2 cache", CACHE_CMDS);
define_command(flush_l2_cache, flush_l2_cache, "Flush L2 cache", SYSTEM_CMDS);
#endif
/**
* Command "leds"
*
* Set Leds value
*
*/
#ifdef CSR_LEDS_BASE
static void leds_handler(int nb_params, char **params)
{
char *c;
unsigned int value;
if (nb_params < 1)
{
printf("leds <value>");
return;
}
value = strtoul(params[0], &c, 0);
if (*c != 0)
{
printf("Incorrect value");
return;
}
printf("Settings Leds to 0x%x", value);
leds_out_write(value);
}
define_command(leds, leds_handler, "Set Leds value", SYSTEM_CMDS);
#endif
/**
* Command "trace"
*
* Start/stop simulation trace dump.
*
*/
#ifdef CSR_SIM_TRACE_BASE
static void cmd_sim_trace_handler(int nb_params, char **params)
{
sim_trace(!sim_trace_enable_read());
}
define_command(trace, cmd_sim_trace_handler, "Toggle simulation tracing", SYSTEM_CMDS);
#endif
/**
* Command "finish"
*
* Finish simulation.
*
*/
#ifdef CSR_SIM_FINISH_BASE
static void cmd_sim_finish_handler(int nb_params, char **params)
{
sim_finish();
}
define_command(finish, cmd_sim_finish_handler, "Finish simulation", SYSTEM_CMDS);
#endif
/**
* Command "mark"
*
* Set a debug marker value
*
*/
#ifdef CSR_SIM_MARKER_BASE
static void cmd_sim_mark_handler(int nb_params, char **params)
{
// cannot use param[1] as it is not a const string
sim_mark(NULL);
}
define_command(mark, cmd_sim_mark_handler, "Set a debug simulation marker", SYSTEM_CMDS);
#endif
......@@ -8,6 +8,81 @@
#include <stdio.h>
#include <stdlib.h>
/**
* Command "boot"
*
* Boot software from system memory
*
*/
static void boot_handler(int nb_params, char **params)
{
char *c;
void *addr;
unsigned long r1;
unsigned long r2;
unsigned long r3;
if (nb_params < 1)
{
printf("boot <address> [r1] [r2] [r3]");
return;
}
addr = (void *)(uintptr_t)strtoul(params[0], &c, 0);
if (*c != 0)
{
printf("Incorrect address");
return;
}
r1 = 0;
if (nb_params > 1)
{
r1 = strtoul(params[1], &c, 0);
if (*c != 0)
{
printf("Incorrect r1");
return;
}
}
r2 = 0;
if (nb_params > 2)
{
r2 = strtoul(params[2], &c, 0);
if (*c != 0)
{
printf("Incorrect r2");
return;
}
}
r3 = 0;
if (nb_params > 3)
{
r2 = strtoul(params[3], &c, 0);
if (*c != 0)
{
printf("Incorrect r3");
return;
}
}
boot(r1, r2, r3, addr);
}
define_command(boot, boot_handler, "Boot from Memory", BOOT_CMDS);
/**
* Command "reboot"
*
* Reboot the system
*
*/
#ifdef CSR_CTRL_RESET_ADDR
static void reboot_handler(int nb_params, char **params)
{
ctrl_reset_write(1);
}
define_command(reboot, reboot_handler, "Reboot", BOOT_CMDS);
#endif
/**
* Command "flashboot"
*
......@@ -34,7 +109,9 @@ define_command(romboot, romboot, "Boot from ROM", BOOT_CMDS);
* Boot software from serial interface
*
*/
#ifdef CSR_UART_BASE
define_command(serialboot, serialboot, "Boot from Serial (SFL)", BOOT_CMDS);
#endif
/**
* Command "netboot"
......@@ -55,3 +132,13 @@ define_command(netboot, netboot, "Boot via Ethernet (TFTP)", BOOT_CMDS);
#if defined(CSR_SPISDCARD_BASE) || defined(CSR_SDCORE_BASE)
define_command(sdcardboot, sdcardboot, "Boot from SDCard", BOOT_CMDS);
#endif
/**
* Command "sataboot"
*
* Boot software from SATA
*
*/
#if defined(CSR_SATA_SECTOR2MEM_BASE)
define_command(sataboot, sataboot, "Boot from SATA", BOOT_CMDS);
#endif
......@@ -10,23 +10,23 @@
#include <stdlib.h>
/**
* Command "i2creset"
* Command "i2c_reset"
*
* Reset I2C line state in case a slave locks the line.
*
*/
#ifdef CSR_I2C_BASE
define_command(i2creset, i2c_reset, "Reset I2C line state", I2C_CMDS);
define_command(i2c_reset, i2c_reset, "Reset I2C line state", I2C_CMDS);
#endif
/**
* Command "i2cwr"
* Command "i2c_write"
*
* Write I2C slave memory using 7-bit slave address and 8-bit memory address.
*
*/
#ifdef CSR_I2C_BASE
static void i2cwr_handler(int nb_params, char **params)
static void i2c_write_handler(int nb_params, char **params)
{
int i;
char *c;
......@@ -34,13 +34,13 @@ static void i2cwr_handler(int nb_params, char **params)
if (nb_params < 2)
{
printf("i2cwr <slaveaddr7bit> <addr> [<data>, ...]");
printf("i2c_write <slaveaddr7bit> <addr> [<data>, ...]");
return;
}
if (nb_params - 1 > sizeof(write_params))
{
printf("Max data length is %d", sizeof(write_params));
printf("Max data length is %zu", sizeof(write_params));
return;
}
......@@ -60,17 +60,17 @@ static void i2cwr_handler(int nb_params, char **params)
return;
}
}
define_command(i2cwr, i2cwr_handler, "Write over I2C", I2C_CMDS);
define_command(i2c_write, i2c_write_handler, "Write over I2C", I2C_CMDS);
#endif
/**
* Command "i2crd"
* Command "i2c_read"
*
* Read I2C slave memory using 7-bit slave address and 8-bit memory address.
*
*/
#ifdef CSR_I2C_BASE
static void i2crd_handler(int nb_params, char **params)
static void i2c_read_handler(int nb_params, char **params)
{
char *c;
int len;
......@@ -80,7 +80,7 @@ static void i2crd_handler(int nb_params, char **params)
if (nb_params < 3)
{
printf("i2crd <slaveaddr7bit> <addr> <len> [<send_stop>]");
printf("i2c_read <slaveaddr7bit> <addr> <len> [<send_stop>]");
return;
}
......@@ -106,7 +106,7 @@ static void i2crd_handler(int nb_params, char **params)
}
if (len > sizeof(buf))
{
printf("Max data count is %d", sizeof(buf));
printf("Max data count is %zu", sizeof(buf));
return;
}
......@@ -128,5 +128,37 @@ static void i2crd_handler(int nb_params, char **params)
dump_bytes((unsigned int *)buf, len, addr);
}
define_command(i2crd, i2crd_handler, "Read over I2C", I2C_CMDS);
define_command(i2c_read, i2c_read_handler, "Read over I2C", I2C_CMDS);
#endif
/**
* Command "i2c_scan"
*
* Scan for available I2C devices
*
*/
#ifdef CSR_I2C_BASE
static void i2c_scan_handler(int nb_params, char **params)
{
int slave_addr;
printf(" 0 1 2 3 4 5 6 7 8 9 a b c d e f");
for (slave_addr = 0; slave_addr < 0x80; slave_addr++)
{
if (slave_addr % 0x10 == 0)
{
printf("\n0x%02x:", slave_addr & 0x70);
}
if (i2c_poll(slave_addr))
{
printf(" %02x", slave_addr);
}
else
{
printf(" --");
}
}
printf("\n");
}
define_command(i2c_scan, i2c_scan_handler, "Scan for I2C slaves", I2C_CMDS);
#endif
// SPDX-License-Identifier: BSD-Source-Code
#include "../boot.h"
#include "../command.h"
#include "../helpers.h"
#include <generated/csr.h>
#include <generated/soc.h>
#include <libliteeth/mdio.h>
#include <stdio.h>
#include <stdlib.h>
/**
* Command "mdiow"
* Command "mdio_write"
*
* Write MDIO register
*
*/
#ifdef CSR_ETHPHY_MDIO_W_ADDR
static void mdiow(int nb_params, char **params)
static void mdio_write_handler(int nb_params, char **params)
{
char *c;
unsigned int phyadr2;
......@@ -24,7 +26,7 @@ static void mdiow(int nb_params, char **params)
if (nb_params < 3)
{
printf("mdiow <phyadr> <reg> <value>");
printf("mdio_write <phyadr> <reg> <value>");
return;
}
......@@ -49,20 +51,21 @@ static void mdiow(int nb_params, char **params)
return;
}
printf("MDIO write @0x%x: 0x%02x 0x%04x\n", phyadr2, reg2, val2);
mdio_write(phyadr2, reg2, val2);
}
define_command(mdiow, mdiow, "Write MDIO register", LITEETH_CMDS);
define_command(mdio_write, mdio_write_handler, "Write MDIO register", LITEETH_CMDS);
#endif
/**
* Command "mdior"
* Command "mdio_read"
*
* Read MDIO register
*
*/
#ifdef CSR_ETHPHY_MDIO_W_ADDR
static void mdior(int nb_params, char **params)
static void mdio_read_handler(int nb_params, char **params)
{
char *c;
unsigned int phyadr2;
......@@ -89,21 +92,22 @@ static void mdior(int nb_params, char **params)
return;
}
printf("MDIO read @0x%x:\n", phyadr2);
val = mdio_read(phyadr2, reg2);
printf("Reg %d: 0x%04x", reg2, val);
printf("0x%02x 0x%04x", reg2, val);
}
define_command(mdior, mdior, "Read MDIO register", LITEETH_CMDS);
define_command(mdio_read, mdio_read_handler, "Read MDIO register", LITEETH_CMDS);
#endif
/**
* Command "mdiod"
* Command "mdio_dump"
*
* Dump MDIO registers
*
*/
#ifdef CSR_ETHPHY_MDIO_W_ADDR
static void mdiod(int nb_params, char **params)
static void mdio_dump_handler(int nb_params, char **params)
{
char *c;
unsigned int phyadr;
......@@ -135,9 +139,69 @@ static void mdiod(int nb_params, char **params)
for (i = 0; i < count; i++)
{
val = mdio_read(phyadr, i);
printf("reg %d: 0x%04x", i, val);
printf("0x%02x 0x%04x\n", i, val);
}
}
define_command(mdiod, mdiod, "Dump MDIO registers", LITEETH_CMDS);
define_command(mdio_dump, mdio_dump_handler, "Dump MDIO registers", LITEETH_CMDS);
#endif
/**
* Command "eth_local_ip"
*
* Set local ip
*
*/
#ifdef ETH_DYNAMIC_IP
static void eth_local_ip_handler(int nb_params, char **params)
{
if (nb_params < 1)
{
printf("eth_local_ip <address>");
return;
}
set_local_ip(params[0]);
}
define_command(eth_local_ip, eth_local_ip_handler, "Set the local ip address", LITEETH_CMDS);
#endif
/**
* Command "eth_remote_ip"
*
* Set remote ip.
*
*/
#ifdef ETH_DYNAMIC_IP
static void eth_remote_ip_handler(int nb_params, char **params)
{
if (nb_params < 1)
{
printf("eth_remote_ip <address>");
return;
}
set_remote_ip(params[0]);
}
define_command(eth_remote_ip, eth_remote_ip_handler, "Set the remote ip address", LITEETH_CMDS);
#endif
/**
* Command "eth_mac_addr"
*
* Set mac address.
*
*/
#ifdef ETH_DYNAMIC_IP
static void eth_mac_addr_handler(int nb_params, char **params)
{
if (nb_params < 1)
{
printf("eth_mac_addr <address>");
return;
}
set_mac_addr(params[0]);
}
define_command(eth_mac_addr, eth_mac_addr_handler, "Set the mac address", LITEETH_CMDS);
#endif
// SPDX-License-Identifier: BSD-Source-Code
#include <stdio.h>
#include <stdlib.h>
#include <generated/csr.h>
#include <liblitesata/sata.h>
#include "../command.h"
#include "../helpers.h"
/**
* Command "sata_init"
*
* Initialize SATA
*
*/
#ifdef CSR_SATA_PHY_BASE
static void sata_init_handler(int nb_params, char **params)
{
printf("Initialize SATA... ");
if (sata_init())
printf("Successful.\n");
else
printf("Failed.\n");
}
define_command(sata_init, sata_init_handler, "Initialize SATA", LITESATA_CMDS);
#endif
/**
* Command "sata_read"
*
* Perform SATA sector read
*
*/
#ifdef CSR_SATA_SECTOR2MEM_BASE
static void sata_read_handler(int nb_params, char **params)
{
unsigned int sector;
char *c;
uint8_t buf[512];
if (nb_params < 1) {
printf("sata_read <sector>");
return;
}
sector = strtoul(params[0], &c, 0);
if (*c != 0) {
printf("Incorrect sector number");
return;
}
sata_read(sector, 1, buf);
dump_bytes((uint32_t *)buf, 512, (unsigned long) buf);
}
define_command(sata_read, sata_read_handler, "Read SATA sector", LITESATA_CMDS);
#endif
/**
* Command "sata_write"
*
* Perform SATA sector write
*
*/
#ifdef CSR_SATA_MEM2SECTOR_BASE
static void sata_write_handler(int nb_params, char **params)
{
int i;
uint8_t buf[512];
unsigned int sector;
char *c;
if (nb_params < 2) {
printf("sata_write <sector> <str>");
return;
}
sector = strtoul(params[0], &c, 0);
if (*c != 0) {
printf("Incorrect sector number");
return;
}
c = params[1];
if (params[1] != NULL) {
for(i=0; i<512; i++) {
buf[i] = *c;
if(*(++c) == 0) {
c = params[1];
}
}
}
dump_bytes((uint32_t *)buf, 512, (unsigned long) buf);
sata_write(sector, 1, buf);
}
define_command(sata_write, sata_write_handler, "Write SATA sector", LITESATA_CMDS);
#endif
......@@ -9,23 +9,82 @@
#include <stdlib.h>
/**
* Command "sdinit"
* Command "sdcard_detect"
*
* Detect SDcard
*
*/
#ifdef CSR_SDPHY_BASE
static void sdcard_detect_handler(int nb_params, char **params)
{
uint8_t cd = sdphy_card_detect_read();
printf("SDCard %sinserted.\n", cd ? "not " : "");
}
define_command(sdcard_detect, sdcard_detect_handler, "Detect SDCard", LITESDCARD_CMDS);
#endif
/**
* Command "sdcard_init"
*
* Initialize SDcard
*
*/
#ifdef CSR_SDCORE_BASE
define_command(sdinit, sdcard_init, "Initialize SDCard", LITESDCARD_CMDS);
static void sdcard_init_handler(int nb_params, char **params)
{
printf("Initialize SDCard... ");
if (sdcard_init())
{
printf("Successful.\n");
}
else
{
printf("Failed.\n");
}
}
define_command(sdcard_init, sdcard_init_handler, "Initialize SDCard", LITESDCARD_CMDS);
#endif
/**
* Command "sdcard_freq"
*
* Set SDcard clock frequency
*
*/