Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions payloads/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ config PAYLOAD_ELF

config PAYLOAD_FIT
bool "A FIT payload"
depends on ARCH_ARM64 || ARCH_RISCV || ARCH_ARM
depends on ARCH_ARM64 || ARCH_RISCV || ARCH_ARM || ARCH_PPC64
select PAYLOAD_FIT_SUPPORT
help
Select this option if you have a payload image (a FIT file) which
Expand Down Expand Up @@ -96,8 +96,8 @@ config PAYLOAD_IS_FLAT_BINARY
config PAYLOAD_FIT_SUPPORT
bool "FIT support"
default n
default y if PAYLOAD_LINUX && (ARCH_ARM || ARCH_ARM64 || ARCH_RISCV)
depends on ARCH_ARM64 || ARCH_RISCV || ARCH_ARM
default y if PAYLOAD_LINUX && (ARCH_ARM || ARCH_ARM64 || ARCH_RISCV || ARCH_PPC64)
depends on ARCH_ARM64 || ARCH_RISCV || ARCH_ARM || ARCH_PPC64
select FLATTENED_DEVICE_TREE
help
Select this option if your payload is of type FIT.
Expand Down
1 change: 1 addition & 0 deletions payloads/Makefile.inc
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ payloads/external/tianocore \
payloads/external/GRUB2 \
payloads/external/LinuxBoot \
payloads/external/Yabits \
payloads/external/skiboot

force-payload:

Expand Down
5 changes: 5 additions & 0 deletions payloads/external/Makefile.inc
Original file line number Diff line number Diff line change
Expand Up @@ -324,3 +324,8 @@ payloads/external/Yabits/uefi/build/uefi.elf yabits:

payloads/external/BOOTBOOT/bootboot/dist/bootbootcb.elf:
$(MAKE) -C payloads/external/BOOTBOOT all

# skiboot

payloads/external/skiboot/talos-skiboot/skiboot.lid:
$(MAKE) -C payloads/external/skiboot all
16 changes: 16 additions & 0 deletions payloads/external/skiboot/Kconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
## SPDX-License-Identifier: GPL-2.0-only

if PAYLOAD_SKIBOOT

config PAYLOAD_FILE
default "payloads/external/skiboot/talos-skiboot/skiboot.lid"

config PAYLOAD_SPECIFIC_OPTIONS
def_bool y
select PAYLOAD_IS_FLAT_BINARY
select PAYLOAD_FIT_SUPPORT

config PAYLOAD_OPTIONS
default "-l 0x100000 -e 0x100010"

endif #PAYLOAD_SKIBOOT
8 changes: 8 additions & 0 deletions payloads/external/skiboot/Kconfig.name
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
## SPDX-License-Identifier: GPL-2.0-only

config PAYLOAD_SKIBOOT
bool "skiboot"
depends on ARCH_PPC64
help
Select this option if you want to build a coreboot image
with a skiboot payload.
26 changes: 26 additions & 0 deletions payloads/external/skiboot/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
## SPDX-License-Identifier: GPL-2.0-only

skiboot_dir=$(CURDIR)/talos-skiboot
skiboot_git_repo=https://git.raptorcs.com/git/talos-skiboot
skiboot_revision=9858186353f2203fe477f316964e03609d12fd1d

unexport $(COREBOOT_EXPORTS)

all: $(skiboot_dir)
cd $(skiboot_dir) && $(MAKE) -j`nproc` CROSS=powerpc64-linux-gnu- DEBUG=1
# $(error BUILDING SKIBOOT)

clean:
rm -rf $(skiboot_dir)
#$(MAKE) -C $(skiboot_dir) CROSS=powerpc64-linux-gnu- distclean

distclean:
rm -rf $(skiboot_dir)

$(skiboot_dir):
echo " Cloning $(project_name) from Git"
git clone $(skiboot_git_repo) $(skiboot_dir)
echo " Checking out $(skiboot_revision)"
cd $(skiboot_dir) && git checkout $(skiboot_revision)


40 changes: 40 additions & 0 deletions payloads/external/skiboot/config.its
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
/dts-v1/;
/ {
description = "Simple image with skiboot and FDT blob";
#address-cells = <1>;

images {
kernel {
description = "skiboot";
data = /incbin/("skiboot.lid");
type = "kernel";
arch = "powerpc";
compression = "none";
load = <0x00000>;
entry = <0x10>;
hash-1 {
algo = "crc32";
};
};
fdt-1 {
description = "Flattened Device Tree blob";
data = /incbin/("fdt.bin");
type = "flat_dt";
arch = "powerpc";
compression = "none";
load = <0x1000000>;
hash-1 {
algo = "crc32";
};
};
};

configurations {
default = "conf-1";
conf-1 {
description = "Boot skiboot with FDT blob";
kernel = "kernel";
fdt = "fdt-1";
};
};
};
176 changes: 176 additions & 0 deletions src/arch/ppc64/boot.c
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,185 @@

#include <program_loading.h>

#if ENV_PAYLOAD_LOADER

#include <device_tree.h>
#include <fit.h>
#include <commonlib/stdlib.h>

/* Empty FDT */
static uint32_t fdt_buf[100*1024] =
{
FDT_HEADER_MAGIC, /* uint32_t magic; */
sizeof(struct fdt_header), /* uint32_t totalsize; */
sizeof(struct fdt_header), /* uint32_t structure_offset; */
sizeof(struct fdt_header), /* uint32_t strings_offset; */
sizeof(struct fdt_header), /* uint32_t reserve_map_offset; */

FDT_SUPPORTED_VERSION, /* uint32_t version; */
16, /* uint32_t last_comp_version; */

4, /* uint32_t boot_cpuid_phys; */

0, /* uint32_t strings_size; */
0, /* uint32_t structure_size; */
};

static uint8_t xscom_compat[] = "ibm,xscom\0ibm,power9-xscom\0";
static uint64_t xscom_addrs[] = { 0x000603fc00000000 };
static uint64_t xscom_sizes[] = { 0x0000000800000000 };
static uint8_t chiptod_compat[] = "ibm,power9-chiptod\0ibm,power-chiptod\0";
static uint64_t chiptod_addrs[] = { 0x40000 };
static uint64_t chiptod_sizes[] = { 0x34 };
static uint64_t cpu_addrs[] = { 0x4, 0xc, 0x10, 0x1c };
static uint8_t lpcm_compat[] = "ibm,power9-lpcm-opb\0simple-bus\0";
static uint64_t lpcm_addrs[] = { 0x0006030000000000 };
static uint64_t lpcm_sizes[] = { 0x0000000100000000 };
static uint32_t lpcm_ranges[] = { 0x00, 0x60300, 0x00, 0x80000000, 0x80000000,
0x60300, 0x80000000, 0x80000000 };
static uint8_t lpc_compat[] = "ibm,power9-lpc\0ibm,power8-lpc\0";
static uint64_t serial_addrs[] = { 0x00000001000003f8 };
static uint64_t serial_sizes[] = { 1 };

static void *fdt_prepare(void)
{
struct device_tree *dt = fdt_unflatten(&fdt_buf[0]);
struct device_tree_node *node, *subnode, *subsubnode;

fit_update_memory(dt);

dt_add_u32_prop(dt->root, "#address-cells", 2);
dt_add_u32_prop(dt->root, "#size-cells", 2);


node = xzalloc(sizeof(*node));
node->name = "xscom"; /* FIXME: shall include the unit address */
dt_add_bin_prop(node, "primary", NULL, 0);
dt_add_reg_prop(node, xscom_addrs, xscom_sizes, 1, 2, 2);
dt_add_u32_prop(node, "#address-cells", 1);
dt_add_u32_prop(node, "#size-cells", 1);
//~ dt_add_u32_prop(node, "primary", 0);
dt_add_u32_prop(node, "ibm,chip-id", 0 /* FIXME for second CPU */);
dt_add_bin_prop(node, "compatible", xscom_compat, sizeof(xscom_compat));
list_insert_after(&node->list_node, &dt->root->children);

subnode = xzalloc(sizeof(*subnode));
subnode->name = "chiptod";
dt_add_bin_prop(subnode, "primary", NULL, 0);
dt_add_reg_prop(subnode, chiptod_addrs, chiptod_sizes, 1, 1, 1);
dt_add_bin_prop(subnode, "compatible", chiptod_compat, sizeof(chiptod_compat));
list_insert_after(&subnode->list_node, &node->children);


node = xzalloc(sizeof(*node));
node->name = "cpus";
dt_add_u32_prop(node, "#address-cells", 1);
dt_add_u32_prop(node, "#size-cells", 0);
list_insert_after(&node->list_node, &dt->root->children);

subnode = xzalloc(sizeof(*subnode));
subnode->name = "PowerPC,POWER9@4";
dt_add_reg_prop(subnode, &cpu_addrs[0], NULL, 1, 1, 0);
dt_add_string_prop(subnode, "device_type", (char *)"cpu");
dt_add_string_prop(subnode, "status", (char *)"okay");
dt_add_u32_prop(subnode, "ibm,chip-id", 0 /* FIXME for second CPU */);
dt_add_u32_prop(subnode, "clock-frequency", 0xa0eebb00); /* 512MHz */
dt_add_u32_prop(subnode, "timebase-frequency", 0x1e848000); /* 2.7GHz */
list_insert_after(&subnode->list_node, &node->children);

subnode = xzalloc(sizeof(*subnode));
subnode->name = "PowerPC,POWER9@c";
dt_add_reg_prop(subnode, &cpu_addrs[1], NULL, 1, 1, 0);
dt_add_string_prop(subnode, "device_type", (char *)"cpu");
dt_add_string_prop(subnode, "status", (char *)"disabled");
dt_add_u32_prop(subnode, "ibm,chip-id", 0 /* FIXME for second CPU */);
dt_add_u32_prop(subnode, "clock-frequency", 0xa0eebb00); /* 512MHz */
dt_add_u32_prop(subnode, "timebase-frequency", 0x1e848000); /* 2.7GHz */
list_insert_after(&subnode->list_node, &node->children);

subnode = xzalloc(sizeof(*subnode));
subnode->name = "PowerPC,POWER9@10";
dt_add_reg_prop(subnode, &cpu_addrs[2], NULL, 1, 1, 0);
dt_add_string_prop(subnode, "device_type", (char *)"cpu");
dt_add_string_prop(subnode, "status", (char *)"disabled");
dt_add_u32_prop(subnode, "ibm,chip-id", 0 /* FIXME for second CPU */);
dt_add_u32_prop(subnode, "clock-frequency", 0xa0eebb00); /* 512MHz */
dt_add_u32_prop(subnode, "timebase-frequency", 0x1e848000); /* 2.7GHz */
list_insert_after(&subnode->list_node, &node->children);

subnode = xzalloc(sizeof(*subnode));
subnode->name = "PowerPC,POWER9@1c";
dt_add_reg_prop(subnode, &cpu_addrs[3], NULL, 1, 1, 0);
dt_add_string_prop(subnode, "device_type", (char *)"cpu");
dt_add_string_prop(subnode, "status", (char *)"disabled");
dt_add_u32_prop(subnode, "ibm,chip-id", 0 /* FIXME for second CPU */);
dt_add_u32_prop(subnode, "clock-frequency", 0xa0eebb00); /* 512MHz */
dt_add_u32_prop(subnode, "timebase-frequency", 0x1e848000); /* 2.7GHz */
list_insert_after(&subnode->list_node, &node->children);


node = xzalloc(sizeof(*node));
node->name = "lpcm-opb";
dt_add_reg_prop(node, lpcm_addrs, lpcm_sizes, 1, 2, 2);
dt_add_u32_prop(node, "#address-cells", 1);
dt_add_u32_prop(node, "#size-cells", 1);
dt_add_bin_prop(node, "compatible", lpcm_compat, sizeof(lpcm_compat));
dt_add_bin_prop(node, "ranges", lpcm_ranges, sizeof(lpcm_ranges));
dt_add_u32_prop(node, "ibm,chip-id", 0 /* FIXME for second CPU */);
list_insert_after(&node->list_node, &dt->root->children);

subnode = xzalloc(sizeof(*subnode));
subnode->name = "lpc";
dt_add_u32_prop(subnode, "#address-cells", 2);
dt_add_u32_prop(subnode, "#size-cells", 1);
dt_add_bin_prop(subnode, "compatible", lpc_compat, sizeof(lpc_compat));
list_insert_after(&subnode->list_node, &node->children);

subsubnode = xzalloc(sizeof(*subnode));
subsubnode->name = "serial";
dt_add_reg_prop(subsubnode, serial_addrs, serial_sizes, 1, 2, 1);
dt_add_string_prop(subsubnode, "device_type", (char *)"serial");
dt_add_string_prop(subsubnode, "compatible", (char *)"ns16550");
dt_add_u32_prop(subsubnode, "clock-frequency", 0x1c2000); /* 512MHz */
dt_add_u32_prop(subsubnode, "current-speed", 0x1c200); /* 2.7GHz */
list_insert_after(&subsubnode->list_node, &subnode->children);


/* Adding 'bmc' node significantly changes skiboot's flow */
node = xzalloc(sizeof(*node));
node->name = "bmc";
dt_add_string_prop(subsubnode, "compatible", (char *)"ibm,ast2500,openbmc");
list_insert_after(&node->list_node, &dt->root->children);


dt_apply_fixups(dt);

/* Repack FDT for handoff to kernel */
dt_flatten(dt, &fdt_buf[0]);

return &fdt_buf[0];
}

/*
* Payload's entry point is an offset to the real entry point, not to OPD
* (Official Procedure Descriptor) for entry point.
*/
void arch_prog_run(struct prog *prog)
{
asm volatile(
"mtctr %1\n"
"mr 3, %0\n"
"bctr\n"
:: "r"(fdt_prepare()), "r"(prog_entry(prog)) : "memory");
}

#else

void arch_prog_run(struct prog *prog)
{
void (*doit)(void *) = prog_entry(prog);

doit(prog_entry_arg(prog));
}

#endif
4 changes: 2 additions & 2 deletions src/arch/ppc64/stages.c
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ bool fit_payload_arch(struct prog *payload, struct fit_config_node *config,

/* Place FDT */
/* TODO: remove hardcoded size */
fdt->offset = 0xf0000000;
fdt->offset = 0xfe000000;
fdt->size = 318539;

/* Mark as reserved for future allocations. */
Expand All @@ -68,7 +68,7 @@ bool fit_payload_arch(struct prog *payload, struct fit_config_node *config,
/* Kernel expects FDT as argument */
arg = (void *)fdt->offset;

prog_set_entry(payload, (void *)0x10 /* kernel->offset + 0x10 ? */, arg);
prog_set_entry(payload, (void *)(kernel->offset + 0x10), arg);

bootmem_dump_ranges();

Expand Down
2 changes: 1 addition & 1 deletion src/lib/fit_payload.c
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ void fit_payload(struct prog *payload, void *data)
#if defined(CONFIG_LINUX_COMMAND_LINE)
fit_update_chosen(dt, (char *)CONFIG_LINUX_COMMAND_LINE);
#endif
fit_update_memory(dt);
//~ fit_update_memory(dt);

/* Collect infos for fit_payload_arch */
kernel.size = config->kernel->size;
Expand Down
40 changes: 38 additions & 2 deletions src/mainboard/raptor-cs/talos-2/mainboard.c
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,31 @@
#include <device/device.h>
#include <cbmem.h>

#include <fit.h>
#include <console/console.h>

static int dt_platform_fixup(struct device_tree_fixup *fixup,
struct device_tree *tree)
{
struct device_tree_node *node;
//~ uint32_t i = 0x44;

printk(BIOS_ERR, "dt_platform_fixup called **************************\n");

/* Memory devices are always direct children of root */
list_for_each(node, tree->root->children, list_node) {
const char *devtype = dt_find_string_prop(node, "device_type");
if (devtype && !strcmp(devtype, "memory")) {
dt_add_u32_prop(node, "ibm,chip-id", 0 /* FIXME for second CPU */);
}
}

dt_print_node(tree->root);

printk(BIOS_ERR, "dt_platform_fixup exiting **************************\n");
return 0;
}

static void mainboard_enable(struct device *dev)
{

Expand All @@ -19,8 +44,19 @@ static void mainboard_enable(struct device *dev)
*
* TODO: implement this properly for all RAM
*/
ram_resource(dev, 0, 0, 4 * 1024 * 1024 - 128 * 1024);
reserved_ram_resource(dev, 1, 4 * 1024 * 1024 - 128 * 1024, 128 * 1024);
ram_resource(dev, 0, 0, 4 * 1024 * 1024 - 256 * 1024);
reserved_ram_resource(dev, 1, 4 * 1024 * 1024 - 256 * 1024, 256 * 1024);

if (CONFIG(PAYLOAD_FIT_SUPPORT)) {
struct device_tree_fixup *dt_fixup;

dt_fixup = malloc(sizeof(*dt_fixup));
if (dt_fixup) {
dt_fixup->fixup = dt_platform_fixup;
list_insert_after(&dt_fixup->list_node,
&device_tree_fixups);
}
}
}

struct chip_operations mainboard_ops = {
Expand Down
Loading