with BBS;
with BBS.http;
with BBS.internal;
with Panel;
package body web.xml is
--
-- Get and optionally set the state of the auto_man flag
--
procedure auto_man(s : GNAT.Sockets.Stream_Access;
h : BBS.web_common.params.Map;
p : BBS.web_common.params.Map) is
pragma Unreferenced(h);
value : Boolean := Panel.auto_man;
begin
BBS.http.ok(s, "application/xml");
if (BBS.web_common.params.Contains(p, "auto-man")) then
begin
value := Boolean'Value(BBS.web_common.params.Element(p, "auto-man"));
exception
when others =>
value := Panel.auto_man;
end;
if Panel.sw_ctrl.auto then
Panel.auto_man := value;
end if;
end if;
String'Write(s, "" & Boolean'Image(Panel.sw_ctrl.auto) &
"" & Boolean'Image(Panel.auto_man) & "");
end auto_man;
--
-- Get and optionally set the type of the simulation
--
procedure sim_type(s : GNAT.Sockets.Stream_Access;
h : BBS.web_common.params.Map;
p : BBS.web_common.params.Map) is
pragma Unreferenced(h);
value : Natural := Panel.get_pattern;
begin
BBS.http.ok(s, "application/xml");
if (BBS.web_common.params.Contains(p, "sim-type")) then
begin
value := Natural'Value(BBS.web_common.params.Element(p, "sim-type"));
exception
when others =>
value := Panel.get_pattern;
end;
Panel.set_pattern(value);
end if;
String'Write(s, "" & Natural'Image(Panel.get_pattern) & "");
end sim_type;
--
-- Get switch and LED register values. Currently read-only
--
procedure sw_led_reg(s : GNAT.Sockets.Stream_Access;
h : BBS.web_common.params.Map;
p : BBS.web_common.params.Map) is
pragma Unreferenced(h);
pragma Unreferenced(p);
begin
BBS.http.ok(s, "application/xml");
String'Write(s, "");
String'Write(s, "" & BBS.uint32'Image(Panel.lr_ad) & "");
String'Write(s, "" & BBS.uint16'Image(Panel.lr_ctl) & "");
String'Write(s, "" & BBS.uint32'Image(Panel.sr_ad) & "");
String'Write(s, "" & BBS.uint16'Image(Panel.sr_ctl) & "");
String'Write(s, "");
end sw_led_reg;
--
-- Get simulated CPU information (currently name, num reg, and mem size)
--
procedure Get_CPU_info(s : GNAT.Sockets.Stream_Access;
h : BBS.web_common.params.Map;
p : BBS.web_common.params.Map) is
pragma Unreferenced(h);
pragma Unreferenced(p);
begin
BBS.http.ok(s, "application/xml");
String'Write(s, "");
String'Write(s, "" & Panel.CPU.all.name & "");
String'Write(s, "" & BBS.uint32'Image(Panel.CPU.all.registers) & "");
String'Write(s, "" & BBS.uint32'Image(Panel.CPU.all.mem_size) & "");
String'Write(s, "");
end Get_CPU_info;
--
-- Get simulated CPU register name and value
--
procedure Get_CPU_reg(s : GNAT.Sockets.Stream_Access;
h : BBS.web_common.params.Map;
p : BBS.web_common.params.Map) is
pragma Unreferenced(h);
value : Natural;
begin
BBS.http.ok(s, "application/xml");
if (BBS.web_common.params.Contains(p, "register")) then
begin
value := Natural'Value(BBS.web_common.params.Element(p, "register"));
exception
when others =>
value := 0;
end;
end if;
String'Write(s, "" & Natural'Image(value) & "");
String'Write(s, "" & Panel.CPU.all.reg_name(BBS.uint32(value))
& "");
String'Write(s, "" & String'(Panel.CPU.all.read_reg(BBS.uint32(value)))
& "");
end Get_CPU_reg;
--
-- Set exit flags. Sets the simulator exit flag and then request that the
-- web server exit.
--
procedure set_exits(s : GNAT.Sockets.Stream_Access;
h : BBS.web_common.params.Map;
p : BBS.web_common.params.Map)is
begin
Panel.exit_sim := True;
BBS.internal.html_set_exit(s, h, p);
end set_exits;
--
end;