diff --git a/Makefile b/Makefile index 17495118..93ed908c 100644 --- a/Makefile +++ b/Makefile @@ -38,6 +38,12 @@ CSVS = $(wildcard $(CSV_DIR)/*.csv) GEN_DIR = $(SRC_DIR)/generated SCRIPTS_DIR = $(SRC_DIR)/scripts +# Downloaded Sail Asciidoc JSON, which includes all of +# the Sail code and can be embedded. We don't vendor it +# into this repo since it's quite large (~4MB). +SAIL_ASCIIDOC_JSON_URL_FILE = riscv_RV64.json.url +SAIL_ASCIIDOC_JSON = $(GEN_DIR)/riscv_RV64.json + # Output files PDF_RESULT := $(BUILD_DIR)/riscv-cheri.pdf HTML_RESULT := $(BUILD_DIR)/riscv-cheri.html @@ -89,7 +95,8 @@ ASCIIDOC_OPTIONS = --trace --verbose \ --failure-level=ERROR $(EXTRA_ASCIIDOC_OPTIONS) ASCIIDOC_REQUIRES = --require=asciidoctor-bibtex \ --require=asciidoctor-diagram \ - --require=asciidoctor-mathematical + --require=asciidoctor-mathematical \ + --require=asciidoctor-sail # File extension to backend map. ASCIIDOC_BACKEND_.html = html5 @@ -130,11 +137,11 @@ $(BUILD_DIR): @echo " DIR $@" @mkdir -p $@ -%.pdf: $(SRCS) $(IMGS) $(GEN_SRC) | $(BUILD_DIR) +%.pdf: $(SRCS) $(IMGS) $(GEN_SRC) $(SAIL_ASCIIDOC_JSON) | $(BUILD_DIR) @echo " DOC $@" $(BUILD_COMMAND) -%.html: $(SRCS) $(IMGS) $(GEN_SRC) | $(BUILD_DIR) +%.html: $(SRCS) $(IMGS) $(GEN_SRC) $(SAIL_ASCIIDOC_JSON) | $(BUILD_DIR) @echo " DOC $@" $(BUILD_COMMAND) @@ -143,9 +150,15 @@ $(GEN_SRC) &: $(CSVS) $(GEN_SCRIPT) @echo " GEN $@" @$(GEN_SCRIPT) -o $(GEN_DIR) --csr $(CSV_DIR)/CHERI_CSR.csv --isa $(CSV_DIR)/CHERI_ISA.csv +# Download the Sail JSON. The URL is stored in a file so if the URL changes +# Make will know to download it again. +# TODO: Remove iconv once this is fixed: https://github.com/Alasdair/asciidoctor-sail/issues/6 +$(SAIL_ASCIIDOC_JSON): $(SAIL_ASCIIDOC_JSON_URL_FILE) + @curl --location '$(shell cat $<)' | iconv -f UTF-8 -t ASCII//TRANSLIT >$@ + # Clean clean: @echo " CLEAN" - @$(RM) -r $(PDF_RESULT) $(HTML_RESULT) $(GEN_SRC) + @$(RM) -r $(PDF_RESULT) $(HTML_RESULT) $(GEN_SRC) $(SAIL_ASCIIDOC_JSON) .PHONY: all generate clean diff --git a/riscv_RV64.json.url b/riscv_RV64.json.url new file mode 100644 index 00000000..7f2db19c --- /dev/null +++ b/riscv_RV64.json.url @@ -0,0 +1 @@ +https://github.com/CHERI-Alliance/sail-cheri-riscv/releases/download/2024-12-19/riscv_RV64.json diff --git a/src/attributes.adoc b/src/attributes.adoc index c756c011..ba87d512 100644 --- a/src/attributes.adoc +++ b/src/attributes.adoc @@ -36,6 +36,9 @@ endif::[] :xrefstyle: short :attribute-missing: warn +// Sail source code +:sail-doc: src/generated/riscv_RV64.json + /////////////////////////////////////////////////////////////////////////////// // Top-level CHERI definitions /////////////////////////////////////////////////////////////////////////////// diff --git a/src/insns/modesw_32bit.adoc b/src/insns/modesw_32bit.adoc index 7b3f015f..14956405 100644 --- a/src/insns/modesw_32bit.adoc +++ b/src/insns/modesw_32bit.adoc @@ -34,7 +34,5 @@ Prerequisites:: {cheri_default_ext_name} Operation:: -[source,SAIL,subs="verbatim,quotes"] --- -TODO --- ++ +sail::execute[clause="MODESW()",part=body,unindent] diff --git a/src/insns/scaddr_32bit.adoc b/src/insns/scaddr_32bit.adoc index 1952825d..812366d6 100644 --- a/src/insns/scaddr_32bit.adoc +++ b/src/insns/scaddr_32bit.adoc @@ -34,6 +34,4 @@ Prerequisites:: Operation:: + --- -TODO --- +sail::execute[clause="SCADDR(_, _, _)",part=body,unindent]