From 5d2355896ee74c08a5852111fd9748a354304194 Mon Sep 17 00:00:00 2001 From: brolley Date: Fri, 19 Aug 2005 19:44:46 +0000 Subject: [PATCH] 2005-08-19 Dave Brolley * Contribute the following changes: 2005-07-13 Dave Brolley * gloss.cxx (gloss32): Initialize dynamic_configurator. Add dynamic-configurator relation. * gloss.h (gloss32): Inherit virtually from fixed_attribute_map_component. (dynamic_configurator): New member of gloss32. 2005-07-05 Dave Brolley * gloss.cxx (start_config): Removed from gloss32. (gloss32): Remove "start-config" attribute. Add "config-error" pin. (reset): Don't call sys_config_set. (sys_reconfig_set): Call set_error_result based on the value driven on config_error_pin. (sys_reconfig_reset): Likewise. * gloss.h (start_config): Removed from gloss32. (config_error_pin): New member of gloss32. 2005-06-06 Dave Brolley * gloss.cxx (gloss32): Don't initialize dynamic_configurator. Don't add dynamic-configurator relation. (configure_pin): Renamed to sys_configure_pin. (configure): New virtual override in gloss32. (do_sys_reconfig): Print log messages to cerr and only when verbose_p. * gloss.h (gloss32): fixed_pin_map_component and configurable_component inherited virtually. (dynamic_configurator): Removed. (configure_pin): Renamed to sys_configure_pin. (configure): New virtual override in gloss32. 2005-05-29 Dave Brolley * libgloss.h (SYS_reconfig): New enumerator. * gloss.h (main, dynamic_configurator): New members of gloss32. (configure_pin, config_result_pin, start_config): Likewise. (sys_reconfig_set): New method of gloss32. (sys_reconfig_reset, do_sys_reconfig): Likewise. * gloss.cxx (gloss32): Initialize main, dynamic_configurator and start_config. Add relations main, dynamic-configurator. Add configure pin. Add start-config addtribute. Add config-result pin. (reset): Call sys_reconfig_set with start_config if it's not empty. (syscall_trap): Handle SYS_reconfig. (sys_reconfig_set): New method of gloss32. (sys_reconfig_reset, do_sys_reconfig): Likewise. --- sid/component/gloss/ChangeLog | 55 +++++++++++++++++++ sid/component/gloss/gloss.cxx | 121 ++++++++++++++++++++++++++++++++++++++++- sid/component/gloss/gloss.h | 22 ++++++-- sid/component/gloss/libgloss.h | 3 +- 4 files changed, 194 insertions(+), 7 deletions(-) diff --git a/sid/component/gloss/ChangeLog b/sid/component/gloss/ChangeLog index 21c8cf77ca..801592ecd4 100644 --- a/sid/component/gloss/ChangeLog +++ b/sid/component/gloss/ChangeLog @@ -1,3 +1,58 @@ +2005-08-19 Dave Brolley + + * Contribute the following changes: + + 2005-07-13 Dave Brolley + + * gloss.cxx (gloss32): Initialize dynamic_configurator. Add + dynamic-configurator relation. + * gloss.h (gloss32): Inherit virtually from + fixed_attribute_map_component. + (dynamic_configurator): New member of gloss32. + + 2005-07-05 Dave Brolley + + * gloss.cxx (start_config): Removed from gloss32. + (gloss32): Remove "start-config" attribute. Add "config-error" + pin. + (reset): Don't call sys_config_set. + (sys_reconfig_set): Call set_error_result based on the value driven on + config_error_pin. + (sys_reconfig_reset): Likewise. + * gloss.h (start_config): Removed from gloss32. + (config_error_pin): New member of gloss32. + + 2005-06-06 Dave Brolley + + * gloss.cxx (gloss32): Don't initialize dynamic_configurator. + Don't add dynamic-configurator relation. + (configure_pin): Renamed to sys_configure_pin. + (configure): New virtual override in gloss32. + (do_sys_reconfig): Print log messages to cerr and only when + verbose_p. + * gloss.h (gloss32): fixed_pin_map_component and configurable_component + inherited virtually. + (dynamic_configurator): Removed. + (configure_pin): Renamed to sys_configure_pin. + (configure): New virtual override in gloss32. + + 2005-05-29 Dave Brolley + + * libgloss.h (SYS_reconfig): New enumerator. + * gloss.h (main, dynamic_configurator): New members of gloss32. + (configure_pin, config_result_pin, start_config): Likewise. + (sys_reconfig_set): New method of gloss32. + (sys_reconfig_reset, do_sys_reconfig): Likewise. + * gloss.cxx (gloss32): Initialize main, dynamic_configurator and + start_config. Add relations main, dynamic-configurator. Add + configure pin. Add start-config addtribute. Add config-result + pin. + (reset): Call sys_reconfig_set with start_config if it's not + empty. + (syscall_trap): Handle SYS_reconfig. + (sys_reconfig_set): New method of gloss32. + (sys_reconfig_reset, do_sys_reconfig): Likewise. + 2005-06-03 Jim Blandy * Makefile.in: Regenerated with Automake 1.9.5. diff --git a/sid/component/gloss/gloss.cxx b/sid/component/gloss/gloss.cxx index fb68bde2b7..a5fa6a0d8a 100644 --- a/sid/component/gloss/gloss.cxx +++ b/sid/component/gloss/gloss.cxx @@ -1,6 +1,6 @@ // gloss.cxx - Gloss routines. -*- C++ -*- -// Copyright (C) 1999, 2000, 2001, 2002 Red Hat. +// Copyright (C) 1999, 2000, 2001, 2002, 2005 Red Hat. // This file is part of SID and is licensed under the GPL. // See the file COPYING.SID for conditions for redistribution. @@ -41,7 +41,9 @@ gloss32::gloss32() : trap_type_ipin(this, &gloss32::trap_pin_handler), rx_pin(this, &gloss32::rx_handler), cpu (0), + main (0), cpu_memory_bus (0), + dynamic_configurator (0), syscall_numbering_scheme("libgloss"), max_fds(32), verbose_p(false) @@ -64,6 +66,9 @@ gloss32::gloss32() : add_attribute_ro_value ("tk tty", string("hw-visual-tty"), "gui"); add_uni_relation("cpu", &this->cpu); + add_uni_relation("main", &this->main); + add_uni_relation("dynamic-configurator", &this->dynamic_configurator); + add_pin ("configure", &this->sys_configure_pin); add_attribute_virtual("command-line", this, &gloss32::get_command_line, @@ -71,6 +76,9 @@ gloss32::gloss32() : "setting"); add_attribute("syscall-numbering-scheme", &this->syscall_numbering_scheme, "setting"); + add_pin ("config-result", &config_result_pin); + add_pin ("config-error", &config_error_pin); + add_attribute("verbose?", &this->verbose_p, "setting"); add_attribute("max-fds", &this->max_fds, "setting"); @@ -341,7 +349,7 @@ gloss32::get_halfword (address32 addr, sid::host_int_2& value) if (! cpu_memory_bus) { if (verbose_p) - cerr << "*** CPU memory bus not configure!" << endl; + cerr << "*** CPU memory bus not configured!" << endl; return false; } @@ -790,6 +798,9 @@ gloss32::syscall_trap() switch (target_to_host_syscall(syscall)) { + case libgloss::SYS_reconfig: + do_sys_reconfig(); + break; case libgloss::SYS_read: do_sys_read(); break; @@ -848,6 +859,112 @@ gloss32::do_nonstandard_target_syscalls (int32 target_syscall) } void +gloss32::configure (const string &config) +{ + // Call up to the base class first + configurable_component::configure (config); + + // Now handle relevent configuration for us. + if (config.size () <= 8) + return; + if (config.substr (0, 8) == "verbose=") + { + verbose_p = (config.substr (8) == "true"); + return; + } +} + +void +gloss32::sys_reconfig_set (const string &profile_name) +{ + // Make sure that the main component and the dynamic configurator component + // have been related to us. + if (! main) + { + set_error_result (1); + return; + } + if (! dynamic_configurator) + { + set_error_result (2); + return; + } + + // Set main's lookup-dynamic-config attribute with the name we're looking + // for. main will then write the configuration string into its + // found-config-profile attribute if it is found. + component::status s = main->set_attribute_value ("lookup-dynamic-config!", + profile_name); + if (s != component::ok) + { + set_error_result (3); + return; + } + + // Pass the configuration string to the dynamic configurator for this board. + string config = main->attribute_value ("found-dynamic-config"); + dynamic_configurator->set_attribute_value ("configure!", config); + if (s != component::ok) + { + set_error_result (4); + return; + } + + host_int_4 result = config_result_pin.sense (); + set_int_result (result); + host_int_4 error = config_error_pin.sense (); + set_error_result (error); +} + +void +gloss32::sys_reconfig_reset (int32 handle) +{ + // Drive the configure! pin of the dynamic configurator + sys_configure_pin.drive (handle); + + // If there is an error, then the config result will be zero, otherwise + // it will be a config handle. + host_int_4 result = config_result_pin.sense (); + set_int_result (result); + host_int_4 error = config_error_pin.sense (); + set_error_result (error); +} + +void +gloss32::do_sys_reconfig () +{ + if (verbose_p) + cerr << "sys_reconfig: "; + + int32 n, str_ptr, handle; + string profile_name; + + get_int_argument(1, n); + switch (n) + { + case 0: // warmup () + profile_name = "sid-internal-warmup"; + if (verbose_p) + cerr << profile_name << endl; + sys_reconfig_set (profile_name); + break; + case 1: // set (name) + get_int_argument(2, str_ptr); + get_string(str_ptr, profile_name); + if (verbose_p) + cerr << "set " << profile_name << endl; + sys_reconfig_set (profile_name); + break; + case 2: // reset (handle) + get_int_argument(2, handle); + if (verbose_p) + cerr << "reset 0x" << ios::hex << handle << ios::dec << endl; + sys_reconfig_reset (handle); + break; + } +} + +void gloss32::do_sys_argc () { set_int_result (command_line.size ()); diff --git a/sid/component/gloss/gloss.h b/sid/component/gloss/gloss.h index 4a5d4dbd74..7d982745b0 100644 --- a/sid/component/gloss/gloss.h +++ b/sid/component/gloss/gloss.h @@ -1,7 +1,7 @@ // gloss.h - Basic process emulation plus ROM monitor support. // -*- C++ -*- -// Copyright (C) 1999, 2000, 2001, 2002 Red Hat. +// Copyright (C) 1999, 2000, 2001, 2002, 2005 Red Hat. // This file is part of SID and is licensed under the GPL. // See the file COPYING.SID for conditions for redistribution. @@ -52,17 +52,19 @@ using sidutil::fixed_accessor_map_component; using sidutil::fixed_pin_map_component; using sidutil::no_bus_component; using sidutil::fixed_relation_map_component; +using sidutil::configurable_component; using sidutil::callback_pin; using sidutil::output_pin; using sidutil::input_pin; class gloss32: public virtual component, - protected fixed_attribute_map_component, + protected virtual fixed_attribute_map_component, protected fixed_accessor_map_component, - protected fixed_pin_map_component, + protected virtual fixed_pin_map_component, protected no_bus_component, - protected fixed_relation_map_component + protected virtual fixed_relation_map_component, + protected configurable_component { public: @@ -73,6 +75,8 @@ protected: // The cpu we're connected to. component* cpu; + // The main SID component. + component* main; // Access to the cpu's memory. bus* cpu_memory_bus; // The endian of `cpu'. @@ -150,8 +154,18 @@ protected: virtual void syscall_trap(); bool blocked_p; // signal that syscall blocked + // Dynamic configuration + component *dynamic_configurator; + void configure (const string &config); + // syscall support + output_pin sys_configure_pin; + input_pin config_result_pin; + input_pin config_error_pin; int32 errnum; + void do_sys_reconfig(); + void sys_reconfig_set (const string &profile_name); + void sys_reconfig_reset (int32 handle); void do_sys_exit(); void do_sys_read(); void do_sys_write(); diff --git a/sid/component/gloss/libgloss.h b/sid/component/gloss/libgloss.h index bf9e545c4b..aabb6b15fd 100644 --- a/sid/component/gloss/libgloss.h +++ b/sid/component/gloss/libgloss.h @@ -1,6 +1,6 @@ // libgloss.h - Interface details for libgloss. -*- C++ -*- -// Copyright (C) 1999, 2000, 2001, 2002 Red Hat. +// Copyright (C) 1999, 2000, 2001, 2002, 2005 Red Hat. // This file is part of SID and is licensed under the GPL. // See the file COPYING.SID for conditions for redistribution. @@ -19,6 +19,7 @@ public: enum libgloss_syscall { + SYS_reconfig = 0, SYS_exit = 1, SYS_open = 2, SYS_close = 3, -- 2.11.0