Implementation description of the Loader Application: ===================================================== The loader application is used for convenient communication with the DIY Calculator hardware. All tasks (and even more) that can be done with the loader application can be don via a terminal emulation program, such as TeraTerm. In fact, the loader application is only a GUI to the various commands, which the DIY Calculator ROM Monitor accepts. Structure: ---------- The application is built from the following modules: - background.c ..... the DIY Calculator background image - cmd.c ............ send a cmd to the DIY Calculator, wait for a string - cpu_clk.c ........ adjust CPU speed dialog - cpu_reg.c ........ display DPU registers - disp_mem ......... the Memory Walker - io_ports.c ....... display some well-known I/O ports - save_ram.c ....... save the contents of the RAM to Flash - serial.c ......... low level serial I/O functions - set_comm_port.c .. select the communications port dialog - version_info.c ... display DIY Calculator version information - gtk_filename.c ... file selector dialog - gtk_helper.c ..... helper functions for GTK - gtk_msgbox.c ..... a simple message box - gtk_multibox.c ... a message box with multiple buttons - gtk_statusbox.c .. a status box with or without progress bar The application uses the GTK graphical widgets library, which is available on a number of different platforms. The Windows (WIN32) and Linux platforms are supported. Besides the low-level serial I/O access routines very few "compiler-ifdefs" are used for platform adoption. The modules fall into three categories: - Every window (including the main window), dialog box, etc. is a separate module in a separate source file. - Some Additions to GTK - the low-level serial I/O routines (serial.c) In the WIN32 environment there exists the concept of CLI program versus GUI program. This must be specified a link time. To overcome unexpected behaviour resulting from that there is additional code for the Windows version in main.c (view comments inside the code). The application can be in several states or modes: - not connected . DIY Calculator HW is not detected - connected ..... DIY Calculator HW detected - reset ......... DIY Calculator HW detected and reset - single step ... DIY Calculator HW in single stepggin a user program - running ....... a user program is running - offline ....... application started in offline mode (for GUI test or demo) The mode is displayed in the bottom status line of the main window. The serial reception is done in a timer function within main.c. This timer is installed during startup and is called every 20 msec. If no other window expects response from the DIY Calculator the received characters are printed to the main window. When clicking one of the shortcut buttons or selecting a menu entry the corresponding callback function is called and depending on the action a new window is opened. Most of the windows are non-modal, which means that the main window is still active besides the child window. When a child window needs to grab the input from the serial port it sets the global variable do_timer_cb to 0. Thus the timer routine bypasses the reception code and the response from the DIY Calculator can be received by the chilid window (e.g. CPU register display). Note that if the DIY Calculator HW is executing or single stepping a user program it only responses to the 'step', 'run', and 'reset' commands. Usage: ------ The application accepts the following cmdline parameters: -d --debug .......... displays debug information -h --help ........... short online help -o --offline ........ offline mode (no DIY Calculator connected) -p --port=portname .. communications port name (e.g. com3 or /dev/ttyS0) be sure to have write acces to the comm. port. It defaults to the first comm. port in the system -t --terminal ....... start a terminal instead of the background image -v --version ........ display version information and exit The is not (yet) an online help, but usage should be straightforward. Be careful with the CPU clock selection. At settings below 1MHz the CPU is too slow for the RS-232 communication. You only can restart with HW reset button on the hardware. Building a new version: ----------------------- Makefiles for both Windows and Linux are provided. If you are using the "MinGW Developer Studio" from Parinyasoft (http://www.parinyasoft.com) you can make use of the provided project files (diy_loader-***.mdsp). Linux users most probably will have all necessary tools and header files, etc. installed. Windows users must install besides a C compiler the GTK development files (version 2.6.4 or higher). For execution the GTK runtime library is prerequisite (download from: http://gimp-win.sourceforge.net/stable.html) The background image was taken with kind permission of Clive "Max" Maxfield. Create the C source of the background image with the help of "gdk-pixbuf-csource": gdk-pixbuf-csource --raw --name=background_inline diy_calculator_626x402_2.png The gdk-pixbuf-csource program is part of the GTK source distribution. Linux users will have the executable installed. If not, you can download it from the download section at http://diycalculator.pcl.at. Simulator: ---------- There is a ROM Monitor simulator (diy_sim.exe) which simulates the ROM Monitor responses. It does not simulate the DIY Calculator CPU or hardware. You may connect two PCs via null modem, start on one PC the simulator and on the other the Loader Application. Now you can test the loader application. For more details see the README file in the Loader project directory. 15.Dec.2006 Johannes Hausensteiner