From b0b43b35ff6fde4aa540ec72300b83b948919857 Mon Sep 17 00:00:00 2001 From: Mikael Pettersson Date: Sun, 28 Jun 2020 21:44:35 +0200 Subject: [PATCH] sim: sim_core: start implementing the simulator core --- erlang/apps/sim/src/sim.erl | 3 +- erlang/apps/sim/src/sim_core.erl | 49 ++++++++++++++++++++++++++++++++ erlang/rebar.config | 1 + 3 files changed, 52 insertions(+), 1 deletion(-) create mode 100644 erlang/apps/sim/src/sim_core.erl diff --git a/erlang/apps/sim/src/sim.erl b/erlang/apps/sim/src/sim.erl index 990717c..68b9e6e 100644 --- a/erlang/apps/sim/src/sim.erl +++ b/erlang/apps/sim/src/sim.erl @@ -146,7 +146,8 @@ version() -> do_sim(#options{exe = Exe, argv = Argv}) -> case sim_loader:load(Exe, Argv, simenv()) of - {ok, {_Mem, _PC, _SP, _Argc, _ArgvPtr, _Envp}} -> ok; % FIXME + {ok, {Mem, PC, SP, Argc, ArgvPtr, Envp}} -> + sim_core:run(Mem, PC, SP, Argc, ArgvPtr, Envp); {error, _Reason} = Error -> Error end. diff --git a/erlang/apps/sim/src/sim_core.erl b/erlang/apps/sim/src/sim_core.erl new file mode 100644 index 0000000..100fcde --- /dev/null +++ b/erlang/apps/sim/src/sim_core.erl @@ -0,0 +1,49 @@ +%%% -*- erlang-indent-level: 2 -*- +%%% +%%% simulator for pdp10-elf +%%% Copyright (C) 2020 Mikael Pettersson +%%% +%%% This file is part of pdp10-tools. +%%% +%%% pdp10-tools is free software: you can redistribute it and/or modify +%%% it under the terms of the GNU General Public License as published by +%%% the Free Software Foundation, either version 3 of the License, or +%%% (at your option) any later version. +%%% +%%% pdp10-tools is distributed in the hope that it will be useful, +%%% but WITHOUT ANY WARRANTY; without even the implied warranty of +%%% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +%%% GNU General Public License for more details. +%%% +%%% You should have received a copy of the GNU General Public License +%%% along with pdp10-tools. If not, see . +%%% +%%%============================================================================= +%%% +%%% Runs a loaded pdp10-elf user-mode program. + +-module(sim_core). + +-export([ run/6 + , format_error/1 + ]). + +-include("sim_core.hrl"). + +%% Run a program =============================================================== + +-spec run(Mem :: sim_mem:mem(), + PC :: word(), + SP :: word(), + Argc :: word(), + Argv :: word(), + Envp :: word()) -> ok | {error, {module(), term()}}. +run(_Mem, _PC, _SP, _Argc, _Argv, _Envp) -> ok. % FIXME + +%% Error Formatting ============================================================ + +-spec format_error(term()) -> io_lib:chars(). +format_error(Reason) -> + case Reason of + _ -> [] % FIXME + end. diff --git a/erlang/rebar.config b/erlang/rebar.config index cebc643..6bc43af 100644 --- a/erlang/rebar.config +++ b/erlang/rebar.config @@ -63,6 +63,7 @@ , {scan, format_error, 1} , {scan_state, format_error, 1} , {sim, format_error, 1} + , {sim_core, format_error, 1} , {sim_loader, format_error, 1} , {strtol, format_error, 1} %% actual unused exports