Skip to content

Commit

Permalink
naming change only. no functional changes. cfunc -> rv_cfg
Browse files Browse the repository at this point in the history
  • Loading branch information
billmcspadden-riscv committed Aug 4, 2022
1 parent ae26f5b commit 9c1341c
Show file tree
Hide file tree
Showing 7 changed files with 24 additions and 27 deletions.
10 changes: 5 additions & 5 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -119,8 +119,8 @@ export LEM_DIR

C_WARNINGS ?=
#-Wall -Wextra -Wno-unused-label -Wno-unused-parameter -Wno-unused-but-set-variable -Wno-unused-function
C_INCS = $(addprefix c_emulator/,riscv_prelude.h riscv_platform_impl.h riscv_platform.h riscv_softfloat.h cfunc.h)
C_SRCS = $(addprefix c_emulator/,riscv_prelude.c riscv_platform_impl.c riscv_platform.c riscv_softfloat.c riscv_sim.c cfunc.c)
C_INCS = $(addprefix c_emulator/,riscv_prelude.h riscv_platform_impl.h riscv_platform.h riscv_softfloat.h rv_cfg_func.h)
C_SRCS = $(addprefix c_emulator/,riscv_prelude.c riscv_platform_impl.c riscv_platform.c riscv_softfloat.c riscv_sim.c rv_cfg_func.c)

SOFTFLOAT_DIR = c_emulator/SoftFloat-3e
SOFTFLOAT_INCDIR = $(SOFTFLOAT_DIR)/source/include
Expand All @@ -134,8 +134,8 @@ GMP_FLAGS = $(shell pkg-config --cflags gmp)
GMP_LIBS = $(shell pkg-config --libs gmp || echo -lgmp)
ZLIB_FLAGS = $(shell pkg-config --cflags zlib)
ZLIB_LIBS = $(shell pkg-config --libs zlib)
FYAML_FLAGS =$(shell pkg-config --cflags libfyaml)
FYAML_LIBS=$(shell pkg-config --libs libfyaml)
FYAML_FLAGS = $(shell pkg-config --cflags libfyaml)
FYAML_LIBS = $(shell pkg-config --libs libfyaml)

C_FLAGS = -I $(SAIL_LIB_DIR) -I c_emulator $(GMP_FLAGS) $(ZLIB_FLAGS) $(SOFTFLOAT_FLAGS) $(FYAML_FLAGS) -fcommon
C_LIBS = $(GMP_LIBS) $(ZLIB_LIBS) $(SOFTFLOAT_LIBS) $(FYAML_LIBS)
Expand Down Expand Up @@ -277,7 +277,7 @@ rvfi_preserve_fns=-c_preserve rvfi_set_instr_packet \

generated_definitions/c/riscv_rvfi_model_$(ARCH).c: $(SAIL_RVFI_SRCS) model/main.sail Makefile
mkdir -p generated_definitions/c
$(SAIL) $(rvfi_preserve_fns) $(SAIL_FLAGS) -O -Oconstant_fold -memo_z3 -c -c_include riscv_prelude.h -c_include riscv_platform.h -c_include cfunc.h -c_no_main $(SAIL_RVFI_SRCS) model/main.sail -o $(basename $@)
$(SAIL) $(rvfi_preserve_fns) $(SAIL_FLAGS) -O -Oconstant_fold -memo_z3 -c -c_include riscv_prelude.h -c_include riscv_platform.h -c_include rv_cfg_func.h -c_no_main $(SAIL_RVFI_SRCS) model/main.sail -o $(basename $@)
sed -i -e '/^[[:space:]]*$$/d' $@

c_emulator/riscv_rvfi_$(ARCH): generated_definitions/c/riscv_rvfi_model_$(ARCH).c $(C_INCS) $(C_SRCS) $(SOFTFLOAT_LIBS) Makefile
Expand Down
2 changes: 1 addition & 1 deletion c_emulator/riscv_platform_impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
/* Settings of the platform implementation. */

// #define DEFAULT_RSTVEC 0x00001000
#define DEFAULT_RSTVEC cfunc_int_c("/reset/address")
#define DEFAULT_RSTVEC rv_cfg_int_c("/reset/address")

extern bool rv_enable_pmp;
extern bool rv_enable_zfinx;
Expand Down
2 changes: 1 addition & 1 deletion c_emulator/riscv_sim.c
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
#include "riscv_platform_impl.h"
#include "riscv_sail.h"

#include "cfunc.h"
#include "rv_cfg_func.h"

#ifdef ENABLE_SPIKE
#include "tv_spike_intf.h"
Expand Down
14 changes: 7 additions & 7 deletions c_emulator/cfunc.c → c_emulator/rv_cfg_func.c
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// vim: set tabstop=4 shiftwidth=4 expandtab
// ============================================================================
// Filename: cfunc.c
// Filename: rv_cfg_func.c
//
// Description: Functions to be called by Sail to get values from a yaml file.
//
Expand All @@ -10,7 +10,7 @@
// ============================================================================

#include <sail.h>
#include "cfunc.h"
#include "rv_cfg_func.h"
#include "string.h"

/* RISC-V Config YAML configuration support */
Expand Down Expand Up @@ -104,7 +104,7 @@ rv_cfg_build_from_file(rv_cfg_e rv_cfg_type, char * filename )

// ============================================================================
unsigned int
cfunc_int_c(char * key_str)
rv_cfg_int_c(char * key_str)
{
struct fy_document *fyd = NULL;
//unsigned int yaml_val_int;
Expand Down Expand Up @@ -154,16 +154,16 @@ cfunc_int_c(char * key_str)

// ============================================================================
int
cfunc_int(sail_int *zret_int, char * yaml_key_str)
rv_cfg_int(sail_int *zret_int, char * yaml_key_str)
{
printf("%s, %d: entering cfunc_int()\n", __FILE__, __LINE__);
mpz_set_ui(*zret_int, cfunc_int_c(yaml_key_str));
printf("%s, %d: entering rv_cfg_int()\n", __FILE__, __LINE__);
mpz_set_ui(*zret_int, rv_cfg_int_c(yaml_key_str));
return(1);

}

unit
cfunc_dump_yaml(char *yaml_filename)
rv_cfg_dump_yaml(char *yaml_filename)
{
struct fy_document *fyd = NULL;

Expand Down
15 changes: 6 additions & 9 deletions c_emulator/cfunc.h → c_emulator/rv_cfg_func.h
Original file line number Diff line number Diff line change
@@ -1,16 +1,13 @@
// vim: set tabstop=4 shiftwidth=4 expandtab
// ============================================================================
// Filename: cfunc.h
// Filename: rv_cfg_func.h
//
// Description: Functions prototype support for cfunc
// Description: Functions prototype support for rv_cfg
//
// Author(s): Bill McSpadden ([email protected])
//
// Revision: See git log
// ============================================================================
//#ifndef __CFUNC_H__
//#define __CFUNC_H__
//

#pragma once

Expand Down Expand Up @@ -50,7 +47,7 @@ int rv_cfg_init(void);
char * rv_cfg_get_string(rv_cfg_e e);
rv_cfg_e rv_cfg_get_enum(char * s);
int rv_cfg_build_from_file(rv_cfg_e rv_cfg_type, char * filename );
unsigned int cfunc_int_c(char *);
unsigned int rv_cfg_int_c(char *);



Expand All @@ -64,9 +61,9 @@ unsigned int cfunc_int_c(char *);
//
// TODO: make the return value of type void.

//INT_RET_TYPE cfunc_int(sail_int *, char *, unit); // TODO: find out why unit is sometimes required, sometimes not INT_RET_TYPE cfunc_int(sail_int *, char *);
//INT_RET_TYPE rv_cfg_int(sail_int *, char *, unit); // TODO: find out why unit is sometimes required, sometimes not INT_RET_TYPE rv_cfg_int(sail_int *, char *);

int cfunc_int(sail_int *, char *);
unit cfunc_dump_yaml(char *);
int rv_cfg_int(sail_int *, char *);
unit rv_cfg_dump_yaml(char *);

//#endif
6 changes: 3 additions & 3 deletions model/main.sail
Original file line number Diff line number Diff line change
Expand Up @@ -66,14 +66,14 @@
/* SUCH DAMAGE. */
/*=======================================================================================*/

// TODO: put the cfunc interface into a sail file and include it.
val cfunc_int = { c: "cfunc_int" } : (string) -> int
// TODO: put the rv_cfg_func interface into a sail file and include it.
val rv_cfg_int = { c: "rv_cfg_int" } : (string) -> int

function main () : unit -> unit = {

print("hello from main() in main.sail\n");

let reset_address : int = cfunc_int( "/reset/address") ;
let reset_address : int = rv_cfg_int( "/reset/address") ;
print_int("/reset/address: 0x%x\n", reset_address);

// initialize extensions
Expand Down
2 changes: 1 addition & 1 deletion model/riscv_step.sail
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@
/* SUCH DAMAGE. */
/*=======================================================================================*/

val cfunc_int = { c: "cfunc_int" } : (string) -> int
val rv_cfg_int = { c: "rv_cfg_int" } : (string) -> int

/* The emulator fetch-execute-interrupt dispatch loop. */

Expand Down

0 comments on commit 9c1341c

Please sign in to comment.