Search
lxdream.org :: lxdream/src/gui/gui_mmr.c :: diff
lxdream 0.9.1
released Jun 29
Download Now
filename src/gui/gui_mmr.c
changeset 1:eea311cfd33e
author nkeynes
date Sat Mar 13 00:03:32 2004 +0000 (20 years ago)
permissions -rw-r--r--
last change This commit was generated by cvs2svn to compensate for changes in r2,
which included commits to RCS files with non-trunk default branches.
file annotate diff log raw
1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/src/gui/gui_mmr.c Sat Mar 13 00:03:32 2004 +0000
1.3 @@ -0,0 +1,151 @@
1.4 +#include <stdint.h>
1.5 +#include <gnome.h>
1.6 +#include "interface.h"
1.7 +#include "gui.h"
1.8 +#include "mem.h"
1.9 +#include "mmio.h"
1.10 +
1.11 +GtkWidget *mmr_win;
1.12 +GtkNotebook *mmr_book;
1.13 +
1.14 +static void printbits( char *out, int nbits, uint32_t value )
1.15 +{
1.16 + if( nbits < 32 ) {
1.17 + int i;
1.18 + for( i=32; i>nbits; i-- ) {
1.19 + if( !(i % 8) ) *out++ = ' ';
1.20 + *out++ = ' ';
1.21 + }
1.22 + }
1.23 + while( nbits > 0 ) {
1.24 + *out++ = (value&(1<<--nbits) ? '1' : '0');
1.25 + if( !(nbits % 8) ) *out++ = ' ';
1.26 + }
1.27 + *out = '\0';
1.28 +}
1.29 +
1.30 +static void printhex( char *out, int nbits, uint32_t value )
1.31 +{
1.32 + char tmp[10], *p = tmp;
1.33 + int i;
1.34 +
1.35 + sprintf( tmp, "%08X", value );
1.36 + for( i=32; i>0; i-=4, p++ ) {
1.37 + if( i <= nbits ) *out++ = *p;
1.38 + else *out++ = ' ';
1.39 + }
1.40 + *out = '\0';
1.41 +}
1.42 +
1.43 +
1.44 +static GtkCList *create_mmr_page( char *name )
1.45 +{
1.46 + GtkCList *list;
1.47 + GtkWidget *scroll;
1.48 + GtkWidget *tab;
1.49 +
1.50 + scroll = gtk_scrolled_window_new(NULL, NULL);
1.51 + gtk_widget_show( scroll );
1.52 + gtk_scrolled_window_set_policy( GTK_SCROLLED_WINDOW(scroll),
1.53 + GTK_POLICY_AUTOMATIC, GTK_POLICY_ALWAYS );
1.54 + list = GTK_CLIST(gtk_clist_new(5));
1.55 + gtk_clist_set_column_width(list, 0, 60);
1.56 + gtk_clist_set_column_width(list, 1, 50);
1.57 + gtk_clist_set_column_width(list, 2, 60);
1.58 + gtk_clist_set_column_width(list, 3, 220);
1.59 + gtk_clist_set_column_width(list, 4, 160);
1.60 + gtk_clist_set_column_justification(list, 0, GTK_JUSTIFY_CENTER );
1.61 + gtk_clist_set_column_justification(list, 2, GTK_JUSTIFY_CENTER );
1.62 + gtk_clist_set_column_justification(list, 3, GTK_JUSTIFY_CENTER );
1.63 + gtk_clist_set_column_title(list, 0, "Address");
1.64 + gtk_clist_set_column_title(list, 1, "Register");
1.65 + gtk_clist_set_column_title(list, 2, "Value");
1.66 + gtk_clist_set_column_title(list, 3, "Bit Pattern");
1.67 + gtk_clist_set_column_title(list, 4, "Description");
1.68 + gtk_clist_column_titles_show(list);
1.69 + gtk_widget_set_style( GTK_WIDGET(list), fixed_list_style );
1.70 + gtk_widget_show( GTK_WIDGET(list) );
1.71 + tab = gtk_label_new(_(name));
1.72 + gtk_widget_show( tab );
1.73 + gtk_container_add( GTK_CONTAINER(scroll), GTK_WIDGET(list) );
1.74 + gtk_notebook_append_page( mmr_book, scroll, tab );
1.75 + gtk_object_set_data( GTK_OBJECT(mmr_win), name, list );
1.76 + return list;
1.77 +}
1.78 +
1.79 +void update_mmr_win( void )
1.80 +{
1.81 + int i,j, count = 0;
1.82 + GtkCList *page, *all_page;
1.83 + char data[10], bits[40];
1.84 +
1.85 + all_page = GTK_CLIST(gtk_object_get_data( GTK_OBJECT(mmr_win), "All" ));
1.86 +
1.87 + for( i=1; i < num_io_rgns; i++ ) {
1.88 + page = GTK_CLIST(gtk_object_get_data( GTK_OBJECT(mmr_win),
1.89 + io_rgn[i]->id ));
1.90 + for( j=0; io_rgn[i]->ports[j].id != NULL; j++ ) {
1.91 + if( *io_rgn[i]->ports[j].val !=
1.92 + *(uint32_t *)(io_rgn[i]->save_mem+io_rgn[i]->ports[j].offset)){
1.93 + int sz = io_rgn[i]->ports[j].width;
1.94 + /* Changed */
1.95 + printhex( data, sz, *io_rgn[i]->ports[j].val );
1.96 + printbits( bits, sz, *io_rgn[i]->ports[j].val );
1.97 +
1.98 + gtk_clist_set_text( page, j, 2, data );
1.99 + gtk_clist_set_text( page, j, 3, bits );
1.100 + gtk_clist_set_foreground( page, j, &clrChanged );
1.101 +
1.102 + gtk_clist_set_text( all_page, count, 2, data );
1.103 + gtk_clist_set_text( all_page, count, 3, bits );
1.104 + gtk_clist_set_foreground( all_page, count, &clrChanged );
1.105 +
1.106 + } else {
1.107 + gtk_clist_set_foreground( page, j, &clrNormal );
1.108 + gtk_clist_set_foreground( all_page, count, &clrNormal );
1.109 + }
1.110 + count++;
1.111 + }
1.112 + memcpy( io_rgn[i]->save_mem, io_rgn[i]->mem, PAGE_SIZE );
1.113 + }
1.114 +}
1.115 +
1.116 +void init_mmr_win( void )
1.117 +{
1.118 + int i, j;
1.119 + GtkCList *all_list;
1.120 + mmr_win = create_mmr_win();
1.121 + mmr_book = GTK_NOTEBOOK( gtk_object_get_data( GTK_OBJECT(mmr_win), "mmr_notebook" ));
1.122 +
1.123 + /* kill the dummy page glade insists on adding */
1.124 + gtk_notebook_remove_page( mmr_book, 0 );
1.125 +
1.126 + all_list = create_mmr_page( "All" );
1.127 + for( i=1; i < num_io_rgns; i++ ) {
1.128 + GtkCList *list = create_mmr_page( io_rgn[i]->id );
1.129 +
1.130 + for( j=0; io_rgn[i]->ports[j].id != NULL; j++ ) {
1.131 + int sz = io_rgn[i]->ports[j].width;
1.132 + char addr[10], data[10], bits[40];
1.133 + char *arr[] = { addr, io_rgn[i]->ports[j].id, data, bits,
1.134 + io_rgn[i]->ports[j].desc };
1.135 + sprintf( addr, "%08X",
1.136 + io_rgn[i]->base + io_rgn[i]->ports[j].offset );
1.137 + printhex( data, sz, *io_rgn[i]->ports[j].val );
1.138 + printbits( bits, io_rgn[i]->ports[j].width,
1.139 + *io_rgn[i]->ports[j].val );
1.140 + gtk_clist_append( list, arr );
1.141 + gtk_clist_append( all_list, arr );
1.142 + }
1.143 + }
1.144 +}
1.145 +
1.146 +void mmr_open_win( void )
1.147 +{
1.148 + gtk_widget_show( mmr_win );
1.149 +}
1.150 +
1.151 +void mmr_close_win( void )
1.152 +{
1.153 + gtk_widget_hide( mmr_win );
1.154 +}
.