Search
lxdream.org :: lxdream/src/gui/mmio_win.c :: diff
lxdream 0.9.1
released Jun 29
Download Now
filename src/gui/mmio_win.c
changeset 457:af605fd32c0b
prev455:3080881d00d4
next484:e2c1476f4c67
author nkeynes
date Sun Oct 21 11:38:02 2007 +0000 (13 years ago)
permissions -rw-r--r--
last change Finish updating debug gui window bits
file annotate diff log raw
1.1 --- a/src/gui/mmio_win.c Sun Oct 21 05:21:35 2007 +0000
1.2 +++ b/src/gui/mmio_win.c Sun Oct 21 11:38:02 2007 +0000
1.3 @@ -1,5 +1,5 @@
1.4 /**
1.5 - * $Id: mmio_win.c,v 1.8 2007-10-21 05:21:35 nkeynes Exp $
1.6 + * $Id: mmio_win.c,v 1.9 2007-10-21 11:38:02 nkeynes Exp $
1.7 *
1.8 * Implements the MMIO register viewing window
1.9 *
1.10 @@ -18,14 +18,15 @@
1.11
1.12 #include <stdint.h>
1.13 #include <gnome.h>
1.14 -#include "debugif.h"
1.15 -#include "debugcb.h"
1.16 #include "gui/gtkui.h"
1.17 #include "mem.h"
1.18 #include "mmio.h"
1.19
1.20 -GtkWidget *mmr_win;
1.21 -GtkNotebook *mmr_book;
1.22 +
1.23 +struct mmio_window_info {
1.24 + GtkWidget *window;
1.25 + GtkWidget *notebook;
1.26 +};
1.27
1.28 static void printbits( char *out, int nbits, uint32_t value )
1.29 {
1.30 @@ -56,8 +57,36 @@
1.31 *out = '\0';
1.32 }
1.33
1.34 -
1.35 -static GtkCList *create_mmr_page( char *name, struct mmio_region *io_rgn )
1.36 +
1.37 +
1.38 +
1.39 +gboolean
1.40 +on_mmio_delete_event (GtkWidget *widget,
1.41 + GdkEvent *event,
1.42 + gpointer user_data)
1.43 +{
1.44 + gtk_widget_hide(widget);
1.45 + return TRUE;
1.46 +}
1.47 +
1.48 +
1.49 +void on_mmio_close_clicked( GtkButton *button, gpointer user_data)
1.50 +{
1.51 + gtk_widget_hide( ((mmio_window_t)user_data)->window );
1.52 +}
1.53 +
1.54 +
1.55 +void on_trace_button_toggled (GtkToggleButton *button,
1.56 + gpointer user_data)
1.57 +{
1.58 + struct mmio_region *io_rgn = (struct mmio_region *)user_data;
1.59 + gboolean isActive = gtk_toggle_button_get_active(button);
1.60 + if( io_rgn != NULL ) {
1.61 + io_rgn->trace_flag = isActive ? 1 : 0;
1.62 + }
1.63 +}
1.64 +
1.65 +static GtkCList *mmio_window_add_page( mmio_window_t mmio, char *name, struct mmio_region *io_rgn )
1.66 {
1.67 GtkCList *list;
1.68 GtkWidget *scroll;
1.69 @@ -66,7 +95,6 @@
1.70 GtkVBox *vbox;
1.71
1.72 scroll = gtk_scrolled_window_new(NULL, NULL);
1.73 - gtk_widget_show( scroll );
1.74 gtk_scrolled_window_set_policy( GTK_SCROLLED_WINDOW(scroll),
1.75 GTK_POLICY_AUTOMATIC, GTK_POLICY_ALWAYS );
1.76 list = GTK_CLIST(gtk_clist_new(5));
1.77 @@ -85,38 +113,95 @@
1.78 gtk_clist_set_column_title(list, 4, "Description");
1.79 gtk_clist_column_titles_show(list);
1.80 gtk_widget_modify_font( GTK_WIDGET(list), gui_fixed_font );
1.81 - gtk_widget_show( GTK_WIDGET(list) );
1.82 tab = gtk_label_new(_(name));
1.83 - gtk_widget_show( tab );
1.84 gtk_container_add( GTK_CONTAINER(scroll), GTK_WIDGET(list) );
1.85
1.86 vbox = GTK_VBOX(gtk_vbox_new( FALSE, 0 ));
1.87 - gtk_widget_show( GTK_WIDGET(vbox) );
1.88 gtk_container_add( GTK_CONTAINER(vbox), GTK_WIDGET(scroll) );
1.89
1.90 trace_button = GTK_CHECK_BUTTON(gtk_check_button_new_with_label("Trace access"));
1.91 - gtk_widget_show( GTK_WIDGET(trace_button) );
1.92 gtk_container_add( GTK_CONTAINER(vbox), GTK_WIDGET(trace_button) );
1.93 gtk_box_set_child_packing( GTK_BOX(vbox), GTK_WIDGET(trace_button),
1.94 FALSE, FALSE, 0, GTK_PACK_START );
1.95 - gtk_notebook_append_page( mmr_book, GTK_WIDGET(vbox), tab );
1.96 - gtk_object_set_data( GTK_OBJECT(mmr_win), name, list );
1.97 + gtk_notebook_append_page( GTK_NOTEBOOK(mmio->notebook), GTK_WIDGET(vbox), tab );
1.98 + gtk_object_set_data( GTK_OBJECT(mmio->window), name, list );
1.99 g_signal_connect ((gpointer) trace_button, "toggled",
1.100 G_CALLBACK (on_trace_button_toggled),
1.101 io_rgn);
1.102 return list;
1.103 }
1.104
1.105 -void mmio_win_update( mmio_window_t win )
1.106 +
1.107 +
1.108 +mmio_window_t mmio_window_new( const gchar *title )
1.109 +{
1.110 + mmio_window_t mmio = g_malloc0( sizeof(struct mmio_window_info) );
1.111 +
1.112 + int i, j;
1.113 + GtkCList *all_list;
1.114 + GtkWidget *vbox1;
1.115 + GtkWidget *hbuttonbox1;
1.116 + GtkWidget *mmr_close;
1.117 +
1.118 + mmio->window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
1.119 + gtk_window_set_title (GTK_WINDOW (mmio->window), title);
1.120 + gtk_window_set_default_size (GTK_WINDOW (mmio->window), 600, 600);
1.121 +
1.122 + vbox1 = gtk_vbox_new (FALSE, 0);
1.123 + gtk_container_add (GTK_CONTAINER (mmio->window), vbox1);
1.124 +
1.125 + mmio->notebook = gtk_notebook_new ();
1.126 + gtk_box_pack_start (GTK_BOX (vbox1), mmio->notebook, TRUE, TRUE, 0);
1.127 + gtk_notebook_set_tab_pos (GTK_NOTEBOOK (mmio->notebook), GTK_POS_LEFT);
1.128 +
1.129 + hbuttonbox1 = gtk_hbutton_box_new ();
1.130 + gtk_box_pack_start (GTK_BOX (vbox1), hbuttonbox1, FALSE, TRUE, 0);
1.131 + gtk_box_set_spacing (GTK_BOX (hbuttonbox1), 30);
1.132 +
1.133 + mmr_close = gtk_button_new_with_mnemonic (_("Close"));
1.134 + gtk_container_add (GTK_CONTAINER (hbuttonbox1), mmr_close);
1.135 + GTK_WIDGET_SET_FLAGS (mmr_close, GTK_CAN_DEFAULT);
1.136 +
1.137 + /* Add the mmio register data */
1.138 + all_list = mmio_window_add_page( mmio, "All", NULL );
1.139 + for( i=0; i < num_io_rgns; i++ ) {
1.140 + GtkCList *list = mmio_window_add_page( mmio, io_rgn[i]->id, io_rgn[i] );
1.141 + for( j=0; io_rgn[i]->ports[j].id != NULL; j++ ) {
1.142 + int sz = io_rgn[i]->ports[j].width;
1.143 + char addr[10], data[10], bits[40];
1.144 + char *arr[] = { addr, io_rgn[i]->ports[j].id, data, bits,
1.145 + io_rgn[i]->ports[j].desc };
1.146 + sprintf( addr, "%08X",
1.147 + io_rgn[i]->base + io_rgn[i]->ports[j].offset );
1.148 + printhex( data, sz, *io_rgn[i]->ports[j].val );
1.149 + printbits( bits, io_rgn[i]->ports[j].width,
1.150 + *io_rgn[i]->ports[j].val );
1.151 + gtk_clist_append( list, arr );
1.152 + gtk_clist_append( all_list, arr );
1.153 + }
1.154 + }
1.155 +
1.156 + g_signal_connect ((gpointer) mmio->window, "delete_event",
1.157 + G_CALLBACK (on_mmio_delete_event),
1.158 + NULL);
1.159 + g_signal_connect ((gpointer) mmr_close, "clicked",
1.160 + G_CALLBACK (on_mmio_close_clicked),
1.161 + mmio);
1.162 +
1.163 + gtk_widget_show_all( mmio->window );
1.164 + return mmio;
1.165 +}
1.166 +
1.167 +void mmio_window_update( mmio_window_t mmio )
1.168 {
1.169 int i,j, count = 0;
1.170 GtkCList *page, *all_page;
1.171 char data[10], bits[40];
1.172
1.173 - all_page = GTK_CLIST(gtk_object_get_data( GTK_OBJECT(mmr_win), "All" ));
1.174 + all_page = GTK_CLIST(gtk_object_get_data( GTK_OBJECT(mmio->window), "All" ));
1.175
1.176 for( i=0; i < num_io_rgns; i++ ) {
1.177 - page = GTK_CLIST(gtk_object_get_data( GTK_OBJECT(mmr_win),
1.178 + page = GTK_CLIST(gtk_object_get_data( GTK_OBJECT(mmio->window),
1.179 io_rgn[i]->id ));
1.180 for( j=0; io_rgn[i]->ports[j].id != NULL; j++ ) {
1.181 if( *io_rgn[i]->ports[j].val !=
1.182 @@ -144,49 +229,12 @@
1.183 }
1.184 }
1.185
1.186 -void init_mmr_win( void )
1.187 +void mmio_window_show( mmio_window_t mmio, gboolean show )
1.188 {
1.189 - int i, j;
1.190 - GtkCList *all_list;
1.191 - mmr_win = create_mmr_win();
1.192 - mmr_book = GTK_NOTEBOOK( gtk_object_get_data( GTK_OBJECT(mmr_win), "mmr_notebook" ));
1.193 -
1.194 - /* kill the dummy page glade insists on adding */
1.195 - gtk_notebook_remove_page( mmr_book, 0 );
1.196 -
1.197 - all_list = create_mmr_page( "All", NULL );
1.198 - for( i=0; i < num_io_rgns; i++ ) {
1.199 - GtkCList *list = create_mmr_page( io_rgn[i]->id, io_rgn[i] );
1.200 -
1.201 - for( j=0; io_rgn[i]->ports[j].id != NULL; j++ ) {
1.202 - int sz = io_rgn[i]->ports[j].width;
1.203 - char addr[10], data[10], bits[40];
1.204 - char *arr[] = { addr, io_rgn[i]->ports[j].id, data, bits,
1.205 - io_rgn[i]->ports[j].desc };
1.206 - sprintf( addr, "%08X",
1.207 - io_rgn[i]->base + io_rgn[i]->ports[j].offset );
1.208 - printhex( data, sz, *io_rgn[i]->ports[j].val );
1.209 - printbits( bits, io_rgn[i]->ports[j].width,
1.210 - *io_rgn[i]->ports[j].val );
1.211 - gtk_clist_append( list, arr );
1.212 - gtk_clist_append( all_list, arr );
1.213 - }
1.214 + if( show ) {
1.215 + gtk_widget_show( mmio->window );
1.216 + } else {
1.217 + gtk_widget_hide( mmio->window );
1.218 }
1.219 }
1.220
1.221 -mmio_window_t mmio_window_new( const gchar *title )
1.222 -{
1.223 - init_mmr_win();
1.224 - gtk_widget_show( mmr_win );
1.225 - return NULL;
1.226 -}
1.227 -
1.228 -void mmio_window_show( mmio_window_t mmio, gboolean show )
1.229 -{
1.230 - gtk_widget_show( mmr_win );
1.231 -}
1.232 -
1.233 -void mmr_close_win( void )
1.234 -{
1.235 - gtk_widget_hide( mmr_win );
1.236 -}
.