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
63 changes: 63 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
name: xuantie-mainline-opensbi

on:
push:
pull_request:
workflow_dispatch:
schedule:
- cron: "0 2 * * *"

env:
xuantie_toolchain: https://occ-oss-prod.oss-cn-hangzhou.aliyuncs.com/resource//1732863205852
toolchain_file_name: Xuantie-900-gcc-linux-6.6.0-glibc-x86_64-V3.0.1-20241120.tar.gz
mainline_toolchain: https://github.com/riscv-collab/riscv-gnu-toolchain/releases/download/2025.01.20
mainline_toolchain_file_name: riscv64-glibc-ubuntu-22.04-gcc-nightly-2025.01.20-nightly.tar.xz
wget_alias: 'wget --retry-connrefused --waitretry=1 --read-timeout=20 --timeout=15 -t 0'
ARCH: riscv
CROSS_COMPILE: riscv64-unknown-linux-gnu-

jobs:
build:
runs-on: ubuntu-22.04
strategy:
fail-fast: false
matrix:
name: [xuantie-gcc, gcc-14]

steps:
- name: Install software
run: |
sudo apt update && \
sudo apt install -y gdisk dosfstools g++-12-riscv64-linux-gnu cpp-12-riscv64-linux-gnu build-essential \
libncurses-dev gawk flex bison openssl libssl-dev tree \
dkms libelf-dev libudev-dev libpci-dev libiberty-dev autoconf device-tree-compiler

- name: Checkout opensbi
uses: actions/checkout@v4

- name: opensbi compile
run: |
mkdir output
if [[ ${{ matrix.name }} = "xuantie-gcc" ]]; then
${wget_alias} ${xuantie_toolchain}/${toolchain_file_name}
tar -xvf ${toolchain_file_name} -C /opt
export PATH="/opt/Xuantie-900-gcc-linux-6.6.0-glibc-x86_64-V3.0.1/bin:$PATH"
else
${wget_alias} ${mainline_toolchain}/${mainline_toolchain_file_name}
tar -xvf ${mainline_toolchain_file_name} -C /opt
export PATH="/opt/riscv/bin:$PATH"
fi
${CROSS_COMPILE}gcc -v

pushd $PWD
make PLATFORM=generic FW_PIC=y
cp -v build/platform/generic/firmware/fw_dynamic.bin output/
popd
tree ${GITHUB_WORKSPACE}/output

- name: 'Upload Artifact'
uses: actions/upload-artifact@v4
with:
name: xuantie-mainline-opensbi-${{ matrix.name }}
path: output/fw_dynamic.bin
retention-days: 30
26 changes: 0 additions & 26 deletions .github/workflows/repo-lockdown.yml

This file was deleted.

2 changes: 2 additions & 0 deletions firmware/fw_base.S
Original file line number Diff line number Diff line change
Expand Up @@ -647,6 +647,8 @@ memcmp:
.align 3
.globl _trap_handler
_trap_handler:
sfence.vma zero, t0

TRAP_SAVE_AND_SETUP_SP_T0

TRAP_SAVE_MEPC_MSTATUS 0
Expand Down
2 changes: 2 additions & 0 deletions include/sbi/sbi_hart.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@ enum sbi_hart_extensions {
SBI_HART_EXT_SSCOFPMF,
/** HART has Sstc extension */
SBI_HART_EXT_SSTC,
/** HART has Xtheadsstc extension */
SBI_HART_EXT_XTHEADSSTC,
/** HART has Zicntr extension (i.e. HW cycle, time & instret CSRs) */
SBI_HART_EXT_ZICNTR,
/** HART has Zihpm extension */
Expand Down
3 changes: 3 additions & 0 deletions include/sbi_utils/fdt/fdt_helper.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,9 @@ struct platform_uart_data {
unsigned long reg_offset;
};

const struct fdt_match *fdt_match_node(const void *fdt, int nodeoff,
const struct fdt_match *match_table);

int fdt_parse_phandle_with_args(const void *fdt, int nodeoff,
const char *prop, const char *cells_prop,
int index, struct fdt_phandle_args *out_args);
Expand Down
1 change: 1 addition & 0 deletions lib/sbi/sbi_hart.c
Original file line number Diff line number Diff line change
Expand Up @@ -371,6 +371,7 @@ const struct sbi_hart_ext_data sbi_hart_ext[] = {
__SBI_HART_EXT_DATA(smstateen, SBI_HART_EXT_SMSTATEEN),
__SBI_HART_EXT_DATA(sscofpmf, SBI_HART_EXT_SSCOFPMF),
__SBI_HART_EXT_DATA(sstc, SBI_HART_EXT_SSTC),
__SBI_HART_EXT_DATA(xtheadsstc, SBI_HART_EXT_XTHEADSSTC),
__SBI_HART_EXT_DATA(zicntr, SBI_HART_EXT_ZICNTR),
__SBI_HART_EXT_DATA(zihpm, SBI_HART_EXT_ZIHPM),
__SBI_HART_EXT_DATA(zkr, SBI_HART_EXT_ZKR),
Expand Down
10 changes: 9 additions & 1 deletion lib/sbi/sbi_trap.c
Original file line number Diff line number Diff line change
Expand Up @@ -318,8 +318,16 @@ struct sbi_trap_context *sbi_trap_handler(struct sbi_trap_context *tcntx)
if (sbi_hart_has_extension(sbi_scratch_thishart_ptr(),
SBI_HART_EXT_SMAIA))
rc = sbi_trap_aia_irq();
else
else {
/*
* DCACHE.CALL:
* | 31 - 25 | 24 - 20 | 19 - 15 | 14 - 12 | 11 - 7 | 6 - 0 |
* 0000000 00001 00000 000 00000 0001011
*/
if ((regs->mepc & 0x7f) == 4)
asm volatile(".long 0x0010000b\n");
rc = sbi_trap_nonaia_irq(mcause & ~MCAUSE_IRQ_MASK);
}
msg = "unhandled local interrupt";
goto trap_done;
}
Expand Down
19 changes: 19 additions & 0 deletions lib/utils/fdt/fdt_helper.c
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,25 @@
#define DEFAULT_SHAKTI_UART_FREQ 50000000
#define DEFAULT_SHAKTI_UART_BAUD 115200

const struct fdt_match *fdt_match_node(const void *fdt, int nodeoff,
const struct fdt_match *match_table)
{
int ret;

if (!fdt || nodeoff < 0 || !match_table)
return NULL;

while (match_table->compatible) {
ret = fdt_node_check_compatible(fdt, nodeoff,
match_table->compatible);
if (!ret)
return match_table;
match_table++;
}

return NULL;
}

int fdt_parse_phandle_with_args(const void *fdt, int nodeoff,
const char *prop, const char *cells_prop,
int index, struct fdt_phandle_args *out_args)
Expand Down
11 changes: 9 additions & 2 deletions lib/utils/timer/aclint_mtimer.c
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
#include <sbi/sbi_bitops.h>
#include <sbi/sbi_domain.h>
#include <sbi/sbi_error.h>
#include <sbi/sbi_hart.h>
#include <sbi/sbi_scratch.h>
#include <sbi/sbi_timer.h>
#include <sbi_utils/timer/aclint_mtimer.h>
Expand Down Expand Up @@ -81,7 +82,10 @@ static void mtimer_event_stop(void)
return;

/* Clear MTIMER Time Compare */
time_cmp = (void *)mt->mtimecmp_addr;
if (sbi_hart_has_extension(scratch, SBI_HART_EXT_XTHEADSSTC))
time_cmp = (void *)(mt->mtimecmp_addr + 0x9000);
else
time_cmp = (void *)mt->mtimecmp_addr;
mt->time_wr(true, -1ULL, &time_cmp[target_hart - mt->first_hartid]);
}

Expand All @@ -97,7 +101,10 @@ static void mtimer_event_start(u64 next_event)
return;

/* Program MTIMER Time Compare */
time_cmp = (void *)mt->mtimecmp_addr;
if (sbi_hart_has_extension(scratch, SBI_HART_EXT_XTHEADSSTC))
time_cmp = (void *)(mt->mtimecmp_addr + 0x9000);
else
time_cmp = (void *)mt->mtimecmp_addr;
mt->time_wr(true, next_event,
&time_cmp[target_hart - mt->first_hartid]);
}
Expand Down
2 changes: 2 additions & 0 deletions platform/generic/configs/defconfig
Original file line number Diff line number Diff line change
Expand Up @@ -72,3 +72,5 @@ CONFIG_FDT_MPXY_RPMI_VOLTAGE=y
CONFIG_FDT_MPXY_RPMI_DEVICE_POWER=y
CONFIG_FDT_MPXY_RPMI_PERFORMANCE=y
CONFIG_FDT_MPXY_RPMI_SYSMSI=y
CONFIG_FDT_MBOX=y
CONFIG_FDT_MBOX_THEAD=y
1 change: 1 addition & 0 deletions platform/generic/include/thead/c9xx_encoding.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
#define THEAD_C9XX_CSR_MCOUNTEROF 0x7cb
#define THEAD_C9XX_CSR_MHINT2 0x7cc
#define THEAD_C9XX_CSR_MHINT3 0x7cd
#define THEAD_C9XX_CSR_MHINT4 0x7ce
#define THEAD_C9XX_CSR_MRADDR 0x7e0
#define THEAD_C9XX_CSR_MEXSTATUS 0x7e1
#define THEAD_C9XX_CSR_MNMICAUSE 0x7e2
Expand Down
2 changes: 2 additions & 0 deletions platform/generic/include/thead/c9xx_errata.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
*/
#define THEAD_QUIRK_ERRATA_TLB_FLUSH BIT(0)
#define THEAD_QUIRK_ERRATA_THEAD_PMU BIT(1)
#define THEAD_QUIRK_ERRATA_LOGHT_PPU BIT(2)
#define THEAD_QUIRK_ERRATA_XTHEADSSTC BIT(3)

void thead_register_tlb_flush_trap_handler(void);

Expand Down
Loading