sim: sim_core: start implementing the simulator core

This commit is contained in:
Mikael Pettersson
2020-06-28 21:44:35 +02:00
parent 1bfa79597a
commit b0b43b35ff
3 changed files with 52 additions and 1 deletions

View File

@@ -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.

View File

@@ -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 <http://www.gnu.org/licenses/>.
%%%
%%%=============================================================================
%%%
%%% 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.

View File

@@ -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